Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-02-13 10:11:06 +0000
committerMarkus Schorn2008-02-13 10:11:06 +0000
commit51beaeaa4252af007359f2b5943a550ac130eb64 (patch)
tree19daae15b9598e24cb9725f292bc20b15eb57f56 /core/org.eclipse.cdt.core/parser
parentc3f7d8269cd64a0d9f61481f897a8039807a2bbb (diff)
downloadorg.eclipse.cdt-51beaeaa4252af007359f2b5943a550ac130eb64.tar.gz
org.eclipse.cdt-51beaeaa4252af007359f2b5943a550ac130eb64.tar.xz
org.eclipse.cdt-51beaeaa4252af007359f2b5943a550ac130eb64.zip
Additional test-case and fix for using-declarations (related to bug 203385).
Diffstat (limited to 'core/org.eclipse.cdt.core/parser')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java35
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPNamespaceScope.java10
3 files changed, 33 insertions, 20 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java
index 1a7f5ea049d..e73099db925 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java
@@ -21,8 +21,10 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective;
+import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.internal.core.index.IIndexScope;
@@ -62,7 +64,7 @@ public class CPPScopeMapper {
if (parent instanceof IIndexScope) {
return mapToASTScope((IIndexScope) parent);
}
- return fTuScope;
+ return fTu.getScope();
}
public IName getScopeName() throws DOMException {
@@ -99,7 +101,7 @@ public class CPPScopeMapper {
public IScope getContainingScope() {
final IScope scope= fDirective.getContainingScope();
if (scope == null) {
- return fTuScope;
+ return fTu.getScope();
}
return scope;
}
@@ -118,11 +120,11 @@ public class CPPScopeMapper {
private final HashMap<IIndexScope, IScope> fMappedScopes= new HashMap<IIndexScope, IScope>();
private final HashMap<String, NamespaceScopeWrapper> fNamespaceWrappers= new HashMap<String, NamespaceScopeWrapper>();
private final Map<String, List<UsingDirectiveWrapper>> fPerName= new HashMap<String, List<UsingDirectiveWrapper>>();
- private final CPPNamespaceScope fTuScope;
+ private final CPPASTTranslationUnit fTu;
public CPPScopeMapper(CPPASTTranslationUnit tu) {
- fTuScope= tu.getScope();
+ fTu= tu;
}
/**
@@ -169,13 +171,14 @@ public class CPPScopeMapper {
}
private String getReverseQualifiedName(IScope scope) throws DOMException {
- if (scope == fTuScope || scope == null) {
+ final CPPNamespaceScope tuscope = fTu.getScope();
+ if (scope == tuscope || scope == null) {
return ""; //$NON-NLS-1$
}
StringBuilder buf= new StringBuilder();
buf.append(scope.getScopeName().toCharArray());
scope= scope.getParent();
- while (scope != null && scope != fTuScope) {
+ while (scope != null && scope != tuscope) {
buf.append(':');
buf.append(scope.getScopeName().toCharArray());
scope= scope.getParent();
@@ -188,14 +191,14 @@ public class CPPScopeMapper {
*/
public IScope mapToASTScope(IIndexScope scope) {
if (scope == null) {
- return fTuScope;
+ return fTu.getScope();
}
if (scope instanceof ICPPNamespaceScope) {
IScope result= fMappedScopes.get(scope);
if (result == null) {
- result= fTuScope.findNamespaceScope(scope);
+ result= fTu.getScope().findNamespaceScope(scope);
if (result == null) {
- result= wrapNamespaceScope(scope);
+ result= wrapNamespaceScope((ICPPNamespaceScope) scope);
}
fMappedScopes.put(scope, result);
}
@@ -204,12 +207,12 @@ public class CPPScopeMapper {
return scope;
}
- private IScope wrapNamespaceScope(IIndexScope scope) {
+ private IScope wrapNamespaceScope(ICPPNamespaceScope scope) {
try {
String rqname= getReverseQualifiedName(scope);
NamespaceScopeWrapper result= fNamespaceWrappers.get(rqname);
if (result == null) {
- result= new NamespaceScopeWrapper((ICPPNamespaceScope) scope);
+ result= new NamespaceScopeWrapper(getCompositeNamespaceScope(scope));
fNamespaceWrappers.put(rqname, result);
}
return result;
@@ -218,4 +221,14 @@ public class CPPScopeMapper {
return null;
}
}
+
+ private ICPPNamespaceScope getCompositeNamespaceScope(ICPPNamespaceScope scope) throws DOMException {
+ if (scope instanceof IIndexScope) {
+ IIndexBinding binding= fTu.getIndex().adaptBinding(((IIndexScope) scope).getScopeBinding());
+ if (binding instanceof ICPPNamespace) {
+ scope= ((ICPPNamespace) binding).getNamespaceScope();
+ }
+ }
+ return scope;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
index 70886dfe887..bda2979901a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
@@ -1074,7 +1074,7 @@ public class CPPSemantics {
IBinding binding = scope.getBinding( data.astName, false, fileSet );
if (binding instanceof CPPImplicitFunction || binding instanceof CPPImplicitTypedef)
mergeResults( data, binding, true );
- else
+ else if (binding != null)
b = new IBinding[] { binding };
} else {
b = scope.getBindings( data.astName, false, data.prefixLookup, fileSet );
@@ -2399,9 +2399,9 @@ public class CPPSemantics {
outer: for( int fnIdx = 0; fnIdx < numFns; fnIdx++ ){
currFn = (IFunction) fns[fnIdx];
- if( currFn == null || bestFn == currFn ||
- ( bestFn instanceof ICPPDelegate && ((ICPPDelegate)bestFn).getBinding() == currFn ) ||
- ( currFn instanceof ICPPDelegate && ((ICPPDelegate)currFn).getBinding() == bestFn ) )
+ if (currFn == null || bestFn == currFn ||
+ (bestFn instanceof ICPPDelegate && currFn.equals(((ICPPDelegate)bestFn).getBinding())) ||
+ (bestFn != null && currFn instanceof ICPPDelegate && bestFn.equals(((ICPPDelegate)currFn).getBinding())) )
{
continue;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPNamespaceScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPNamespaceScope.java
index ecb9fcab41c..cb415e16ebf 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPNamespaceScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPNamespaceScope.java
@@ -20,7 +20,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.index.IIndexName;
-import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.index.composite.CompositeScope;
@@ -53,12 +52,13 @@ class CompositeCPPNamespaceScope extends CompositeScope implements ICPPNamespace
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet)
throws DOMException {
- IBinding[] preresult = null;
+ IIndexFragmentBinding[][] preresult = new IIndexFragmentBinding[namespaces.length][];
for(int i=0; i<namespaces.length; i++) {
- preresult = (IBinding[]) ArrayUtil.addAll(IBinding.class, preresult,
- namespaces[i].getNamespaceScope().getBindings(name, resolve, prefixLookup, fileSet));
+ IBinding[] raw = namespaces[i].getNamespaceScope().getBindings(name, resolve, prefixLookup, fileSet);
+ preresult[i] = new IIndexFragmentBinding[raw.length];
+ System.arraycopy(raw, 0, preresult[i], 0, raw.length);
}
- return processUncertainBindings(preresult);
+ return cf.getCompositeBindings(preresult);
}
final public IBinding[] find(String name) throws DOMException {

Back to the top