Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeScope.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassInstance.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecializationScope.java38
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPNamespaceAlias.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateScope.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java15
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPSpecialization.java24
11 files changed, 106 insertions, 39 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeScope.java
index d60fb3ba2d..3a64f17dc7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeScope.java
@@ -44,7 +44,7 @@ public abstract class CompositeScope implements IIndexScope {
this.rbinding = rbinding;
}
- final public IIndexScope getParent() {
+ public IIndexScope getParent() {
IIndexScope rscope = rbinding.getScope();
if(rscope!=null) {
return cf.getCompositeScope(rscope);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
index d1bd152200..148fb09ea9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
@@ -194,7 +194,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
}
} else if (binding instanceof ICPPTemplateDefinition) {
if (binding instanceof ICPPClassTemplatePartialSpecialization) {
- return new CompositeCPPClassTemplatePartialSpecialization(this, (ICPPClassTemplatePartialSpecialization) binding);
+ return new CompositeCPPClassTemplatePartialSpecialization(this, (ICPPClassTemplatePartialSpecialization) findOneBinding(binding));
} else if (binding instanceof ICPPClassType) {
return new CompositeCPPClassTemplateSpecialization(this, (ICPPClassType) binding);
} else if (binding instanceof ICPPConstructor) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassInstance.java
index 328b8e06f6..3a734fc5b7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassInstance.java
@@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
@@ -42,6 +43,11 @@ public class CompositeCPPClassInstance extends CompositeCPPClassType
return bindings;
}
+ @Override
+ public IScope getCompositeScope() throws DOMException {
+ return new CompositeCPPClassSpecializationScope(cf, rbinding);
+ }
+
public ObjectMap getArgumentMap() { return TemplateInstanceUtil.getArgumentMap(cf, rbinding); }
public IBinding getSpecializedBinding() { return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding); }
public IType[] getArguments() { return TemplateInstanceUtil.getArguments(cf, (ICPPTemplateInstance) rbinding); }
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecializationScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecializationScope.java
index 117ff4de80..4d5ee295d9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecializationScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecializationScope.java
@@ -26,14 +26,11 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
-import org.eclipse.cdt.internal.core.index.composite.CompositingNotImplementedError;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
-/**
- *
- */
public class CompositeCPPClassSpecializationScope extends CompositeCPPClassScope {
-
+ private ObjectMap instanceMap = ObjectMap.EMPTY_MAP;
+
public CompositeCPPClassSpecializationScope(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
super(cf, rbinding);
}
@@ -44,12 +41,13 @@ public class CompositeCPPClassSpecializationScope extends CompositeCPPClassScope
@Override
public ICPPMethod[] getImplicitMethods() {
- throw new CompositingNotImplementedError();
+ // Implicit methods shouldn't have implicit specializations
+ return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
}
@Override
public IBinding[] find(String name) throws DOMException {
- throw new CompositingNotImplementedError();
+ return CPPSemantics.findBindings(this, name, false);
}
@Override
@@ -77,8 +75,28 @@ public class CompositeCPPClassSpecializationScope extends CompositeCPPClassScope
}
@Override
- public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet acceptLocalBindings) throws DOMException {
- throw new CompositingNotImplementedError();
+ public IBinding[] getBindings(IASTName name, boolean forceResolve, boolean prefixLookup,
+ IIndexFileSet fileSet) throws DOMException {
+ char[] c = name.toCharArray();
+ IBinding[] result = null;
+
+ if ((!prefixLookup && CharArrayUtils.equals(c, specialization().getNameCharArray())) ||
+ (prefixLookup && CharArrayUtils.equals(specialization().getNameCharArray(), 0, c.length, c, true))) {
+ result = new IBinding[] { specialization() };
+ }
+
+ ICPPClassType specialized = (ICPPClassType) specialization().getSpecializedBinding();
+ IScope classScope = specialized.getCompositeScope();
+ IBinding[] bindings = classScope != null ?
+ classScope.getBindings(name, forceResolve, prefixLookup, fileSet) : null;
+
+ if (bindings != null) {
+ for (int i = 0; i < bindings.length; i++) {
+ result = (IBinding[]) ArrayUtil.append(IBinding.class, result, getInstance(bindings[i]));
+ }
+ }
+
+ return (IBinding[]) ArrayUtil.trim(IBinding.class, result);
}
private IBinding getInstance(IBinding binding) {
@@ -93,6 +111,4 @@ public class CompositeCPPClassSpecializationScope extends CompositeCPPClassScope
}
return null;
}
-
- private ObjectMap instanceMap = ObjectMap.EMPTY_MAP;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPNamespaceAlias.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPNamespaceAlias.java
index 1f07fa5c54..95a072d1e6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPNamespaceAlias.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPNamespaceAlias.java
@@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
+import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
class CompositeCPPNamespaceAlias extends CompositeCPPBinding implements ICPPNamespaceAlias {
@@ -23,11 +24,15 @@ class CompositeCPPNamespaceAlias extends CompositeCPPBinding implements ICPPName
}
public IBinding[] getMemberBindings() throws DOMException {
- fail(); return null;
+ IBinding[] result= ((ICPPNamespaceAlias)rbinding).getMemberBindings();
+ for(int i=0; i<result.length; i++) {
+ result[i]= cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
+ }
+ return result;
}
public ICPPNamespaceScope getNamespaceScope() throws DOMException {
- fail(); return null;
+ return (ICPPNamespaceScope) cf.getCompositeScope((IIndexScope) ((ICPPNamespaceAlias)rbinding).getNamespaceScope());
}
public IBinding getBinding() {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateScope.java
index e374109127..85d164b8a0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateScope.java
@@ -18,13 +18,14 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFileSet;
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;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
public class CompositeCPPTemplateScope extends CompositeScope implements ICPPTemplateScope {
public CompositeCPPTemplateScope(ICompositesFactory cf,
ICPPTemplateScope rbinding) {
- super(cf, (IIndexFragmentBinding) rbinding);
+ super(cf, (IIndexFragmentBinding) ((IIndexScope)rbinding).getScopeBinding());
}
public ICPPTemplateDefinition getTemplateDefinition() throws DOMException {
@@ -50,4 +51,9 @@ public class CompositeCPPTemplateScope extends CompositeScope implements ICPPTem
public IIndexBinding getScopeBinding() {
return cf.getCompositeBinding(rbinding);
}
+
+ @Override
+ public IIndexScope getParent() {
+ return (IIndexScope) rbinding;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java
index 8d062ab191..d5e47445f4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java
@@ -197,7 +197,13 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
return null;
}
- public final IIndexScope getScope() {
+ /*
+ * Most of the time, the parent node in the binding hierarchy is also the scope. For
+ * some template bindings, this does not hold.
+ *
+ * @see org.eclipse.cdt.internal.core.index.IIndexFragmentBinding#getScope()
+ */
+ public IIndexScope getScope() {
try {
IBinding parent = getParentBinding();
if (parent instanceof IIndexScope) {
@@ -224,8 +230,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
@Override
abstract protected int getRecordSize(); // superclass's implementation is no longer valid
- /* For debug purposes only
- * (non-Javadoc)
+ /* For debug purposes only.
* @see java.lang.Object#toString()
*/
@Override
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java
index 034e96efde..78189ca3cb 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Andrew Ferguson (Symbian)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@@ -296,4 +297,18 @@ class PDOMCPPClassInstance extends PDOMCPPInstance implements
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
list.accept(visitor);
}
+
+
+ @Override
+ public final IIndexScope getScope() {
+ try {
+ IScope scope= getSpecializedBinding().getScope();
+ if(scope instanceof IIndexScope) {
+ return (IIndexScope) scope;
+ }
+ } catch(DOMException de) {
+ CCorePlugin.log(de);
+ }
+ return null;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java
index 81b857af55..e0d61d2bce 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java
@@ -35,7 +35,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
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.index.IndexFilter;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
@@ -144,15 +143,6 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType
public ICPPTemplateDefinition getTemplateDefinition() throws DOMException {
return null;
}
-
-
- @Override
- // this is actually wrong, the undeclared bindings should be filtered out. However, that causes
- // some of the test cases to fail. --> need to look into this.
- // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=227967
- protected IndexFilter getFilterForBindingsOfScope() {
- return IndexFilter.ALL;
- }
private class PDOMCPPTemplateScope implements ICPPTemplateScope, IIndexScope {
public IBinding[] find(String name) throws DOMException {
@@ -197,7 +187,7 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType
}
public IIndexScope getParent() {
- return PDOMCPPClassTemplate.super.getParent();
+ return PDOMCPPClassTemplate.this.getParent();
}
public ICPPTemplateDefinition getTemplateDefinition()
@@ -217,7 +207,7 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType
private PDOMCPPTemplateScope scope;
@Override
- public IIndexScope getParent() {
+ public IIndexScope getScope() {
if (scope == null) {
scope = new PDOMCPPTemplateScope();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
index c1027a163c..480a87591f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
@@ -673,6 +673,14 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return null;
}
+ if (scope instanceof ICPPTemplateScope &&
+ !(binding instanceof ICPPTemplateParameter || binding instanceof ICPPTemplateInstance)) {
+ scope = scope.getParent();
+ if (scope == null) {
+ return this;
+ }
+ }
+
if (scope instanceof IIndexScope) {
if (scope instanceof CompositeScope) { // we special case for performance
return adaptOrAddBinding(add, ((CompositeScope) scope).getRawScopeBinding());
@@ -681,14 +689,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
}
// the scope is from the ast
- if (scope instanceof ICPPTemplateScope &&
- !(binding instanceof ICPPTemplateParameter || binding instanceof ICPPTemplateInstance)) {
- scope = scope.getParent();
- if (scope == null) {
- return null;
- }
- }
-
while (scope instanceof ICPPNamespaceScope) {
IName name= scope.getScopeName();
if (name != null && name.toCharArray().length == 0) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPSpecialization.java
index 479316bd2b..cbf49a5f81 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPSpecialization.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX - Initial API and implementation
+ * Andrew Ferguson (Symbian)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@@ -19,11 +20,14 @@ import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.parser.util.ObjectMap;
+import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
@@ -188,4 +192,24 @@ abstract class PDOMCPPSpecialization extends PDOMCPPBinding implements
}
return result.toString();
}
+
+ @Override
+ public IIndexScope getScope() {
+ try {
+ IBinding parent= getParentBinding();
+ if(parent instanceof ICPPSpecialization && parent instanceof ICPPClassType) {
+ return (IIndexScope) ((ICPPClassType) parent).getCompositeScope();
+ } else {
+ IScope scope= getSpecializedBinding().getScope();
+ if(scope instanceof IIndexScope) {
+ return (IIndexScope) scope;
+ }
+ }
+ } catch(DOMException de) {
+ CCorePlugin.log(de);
+ } catch(CoreException ce) {
+ CCorePlugin.log(ce);
+ }
+ return null;
+ }
}

Back to the top