mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 01:45:33 +02:00
Bug 511048 - Offer completion proposals for nonstatic methods in a using-declaration
Change-Id: Ifb3aee10c354aebe606c439cdda1453b1cc29095
This commit is contained in:
parent
7b8bf74386
commit
5a4e821cfb
2 changed files with 24 additions and 1 deletions
|
@ -39,6 +39,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
|
@ -336,6 +337,11 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
|||
&& ((IASTUnaryExpression) getParent().getParent()).getOperator() == IASTUnaryExpression.op_amper;
|
||||
}
|
||||
|
||||
// Are we inside a using-declaration?
|
||||
private boolean inUsingDecl() {
|
||||
return getParent() instanceof ICPPASTUsingDeclaration;
|
||||
}
|
||||
|
||||
private boolean canBeFieldAccess(ICPPClassType baseClass) {
|
||||
IASTNode parent= getParent();
|
||||
if (parent instanceof IASTFieldReference) {
|
||||
|
@ -390,7 +396,7 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
|||
private List<IBinding> filterClassScopeBindings(ICPPClassType classType, IBinding[] bindings,
|
||||
final boolean isDeclaration) {
|
||||
List<IBinding> filtered = new ArrayList<IBinding>();
|
||||
final boolean allowNonstatic = canBeFieldAccess(classType) || isAddressOf();
|
||||
final boolean allowNonstatic = canBeFieldAccess(classType) || isAddressOf() || inUsingDecl();
|
||||
final IBinding templateDefinition = (classType instanceof ICPPTemplateInstance)
|
||||
? ((ICPPTemplateInstance) classType).getTemplateDefinition() : null;
|
||||
|
||||
|
|
|
@ -1364,6 +1364,23 @@ public class CompletionTests extends CompletionTestBase {
|
|||
assertCompletionResults(fCursorOffset, expected, REPLACEMENT);
|
||||
}
|
||||
|
||||
// class Base {
|
||||
// private:
|
||||
// void priv();
|
||||
// protected:
|
||||
// void prot();
|
||||
// public:
|
||||
// void publ();
|
||||
// };
|
||||
// class Derived : Base {
|
||||
// using Base::/*cursor*/
|
||||
// };
|
||||
public void testUsingDeclarationInClass_511048() throws Exception {
|
||||
final String[] expected = { "prot(void)", "publ(void)" };
|
||||
assertCompletionResults(fCursorOffset, expected, ID);
|
||||
}
|
||||
|
||||
|
||||
// template <typen/*cursor*/
|
||||
public void testTemplateDeclaration_397288() throws Exception {
|
||||
final String[] expected= { "typename" };
|
||||
|
|
Loading…
Add table
Reference in a new issue