Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2017-01-27 02:18:57 -0500
committerNathan Ridge2017-02-10 13:35:48 -0500
commitfcd3f62d316282789ca7c79294861e289f7d7de9 (patch)
tree3c34574cce01ca513197849be52d47665c16bb0e
parentbbbf9c7059d703307d33a6fb23312da4f8c07cb5 (diff)
downloadorg.eclipse.cdt-fcd3f62d316282789ca7c79294861e289f7d7de9.tar.gz
org.eclipse.cdt-fcd3f62d316282789ca7c79294861e289f7d7de9.tar.xz
org.eclipse.cdt-fcd3f62d316282789ca7c79294861e289f7d7de9.zip
Bug 511048 - Offer completion proposals for nonstatic methods in a using-declaration
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java12
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java17
2 files changed, 26 insertions, 3 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java
index 34c729dfab..96c3ccc0fc 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java
@@ -38,6 +38,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;
@@ -342,6 +343,11 @@ public class CPPASTQualifiedName extends CPPASTNameBase
return bindings;
}
+ // 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) {
@@ -368,14 +374,14 @@ public class CPPASTQualifiedName extends CPPASTNameBase
private List<IBinding> filterClassScopeBindings(ICPPClassType classType, IBinding[] bindings,
final boolean isDeclaration) {
List<IBinding> filtered = new ArrayList<IBinding>();
- final boolean canBeFieldAccess = canBeFieldAccess(classType);
+ final boolean allowNonstatic = canBeFieldAccess(classType) || inUsingDecl();
final IBinding templateDefinition = (classType instanceof ICPPTemplateInstance)
? ((ICPPTemplateInstance) classType).getTemplateDefinition() : null;
for (final IBinding binding : bindings) {
if (binding instanceof IField) {
IField field = (IField) binding;
- if (!canBeFieldAccess && !field.isStatic())
+ if (!allowNonstatic && !field.isStatic())
continue;
} else if (binding instanceof ICPPMethod) {
ICPPMethod method = (ICPPMethod) binding;
@@ -383,7 +389,7 @@ public class CPPASTQualifiedName extends CPPASTNameBase
continue;
if (!isDeclaration) {
if (method.isDestructor() || method instanceof ICPPConstructor
- || (!canBeFieldAccess && !method.isStatic()))
+ || (!allowNonstatic && !method.isStatic()))
continue;
}
} else if (binding instanceof IEnumerator || binding instanceof IEnumeration) {
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java
index a7d8ee440b..18f16f3827 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java
@@ -1255,6 +1255,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" };

Back to the top