mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 351009: Content assist for member-initializer outside of class body.
This commit is contained in:
parent
5b93048496
commit
a938fee083
2 changed files with 26 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue