From 64033dea4c07e84c83937133054fe41f3f6a004b Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Fri, 16 Dec 2016 02:36:44 -0500 Subject: [PATCH] Bug 508254 - Have adapter bindings for anonymous AST bindings implement ICPPInternalBinding Change-Id: I02f035e6746aec4a937a325982033d70d711ffc7 --- .../tests/IndexCPPBindingResolutionTest.java | 9 +++++ .../core/pdom/dom/PDOMASTAdapter.java | 33 ++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java index c13d4e954f4..fb158e39842 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java @@ -2409,4 +2409,13 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas public void testStaticFieldOfEnclosingType_508254() throws Exception { checkBindings(); } + + // namespace { + // struct {} waldo; + // } + + // // empty file + public void testAnonymousStructInAnonymousNamespace_508254() throws Exception { + checkBindings(); + } } 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 8b145ce61a8..a9d74762eb2 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 @@ -45,6 +45,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.parser.IToken; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding; public class PDOMASTAdapter { private static class AnonymousASTName implements IASTName { @@ -430,7 +431,7 @@ public class PDOMASTAdapter { } } - private static class AnonymousCPPBinding implements ICPPBinding { + private static class AnonymousCPPBinding implements ICPPInternalBinding { protected ICPPBinding fDelegate; private char[] fName; @@ -498,6 +499,36 @@ public class PDOMASTAdapter { public IBinding getOwner() { return fDelegate.getOwner(); } + + @Override + public IASTNode getDefinition() { + if (fDelegate instanceof ICPPInternalBinding) { + return ((ICPPInternalBinding) fDelegate).getDefinition(); + } + return null; + } + + @Override + public IASTNode[] getDeclarations() { + if (fDelegate instanceof ICPPInternalBinding) { + return ((ICPPInternalBinding) fDelegate).getDeclarations(); + } + return null; + } + + @Override + public void addDefinition(IASTNode node) { + if (fDelegate instanceof ICPPInternalBinding) { + ((ICPPInternalBinding) fDelegate).addDefinition(node); + } + } + + @Override + public void addDeclaration(IASTNode node) { + if (fDelegate instanceof ICPPInternalBinding) { + ((ICPPInternalBinding) fDelegate).addDeclaration(node); + } + } } private static class AnonymousCPPEnumeration extends AnonymousCPPBinding implements ICPPEnumeration {