Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2008-02-25 00:00:32 +0000
committerSergey Prigogin2008-02-25 00:00:32 +0000
commitbd4d1ba488af8d87a2023c50a78d668e7b0925d8 (patch)
tree782a1d82d81e27596ab91bd49c985bb6463db600 /core/org.eclipse.cdt.core
parenta2f9f9a4eb3228f55953b53ab40fb90529f298a9 (diff)
downloadorg.eclipse.cdt-bd4d1ba488af8d87a2023c50a78d668e7b0925d8.tar.gz
org.eclipse.cdt-bd4d1ba488af8d87a2023c50a78d668e7b0925d8.tar.xz
org.eclipse.cdt-bd4d1ba488af8d87a2023c50a78d668e7b0925d8.zip
toString methods and generics.
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java25
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java73
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDirective.java16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java63
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java401
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java54
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java354
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownBinding.java51
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClass.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java58
10 files changed, 556 insertions, 550 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java
index c21bd7714ee..b5e64464744 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java
@@ -25,6 +25,9 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier
private boolean isShort;
private boolean isLong;
+ /**
+ * @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier
+ */
public int getType() {
return type;
}
@@ -65,19 +68,19 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier
isShort = value;
}
- public boolean accept( ASTVisitor action ){
- if( action.shouldVisitDeclSpecifiers ){
- switch( action.visit( this ) ){
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
+ public boolean accept(ASTVisitor action) {
+ if (action.shouldVisitDeclSpecifiers) {
+ switch (action.visit(this)) {
+ case ASTVisitor.PROCESS_ABORT: return false;
+ case ASTVisitor.PROCESS_SKIP: return true;
+ default: break;
}
}
- if( action.shouldVisitDeclSpecifiers ){
- switch( action.leave( this ) ){
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
+ if (action.shouldVisitDeclSpecifiers) {
+ switch (action.leave(this)) {
+ case ASTVisitor.PROCESS_ABORT: return false;
+ case ASTVisitor.PROCESS_SKIP: return true;
+ default: break;
}
}
return true;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java
index dbfc1a5ab82..0c289191e09 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java
@@ -29,10 +29,11 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
* @author jcamelon
*/
public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, IASTAmbiguityParent {
-
private IASTName templateName;
+ private IASTNode[] templateArguments = null;
+ private IBinding binding = null;
+ private int fResolutionDepth = 0;
-
public CPPASTTemplateId() {
}
@@ -53,7 +54,7 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
}
public void addTemplateArgument(IASTTypeId typeId) {
- templateArguments = (IASTNode[]) ArrayUtil.append( IASTNode.class, templateArguments, typeId );
+ templateArguments = (IASTNode[]) ArrayUtil.append(IASTNode.class, templateArguments, typeId);
if (typeId != null) {
typeId.setParent(this);
typeId.setPropertyInParent(TEMPLATE_ID_ARGUMENT);
@@ -61,7 +62,7 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
}
public void addTemplateArgument(IASTExpression expression) {
- templateArguments = (IASTNode[]) ArrayUtil.append( IASTNode.class, templateArguments, expression );
+ templateArguments = (IASTNode[]) ArrayUtil.append(IASTNode.class, templateArguments, expression);
if (expression != null) {
expression.setParent(this);
expression.setPropertyInParent(TEMPLATE_ID_ARGUMENT);
@@ -69,61 +70,56 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
}
public IASTNode[] getTemplateArguments() {
- if( templateArguments == null ) return ICPPASTTemplateId.EMPTY_ARG_ARRAY;
- return (IASTNode[]) ArrayUtil.trim( IASTNode.class, templateArguments );
+ if (templateArguments == null) return ICPPASTTemplateId.EMPTY_ARG_ARRAY;
+ return (IASTNode[]) ArrayUtil.trim(IASTNode.class, templateArguments);
}
-
- private IASTNode [] templateArguments = null;
- private IBinding binding = null;
- private int fResolutionDepth= 0;
public IBinding resolveBinding() {
if (binding == null) {
// protect for infinite recursion
if (++fResolutionDepth > CPPASTName.MAX_RESOLUTION_DEPTH) {
binding= new CPPASTName.RecursionResolvingBinding(this);
- }
- else {
- binding = CPPTemplates.createBinding( this );
+ } else {
+ binding = CPPTemplates.createBinding(this);
}
}
-
- return binding;
+
+ return binding;
}
public IASTCompletionContext getCompletionContext() {
return null;
}
-
public char[] toCharArray() {
return templateName.toCharArray();
}
+
@Override
public String toString() {
return templateName.toString();
}
@Override
- public boolean accept( ASTVisitor action ){
- if( action.shouldVisitNames ){
- switch( action.visit( this ) ){
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
+ public boolean accept(ASTVisitor action) {
+ if (action.shouldVisitNames) {
+ switch(action.visit(this)) {
+ case ASTVisitor.PROCESS_ABORT: return false;
+ case ASTVisitor.PROCESS_SKIP: return true;
+ default: break;
}
}
- if( templateName != null ) if( !templateName.accept( action ) ) return false;
-
- IASTNode [] nodes = getTemplateArguments();
- for ( int i = 0; i < nodes.length; i++ ) {
- if( !nodes[i].accept( action ) ) return false;
+ if (templateName != null && !templateName.accept(action)) return false;
+
+ IASTNode[] nodes = getTemplateArguments();
+ for (int i = 0; i < nodes.length; i++) {
+ if (!nodes[i].accept(action)) return false;
}
- if( action.shouldVisitNames ){
- switch( action.leave( this ) ){
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
+ if (action.shouldVisitNames) {
+ switch(action.leave(this)) {
+ case ASTVisitor.PROCESS_ABORT: return false;
+ case ASTVisitor.PROCESS_SKIP: return true;
+ default: break;
}
}
return true;
@@ -138,7 +134,7 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
}
public int getRoleForName(IASTName n) {
- if( n == templateName )
+ if (n == templateName)
return r_reference;
return r_unclear;
}
@@ -149,11 +145,11 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
public void setBinding(IBinding binding) {
this.binding = binding;
- fResolutionDepth= 0;
+ fResolutionDepth = 0;
}
public void replace(IASTNode child, IASTNode other) {
- if( templateArguments == null ) return;
+ if (templateArguments == null) return;
for (int i = 0; i < templateArguments.length; ++i) {
if (child == templateArguments[i]) {
other.setPropertyInParent(child.getPropertyInParent());
@@ -162,20 +158,19 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
}
}
}
-
+
public boolean isDefinition() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
- if( role == IASTNameOwner.r_definition ) return true;
- return false;
+ return role == IASTNameOwner.r_definition;
}
return false;
}
public void incResolutionDepth() {
if (binding == null && ++fResolutionDepth > CPPASTName.MAX_RESOLUTION_DEPTH) {
- binding= new CPPASTName.RecursionResolvingBinding(this);
+ binding = new CPPASTName.RecursionResolvingBinding(this);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDirective.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDirective.java
index 66405b8ce85..bf323bad347 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDirective.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDirective.java
@@ -46,7 +46,7 @@ public class CPPASTUsingDirective extends CPPASTNode implements
qualifiedName.setParent(this);
qualifiedName.setPropertyInParent(QUALIFIED_NAME);
}
-
+
}
public boolean accept( ASTVisitor action ){
@@ -57,9 +57,9 @@ public class CPPASTUsingDirective extends CPPASTNode implements
default : break;
}
}
-
+
if( name != null ) if( !name.accept( action ) ) return false;
-
+
if( action.shouldVisitDeclarations ){
switch( action.leave( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
@@ -76,17 +76,17 @@ public class CPPASTUsingDirective extends CPPASTNode implements
return r_reference;
return r_unclear;
}
-
+
public IBinding[] findBindings(IASTName n, boolean isPrefix) {
IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix);
- List filtered = new ArrayList();
-
+ List<IBinding> filtered = new ArrayList<IBinding>();
+
for (int i = 0;i < bindings.length; i++) {
if (bindings[i] instanceof ICPPNamespace) {
filtered.add(bindings[i]);
}
}
-
- return (IBinding[]) filtered.toArray(new IBinding[filtered.size()]);
+
+ return filtered.toArray(new IBinding[filtered.size()]);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java
index 0ba059e556c..41bad61f301 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java
@@ -42,8 +42,8 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @param args
* @param arguments
*/
- public CPPClassInstance( ICPPScope scope, IBinding decl, ObjectMap argMap, IType[] args ) {
- super( scope, decl, argMap, args );
+ public CPPClassInstance(ICPPScope scope, IBinding decl, ObjectMap argMap, IType[] args) {
+ super(scope, decl, argMap, args);
}
/* (non-Javadoc)
@@ -51,17 +51,17 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
*/
public ICPPBase[] getBases() throws DOMException {
ICPPClassType cls = (ICPPClassType) getSpecializedBinding();
- if( cls != null ){
+ if (cls != null) {
ICPPBase[] result = null;
- ICPPBase [] bindings = cls.getBases();
+ ICPPBase[] bindings = cls.getBases();
for (int i = 0; i < bindings.length; i++) {
- ICPPBase specBinding = (ICPPBase) ((ICPPInternalBase)bindings[i]).clone();
+ ICPPBase specBinding = (ICPPBase) ((ICPPInternalBase) bindings[i]).clone();
IBinding base = bindings[i].getBaseClass();
if (base instanceof IType) {
IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap);
specBase = CPPSemantics.getUltimateType(specBase, false);
if (specBase instanceof IBinding) {
- ((ICPPInternalBase)specBinding).setBaseClass((IBinding)specBase);
+ ((ICPPInternalBase) specBinding).setBaseClass((IBinding) specBase);
}
result = (ICPPBase[]) ArrayUtil.append(ICPPBase.class, result, specBinding);
}
@@ -75,7 +75,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields()
*/
public IField[] getFields() throws DOMException {
- // TODO Auto-generated method stub
return null;
}
@@ -83,7 +82,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#findField(java.lang.String)
*/
public IField findField(String name) throws DOMException {
- // TODO Auto-generated method stub
return null;
}
@@ -91,7 +89,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredFields()
*/
public ICPPField[] getDeclaredFields() throws DOMException {
- // TODO Auto-generated method stub
return null;
}
@@ -99,7 +96,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getMethods()
*/
public ICPPMethod[] getMethods() throws DOMException {
- // TODO Auto-generated method stub
return null;
}
@@ -107,7 +103,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getAllDeclaredMethods()
*/
public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
- // TODO Auto-generated method stub
return null;
}
@@ -115,7 +110,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredMethods()
*/
public ICPPMethod[] getDeclaredMethods() throws DOMException {
- // TODO Auto-generated method stub
return null;
}
@@ -124,7 +118,7 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
*/
public ICPPConstructor[] getConstructors() throws DOMException {
CPPClassSpecializationScope scope = (CPPClassSpecializationScope) getCompositeScope();
- if( scope.isFullyCached() )
+ if (scope.isFullyCached())
return scope.getConstructors();
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
}
@@ -133,7 +127,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFriends()
*/
public IBinding[] getFriends() throws DOMException {
- // TODO Auto-generated method stub
return null;
}
@@ -141,15 +134,15 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
*/
public int getKey() throws DOMException {
- return ((ICPPClassType)getSpecializedBinding()).getKey();
+ return ((ICPPClassType) getSpecializedBinding()).getKey();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getCompositeScope()
*/
public IScope getCompositeScope() {
- if( instanceScope == null ){
- instanceScope = new CPPClassSpecializationScope( this );
+ if (instanceScope == null) {
+ instanceScope = new CPPClassSpecializationScope(this);
}
return instanceScope;
}
@@ -158,35 +151,35 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see java.lang.Object#clone()
*/
@Override
- public Object clone(){
- // TODO Auto-generated method stub
+ public Object clone() {
return this;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
- public boolean isSameType( IType type ) {
- if( type == this )
+ public boolean isSameType(IType type) {
+ if (type == this)
return true;
- if( type instanceof ITypedef || type instanceof IIndexType )
- return type.isSameType( this );
- if( type instanceof ICPPDeferredTemplateInstance && type instanceof ICPPClassType )
- return type.isSameType( this ); //the CPPDeferredClassInstance has some fuzziness
+ if (type instanceof ITypedef || type instanceof IIndexType)
+ return type.isSameType(this);
+ if (type instanceof ICPPDeferredTemplateInstance && type instanceof ICPPClassType)
+ return type.isSameType(this); // the CPPDeferredClassInstance has some fuzziness
- if( type instanceof ICPPTemplateInstance ){
+ if (type instanceof ICPPTemplateInstance) {
ICPPClassType ct1= (ICPPClassType) getSpecializedBinding();
- ICPPClassType ct2= (ICPPClassType) ((ICPPTemplateInstance)type).getTemplateDefinition();
- if(!ct1.isSameType(ct2))
+ ICPPClassType ct2= (ICPPClassType) ((ICPPTemplateInstance) type).getTemplateDefinition();
+ if (!ct1.isSameType(ct2))
return false;
- ObjectMap m1 = getArgumentMap(), m2 = ((ICPPTemplateInstance)type).getArgumentMap();
- if( m1 == null || m2 == null || m1.size() != m2.size())
+ ObjectMap m1 = getArgumentMap();
+ ObjectMap m2 = ((ICPPTemplateInstance) type).getArgumentMap();
+ if (m1 == null || m2 == null || m1.size() != m2.size())
return false;
- for( int i = 0; i < m1.size(); i++ ){
- IType t1 = (IType) m1.getAt( i );
- IType t2 = (IType) m2.getAt( i );
- if( t1 == null || ! t1.isSameType( t2 ) )
+ for (int i = 0; i < m1.size(); i++) {
+ IType t1 = (IType) m1.getAt(i);
+ IType t2 = (IType) m2.getAt(i);
+ if (t1 == null || !t1.isSameType(t2))
return false;
}
return true;
@@ -210,6 +203,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
@Override
public boolean equals(Object obj) {
- return obj instanceof ICPPClassType ? isSameType((ICPPClassType)obj) : false;
+ return obj instanceof ICPPClassType && isSameType((ICPPClassType) obj);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java
index b02dc2419b1..051fc783f89 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java
@@ -38,7 +38,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
@@ -57,177 +56,177 @@ import org.eclipse.cdt.core.parser.util.ObjectSet;
* @author aniefer
*/
public class CPPClassScope extends CPPScope implements ICPPClassScope {
- private static final char [] CONSTRUCTOR_KEY = "!!!CTOR!!!".toCharArray(); //$NON-NLS-1$
+ private static final char[] CONSTRUCTOR_KEY = "!!!CTOR!!!".toCharArray(); //$NON-NLS-1$
private ICPPMethod[] implicits = null;
-
- public CPPClassScope( ICPPASTCompositeTypeSpecifier physicalNode ) {
- super( physicalNode );
- ((CPPASTCompositeTypeSpecifier)physicalNode).setScope( this );
+
+ public CPPClassScope(ICPPASTCompositeTypeSpecifier physicalNode) {
+ super(physicalNode);
+ ((CPPASTCompositeTypeSpecifier) physicalNode).setScope(this);
createImplicitMembers();
}
// 12.1 The default constructor, copy constructor, copy assignment operator, and destructor are
//special member functions. The implementation will implicitly declare these member functions
//for a class type when the program does not declare them.
- private void createImplicitMembers(){
+ private void createImplicitMembers() {
//create bindings for the implicit members, if the user declared them then those declarations
//will resolve to these bindings.
ICPPASTCompositeTypeSpecifier compTypeSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
-
+
IASTName name = compTypeSpec.getName();
- if( name instanceof ICPPASTQualifiedName ){
- IASTName [] ns = ((ICPPASTQualifiedName) name).getNames();
- name = ns[ ns.length - 1 ];
+ if (name instanceof ICPPASTQualifiedName) {
+ IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
+ name = ns[ns.length - 1];
}
-
+
IBinding binding = name.resolveBinding();
- if( !(binding instanceof ICPPClassType ) )
+ if (!(binding instanceof ICPPClassType))
return;
-
+
ICPPClassType clsType = (ICPPClassType) binding;
- if( clsType instanceof ICPPClassTemplate ){
+ if (clsType instanceof ICPPClassTemplate) {
try {
- IBinding within = CPPTemplates.instantiateWithinClassTemplate( (ICPPClassTemplate) clsType );
+ IBinding within = CPPTemplates.instantiateWithinClassTemplate((ICPPClassTemplate) clsType);
if (within instanceof ICPPClassType)
clsType = (ICPPClassType)within;
- } catch ( DOMException e ) {
+ } catch (DOMException e) {
}
}
- char [] className = name.toCharArray();
-
- IParameter [] voidPs = new IParameter [] { new CPPParameter( CPPSemantics.VOID_TYPE ) };
- IType pType = new CPPReferenceType( new CPPQualifierType( clsType, true, false ) );
- IParameter [] ps = new IParameter [] { new CPPParameter( pType ) };
-
+ char[] className = name.toCharArray();
+
+ IParameter[] voidPs = new IParameter[] { new CPPParameter(CPPSemantics.VOID_TYPE) };
+ IType pType = new CPPReferenceType(new CPPQualifierType(clsType, true, false));
+ IParameter[] ps = new IParameter[] { new CPPParameter(pType) };
+
int i= 0;
- ImplicitsAnalysis ia= new ImplicitsAnalysis( compTypeSpec );
+ ImplicitsAnalysis ia= new ImplicitsAnalysis(compTypeSpec);
implicits= new ICPPMethod[ia.getImplicitsToDeclareCount()];
- if( !ia.hasUserDeclaredConstructor() ) {
+ if (!ia.hasUserDeclaredConstructor()) {
//default constructor: A(void)
- ICPPMethod m = new CPPImplicitConstructor( this, className, voidPs );
- implicits[i++]=m;
- addBinding( m );
+ ICPPMethod m = new CPPImplicitConstructor(this, className, voidPs);
+ implicits[i++] = m;
+ addBinding(m);
}
- if( !ia.hasUserDeclaredCopyConstructor() ) {
- //copy constructor: A( const A & )
+ if (!ia.hasUserDeclaredCopyConstructor()) {
+ //copy constructor: A(const A &)
- ICPPMethod m = new CPPImplicitConstructor( this, className, ps );
+ ICPPMethod m = new CPPImplicitConstructor(this, className, ps);
implicits[i++]=m;
- addBinding( m );
+ addBinding(m);
}
- if( !ia.hasUserDeclaredCopyAssignmentOperator() ) {
- //copy assignment operator: A& operator = ( const A & )
- IType refType = new CPPReferenceType( clsType );
- ICPPMethod m = new CPPImplicitMethod( this, OverloadableOperator.ASSIGN.toCharArray(), refType, ps );
- implicits[i++]=m;
- addBinding( m );
+ if (!ia.hasUserDeclaredCopyAssignmentOperator()) {
+ //copy assignment operator: A& operator = (const A &)
+ IType refType = new CPPReferenceType(clsType);
+ ICPPMethod m = new CPPImplicitMethod(this, OverloadableOperator.ASSIGN.toCharArray(), refType, ps);
+ implicits[i++] = m;
+ addBinding(m);
}
- if( !ia.hasUserDeclaredDestructor() ) {
+ if (!ia.hasUserDeclaredDestructor()) {
//destructor: ~A()
- char [] dtorName = CharArrayUtils.concat( "~".toCharArray(), className ); //$NON-NLS-1$
- ICPPMethod m = new CPPImplicitMethod( this, dtorName, new CPPBasicType( IBasicType.t_unspecified, 0 ), voidPs );
- implicits[i++]=m;
- addBinding( m );
+ char[] dtorName = CharArrayUtils.concat("~".toCharArray(), className); //$NON-NLS-1$
+ ICPPMethod m = new CPPImplicitMethod(this, dtorName, new CPPBasicType(IBasicType.t_unspecified, 0), voidPs);
+ implicits[i++] = m;
+ addBinding(m);
}
}
-
+
public IScope getParent() {
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
IASTName compName = compType.getName();
- if( compName instanceof ICPPASTQualifiedName ){
- IASTName [] ns = ((ICPPASTQualifiedName)compName).getNames();
- compName = ns[ ns.length - 1 ];
+ if (compName instanceof ICPPASTQualifiedName) {
+ IASTName[] ns = ((ICPPASTQualifiedName)compName).getNames();
+ compName = ns[ns.length - 1];
}
- return CPPVisitor.getContainingScope( compName );
+ return CPPVisitor.getContainingScope(compName);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#addBinding(org.eclipse.cdt.core.dom.ast.IBinding)
*/
public void addBinding(IBinding binding) {
- if( binding instanceof ICPPConstructor ){
- addConstructor( binding );
+ if (binding instanceof ICPPConstructor) {
+ addConstructor(binding);
return;
}
super.addBinding(binding);
}
public void addName(IASTName name) {
- if( name instanceof ICPPASTQualifiedName )
+ if (name instanceof ICPPASTQualifiedName)
return;
-
+
IASTNode parent = name.getParent();
- if( parent instanceof IASTDeclarator ){
- if( CPPVisitor.isConstructor( this, (IASTDeclarator) parent ) ){
- addConstructor( name );
+ if (parent instanceof IASTDeclarator) {
+ if (CPPVisitor.isConstructor(this, (IASTDeclarator) parent)) {
+ addConstructor(name);
return;
}
}
- super.addName( name );
+ super.addName(name);
}
- private void addConstructor( Object constructor ){
- if( bindings == null )
+ private void addConstructor(Object constructor) {
+ if (bindings == null)
bindings = new CharArrayObjectMap(1);
-
- if( constructor instanceof IASTName && ((IASTName)constructor).getBinding() != null ){
+
+ if (constructor instanceof IASTName && ((IASTName)constructor).getBinding() != null) {
constructor = ((IASTName)constructor).getBinding();
}
-
- Object o = bindings.get( CONSTRUCTOR_KEY );
- if( o != null ){
- if( o instanceof ObjectSet ){
- ((ObjectSet)o).put( constructor );
+
+ Object o = bindings.get(CONSTRUCTOR_KEY);
+ if (o != null) {
+ if (o instanceof ObjectSet) {
+ ((ObjectSet)o).put(constructor);
} else {
ObjectSet set = new ObjectSet(2);
- set.put( o );
- set.put( constructor );
- bindings.put( CONSTRUCTOR_KEY, set );
+ set.put(o);
+ set.put(constructor);
+ bindings.put(CONSTRUCTOR_KEY, set);
}
} else {
- bindings.put( CONSTRUCTOR_KEY, constructor );
+ bindings.put(CONSTRUCTOR_KEY, constructor);
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getBinding(int, char[])
*/
- public IBinding getBinding( IASTName name, boolean resolve, IIndexFileSet fileSet ) throws DOMException {
- char [] c = name.toCharArray();
-
+ public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException {
+ char[] c = name.toCharArray();
+
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
IASTName compName = compType.getName();
- if( compName instanceof ICPPASTQualifiedName ){
- IASTName [] ns = ((ICPPASTQualifiedName)compName).getNames();
- compName = ns[ ns.length - 1 ];
+ if (compName instanceof ICPPASTQualifiedName) {
+ IASTName[] ns = ((ICPPASTQualifiedName)compName).getNames();
+ compName = ns[ns.length - 1];
}
- if( CharArrayUtils.equals( c, compName.toCharArray() ) ){
- if( isConstructorReference( name ) ){
- return CPPSemantics.resolveAmbiguities( name, getConstructors( bindings, resolve, name ) );
+ if (CharArrayUtils.equals(c, compName.toCharArray())) {
+ if (isConstructorReference(name)) {
+ return CPPSemantics.resolveAmbiguities(name, getConstructors(bindings, resolve, name));
}
//9.2 ... The class-name is also inserted into the scope of the class itself
return compName.resolveBinding();
}
- return super.getBinding( name, resolve, fileSet);
+ return super.getBinding(name, resolve, fileSet);
}
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) throws DOMException {
- char [] c = name.toCharArray();
-
+ char[] c = name.toCharArray();
+
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
IASTName compName = compType.getName();
- if( compName instanceof ICPPASTQualifiedName ){
- IASTName [] ns = ((ICPPASTQualifiedName)compName).getNames();
- compName = ns[ ns.length - 1 ];
+ if (compName instanceof ICPPASTQualifiedName) {
+ IASTName[] ns = ((ICPPASTQualifiedName)compName).getNames();
+ compName = ns[ns.length - 1];
}
IBinding[] result = null;
- if( (!prefixLookup && CharArrayUtils.equals( c, compName.toCharArray() ))
- || (prefixLookup && CharArrayUtils.equals(compName.toCharArray(), 0, c.length, c, true)) ){
- if( isConstructorReference( name ) ){
- result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, getConstructors( bindings, resolve, name ));
+ if ((!prefixLookup && CharArrayUtils.equals(c, compName.toCharArray()))
+ || (prefixLookup && CharArrayUtils.equals(compName.toCharArray(), 0, c.length, c, true))) {
+ if (isConstructorReference(name)) {
+ result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, getConstructors(bindings, resolve, name));
}
//9.2 ... The class-name is also inserted into the scope of the class itself
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, compName.resolveBinding());
@@ -235,100 +234,101 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
return (IBinding[]) ArrayUtil.trim(IBinding.class, result);
}
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result,
- super.getBindings( name, resolve, prefixLookup, fileSet ));
+ super.getBindings(name, resolve, prefixLookup, fileSet));
return (IBinding[]) ArrayUtil.trim(IBinding.class, result);
}
-
+
static protected boolean shouldResolve(boolean force, IASTName candidate, IASTName forName) {
- if(!force || candidate == forName)
+ if (!force || candidate == forName)
return false;
- if(forName == null)
+ if (forName == null)
return true;
- if(!forName.isReference() && !CPPSemantics.declaredBefore(candidate, forName, false))
+ if (!forName.isReference() && !CPPSemantics.declaredBefore(candidate, forName, false))
return false;
return true;
}
-
- protected ICPPConstructor [] getConstructors( boolean forceResolve ){
- return getConstructors( bindings, forceResolve, null );
+
+ protected ICPPConstructor[] getConstructors(boolean forceResolve) {
+ return getConstructors(bindings, forceResolve, null);
}
- static protected ICPPConstructor [] getConstructors( CharArrayObjectMap bindings, boolean forceResolve ) {
+ static protected ICPPConstructor[] getConstructors(CharArrayObjectMap bindings, boolean forceResolve) {
return getConstructors(bindings, forceResolve, null);
}
- static protected ICPPConstructor [] getConstructors( CharArrayObjectMap bindings, boolean forceResolve, IASTName forName ){
- if( bindings == null )
+ static protected ICPPConstructor[] getConstructors(CharArrayObjectMap bindings, boolean forceResolve, IASTName forName) {
+ if (bindings == null)
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
-
- Object o = bindings.get( CONSTRUCTOR_KEY );
- if( o != null ){
+
+ Object o = bindings.get(CONSTRUCTOR_KEY);
+ if (o != null) {
IBinding binding = null;
- if( o instanceof ObjectSet ) {
+ if (o instanceof ObjectSet) {
ObjectSet set = (ObjectSet) o;
- IBinding [] bs = null;
- for( int i = 0; i < set.size(); i++ ){
- Object obj = set.keyAt( i );
- if( obj instanceof IASTName ){
- IASTName n = (IASTName) obj;
+ IBinding[] bs = null;
+ for (int i = 0; i < set.size(); i++) {
+ Object obj = set.keyAt(i);
+ if (obj instanceof IASTName) {
+ IASTName n = (IASTName) obj;
binding = shouldResolve(forceResolve, n, forName) ? n.resolveBinding() : n.getBinding();
- if( binding != null ) {
- set.remove( n );
- set.put( binding );
+ if (binding != null) {
+ set.remove(n);
+ set.put(binding);
i--;
continue;
}
- } else if( obj instanceof ICPPConstructor )
- bs = (IBinding[]) ArrayUtil.append( ICPPConstructor.class, bs, obj );
- }
- return (ICPPConstructor[]) ArrayUtil.trim( ICPPConstructor.class, bs );
- } else if( o instanceof IASTName ){
- if( shouldResolve(forceResolve, (IASTName) o, forName) || ((IASTName)o).getBinding() != null ){
+ } else if (obj instanceof ICPPConstructor) {
+ bs = (IBinding[]) ArrayUtil.append(ICPPConstructor.class, bs, obj);
+ }
+ }
+ return (ICPPConstructor[]) ArrayUtil.trim(ICPPConstructor.class, bs);
+ } else if (o instanceof IASTName) {
+ if (shouldResolve(forceResolve, (IASTName) o, forName) || ((IASTName)o).getBinding() != null) {
binding = ((IASTName)o).resolveBinding();
- bindings.put( CONSTRUCTOR_KEY, binding );
+ bindings.put(CONSTRUCTOR_KEY, binding);
}
- } else if( o instanceof IBinding ){
+ } else if (o instanceof IBinding) {
binding = (IBinding) o;
}
- if( binding != null && binding instanceof ICPPConstructor){
+ if (binding != null && binding instanceof ICPPConstructor) {
return new ICPPConstructor[] { (ICPPConstructor) binding };
}
}
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
*/
public IBinding[] find(String name) throws DOMException {
- char [] n = name.toCharArray();
+ char[] n = name.toCharArray();
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
IASTName compName = compType.getName();
- if( compName instanceof ICPPASTQualifiedName ){
- IASTName [] ns = ((ICPPASTQualifiedName)compName).getNames();
- compName = ns[ ns.length - 1 ];
+ if (compName instanceof ICPPASTQualifiedName) {
+ IASTName[] ns = ((ICPPASTQualifiedName)compName).getNames();
+ compName = ns[ns.length - 1];
}
- if(CharArrayUtils.equals(compName.toCharArray(), n)) {
+ if (CharArrayUtils.equals(compName.toCharArray(), n)) {
return new IBinding[] {getClassType()};
}
-
+
return super.find(name);
}
-
- public static boolean isConstructorReference( IASTName name ){
- if( name.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY ) return false;
+
+ public static boolean isConstructorReference(IASTName name) {
+ if (name.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY) return false;
IASTNode node = name.getParent();
- if( node instanceof ICPPASTTemplateId )
+ if (node instanceof ICPPASTTemplateId)
node = node.getParent();
- if( node instanceof ICPPASTQualifiedName ){
- IASTName [] ns = ((ICPPASTQualifiedName)node).getNames();
- if( ns[ ns.length - 1 ] == name )
+ if (node instanceof ICPPASTQualifiedName) {
+ IASTName[] ns = ((ICPPASTQualifiedName)node).getNames();
+ if (ns[ns.length - 1] == name)
node = node.getParent();
else
return false;
}
- if( node instanceof IASTDeclSpecifier ){
+ if (node instanceof IASTDeclSpecifier) {
IASTNode parent = node.getParent();
- if( parent instanceof IASTTypeId && parent.getParent() instanceof ICPPASTNewExpression )
+ if (parent instanceof IASTTypeId && parent.getParent() instanceof ICPPASTNewExpression)
return true;
return false;
}
@@ -344,15 +344,15 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
if (binding instanceof ICPPClassType)
return (ICPPClassType) binding;
- return new CPPClassType.CPPClassTypeProblem( compSpec.getName(), IProblemBinding.SEMANTIC_BAD_SCOPE, compSpec.getName().toCharArray() );
+ return new CPPClassType.CPPClassTypeProblem(compSpec.getName(), IProblemBinding.SEMANTIC_BAD_SCOPE, compSpec.getName().toCharArray());
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getImplicitMethods()
*/
public ICPPMethod[] getImplicitMethods() {
- if( implicits == null )
- implicits = new ICPPMethod[] { new CPPMethod.CPPMethodProblem( null, IProblemBinding.SEMANTIC_INVALID_TYPE, CPPSemantics.EMPTY_NAME_ARRAY ) };
+ if (implicits == null)
+ implicits = new ICPPMethod[] { new CPPMethod.CPPMethodProblem(null, IProblemBinding.SEMANTIC_INVALID_TYPE, CPPSemantics.EMPTY_NAME_ARRAY) };
return implicits;
}
@@ -361,20 +361,20 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
*/
public IName getScopeName() {
IASTNode node = getPhysicalNode();
- if( node instanceof ICPPASTCompositeTypeSpecifier ){
+ if (node instanceof ICPPASTCompositeTypeSpecifier) {
return ((ICPPASTCompositeTypeSpecifier)node).getName();
}
return null;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
*/
public void removeBinding(IBinding binding) {
- if( binding instanceof ICPPConstructor ){
- removeBinding( CONSTRUCTOR_KEY, binding );
+ if (binding instanceof ICPPConstructor) {
+ removeBinding(CONSTRUCTOR_KEY, binding);
} else {
- removeBinding( binding.getNameCharArray(), binding );
+ removeBinding(binding.getNameCharArray(), binding);
}
}
}
@@ -382,31 +382,31 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
/**
* Helps analysis of the class declaration for user declared members relevant
* to deciding which implicit bindings to declare.
- *
+ *
* @see chapter 12 of the ISO specification
- */
+ */
class ImplicitsAnalysis {
private boolean hasUserDeclaredConstructor;
private boolean hasUserDeclaredCopyConstructor;
private boolean hasUserDeclaredCopyAssignmentOperator;
private boolean hasUserDeclaredDestructor;
-
- ImplicitsAnalysis( ICPPASTCompositeTypeSpecifier compSpec ) {
+
+ ImplicitsAnalysis(ICPPASTCompositeTypeSpecifier compSpec) {
ICPPASTFunctionDeclarator[] ctors= getUserDeclaredCtorOrDtor(compSpec, true);
-
+
hasUserDeclaredConstructor= ctors.length> 0;
hasUserDeclaredCopyConstructor= false;
hasUserDeclaredCopyAssignmentOperator= false;
hasUserDeclaredDestructor= getUserDeclaredCtorOrDtor(compSpec, false).length>0;
-
- outer: for(int i=0; i<ctors.length; i++) {
+
+ outer: for (int i=0; i<ctors.length; i++) {
ICPPASTFunctionDeclarator dcltor= ctors[i];
- IASTParameterDeclaration [] ps = dcltor.getParameters();
- if( ps.length >= 1 ){
- if(paramHasTypeReferenceToTheAssociatedClassType(ps[0], compSpec.getName().getRawSignature())) {
- // and all remaining arguments have initialisers
- for(int j=1; j<ps.length; j++) {
- if( ps[j].getDeclarator().getInitializer() == null ) {
+ IASTParameterDeclaration[] ps = dcltor.getParameters();
+ if (ps.length >= 1) {
+ if (paramHasTypeReferenceToTheAssociatedClassType(ps[0], compSpec.getName().getRawSignature())) {
+ // and all remaining arguments have initializers
+ for (int j = 1; j < ps.length; j++) {
+ if (ps[j].getDeclarator().getInitializer() == null) {
continue outer;
}
}
@@ -414,89 +414,88 @@ class ImplicitsAnalysis {
}
}
}
-
+
boolean hasUserDeclaredCAO= getUserDeclaredCopyAssignmentOperators(compSpec).length > 0;
hasUserDeclaredCopyAssignmentOperator= hasUserDeclaredCAO;
}
-
+
public int getImplicitsToDeclareCount() {
return (!hasUserDeclaredDestructor ? 1 : 0)
+ (!hasUserDeclaredConstructor ? 1 : 0)
+ (!hasUserDeclaredCopyConstructor ? 1 : 0)
+ (!hasUserDeclaredCopyAssignmentOperator ? 1 : 0);
}
-
- private static ICPPASTFunctionDeclarator[] getUserDeclaredCtorOrDtor( ICPPASTCompositeTypeSpecifier compSpec, boolean constructor ) {
+
+ private static ICPPASTFunctionDeclarator[] getUserDeclaredCtorOrDtor(ICPPASTCompositeTypeSpecifier compSpec, boolean constructor) {
List<ICPPASTFunctionDeclarator> result= new ArrayList<ICPPASTFunctionDeclarator>();
- IASTDeclaration [] members = compSpec.getMembers();
- char [] name = compSpec.getName().toCharArray();
+ IASTDeclaration[] members = compSpec.getMembers();
+ char[] name = compSpec.getName().toCharArray();
IASTDeclarator dcltor = null;
IASTDeclSpecifier spec = null;
- for( int i = 0; i < members.length; i++ ){
- if( members[i] instanceof IASTSimpleDeclaration ){
- IASTDeclarator [] dtors = ((IASTSimpleDeclaration)members[i]).getDeclarators();
- if( dtors.length == 0 || dtors.length > 1 )
+ for (int i = 0; i < members.length; i++) {
+ if (members[i] instanceof IASTSimpleDeclaration) {
+ IASTDeclarator[] dtors = ((IASTSimpleDeclaration)members[i]).getDeclarators();
+ if (dtors.length == 0 || dtors.length > 1)
continue;
dcltor = dtors[0];
spec = ((IASTSimpleDeclaration)members[i]).getDeclSpecifier();
- } else if( members[i] instanceof IASTFunctionDefinition ){
+ } else if (members[i] instanceof IASTFunctionDefinition) {
dcltor = ((IASTFunctionDefinition)members[i]).getDeclarator();
spec = ((IASTFunctionDefinition)members[i]).getDeclSpecifier();
}
-
-
- if( !(dcltor instanceof ICPPASTFunctionDeclarator) || !(spec instanceof IASTSimpleDeclSpecifier) ||
- ((IASTSimpleDeclSpecifier)spec).getType() != IASTSimpleDeclSpecifier.t_unspecified)
- {
+
+
+ if (!(dcltor instanceof ICPPASTFunctionDeclarator) || !(spec instanceof IASTSimpleDeclSpecifier) ||
+ ((IASTSimpleDeclSpecifier)spec).getType() != IASTSimpleDeclSpecifier.t_unspecified) {
continue;
}
-
+
boolean nameEquals= false;
- if(constructor) {
- nameEquals= CharArrayUtils.equals( dcltor.getName().toCharArray(), name );
+ if (constructor) {
+ nameEquals= CharArrayUtils.equals(dcltor.getName().toCharArray(), name);
} else {
char[] cname= dcltor.getName().toCharArray();
- if(cname.length>0 && cname[0]=='~') {
- nameEquals= CharArrayUtils.equals( cname, 1, name.length, name );
+ if (cname.length > 0 && cname[0] == '~') {
+ nameEquals= CharArrayUtils.equals(cname, 1, name.length, name);
}
}
-
- if(!nameEquals)
+
+ if (!nameEquals)
continue;
-
+
result.add((ICPPASTFunctionDeclarator) dcltor);
}
return result.toArray(new ICPPASTFunctionDeclarator[result.size()]);
}
-
- private static ICPPASTFunctionDeclarator[] getUserDeclaredCopyAssignmentOperators( ICPPASTCompositeTypeSpecifier compSpec ) {
+
+ private static ICPPASTFunctionDeclarator[] getUserDeclaredCopyAssignmentOperators(ICPPASTCompositeTypeSpecifier compSpec) {
List<ICPPASTFunctionDeclarator> result= new ArrayList<ICPPASTFunctionDeclarator>();
- IASTDeclaration [] members = compSpec.getMembers();
+ IASTDeclaration[] members = compSpec.getMembers();
IASTDeclarator dcltor = null;
- for( int i = 0; i < members.length; i++ ){
- if( members[i] instanceof IASTSimpleDeclaration ){
- IASTDeclarator [] dtors = ((IASTSimpleDeclaration)members[i]).getDeclarators();
- if( dtors.length == 0 || dtors.length > 1 )
+ for (int i = 0; i < members.length; i++) {
+ if (members[i] instanceof IASTSimpleDeclaration) {
+ IASTDeclarator[] dtors = ((IASTSimpleDeclaration)members[i]).getDeclarators();
+ if (dtors.length == 0 || dtors.length > 1)
continue;
dcltor = dtors[0];
- } else if( members[i] instanceof IASTFunctionDefinition ){
+ } else if (members[i] instanceof IASTFunctionDefinition) {
dcltor = ((IASTFunctionDefinition)members[i]).getDeclarator();
}
- if( !(dcltor instanceof ICPPASTFunctionDeclarator) ||
- !CharArrayUtils.equals( dcltor.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray() ) )
+ if (!(dcltor instanceof ICPPASTFunctionDeclarator) ||
+ !CharArrayUtils.equals(dcltor.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray()))
{
continue;
}
-
- IASTParameterDeclaration [] ps = ((ICPPASTFunctionDeclarator)dcltor).getParameters();
- if(ps.length != 1 || !paramHasTypeReferenceToTheAssociatedClassType(ps[0], null))
+
+ IASTParameterDeclaration[] ps = ((ICPPASTFunctionDeclarator)dcltor).getParameters();
+ if (ps.length != 1 || !paramHasTypeReferenceToTheAssociatedClassType(ps[0], null))
continue;
-
+
result.add((ICPPASTFunctionDeclarator)dcltor);
}
return result.toArray(new ICPPASTFunctionDeclarator[result.size()]);
}
-
+
/**
* @param compSpec the name the parameter must have in order to match, or null for any name
* @param dec
@@ -506,10 +505,10 @@ class ImplicitsAnalysis {
private static boolean paramHasTypeReferenceToTheAssociatedClassType(IASTParameterDeclaration dec, String name) {
boolean result= false;
IASTDeclarator pdtor= dec.getDeclarator();
- if(pdtor.getPointerOperators().length==1 && pdtor.getPointerOperators()[0] instanceof ICPPASTReferenceOperator) {
- if(dec.getDeclSpecifier() instanceof ICPPASTNamedTypeSpecifier) {
+ if (pdtor.getPointerOperators().length == 1 && pdtor.getPointerOperators()[0] instanceof ICPPASTReferenceOperator) {
+ if (dec.getDeclSpecifier() instanceof ICPPASTNamedTypeSpecifier) {
ICPPASTNamedTypeSpecifier nts= (ICPPASTNamedTypeSpecifier) dec.getDeclSpecifier();
- if(name==null || name.equals(nts.getName().getRawSignature())) {
+ if (name == null || name.equals(nts.getName().getRawSignature())) {
result= true;
}
}
@@ -528,7 +527,7 @@ class ImplicitsAnalysis {
public boolean hasUserDeclaredCopyAssignmentOperator() {
return hasUserDeclaredCopyAssignmentOperator;
}
-
+
public boolean hasUserDeclaredDestructor() {
return hasUserDeclaredDestructor;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java
index 9c0d303d7c1..782b22b5b9b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java
@@ -34,14 +34,14 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
implements ICPPClassTemplate, ICPPInternalClassTemplate {
private ObjectMap instances = null;
-
+
/**
* @param specialized
* @param scope
* @param argumentMap
*/
- public CPPClassTemplateSpecialization(IBinding specialized,
- ICPPScope scope, ObjectMap argumentMap) {
+ public CPPClassTemplateSpecialization(IBinding specialized, ICPPScope scope,
+ ObjectMap argumentMap) {
super(specialized, scope, argumentMap);
}
@@ -61,31 +61,31 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
}
public void addSpecialization(IType[] arguments, ICPPSpecialization specialization) {
- if( instances == null )
+ if (instances == null)
instances = new ObjectMap(2);
- instances.put( arguments, specialization );
+ instances.put(arguments, specialization);
}
-
- public ICPPSpecialization getInstance( IType [] arguments ) {
- if( instances == null )
+
+ public ICPPSpecialization getInstance(IType[] arguments) {
+ if (instances == null)
return null;
-
+
int found = -1;
- for( int i = 0; i < instances.size(); i++ ){
- IType [] args = (IType[]) instances.keyAt( i );
- if( args.length == arguments.length ){
+ for (int i = 0; i < instances.size(); i++) {
+ IType[] args = (IType[]) instances.keyAt(i);
+ if (args.length == arguments.length) {
int j = 0;
for(; j < args.length; j++) {
- if( !( args[j].isSameType( arguments[j] ) ) )
+ if (!(args[j].isSameType(arguments[j])))
break;
}
- if( j == args.length ){
+ if (j == args.length) {
found = i;
break;
}
}
}
- if( found != -1 ){
+ if (found != -1) {
return (ICPPSpecialization) instances.getAt(found);
}
return null;
@@ -93,28 +93,32 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
public IBinding instantiate(IType[] arguments) {
ICPPTemplateDefinition template = null;
-
+
try {
- template = CPPTemplates.matchTemplatePartialSpecialization( this, arguments );
+ template = CPPTemplates.matchTemplatePartialSpecialization(this, arguments);
} catch (DOMException e) {
return e.getProblem();
}
-
- if( template instanceof IProblemBinding )
+
+ if (template instanceof IProblemBinding) {
return template;
- if( template != null && template instanceof ICPPClassTemplatePartialSpecialization ){
- return ((ICPPInternalTemplateInstantiator)template).instantiate( arguments );
}
-
- return CPPTemplates.instantiateTemplate( this, arguments, argumentMap );
+ if (template != null && template instanceof ICPPClassTemplatePartialSpecialization) {
+ return ((ICPPInternalTemplateInstantiator) template).instantiate(arguments);
+ }
+
+ return CPPTemplates.instantiateTemplate(this, arguments, argumentMap);
}
public ICPPSpecialization deferredInstance(IType[] arguments) {
- // TODO Auto-generated method stub
return null;
}
- public void addPartialSpecialization( ICPPClassTemplatePartialSpecialization spec ){
+ public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) {
//should not occur
}
+
+ public String toString() {
+ return getName();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java
index b11d8911758..0a293062347 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java
@@ -98,7 +98,7 @@ public class CPPTemplates {
return ((ICPPASTParameterDeclaration)param).getDeclarator().getName();
return null;
}
-
+
private static ICPPTemplateDefinition getContainingTemplate(ICPPASTTemplateParameter param) {
IASTNode parent = param.getParent();
IBinding binding = null;
@@ -107,22 +107,22 @@ public class CPPTemplates {
// if (name != null) {
// if (name instanceof ICPPASTTemplateId && !(name.getParent() instanceof ICPPASTQualifiedName))
// name = ((ICPPASTTemplateId)name).getTemplateName();
-//
+//
// binding = name.resolveBinding();
// }
ICPPASTTemplateDeclaration[] templates = new ICPPASTTemplateDeclaration[] { (ICPPASTTemplateDeclaration) parent };
-
- while(parent.getParent() instanceof ICPPASTTemplateDeclaration) {
+
+ while (parent.getParent() instanceof ICPPASTTemplateDeclaration) {
parent = parent.getParent();
templates = (ICPPASTTemplateDeclaration[]) ArrayUtil.append(ICPPASTTemplateDeclaration.class, templates, parent);
}
templates = (ICPPASTTemplateDeclaration[]) ArrayUtil.trim(ICPPASTTemplateDeclaration.class, templates);
-
+
ICPPASTTemplateDeclaration templateDeclaration = templates[0];
IASTDeclaration decl = templateDeclaration.getDeclaration();
while(decl instanceof ICPPASTTemplateDeclaration)
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
-
+
IASTName name = null;
if (decl instanceof IASTSimpleDeclaration) {
IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) decl;
@@ -148,7 +148,7 @@ public class CPPTemplates {
}
if (name == null)
return null;
-
+
if (name instanceof ICPPASTQualifiedName) {
int idx = templates.length;
int i = 0;
@@ -176,7 +176,7 @@ public class CPPTemplates {
public static IBinding createBinding(ICPPASTTemplateParameter templateParameter) {
ICPPTemplateDefinition template = getContainingTemplate(templateParameter);
-
+
IBinding binding = null;
if (template instanceof CPPTemplateTemplateParameter) {
binding = ((CPPTemplateTemplateParameter)template).resolveTemplateParameter(templateParameter);
@@ -206,7 +206,7 @@ public class CPPTemplates {
}
}
}
-
+
return binding;
}
@@ -220,7 +220,7 @@ public class CPPTemplates {
}
node = node.getParent();
}
-
+
return null;
}
@@ -241,24 +241,24 @@ public class CPPTemplates {
while(!(decl instanceof IASTDeclaration))
decl = decl.getParent();
decl = decl.getParent();
-
+
if (decl instanceof ICPPASTExplicitTemplateInstantiation &&
parent instanceof ICPPASTElaboratedTypeSpecifier && segment != 0) {
return createClassExplicitInstantiation((ICPPASTElaboratedTypeSpecifier) parent);
} else if (((parent instanceof ICPPASTElaboratedTypeSpecifier &&
decl instanceof ICPPASTTemplateDeclaration) ||
- parent instanceof ICPPASTCompositeTypeSpecifier) &&
+ parent instanceof ICPPASTCompositeTypeSpecifier) &&
segment != 0) {
return createClassSpecialization((ICPPASTDeclSpecifier) parent);
} else if (parent instanceof ICPPASTFunctionDeclarator && segment != 0) {
return createFunctionSpecialization(id);
}
-
+
//a reference: class or function template?
IBinding template = null;
if (parent instanceof ICPPASTNamedTypeSpecifier ||
parent instanceof ICPPASTElaboratedTypeSpecifier ||
- parent instanceof ICPPASTBaseSpecifier ||
+ parent instanceof ICPPASTBaseSpecifier ||
segment == 0) {
//class template
IASTName templateName = id.getTemplateName();
@@ -273,7 +273,7 @@ public class CPPTemplates {
} else if (template instanceof ICPPSpecialization && !(template instanceof ICPPTemplateDefinition)) {
template = ((ICPPSpecialization)template).getSpecializedBinding();
}
-
+
if (template != null && template instanceof ICPPInternalTemplateInstantiator) {
IASTNode[] args = id.getTemplateArguments();
IType[] types = CPPTemplates.createTypeArray(args);
@@ -288,7 +288,7 @@ public class CPPTemplates {
templateName.setBinding(((ICPPTemplateInstance)template).getTemplateDefinition());
}
}
-
+
return template;
}
@@ -300,9 +300,9 @@ public class CPPTemplates {
}
ICPPASTTemplateId id = (ICPPASTTemplateId) name;
IBinding template = id.getTemplateName().resolveBinding();
- if (!(template instanceof ICPPClassTemplate))
+ if (!(template instanceof ICPPClassTemplate))
return null; //TODO: problem?
-
+
ICPPClassTemplate classTemplate = (ICPPClassTemplate) template;
IType[] args = createTypeArray(id.getTemplateArguments());
if (classTemplate instanceof ICPPInternalTemplateInstantiator) {
@@ -318,21 +318,21 @@ public class CPPTemplates {
name = ((ICPPASTElaboratedTypeSpecifier)compSpec).getName();
else if (compSpec instanceof ICPPASTCompositeTypeSpecifier)
name = ((ICPPASTCompositeTypeSpecifier)compSpec).getName();
- else
+ else
return null;
-
+
if (name instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName)name).getNames();
name = ns[ns.length - 1];
}
ICPPASTTemplateId id = (ICPPASTTemplateId) name;
-
+
IBinding binding = id.getTemplateName().resolveBinding();
- if (!(binding instanceof ICPPClassTemplate))
+ if (!(binding instanceof ICPPClassTemplate))
return null; //TODO: problem?
-
+
ICPPClassTemplate template = (ICPPClassTemplate) binding;
-
+
IBinding spec = null;
ICPPASTTemplateDeclaration templateDecl = getTemplateDeclaration(id);
if (templateDecl instanceof ICPPASTTemplateSpecialization) {
@@ -369,7 +369,7 @@ public class CPPTemplates {
((ICPPInternalBinding)spec).addDefinition(id);
}
return spec;
- }
+ }
//else partial specialization
//CPPClassTemplate template = (CPPClassTemplate) binding;
ICPPClassTemplatePartialSpecialization[] specializations = null;
@@ -385,19 +385,19 @@ public class CPPTemplates {
}
}
}
-
+
if (spec != null) {
if (spec instanceof ICPPInternalBinding)
((ICPPInternalBinding)spec).addDefinition(id);
return spec;
}
-
+
spec = new CPPClassTemplatePartialSpecialization(id);
if (template instanceof ICPPInternalClassTemplate)
((ICPPInternalClassTemplate)template).addPartialSpecialization((ICPPClassTemplatePartialSpecialization) spec);
return spec;
}
-
+
protected static IBinding createFunctionSpecialization(IASTName name) {
CPPSemantics.LookupData data = new CPPSemantics.LookupData(name);
data.forceQualified = true;
@@ -419,14 +419,14 @@ public class CPPTemplates {
return new ProblemBinding(name, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, name.toCharArray());
if (function instanceof IProblemBinding)
return function;
-
+
if (name instanceof ICPPASTTemplateId) {
((ICPPASTTemplateId)name).getTemplateName().setBinding(function);
}
IASTNode parent = name.getParent();
while(parent instanceof IASTName)
parent = parent.getParent();
-
+
IASTParameterDeclaration[] ps = ((ICPPASTFunctionDeclarator)parent).getParameters();
Object[] map_types;
try {
@@ -437,7 +437,7 @@ public class CPPTemplates {
if (map_types != null) {
while(!(parent instanceof IASTDeclaration))
parent = parent.getParent();
-
+
ICPPSpecialization spec = null;
if (parent.getParent() instanceof ICPPASTExplicitTemplateInstantiation) {
spec = ((ICPPInternalTemplateInstantiator)function).getInstance((IType[])map_types[1]);
@@ -450,15 +450,15 @@ public class CPPTemplates {
spec = new CPPConstructorSpecialization(function, scope, (ObjectMap) map_types[0]);
else if (function instanceof ICPPMethod)
spec = new CPPMethodSpecialization(function, scope, (ObjectMap) map_types[0]);
- else
+ else
spec = new CPPFunctionSpecialization(function, scope, (ObjectMap) map_types[0]);
}
-
+
if (spec instanceof ICPPInternalBinding) {
if (parent instanceof IASTSimpleDeclaration)
((ICPPInternalBinding)spec).addDeclaration(name);
else if (parent instanceof IASTFunctionDefinition)
- ((ICPPInternalBinding)spec).addDefinition(name);
+ ((ICPPInternalBinding)spec).addDefinition(name);
}
}
if (function instanceof ICPPInternalTemplate)
@@ -466,9 +466,9 @@ public class CPPTemplates {
return spec;
}
//TODO problem?
- return null;
+ return null;
}
-
+
static protected ICPPFunctionTemplate resolveTemplateFunctions(Object[] items, IASTName name) {
if (items == null)
return null;
@@ -476,7 +476,7 @@ public class CPPTemplates {
IBinding temp = null;
for (int i = 0; i < items.length; i++) {
Object o = items[i];
-
+
if (o instanceof IASTName) {
temp = ((IASTName) o).resolveBinding();
if (temp == null)
@@ -486,24 +486,24 @@ public class CPPTemplates {
} else {
continue;
}
-
+
if (temp instanceof ICPPTemplateInstance)
temp = ((ICPPTemplateInstance)temp).getTemplateDefinition();
if (temp instanceof ICPPFunctionTemplate)
templates = (ICPPFunctionTemplate[]) ArrayUtil.append(ICPPFunctionTemplate.class, templates, temp);
}
-
+
if (templates == null)
return null;
-
+
IType[] templateArguments = null;
-
+
if (name instanceof ICPPASTTemplateId) {
templateArguments = createTypeArray(((ICPPASTTemplateId)name).getTemplateArguments());
}
int numArgs = (templateArguments != null) ? templateArguments.length : 0;
-
-
+
+
if (name.getParent() instanceof IASTName)
name = (IASTName) name.getParent();
IASTNode n = name.getParent();
@@ -512,26 +512,26 @@ public class CPPTemplates {
}
ICPPASTFunctionDeclarator fdtor = (ICPPASTFunctionDeclarator) n;
IType[] functionParameters = createTypeArray(fdtor.getParameters());
-
+
ICPPFunctionTemplate result = null;
outer: for (int i = 0; i < templates.length && templates[i] != null; i++) {
ICPPFunctionTemplate tmpl = templates[i];
-
+
ObjectMap map = ObjectMap.EMPTY_MAP;
try {
map = deduceTemplateArguments(tmpl, functionParameters);
} catch (DOMException e) {
}
-
+
if (map == null)
- continue;
+ continue;
ICPPTemplateParameter[] params = null;
try {
params = tmpl.getTemplateParameters();
} catch (DOMException e) {
continue;
}
-
+
int numParams = params.length;
IType arg = null;
for (int j = 0; j < numParams; j++) {
@@ -555,29 +555,30 @@ public class CPPTemplates {
//made it this far, its a match
if (result != null) {
return new CPPFunctionTemplate.CPPFunctionTemplateProblem(name, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, name.toCharArray());
- }
+ }
result = tmpl;
}
-
+
return result;
}
-
+
/**
- * return Object[] of { ObjectMap, IType[] }
+ * return Object[] of { ObjectMap, IType[] }
* @param primaryTemplate
* @param ps
* @param specArgs
* @return
* @throws DOMException
*/
- static protected Object[] deduceTemplateFunctionArguments(ICPPFunctionTemplate primaryTemplate, IASTParameterDeclaration[] ps, IASTNode[] specArgs) throws DOMException
+ static protected Object[] deduceTemplateFunctionArguments(ICPPFunctionTemplate primaryTemplate,
+ IASTParameterDeclaration[] ps, IASTNode[] specArgs) throws DOMException
{
ICPPTemplateParameter[] templateParameters = primaryTemplate.getTemplateParameters();
IType[] arguments = createTypeArray(specArgs);
IType[] result = new IType[templateParameters.length];
-
+
ObjectMap map = null;
-
+
if (arguments.length == result.length) {
map = new ObjectMap(result.length);
for (int i = 0; i < templateParameters.length; i++) {
@@ -586,7 +587,7 @@ public class CPPTemplates {
}
return new Object[] { map, result };
}
-
+
//else need to deduce some arguments
IType[] paramTypes = createTypeArray(ps);
map = deduceTemplateArguments(primaryTemplate, paramTypes);
@@ -600,15 +601,15 @@ public class CPPTemplates {
} else if (map.containsKey(param)) {
arg = (IType) map.get(param);
}
-
+
if (arg == null || !matchTemplateParameterAndArgument(param, arg, map))
return null;
-
+
result[i] = arg;
}
return new Object[] { map, result };
}
-
+
return null;
}
@@ -630,7 +631,7 @@ public class CPPTemplates {
}
return instance;
}
-
+
public static ICPPSpecialization createSpecialization(ICPPScope scope, IBinding decl, ObjectMap argMap) {
ICPPSpecialization spec = null;
if (decl instanceof ICPPClassTemplate) {
@@ -665,7 +666,7 @@ public class CPPTemplates {
public static IType instantiateType(IType type, ObjectMap argMap) {
if (argMap == null)
return type;
-
+
IType newType = type;
IType temp = null;
if (type instanceof IFunctionType) {
@@ -681,7 +682,8 @@ public class CPPTemplates {
}
} catch (DOMException e) {
}
- newType = new CPPFunctionType(ret, params, ((ICPPFunctionType)type).isConst(), ((ICPPFunctionType)type).isVolatile());
+ newType = new CPPFunctionType(ret, params, ((ICPPFunctionType)type).isConst(),
+ ((ICPPFunctionType)type).isVolatile());
} else if (type instanceof ITypedef) {
// Typedef requires special treatment (bug 213861).
try {
@@ -716,15 +718,15 @@ public class CPPTemplates {
binding = e.getProblem();
}
if (binding instanceof IType)
- newType = (IType) binding;
+ newType = (IType) binding;
}
-
+
return newType;
}
public static ICPPASTTemplateDeclaration getTemplateDeclaration(IASTName name) {
if (name == null) return null;
-
+
IASTNode parent = name.getParent();
while(parent instanceof IASTName) {
parent = parent.getParent();
@@ -741,7 +743,7 @@ public class CPPTemplates {
} else {
return null;
}
-
+
if (parent instanceof ICPPASTTemplateDeclaration) {
ICPPASTTemplateDeclaration templateDecl = (ICPPASTTemplateDeclaration) parent;
while(templateDecl.getParent() instanceof ICPPASTTemplateDeclaration)
@@ -780,19 +782,19 @@ public class CPPTemplates {
}
return null;
}
-
+
public static IASTName getTemplateName(ICPPASTTemplateDeclaration templateDecl) {
if (templateDecl == null) return null;
-
+
ICPPASTTemplateDeclaration decl = templateDecl;
while(decl.getParent() instanceof ICPPASTTemplateDeclaration)
- decl = (ICPPASTTemplateDeclaration) decl.getParent();
+ decl = (ICPPASTTemplateDeclaration) decl.getParent();
IASTDeclaration nestedDecl = templateDecl.getDeclaration();
while(nestedDecl instanceof ICPPASTTemplateDeclaration) {
nestedDecl = ((ICPPASTTemplateDeclaration)nestedDecl).getDeclaration();
}
-
+
IASTName name = null;
if (nestedDecl instanceof IASTSimpleDeclaration) {
IASTSimpleDeclaration simple = (IASTSimpleDeclaration) nestedDecl;
@@ -838,7 +840,7 @@ public class CPPTemplates {
return null;
}
-
+
private static class ClearBindingAction extends CPPASTVisitor {
public ObjectSet bindings = null;
public ClearBindingAction(ObjectSet bindings) {
@@ -888,11 +890,11 @@ public class CPPTemplates {
ICPPASTTemplateDeclaration templateDecl = getTemplateDeclaration(name);
if (templateDecl == null)
return false;
-
+
ICPPASTTemplateParameter[] templateParams = templateDecl.getTemplateParameters();
if (defParams.length != templateParams.length)
return false;
-
+
ObjectSet bindingsToClear = null;
for (int i = 0; i < templateParams.length; i++) {
IASTName tn = getTemplateParameterName(templateParams[i]);
@@ -905,7 +907,7 @@ public class CPPTemplates {
((ICPPInternalBinding)defParams[i]).addDeclaration(tn);
bindingsToClear.put(defParams[i]);
}
-
+
boolean result = false;
IASTNode parent = name.getParent();
if (parent instanceof ICPPASTFunctionDeclarator) {
@@ -953,22 +955,22 @@ public class CPPTemplates {
result = CharArrayUtils.equals(definition.getNameCharArray(), name.toCharArray());
}
}
-
+
if (bindingsToClear != null && !result) {
ClearBindingAction action = new ClearBindingAction(bindingsToClear);
templateDecl.accept(action);
}
-
+
return result;
}
-
+
static public IType[] createTypeArray(Object[] params) {
if (params == null)
return IType.EMPTY_TYPE_ARRAY;
-
+
if (params instanceof IType[])
return (IType[]) params;
-
+
IType[] result = new IType[params.length];
for (int i = 0; i < params.length; i++) {
if (params[i] instanceof IASTNode) {
@@ -983,27 +985,28 @@ public class CPPTemplates {
}
return result;
}
-
- static protected IFunction[] selectTemplateFunctions(ObjectSet templates, Object[] functionArguments, IASTName name) {//IASTNode[] templateArguments) {
+
+ static protected IFunction[] selectTemplateFunctions(ObjectSet templates,
+ Object[] functionArguments, IASTName name) {//IASTNode[] templateArguments) {
if (templates == null || templates.size() == 0)
return null;
-
+
IFunction[] instances = null;
-
+
int size = templates.size();
-
+
int numTemplateArgs = 0;
IASTNode[] templateArguments = null;
if (name instanceof ICPPASTTemplateId) {
templateArguments = ((ICPPASTTemplateId)name).getTemplateArguments();
numTemplateArgs = templateArguments.length;
}
-
+
IType[] fnArgs = createTypeArray(functionArguments);
-
+
outer: for (int idx = 0; idx < size; idx++) {
ICPPFunctionTemplate template = (ICPPFunctionTemplate) templates.keyAt(idx);
-
+
ObjectMap map = null;
try {
map = deduceTemplateArguments(template, fnArgs);
@@ -1012,7 +1015,7 @@ public class CPPTemplates {
}
if (map == null)
continue;
-
+
ICPPTemplateParameter[] templateParams = null;
try {
templateParams = template.getTemplateParameters();
@@ -1020,12 +1023,12 @@ public class CPPTemplates {
continue outer;
}
int numTemplateParams = templateParams.length;
-
+
IType[] instanceArgs = null;
for (int i = 0; i < numTemplateParams; i++) {
IType arg = (i < numTemplateArgs) ? CPPVisitor.createType(templateArguments[i]) : null;
IType mapped = (IType) map.get(templateParams[i]);
-
+
if (arg != null && mapped != null) {
if (arg.isSameType(mapped))
instanceArgs = (IType[]) ArrayUtil.append(IType.class, instanceArgs, arg);
@@ -1053,7 +1056,7 @@ public class CPPTemplates {
}
}
instanceArgs = (IType[]) ArrayUtil.append(IType.class, instanceArgs, def);
- } else {
+ } else {
continue outer;
}
} else {
@@ -1065,18 +1068,18 @@ public class CPPTemplates {
if (temp != null)
instances = (IFunction[]) ArrayUtil.append(IFunction.class, instances, temp);
}
-
+
return (IFunction[]) ArrayUtil.trim(IFunction.class, instances);
}
-
+
/**
- *
+ *
* @param template
* @param args
* @return
- *
- * A type that is specified in terms of template parameters (P) is compared with an actual
- * type (A), and an attempt is made to find template argument vaules that will make P,
+ *
+ * A type that is specified in terms of template parameters (P) is compared with an actual
+ * type (A), and an attempt is made to find template argument vaules that will make P,
* after substitution of the deduced values, compatible with A.
* @throws DOMException
*/
@@ -1091,7 +1094,7 @@ public class CPPTemplates {
if (arguments == null /*|| functionParameters.length != arguments.length*/) {
return null;
}
-
+
int numParams = functionParameters.length;
int numArgs = arguments.length;
ObjectMap map = new ObjectMap(numParams);
@@ -1100,16 +1103,16 @@ public class CPPTemplates {
return null;
}
}
-
- return map;
+
+ return map;
}
-
+
/**
* 14.8.2.1-2 If P is a cv-qualified type, the top level cv-qualifiers of P's type are ignored for type
* deduction. If P is a reference type, the type referred to by P is used for Type deduction.
* @param pSymbol
* @return
- */
+ */
static private IType getParameterTypeForDeduction(IType pType) {
IType result = pType;
try {
@@ -1125,13 +1128,13 @@ public class CPPTemplates {
}
return result;
}
-
+
/**
* 14.8.2.1-2
* if P is not a reference type
* - If A is an array type, the pointer type produced by the array-to-pointer conversion is used instead
* - If A is a function type, the pointer type produced by the function-to-pointer conversion is used instead
- * - If A is a cv-qualified type, the top level cv-qualifiers are ignored for type deduction
+ * - If A is a cv-qualified type, the top level cv-qualifiers are ignored for type deduction
* @param aInfo
* @return
*/
@@ -1154,18 +1157,18 @@ public class CPPTemplates {
} else if (aType instanceof CPPPointerType) {
result = ((CPPPointerType)aType).stripQualifiers();
}
- } catch(DOMException e) {
+ } catch (DOMException e) {
result = e.getProblem();
}
}
-
+
return result;
}
static private boolean expressionsEquivalent(IASTExpression p, IASTExpression a) {
if (p == null)
return true;
-
+
if (p instanceof IASTLiteralExpression && a instanceof IASTLiteralExpression) {
return p.toString().equals(a.toString ());
}
@@ -1175,7 +1178,7 @@ public class CPPTemplates {
boolean pIsAReferenceType = (p instanceof ICPPReferenceType);
p = getParameterTypeForDeduction(p);
a = getArgumentTypeForDeduction(a, pIsAReferenceType);
-
+
if (p instanceof IBasicType) {
if (p.isSameType(a) && a instanceof IBasicType) {
return expressionsEquivalent(((IBasicType)p).getValue(), ((IBasicType)a).getValue());
@@ -1189,10 +1192,10 @@ public class CPPTemplates {
} else if (p instanceof ICPPPointerToMemberType) {
if (!(a instanceof ICPPPointerToMemberType))
return false;
-
+
if (!deduceTemplateArgument(map, ((ICPPPointerToMemberType)p).getMemberOfClass(), ((ICPPPointerToMemberType)a).getMemberOfClass()))
return false;
-
+
p = ((ICPPPointerToMemberType)p).getType();
p = ((ICPPPointerToMemberType)a).getType();
} else if (p instanceof IPointerType) {
@@ -1216,7 +1219,7 @@ public class CPPTemplates {
if (pParams.length != aParams.length)
return false;
for (int i = 0; i < pParams.length; i++) {
- if (!deduceTemplateArgument(map, pParams[i], aParams[i]))
+ if (!deduceTemplateArgument(map, pParams[i], aParams[i]))
return false;
}
return true;
@@ -1224,7 +1227,7 @@ public class CPPTemplates {
if (map.containsKey(p)) {
IType current = (IType)map.get(p);
return current.isSameType(a);
- }
+ }
if (a == null)
return false;
map.put(p, a);
@@ -1243,7 +1246,7 @@ public class CPPTemplates {
return false;
for (int i = 0; i < pArgs.length; i++) {
IType t = (IType) aMap.get(aParams[i]);
- if (t == null || !deduceTemplateArgument(map, pArgs[i], t))
+ if (t == null || !deduceTemplateArgument(map, pArgs[i], t))
return false;
}
} else {
@@ -1251,7 +1254,7 @@ public class CPPTemplates {
if (aArgs.length != pArgs.length)
return false;
for (int i = 0; i < pArgs.length; i++) {
- if (!deduceTemplateArgument(map, pArgs[i], aArgs[i]))
+ if (!deduceTemplateArgument(map, pArgs[i], aArgs[i]))
return false;
}
}
@@ -1264,10 +1267,10 @@ public class CPPTemplates {
return false;
}
-
+
/**
* transform a function template for use in partial ordering, as described in the
- * spec 14.5.5.2-3
+ * spec 14.5.5.2-3
* @param template
* @return
* -for each type template parameter, synthesize a unique type and substitute that for each
@@ -1300,50 +1303,50 @@ public class CPPTemplates {
}
return args;
}
-
+
static protected int orderTemplateFunctions(ICPPFunctionTemplate f1, ICPPFunctionTemplate f2) throws DOMException {
//Using the transformed parameter list, perform argument deduction against the other
//function template
IType[] args = createArgsForFunctionTemplateOrdering(f1);
ICPPFunction function = (ICPPFunction) ((ICPPInternalTemplateInstantiator)f1).instantiate(args);
-
+
ObjectMap m1 = null;
if (function != null)
m1 = deduceTemplateArguments(f2, function.getType().getParameterTypes());
-
+
args = createArgsForFunctionTemplateOrdering(f2);
function = (ICPPFunction) ((ICPPInternalTemplateInstantiator)f2).instantiate(args);
-
+
ObjectMap m2 = null;
if (function != null)
m2 = deduceTemplateArguments(f1, function.getType().getParameterTypes());
-
+
//The transformed template is at least as specialized as the other iff the deduction
//succeeds and the deduced parameter types are an exact match
//A template is more specialized than another iff it is at least as specialized as the
//other template and that template is not at least as specialized as the first.
boolean d1 = (m1 != null);
boolean d2 = (m2 != null);
-
+
if (d1 && d2 || !d1 && !d2)
return 0;
else if (d1 && !d2)
return 1;
- else
+ else
return -1;
}
-
+
static public ICPPTemplateDefinition matchTemplatePartialSpecialization(ICPPClassTemplate template, IType[] args) throws DOMException{
if (template == null) {
return null;
}
-
+
ICPPClassTemplatePartialSpecialization[] specializations = template.getPartialSpecializations();
int size = (specializations != null) ? specializations.length : 0;
if (size == 0) {
return template;
}
-
+
ICPPClassTemplatePartialSpecialization bestMatch = null, spec = null;
boolean bestMatchIsBest = true;
IType[] specArgs = null;
@@ -1353,8 +1356,8 @@ public class CPPTemplates {
if (specArgs == null || specArgs.length != args.length) {
continue;
}
-
- int specArgsSize = specArgs.length;
+
+ int specArgsSize = specArgs.length;
ObjectMap map = new ObjectMap(specArgsSize);
IType t1 = null, t2 = null;
@@ -1362,7 +1365,7 @@ public class CPPTemplates {
for (int j = 0; j < specArgsSize; j++) {
t1 = specArgs[j];
t2 = args[j];
-
+
if (!deduceTemplateArgument(map, t1, t2)) {
match = false;
break;
@@ -1371,24 +1374,24 @@ public class CPPTemplates {
if (match) {
int compare = orderSpecializations(bestMatch, spec);
if (compare == 0) {
- bestMatchIsBest = false;
+ bestMatchIsBest = false;
} else if (compare < 0) {
bestMatch = spec;
bestMatchIsBest = true;
}
}
}
-
+
//14.5.4.1 If none of the specializations is more specialized than all the other matchnig
//specializations, then the use of the class template is ambiguous and the program is ill-formed.
if (!bestMatchIsBest) {
//TODO problem
return new CPPTemplateDefinition.CPPTemplateProblem(null, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, null);
}
-
+
return bestMatch;
}
-
+
/**
* Compare spec1 to spec2. Return > 0 if spec1 is more specialized, < 0 if spec2
* is more specialized, = 0 otherwise.
@@ -1399,23 +1402,23 @@ public class CPPTemplates {
*/
static private int orderSpecializations(ICPPClassTemplatePartialSpecialization spec1, ICPPClassTemplatePartialSpecialization spec2) throws DOMException {
if (spec1 == null) {
- return -1;
+ return -1;
}
-
+
//to order class template specializations, we need to transform them into function templates
ICPPFunctionTemplate template1 = null, template2 = null;
-
+
if (spec1 instanceof ICPPClassType) {
template1 = classTemplateSpecializationToFunctionTemplate(spec1);
- template2 = classTemplateSpecializationToFunctionTemplate(spec2);
+ template2 = classTemplateSpecializationToFunctionTemplate(spec2);
} else if (spec1 instanceof ICPPFunction) {
template1 = (ICPPFunctionTemplate) spec1;
template2 = (ICPPFunctionTemplate) spec2;
}
-
+
return orderTemplateFunctions(template1, template2);
}
-
+
public static final class CPPImplicitFunctionTemplate extends CPPFunctionTemplate {
IParameter[] functionParameters = null;
ICPPTemplateParameter[] templateParameters = null;
@@ -1429,7 +1432,7 @@ public class CPPTemplates {
}
@Override
public IParameter[] getParameters() {
- return functionParameters;
+ return functionParameters;
}
@Override
public ICPPTemplateParameter[] getTemplateParameters() {
@@ -1453,7 +1456,7 @@ public class CPPTemplates {
* @param template
* @return IParameterizedSymbol
* the function template has the same template parameters as the partial specialization and
- * has a single function parameter whose type is a class template specialization with the template
+ * has a single function parameter whose type is a class template specialization with the template
* arguments of the partial specialization
*/
static private ICPPFunctionTemplate classTemplateSpecializationToFunctionTemplate(ICPPClassTemplatePartialSpecialization specialization) {
@@ -1467,22 +1470,22 @@ public class CPPTemplates {
} catch (DOMException e1) {
return null;
}
-
+
IType paramType = (IType) ((ICPPInternalTemplateInstantiator)template).instantiate(args);
IParameter[] functionParameters = new IParameter[] { new CPPParameter(paramType) };
-
+
try {
return new CPPImplicitFunctionTemplate(specialization.getTemplateParameters(), functionParameters);
} catch (DOMException e) {
return null;
}
}
-
+
static private boolean isValidArgument(ICPPTemplateParameter param, IType argument) {
//TODO
- return true;
+ return true;
}
-
+
static protected boolean matchTemplateParameterAndArgument(ICPPTemplateParameter param, IType argument, ObjectMap map) {
if (!isValidArgument(param, argument)) {
return false;
@@ -1492,7 +1495,7 @@ public class CPPTemplates {
} else if (param instanceof ICPPTemplateTemplateParameter) {
if (!(argument instanceof ICPPTemplateDefinition))
return false;
-
+
ICPPTemplateParameter[] pParams = null, aParams = null;
try {
pParams = ((ICPPTemplateTemplateParameter)param).getTemplateParameters();
@@ -1500,13 +1503,13 @@ public class CPPTemplates {
} catch (DOMException e) {
return false;
}
-
+
int size = pParams.length;
if (aParams.length != size) {
return false;
}
-
+
for (int i = 0; i < size; i++) {
if ((pParams[i] instanceof ICPPTemplateTypeParameter && !(aParams[i] instanceof ICPPTemplateTypeParameter)) ||
(pParams[i] instanceof ICPPTemplateTemplateParameter && !(aParams[i] instanceof ICPPTemplateTemplateParameter)) ||
@@ -1515,7 +1518,7 @@ public class CPPTemplates {
return false;
}
}
-
+
return true;
} else {
try {
@@ -1523,7 +1526,7 @@ public class CPPTemplates {
if (map != null && pType != null && map.containsKey(pType)) {
pType = (IType) map.get(pType);
}
-
+
//14.1s8 function to pointer and array to pointer conversions
if (pType instanceof IFunctionType)
{
@@ -1536,7 +1539,7 @@ public class CPPTemplates {
}
}
Cost cost = CPPSemantics.checkStandardConversionSequence(argument, pType, false);
-
+
if (cost == null || cost.rank == Cost.NO_MATCH_RANK) {
return false;
}
@@ -1562,48 +1565,45 @@ public class CPPTemplates {
}
}
}
-
+
if (template instanceof ICPPInternalTemplateInstantiator) {
return ((ICPPInternalTemplateInstantiator)template).instantiate(args);
}
return template;
}
-
+
public static boolean typeContainsTemplateParameter(IType t) {
if (t instanceof ICPPTemplateParameter)
return true;
t = CPPSemantics.getUltimateType(t, false);
return (t instanceof ICPPTemplateParameter);
}
-
- public static IBinding instantiateTemplate(ICPPTemplateDefinition template, IType[] arguments, ObjectMap specializedArgs) {
- if (template == null) {
- template = null;
- }
-
+
+ public static IBinding instantiateTemplate(ICPPTemplateDefinition template, IType[] arguments,
+ ObjectMap specializedArgs) {
ICPPTemplateParameter[] parameters = null;
try {
parameters = template.getTemplateParameters();
} catch (DOMException e1) {
return e1.getProblem();
}
-
+
int numParams = (parameters != null) ? parameters.length : 0;
int numArgs = arguments.length;
-
+
if (numParams == 0) {
- return null;
+ return null;
}
ObjectMap map = new ObjectMap(numParams);
ICPPTemplateParameter param = null;
IType arg = null;
IType[] actualArgs = new IType[numParams];
-
+
for (int i = 0; i < numParams; i++) {
arg = null;
param = parameters[i];
-
+
if (i < numArgs) {
arg = arguments[i];
//If the argument is a template parameter, we can't instantiate yet, defer for later
@@ -1639,7 +1639,7 @@ public class CPPTemplates {
return null;
}
}
-
+
if (CPPTemplates.matchTemplateParameterAndArgument(param, arg, map)) {
map.put(param, arg);
actualArgs[i] = arg;
@@ -1648,18 +1648,18 @@ public class CPPTemplates {
return null;
}
}
-
+
ICPPSpecialization instance = ((ICPPInternalTemplateInstantiator)template).getInstance(actualArgs);
if (instance != null) {
return instance;
- }
-
+ }
+
if (specializedArgs != null) {
for (int i = 0; i < specializedArgs.size(); i++) {
map.put(specializedArgs.keyAt(i), specializedArgs.getAt(i));
}
}
-
+
ICPPScope scope = null;
try {
scope = (ICPPScope) template.getScope();
@@ -1669,10 +1669,10 @@ public class CPPTemplates {
instance = (ICPPTemplateInstance) CPPTemplates.createInstance(scope, template, map, arguments);
if (template instanceof ICPPInternalTemplate)
((ICPPInternalTemplate)template).addSpecialization(arguments, instance);
-
- return instance;
+
+ return instance;
}
-
+
/**
* Returns an array of specialized bases. The bases will be specialized versions of
* the template instances associated specialized bindings bases.
@@ -1681,13 +1681,13 @@ public class CPPTemplates {
* @return
* @throws DOMException
*/
- public static ICPPBase[] getBases(ICPPTemplateInstance classInstance) throws DOMException {
+ public static ICPPBase[] getBases(ICPPTemplateInstance classInstance) throws DOMException {
assert classInstance instanceof ICPPClassType;
ICPPBase[] pdomBases = ((ICPPClassType) classInstance.getTemplateDefinition()).getBases();
if (pdomBases != null) {
ICPPBase[] result = null;
-
+
for (int i = 0; i < pdomBases.length; i++) {
ICPPBase origBase = pdomBases[i];
ICPPBase specBase = (ICPPBase) ((ICPPInternalBase)origBase).clone();
@@ -1701,10 +1701,10 @@ public class CPPTemplates {
result = (ICPPBase[]) ArrayUtil.append(ICPPBase.class, result, specBase);
}
}
-
+
return (ICPPBase[]) ArrayUtil.trim(ICPPBase.class, result);
}
-
+
return new ICPPBase[0];
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownBinding.java
index b663a3faf32..651dcf02f46 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownBinding.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownBinding.java
@@ -34,21 +34,21 @@ public class CPPUnknownBinding extends PlatformObject implements ICPPInternalUnk
private ICPPScope scope = null;
private IASTName name = null;
/**
- *
+ *
*/
- public CPPUnknownBinding( ICPPScope scope, IBinding scopeBinding, IASTName name ) {
+ public CPPUnknownBinding(ICPPScope scope, IBinding scopeBinding, IASTName name) {
super();
this.scope = scope;
this.name = name;
this.scopeBinding = scopeBinding;
}
- /* (non-Javadoc)```
+ /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#getUnknownScope()
*/
public ICPPScope getUnknownScope() {
- if( unknownScope == null ){
- unknownScope = new CPPUnknownScope( this, name );
+ if (unknownScope == null) {
+ unknownScope = new CPPUnknownScope(this, name);
}
return unknownScope;
}
@@ -70,33 +70,33 @@ public class CPPUnknownBinding extends PlatformObject implements ICPPInternalUnk
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
*/
- public void addDefinition( IASTNode node ) {
+ public void addDefinition(IASTNode node) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode)
*/
- public void addDeclaration( IASTNode node ) {
+ public void addDeclaration(IASTNode node) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#removeDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode)
*/
- public void removeDeclaration( IASTNode node ) {
+ public void removeDeclaration(IASTNode node) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName()
*/
public String[] getQualifiedName() {
- return CPPVisitor.getQualifiedName( this );
+ return CPPVisitor.getQualifiedName(this);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray()
*/
public char[][] getQualifiedNameCharArray() {
- return CPPVisitor.getQualifiedNameCharArray( this );
+ return CPPVisitor.getQualifiedNameCharArray(this);
}
/* (non-Javadoc)
@@ -130,26 +130,33 @@ public class CPPUnknownBinding extends PlatformObject implements ICPPInternalUnk
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#resolveUnknown(org.eclipse.cdt.core.parser.util.ObjectMap)
*/
- public IBinding resolveUnknown( ObjectMap argMap ) throws DOMException {
+ public IBinding resolveUnknown(ObjectMap argMap) throws DOMException {
IBinding result = this;
- if( argMap.containsKey( scopeBinding ) ){
- IType t = (IType) argMap.get( scopeBinding );
- t = CPPSemantics.getUltimateType( t, false );
- if( t instanceof ICPPClassType ){
+ if (argMap.containsKey(scopeBinding)) {
+ IType t = (IType) argMap.get(scopeBinding);
+ t = CPPSemantics.getUltimateType(t, false);
+ if (t instanceof ICPPClassType) {
IScope s = ((ICPPClassType)t).getCompositeScope();
-
- if( s != null && ASTInternal.isFullyCached(s) )
- result = s.getBinding( name, true );
-// CPPSemantics.LookupData data = CPPSemantics.createLookupData( name, false );
-// CPPSemantics.lookup( data, s );
-// IBinding result = CPPSemantics.resolveAmbiguities( data, name );
+
+ if (s != null && ASTInternal.isFullyCached(s))
+ result = s.getBinding(name, true);
+// CPPSemantics.LookupData data = CPPSemantics.createLookupData(name, false);
+// CPPSemantics.lookup(data, s);
+// IBinding result = CPPSemantics.resolveAmbiguities(data, name);
return result;
}
}
return result;
}
-
+
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
+
+ /* (non-Javadoc)
+ * For debug purposes only
+ */
+ public String toString() {
+ return getName();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClass.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClass.java
index 1c1009c7276..c4b641bb1ae 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClass.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClass.java
@@ -27,6 +27,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
/**
+ * Represents a C++ class for which we don't yet have a complete declaration.
+ *
* @author aniefer
*/
public class CPPUnknownClass extends CPPUnknownBinding implements ICPPClassType {
@@ -35,8 +37,8 @@ public class CPPUnknownClass extends CPPUnknownBinding implements ICPPClassType
* @param scope
* @param name
*/
- public CPPUnknownClass( ICPPScope scope, IBinding scopeBinding, IASTName name ) {
- super( scope, scopeBinding, name );
+ public CPPUnknownClass(ICPPScope scope, IBinding scopeBinding, IASTName name) {
+ super(scope, scopeBinding, name);
}
/* (non-Javadoc)
@@ -56,7 +58,7 @@ public class CPPUnknownClass extends CPPUnknownBinding implements ICPPClassType
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#findField(java.lang.String)
*/
- public IField findField( String name ) {
+ public IField findField(String name) {
return null;
}
@@ -126,12 +128,11 @@ public class CPPUnknownClass extends CPPUnknownBinding implements ICPPClassType
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
- public boolean isSameType( IType type ) {
+ public boolean isSameType(IType type) {
return type == this;
}
public ICPPClassType[] getNestedClasses() {
return ICPPClassType.EMPTY_CLASS_ARRAY;
}
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java
index da819e77f2a..c9bb10bbf96 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java
@@ -37,9 +37,9 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
private IASTName scopeName = null;
private CharArrayObjectMap map = null;
/**
- *
+ *
*/
- public CPPUnknownScope( IBinding binding, IASTName name ) {
+ public CPPUnknownScope(IBinding binding, IASTName name) {
super();
this.scopeName = name;
this.binding = binding;
@@ -62,7 +62,7 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
*/
- public IBinding[] find( String name ) {
+ public IBinding[] find(String name) {
return null;
}
@@ -76,15 +76,13 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#addName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
- public void addName( IASTName name ) {
-
+ public void addName(IASTName name) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
*/
- public void removeBinding( IBinding binding1 ) {
-
+ public void removeBinding(IBinding binding) {
}
public final IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
@@ -98,28 +96,28 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean)
*/
- public IBinding getBinding( IASTName name, boolean resolve, IIndexFileSet fileSet ) {
- if( map == null )
+ public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) {
+ if (map == null)
map = new CharArrayObjectMap(2);
-
- char [] c = name.toCharArray();
- if( map.containsKey( c ) ){
- return (IBinding) map.get( c );
+
+ char[] c = name.toCharArray();
+ if (map.containsKey(c)) {
+ return (IBinding) map.get(c);
}
-
- IBinding b = new CPPUnknownClass( this, binding, name );
- name.setBinding( b );
- map.put( c, b );
+ IBinding b = new CPPUnknownClass(this, binding, name);
+ name.setBinding(b);
+ map.put(c, b);
return b;
}
-
- public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) {
- if( map == null )
+
+ public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup,
+ IIndexFileSet fileSet) {
+ if (map == null)
map = new CharArrayObjectMap(2);
-
- char [] c = name.toCharArray();
-
+
+ char[] c = name.toCharArray();
+
IBinding[] result = null;
if (prefixLookup) {
Object[] keys = map.keyArray();
@@ -130,9 +128,9 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
}
}
} else {
- result = new IBinding[] { (IBinding) map.get( c ) };
+ result = new IBinding[] { (IBinding) map.get(c) };
}
-
+
result = (IBinding[]) ArrayUtil.trim(IBinding.class, result);
return result;
}
@@ -140,7 +138,7 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#setFullyCached(boolean)
*/
- public void setFullyCached( boolean b ) {
+ public void setFullyCached(boolean b) {
}
/* (non-Javadoc)
@@ -156,8 +154,14 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
public void flushCache() {
}
- public void addBinding(IBinding aBinding) {
+ public void addBinding(IBinding binding) {
// do nothing, this is part of template magic and not a normal scope
}
+ /* (non-Javadoc)
+ * For debug purposes only
+ */
+ public String toString() {
+ return scopeName.toString();
+ }
}

Back to the top