mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-03 13:43:31 +02:00
184216: add two missing composite template bindings
This commit is contained in:
parent
b3e38d9e19
commit
93ae2153c7
8 changed files with 116 additions and 12 deletions
|
@ -19,9 +19,12 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
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.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
|
@ -29,12 +32,12 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
/**
|
/**
|
||||||
* For testing PDOM binding resolution
|
* For testing PDOM binding resolution
|
||||||
*/
|
*/
|
||||||
public class IndexBindingResolutionBugs extends IndexBindingResolutionTestBase {
|
public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBase {
|
||||||
|
|
||||||
public static class SingleProject extends IndexBindingResolutionBugs {
|
public static class SingleProject extends IndexCPPBindingResolutionBugs {
|
||||||
public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true));}
|
public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true));}
|
||||||
}
|
}
|
||||||
public static class ProjectWithDepProj extends IndexBindingResolutionBugs {
|
public static class ProjectWithDepProj extends IndexCPPBindingResolutionBugs {
|
||||||
public ProjectWithDepProj() {setStrategy(new ReferencedProject(true));}
|
public ProjectWithDepProj() {setStrategy(new ReferencedProject(true));}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,13 +47,39 @@ public class IndexBindingResolutionBugs extends IndexBindingResolutionTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TestSuite suite() {
|
public static TestSuite suite() {
|
||||||
return suite(IndexBindingResolutionBugs.class);
|
return suite(IndexCPPBindingResolutionBugs.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndexBindingResolutionBugs() {
|
public IndexCPPBindingResolutionBugs() {
|
||||||
setStrategy(new SinglePDOMTestStrategy(true));
|
setStrategy(new SinglePDOMTestStrategy(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// class MyClass {
|
||||||
|
// public:
|
||||||
|
// template<class T>
|
||||||
|
// T* MopGetObject(T*& aPtr)
|
||||||
|
// { return 0; }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// template<class T>
|
||||||
|
// T* MopGetObjectNoChaining(T*& aPtr)
|
||||||
|
// { return 0; }
|
||||||
|
//
|
||||||
|
// };
|
||||||
|
|
||||||
|
// int main() {
|
||||||
|
// MyClass* cls;
|
||||||
|
// }
|
||||||
|
public void test184216() throws Exception {
|
||||||
|
IBinding b0= getBindingFromASTName("MyClass", 7);
|
||||||
|
assertInstance(b0, ICPPClassType.class);
|
||||||
|
ICPPClassType ct= (ICPPClassType) b0;
|
||||||
|
ICPPMethod[] ms= ct.getDeclaredMethods(); // 184216 reports CCE thrown
|
||||||
|
assertEquals(2, ms.length);
|
||||||
|
assertInstance(ms[0], ICPPTemplateDefinition.class);
|
||||||
|
assertInstance(ms[1], ICPPTemplateDefinition.class);
|
||||||
|
}
|
||||||
|
|
||||||
// // header file
|
// // header file
|
||||||
// class cl;
|
// class cl;
|
||||||
// typedef cl* t1;
|
// typedef cl* t1;
|
|
@ -42,7 +42,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
||||||
suite.addTest(suite(SingleProject.class));
|
suite.addTest(suite(SingleProject.class));
|
||||||
suite.addTest(suite(ProjectWithDepProj.class));
|
suite.addTest(suite(ProjectWithDepProj.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// template<typename X>
|
// template<typename X>
|
||||||
// void foo(X x) {}
|
// void foo(X x) {}
|
||||||
|
|
|
@ -30,11 +30,11 @@ public class IndexTests extends TestSuite {
|
||||||
suite.addTest(TeamSharedIndexTest.suite());
|
suite.addTest(TeamSharedIndexTest.suite());
|
||||||
suite.addTest(IndexProviderManagerTest.suite());
|
suite.addTest(IndexProviderManagerTest.suite());
|
||||||
|
|
||||||
IndexCBindingResolutionTest.addTests(suite);
|
IndexCPPBindingResolutionBugs.addTests(suite);
|
||||||
IndexCPPTemplateResolutionTest.addTests(suite);
|
|
||||||
IndexCPPBindingResolutionTest.addTests(suite);
|
IndexCPPBindingResolutionTest.addTests(suite);
|
||||||
|
IndexCPPTemplateResolutionTest.addTests(suite);
|
||||||
IndexCBindingResolutionBugs.addTests(suite);
|
IndexCBindingResolutionBugs.addTests(suite);
|
||||||
IndexBindingResolutionBugs.addTests(suite);
|
IndexCBindingResolutionTest.addTests(suite);
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,6 +162,10 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
|
||||||
} else if (binding instanceof ICPPTemplateDefinition) {
|
} else if (binding instanceof ICPPTemplateDefinition) {
|
||||||
if(binding instanceof ICPPClassTemplate) {
|
if(binding instanceof ICPPClassTemplate) {
|
||||||
return new CompositeCPPClassTemplate(this, (ICPPClassType) findOneDefinition(binding));
|
return new CompositeCPPClassTemplate(this, (ICPPClassType) findOneDefinition(binding));
|
||||||
|
} else if (binding instanceof ICPPConstructor) {
|
||||||
|
return new CompositeCPPConstructorTemplate(this, (ICPPConstructor) binding);
|
||||||
|
} else if (binding instanceof ICPPMethod) {
|
||||||
|
return new CompositeCPPMethodTemplate(this, (ICPPMethod) binding);
|
||||||
} else if (binding instanceof ICPPFunctionTemplate) {
|
} else if (binding instanceof ICPPFunctionTemplate) {
|
||||||
return new CompositeCPPFunctionTemplate(this, (ICPPFunction) binding);
|
return new CompositeCPPFunctionTemplate(this, (ICPPFunction) binding);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
public class CompositeCPPConstructorTemplate extends CompositeCPPMethodTemplate implements ICPPConstructor {
|
||||||
|
|
||||||
|
public CompositeCPPConstructorTemplate(ICompositesFactory cf, ICPPConstructor rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExplicit() throws DOMException {
|
||||||
|
return ((ICPPConstructor)rbinding).isExplicit();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
public class CompositeCPPMethodTemplate extends CompositeCPPFunctionTemplate implements ICPPMethod {
|
||||||
|
|
||||||
|
public CompositeCPPMethodTemplate(ICompositesFactory cf, ICPPMethod rbinding) {
|
||||||
|
super(cf, rbinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDestructor() throws DOMException {
|
||||||
|
return ((ICPPMethod)rbinding).isDestructor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isImplicit() {
|
||||||
|
return ((ICPPMethod)rbinding).isImplicit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVirtual() throws DOMException {
|
||||||
|
return ((ICPPMethod)rbinding).isVirtual();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPClassType getClassOwner() throws DOMException {
|
||||||
|
IIndexFragmentBinding rowner = (IIndexFragmentBinding) ((ICPPMethod)rbinding).getClassOwner();
|
||||||
|
return (ICPPClassType) cf.getCompositeBinding(rowner);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getVisibility() throws DOMException {
|
||||||
|
return ((ICPPMethod)rbinding).getVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -27,7 +27,7 @@ public class DBStatus extends Status {
|
||||||
* @param exception
|
* @param exception
|
||||||
*/
|
*/
|
||||||
public DBStatus(IOException exception) {
|
public DBStatus(IOException exception) {
|
||||||
super(IStatus.ERROR, CCorePlugin.PLUGIN_ID, 0, "IOException", exception);
|
super(IStatus.ERROR, CCorePlugin.PLUGIN_ID, 0, "IOException", exception); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
Loading…
Add table
Reference in a new issue