Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarkus Schorn2011-07-05 07:37:38 -0400
committerMarkus Schorn2011-07-05 07:37:38 -0400
commit48094a56891f802f0d5c0daf33518c5b4a654be9 (patch)
treea3a70c91bc53389b6c05fa3bb1f9569dc739c4ca /core
parentbebd18a5b299d8ba3aa5e04b6f148065ba904a64 (diff)
downloadorg.eclipse.cdt-48094a56891f802f0d5c0daf33518c5b4a654be9.tar.gz
org.eclipse.cdt-48094a56891f802f0d5c0daf33518c5b4a654be9.tar.xz
org.eclipse.cdt-48094a56891f802f0d5c0daf33518c5b4a654be9.zip
Bug 351009: Content assist for member-initializer outside of class body.
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java13
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java20
2 files changed, 26 insertions, 7 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java
index 74c3044f17..7e68668203 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java
@@ -288,6 +288,19 @@ public class BasicCompletionTest extends CompletionTestBase {
checkNonPrefixCompletion(code, true, expected);
}
+ // struct A {
+ // A(int, char, int){}
+ // };
+ // struct B : A {
+ // B();
+ // };
+ // B::B() : A
+ public void testCompletionInCtorOfMemberInitializer_351009() throws Exception {
+ String code = getAboveComment();
+ String[] expected= {"A"};
+ checkNonPrefixCompletion(code, true, expected);
+ }
+
// struct S {};
// void foo() {
// S b
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java
index 64b49e12d2..1915f311ca 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java
@@ -21,14 +21,15 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICPPASTCompletionContext;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
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.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArraySet;
@@ -160,11 +161,16 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements
private CharArraySet getBaseClasses(IASTName name) {
CharArraySet result= new CharArraySet(2);
for (IASTNode parent = name.getParent(); parent != null; parent = parent.getParent()) {
- if (parent instanceof ICPPASTCompositeTypeSpecifier) {
- ICPPASTCompositeTypeSpecifier specifier = (ICPPASTCompositeTypeSpecifier) parent;
- for (ICPPASTBaseSpecifier bs : specifier.getBaseSpecifiers()) {
- result.put(bs.getName().getLastName().getSimpleID());
- }
+ if (parent instanceof ICPPASTFunctionDefinition) {
+ ICPPASTFunctionDefinition fdef= (ICPPASTFunctionDefinition) parent;
+ IBinding method= fdef.getDeclarator().getName().resolveBinding();
+ if (method instanceof ICPPMethod) {
+ ICPPClassType cls= ((ICPPMethod) method).getClassOwner();
+ for (ICPPBase base : cls.getBases()) {
+ result.put(base.getBaseClassSpecifierName().getSimpleID());
+ }
+ return result;
+ }
}
}
return result;

Back to the top