mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 02:36:01 +02:00
toString methods.
This commit is contained in:
parent
c09235c6d1
commit
ce309040bd
9 changed files with 1216 additions and 1149 deletions
|
@ -74,15 +74,17 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
|
||||||
public IBinding getBinding(IASTName name, boolean forceResolve, IIndexFileSet fileSet) throws DOMException {
|
public IBinding getBinding(IASTName name, boolean forceResolve, IIndexFileSet fileSet) throws DOMException {
|
||||||
char[] c = name.toCharArray();
|
char[] c = name.toCharArray();
|
||||||
|
|
||||||
if( CharArrayUtils.equals( c, specialization.getNameCharArray() ) )
|
if (CharArrayUtils.equals(c, specialization.getNameCharArray()) &&
|
||||||
if (!CPPClassScope.isConstructorReference( name ))
|
!CPPClassScope.isConstructorReference(name)) {
|
||||||
return specialization;
|
return specialization;
|
||||||
|
}
|
||||||
|
|
||||||
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
|
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
|
||||||
IScope classScope = specialized.getCompositeScope();
|
IScope classScope = specialized.getCompositeScope();
|
||||||
IBinding[] bindings = classScope != null ? classScope.getBindings(name, forceResolve, false) : null;
|
IBinding[] bindings = classScope != null ? classScope.getBindings(name, forceResolve, false) : null;
|
||||||
|
|
||||||
if (bindings == null) return null;
|
if (bindings == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
IBinding[] specs = new IBinding[0];
|
IBinding[] specs = new IBinding[0];
|
||||||
for (int i = 0; i < bindings.length; i++) {
|
for (int i = 0; i < bindings.length; i++) {
|
||||||
|
@ -92,17 +94,20 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
|
||||||
return CPPSemantics.resolveAmbiguities(name, specs);
|
return CPPSemantics.resolveAmbiguities(name, specs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] getBindings( IASTName name, boolean forceResolve, boolean prefixLookup, IIndexFileSet fileSet ) throws DOMException {
|
public IBinding[] getBindings(IASTName name, boolean forceResolve, boolean prefixLookup,
|
||||||
|
IIndexFileSet fileSet) throws DOMException {
|
||||||
char[] c = name.toCharArray();
|
char[] c = name.toCharArray();
|
||||||
IBinding[] result = null;
|
IBinding[] result = null;
|
||||||
|
|
||||||
if( (!prefixLookup && CharArrayUtils.equals( c, specialization.getNameCharArray() ))
|
if ((!prefixLookup && CharArrayUtils.equals(c, specialization.getNameCharArray())) ||
|
||||||
|| (prefixLookup && CharArrayUtils.equals(specialization.getNameCharArray(), 0, c.length, c, true)) )
|
(prefixLookup && CharArrayUtils.equals(specialization.getNameCharArray(), 0, c.length, c, true))) {
|
||||||
result = new IBinding[] { specialization };
|
result = new IBinding[] { specialization };
|
||||||
|
}
|
||||||
|
|
||||||
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
|
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
|
||||||
IScope classScope = specialized.getCompositeScope();
|
IScope classScope = specialized.getCompositeScope();
|
||||||
IBinding[] bindings = classScope != null ? classScope.getBindings(name, forceResolve, prefixLookup, fileSet) : null;
|
IBinding[] bindings = classScope != null ?
|
||||||
|
classScope.getBindings(name, forceResolve, prefixLookup, fileSet) : null;
|
||||||
|
|
||||||
if (bindings != null) {
|
if (bindings != null) {
|
||||||
for (int i = 0; i < bindings.length; i++) {
|
for (int i = 0; i < bindings.length; i++) {
|
||||||
|
@ -124,7 +129,7 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getImplicitMethods()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getImplicitMethods()
|
||||||
*/
|
*/
|
||||||
public ICPPMethod[] getImplicitMethods() {
|
public ICPPMethod[] getImplicitMethods() {
|
||||||
//implicit methods shouldn't have implicit specializations
|
// Implicit methods shouldn't have implicit specializations
|
||||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,11 +212,17 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//this scope does not cache its own names
|
// This scope does not cache its own names
|
||||||
public void setFullyCached(boolean b) {}
|
public void setFullyCached(boolean b) {}
|
||||||
public void flushCache() {}
|
public void flushCache() {}
|
||||||
public void addName(IASTName name) {}
|
public void addName(IASTName name) {}
|
||||||
public IASTNode getPhysicalNode() { return null; }
|
public IASTNode getPhysicalNode() { return null; }
|
||||||
public void removeBinding(IBinding binding) {}
|
public void removeBinding(IBinding binding) {}
|
||||||
public void addBinding(IBinding binding) {}
|
public void addBinding(IBinding binding) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
IName name = getScopeName();
|
||||||
|
return name != null ? name.toString() : "<unnamed scope>"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
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.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
@ -51,7 +52,8 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
||||||
IParameter[] params = function.getParameters();
|
IParameter[] params = function.getParameters();
|
||||||
specializedParams = new IParameter[params.length];
|
specializedParams = new IParameter[params.length];
|
||||||
for (int i = 0; i < params.length; i++) {
|
for (int i = 0; i < params.length; i++) {
|
||||||
specializedParams[i] = new CPPParameterSpecialization( (ICPPParameter)params[i], (ICPPScope) getScope(), argumentMap );
|
specializedParams[i] = new CPPParameterSpecialization((ICPPParameter)params[i],
|
||||||
|
(ICPPScope) getScope(), argumentMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return specializedParams;
|
return specializedParams;
|
||||||
|
@ -196,6 +198,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
||||||
updateParameterBindings((ICPPASTFunctionDeclarator) n);
|
updateParameterBindings((ICPPASTFunctionDeclarator) n);
|
||||||
super.addDefinition(n);
|
super.addDefinition(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addDeclaration(IASTNode node) {
|
public void addDeclaration(IASTNode node) {
|
||||||
IASTNode n = node;
|
IASTNode n = node;
|
||||||
|
@ -206,6 +209,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
||||||
updateParameterBindings((ICPPASTFunctionDeclarator) n);
|
updateParameterBindings((ICPPASTFunctionDeclarator) n);
|
||||||
super.addDeclaration(n);
|
super.addDeclaration(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateParameterBindings(ICPPASTFunctionDeclarator fdtor) {
|
protected void updateParameterBindings(ICPPASTFunctionDeclarator fdtor) {
|
||||||
IParameter[] params = null;
|
IParameter[] params = null;
|
||||||
try {
|
try {
|
||||||
|
@ -227,4 +231,21 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
result.append(getName());
|
||||||
|
IFunctionType t = null;
|
||||||
|
try {
|
||||||
|
t = getType();
|
||||||
|
} catch (DOMException e) {
|
||||||
|
}
|
||||||
|
result.append(t != null ? ASTTypeUtil.getParameterTypeString(t) : "()"); //$NON-NLS-1$
|
||||||
|
if (argumentMap != null) {
|
||||||
|
result.append(" ");
|
||||||
|
result.append(argumentMap.toString());
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,9 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
*/
|
*/
|
||||||
abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
||||||
private static final IProgressMonitor NPM = new NullProgressMonitor();
|
private static final IProgressMonitor NPM = new NullProgressMonitor();
|
||||||
|
private IASTNode physicalNode;
|
||||||
|
private boolean isfull = false;
|
||||||
|
protected CharArrayObjectMap bindings = null;
|
||||||
|
|
||||||
public static class CPPScopeProblem extends ProblemBinding implements ICPPScope {
|
public static class CPPScopeProblem extends ProblemBinding implements ICPPScope {
|
||||||
public CPPScopeProblem(IASTNode node, int id, char[] arg) {
|
public CPPScopeProblem(IASTNode node, int id, char[] arg) {
|
||||||
|
@ -58,7 +61,6 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTNode physicalNode;
|
|
||||||
public CPPScope(IASTNode physicalNode) {
|
public CPPScope(IASTNode physicalNode) {
|
||||||
this.physicalNode = physicalNode;
|
this.physicalNode = physicalNode;
|
||||||
}
|
}
|
||||||
|
@ -74,16 +76,15 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
||||||
return physicalNode;
|
return physicalNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CharArrayObjectMap bindings = null;
|
|
||||||
|
|
||||||
public void addName(IASTName name) throws DOMException {
|
public void addName(IASTName name) throws DOMException {
|
||||||
if (bindings == null)
|
if (bindings == null)
|
||||||
bindings = new CharArrayObjectMap(1);
|
bindings = new CharArrayObjectMap(1);
|
||||||
char[] c;
|
char[] c;
|
||||||
if (name instanceof ICPPASTQualifiedName) {
|
if (name instanceof ICPPASTQualifiedName) {
|
||||||
if (physicalNode instanceof ICPPASTCompositeTypeSpecifier == false &&
|
if (!(physicalNode instanceof ICPPASTCompositeTypeSpecifier) &&
|
||||||
physicalNode instanceof ICPPASTNamespaceDefinition == false)
|
!(physicalNode instanceof ICPPASTNamespaceDefinition)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//name belongs to a different scope, don't add it here except it names this scope
|
//name belongs to a different scope, don't add it here except it names this scope
|
||||||
final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name;
|
final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name;
|
||||||
|
@ -91,8 +92,7 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
||||||
if (!canDenoteScopeMember(qname))
|
if (!canDenoteScopeMember(qname))
|
||||||
return;
|
return;
|
||||||
c= ns[ns.length - 1].toCharArray();
|
c= ns[ns.length - 1].toCharArray();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
c= name.toCharArray();
|
c= name.toCharArray();
|
||||||
}
|
}
|
||||||
Object o = bindings.get(c);
|
Object o = bindings.get(c);
|
||||||
|
@ -141,19 +141,20 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
||||||
// Try looking this up in the PDOM
|
// Try looking this up in the PDOM
|
||||||
if (physicalNode instanceof IASTTranslationUnit) {
|
if (physicalNode instanceof IASTTranslationUnit) {
|
||||||
try {
|
try {
|
||||||
IBinding[] bindings= index.findBindings(name.toCharArray(), IndexFilter.CPP_DECLARED_OR_IMPLICIT, NPM);
|
IBinding[] bindings= index.findBindings(name.toCharArray(),
|
||||||
|
IndexFilter.CPP_DECLARED_OR_IMPLICIT, NPM);
|
||||||
if (fileSet != null) {
|
if (fileSet != null) {
|
||||||
bindings= fileSet.filterFileLocalBindings(bindings);
|
bindings= fileSet.filterFileLocalBindings(bindings);
|
||||||
}
|
}
|
||||||
binding= CPPSemantics.resolveAmbiguities(name, bindings);
|
binding= CPPSemantics.resolveAmbiguities(name, bindings);
|
||||||
if (binding instanceof ICPPUsingDeclaration) {
|
if (binding instanceof ICPPUsingDeclaration) {
|
||||||
binding= CPPSemantics.resolveAmbiguities( name, ((ICPPUsingDeclaration)binding).getDelegates() );
|
binding= CPPSemantics.resolveAmbiguities(name,
|
||||||
|
((ICPPUsingDeclaration)binding).getDelegates());
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
} else if (physicalNode instanceof ICPPASTNamespaceDefinition) {
|
||||||
else if (physicalNode instanceof ICPPASTNamespaceDefinition) {
|
|
||||||
ICPPASTNamespaceDefinition nsdef = (ICPPASTNamespaceDefinition)physicalNode;
|
ICPPASTNamespaceDefinition nsdef = (ICPPASTNamespaceDefinition)physicalNode;
|
||||||
IASTName nsname = nsdef.getName();
|
IASTName nsname = nsdef.getName();
|
||||||
IBinding nsbinding= nsname.resolveBinding();
|
IBinding nsbinding= nsname.resolveBinding();
|
||||||
|
@ -166,7 +167,8 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
||||||
}
|
}
|
||||||
binding= CPPSemantics.resolveAmbiguities(name, bindings);
|
binding= CPPSemantics.resolveAmbiguities(name, bindings);
|
||||||
if (binding instanceof ICPPUsingDeclaration) {
|
if (binding instanceof ICPPUsingDeclaration) {
|
||||||
binding= CPPSemantics.resolveAmbiguities( name, ((ICPPUsingDeclaration)binding).getDelegates() );
|
binding= CPPSemantics.resolveAmbiguities(name,
|
||||||
|
((ICPPUsingDeclaration)binding).getDelegates());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,15 +200,16 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
||||||
n = ns[ns.length - 1];
|
n = ns[ns.length - 1];
|
||||||
}
|
}
|
||||||
bs = (IBinding[]) ArrayUtil.append(IBinding.class, bs, n.getBinding());
|
bs = (IBinding[]) ArrayUtil.append(IBinding.class, bs, n.getBinding());
|
||||||
} else
|
} else {
|
||||||
bs = (IBinding[]) ArrayUtil.append(IBinding.class, bs, o);
|
bs = (IBinding[]) ArrayUtil.append(IBinding.class, bs, o);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return CPPSemantics.resolveAmbiguities(name, bs);
|
return CPPSemantics.resolveAmbiguities(name, bs);
|
||||||
} else if (obj instanceof IASTName) {
|
} else if (obj instanceof IASTName) {
|
||||||
IBinding binding = null;
|
IBinding binding = null;
|
||||||
if( forceResolve && obj != name && obj != name.getParent())
|
if (forceResolve && obj != name && obj != name.getParent()) {
|
||||||
binding = CPPSemantics.resolveAmbiguities(name, new Object[] { obj });
|
binding = CPPSemantics.resolveAmbiguities(name, new Object[] { obj });
|
||||||
else {
|
} else {
|
||||||
IASTName n = (IASTName) obj;
|
IASTName n = (IASTName) obj;
|
||||||
if (n instanceof ICPPASTQualifiedName) {
|
if (n instanceof ICPPASTQualifiedName) {
|
||||||
IASTName[] ns = ((ICPPASTQualifiedName)n).getNames();
|
IASTName[] ns = ((ICPPASTQualifiedName)n).getNames();
|
||||||
|
@ -224,7 +227,8 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) throws DOMException {
|
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet)
|
||||||
|
throws DOMException {
|
||||||
IBinding[] result = getBindingsInAST(name, resolve, prefixLookup);
|
IBinding[] result = getBindingsInAST(name, resolve, prefixLookup);
|
||||||
|
|
||||||
final IASTTranslationUnit tu = name.getTranslationUnit();
|
final IASTTranslationUnit tu = name.getTranslationUnit();
|
||||||
|
@ -264,7 +268,8 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
||||||
return (IBinding[]) ArrayUtil.trim(IBinding.class, result);
|
return (IBinding[]) ArrayUtil.trim(IBinding.class, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] getBindingsInAST(IASTName name, boolean forceResolve, boolean prefixLookup) throws DOMException {
|
public IBinding[] getBindingsInAST(IASTName name, boolean forceResolve, boolean prefixLookup)
|
||||||
|
throws DOMException {
|
||||||
char[] c = name.toCharArray();
|
char[] c = name.toCharArray();
|
||||||
IBinding[] result = null;
|
IBinding[] result = null;
|
||||||
|
|
||||||
|
@ -295,14 +300,15 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
||||||
}
|
}
|
||||||
IBinding binding = forceResolve ? n.resolveBinding() : n.getBinding();
|
IBinding binding = forceResolve ? n.resolveBinding() : n.getBinding();
|
||||||
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, binding);
|
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, binding);
|
||||||
} else
|
} else {
|
||||||
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, o);
|
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, o);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (obj[i] instanceof IASTName) {
|
} else if (obj[i] instanceof IASTName) {
|
||||||
IBinding binding = null;
|
IBinding binding = null;
|
||||||
if( forceResolve && obj[i] != name && obj[i] != name.getParent())
|
if (forceResolve && obj[i] != name && obj[i] != name.getParent()) {
|
||||||
binding = ((IASTName) obj[i]).resolveBinding();
|
binding = ((IASTName) obj[i]).resolveBinding();
|
||||||
else {
|
} else {
|
||||||
IASTName n = (IASTName) obj[i];
|
IASTName n = (IASTName) obj[i];
|
||||||
if (n instanceof ICPPASTQualifiedName) {
|
if (n instanceof ICPPASTQualifiedName) {
|
||||||
IASTName[] ns = ((ICPPASTQualifiedName)n).getNames();
|
IASTName[] ns = ((ICPPASTQualifiedName)n).getNames();
|
||||||
|
@ -311,7 +317,8 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
||||||
binding = n.getBinding();
|
binding = n.getBinding();
|
||||||
}
|
}
|
||||||
if (binding instanceof ICPPUsingDeclaration) {
|
if (binding instanceof ICPPUsingDeclaration) {
|
||||||
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, ((ICPPUsingDeclaration)binding).getDelegates());
|
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result,
|
||||||
|
((ICPPUsingDeclaration)binding).getDelegates());
|
||||||
}
|
}
|
||||||
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, binding);
|
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, binding);
|
||||||
} else {
|
} else {
|
||||||
|
@ -321,7 +328,6 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
||||||
return (IBinding[]) ArrayUtil.trim(IBinding.class, result);
|
return (IBinding[]) ArrayUtil.trim(IBinding.class, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isfull = false;
|
|
||||||
public void setFullyCached(boolean full) {
|
public void setFullyCached(boolean full) {
|
||||||
isfull = full;
|
isfull = full;
|
||||||
}
|
}
|
||||||
|
@ -348,16 +354,15 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
||||||
for (int i = set.size() - 1; i > 0; i--) {
|
for (int i = set.size() - 1; i > 0; i--) {
|
||||||
Object o = set.keyAt(i);
|
Object o = set.keyAt(i);
|
||||||
if ((o instanceof IBinding && o == binding) ||
|
if ((o instanceof IBinding && o == binding) ||
|
||||||
(o instanceof IASTName && ((IASTName)o).getBinding() == binding) )
|
(o instanceof IASTName && ((IASTName)o).getBinding() == binding)) {
|
||||||
{
|
|
||||||
set.remove(o);
|
set.remove(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( set.size() == 0 )
|
if (set.isEmpty()) {
|
||||||
bindings.remove(key, 0, key.length);
|
bindings.remove(key, 0, key.length);
|
||||||
|
}
|
||||||
} else if ((obj instanceof IBinding && obj == binding) ||
|
} else if ((obj instanceof IBinding && obj == binding) ||
|
||||||
(obj instanceof IASTName && ((IASTName)obj).getBinding() == binding) )
|
(obj instanceof IASTName && ((IASTName)obj).getBinding() == binding)) {
|
||||||
{
|
|
||||||
bindings.remove(key, 0, key.length);
|
bindings.remove(key, 0, key.length);
|
||||||
}
|
}
|
||||||
isfull = false;
|
isfull = false;
|
||||||
|
@ -402,4 +407,18 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
||||||
public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) throws DOMException {
|
public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) throws DOMException {
|
||||||
return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY);
|
return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IName getScopeName() throws DOMException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
IName name = null;
|
||||||
|
try {
|
||||||
|
name = getScopeName();
|
||||||
|
} catch (DOMException e) {
|
||||||
|
}
|
||||||
|
return name != null ? name.toString() : "<unnamed scope>"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,4 +125,14 @@ public abstract class CPPSpecialization extends PlatformObject
|
||||||
public ObjectMap getArgumentMap() {
|
public ObjectMap getArgumentMap() {
|
||||||
return argumentMap;
|
return argumentMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder result = new StringBuilder(getName());
|
||||||
|
if (argumentMap != null) {
|
||||||
|
result.append(" ");
|
||||||
|
result.append(argumentMap.toString());
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,12 +72,13 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
|
||||||
throw new DOMException(this);
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//private IASTName templateName;
|
|
||||||
protected IASTName [] declarations = null;
|
|
||||||
protected IASTName definition = null;
|
|
||||||
|
|
||||||
private ICPPTemplateParameter [] templateParameters = null;
|
//private IASTName templateName;
|
||||||
private ObjectMap instances = null;
|
protected IASTName[] declarations;
|
||||||
|
protected IASTName definition;
|
||||||
|
|
||||||
|
private ICPPTemplateParameter[] templateParameters;
|
||||||
|
private ObjectMap instances;
|
||||||
|
|
||||||
public CPPTemplateDefinition(IASTName name) {
|
public CPPTemplateDefinition(IASTName name) {
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
|
@ -93,13 +94,14 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
|
||||||
IASTNode parent = name.getParent();
|
IASTNode parent = name.getParent();
|
||||||
while (!(parent instanceof IASTDeclaration))
|
while (!(parent instanceof IASTDeclaration))
|
||||||
parent = parent.getParent();
|
parent = parent.getParent();
|
||||||
if( parent instanceof IASTFunctionDefinition )
|
if (parent instanceof IASTFunctionDefinition) {
|
||||||
definition = name;
|
definition = name;
|
||||||
else
|
} else {
|
||||||
declarations = new IASTName[] { name };
|
declarations = new IASTName[] { name };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public abstract ICPPSpecialization deferredInstance(IType[] arguments);
|
public abstract ICPPSpecialization deferredInstance(IType[] arguments);
|
||||||
|
|
||||||
|
@ -119,8 +121,9 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( template instanceof IProblemBinding )
|
if (template instanceof IProblemBinding) {
|
||||||
return template;
|
return template;
|
||||||
|
}
|
||||||
if (template != null && template instanceof ICPPClassTemplatePartialSpecialization) {
|
if (template != null && template instanceof ICPPClassTemplatePartialSpecialization) {
|
||||||
return ((ICPPInternalTemplateInstantiator)template).instantiate(arguments);
|
return ((ICPPInternalTemplateInstantiator)template).instantiate(arguments);
|
||||||
}
|
}
|
||||||
|
@ -156,9 +159,10 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
|
||||||
public void addSpecialization(IType[] types, ICPPSpecialization spec) {
|
public void addSpecialization(IType[] types, ICPPSpecialization spec) {
|
||||||
if (types == null)
|
if (types == null)
|
||||||
return;
|
return;
|
||||||
for( int i = 0; i < types.length; i++ )
|
for (int i = 0; i < types.length; i++) {
|
||||||
if (types[i] == null)
|
if (types[i] == null)
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (instances == null)
|
if (instances == null)
|
||||||
instances = new ObjectMap(2);
|
instances = new ObjectMap(2);
|
||||||
instances.put(types, spec);
|
instances.put(types, spec);
|
||||||
|
@ -195,12 +199,13 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//create a new binding and set it for the corresponding parameter in all known decls
|
//create a new binding and set it for the corresponding parameter in all known decls
|
||||||
if( templateParameter instanceof ICPPASTSimpleTypeTemplateParameter )
|
if (templateParameter instanceof ICPPASTSimpleTypeTemplateParameter) {
|
||||||
binding = new CPPTemplateTypeParameter(name);
|
binding = new CPPTemplateTypeParameter(name);
|
||||||
else if( templateParameter instanceof ICPPASTParameterDeclaration )
|
} else if (templateParameter instanceof ICPPASTParameterDeclaration) {
|
||||||
binding = new CPPTemplateNonTypeParameter(name);
|
binding = new CPPTemplateNonTypeParameter(name);
|
||||||
else
|
} else {
|
||||||
binding = new CPPTemplateTemplateParameter(name);
|
binding = new CPPTemplateTemplateParameter(name);
|
||||||
|
}
|
||||||
|
|
||||||
int length = (declarations != null) ? declarations.length : 0;
|
int length = (declarations != null) ? declarations.length : 0;
|
||||||
int j = (definition != null) ? -1 : 0;
|
int j = (definition != null) ? -1 : 0;
|
||||||
|
@ -229,6 +234,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
|
||||||
public IASTName getTemplateName() {
|
public IASTName getTemplateName() {
|
||||||
return definition != null ? definition : declarations[0];
|
return definition != null ? definition : declarations[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||||
*/
|
*/
|
||||||
|
@ -332,9 +338,9 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
|
||||||
return;
|
return;
|
||||||
IASTName declName = (IASTName) node;
|
IASTName declName = (IASTName) node;
|
||||||
updateTemplateParameterBindings(declName);
|
updateTemplateParameterBindings(declName);
|
||||||
if( declarations == null )
|
if (declarations == null) {
|
||||||
declarations = new IASTName[] { declName };
|
declarations = new IASTName[] { declName };
|
||||||
else {
|
} else {
|
||||||
// keep the lowest offset declaration in[0]
|
// keep the lowest offset declaration in[0]
|
||||||
if (declarations.length > 0 && ((ASTNode) node).getOffset() < ((ASTNode) declarations[0]).getOffset()) {
|
if (declarations.length > 0 && ((ASTNode) node).getOffset() < ((ASTNode) declarations[0]).getOffset()) {
|
||||||
declarations = (IASTName[]) ArrayUtil.prepend(IASTName.class, declarations, declName);
|
declarations = (IASTName[]) ArrayUtil.prepend(IASTName.class, declarations, declName);
|
||||||
|
|
|
@ -73,7 +73,8 @@ public class CPPTemplateScope extends CPPScope implements ICPPTemplateScope {
|
||||||
IASTName[] names = qual.getNames();
|
IASTName[] names = qual.getNames();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < names.length; i++) {
|
for (; i < names.length; i++) {
|
||||||
if( names[i] == name ) break;
|
if (names[i] == name)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
try {
|
try {
|
||||||
|
@ -87,14 +88,16 @@ public class CPPTemplateScope extends CPPScope implements ICPPTemplateScope {
|
||||||
} else if (binding instanceof IProblemBinding) {
|
} else if (binding instanceof IProblemBinding) {
|
||||||
if (binding instanceof ICPPScope)
|
if (binding instanceof ICPPScope)
|
||||||
return (IScope) binding;
|
return (IScope) binding;
|
||||||
return new CPPScope.CPPScopeProblem( names[i-1], IProblemBinding.SEMANTIC_BAD_SCOPE, names[i-1].toCharArray() );
|
return new CPPScope.CPPScopeProblem(names[i - 1], IProblemBinding.SEMANTIC_BAD_SCOPE,
|
||||||
|
names[i - 1].toCharArray());
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
IScope result = e.getProblem();
|
IScope result = e.getProblem();
|
||||||
if (result instanceof ICPPScope) {
|
if (result instanceof ICPPScope) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return new CPPScope.CPPScopeProblem( names[i-1], IProblemBinding.SEMANTIC_BAD_SCOPE, names[i-1].toCharArray() );
|
return new CPPScope.CPPScopeProblem(names[i - 1], IProblemBinding.SEMANTIC_BAD_SCOPE,
|
||||||
|
names[i - 1].toCharArray());
|
||||||
}
|
}
|
||||||
} else if (qual.isFullyQualified()) {
|
} else if (qual.isFullyQualified()) {
|
||||||
return qual.getTranslationUnit().getScope();
|
return qual.getTranslationUnit().getScope();
|
||||||
|
|
|
@ -21,23 +21,22 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPTypedefSpecialization extends CPPSpecialization implements
|
public class CPPTypedefSpecialization extends CPPSpecialization implements ITypedef, ITypeContainer {
|
||||||
ITypedef, ITypeContainer {
|
|
||||||
|
|
||||||
private IType type = null;
|
private IType type = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param specialized
|
* @param specialized
|
||||||
* @param scope
|
* @param scope
|
||||||
* @param argumentMap
|
* @param argumentMap
|
||||||
*/
|
*/
|
||||||
public CPPTypedefSpecialization( IBinding specialized, ICPPScope scope,
|
public CPPTypedefSpecialization(IBinding specialized, ICPPScope scope, ObjectMap argumentMap) {
|
||||||
ObjectMap argumentMap ) {
|
|
||||||
super(specialized, scope, argumentMap);
|
super(specialized, scope, argumentMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ITypedef getTypedef() {
|
private ITypedef getTypedef() {
|
||||||
return (ITypedef) getSpecializedBinding();
|
return (ITypedef) getSpecializedBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ITypedef#getType()
|
* @see org.eclipse.cdt.core.dom.ast.ITypedef#getType()
|
||||||
*/
|
*/
|
||||||
|
@ -68,7 +67,7 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements
|
||||||
public boolean isSameType(IType o) {
|
public boolean isSameType(IType o) {
|
||||||
if (o == this)
|
if (o == this)
|
||||||
return true;
|
return true;
|
||||||
if( o instanceof ITypedef )
|
if (o instanceof ITypedef) {
|
||||||
try {
|
try {
|
||||||
IType t = getType();
|
IType t = getType();
|
||||||
if (t != null)
|
if (t != null)
|
||||||
|
@ -77,6 +76,7 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IType t = getType();
|
IType t = getType();
|
||||||
|
@ -91,5 +91,4 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements
|
||||||
public void setType(IType type) {
|
public void setType(IType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,12 +161,10 @@ public class CPPVisitor {
|
||||||
parent instanceof ICPPASTBaseSpecifier ||
|
parent instanceof ICPPASTBaseSpecifier ||
|
||||||
parent instanceof ICPPASTConstructorChainInitializer ||
|
parent instanceof ICPPASTConstructorChainInitializer ||
|
||||||
name.getPropertyInParent() == ICPPASTNamespaceAlias.MAPPING_NAME ||
|
name.getPropertyInParent() == ICPPASTNamespaceAlias.MAPPING_NAME ||
|
||||||
parent instanceof ICPPASTTemplateId )
|
parent instanceof ICPPASTTemplateId) {
|
||||||
{
|
|
||||||
binding = CPPSemantics.resolveBinding(name);
|
binding = CPPSemantics.resolveBinding(name);
|
||||||
if( binding instanceof IProblemBinding && parent instanceof ICPPASTQualifiedName
|
if (binding instanceof IProblemBinding && parent instanceof ICPPASTQualifiedName &&
|
||||||
&& !(parent.getParent() instanceof ICPPASTNamespaceAlias))
|
!(parent.getParent() instanceof ICPPASTNamespaceAlias)) {
|
||||||
{
|
|
||||||
final ICPPASTQualifiedName qname = (ICPPASTQualifiedName)parent;
|
final ICPPASTQualifiedName qname = (ICPPASTQualifiedName)parent;
|
||||||
final IASTName[] ns = qname.getNames();
|
final IASTName[] ns = qname.getNames();
|
||||||
if (ns[ns.length - 1] != name)
|
if (ns[ns.length - 1] != name)
|
||||||
|
@ -176,8 +174,10 @@ public class CPPVisitor {
|
||||||
if (((IProblemBinding)binding).getID() == IProblemBinding.SEMANTIC_MEMBER_DECLARATION_NOT_FOUND) {
|
if (((IProblemBinding)binding).getID() == IProblemBinding.SEMANTIC_MEMBER_DECLARATION_NOT_FOUND) {
|
||||||
IASTNode node = getContainingBlockItem(name.getParent());
|
IASTNode node = getContainingBlockItem(name.getParent());
|
||||||
ASTNodeProperty prop= node.getPropertyInParent();
|
ASTNodeProperty prop= node.getPropertyInParent();
|
||||||
if (prop != IASTCompositeTypeSpecifier.MEMBER_DECLARATION && prop != ICPPASTNamespaceDefinition.OWNED_DECLARATION)
|
if (prop != IASTCompositeTypeSpecifier.MEMBER_DECLARATION &&
|
||||||
|
prop != ICPPASTNamespaceDefinition.OWNED_DECLARATION) {
|
||||||
return binding;
|
return binding;
|
||||||
|
}
|
||||||
|
|
||||||
if (getContainingScope(qname) != getContainingScope(name))
|
if (getContainingScope(qname) != getContainingScope(name))
|
||||||
return binding;
|
return binding;
|
||||||
|
@ -308,14 +308,13 @@ public class CPPVisitor {
|
||||||
}
|
}
|
||||||
} else if (parent instanceof IASTParameterDeclaration ||
|
} else if (parent instanceof IASTParameterDeclaration ||
|
||||||
parent instanceof IASTDeclaration ||
|
parent instanceof IASTDeclaration ||
|
||||||
parent instanceof IASTTypeId )
|
parent instanceof IASTTypeId) {
|
||||||
{
|
|
||||||
binding = CPPSemantics.resolveBinding(elabType.getName());
|
binding = CPPSemantics.resolveBinding(elabType.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (binding != null &&
|
if (binding != null &&
|
||||||
(!(binding instanceof IProblemBinding) ||((IProblemBinding)binding).getID() != IProblemBinding.SEMANTIC_NAME_NOT_FOUND) )
|
(!(binding instanceof IProblemBinding) ||
|
||||||
{
|
((IProblemBinding)binding).getID() != IProblemBinding.SEMANTIC_NAME_NOT_FOUND)) {
|
||||||
return binding;
|
return binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,6 +373,7 @@ public class CPPVisitor {
|
||||||
|
|
||||||
return binding;
|
return binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IBinding createBinding(ICPPASTCompositeTypeSpecifier compType) {
|
private static IBinding createBinding(ICPPASTCompositeTypeSpecifier compType) {
|
||||||
IASTName name = compType.getName();
|
IASTName name = compType.getName();
|
||||||
if (name instanceof ICPPASTQualifiedName) {
|
if (name instanceof ICPPASTQualifiedName) {
|
||||||
|
@ -399,18 +399,22 @@ public class CPPVisitor {
|
||||||
if (name.toCharArray().length > 0 && scope != null) //can't lookup anonymous things
|
if (name.toCharArray().length > 0 && scope != null) //can't lookup anonymous things
|
||||||
binding = scope.getBinding(name, false);
|
binding = scope.getBinding(name, false);
|
||||||
if (!(binding instanceof ICPPInternalBinding) || !(binding instanceof ICPPClassType)) {
|
if (!(binding instanceof ICPPInternalBinding) || !(binding instanceof ICPPClassType)) {
|
||||||
if( template )
|
if (template) {
|
||||||
binding = new CPPClassTemplate(name);
|
binding = new CPPClassTemplate(name);
|
||||||
else
|
} else {
|
||||||
binding = new CPPClassType(name, binding);
|
binding = new CPPClassType(name, binding);
|
||||||
if( scope != null )
|
}
|
||||||
|
if (scope != null) {
|
||||||
ASTInternal.addName(scope, compType.getName());
|
ASTInternal.addName(scope, compType.getName());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ICPPInternalBinding internal = (ICPPInternalBinding) binding;
|
ICPPInternalBinding internal = (ICPPInternalBinding) binding;
|
||||||
if( internal.getDefinition() == null )
|
if (internal.getDefinition() == null) {
|
||||||
internal.addDefinition(compType);
|
internal.addDefinition(compType);
|
||||||
else
|
} else {
|
||||||
binding = new ProblemBinding( name, IProblemBinding.SEMANTIC_INVALID_REDEFINITION, name.toCharArray() );
|
binding = new ProblemBinding(name,
|
||||||
|
IProblemBinding.SEMANTIC_INVALID_REDEFINITION, name.toCharArray());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
binding = e.getProblem();
|
binding = e.getProblem();
|
||||||
|
@ -445,13 +449,15 @@ public class CPPVisitor {
|
||||||
IBinding namespace = alias.getMappingName().resolveBinding();
|
IBinding namespace = alias.getMappingName().resolveBinding();
|
||||||
if (namespace instanceof IProblemBinding) {
|
if (namespace instanceof IProblemBinding) {
|
||||||
IProblemBinding problem = (IProblemBinding) namespace;
|
IProblemBinding problem = (IProblemBinding) namespace;
|
||||||
namespace = new CPPNamespace.CPPNamespaceProblem( problem.getASTNode(), problem.getID(), alias.getMappingName().toCharArray());
|
namespace = new CPPNamespace.CPPNamespaceProblem(problem.getASTNode(),
|
||||||
|
problem.getID(), alias.getMappingName().toCharArray());
|
||||||
}
|
}
|
||||||
if (namespace instanceof ICPPNamespace) {
|
if (namespace instanceof ICPPNamespace) {
|
||||||
binding = new CPPNamespaceAlias(alias.getAlias(), (ICPPNamespace) namespace);
|
binding = new CPPNamespaceAlias(alias.getAlias(), (ICPPNamespace) namespace);
|
||||||
ASTInternal.addName(scope, alias.getAlias());
|
ASTInternal.addName(scope, alias.getAlias());
|
||||||
} else {
|
} else {
|
||||||
binding = new ProblemBinding( alias.getAlias(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND, alias.getAlias().toCharArray() );
|
binding = new ProblemBinding(alias.getAlias(),
|
||||||
|
IProblemBinding.SEMANTIC_NAME_NOT_FOUND, alias.getAlias().toCharArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(DOMException e) {
|
} catch(DOMException e) {
|
||||||
|
@ -461,7 +467,6 @@ public class CPPVisitor {
|
||||||
return binding;
|
return binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
private static IBinding createBinding(IASTDeclarator declarator) {
|
private static IBinding createBinding(IASTDeclarator declarator) {
|
||||||
|
@ -495,14 +500,14 @@ public class CPPVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTNodeProperty prop = parent.getPropertyInParent();
|
ASTNodeProperty prop = parent.getPropertyInParent();
|
||||||
if( parent instanceof IASTTypeId )
|
if (parent instanceof IASTTypeId) {
|
||||||
return CPPSemantics.resolveBinding(name);
|
return CPPSemantics.resolveBinding(name);
|
||||||
else if( prop == ICPPASTTemplateSpecialization.OWNED_DECLARATION ||
|
} else if (prop == ICPPASTTemplateSpecialization.OWNED_DECLARATION ||
|
||||||
prop == ICPPASTExplicitTemplateInstantiation.OWNED_DECLARATION )
|
prop == ICPPASTExplicitTemplateInstantiation.OWNED_DECLARATION) {
|
||||||
{
|
|
||||||
return CPPTemplates.createFunctionSpecialization(name);
|
return CPPTemplates.createFunctionSpecialization(name);
|
||||||
} else if( prop == ICPPASTTemplateDeclaration.PARAMETER )
|
} else if (prop == ICPPASTTemplateDeclaration.PARAMETER) {
|
||||||
return CPPTemplates.createBinding((ICPPASTTemplateParameter) parent);
|
return CPPTemplates.createBinding((ICPPASTTemplateParameter) parent);
|
||||||
|
}
|
||||||
|
|
||||||
boolean template = false;
|
boolean template = false;
|
||||||
ICPPScope scope = (ICPPScope) getContainingScope((IASTNode) name);
|
ICPPScope scope = (ICPPScope) getContainingScope((IASTNode) name);
|
||||||
|
@ -532,7 +537,8 @@ public class CPPVisitor {
|
||||||
binding = null;
|
binding = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTSimpleDeclaration simpleDecl = ( parent instanceof IASTSimpleDeclaration ) ? (IASTSimpleDeclaration)parent : null;
|
IASTSimpleDeclaration simpleDecl = (parent instanceof IASTSimpleDeclaration) ?
|
||||||
|
(IASTSimpleDeclaration)parent : null;
|
||||||
if (parent instanceof ICPPASTParameterDeclaration) {
|
if (parent instanceof ICPPASTParameterDeclaration) {
|
||||||
ICPPASTParameterDeclaration param = (ICPPASTParameterDeclaration) parent;
|
ICPPASTParameterDeclaration param = (ICPPASTParameterDeclaration) parent;
|
||||||
parent = param.getParent();
|
parent = param.getParent();
|
||||||
|
@ -552,7 +558,8 @@ public class CPPVisitor {
|
||||||
} else if (parent instanceof ICPPASTTemplateDeclaration) {
|
} else if (parent instanceof ICPPASTTemplateDeclaration) {
|
||||||
return CPPTemplates.createBinding(param);
|
return CPPTemplates.createBinding(param);
|
||||||
}
|
}
|
||||||
} else if( simpleDecl != null && simpleDecl.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef ){
|
} else if (simpleDecl != null &&
|
||||||
|
simpleDecl.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef) {
|
||||||
if (binding instanceof ICPPInternalBinding && binding instanceof ITypedef) {
|
if (binding instanceof ICPPInternalBinding && binding instanceof ITypedef) {
|
||||||
try {
|
try {
|
||||||
IType t1 = ((ITypedef)binding).getType();
|
IType t1 = ((ITypedef)binding).getType();
|
||||||
|
@ -573,19 +580,18 @@ public class CPPVisitor {
|
||||||
IFunction function = (IFunction) binding;
|
IFunction function = (IFunction) binding;
|
||||||
if (CPPSemantics.isSameFunction(function, funcDeclarator)) {
|
if (CPPSemantics.isSameFunction(function, funcDeclarator)) {
|
||||||
ICPPInternalBinding internal = (ICPPInternalBinding) function;
|
ICPPInternalBinding internal = (ICPPInternalBinding) function;
|
||||||
if( parent instanceof IASTSimpleDeclaration )
|
if (parent instanceof IASTSimpleDeclaration) {
|
||||||
internal.addDeclaration(name);
|
internal.addDeclaration(name);
|
||||||
else {
|
} else if (internal.getDefinition() == null) {
|
||||||
if( internal.getDefinition() == null )
|
|
||||||
internal.addDefinition(name);
|
internal.addDefinition(name);
|
||||||
else {
|
} else {
|
||||||
IASTNode def = internal.getDefinition();
|
IASTNode def = internal.getDefinition();
|
||||||
if (def instanceof IASTDeclarator)
|
if (def instanceof IASTDeclarator)
|
||||||
def = ((IASTDeclarator)def).getName();
|
def = ((IASTDeclarator)def).getName();
|
||||||
if( def != name )
|
if (def != name) {
|
||||||
return new ProblemBinding( name, IProblemBinding.SEMANTIC_INVALID_REDEFINITION, name.toCharArray() );
|
return new ProblemBinding(name,
|
||||||
|
IProblemBinding.SEMANTIC_INVALID_REDEFINITION, name.toCharArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return function;
|
return function;
|
||||||
|
@ -606,12 +612,13 @@ public class CPPVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scope instanceof ICPPClassScope) {
|
if (scope instanceof ICPPClassScope) {
|
||||||
if( isConstructor( scope, funcDeclarator) )
|
if (isConstructor(scope, funcDeclarator)) {
|
||||||
binding = template ? (ICPPConstructor) new CPPConstructorTemplate(name)
|
binding = template ? (ICPPConstructor) new CPPConstructorTemplate(name)
|
||||||
: new CPPConstructor((ICPPASTFunctionDeclarator) funcDeclarator);
|
: new CPPConstructor((ICPPASTFunctionDeclarator) funcDeclarator);
|
||||||
else
|
} else {
|
||||||
binding = template ? (ICPPMethod) new CPPMethodTemplate(name)
|
binding = template ? (ICPPMethod) new CPPMethodTemplate(name)
|
||||||
: new CPPMethod((ICPPASTFunctionDeclarator) funcDeclarator);
|
: new CPPMethod((ICPPASTFunctionDeclarator) funcDeclarator);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
binding = template ? (ICPPFunction) new CPPFunctionTemplate(name)
|
binding = template ? (ICPPFunction) new CPPFunctionTemplate(name)
|
||||||
: new CPPFunction((ICPPASTFunctionDeclarator) funcDeclarator);
|
: new CPPFunction((ICPPASTFunctionDeclarator) funcDeclarator);
|
||||||
|
@ -820,13 +827,15 @@ public class CPPVisitor {
|
||||||
}
|
}
|
||||||
node = node.getParent();
|
node = node.getParent();
|
||||||
}
|
}
|
||||||
return new CPPScope.CPPScopeProblem( inputNode, IProblemBinding.SEMANTIC_BAD_SCOPE, inputNode.getRawSignature().toCharArray() );
|
return new CPPScope.CPPScopeProblem(inputNode, IProblemBinding.SEMANTIC_BAD_SCOPE,
|
||||||
|
inputNode.getRawSignature().toCharArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IScope getContainingScope(IASTName name) {
|
public static IScope getContainingScope(IASTName name) {
|
||||||
IScope scope= getContainingScopeOrNull(name);
|
IScope scope= getContainingScopeOrNull(name);
|
||||||
if (scope == null) {
|
if (scope == null) {
|
||||||
return new CPPScope.CPPScopeProblem( name, IProblemBinding.SEMANTIC_BAD_SCOPE, name.toCharArray() );
|
return new CPPScope.CPPScopeProblem(name, IProblemBinding.SEMANTIC_BAD_SCOPE,
|
||||||
|
name.toCharArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
return scope;
|
return scope;
|
||||||
|
@ -868,13 +877,13 @@ public class CPPVisitor {
|
||||||
} else if (binding instanceof IProblemBinding) {
|
} else if (binding instanceof IProblemBinding) {
|
||||||
if (binding instanceof ICPPScope)
|
if (binding instanceof ICPPScope)
|
||||||
scope= (IScope) binding;
|
scope= (IScope) binding;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
done= false;
|
done= false;
|
||||||
}
|
}
|
||||||
if (done) {
|
if (done) {
|
||||||
if (scope == null) {
|
if (scope == null) {
|
||||||
return new CPPScope.CPPScopeProblem( names[i-1], IProblemBinding.SEMANTIC_BAD_SCOPE, names[i-1].toCharArray() );
|
return new CPPScope.CPPScopeProblem(names[i - 1],
|
||||||
|
IProblemBinding.SEMANTIC_BAD_SCOPE, names[i-1].toCharArray());
|
||||||
}
|
}
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
@ -942,8 +951,6 @@ public class CPPVisitor {
|
||||||
return getContainingScope(name);
|
return getContainingScope(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (scope == null)
|
if (scope == null)
|
||||||
return getContainingScope(parent);
|
return getContainingScope(parent);
|
||||||
return scope;
|
return scope;
|
||||||
|
@ -995,9 +1002,10 @@ public class CPPVisitor {
|
||||||
node = ((IASTUnaryExpression)node).getOperand();
|
node = ((IASTUnaryExpression)node).getOperand();
|
||||||
} else if (node instanceof IASTBinaryExpression) {
|
} else if (node instanceof IASTBinaryExpression) {
|
||||||
node = ((IASTBinaryExpression)node).getOperand2();
|
node = ((IASTBinaryExpression)node).getOperand2();
|
||||||
} else
|
} else {
|
||||||
node = null;
|
node = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
if (name instanceof ICPPASTQualifiedName) {
|
if (name instanceof ICPPASTQualifiedName) {
|
||||||
IASTName ns[] = ((ICPPASTQualifiedName)name).getNames();
|
IASTName ns[] = ((ICPPASTQualifiedName)name).getNames();
|
||||||
|
@ -1039,8 +1047,7 @@ public class CPPVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addProblem(IASTProblem problem) {
|
private void addProblem(IASTProblem problem) {
|
||||||
if( problems.length == numFound ) // if the found array is full, then double the array
|
if (problems.length == numFound) { // if the found array is full, then double the array
|
||||||
{
|
|
||||||
IASTProblem[] old = problems;
|
IASTProblem[] old = problems;
|
||||||
problems = new IASTProblem[old.length * 2];
|
problems = new IASTProblem[old.length * 2];
|
||||||
for (int j = 0; j < old.length; ++j)
|
for (int j = 0; j < old.length; ++j)
|
||||||
|
@ -1134,23 +1141,20 @@ public class CPPVisitor {
|
||||||
if (binding instanceof ICPPUsingDeclaration) {
|
if (binding instanceof ICPPUsingDeclaration) {
|
||||||
this.bindings= ((ICPPUsingDeclaration) binding).getDelegates();
|
this.bindings= ((ICPPUsingDeclaration) binding).getDelegates();
|
||||||
kind= KIND_COMPOSITE;
|
kind= KIND_COMPOSITE;
|
||||||
}
|
} else if (binding instanceof ILabel) {
|
||||||
else if( binding instanceof ILabel )
|
|
||||||
kind = KIND_LABEL;
|
kind = KIND_LABEL;
|
||||||
else if( binding instanceof ICPPTemplateParameter )
|
} else if (binding instanceof ICPPTemplateParameter) {
|
||||||
kind = KIND_TEMPLATE_PARAMETER;
|
kind = KIND_TEMPLATE_PARAMETER;
|
||||||
else if( binding instanceof ICompositeType ||
|
} else if (binding instanceof ICompositeType ||
|
||||||
binding instanceof ITypedef ||
|
binding instanceof ITypedef ||
|
||||||
binding instanceof IEnumeration)
|
binding instanceof IEnumeration) {
|
||||||
{
|
|
||||||
kind = KIND_TYPE;
|
kind = KIND_TYPE;
|
||||||
}
|
} else if (binding instanceof ICPPNamespace) {
|
||||||
else if( binding instanceof ICPPNamespace) {
|
|
||||||
kind = KIND_NAMESPACE;
|
kind = KIND_NAMESPACE;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
kind = KIND_OBJ_FN;
|
kind = KIND_OBJ_FN;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTName name) {
|
public int visit(IASTName name) {
|
||||||
|
@ -1163,8 +1167,7 @@ public class CPPVisitor {
|
||||||
switch(kind) {
|
switch(kind) {
|
||||||
case KIND_TEMPLATE_PARAMETER:
|
case KIND_TEMPLATE_PARAMETER:
|
||||||
if (prop == ICPPASTSimpleTypeTemplateParameter.PARAMETER_NAME ||
|
if (prop == ICPPASTSimpleTypeTemplateParameter.PARAMETER_NAME ||
|
||||||
prop == ICPPASTTemplatedTypeTemplateParameter.PARAMETER_NAME )
|
prop == ICPPASTTemplatedTypeTemplateParameter.PARAMETER_NAME) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
} else if (prop == IASTDeclarator.DECLARATOR_NAME) {
|
} else if (prop == IASTDeclarator.DECLARATOR_NAME) {
|
||||||
IASTNode d = name.getParent();
|
IASTNode d = name.getParent();
|
||||||
|
@ -1175,16 +1178,17 @@ public class CPPVisitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
||||||
case KIND_LABEL:
|
case KIND_LABEL:
|
||||||
if (prop == IASTLabelStatement.NAME)
|
if (prop == IASTLabelStatement.NAME)
|
||||||
break;
|
break;
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
||||||
case KIND_TYPE:
|
case KIND_TYPE:
|
||||||
case KIND_COMPOSITE:
|
case KIND_COMPOSITE:
|
||||||
if (prop == IASTCompositeTypeSpecifier.TYPE_NAME ||
|
if (prop == IASTCompositeTypeSpecifier.TYPE_NAME ||
|
||||||
prop == IASTEnumerationSpecifier.ENUMERATION_NAME ||
|
prop == IASTEnumerationSpecifier.ENUMERATION_NAME ||
|
||||||
prop == ICPPASTUsingDeclaration.NAME )
|
prop == ICPPASTUsingDeclaration.NAME) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
} else if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME) {
|
} else if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME) {
|
||||||
IASTNode p = name.getParent().getParent();
|
IASTNode p = name.getParent().getParent();
|
||||||
|
@ -1207,18 +1211,18 @@ public class CPPVisitor {
|
||||||
|
|
||||||
if (kind == KIND_TYPE)
|
if (kind == KIND_TYPE)
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
||||||
case KIND_OBJ_FN:
|
case KIND_OBJ_FN:
|
||||||
if (prop == IASTDeclarator.DECLARATOR_NAME ||
|
if (prop == IASTDeclarator.DECLARATOR_NAME ||
|
||||||
prop == IASTEnumerationSpecifier.IASTEnumerator.ENUMERATOR_NAME ||
|
prop == IASTEnumerationSpecifier.IASTEnumerator.ENUMERATOR_NAME ||
|
||||||
prop == ICPPASTUsingDeclaration.NAME )
|
prop == ICPPASTUsingDeclaration.NAME) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
||||||
case KIND_NAMESPACE:
|
case KIND_NAMESPACE:
|
||||||
if (prop == ICPPASTNamespaceDefinition.NAMESPACE_NAME ||
|
if (prop == ICPPASTNamespaceDefinition.NAMESPACE_NAME ||
|
||||||
prop == ICPPASTNamespaceAlias.ALIAS_NAME )
|
prop == ICPPASTNamespaceAlias.ALIAS_NAME) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
@ -1318,7 +1322,8 @@ public class CPPVisitor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTName name) {
|
public int visit(IASTName name) {
|
||||||
if( name instanceof ICPPASTQualifiedName || name instanceof ICPPASTTemplateId ) return PROCESS_CONTINUE;
|
if (name instanceof ICPPASTQualifiedName || name instanceof ICPPASTTemplateId)
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
|
||||||
ASTNodeProperty prop = name.getPropertyInParent();
|
ASTNodeProperty prop = name.getPropertyInParent();
|
||||||
ASTNodeProperty p2 = null;
|
ASTNodeProperty p2 = null;
|
||||||
|
@ -1340,12 +1345,9 @@ public class CPPVisitor {
|
||||||
prop == ICPPASTUsingDeclaration.NAME ||
|
prop == ICPPASTUsingDeclaration.NAME ||
|
||||||
prop == ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier.NAME ||
|
prop == ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier.NAME ||
|
||||||
prop == ICPPASTTemplateId.TEMPLATE_NAME ||
|
prop == ICPPASTTemplateId.TEMPLATE_NAME ||
|
||||||
p2 == ICPPASTQualifiedName.SEGMENT_NAME )
|
p2 == ICPPASTQualifiedName.SEGMENT_NAME) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
} else if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME) {
|
||||||
else if( prop == IASTElaboratedTypeSpecifier.TYPE_NAME )
|
|
||||||
{
|
|
||||||
IASTNode p = name.getParent().getParent();
|
IASTNode p = name.getParent().getParent();
|
||||||
if (!(p instanceof IASTSimpleDeclaration) ||
|
if (!(p instanceof IASTSimpleDeclaration) ||
|
||||||
((IASTSimpleDeclaration)p).getDeclarators().length > 0)
|
((IASTSimpleDeclaration)p).getDeclarators().length > 0)
|
||||||
|
@ -1364,8 +1366,7 @@ public class CPPVisitor {
|
||||||
prop == ICPPASTUsingDeclaration.NAME ||
|
prop == ICPPASTUsingDeclaration.NAME ||
|
||||||
prop == IASTNamedTypeSpecifier.NAME ||
|
prop == IASTNamedTypeSpecifier.NAME ||
|
||||||
prop == ICPPASTConstructorChainInitializer.MEMBER_ID ||
|
prop == ICPPASTConstructorChainInitializer.MEMBER_ID ||
|
||||||
prop == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT )
|
prop == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
@ -1373,8 +1374,7 @@ public class CPPVisitor {
|
||||||
if (prop == ICPPASTUsingDirective.QUALIFIED_NAME ||
|
if (prop == ICPPASTUsingDirective.QUALIFIED_NAME ||
|
||||||
prop == ICPPASTNamespaceAlias.MAPPING_NAME ||
|
prop == ICPPASTNamespaceAlias.MAPPING_NAME ||
|
||||||
prop == ICPPASTUsingDeclaration.NAME ||
|
prop == ICPPASTUsingDeclaration.NAME ||
|
||||||
p2 == ICPPASTQualifiedName.SEGMENT_NAME )
|
p2 == ICPPASTQualifiedName.SEGMENT_NAME) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
@ -1778,7 +1778,8 @@ public class CPPVisitor {
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return e.getProblem();
|
return e.getProblem();
|
||||||
}
|
}
|
||||||
return new ProblemBinding(expression, IProblemBinding.SEMANTIC_BAD_SCOPE, binding.getName().toCharArray());
|
return new ProblemBinding(expression, IProblemBinding.SEMANTIC_BAD_SCOPE,
|
||||||
|
binding.getName().toCharArray());
|
||||||
} else if (binding instanceof IFunction) {
|
} else if (binding instanceof IFunction) {
|
||||||
IFunctionType fType;
|
IFunctionType fType;
|
||||||
try {
|
try {
|
||||||
|
@ -1862,9 +1863,7 @@ public class CPPVisitor {
|
||||||
((CPPBasicType)result).setValue(expression);
|
((CPPBasicType)result).setValue(expression);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
} else if (expression instanceof IASTUnaryExpression) {
|
||||||
else if( expression instanceof IASTUnaryExpression )
|
|
||||||
{
|
|
||||||
int op = ((IASTUnaryExpression)expression).getOperator();
|
int op = ((IASTUnaryExpression)expression).getOperator();
|
||||||
if (op == IASTUnaryExpression.op_sizeof) {
|
if (op == IASTUnaryExpression.op_sizeof) {
|
||||||
IScope scope = getContainingScope(expression);
|
IScope scope = getContainingScope(expression);
|
||||||
|
|
|
@ -44,8 +44,7 @@ public class TemplateInstanceUtil {
|
||||||
if(specd instanceof ICPPTemplateDefinition) {
|
if(specd instanceof ICPPTemplateDefinition) {
|
||||||
keysToAdapt= ((ICPPTemplateDefinition)specd).getTemplateParameters();
|
keysToAdapt= ((ICPPTemplateDefinition)specd).getTemplateParameters();
|
||||||
}
|
}
|
||||||
final int length= Math.min(keys.length, keysToAdapt.length);
|
for(int i = 0; i < keys.length && i < keysToAdapt.length; i++) {
|
||||||
for(int i=0; i<length; i++) {
|
|
||||||
IType type= (IType) preresult.get(keys[i]);
|
IType type= (IType) preresult.get(keys[i]);
|
||||||
result.put(
|
result.put(
|
||||||
cf.getCompositeBinding((IIndexFragmentBinding)keysToAdapt[i]),
|
cf.getCompositeBinding((IIndexFragmentBinding)keysToAdapt[i]),
|
||||||
|
|
Loading…
Add table
Reference in a new issue