mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for bug 201174.
This commit is contained in:
parent
a64cedd926
commit
52dda7b84f
2 changed files with 39 additions and 5 deletions
|
@ -17,6 +17,7 @@ import junit.framework.TestSuite;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
|
@ -91,7 +92,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// c1.m1("aaa"); // OK
|
||||
// c1.m2("aaa"); // problem
|
||||
// }
|
||||
public void _testUnindexedConstructorInstanceImplicitReferenceToDeferred() throws Exception {
|
||||
public void testUnindexedConstructorInstanceImplicitReferenceToDeferred() throws Exception {
|
||||
IBinding b0= getBindingFromASTName("C1<char> c1", 8);
|
||||
IBinding b1= getBindingFromASTName("m1(\"aaa\")", 2);
|
||||
IBinding b2= getBindingFromASTName("m2(\"aaa\")", 2);
|
||||
|
@ -115,6 +116,25 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertInstance(b0, ICPPMethod.class);
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// class StrT {
|
||||
// public: void assign(const T* s) {}
|
||||
// };
|
||||
|
||||
// void main() {
|
||||
// StrT<char> x;
|
||||
// x.assign("aaa");
|
||||
// }
|
||||
public void testUnindexedMethodInstance2() throws Exception {
|
||||
IBinding b0= getBindingFromASTName("assign(\"aaa\")", 6);
|
||||
assertInstance(b0, ICPPMethod.class);
|
||||
assertEquals(1, getIndex().findNames(b0, IIndex.FIND_REFERENCES).length);
|
||||
IParameter[] parameters = ((ICPPMethod) b0).getParameters();
|
||||
System.out.println(String.valueOf(parameters));
|
||||
IFunctionType type = ((ICPPMethod) b0).getType();
|
||||
System.out.println(String.valueOf(type));
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// class X {};
|
||||
|
||||
|
@ -188,7 +208,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// m1("aaa"); // OK
|
||||
// m2("aaa"); // problem
|
||||
// }
|
||||
public void _testUnindexedConstructorInstanceImplicitReference() throws Exception {
|
||||
public void testUnindexedConstructorInstanceImplicitReference() throws Exception {
|
||||
IBinding b0= getBindingFromASTName("m1(\"aaa\")", 2);
|
||||
IBinding b1= getBindingFromASTName("m2(\"aaa\")", 2);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
@ -224,20 +225,33 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
if (shouldUpdate(pdomBinding, fromName)) {
|
||||
pdomBinding.update(this, fromName.getBinding());
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
PDOMNode parent = getAdaptedParent(binding, true, true);
|
||||
if (parent == null)
|
||||
return null;
|
||||
pdomBinding = addBinding(parent, binding);
|
||||
} catch(DOMException e) {
|
||||
if (pdomBinding instanceof PDOMCPPClassInstance && binding instanceof ICPPClassType) {
|
||||
// Add instantiated constructors to the index (bug 201174).
|
||||
addConstructors(pdomBinding, (ICPPClassType) binding);
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
throw new CoreException(Util.createStatus(e));
|
||||
}
|
||||
}
|
||||
return pdomBinding;
|
||||
}
|
||||
|
||||
private void addConstructors(PDOMBinding pdomBinding, ICPPClassType binding)
|
||||
throws DOMException, CoreException {
|
||||
ICPPConstructor[] constructors = binding.getConstructors();
|
||||
for (int i = 0; i < constructors.length; i++) {
|
||||
if (adaptBinding(constructors[i]) == null) {
|
||||
addBinding(pdomBinding, constructors[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldUpdate(PDOMBinding pdomBinding, IASTName fromName) throws CoreException {
|
||||
if (fromName != null) {
|
||||
if (fromName.isReference()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue