Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-02-05 14:10:36 +0000
committerMarkus Schorn2008-02-05 14:10:36 +0000
commit3e365c0aac926c27505f98ffcbb436497336f238 (patch)
tree66e6ca3743ede944e218d309e9684c8fabb9836d /core/org.eclipse.cdt.core/parser
parentdfb5057e5cd10ca36660affdce593aff52fc9a4a (diff)
downloadorg.eclipse.cdt-3e365c0aac926c27505f98ffcbb436497336f238.tar.gz
org.eclipse.cdt-3e365c0aac926c27505f98ffcbb436497336f238.tar.xz
org.eclipse.cdt-3e365c0aac926c27505f98ffcbb436497336f238.zip
Support for unnamed namespaces, bug 162226.
Diffstat (limited to 'core/org.eclipse.cdt.core/parser')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java53
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCEnumeration.java13
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCStructure.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java62
9 files changed, 112 insertions, 61 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java
index c445277198a..067a1a93e9a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -36,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.core.runtime.CoreException;
public class PDOMASTAdapter {
@@ -173,6 +174,7 @@ public class PDOMASTAdapter {
throw new PDOMNotImplementedError();
}
+ @SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
return fDelegate.getAdapter(adapter);
}
@@ -219,6 +221,7 @@ public class PDOMASTAdapter {
return fDelegate.findField(name);
}
+ @SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
return fDelegate.getAdapter(adapter);
}
@@ -295,6 +298,7 @@ public class PDOMASTAdapter {
return qn;
}
+ @SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
return fDelegate.getAdapter(adapter);
}
@@ -391,8 +395,8 @@ public class PDOMASTAdapter {
* is not appropriate (e.g. binding is not a type).
* Otherwise, if the binding has a name it is returned unchanged.
*/
- public static IBinding getAdapterIfAnonymous(IBinding binding) {
- if (binding != null) {
+ public static IBinding getAdapterForAnonymousASTBinding(IBinding binding) {
+ if (binding != null && !(binding instanceof IIndexBinding)) {
char[] name= binding.getNameCharArray();
if (name.length == 0) {
if (binding instanceof IEnumeration) {
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 e7cd6a56541..89301da89ff 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
@@ -162,9 +162,8 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
return pdom.getDB().getInt(record + LOCAL_TO_FILE);
}
- public final void setLocalToFile(PDOMFile file) throws CoreException {
- final int filerec= file == null ? 0 : file.getRecord();
- pdom.getDB().putInt(record + LOCAL_TO_FILE, filerec);
+ public final void setLocalToFileRec(int rec) throws CoreException {
+ pdom.getDB().putInt(record + LOCAL_TO_FILE, rec);
}
public String getName() {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java
index fe23d40428d..c03fc8823cd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java
@@ -37,7 +37,6 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
@@ -196,7 +195,6 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
return null;
}
- boolean isFromAST= true;
IBinding binding= inputBinding;
if (binding instanceof PDOMBinding) {
// there is no guarantee, that the binding is from the same PDOM object.
@@ -208,7 +206,6 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
if (pdomBinding.isFileLocal()) {
return null;
}
- isFromAST= false;
}
PDOMBinding result= (PDOMBinding) pdom.getCachedResult(inputBinding);
@@ -216,26 +213,20 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
return result;
}
- int fileLocalRec= 0;
- if (isFromAST) {
- // assign names to anonymous types.
- binding= PDOMASTAdapter.getAdapterIfAnonymous(binding);
- if (binding == null) {
- return null;
- }
- PDOMFile lf= getLocalToFile(binding);
- if (lf != null) {
- fileLocalRec= lf.getRecord();
- }
+ // assign names to anonymous types.
+ binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(binding);
+ if (binding == null) {
+ return null;
}
- result= doAdaptBinding(binding, fileLocalRec);
+
+ result= doAdaptBinding(binding);
if (result != null) {
pdom.putCachedResult(inputBinding, result);
}
return result;
}
- protected abstract PDOMBinding doAdaptBinding(IBinding binding, int fileLocalRec) throws CoreException;
+ protected abstract PDOMBinding doAdaptBinding(IBinding binding) throws CoreException;
public final PDOMBinding resolveBinding(IASTName name) throws CoreException {
IBinding binding= name.resolveBinding();
@@ -260,15 +251,6 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
if (binding instanceof ICPPTemplateInstance) {
scopeBinding = ((ICPPTemplateInstance)binding).getTemplateDefinition();
} else {
- // in case this is a delegate the scope of the delegate can be different to the
- // scope of the delegating party (e.g. using-declarations)
- while (binding instanceof ICPPDelegate) {
- final ICPPDelegate delegate = (ICPPDelegate)binding;
- if (delegate.getDelegateType() != ICPPDelegate.USING_DECLARATION) {
- break;
- }
- binding= delegate.getBinding();
- }
IScope scope = binding.getScope();
if (scope == null) {
if (binding instanceof ICPPDeferredTemplateInstance) {
@@ -314,11 +296,13 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
}
}
- if (scope instanceof ICPPNamespaceScope) {
+ while (scope instanceof ICPPNamespaceScope) {
IName name= scope.getScopeName();
if (name != null && name.toCharArray().length == 0) {
// skip unnamed namespaces
- return null;
+ scope= scope.getParent();
+ } else {
+ break;
}
}
@@ -354,6 +338,21 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
return null;
}
+
+ final protected int getLocalToFileRec(PDOMNode parent, IBinding binding) throws CoreException {
+ int rec= 0;
+ if (parent instanceof PDOMBinding) {
+ rec= ((PDOMBinding) parent).getLocalToFileRec();
+ }
+ if (rec == 0) {
+ PDOMFile file= getLocalToFile(binding);
+ if (file != null) {
+ rec= file.getRecord();
+ }
+ }
+ return rec;
+ }
+
protected PDOMFile getLocalToFile(IBinding binding) throws CoreException {
if (pdom instanceof WritablePDOM) {
final WritablePDOM wpdom= (WritablePDOM) pdom;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCEnumeration.java
index 29dbc817f03..7be00b8c259 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCEnumeration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCEnumeration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 QNX Software Systems and others.
+ * Copyright (c) 2006, 2008 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * QNX - Initial API and implementation
- * Markus Schorn (Wind River Systems)
+ * QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.c;
@@ -35,6 +35,7 @@ class PDOMCEnumeration extends PDOMBinding implements IEnumeration, IIndexType {
private static final int FIRST_ENUMERATOR = PDOMBinding.RECORD_SIZE + 0;
+ @SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
public PDOMCEnumeration(PDOM pdom, PDOMNode parent, IEnumeration enumeration)
@@ -56,14 +57,14 @@ class PDOMCEnumeration extends PDOMBinding implements IEnumeration, IIndexType {
public IEnumerator[] getEnumerators() throws DOMException {
try {
- ArrayList enums = new ArrayList();
+ ArrayList<PDOMCEnumerator> enums = new ArrayList<PDOMCEnumerator>();
for (PDOMCEnumerator enumerator = getFirstEnumerator();
enumerator != null;
enumerator = enumerator.getNextEnumerator()) {
enums.add(enumerator);
}
- IEnumerator[] enumerators = (IEnumerator[])enums.toArray(new IEnumerator[enums.size()]);
+ IEnumerator[] enumerators = enums.toArray(new IEnumerator[enums.size()]);
// Reverse the list since they are last in first out
int n = enumerators.length;
@@ -105,7 +106,7 @@ class PDOMCEnumeration extends PDOMBinding implements IEnumeration, IIndexType {
if (type instanceof IEnumeration) {
IEnumeration etype= (IEnumeration) type;
- etype= (IEnumeration) PDOMASTAdapter.getAdapterIfAnonymous(etype);
+ etype= (IEnumeration) PDOMASTAdapter.getAdapterForAnonymousASTBinding(etype);
try {
return getDBName().equals(etype.getNameCharArray());
} catch (CoreException e) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java
index 01a7de8e881..68727593946 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java
@@ -79,7 +79,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
return null;
// assign names to anonymous types.
- binding= PDOMASTAdapter.getAdapterIfAnonymous(binding);
+ binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(binding);
if (binding == null || binding instanceof IParameter)
return null; // skip parameters
@@ -111,7 +111,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
}
if (pdomBinding != null) {
- pdomBinding.setLocalToFile(getLocalToFile(binding));
+ pdomBinding.setLocalToFileRec(getLocalToFileRec(parent, binding));
parent.addChild(pdomBinding);
afterAddBinding(pdomBinding);
}
@@ -172,12 +172,14 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
return 0;
}
- public final PDOMBinding doAdaptBinding(final IBinding binding, int localToFileRec) throws CoreException {
+ public final PDOMBinding doAdaptBinding(final IBinding binding) throws CoreException {
PDOMNode parent = getAdaptedParent(binding, false);
if (parent == this) {
+ int localToFileRec= getLocalToFileRec(null, binding);
return FindBinding.findBinding(getIndex(), getPDOM(), binding.getNameCharArray(), new int[] {getBindingType(binding)}, localToFileRec);
}
if (parent instanceof IPDOMMemberOwner) {
+ int localToFileRec= getLocalToFileRec(parent, binding);
return FindBinding.findBinding(parent, getPDOM(), binding.getNameCharArray(), new int[] {getBindingType(binding)}, localToFileRec);
}
return null;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCStructure.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCStructure.java
index 38b721f7da1..b0fdb1b5db8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCStructure.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCStructure.java
@@ -204,7 +204,7 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
if (type instanceof ICompositeType) {
ICompositeType etype= (ICompositeType) type;
- etype= (ICompositeType) PDOMASTAdapter.getAdapterIfAnonymous(etype);
+ etype= (ICompositeType) PDOMASTAdapter.getAdapterForAnonymousASTBinding(etype);
try {
return getDBName().equals(etype.getNameCharArray());
} catch (CoreException e) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java
index 404a1d9d0ae..dfaa3599cbf 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java
@@ -6,11 +6,11 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * QNX - Initial API and implementation
- * Markus Schorn (Wind River Systems)
- * Andrew Ferguson (Symbian)
- * Bryan Wilkinson (QNX)
- * Sergey Prigogin (Google)
+ * QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
+ * Andrew Ferguson (Symbian)
+ * Bryan Wilkinson (QNX)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@@ -149,7 +149,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
if (type instanceof ICPPClassType && !(type instanceof ProblemBinding)) {
ICPPClassType ctype= (ICPPClassType) type;
- ctype= (ICPPClassType) PDOMASTAdapter.getAdapterIfAnonymous(ctype);
+ ctype= (ICPPClassType) PDOMASTAdapter.getAdapterForAnonymousASTBinding(ctype);
try {
if (ctype.getKey() == getKey()) {
char[][] qname= ctype.getQualifiedNameCharArray();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java
index 753210178e0..908de31dac9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java
@@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * QNX - Initial API and implementation
- * Markus Schorn (Wind River Systems)
- * Sergey Prigogin (Google)
+ * QNX - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@@ -115,7 +115,7 @@ class PDOMCPPEnumeration extends PDOMCPPBinding
if (type instanceof IEnumeration) {
if (type instanceof ICPPBinding) {
ICPPBinding etype= (ICPPBinding) type;
- etype= (ICPPBinding) PDOMASTAdapter.getAdapterIfAnonymous(etype);
+ etype= (ICPPBinding) PDOMASTAdapter.getAdapterForAnonymousASTBinding(etype);
char[][] qname = etype.getQualifiedNameCharArray();
return hasQualifiedName(qname, qname.length-1);
}
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 87d5547caa7..62b62ad5487 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
@@ -18,6 +18,7 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTName;
@@ -38,6 +39,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
@@ -46,6 +48,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
@@ -57,6 +60,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPBasicType;
+import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
@@ -218,10 +222,12 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
public PDOMBinding addBinding(IBinding binding, IASTName fromName) throws CoreException {
// assign names to anonymous types.
- binding= PDOMASTAdapter.getAdapterIfAnonymous(binding);
+ binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(binding);
if (binding == null) {
return null;
}
+ // references to the using-declarations delegates are stored with the original binding.
+ binding = unwrapUsingDelarationDelegates(binding);
PDOMBinding pdomBinding = adaptBinding(binding);
if (pdomBinding != null) {
@@ -245,6 +251,18 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return pdomBinding;
}
+ private IBinding unwrapUsingDelarationDelegates(IBinding binding) {
+ while (binding instanceof ICPPDelegate) {
+ ICPPDelegate d= (ICPPDelegate) binding;
+ if (d.getDelegateType() == ICPPDelegate.USING_DECLARATION) {
+ binding= d.getBinding();
+ } else {
+ break;
+ }
+ }
+ return binding;
+ }
+
private void addConstructors(PDOMBinding pdomBinding, ICPPClassType binding)
throws DOMException, CoreException {
ICPPConstructor[] constructors = binding.getConstructors();
@@ -407,7 +425,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
}
if (pdomBinding != null) {
- pdomBinding.setLocalToFile(getLocalToFile(binding));
+ pdomBinding.setLocalToFileRec(getLocalToFileRec(parent, binding));
parent.addChild(pdomBinding);
afterAddBinding(pdomBinding);
}
@@ -553,15 +571,21 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
* Find the equivalent binding, or binding placeholder within this PDOM
*/
@Override
- public PDOMBinding doAdaptBinding(IBinding binding, int localToFileRec) throws CoreException {
+ public PDOMBinding doAdaptBinding(IBinding binding) throws CoreException {
+ // references to using-declarations are stored with the original binding.
+ binding= unwrapUsingDelarationDelegates(binding);
+
PDOMNode parent = getAdaptedParent(binding, false);
if (parent == this) {
+ int localToFileRec= getLocalToFileRec(null, binding);
return CPPFindBinding.findBinding(getIndex(), this, binding, localToFileRec);
}
if (parent instanceof PDOMCPPNamespace) {
+ int localToFileRec= getLocalToFileRec(parent, binding);
return CPPFindBinding.findBinding(((PDOMCPPNamespace)parent).getIndex(), this, binding, localToFileRec);
}
if (parent instanceof IPDOMMemberOwner) {
+ int localToFileRec= getLocalToFileRec(parent, binding);
return CPPFindBinding.findBinding(parent, this, binding, localToFileRec);
}
return null;
@@ -784,23 +808,45 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
@Override
protected PDOMFile getLocalToFile(IBinding binding) throws CoreException {
- if (binding instanceof ICPPMethod) {
- return null;
- }
if (pdom instanceof WritablePDOM) {
final WritablePDOM wpdom= (WritablePDOM) pdom;
+ PDOMFile file= null;
if (binding instanceof ICPPUsingDeclaration) {
String path= ASTInternal.getDeclaredInOneFileOnly(binding);
if (path != null) {
- return wpdom.getFileForASTPath(getLinkageID(), path);
+ file= wpdom.getFileForASTPath(getLinkageID(), path);
}
} else if (binding instanceof ICPPNamespaceAlias) {
String path= ASTInternal.getDeclaredInSourceFileOnly(binding, false);
if (path != null) {
- return wpdom.getFileForASTPath(getLinkageID(), path);
+ file= wpdom.getFileForASTPath(getLinkageID(), path);
}
}
+ if (file == null && !(binding instanceof IIndexBinding)) {
+ IScope scope;
+ try {
+ scope= binding.getScope();
+ if (scope instanceof ICPPNamespaceScope) {
+ IName name= scope.getScopeName();
+ if (name instanceof IASTName && name.toCharArray().length == 0) {
+ IASTName astName= (IASTName) name;
+ IBinding parentBinding= astName.resolveBinding();
+ String path= ASTInternal.getDeclaredInSourceFileOnly(parentBinding, false);
+ if (path != null) {
+ file= wpdom.getFileForASTPath(getLinkageID(), path);
+ }
+ }
+ }
+ } catch (DOMException e) {
+ }
+ }
+ if (file != null) {
+ return file;
+ }
}
+ if (binding instanceof ICPPMember) {
+ return null;
+ }
return super.getLocalToFile(binding);
}
}

Back to the top