1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

184216: add two missing composite template bindings

This commit is contained in:
Andrew Ferguson 2007-04-27 12:58:21 +00:00
parent b3e38d9e19
commit 93ae2153c7
8 changed files with 116 additions and 12 deletions

View file

@ -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.IScope;
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.ICPPMethod;
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.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
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
*/
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 static class ProjectWithDepProj extends IndexBindingResolutionBugs {
public static class ProjectWithDepProj extends IndexCPPBindingResolutionBugs {
public ProjectWithDepProj() {setStrategy(new ReferencedProject(true));}
}
@ -44,13 +47,39 @@ public class IndexBindingResolutionBugs extends IndexBindingResolutionTestBase {
}
public static TestSuite suite() {
return suite(IndexBindingResolutionBugs.class);
return suite(IndexCPPBindingResolutionBugs.class);
}
public IndexBindingResolutionBugs() {
public IndexCPPBindingResolutionBugs() {
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
// class cl;
// typedef cl* t1;

View file

@ -42,7 +42,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
suite.addTest(suite(SingleProject.class));
suite.addTest(suite(ProjectWithDepProj.class));
}
// template<typename X>
// void foo(X x) {}

View file

@ -30,11 +30,11 @@ public class IndexTests extends TestSuite {
suite.addTest(TeamSharedIndexTest.suite());
suite.addTest(IndexProviderManagerTest.suite());
IndexCBindingResolutionTest.addTests(suite);
IndexCPPTemplateResolutionTest.addTests(suite);
IndexCPPBindingResolutionBugs.addTests(suite);
IndexCPPBindingResolutionTest.addTests(suite);
IndexCPPTemplateResolutionTest.addTests(suite);
IndexCBindingResolutionBugs.addTests(suite);
IndexBindingResolutionBugs.addTests(suite);
IndexCBindingResolutionTest.addTests(suite);
return suite;
}

View file

@ -162,6 +162,10 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
} else if (binding instanceof ICPPTemplateDefinition) {
if(binding instanceof ICPPClassTemplate) {
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) {
return new CompositeCPPFunctionTemplate(this, (ICPPFunction) binding);
} else {

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -27,7 +27,7 @@ public class DBStatus extends Status {
* @param 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$
}
}

View file

@ -12,9 +12,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;