Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2008-02-04 06:29:50 +0000
committerSergey Prigogin2008-02-04 06:29:50 +0000
commitcd0bd1eebbe41eb7789427c7e583c51a1dd620c6 (patch)
tree695d40882e36926b9a02005eed0f6768d4f16752 /core/org.eclipse.cdt.core/parser
parent8a38316b3305ad77ee32d4ae238527e06f8b8e56 (diff)
downloadorg.eclipse.cdt-cd0bd1eebbe41eb7789427c7e583c51a1dd620c6.tar.gz
org.eclipse.cdt-cd0bd1eebbe41eb7789427c7e583c51a1dd620c6.tar.xz
org.eclipse.cdt-cd0bd1eebbe41eb7789427c7e583c51a1dd620c6.zip
Added toString method.
Diffstat (limited to 'core/org.eclipse.cdt.core/parser')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java133
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPInstance.java16
2 files changed, 81 insertions, 68 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java
index 58c53135666..4880f70f3b6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@@ -51,11 +52,13 @@ import org.eclipse.cdt.internal.core.index.IIndexType;
* @author aniefer
*/
public class CPPClassTemplate extends CPPTemplateDefinition implements
-ICPPClassTemplate, ICPPClassType, ICPPInternalClassType, ICPPInternalClassTemplate, ICPPInternalClassTypeMixinHost {
+ ICPPClassTemplate, ICPPClassType, ICPPInternalClassType, ICPPInternalClassTemplate,
+ ICPPInternalClassTypeMixinHost {
- public static class CPPClassTemplateDelegate extends CPPClassType.CPPClassTypeDelegate implements ICPPClassTemplate, ICPPInternalClassTemplate {
- public CPPClassTemplateDelegate( ICPPUsingDeclaration usingDecl, ICPPClassType cls ) {
- super( usingDecl, cls );
+ public static class CPPClassTemplateDelegate extends CPPClassType.CPPClassTypeDelegate
+ implements ICPPClassTemplate, ICPPInternalClassTemplate {
+ public CPPClassTemplateDelegate(ICPPUsingDeclaration usingDecl, ICPPClassType cls) {
+ super(usingDecl, cls);
}
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {
return ((ICPPClassTemplate)getBinding()).getPartialSpecializations();
@@ -63,31 +66,31 @@ ICPPClassTemplate, ICPPClassType, ICPPInternalClassType, ICPPInternalClassTempla
public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
return ((ICPPClassTemplate)getBinding()).getTemplateParameters();
}
- public void addSpecialization( IType[] arguments, ICPPSpecialization specialization ) {
+ public void addSpecialization(IType[] arguments, ICPPSpecialization specialization) {
final IBinding binding = getBinding();
if (binding instanceof ICPPInternalBinding) {
- ((ICPPInternalTemplate)binding).addSpecialization( arguments, specialization );
+ ((ICPPInternalTemplate)binding).addSpecialization(arguments, specialization);
}
}
- public IBinding instantiate( IType[] arguments ) {
- return ((ICPPInternalTemplateInstantiator)getBinding()).instantiate( arguments );
+ public IBinding instantiate(IType[] arguments) {
+ return ((ICPPInternalTemplateInstantiator)getBinding()).instantiate(arguments);
}
- public ICPPSpecialization deferredInstance( IType[] arguments ) {
- return ((ICPPInternalTemplateInstantiator)getBinding()).deferredInstance( arguments );
+ public ICPPSpecialization deferredInstance(IType[] arguments) {
+ return ((ICPPInternalTemplateInstantiator)getBinding()).deferredInstance(arguments);
}
- public ICPPSpecialization getInstance( IType[] arguments ) {
- return ((ICPPInternalTemplateInstantiator)getBinding()).getInstance( arguments );
+ public ICPPSpecialization getInstance(IType[] arguments) {
+ return ((ICPPInternalTemplateInstantiator)getBinding()).getInstance(arguments);
}
- public void addPartialSpecialization( ICPPClassTemplatePartialSpecialization spec ) {
+ public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) {
final IBinding binding = getBinding();
if (binding instanceof ICPPInternalClassTemplate) {
- ((ICPPInternalClassTemplate)getBinding()).addPartialSpecialization( spec );
+ ((ICPPInternalClassTemplate)getBinding()).addPartialSpecialization(spec);
}
}
}
private class FindDefinitionAction extends CPPASTVisitor {
- private char [] nameArray = CPPClassTemplate.this.getNameCharArray();
+ private char[] nameArray = CPPClassTemplate.this.getNameCharArray();
public IASTName result = null;
{
@@ -97,27 +100,26 @@ ICPPClassTemplate, ICPPClassType, ICPPInternalClassType, ICPPInternalClassTempla
shouldVisitDeclarators = true;
}
- public int visit( IASTName name ){
- if( name instanceof ICPPASTTemplateId || name instanceof ICPPASTQualifiedName )
+ public int visit(IASTName name) {
+ if (name instanceof ICPPASTTemplateId || name instanceof ICPPASTQualifiedName)
return PROCESS_CONTINUE;
- char [] c = name.toCharArray();
- if( name.getParent() instanceof ICPPASTTemplateId )
+ char[] c = name.toCharArray();
+ if (name.getParent() instanceof ICPPASTTemplateId)
name = (IASTName) name.getParent();
- if( name.getParent() instanceof ICPPASTQualifiedName ){
- IASTName [] ns = ((ICPPASTQualifiedName)name.getParent()).getNames();
- if( ns[ ns.length - 1 ] != name )
+ if (name.getParent() instanceof ICPPASTQualifiedName) {
+ IASTName[] ns = ((ICPPASTQualifiedName)name.getParent()).getNames();
+ if (ns[ns.length - 1] != name)
return PROCESS_CONTINUE;
name = (IASTName) name.getParent();
}
- if( name.getParent() instanceof ICPPASTCompositeTypeSpecifier &&
- CharArrayUtils.equals( c, nameArray ) )
- {
+ if (name.getParent() instanceof ICPPASTCompositeTypeSpecifier &&
+ CharArrayUtils.equals(c, nameArray)) {
IBinding binding = name.resolveBinding();
- if( binding == CPPClassTemplate.this ){
- if( name instanceof ICPPASTQualifiedName ){
- IASTName [] ns = ((ICPPASTQualifiedName)name).getNames();
- name = ns[ ns.length - 1 ];
+ if (binding == CPPClassTemplate.this) {
+ if (name instanceof ICPPASTQualifiedName) {
+ IASTName[] ns = ((ICPPASTQualifiedName)name).getNames();
+ name = ns[ns.length - 1];
}
result = name;
return PROCESS_ABORT;
@@ -126,18 +128,18 @@ ICPPClassTemplate, ICPPClassType, ICPPInternalClassType, ICPPInternalClassTempla
return PROCESS_CONTINUE;
}
- public int visit( IASTDeclaration declaration ){
- if(declaration instanceof IASTSimpleDeclaration || declaration instanceof ICPPASTTemplateDeclaration)
+ public int visit(IASTDeclaration declaration) {
+ if (declaration instanceof IASTSimpleDeclaration || declaration instanceof ICPPASTTemplateDeclaration)
return PROCESS_CONTINUE;
return PROCESS_SKIP;
}
- public int visit( IASTDeclSpecifier declSpec ){
- return (declSpec instanceof ICPPASTCompositeTypeSpecifier ) ? PROCESS_CONTINUE : PROCESS_SKIP;
+ public int visit(IASTDeclSpecifier declSpec) {
+ return (declSpec instanceof ICPPASTCompositeTypeSpecifier) ? PROCESS_CONTINUE : PROCESS_SKIP;
}
- public int visit( IASTDeclarator declarator ) { return PROCESS_SKIP; }
+ public int visit(IASTDeclarator declarator) { return PROCESS_SKIP; }
}
- private ICPPClassTemplatePartialSpecialization [] partialSpecializations = null;
+ private ICPPClassTemplatePartialSpecialization[] partialSpecializations = null;
private ClassTypeMixin mixin;
public CPPClassTemplate(IASTName name) {
@@ -145,41 +147,41 @@ ICPPClassTemplate, ICPPClassType, ICPPInternalClassType, ICPPInternalClassTempla
this.mixin= new ClassTypeMixin(this);
}
- public ICPPSpecialization deferredInstance( IType [] arguments ){
- ICPPSpecialization instance = getInstance( arguments );
- if( instance == null ){
- instance = new CPPDeferredClassInstance( this, arguments );
- addSpecialization( arguments, instance );
+ public ICPPSpecialization deferredInstance(IType[] arguments) {
+ ICPPSpecialization instance = getInstance(arguments);
+ if (instance == null) {
+ instance = new CPPDeferredClassInstance(this, arguments);
+ addSpecialization(arguments, instance);
}
return instance;
}
- public void checkForDefinition(){
+ public void checkForDefinition() {
FindDefinitionAction action = new FindDefinitionAction();
- IASTNode node = CPPVisitor.getContainingBlockItem( declarations[0] ).getParent();
- while( node instanceof ICPPASTTemplateDeclaration )
+ IASTNode node = CPPVisitor.getContainingBlockItem(declarations[0]).getParent();
+ while(node instanceof ICPPASTTemplateDeclaration)
node = node.getParent();
- node.accept( action );
+ node.accept(action);
definition = action.result;
- if( definition == null ){
- node.getTranslationUnit().accept( action );
+ if (definition == null) {
+ node.getTranslationUnit().accept(action);
definition = action.result;
}
return;
}
- public void addPartialSpecialization( ICPPClassTemplatePartialSpecialization spec ){
- partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.append( ICPPClassTemplatePartialSpecialization.class, partialSpecializations, spec );
+ public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) {
+ partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.append(ICPPClassTemplatePartialSpecialization.class, partialSpecializations, spec);
}
- public ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier(){
- if( definition != null ){
+ public ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier() {
+ if (definition != null) {
IASTNode node = definition.getParent();
- if( node instanceof ICPPASTQualifiedName )
+ if (node instanceof ICPPASTQualifiedName)
node = node.getParent();
- if( node instanceof ICPPASTCompositeTypeSpecifier )
+ if (node instanceof ICPPASTCompositeTypeSpecifier)
return (ICPPASTCompositeTypeSpecifier) node;
}
return null;
@@ -202,7 +204,7 @@ ICPPClassTemplate, ICPPClassType, ICPPInternalClassType, ICPPInternalClassTempla
}
public int getKey() {
- if( definition != null ) {
+ if (definition != null) {
ICPPASTCompositeTypeSpecifier cts= getCompositeTypeSpecifier();
if (cts != null) {
return cts.getKey();
@@ -213,9 +215,9 @@ ICPPClassTemplate, ICPPClassType, ICPPInternalClassType, ICPPInternalClassTempla
}
}
- if( declarations != null && declarations.length > 0 ){
+ if (declarations != null && declarations.length > 0) {
IASTNode n = declarations[0].getParent();
- if( n instanceof ICPPASTElaboratedTypeSpecifier ){
+ if (n instanceof ICPPASTElaboratedTypeSpecifier) {
return ((ICPPASTElaboratedTypeSpecifier)n).getKind();
}
}
@@ -223,20 +225,16 @@ ICPPClassTemplate, ICPPClassType, ICPPInternalClassType, ICPPInternalClassTempla
return ICPPASTElaboratedTypeSpecifier.k_class;
}
-
-
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
- partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.trim( ICPPClassTemplatePartialSpecialization.class, partialSpecializations );
+ partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.trim(ICPPClassTemplatePartialSpecialization.class, partialSpecializations);
return partialSpecializations;
}
- public ICPPDelegate createDelegate( ICPPUsingDeclaration usingDecl ) {
- return new CPPClassTemplateDelegate( usingDecl, this );
+ public ICPPDelegate createDelegate(ICPPUsingDeclaration usingDecl) {
+ return new CPPClassTemplateDelegate(usingDecl, this);
}
- /* */
-
- public boolean isSameType( IType type ) {
+ public boolean isSameType(IType type) {
if (type == this)
return true;
if (type instanceof ITypedef || type instanceof IIndexType || type instanceof ICPPDelegate)
@@ -244,7 +242,7 @@ ICPPClassTemplate, ICPPClassType, ICPPInternalClassType, ICPPInternalClassTempla
return false;
}
- public ICPPBase [] getBases() {
+ public ICPPBase[] getBases() {
return mixin.getBases();
}
@@ -295,4 +293,11 @@ ICPPClassTemplate, ICPPClassType, ICPPInternalClassType, ICPPInternalClassTempla
}
return null;
}
+
+ /* (non-Javadoc)
+ * For debug purposes only
+ */
+ public String toString() {
+ return ASTTypeUtil.getType(this);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPInstance.java
index cc196a39c71..48bb7456713 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPInstance.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,6 +13,7 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
@@ -24,10 +25,10 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
* @author aniefer
*/
public abstract class CPPInstance extends CPPSpecialization implements ICPPTemplateInstance {
- private IType [] arguments;
+ private IType[] arguments;
- public CPPInstance( ICPPScope scope, IBinding orig, ObjectMap argMap, IType [] arguments ){
- super( orig, scope, argMap );
+ public CPPInstance(ICPPScope scope, IBinding orig, ObjectMap argMap, IType[] arguments) {
+ super(orig, scope, argMap);
this.arguments = arguments;
}
@@ -44,4 +45,11 @@ public abstract class CPPInstance extends CPPSpecialization implements ICPPTempl
public IType[] getArguments() {
return arguments;
}
+
+ /* (non-Javadoc)
+ * For debug purposes only
+ */
+ public String toString() {
+ return getName() + " <" + ASTTypeUtil.getTypeListString(arguments) + ">"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
}

Back to the top