mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 19:35:36 +02:00
Fix for Bug 172317 - [Content Assist] Class scoped reference: missing proposals (patch by Bryan Wilkinson)
This commit is contained in:
parent
7389698aa4
commit
97429d512d
3 changed files with 63 additions and 38 deletions
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
|
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
|
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.ICPPASTQualifiedName;
|
||||||
|
@ -301,41 +302,71 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
||||||
public IBinding[] resolvePrefix(IASTName n) {
|
public IBinding[] resolvePrefix(IASTName n) {
|
||||||
IBinding binding = names[names.length - 2].resolveBinding();
|
IBinding binding = names[names.length - 2].resolveBinding();
|
||||||
if (binding instanceof ICPPClassType) {
|
if (binding instanceof ICPPClassType) {
|
||||||
ICPPClassType classType = (ICPPClassType) binding;
|
return resolveClassScopePrefix((ICPPClassType) binding,
|
||||||
List bindings = new ArrayList();
|
n.toCharArray());
|
||||||
char[] name = n.toCharArray();
|
|
||||||
|
|
||||||
try {
|
|
||||||
ICPPMethod[] methods = classType.getDeclaredMethods();
|
|
||||||
for (int i = 0; i < methods.length; i++) {
|
|
||||||
char[] potential = methods[i].getNameCharArray();
|
|
||||||
if (CharArrayUtils.equals(potential, 0, name.length, name, false)) {
|
|
||||||
bindings.add(methods[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (DOMException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return (IBinding[]) bindings.toArray(new IBinding[bindings.size()]);
|
|
||||||
} else if (binding instanceof ICPPNamespace) {
|
} else if (binding instanceof ICPPNamespace) {
|
||||||
ICPPNamespace namespace = (ICPPNamespace) binding;
|
return resolveNamespaceScopePrefix((ICPPNamespace) binding,
|
||||||
List bindings = new ArrayList();
|
n.toCharArray());
|
||||||
char[] name = n.toCharArray();
|
|
||||||
|
|
||||||
try {
|
|
||||||
IBinding[] members = namespace.getMemberBindings();
|
|
||||||
for (int i = 0 ; i < members.length; i++) {
|
|
||||||
char[] potential = members[i].getNameCharArray();
|
|
||||||
if (CharArrayUtils.equals(potential, 0, name.length, name, false)) {
|
|
||||||
bindings.add(members[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (DOMException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return (IBinding[]) bindings.toArray(new IBinding[bindings.size()]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IBinding[] resolveClassScopePrefix(ICPPClassType classType, char[] name) {
|
||||||
|
List bindings = new ArrayList();
|
||||||
|
|
||||||
|
try {
|
||||||
|
IField[] fields = classType.getFields();
|
||||||
|
for (int i = 0; i < fields.length; i++) {
|
||||||
|
if (fields[i].isStatic()) {
|
||||||
|
char[] potential = fields[i].getNameCharArray();
|
||||||
|
if (CharArrayUtils.equals(potential, 0, name.length, name, false)) {
|
||||||
|
bindings.add(fields[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (DOMException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ICPPMethod[] methods = classType.getDeclaredMethods();
|
||||||
|
for (int i = 0; i < methods.length; i++) {
|
||||||
|
char[] potential = methods[i].getNameCharArray();
|
||||||
|
if (CharArrayUtils.equals(potential, 0, name.length, name, false)) {
|
||||||
|
bindings.add(methods[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (DOMException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ICPPClassType[] nested = classType.getNestedClasses();
|
||||||
|
for (int i = 0; i < nested.length; i++) {
|
||||||
|
char[] potential = nested[i].getNameCharArray();
|
||||||
|
if (CharArrayUtils.equals(potential, 0, name.length, name, false)) {
|
||||||
|
bindings.add(nested[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (DOMException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return (IBinding[]) bindings.toArray(new IBinding[bindings.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IBinding[] resolveNamespaceScopePrefix(ICPPNamespace namespace, char[] name) {
|
||||||
|
List bindings = new ArrayList();
|
||||||
|
|
||||||
|
try {
|
||||||
|
IBinding[] members = namespace.getMemberBindings();
|
||||||
|
for (int i = 0 ; i < members.length; i++) {
|
||||||
|
char[] potential = members[i].getNameCharArray();
|
||||||
|
if (CharArrayUtils.equals(potential, 0, name.length, name, false)) {
|
||||||
|
bindings.add(members[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (DOMException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return (IBinding[]) bindings.toArray(new IBinding[bindings.size()]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,14 +30,11 @@ public class CompletionTest_ScopedReference_NonCodeScope extends CompletionProp
|
||||||
"Foo(void) ",
|
"Foo(void) ",
|
||||||
"bar(void) void",
|
"bar(void) void",
|
||||||
"fum(void) void",
|
"fum(void) void",
|
||||||
// missing:
|
|
||||||
"x : int"
|
"x : int"
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_ScopedReference_NonCodeScope(String name) {
|
public CompletionTest_ScopedReference_NonCodeScope(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
// unknown problem
|
|
||||||
setExpectFailure(77777);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -30,15 +30,12 @@ public class CompletionTest_VariableType_NestedPrefix extends CompletionProposa
|
||||||
"Foo(void) ",
|
"Foo(void) ",
|
||||||
"bar(void) void",
|
"bar(void) void",
|
||||||
"fum(void) void",
|
"fum(void) void",
|
||||||
// missing:
|
|
||||||
"DEF",
|
"DEF",
|
||||||
"x : int"
|
"x : int"
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_VariableType_NestedPrefix(String name) {
|
public CompletionTest_VariableType_NestedPrefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
// unknown problem
|
|
||||||
setExpectFailure(77777);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue