mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 284665.
This commit is contained in:
parent
1c5b36e9a9
commit
72d12ff557
3 changed files with 32 additions and 7 deletions
|
@ -33,6 +33,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
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.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.ICPPField;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
|
@ -1374,12 +1375,28 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
||||||
|
|
||||||
// class A {
|
// class A {
|
||||||
// class B;
|
// class B;
|
||||||
|
// void method();
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// class A::B {};
|
// class A::B {
|
||||||
public void _testNestedClass_284665() throws Exception {
|
// B(int x);
|
||||||
ICPPClassType b = getBindingFromASTName("B {}", 1, ICPPClassType.class);
|
// static void m(int p);
|
||||||
assertFalse(b instanceof IIndexBinding);
|
// };
|
||||||
|
//
|
||||||
|
// void A::method() {
|
||||||
|
// new B(0);
|
||||||
|
// B::m(0);
|
||||||
|
// }
|
||||||
|
public void testNestedClass_284665() throws Exception {
|
||||||
|
ICPPClassType b0 = getBindingFromASTName("B {", 1, ICPPClassType.class);
|
||||||
|
assertFalse(b0 instanceof IIndexBinding);
|
||||||
|
ICPPConstructor b1 = getBindingFromASTName("B(int x)", 1, ICPPConstructor.class);
|
||||||
|
assertFalse(b1 instanceof IIndexBinding);
|
||||||
|
ICPPConstructor b2 = getBindingFromASTName("B(0)", 1, ICPPConstructor.class);
|
||||||
|
assertFalse(b2 instanceof IIndexBinding);
|
||||||
|
assertEquals(b1, b2);
|
||||||
|
ICPPMethod b3 = getBindingFromASTName("m(0)", 1, ICPPMethod.class);
|
||||||
|
assertFalse(b3 instanceof IIndexBinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
// class A {
|
// class A {
|
||||||
|
@ -1479,7 +1496,7 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param binding
|
* @param type
|
||||||
* @param cqn
|
* @param cqn
|
||||||
* @param qn may be null
|
* @param qn may be null
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -352,7 +352,11 @@ public class CPPSemantics {
|
||||||
|
|
||||||
if (data.considerConstructors) {
|
if (data.considerConstructors) {
|
||||||
if (binding instanceof ICPPClassType) {
|
if (binding instanceof ICPPClassType) {
|
||||||
|
if (binding instanceof IIndexBinding) {
|
||||||
|
binding= data.tu.mapToAST((ICPPClassType) binding);
|
||||||
|
}
|
||||||
ICPPClassType cls= (ICPPClassType) binding;
|
ICPPClassType cls= (ICPPClassType) binding;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (data.astName instanceof ICPPASTTemplateId && cls instanceof ICPPClassTemplate) {
|
if (data.astName instanceof ICPPASTTemplateId && cls instanceof ICPPClassTemplate) {
|
||||||
if (data.tu != null) {
|
if (data.tu != null) {
|
||||||
|
|
|
@ -217,9 +217,13 @@ public class CPPVisitor extends ASTQueries {
|
||||||
if (scope != getContainingScope(name))
|
if (scope != getContainingScope(name))
|
||||||
return binding;
|
return binding;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (binding instanceof ICPPClassType && binding instanceof IIndexBinding && name.isDefinition()) {
|
||||||
|
parent= parent.getParent(); // need to create an ast binding.
|
||||||
} else {
|
} else {
|
||||||
return binding;
|
return binding;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (parent instanceof ICPPASTTemplateId) {
|
} else if (parent instanceof ICPPASTTemplateId) {
|
||||||
final ICPPASTTemplateId id = (ICPPASTTemplateId) parent;
|
final ICPPASTTemplateId id = (ICPPASTTemplateId) parent;
|
||||||
if (CPPTemplates.isClassTemplate(id))
|
if (CPPTemplates.isClassTemplate(id))
|
||||||
|
|
Loading…
Add table
Reference in a new issue