mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Improve accuracy of index based binding resolution
this patch * improves pdom resolution binding (PDOMC*Linkage.resolveBinding) * fixes some broken binding resolution test data * has PDOMCPPField store type information * has PDOMCPPNamespaceAlias store what it is aliasing
This commit is contained in:
parent
23ee23bc84
commit
94f1a13a14
31 changed files with 799 additions and 381 deletions
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.index.IndexFilter;
|
|||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
/**
|
||||
|
@ -47,6 +48,9 @@ public class CCompositeTypeTests extends PDOMTestBase {
|
|||
|
||||
protected void tearDown() throws Exception {
|
||||
pdom.releaseReadLock();
|
||||
if (project != null) {
|
||||
project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
||||
//TODO PDOM does not distinguish between a struct or union in C
|
||||
|
|
|
@ -18,6 +18,8 @@ import org.eclipse.cdt.core.dom.ast.IFunction;
|
|||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
/**
|
||||
* Tests for verifying whether the PDOM correctly stores information about
|
||||
|
@ -40,6 +42,9 @@ public class CFunctionTests extends PDOMTestBase {
|
|||
|
||||
protected void tearDown() throws Exception {
|
||||
pdom.releaseReadLock();
|
||||
if (project != null) {
|
||||
project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
||||
public void testExternCFunction() throws Exception {
|
||||
|
|
|
@ -22,7 +22,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
|||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
/**
|
||||
* Tests for verifying whether the PDOM correctly stores information about
|
||||
|
@ -45,6 +47,9 @@ public class CPPFieldTests extends PDOMTestBase {
|
|||
|
||||
protected void tearDown() throws Exception {
|
||||
pdom.releaseReadLock();
|
||||
if (project != null) {
|
||||
project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
||||
public void testFieldDeclarations() throws Exception {
|
||||
|
@ -101,23 +106,19 @@ public class CPPFieldTests extends PDOMTestBase {
|
|||
assertTrue(field.isStatic());
|
||||
}
|
||||
|
||||
public void _testIntField() throws Exception {
|
||||
// Type information not yet stored in PDOM.
|
||||
public void testIntField() throws Exception {
|
||||
assertFieldType(pdom, "Class1::c1a", IBasicType.t_int);
|
||||
}
|
||||
|
||||
public void _testDoubleField() throws Exception {
|
||||
// Type information not yet stored in PDOM.
|
||||
public void testDoubleField() throws Exception {
|
||||
assertFieldType(pdom, "Class1::c1b", IBasicType.t_double);
|
||||
}
|
||||
|
||||
public void _testCharField() throws Exception {
|
||||
// Type information not yet stored in PDOM.
|
||||
public void testCharField() throws Exception {
|
||||
assertFieldType(pdom, "Class2::c2a", IBasicType.t_char);
|
||||
}
|
||||
|
||||
public void _testFloatField() throws Exception {
|
||||
// Type information not yet stored in PDOM.
|
||||
public void testFloatField() throws Exception {
|
||||
assertFieldType(pdom, "Class2::c2b", IBasicType.t_float);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
|||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
/**
|
||||
* Tests for verifying whether the PDOM correctly stores information about
|
||||
|
@ -48,6 +50,9 @@ public class CPPFunctionTests extends PDOMTestBase {
|
|||
|
||||
protected void tearDown() throws Exception {
|
||||
pdom.releaseReadLock();
|
||||
if (project != null) {
|
||||
project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
||||
public void testFunctionType() throws Exception {
|
||||
|
|
|
@ -18,6 +18,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
|||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
/**
|
||||
* Tests for verifying whether the PDOM correctly stores information about
|
||||
|
@ -40,6 +42,9 @@ public class CPPVariableTests extends PDOMTestBase {
|
|||
|
||||
protected void tearDown() throws Exception {
|
||||
pdom.releaseReadLock();
|
||||
if (project != null) {
|
||||
project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
||||
public void testCPPAutoVariable() throws Exception {
|
||||
|
|
|
@ -18,6 +18,8 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
|
|||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
/**
|
||||
* Tests for verifying whether the PDOM correctly stores information about
|
||||
|
@ -40,6 +42,9 @@ public class CVariableTests extends PDOMTestBase {
|
|||
|
||||
protected void tearDown() throws Exception {
|
||||
pdom.releaseReadLock();
|
||||
if (project != null) {
|
||||
project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
||||
public void testCAutoVariable() throws Exception {
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.core.model.ICProject;
|
|||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
@ -44,14 +45,15 @@ public class DefDeclTests extends PDOMTestBase {
|
|||
private String projectName = null;
|
||||
|
||||
protected PDOM pdom;
|
||||
|
||||
protected ICProject cproject;
|
||||
|
||||
public static Test suite() {
|
||||
return suite(DefDeclTests.class);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
String requiredName = "defDeclTests";
|
||||
ICProject cproject = createProject(requiredName);
|
||||
cproject = createProject(requiredName);
|
||||
this.projectName = cproject.getElementName();
|
||||
pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject);
|
||||
pdom.acquireReadLock();
|
||||
|
@ -59,6 +61,9 @@ public class DefDeclTests extends PDOMTestBase {
|
|||
|
||||
protected void tearDown() throws Exception {
|
||||
pdom.releaseReadLock();
|
||||
if (cproject != null) {
|
||||
cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
||||
private IBinding findSingleBinding(String elName) throws CoreException {
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.model.ICProject;
|
|||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
|
@ -48,6 +49,9 @@ public class FilesOnReindexTests extends PDOMTestBase {
|
|||
|
||||
protected void tearDown() throws Exception {
|
||||
pdom.releaseReadLock();
|
||||
if (project != null) {
|
||||
project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
||||
public void testFilesOnReindex() throws CoreException, InterruptedException {
|
||||
|
|
|
@ -42,43 +42,41 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
|||
|
||||
// // header file
|
||||
// struct S {}; union U {}; enum E {ER1,ER2,ER3};
|
||||
// int var1; C var2; S *var3; void func1(E); void func2(S);
|
||||
// int var1; S var2; S *var3; void func1(E); void func2(S);
|
||||
// typedef int Int; typedef int *IntPtr;
|
||||
// void func3(int** ppi); void func4(int);
|
||||
|
||||
// // referencing file
|
||||
// #include "header.h"
|
||||
// void references() {
|
||||
// struct S s; /*s*/ union U u; /*u*/ E e; /*e*/
|
||||
// var1 = 1; /*var1*/ var2 = c; /*var2*/ var3 = &s; /*var3*/
|
||||
// func(e); /*func1*/ func(var1); /*func2*/ func(c); /*func3*/
|
||||
// var1 = 1; /*var1*/ var2 = s; /*var2*/ var3 = &s; /*var3*/
|
||||
// func1(e); /*func1*/ func1(var1); /*func2*/ func2(s); /*func3*/
|
||||
// Int a; /*a*/
|
||||
// IntPtr b = &a; /*b*/
|
||||
// func(*b); /*func4*/ func(a); /*func5*/
|
||||
// func3(*b); /*func4*/ func4(a); /*func5*/
|
||||
// }
|
||||
public void testSimpleGlobalBindings() throws IOException {
|
||||
IBinding b2 = getBindingFromASTName("S s;", 1);
|
||||
IBinding b3 = getBindingFromASTName("s;", 1);
|
||||
IBinding b4 = getBindingFromASTName("U u;", 1);
|
||||
IBinding b5 = getBindingFromASTName("u; ", 1);
|
||||
IBinding b6 = getBindingFromASTName("E e; ", 1);
|
||||
IBinding b7 = getBindingFromASTName("e; ", 1);
|
||||
IBinding b8 = getBindingFromASTName("var1 = 1;", 4);
|
||||
IBinding b9 = getBindingFromASTName("var2 = c;", 4);
|
||||
IBinding b9 = getBindingFromASTName("var2 = s;", 4);
|
||||
IBinding b10 = getBindingFromASTName("var3 = &s;", 4);
|
||||
IBinding b11 = getBindingFromASTName("func(e);", 4);
|
||||
IBinding b13 = getBindingFromASTName("func(c);", 4);
|
||||
IBinding b15 = getBindingFromASTName("a; ", 1);
|
||||
IBinding b17 = getBindingFromASTName("b = &a; /*b*/", 1);
|
||||
IBinding b19 = getBindingFromASTName("b); /*func4*/", 1);
|
||||
IBinding b20 = getBindingFromASTName("func(a);", 4);
|
||||
IBinding b21 = getBindingFromASTName("a); /*func5*/", 1);
|
||||
}
|
||||
|
||||
public void _testSimpleGlobalBindings() throws IOException {
|
||||
IBinding b6 = getBindingFromASTName("E e; ", 1);
|
||||
IBinding b12 = getBindingFromASTName("func1(var1);", 4);
|
||||
IBinding b11 = getBindingFromASTName("func1(e);", 5);
|
||||
IBinding b12 = getBindingFromASTName("func1(var1);", 5);
|
||||
IBinding b13 = getBindingFromASTName("func2(s);", 5);
|
||||
IBinding b14 = getBindingFromASTName("Int a; ", 3);
|
||||
IBinding b15 = getBindingFromASTName("a; ", 1);
|
||||
IBinding b16 = getBindingFromASTName("IntPtr b = &a; ", 6);
|
||||
IBinding b18 = getBindingFromASTName("func2(*b);", 4);
|
||||
IBinding b17 = getBindingFromASTName("b = &a; /*b*/", 1);
|
||||
IBinding b18 = getBindingFromASTName("func3(*b);", 5);
|
||||
IBinding b19 = getBindingFromASTName("b); /*func4*/", 1);
|
||||
IBinding b20 = getBindingFromASTName("func4(a);", 5);
|
||||
IBinding b21 = getBindingFromASTName("a); /*func5*/", 1);
|
||||
}
|
||||
|
||||
public void _testEnumeratorInFileScope() {fail("todo");}
|
||||
|
|
|
@ -47,33 +47,34 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
|||
// // header file
|
||||
// class C {
|
||||
// public:
|
||||
// int field;
|
||||
// struct CS { long* l; C *method(CS *); };
|
||||
// CS cs;
|
||||
// long * CS::* ouch;
|
||||
// long * CS::* autsch;
|
||||
// C * CS:: method(CS *);
|
||||
// int field;
|
||||
// struct CS { long* l; C *method(CS **); };
|
||||
// CS cs;
|
||||
// CS **cspp;
|
||||
// long * CS::* ouch;
|
||||
// long * CS::* autsch;
|
||||
// C * CS::* method(CS **);
|
||||
// };
|
||||
|
||||
// // referencing file
|
||||
// #include "header.h"
|
||||
// void references() {
|
||||
// C *cp = new C();
|
||||
// long l = 5, *lp;
|
||||
// lp = &l;
|
||||
// cp->cs.*cp->ouch = lp = cp->cs.*cp->autsch;
|
||||
// &(cp->cs)->*cp->autsch = lp = &(cp->cs)->*cp->ouch;
|
||||
// cp->cs.*method(cp);/*1*/ &(cp->cs)->*method(cp);/*2*/
|
||||
// C *cp = new C();
|
||||
// long l = 5, *lp;
|
||||
// lp = &l;
|
||||
// cp->cs.*cp->ouch = lp = cp->cs.*cp->autsch;
|
||||
// &(cp->cs)->*cp->autsch = lp = &(cp->cs)->*cp->ouch;
|
||||
// cp->cs.*method(cp->cspp);/*1*/ &(cp->cs)->*method(cp->cspp);/*2*/
|
||||
// }
|
||||
public void _testPointerToMemberFields() throws IOException {
|
||||
public void testPointerToMemberFields() throws IOException {
|
||||
IBinding b0 = getBindingFromASTName("cs.*cp->o", 2);
|
||||
IBinding b1 = getBindingFromASTName("ouch = lp;", 4);
|
||||
IBinding b1 = getBindingFromASTName("ouch = lp", 4);
|
||||
IBinding b2 = getBindingFromASTName("autsch;", 6);
|
||||
IBinding b3 = getBindingFromASTName("cs)->*c->a", 2);
|
||||
IBinding b3 = getBindingFromASTName("cs)->*cp->a", 2);
|
||||
IBinding b4 = getBindingFromASTName("autsch = lp", 6);
|
||||
IBinding b5 = getBindingFromASTName("ouch;", 4);
|
||||
IBinding b6 = getBindingFromASTName("method(cp);/*1*/", 6);
|
||||
IBinding b7 = getBindingFromASTName("method(cp);/*2*/", 6);
|
||||
IBinding b6 = getBindingFromASTName("method(cp->cspp);/*1*/", 6);
|
||||
IBinding b7 = getBindingFromASTName("method(cp->cspp);/*2*/", 6);
|
||||
}
|
||||
|
||||
// // header file
|
||||
|
@ -81,7 +82,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
|||
// int var1; C var2; S *var3; void func(E); void func(C);
|
||||
// namespace ns {}
|
||||
// typedef int Int; typedef int *IntPtr;
|
||||
|
||||
// void func(int*); void func(int);
|
||||
// // referencing file
|
||||
// #include "header.h"
|
||||
// void references() {
|
||||
|
@ -94,7 +95,6 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
|||
// }
|
||||
// class C2 : public C {}; /*base*/
|
||||
// struct S2 : public S {}; /*base*/
|
||||
// union U2 : public U {}; /*base*/
|
||||
public void testSimpleGlobalBindings() throws IOException {
|
||||
IBinding b0 = getBindingFromASTName("C c; ", 1);
|
||||
IBinding b1 = getBindingFromASTName("c; ", 1);
|
||||
|
@ -102,32 +102,26 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
|||
IBinding b3 = getBindingFromASTName("s;", 1);
|
||||
IBinding b4 = getBindingFromASTName("U u;", 1);
|
||||
IBinding b5 = getBindingFromASTName("u; ", 1);
|
||||
IBinding b6 = getBindingFromASTName("E e; ", 1);
|
||||
IBinding b7 = getBindingFromASTName("e; ", 1);
|
||||
IBinding b8 = getBindingFromASTName("var1 = 1;", 4);
|
||||
IBinding b9 = getBindingFromASTName("var2 = c;", 4);
|
||||
IBinding b10 = getBindingFromASTName("var3 = &s;", 4);
|
||||
IBinding b11 = getBindingFromASTName("func(e);", 4);
|
||||
IBinding b12 = getBindingFromASTName("func(var1);", 4);
|
||||
IBinding b13 = getBindingFromASTName("func(c);", 4);
|
||||
IBinding b14 = getBindingFromASTName("Int a; ", 3);
|
||||
IBinding b15 = getBindingFromASTName("a; ", 1);
|
||||
IBinding b16 = getBindingFromASTName("IntPtr b = &a; ", 6);
|
||||
IBinding b17 = getBindingFromASTName("b = &a; /*b*/", 1);
|
||||
IBinding b18 = getBindingFromASTName("func(*b);", 4);
|
||||
IBinding b19 = getBindingFromASTName("b); /*func4*/", 1);
|
||||
IBinding b20 = getBindingFromASTName("func(a);", 4);
|
||||
IBinding b21 = getBindingFromASTName("a); /*func5*/", 1);
|
||||
IBinding b22 = getBindingFromASTName("C2 : public", 2);
|
||||
IBinding b24 = getBindingFromASTName("S2 : public", 2);
|
||||
IBinding b26 = getBindingFromASTName("U2 : public", 2);
|
||||
}
|
||||
|
||||
public void _testSimpleGlobalBindings() throws IOException {
|
||||
/* note the test data from above follows through to this test */
|
||||
IBinding b6 = getBindingFromASTName("E e; ", 1);
|
||||
IBinding b12 = getBindingFromASTName("func(var1);", 4);
|
||||
IBinding b14 = getBindingFromASTName("Int a; ", 3);
|
||||
IBinding b16 = getBindingFromASTName("IntPtr b = &a; ", 6);
|
||||
IBinding b18 = getBindingFromASTName("func(*b);", 4);
|
||||
IBinding b23 = getBindingFromASTName("C {}; /*base*/", 1);
|
||||
IBinding b25 = getBindingFromASTName("S {}; /*base*/", 1);
|
||||
IBinding b27 = getBindingFromASTName("U {}; /*base*/", 1);
|
||||
IBinding b24 = getBindingFromASTName("S2 : public", 2);
|
||||
IBinding b25 = getBindingFromASTName("S {}; /*base*/", 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -148,7 +142,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
|||
// }
|
||||
// };
|
||||
//}
|
||||
public void _testSingletonQualifiedName() {
|
||||
public void testSingletonQualifiedName() {
|
||||
IBinding b0 = getBindingFromASTName("TopC c", 4);
|
||||
IBinding b1 = getBindingFromASTName("TopS s", 4);
|
||||
IBinding b2 = getBindingFromASTName("TopU u", 4);
|
||||
|
@ -169,98 +163,98 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
|||
|
||||
// // header content
|
||||
// namespace n1 { namespace n2 { struct S {}; } }
|
||||
// class c1 { class c2 { struct S {}; };
|
||||
// class c1 { public: class c2 { public: struct S {}; }; };
|
||||
// struct s1 { struct s2 { struct S {}; }; };
|
||||
// union u1 { struct u2 { struct S {}; }; };
|
||||
// namespace n3 { class c3 { struct s3 { union u3 { struct S {}; }; }; }; }
|
||||
// namespace n3 { class c3 { public: struct s3 { union u3 { struct S {}; }; }; }; }
|
||||
|
||||
// // reference content
|
||||
// void reference() {
|
||||
// ::n1::n2::S s0; n1::n2::S s1;
|
||||
// ::c1::c2::S s2; c1::c2::S s3;
|
||||
// ::s1::s2::S s4; s1::s2::S s5;
|
||||
// ::u1::u2::S s6; u1::u2::S s7;
|
||||
// ::n3::c3::s3::u3::S s8;
|
||||
// n3::c3::s3::u3::S s9;
|
||||
// ::n1::n2::S _s0; n1::n2::S _s1;
|
||||
// ::c1::c2::S _s2; c1::c2::S _s3;
|
||||
// ::s1::s2::S _s4; s1::s2::S _s5;
|
||||
// ::u1::u2::S _s6; u1::u2::S _s7;
|
||||
// ::n3::c3::s3::u3::S _s8;
|
||||
// n3::c3::s3::u3::S _s9;
|
||||
// }
|
||||
// namespace n3 { c3::s3::u3::S s10; }
|
||||
// namespace n1 { n2::S s11; }
|
||||
// namespace n1 { namespace n2 { S s12; }}
|
||||
public void _testQualifiedNamesForStruct() throws DOMException {
|
||||
IBinding b0 = getBindingFromASTName("S s0;", 1);
|
||||
// namespace n3 { c3::s3::u3::S _s10; }
|
||||
// namespace n1 { n2::S _s11; }
|
||||
// namespace n1 { namespace n2 { S _s12; }}
|
||||
public void testQualifiedNamesForStruct() throws DOMException {
|
||||
IBinding b0 = getBindingFromASTName("S _s0;", 1);
|
||||
assertQNEquals("n1::n2::S", b0);
|
||||
IBinding b1 = getBindingFromASTName("S s1;", 1);
|
||||
IBinding b1 = getBindingFromASTName("S _s1;", 1);
|
||||
assertQNEquals("n1::n2::S", b1);
|
||||
IBinding b2 = getBindingFromASTName("S s2;", 1);
|
||||
IBinding b2 = getBindingFromASTName("S _s2;", 1);
|
||||
assertQNEquals("c1::c2::S", b2);
|
||||
IBinding b3 = getBindingFromASTName("S s3;", 1);
|
||||
IBinding b3 = getBindingFromASTName("S _s3;", 1);
|
||||
assertQNEquals("c1::c2::S", b3);
|
||||
IBinding b4 = getBindingFromASTName("S s4;", 1);
|
||||
IBinding b4 = getBindingFromASTName("S _s4;", 1);
|
||||
assertQNEquals("s1::s2::S", b4);
|
||||
IBinding b5 = getBindingFromASTName("S s5;", 1);
|
||||
IBinding b5 = getBindingFromASTName("S _s5;", 1);
|
||||
assertQNEquals("s1::s2::S", b5);
|
||||
IBinding b6 = getBindingFromASTName("S s6;", 1);
|
||||
IBinding b6 = getBindingFromASTName("S _s6;", 1);
|
||||
assertQNEquals("u1::u2::S", b6);
|
||||
IBinding b7 = getBindingFromASTName("S s7;", 1);
|
||||
IBinding b7 = getBindingFromASTName("S _s7;", 1);
|
||||
assertQNEquals("u1::u2::S", b7);
|
||||
IBinding b8 = getBindingFromASTName("S s8;", 1);
|
||||
IBinding b8 = getBindingFromASTName("S _s8;", 1);
|
||||
assertQNEquals("n3::c3::s3::u3::S", b8);
|
||||
IBinding b9 = getBindingFromASTName("S s9;", 1);
|
||||
IBinding b9 = getBindingFromASTName("S _s9;", 1);
|
||||
assertQNEquals("n3::c3::s3::u3::S", b9);
|
||||
IBinding b10 = getBindingFromASTName("S s10;", 1);
|
||||
IBinding b10 = getBindingFromASTName("S _s10;", 1);
|
||||
assertQNEquals("n3::c3::s3::u3::S", b10);
|
||||
IBinding b11 = getBindingFromASTName("S s11;", 1);
|
||||
IBinding b11 = getBindingFromASTName("S _s11;", 1);
|
||||
assertQNEquals("n1::n2::S", b11);
|
||||
IBinding b12 = getBindingFromASTName("S s12;", 1);
|
||||
IBinding b12 = getBindingFromASTName("S _s12;", 1);
|
||||
assertQNEquals("n1::n2::S", b12);
|
||||
}
|
||||
|
||||
// // header content
|
||||
// namespace n1 { namespace n2 { union U {}; } }
|
||||
// class c1 { class c2 { union U {}; };
|
||||
// class c1 { public: class c2 { public: union U {}; }; };
|
||||
// struct s1 { struct s2 { union U {}; }; };
|
||||
// union u1 { struct u2 { union U {}; }; };
|
||||
// namespace n3 { class c3 { struct s3 { union u3 { union U {}; }; }; }; }
|
||||
// namespace n3 { class c3 { public: struct s3 { union u3 { union U {}; }; }; }; }
|
||||
|
||||
// // reference content
|
||||
// void reference() {
|
||||
// ::n1::n2::U u0; n1::n2::U u1;
|
||||
// ::c1::c2::U u2; c1::c2::U u3;
|
||||
// ::s1::s2::U u4; s1::s2::U u5;
|
||||
// ::u1::u2::U u6; u1::u2::U u7;
|
||||
// ::n3::c3::s3::u3::U u8;
|
||||
// n3::c3::s3::u3::U u9;
|
||||
// ::n1::n2::U _u0; n1::n2::U _u1;
|
||||
// ::c1::c2::U _u2; c1::c2::U _u3;
|
||||
// ::s1::s2::U _u4; s1::s2::U _u5;
|
||||
// ::u1::u2::U _u6; u1::u2::U _u7;
|
||||
// ::n3::c3::s3::u3::U _u8;
|
||||
// n3::c3::s3::u3::U _u9;
|
||||
// }
|
||||
// namespace n3 { c3::s3::u3::U u10; }
|
||||
// namespace n1 { n2::U u11; }
|
||||
// namespace n1 { namespace n2 { U u12; }}
|
||||
public void _testQualifiedNamesForUnion() throws DOMException {
|
||||
IBinding b0 = getBindingFromASTName("S s0;", 1);
|
||||
assertQNEquals("n1::n2::S", b0);
|
||||
IBinding b1 = getBindingFromASTName("S s1;", 1);
|
||||
assertQNEquals("n1::n2::S", b1);
|
||||
IBinding b2 = getBindingFromASTName("S s2;", 1);
|
||||
assertQNEquals("c1::c2::S", b2);
|
||||
IBinding b3 = getBindingFromASTName("S s3;", 1);
|
||||
assertQNEquals("c1::c2::S", b3);
|
||||
IBinding b4 = getBindingFromASTName("S s4;", 1);
|
||||
assertQNEquals("s1::s2::S", b4);
|
||||
IBinding b5 = getBindingFromASTName("S s5;", 1);
|
||||
assertQNEquals("s1::s2::S", b5);
|
||||
IBinding b6 = getBindingFromASTName("S s6;", 1);
|
||||
assertQNEquals("u1::u2::S", b6);
|
||||
IBinding b7 = getBindingFromASTName("S s7;", 1);
|
||||
assertQNEquals("u1::u2::S", b7);
|
||||
IBinding b8 = getBindingFromASTName("S s8;", 1);
|
||||
assertQNEquals("n3::c3::s3::u3::S", b8);
|
||||
IBinding b9 = getBindingFromASTName("S s9;", 1);
|
||||
assertQNEquals("n3::c3::s3::u3::S", b9);
|
||||
IBinding b10 = getBindingFromASTName("S s10;", 1);
|
||||
assertQNEquals("n3::c3::s3::u3::S", b10);
|
||||
IBinding b11 = getBindingFromASTName("S s11;", 1);
|
||||
assertQNEquals("n1::n2::S", b11);
|
||||
IBinding b12 = getBindingFromASTName("C s12;", 1);
|
||||
assertQNEquals("n1::n2::S", b12);
|
||||
// namespace n3 { c3::s3::u3::U _u10; }
|
||||
// namespace n1 { n2::U _u11; }
|
||||
// namespace n1 { namespace n2 { U _u12; }}
|
||||
public void testQualifiedNamesForUnion() throws DOMException {
|
||||
IBinding b0 = getBindingFromASTName("U _u0;", 1);
|
||||
assertQNEquals("n1::n2::U", b0);
|
||||
IBinding b1 = getBindingFromASTName("U _u1;", 1);
|
||||
assertQNEquals("n1::n2::U", b1);
|
||||
IBinding b2 = getBindingFromASTName("U _u2;", 1);
|
||||
assertQNEquals("c1::c2::U", b2);
|
||||
IBinding b3 = getBindingFromASTName("U _u3;", 1);
|
||||
assertQNEquals("c1::c2::U", b3);
|
||||
IBinding b4 = getBindingFromASTName("U _u4;", 1);
|
||||
assertQNEquals("s1::s2::U", b4);
|
||||
IBinding b5 = getBindingFromASTName("U _u5;", 1);
|
||||
assertQNEquals("s1::s2::U", b5);
|
||||
IBinding b6 = getBindingFromASTName("U _u6;", 1);
|
||||
assertQNEquals("u1::u2::U", b6);
|
||||
IBinding b7 = getBindingFromASTName("U _u7;", 1);
|
||||
assertQNEquals("u1::u2::U", b7);
|
||||
IBinding b8 = getBindingFromASTName("U _u8;", 1);
|
||||
assertQNEquals("n3::c3::s3::u3::U", b8);
|
||||
IBinding b9 = getBindingFromASTName("U _u9;", 1);
|
||||
assertQNEquals("n3::c3::s3::u3::U", b9);
|
||||
IBinding b10 = getBindingFromASTName("U _u10;", 1);
|
||||
assertQNEquals("n3::c3::s3::u3::U", b10);
|
||||
IBinding b11 = getBindingFromASTName("U _u11;", 1);
|
||||
assertQNEquals("n1::n2::U", b11);
|
||||
IBinding b12 = getBindingFromASTName("U _u12;", 1);
|
||||
assertQNEquals("n1::n2::U", b12);
|
||||
}
|
||||
|
||||
// // header content
|
||||
|
@ -269,45 +263,45 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
|||
// struct s1 { struct s2 { class C {}; }; };
|
||||
// union u1 { union u2 { class C {}; }; };
|
||||
// namespace n3 { class c3 { public: struct s3 { union u3 { class C {}; }; }; }; }
|
||||
//
|
||||
|
||||
// // reference content
|
||||
// void reference() {
|
||||
// ::n1::n2::C c0; n1::n2::C c1;
|
||||
// ::c1::c2::C c2; c1::c2::C c3;
|
||||
// ::s1::s2::C c4; s1::s2::C c5;
|
||||
// ::u1::u2::C c6; u1::u2::C c7;
|
||||
// ::n3::c3::s3::u3::C c8;
|
||||
// n3::c3::s3::u3::C c9;
|
||||
// ::n1::n2::C _c0; n1::n2::C _c1;
|
||||
// ::c1::c2::C _c2; c1::c2::C _c3;
|
||||
// ::s1::s2::C _c4; s1::s2::C _c5;
|
||||
// ::u1::u2::C _c6; u1::u2::C _c7;
|
||||
// ::n3::c3::s3::u3::C _c8;
|
||||
// n3::c3::s3::u3::C _c9;
|
||||
// }
|
||||
// namespace n3 { c3::s3::u3::C c10; }
|
||||
// namespace n1 { n2::C c11; }
|
||||
// namespace n1 { namespace n2 { C c12; }}
|
||||
public void _testQualifiedNamesForClass() throws DOMException {
|
||||
IBinding b0 = getBindingFromASTName("C c0;", 1);
|
||||
// namespace n3 { c3::s3::u3::C _c10; }
|
||||
// namespace n1 { n2::C _c11; }
|
||||
// namespace n1 { namespace n2 { C _c12; }}
|
||||
public void testQualifiedNamesForClass() throws DOMException {
|
||||
IBinding b0 = getBindingFromASTName("C _c0;", 1);
|
||||
assertQNEquals("n1::n2::C", b0);
|
||||
IBinding b1 = getBindingFromASTName("C c1;", 1);
|
||||
IBinding b1 = getBindingFromASTName("C _c1;", 1);
|
||||
assertQNEquals("n1::n2::C", b1);
|
||||
IBinding b2 = getBindingFromASTName("C c2;", 1);
|
||||
IBinding b2 = getBindingFromASTName("C _c2;", 1);
|
||||
assertQNEquals("c1::c2::C", b2);
|
||||
IBinding b3 = getBindingFromASTName("C c3;", 1);
|
||||
IBinding b3 = getBindingFromASTName("C _c3;", 1);
|
||||
assertQNEquals("c1::c2::C", b3);
|
||||
IBinding b4 = getBindingFromASTName("C c4;", 1);
|
||||
IBinding b4 = getBindingFromASTName("C _c4;", 1);
|
||||
assertQNEquals("s1::s2::C", b4);
|
||||
IBinding b5 = getBindingFromASTName("C c5;", 1);
|
||||
IBinding b5 = getBindingFromASTName("C _c5;", 1);
|
||||
assertQNEquals("s1::s2::C", b5);
|
||||
IBinding b6 = getBindingFromASTName("C c6;", 1);
|
||||
IBinding b6 = getBindingFromASTName("C _c6;", 1);
|
||||
assertQNEquals("u1::u2::C", b6);
|
||||
IBinding b7 = getBindingFromASTName("C c7;", 1);
|
||||
IBinding b7 = getBindingFromASTName("C _c7;", 1);
|
||||
assertQNEquals("u1::u2::C", b7);
|
||||
IBinding b8 = getBindingFromASTName("C c8;", 1);
|
||||
IBinding b8 = getBindingFromASTName("C _c8;", 1);
|
||||
assertQNEquals("n3::c3::s3::u3::C", b8);
|
||||
IBinding b9 = getBindingFromASTName("C c9;", 1);
|
||||
IBinding b9 = getBindingFromASTName("C _c9;", 1);
|
||||
assertQNEquals("n3::c3::s3::u3::C", b9);
|
||||
IBinding b10 = getBindingFromASTName("C c10;", 1);
|
||||
IBinding b10 = getBindingFromASTName("C _c10;", 1);
|
||||
assertQNEquals("n3::c3::s3::u3::C", b10);
|
||||
IBinding b11 = getBindingFromASTName("C c11;", 1);
|
||||
IBinding b11 = getBindingFromASTName("C _c11;", 1);
|
||||
assertQNEquals("n1::n2::C", b11);
|
||||
IBinding b12 = getBindingFromASTName("C c12;", 1);
|
||||
IBinding b12 = getBindingFromASTName("C _c12;", 1);
|
||||
assertQNEquals("n1::n2::C", b12);
|
||||
}
|
||||
|
||||
|
@ -389,10 +383,10 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
|||
// void m1() { e1 = ER1; }
|
||||
// static void m2() { e2 = ER2; }
|
||||
// };
|
||||
public void _testEnumeratorInStructScope() {
|
||||
public void testEnumeratorInStructScope() {
|
||||
IBinding b0 = getBindingFromASTName("E e1", 1);
|
||||
IBinding b1 = getBindingFromASTName("ER1; }", 1);
|
||||
IBinding b2 = getBindingFromASTName("ER2; }", 1);
|
||||
IBinding b1 = getBindingFromASTName("ER1; }", 3);
|
||||
IBinding b2 = getBindingFromASTName("ER2; }", 3);
|
||||
}
|
||||
|
||||
// // header content
|
||||
|
@ -405,10 +399,10 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
|||
// void m1() { e1 = ER1; }
|
||||
// static void m2() { e2 = ER2; }
|
||||
// };
|
||||
public void _testEnumeratorInUnionScope() {
|
||||
public void testEnumeratorInUnionScope() {
|
||||
IBinding b0 = getBindingFromASTName("E e1", 1);
|
||||
IBinding b1 = getBindingFromASTName("ER1; }", 1);
|
||||
IBinding b2 = getBindingFromASTName("ER2; }", 1);
|
||||
IBinding b1 = getBindingFromASTName("ER1; }", 3);
|
||||
IBinding b2 = getBindingFromASTName("ER2; }", 3);
|
||||
}
|
||||
|
||||
// // header content
|
||||
|
@ -421,10 +415,10 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
|||
// void f1() { e1 = ER1; }
|
||||
// static void f2() { e2 = ER2; }
|
||||
// };
|
||||
public void _testEnumeratorInNamespaceScope() {
|
||||
public void testEnumeratorInNamespaceScope() {
|
||||
IBinding b0 = getBindingFromASTName("E e1", 1);
|
||||
IBinding b1 = getBindingFromASTName("ER1; }", 1);
|
||||
IBinding b2 = getBindingFromASTName("ER2; }", 1);
|
||||
IBinding b1 = getBindingFromASTName("ER1; }", 3);
|
||||
IBinding b2 = getBindingFromASTName("ER2; }", 3);
|
||||
}
|
||||
|
||||
// // teh header
|
||||
|
@ -537,13 +531,14 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
|||
|
||||
|
||||
// // header file
|
||||
// class C {C* cp;};
|
||||
// class C {public: C* cp;};
|
||||
// C foo(C c);
|
||||
// C* foo(C* c);
|
||||
// int foo(int i);
|
||||
// int foo(int i, C c);
|
||||
|
||||
// // referencing content
|
||||
// #include "header.h"
|
||||
// void references() {
|
||||
// C c, *cp;
|
||||
// foo/*a*/(cp[1]); // IASTArraySubscriptExpression
|
||||
|
@ -653,7 +648,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
|||
// fni4 = &f;/*20*/ fnlp4 = &f;/*21*/ fnS4 = &f;/*22*/ fnU4 = &f;/*23*/ fnE4 = &f;/*24*/
|
||||
// fE = &f;/*25*/
|
||||
// }
|
||||
public void _testAddressOfOverloadedFunction() throws DOMException {
|
||||
public void testAddressOfOverloadedFunction() throws DOMException {
|
||||
IBinding b0 = getBindingFromASTName("f;/*0*/", 1);
|
||||
IBinding b1 = getBindingFromASTName("f;/*1*/", 1);
|
||||
IBinding b2 = getBindingFromASTName("f;/*2*/", 1);
|
||||
|
|
|
@ -24,6 +24,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
|||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
/**
|
||||
* Tests for verifying whether the PDOM correctly stores information about
|
||||
|
@ -45,6 +47,9 @@ public class MethodTests extends PDOMTestBase {
|
|||
|
||||
protected void tearDown() throws Exception {
|
||||
pdom.releaseReadLock();
|
||||
if (project != null) {
|
||||
project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
||||
public void testMethodParameters() throws Exception {
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.core.index.IndexFilter;
|
|||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
|
@ -48,7 +49,7 @@ public class NamespaceTests extends PDOMTestBase {
|
|||
|
||||
protected void setUp() throws Exception {
|
||||
if (pdom == null) {
|
||||
ICProject project = createProject("namespaceTests", true);
|
||||
project = createProject("namespaceTests", true);
|
||||
pdom = (PDOM)CCoreInternals.getPDOMManager().getPDOM(project);
|
||||
}
|
||||
pdom.acquireReadLock();
|
||||
|
@ -56,6 +57,9 @@ public class NamespaceTests extends PDOMTestBase {
|
|||
|
||||
protected void tearDown() throws Exception {
|
||||
pdom.releaseReadLock();
|
||||
if (project != null) {
|
||||
project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
||||
public void _testAlias() throws Exception {
|
||||
|
|
|
@ -50,8 +50,6 @@ public class OverloadsWithinCommonHeaderTests extends PDOMTestBase {
|
|||
pdom.releaseReadLock();
|
||||
}
|
||||
|
||||
public void testDummy() {}
|
||||
|
||||
public void testOverloadedInCommonHeader_ClassScope() throws CoreException {
|
||||
Pattern[] ManyOverloadedQuxPath = makePatternArray(new String[] {"ManyOverloaded","qux"});
|
||||
IBinding[] ManyOverloadedQux = pdom.findBindings(ManyOverloadedQuxPath, new NullProgressMonitor());
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IndexFilter;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
|
@ -185,7 +186,7 @@ public class PDOMTestBase extends BaseTestCase {
|
|||
public static final void assertFunctionRefCount(PDOM pdom, Class[] args, IBinding[] bindingPool, int refCount) throws CoreException {
|
||||
IBinding[] bindings = findIFunctions(args, bindingPool);
|
||||
assertEquals(1, bindings.length);
|
||||
IName[] refs = pdom.getReferences(bindings[0]);
|
||||
IName[] refs = pdom.findNames(bindings[0], IIndex.FIND_REFERENCES);
|
||||
assertEquals(refCount, refs.length);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
class ManyOverloaded {
|
||||
public:
|
||||
void qux() {}
|
||||
void qux(int i) {}
|
||||
void qux(int i, char c) {}
|
||||
void qux(ManyOverloaded* ptr) {}
|
||||
void qux(ManyOverloaded nptr) {}
|
||||
};
|
||||
|
||||
void quux() {}
|
||||
void quux(int i) {}
|
||||
void quux(int i, char c) {}
|
||||
void quux(ManyOverloaded* ptr) {}
|
||||
void quux(ManyOverloaded nptr) {}
|
||||
|
||||
|
||||
namespace corge {
|
||||
void grault() {}
|
||||
void grault(int i) {}
|
||||
void grault(int i, char c) {}
|
||||
void grault(ManyOverloaded* ptr) {}
|
||||
void grault(ManyOverloaded nptr) {}
|
||||
}
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICBasicType;
|
|||
import org.eclipse.cdt.core.dom.ast.c.ICPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICQualifierType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
|
@ -196,7 +197,16 @@ public class ASTTypeUtil {
|
|||
// }
|
||||
// } catch (DOMException e) {}
|
||||
// result.append(SPACE);
|
||||
result.append(((ICompositeType)type).getName());
|
||||
if(type instanceof ICPPClassType) {
|
||||
try {
|
||||
String qn = CPPVisitor.renderQualifiedName(((ICPPClassType)type).getQualifiedName());
|
||||
result.append(qn);
|
||||
} catch(DOMException de) {
|
||||
result.append(((ICompositeType)type).getName());
|
||||
}
|
||||
} else {
|
||||
result.append(((ICompositeType)type).getName());
|
||||
}
|
||||
} else if (type instanceof ICPPReferenceType) {
|
||||
result.append(Keywords.cpAMPER);
|
||||
} else if (type instanceof ICPPTemplateTypeParameter) {
|
||||
|
|
|
@ -185,11 +185,34 @@ public class ArrayUtil {
|
|||
return temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the specified array contains the specified object. Comparison is by
|
||||
* object identity.
|
||||
* @param array the array to search
|
||||
* @param obj the object to search for
|
||||
* @return true if the specified array contains the specified object, or the specified array is null
|
||||
*/
|
||||
public static boolean contains( Object [] array, Object obj ){
|
||||
if( array == null ) return false;
|
||||
for( int i = 0; i < array.length; i++ )
|
||||
if( array[i] == obj ) return true;
|
||||
return false;
|
||||
return indexOf(array, obj)!=-1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index into the specified array of the specified object, or -1 if the array does not
|
||||
* contain the object, or if the array is null. Comparison is by object identity.
|
||||
* @param array the array to search
|
||||
* @param obj the object to search for
|
||||
* @return the index into the specified array of the specified object, or -1 if the array does not
|
||||
* contain the object, or if the array is null
|
||||
*/
|
||||
public static int indexOf(Object[] array, Object obj) {
|
||||
int result = -1;
|
||||
if(array!=null) {
|
||||
for(int i=0; i<array.length; i++) {
|
||||
if(array[i] == obj)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -878,7 +878,9 @@ public class CPPSemantics {
|
|||
}
|
||||
}
|
||||
} else if( t instanceof IEnumeration ){
|
||||
namespaces.put( getContainingNamespaceScope( (IBinding) t ) );
|
||||
IScope scope = getContainingNamespaceScope( (IBinding) t );
|
||||
if(scope!=null)
|
||||
namespaces.put(scope);
|
||||
} else if( t instanceof IFunctionType ){
|
||||
IFunctionType ft = (IFunctionType) t;
|
||||
|
||||
|
@ -2767,7 +2769,7 @@ public class CPPSemantics {
|
|||
return cost;
|
||||
}
|
||||
|
||||
static protected IType getUltimateType( IType type, boolean stopAtPointerToMember ){
|
||||
public static IType getUltimateType( IType type, boolean stopAtPointerToMember ){
|
||||
try {
|
||||
while( true ){
|
||||
if( type instanceof ITypedef )
|
||||
|
|
|
@ -64,7 +64,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
|||
|
||||
private Database db;
|
||||
|
||||
public static final int VERSION = 15;
|
||||
public static final int VERSION = 16;
|
||||
// 0 - the beginning of it all
|
||||
// 1 - first change to kick off upgrades
|
||||
// 2 - added file inclusions
|
||||
|
@ -81,7 +81,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
|||
// 13 - CV-qualifiers, storage class specifiers, function/method annotations
|
||||
// 14 - added timestamps for files (bug 149571)
|
||||
// 15 - fixed offsets for pointer types and qualifier types and PDOMCPPVariable (bug 160540).
|
||||
|
||||
// 16 - have PDOMCPPField store type information, and PDOMCPPNamespaceAlias store what it is aliasing
|
||||
|
||||
public static final int LINKAGES = Database.DATA_AREA;
|
||||
public static final int FILE_INDEX = Database.DATA_AREA + 4;
|
||||
|
|
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.pdom.dom;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||
|
@ -150,8 +151,27 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
|
|||
return new char[0];
|
||||
}
|
||||
|
||||
public IScope getScope() throws DOMException {
|
||||
// TODO implement this
|
||||
public IScope getParent() throws DOMException {
|
||||
try {
|
||||
IBinding parent = getParentBinding();
|
||||
if(parent instanceof IScope) {
|
||||
return (IScope) parent;
|
||||
}
|
||||
} catch(CoreException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final IScope getScope() throws DOMException {
|
||||
try {
|
||||
IBinding parent = getParentBinding();
|
||||
if(parent instanceof IScope) {
|
||||
return (IScope) parent;
|
||||
}
|
||||
} catch(CoreException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -181,7 +201,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
|
|||
/**
|
||||
* Convenience method to shorten subclass file length
|
||||
*/
|
||||
protected void fail() { throw new PDOMNotImplementedError(); }
|
||||
protected final void fail() { throw new PDOMNotImplementedError(); }
|
||||
|
||||
public boolean mayHaveChildren() {
|
||||
return false;
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
|
@ -247,6 +248,21 @@ class PDOMCLinkage extends PDOMLinkage {
|
|||
}
|
||||
} else if (parent instanceof ICASTElaboratedTypeSpecifier) {
|
||||
constant = CSTRUCTURE;
|
||||
} else if (parent instanceof IASTNamedTypeSpecifier){
|
||||
FindBindingByLinkageConstant finder = new FindBindingByLinkageConstant(this, name.toCharArray(), CSTRUCTURE);
|
||||
getIndex().accept(finder);
|
||||
PDOMBinding result = finder.getResult();
|
||||
if(result==null) {
|
||||
finder = new FindBindingByLinkageConstant(this, name.toCharArray(), CENUMERATION);
|
||||
getIndex().accept(finder);
|
||||
result = finder.getResult();
|
||||
}
|
||||
if(result==null) {
|
||||
finder = new FindBindingByLinkageConstant(this, name.toCharArray(), CTYPEDEF);
|
||||
getIndex().accept(finder);
|
||||
result = finder.getResult();
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -17,16 +17,16 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
class PDOMCTypedef extends PDOMBinding implements ITypedef {
|
||||
class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer {
|
||||
|
||||
private static final int TYPE = PDOMBinding.RECORD_SIZE + 0;
|
||||
|
||||
|
@ -68,12 +68,7 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isSameType(IType type) {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public void setType(IType type) {fail();}
|
||||
public boolean isSameType(IType type) {fail(); return false;}
|
||||
public Object clone() {fail(); return null;}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ abstract public class PDOMCPPBinding extends PDOMBinding implements ICPPBinding
|
|||
}
|
||||
|
||||
// TODO: performance?
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
final public String[] getQualifiedName() throws DOMException {
|
||||
List result = new ArrayList();
|
||||
try {
|
||||
PDOMNode node = this;
|
||||
|
@ -53,7 +53,7 @@ abstract public class PDOMCPPBinding extends PDOMBinding implements ICPPBinding
|
|||
}
|
||||
|
||||
// TODO: performance?
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
final public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
String[] preResult = getQualifiedName();
|
||||
char[][] result = new char[preResult.length][];
|
||||
for(int i=0; i<preResult.length; i++) {
|
||||
|
|
|
@ -22,27 +22,40 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
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.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.bid.ILocalBindingIdentity;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.FindBindingByLinkageConstant;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.FindEquivalentBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
|
@ -52,16 +65,16 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* aftodo - contract get Methods/Fields not honoured?
|
||||
*/
|
||||
class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
|
||||
ICPPClassScope, IPDOMMemberOwner {
|
||||
ICPPClassScope, IPDOMMemberOwner {
|
||||
|
||||
private static final int FIRSTBASE = PDOMCPPBinding.RECORD_SIZE + 0;
|
||||
private static final int KEY = PDOMCPPBinding.RECORD_SIZE + 4; // byte
|
||||
private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 8;
|
||||
|
||||
|
||||
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 12;
|
||||
|
||||
public PDOMCPPClassType(PDOM pdom, PDOMNode parent, ICPPClassType classType)
|
||||
throws CoreException {
|
||||
throws CoreException {
|
||||
super(pdom, parent, classType.getName().toCharArray());
|
||||
|
||||
try {
|
||||
|
@ -71,11 +84,11 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
|
|||
}
|
||||
// linked list is initialized by storage being zero'd by malloc
|
||||
}
|
||||
|
||||
|
||||
public PDOMCPPClassType(PDOM pdom, int bindingRecord) {
|
||||
super(pdom, bindingRecord);
|
||||
}
|
||||
|
||||
|
||||
public void addMember(PDOMNode member) throws CoreException {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
|
||||
list.addMember(member);
|
||||
|
@ -98,21 +111,20 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
|
|||
int rec = base != null ? base.getRecord() : 0;
|
||||
pdom.getDB().putInt(record + FIRSTBASE, rec);
|
||||
}
|
||||
|
||||
|
||||
public void addBase(PDOMCPPBase base) throws CoreException {
|
||||
PDOMCPPBase firstBase = getFirstBase();
|
||||
base.setNextBase(firstBase);
|
||||
setFirstBase(base);
|
||||
}
|
||||
|
||||
|
||||
public boolean isSameType(IType type) {
|
||||
if (type instanceof PDOMBinding)
|
||||
return record == ((PDOMBinding)type).getRecord();
|
||||
else
|
||||
// TODO - should we check for real?
|
||||
return false;
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
|
||||
public ICPPBase[] getBases() throws DOMException {
|
||||
try {
|
||||
List list = new ArrayList();
|
||||
|
@ -132,7 +144,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
|
|||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
|
||||
list.accept(visitor);
|
||||
}
|
||||
|
||||
|
||||
private static class GetMethods implements IPDOMVisitor {
|
||||
private final List methods;
|
||||
public GetMethods(List methods) {
|
||||
|
@ -152,7 +164,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
|
|||
return (ICPPMethod[])methods.toArray(new ICPPMethod[methods.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ICPPMethod[] getDeclaredMethods() throws DOMException {
|
||||
try {
|
||||
GetMethods methods = new GetMethods();
|
||||
|
@ -167,11 +179,11 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
|
|||
if (visited.contains(this))
|
||||
return;
|
||||
visited.add(this);
|
||||
|
||||
|
||||
// Get my members
|
||||
GetMethods myMethods = new GetMethods(methods);
|
||||
accept(myMethods);
|
||||
|
||||
|
||||
// Visit my base classes
|
||||
for (PDOMCPPBase base = getFirstBase(); base != null; base = base.getNextBase()) {
|
||||
try {
|
||||
|
@ -183,7 +195,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
|
||||
List methods = new ArrayList();
|
||||
Set visited = new HashSet();
|
||||
|
@ -214,7 +226,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
|
|||
return (IField[])fields.toArray(new IField[fields.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IField[] getFields() throws DOMException {
|
||||
try {
|
||||
GetFields visitor = new GetFields();
|
||||
|
@ -241,7 +253,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
|
|||
return (ICPPClassType[])nestedClasses.toArray(new ICPPClassType[nestedClasses.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ICPPClassType[] getNestedClasses() throws DOMException {
|
||||
try {
|
||||
GetNestedClasses visitor = new GetNestedClasses();
|
||||
|
@ -265,7 +277,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
|
|||
return ICPPClassType.k_class; // or something
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
try {
|
||||
return getParentNode() instanceof PDOMLinkage;
|
||||
|
@ -291,40 +303,216 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
|
|||
}
|
||||
|
||||
public void addChild(PDOMNode member) throws CoreException {addMember(member);}
|
||||
|
||||
|
||||
public ICPPConstructor[] getConstructors() throws DOMException {
|
||||
// TODO
|
||||
return new ICPPConstructor[0];
|
||||
}
|
||||
|
||||
|
||||
public boolean isFullyCached() throws DOMException {return true;}
|
||||
|
||||
|
||||
public IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
|
||||
IASTNode parent = name.getParent();
|
||||
|
||||
ASTNodeProperty prop = name.getPropertyInParent();
|
||||
|
||||
PDOMLinkage linkage;
|
||||
try {
|
||||
linkage = getLinkageImpl();
|
||||
|
||||
if (name instanceof ICPPASTQualifiedName) {
|
||||
IASTName lastName = ((ICPPASTQualifiedName)name).getLastName();
|
||||
return lastName != null ? lastName.resolveBinding() : null;
|
||||
}
|
||||
|
||||
if(parent instanceof ICPPASTQualifiedName) {
|
||||
IASTName[] names = ((ICPPASTQualifiedName)parent).getNames();
|
||||
int index = ArrayUtil.indexOf(names, name);
|
||||
|
||||
if (index == names.length - 1) { // tip of qn
|
||||
parent = parent.getParent();
|
||||
} else {
|
||||
{ // bail out if this is not the outerscope of the name being resolved
|
||||
if(index==-1) {
|
||||
throw new PDOMNotImplementedError();
|
||||
} else {
|
||||
if(index>0) {
|
||||
// make sure we're the class they're talking about
|
||||
PDOMBinding binding = (PDOMBinding) pdom.findBinding(names[index-1]);
|
||||
if(!equals(binding)) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
// ok - just search us and return null if there is nothing in here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FindBindingByLinkageConstant visitor = new FindBindingByLinkageConstant(linkage, name.toCharArray(), PDOMCPPLinkage.CPPCLASSTYPE);
|
||||
try {
|
||||
accept(visitor);
|
||||
} catch(CoreException e) {
|
||||
if (e.getStatus().equals(Status.OK_STATUS)) {
|
||||
return visitor.getResult();
|
||||
} else {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
visitor = new FindBindingByLinkageConstant(linkage, name.toCharArray(), PDOMCPPLinkage.CPPMETHOD);
|
||||
try {
|
||||
accept(visitor);
|
||||
} catch(CoreException e) {
|
||||
if (e.getStatus().equals(Status.OK_STATUS)) {
|
||||
return visitor.getResult();
|
||||
} else {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
visitor = new FindBindingByLinkageConstant(linkage, name.toCharArray(), PDOMCPPLinkage.CPPFIELD);
|
||||
try {
|
||||
accept(visitor);
|
||||
} catch(CoreException e) {
|
||||
if (e.getStatus().equals(Status.OK_STATUS)) {
|
||||
return visitor.getResult();
|
||||
} else {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
visitor = new FindBindingByLinkageConstant(linkage, name.toCharArray(), PDOMCPPLinkage.CPPENUMERATION);
|
||||
try {
|
||||
accept(visitor);
|
||||
} catch(CoreException e) {
|
||||
if (e.getStatus().equals(Status.OK_STATUS)) {
|
||||
return visitor.getResult();
|
||||
} else {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
visitor = new FindBindingByLinkageConstant(linkage, name.toCharArray(), PDOMCPPLinkage.CPPENUMERATOR);
|
||||
try {
|
||||
accept(visitor);
|
||||
} catch(CoreException e) {
|
||||
if (e.getStatus().equals(Status.OK_STATUS)) {
|
||||
return visitor.getResult();
|
||||
} else {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
return null; // not found in this scope
|
||||
}
|
||||
}
|
||||
|
||||
IASTNode eParent = parent.getParent();
|
||||
if(parent instanceof IASTIdExpression) {
|
||||
FindBindingByLinkageConstant visitor = new FindBindingByLinkageConstant(linkage, name.toCharArray(), PDOMCPPLinkage.CPPENUMERATOR);
|
||||
try {
|
||||
accept(visitor);
|
||||
} catch(CoreException e) {
|
||||
if (e.getStatus().equals(Status.OK_STATUS)) {
|
||||
return visitor.getResult();
|
||||
} else {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
} else if(eParent instanceof IASTFunctionCallExpression) {
|
||||
if(parent.getPropertyInParent().equals(IASTFunctionCallExpression.FUNCTION_NAME)) {
|
||||
IType[] types = ((PDOMCPPLinkage)linkage).getTypes(
|
||||
((IASTFunctionCallExpression)eParent).getParameterExpression()
|
||||
);
|
||||
if(types!=null) {
|
||||
ILocalBindingIdentity bid = new CPPBindingIdentity.Holder(
|
||||
new String(name.toCharArray()),
|
||||
PDOMCPPLinkage.CPPFUNCTION,
|
||||
types);
|
||||
FindEquivalentBinding feb = new FindEquivalentBinding(linkage, bid);
|
||||
try {
|
||||
accept(feb);
|
||||
} catch(CoreException e) {
|
||||
if (e.getStatus().equals(Status.OK_STATUS)) {
|
||||
return feb.getResult();
|
||||
} else {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
return feb.getResult();
|
||||
}
|
||||
} else if(parent.getPropertyInParent().equals(IASTFunctionCallExpression.PARAMETERS)) {
|
||||
if(parent instanceof IASTFieldReference) {
|
||||
FindBindingByLinkageConstant visitor = new FindBindingByLinkageConstant(linkage, name.toCharArray(), PDOMCPPLinkage.CPPFIELD);
|
||||
try {
|
||||
accept(visitor);
|
||||
} catch(CoreException e) {
|
||||
if (e.getStatus().equals(Status.OK_STATUS)) {
|
||||
return visitor.getResult();
|
||||
} else {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(prop.equals(IASTFieldReference.FIELD_NAME)) {
|
||||
FindBindingByLinkageConstant visitor = new FindBindingByLinkageConstant(linkage, name.toCharArray(), PDOMCPPLinkage.CPPFIELD);
|
||||
try {
|
||||
accept(visitor);
|
||||
} catch(CoreException e) {
|
||||
if (e.getStatus().equals(Status.OK_STATUS)) {
|
||||
return visitor.getResult();
|
||||
} else {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
} else if (parent instanceof IASTNamedTypeSpecifier) {
|
||||
FindBindingByLinkageConstant visitor = new FindBindingByLinkageConstant(linkage, name.toCharArray(), PDOMCPPLinkage.CPPCLASSTYPE);
|
||||
try {
|
||||
accept(visitor);
|
||||
} catch(CoreException e) {
|
||||
if (e.getStatus().equals(Status.OK_STATUS)) {
|
||||
return visitor.getResult();
|
||||
} else {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
visitor = new FindBindingByLinkageConstant(linkage, name.toCharArray(), PDOMCPPLinkage.CPPENUMERATION);
|
||||
try {
|
||||
accept(visitor);
|
||||
} catch(CoreException e) {
|
||||
if (e.getStatus().equals(Status.OK_STATUS)) {
|
||||
return visitor.getResult();
|
||||
} else {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public IScope getParent() throws DOMException {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Not implemented
|
||||
|
||||
|
||||
public Object clone() {fail();return null;}
|
||||
public IField findField(String name) throws DOMException {fail();return null;}
|
||||
public IBinding[] getFriends() throws DOMException {fail();return null;}
|
||||
public ICPPMethod[] getImplicitMethods() {fail(); return null;}
|
||||
public IBinding[] find(String name) throws DOMException {fail();return null;}
|
||||
public ICPPField[] getDeclaredFields() throws DOMException {fail();return null;}
|
||||
|
||||
public IScope getScope() throws DOMException {
|
||||
|
||||
public IScope getParent() throws DOMException {
|
||||
try {
|
||||
return (IScope)getParentNode();
|
||||
IBinding parent = getParentBinding();
|
||||
if(parent instanceof IScope) {
|
||||
return (IScope) parent;
|
||||
}
|
||||
} catch(CoreException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public boolean mayHaveChildren() {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -14,53 +14,32 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCAnnotation;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
class PDOMCPPField extends PDOMCPPBinding implements ICPPField {
|
||||
|
||||
/**
|
||||
* Offset of annotation information (relative to the beginning of the
|
||||
* record).
|
||||
*/
|
||||
private static final int ANNOTATION = PDOMBinding.RECORD_SIZE + 0; // byte
|
||||
|
||||
/**
|
||||
* The size in bytes of a PDOMCPPField record in the database.
|
||||
*/
|
||||
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 1;
|
||||
class PDOMCPPField extends PDOMCPPVariable implements ICPPField {
|
||||
|
||||
public PDOMCPPField(PDOM pdom, PDOMCPPClassType parent, ICPPField field)
|
||||
throws CoreException {
|
||||
super(pdom, parent, field.getNameCharArray());
|
||||
try {
|
||||
Database db = pdom.getDB();
|
||||
db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(field));
|
||||
} catch (DOMException e) {
|
||||
throw new CoreException(Util.createStatus(e));
|
||||
}
|
||||
super(pdom, parent, field);
|
||||
}
|
||||
|
||||
public PDOMCPPField(PDOM pdom, int bindingRecord) {
|
||||
super(pdom, bindingRecord);
|
||||
}
|
||||
|
||||
// @Override
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
// @Override
|
||||
public int getNodeType() {
|
||||
return PDOMCPPLinkage.CPPFIELD;
|
||||
}
|
||||
|
@ -73,41 +52,31 @@ class PDOMCPPField extends PDOMCPPBinding implements ICPPField {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
return CPPVisitor.getQualifiedName( this );
|
||||
}
|
||||
|
||||
public int getVisibility() throws DOMException {
|
||||
return PDOMCPPAnnotation.getVisibility(getByte(record + ANNOTATION));
|
||||
return PDOMCPPAnnotation.getVisibility(getByte(record + ANNOTATIONS));
|
||||
}
|
||||
|
||||
// @Override
|
||||
public boolean isMutable() throws DOMException {
|
||||
return getBit(getByte(record + ANNOTATION), PDOMCPPAnnotation.MUTABLE_OFFSET);
|
||||
}
|
||||
|
||||
public IType getType() throws DOMException {
|
||||
// TODO
|
||||
return null;
|
||||
return getBit(getByte(record + ANNOTATIONS), PDOMCPPAnnotation.MUTABLE_OFFSET);
|
||||
}
|
||||
|
||||
// @Override
|
||||
public boolean isAuto() throws DOMException {
|
||||
// ISO/IEC 14882:2003 9.2.6
|
||||
return false;
|
||||
}
|
||||
|
||||
// @Override
|
||||
public boolean isExtern() throws DOMException {
|
||||
// ISO/IEC 14882:2003 9.2.6
|
||||
return false;
|
||||
}
|
||||
|
||||
// @Override
|
||||
public boolean isRegister() throws DOMException {
|
||||
// ISO/IEC 14882:2003 9.2.6
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isStatic() throws DOMException {
|
||||
return getBit(getByte(record + ANNOTATION), PDOMCAnnotation.STATIC_OFFSET);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,24 +13,29 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
|
||||
|
@ -43,19 +48,21 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
|||
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.ICPPNamespaceAlias;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.bid.IBindingIdentityFactory;
|
||||
import org.eclipse.cdt.internal.core.dom.bid.ILocalBindingIdentity;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitMethod;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariable;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.FindBindingByLinkageConstant;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.FindEquivalentBinding;
|
||||
|
@ -65,6 +72,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
|||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
||||
|
@ -123,9 +131,10 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
|
||||
IBinding binding = name.resolveBinding();
|
||||
|
||||
if (binding == null || binding instanceof IProblemBinding)
|
||||
if (binding == null || binding instanceof IProblemBinding) {
|
||||
// Can't tell what it is
|
||||
return null;
|
||||
}
|
||||
|
||||
if (binding instanceof IParameter)
|
||||
// Skip parameters (TODO and others I'm sure)
|
||||
|
@ -288,6 +297,7 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
|
||||
private PDOMBinding _resolveBinding(IASTName name) throws CoreException, DOMException {
|
||||
// mstodo revisit
|
||||
|
||||
IBinding origBinding = name.getBinding();
|
||||
if (origBinding != null)
|
||||
return adaptBinding(origBinding);
|
||||
|
@ -298,6 +308,7 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
return resolveBinding(names[0]);
|
||||
IASTName lastName = names[names.length - 1];
|
||||
PDOMBinding nsBinding = adaptBinding(names[names.length - 2].resolveBinding());
|
||||
// aftodo - namespace aliases?
|
||||
if (nsBinding instanceof IScope) {
|
||||
return (PDOMBinding) ((IScope)nsBinding).getBinding(lastName, true);
|
||||
}
|
||||
|
@ -319,21 +330,68 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
// reference
|
||||
IASTNode eParent = parent.getParent();
|
||||
if (eParent instanceof IASTFunctionCallExpression) {
|
||||
if(parent.getPropertyInParent().equals(IASTFunctionCallExpression.FUNCTION_NAME)) {
|
||||
return resolveFunctionCall((IASTFunctionCallExpression) eParent, (IASTIdExpression) parent, name);
|
||||
if (parent.getPropertyInParent().equals(IASTFunctionCallExpression.FUNCTION_NAME)) {
|
||||
return resolveFunctionCall(
|
||||
(IASTFunctionCallExpression) eParent,
|
||||
(IASTIdExpression) parent, name);
|
||||
} else if (parent.getPropertyInParent().equals(IASTFunctionCallExpression.PARAMETERS)) {
|
||||
int constant = (name.getParent() instanceof ICPPASTQualifiedName
|
||||
&& ((ICPPASTQualifiedName) name.getParent()).getLastName() != name)
|
||||
? CPPNAMESPACE : CPPVARIABLE;
|
||||
FindBindingByLinkageConstant finder = new FindBindingByLinkageConstant(
|
||||
this, name.toCharArray(), constant);
|
||||
getIndex().accept(finder);
|
||||
return finder.getResult();
|
||||
}
|
||||
} else {
|
||||
int constant = (name.getParent() instanceof ICPPASTQualifiedName
|
||||
&& ((ICPPASTQualifiedName)name.getParent()).getLastName() != name)
|
||||
? CPPNAMESPACE : CPPVARIABLE;
|
||||
FindBindingByLinkageConstant finder = new FindBindingByLinkageConstant(this, name.toCharArray(), constant);
|
||||
// if the address of me is taken, and assigned to something,
|
||||
// find out the type of the thing I'm assigned to
|
||||
if (eParent instanceof IASTUnaryExpression) {
|
||||
IASTUnaryExpression unaryExp = (IASTUnaryExpression) eParent;
|
||||
if (unaryExp.getOperator() == IASTUnaryExpression.op_amper) {
|
||||
IASTNode epParent = eParent.getParent();
|
||||
if (epParent instanceof IASTBinaryExpression) {
|
||||
if (((IASTBinaryExpression) epParent).getOperator() == IASTBinaryExpression.op_assign) {
|
||||
IASTExpression left = ((IASTBinaryExpression) epParent).getOperand1();
|
||||
IType type = CPPSemantics.getUltimateType(left.getExpressionType(), false);
|
||||
if (type instanceof IFunctionType) {
|
||||
ILocalBindingIdentity lbi = new CPPBindingIdentity.Holder(
|
||||
new String(name.toCharArray()),
|
||||
CPPFUNCTION,
|
||||
((IFunctionType) type).getParameterTypes());
|
||||
FindEquivalentBinding feb = new FindEquivalentBinding(this, lbi);
|
||||
getIndex().accept(feb);
|
||||
return feb.getResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FindBindingByLinkageConstant finder = new FindBindingByLinkageConstant(this, name.toCharArray(), CPPVARIABLE);
|
||||
getIndex().accept(finder);
|
||||
|
||||
if (finder.getResult() == null) {
|
||||
finder = new FindBindingByLinkageConstant(this, name
|
||||
.toCharArray(), CPPENUMERATOR);
|
||||
getIndex().accept(finder);
|
||||
}
|
||||
return finder.getResult();
|
||||
}
|
||||
} else if (parent instanceof IASTNamedTypeSpecifier) {
|
||||
FindBindingByLinkageConstant finder = new FindBindingByLinkageConstant(this, name.toCharArray(), CPPCLASSTYPE);
|
||||
getIndex().accept(finder);
|
||||
PDOMBinding result = finder.getResult();
|
||||
if(result==null) {
|
||||
finder = new FindBindingByLinkageConstant(this, name.toCharArray(), CPPENUMERATION);
|
||||
getIndex().accept(finder);
|
||||
result = finder.getResult();
|
||||
}
|
||||
if(result==null) {
|
||||
finder = new FindBindingByLinkageConstant(this, name.toCharArray(), CPPTYPEDEF);
|
||||
getIndex().accept(finder);
|
||||
result = finder.getResult();
|
||||
}
|
||||
return result;
|
||||
} else if (parent instanceof ICPPASTNamespaceAlias) {
|
||||
FindBindingByLinkageConstant finder = new FindBindingByLinkageConstant(this, name.toCharArray(), CPPNAMESPACE);
|
||||
|
@ -349,8 +407,31 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
if(name.getPropertyInParent().equals(IASTFieldReference.FIELD_NAME)) {
|
||||
return resolveFunctionCall((IASTFunctionCallExpression) eParent, fieldOwner, name);
|
||||
}
|
||||
} else {
|
||||
IBinding fieldOwnerBinding = fieldOwner.getName().getBinding();
|
||||
if(fieldOwnerBinding instanceof ICPPVariable) {
|
||||
IType type = ((ICPPVariable)fieldOwnerBinding).getType();
|
||||
if(type instanceof ICompositeType) {
|
||||
PDOMBinding pdomFOB = adaptBinding( (ICompositeType) type);
|
||||
FindBindingByLinkageConstant visitor = new FindBindingByLinkageConstant(this, name.toCharArray(), PDOMCPPLinkage.CPPFIELD);
|
||||
try {
|
||||
((PDOMBinding)pdomFOB).accept(visitor);
|
||||
} catch (CoreException e) {
|
||||
if (e.getStatus().equals(Status.OK_STATUS)) {
|
||||
return visitor.getResult();
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(parent instanceof ICPPASTBaseSpecifier) {
|
||||
FindBindingByLinkageConstant finder = new FindBindingByLinkageConstant(this, name.toCharArray(), CPPCLASSTYPE);
|
||||
getIndex().accept(finder);
|
||||
return finder.getResult();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -361,11 +442,17 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
* @param paramExp the parameter expression to get types for (null indicates void function/method)
|
||||
* @return an array of types or null if types could not be determined (because of missing semantic information in the AST)
|
||||
*/
|
||||
public IType[] getTypes(IASTExpression paramExp) {
|
||||
public IType[] getTypes(IASTExpression paramExp) throws DOMException {
|
||||
IType[] types = null;
|
||||
|
||||
if(paramExp==null) { // void function/method
|
||||
types = new IType[0];
|
||||
} else if(paramExp instanceof ICPPASTNewExpression) {
|
||||
// aftodo - I'm not 100% sure why a new expression doesn't
|
||||
// have a pointer type already
|
||||
ICPPASTNewExpression exp3 = (ICPPASTNewExpression) paramExp;
|
||||
IType type = exp3.getExpressionType();
|
||||
types = new IType[] {new CPPPointerType(type)};
|
||||
} else {
|
||||
if(paramExp instanceof IASTExpressionList) {
|
||||
IASTExpressionList list = (IASTExpressionList) paramExp;
|
||||
|
@ -374,21 +461,22 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
for(int i=0; i<paramExps.length; i++) {
|
||||
types[i] = paramExps[i].getExpressionType();
|
||||
}
|
||||
} else if(paramExp instanceof IASTLiteralExpression) {
|
||||
IASTLiteralExpression litExp = (IASTLiteralExpression) paramExp;
|
||||
types = new IType[] {litExp.getExpressionType()};
|
||||
} else if(paramExp instanceof ICPPASTNewExpression) {
|
||||
ICPPASTNewExpression exp3 = (ICPPASTNewExpression) paramExp;
|
||||
IType type = exp3.getExpressionType();
|
||||
types = new IType[] {new CPPPointerType(type)};
|
||||
} else if(paramExp instanceof CPPASTIdExpression) {
|
||||
IBinding nameBinding = ((CPPASTIdExpression)paramExp).getName().resolveBinding();
|
||||
if(nameBinding instanceof CPPVariable) {
|
||||
types = new IType[] {((CPPVariable)nameBinding).getType()};
|
||||
}
|
||||
} else {
|
||||
types = new IType[] {paramExp.getExpressionType()};
|
||||
}
|
||||
}
|
||||
|
||||
if(types!=null) { // aftodo - unit test coverage of this is low
|
||||
for(int i=0; i<types.length; i++) {
|
||||
// aftodo - assumed this always terminates
|
||||
while(types[i] instanceof ITypedef) {
|
||||
types[i] = ((ITypedef)types[i]).getType();
|
||||
}
|
||||
if(types[i] instanceof ProblemBinding)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
|
@ -397,41 +485,71 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
*
|
||||
* (It does work though)
|
||||
*/
|
||||
public PDOMBinding resolveFunctionCall(IASTFunctionCallExpression callExp, IASTIdExpression id, IASTName name) throws CoreException, DOMException {
|
||||
public PDOMBinding resolveFunctionCall(IASTFunctionCallExpression callExp,
|
||||
IASTIdExpression id, IASTName name) throws CoreException,
|
||||
DOMException {
|
||||
IASTExpression paramExp = callExp.getParameterExpression();
|
||||
|
||||
IType[] types = getTypes(paramExp);
|
||||
if(types!=null) {
|
||||
if (types != null) {
|
||||
IBinding parentBinding = id.getName().getBinding();
|
||||
ILocalBindingIdentity bid = null;
|
||||
if(parentBinding == null) { // filescope
|
||||
bid = new CPPBindingIdentity.Holder(
|
||||
new String(name.toCharArray()),
|
||||
CPPFUNCTION,
|
||||
types);
|
||||
FindEquivalentBinding feb = new FindEquivalentBinding(this, bid);
|
||||
getIndex().accept(feb);
|
||||
return feb.getResult();
|
||||
} else if(parentBinding instanceof ICPPVariable) {
|
||||
|
||||
if (parentBinding instanceof ICPPVariable) {
|
||||
|
||||
ICPPVariable v = (ICPPVariable) parentBinding;
|
||||
IType type = v.getType();
|
||||
if(type instanceof PDOMBinding) {
|
||||
bid = new CPPBindingIdentity.Holder(
|
||||
new String(name.toCharArray()),
|
||||
CPPMETHOD,
|
||||
types);
|
||||
FindEquivalentBinding feb = new FindEquivalentBinding(this, bid);
|
||||
if (type instanceof PDOMBinding) {
|
||||
bid = new CPPBindingIdentity.Holder(new String(name
|
||||
.toCharArray()), CPPMETHOD, types);
|
||||
FindEquivalentBinding feb = new FindEquivalentBinding(this,
|
||||
bid);
|
||||
try {
|
||||
((PDOMBinding)type).accept(feb);
|
||||
((PDOMBinding) type).accept(feb);
|
||||
} catch (CoreException e) {
|
||||
if (e.getStatus().equals(Status.OK_STATUS)) {
|
||||
return feb.getResult();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IASTNode expPNode = callExp.getParent();
|
||||
if (expPNode instanceof IASTBinaryExpression) {
|
||||
IASTBinaryExpression bExp = (IASTBinaryExpression) expPNode;
|
||||
switch (bExp.getOperator()) {
|
||||
case ICPPASTBinaryExpression.op_pmarrow: /* fall through */
|
||||
case ICPPASTBinaryExpression.op_pmdot:
|
||||
IASTExpression left = bExp.getOperand1();
|
||||
IType t = CPPSemantics.getUltimateType(left.getExpressionType(), false);
|
||||
if (t instanceof PDOMCPPClassType) {
|
||||
bid = new CPPBindingIdentity.Holder(
|
||||
new String(name.toCharArray()),
|
||||
CPPMETHOD,
|
||||
types);
|
||||
FindEquivalentBinding feb = new FindEquivalentBinding(this, bid);
|
||||
try {
|
||||
((PDOMCPPClassType) t).accept(feb);
|
||||
} catch (CoreException e) {
|
||||
if (e.getStatus().equals(Status.OK_STATUS)) {
|
||||
return feb.getResult();
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else { // filescope
|
||||
bid = new CPPBindingIdentity.Holder(
|
||||
new String(name.toCharArray()),
|
||||
CPPFUNCTION,
|
||||
types);
|
||||
FindEquivalentBinding feb = new FindEquivalentBinding(this,bid);
|
||||
getIndex().accept(feb);
|
||||
return feb.getResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -443,29 +561,44 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
|
||||
// Must be a namespace or a class
|
||||
IASTName[] names = qualName.getNames();
|
||||
IASTName nsName = null;
|
||||
for (int i = 0; i < names.length; ++i) {
|
||||
if (names[i] == name)
|
||||
break;
|
||||
else
|
||||
nsName = names[i];
|
||||
}
|
||||
if (nsName == names[names.length - 1])
|
||||
// didn't find our name here, weird...
|
||||
return null;
|
||||
int index = ArrayUtil.indexOf(names, name);
|
||||
if(index!=-1) {
|
||||
if (index == 0) {
|
||||
// we are at the root
|
||||
FindBindingByLinkageConstant finder = new FindBindingByLinkageConstant(
|
||||
this, name.toCharArray(), CPPNAMESPACE);
|
||||
|
||||
if (nsName == null) {
|
||||
// we are at the root
|
||||
|
||||
FindBindingByLinkageConstant finder = new FindBindingByLinkageConstant(this, name.toCharArray(), CPPNAMESPACE);
|
||||
getIndex().accept(finder);
|
||||
if(finder.getResult()==null) {
|
||||
finder = new FindBindingByLinkageConstant(this, name.toCharArray(), CPPCLASSTYPE);
|
||||
getIndex().accept(finder);
|
||||
if (finder.getResult() == null) {
|
||||
finder = new FindBindingByLinkageConstant(this, name.toCharArray(), CPPCLASSTYPE);
|
||||
getIndex().accept(finder);
|
||||
}
|
||||
if (finder.getResult() == null) {
|
||||
finder = new FindBindingByLinkageConstant(this, name.toCharArray(), CPPNAMESPACEALIAS);
|
||||
getIndex().accept(finder);
|
||||
}
|
||||
return finder.getResult();
|
||||
} else {
|
||||
try {
|
||||
PDOMBinding binding = adaptBinding(names[index-1].getBinding());
|
||||
if(binding instanceof PDOMCPPClassType) {
|
||||
// TODO - a test case for this..
|
||||
return (PDOMBinding) ((PDOMCPPClassType)binding).getBinding(name, true);
|
||||
} else if(binding instanceof PDOMCPPNamespaceAlias) {
|
||||
PDOMCPPNamespace pns = (PDOMCPPNamespace) ((PDOMCPPNamespaceAlias) binding).getBinding();
|
||||
return (PDOMBinding) ((ICPPNamespaceScope) pns).getBinding(name, true);
|
||||
} else if(binding instanceof PDOMCPPNamespace) {
|
||||
return (PDOMBinding) ((ICPPNamespaceScope)binding).getBinding(name, true);
|
||||
} else {
|
||||
throw new PDOMNotImplementedError(); // aftodo - again I think we can't get here
|
||||
}
|
||||
} catch(DOMException de) {
|
||||
throw new CoreException(CCorePlugin.createStatus(de.getMessage())); // aftodo
|
||||
}
|
||||
}
|
||||
return finder.getResult();
|
||||
} else {
|
||||
// TODO we are in another namespace
|
||||
// aftodo - I don't believe this can happen..
|
||||
// didn't find our name here, weird...
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -480,6 +613,11 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
if (binding != null) {
|
||||
return binding;
|
||||
}
|
||||
} else if(type instanceof IEnumeration) {
|
||||
PDOMBinding binding= adaptBinding((IEnumeration) type);
|
||||
if (binding != null) {
|
||||
return binding;
|
||||
}
|
||||
}
|
||||
return super.addType(parent, type);
|
||||
}
|
||||
|
|
|
@ -235,13 +235,4 @@ class PDOMCPPMethod extends PDOMCPPBinding implements ICPPMethod, ICPPFunctionTy
|
|||
// TODO further analysis to compare with DOM objects
|
||||
return false;
|
||||
}
|
||||
|
||||
public IScope getScope() throws DOMException {
|
||||
try {
|
||||
return (IScope)getParentNode();
|
||||
} catch(CoreException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,14 +28,17 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.bid.ILocalBindingIdentity;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.FindBindingByLinkageConstant;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.FindBindingsInBTree;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.FindEquivalentBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -123,17 +126,31 @@ class PDOMCPPNamespace extends PDOMCPPBinding
|
|||
IASTNode parent = name.getParent();
|
||||
if (parent instanceof ICPPASTQualifiedName) {
|
||||
IASTName[] names = ((ICPPASTQualifiedName)parent).getNames();
|
||||
if (name == names[names.length - 1]) {
|
||||
int index = ArrayUtil.indexOf(names, name);
|
||||
|
||||
if (index == names.length - 1) { // tip of qn
|
||||
parent = parent.getParent();
|
||||
} else {
|
||||
IASTName nsname = null;
|
||||
for (int i = 0; i < names.length - 2; ++i) {
|
||||
if (name != names[i])
|
||||
nsname = names[i];
|
||||
{ // bail out if this is not the outerscope of the name being resolved
|
||||
if(index==-1) {
|
||||
throw new PDOMNotImplementedError();
|
||||
} else {
|
||||
if(index>0) {
|
||||
// make sure we're the namespace they're talking about
|
||||
PDOMBinding binding = (PDOMBinding) pdom.findBinding(names[index-1]); // index == 0 ?
|
||||
if(binding instanceof PDOMCPPNamespaceAlias) {
|
||||
// aftodo - this needs a review - do we want to assign to binding
|
||||
// or just check against this?
|
||||
binding = (PDOMBinding) ((PDOMCPPNamespaceAlias) binding).getBinding();
|
||||
}
|
||||
if(!equals(binding)) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
// ok - just search us and return null if there is nothing in here
|
||||
}
|
||||
}
|
||||
}
|
||||
// make sure we're the namespace they're talking about
|
||||
if (nsname != null && !equals(pdom.findBinding(nsname)))
|
||||
return null;
|
||||
|
||||
// Look up the name
|
||||
FindBindingsInBTree visitor = new FindBindingsInBTree(getLinkageImpl(), name.toCharArray(),
|
||||
|
@ -167,15 +184,22 @@ class PDOMCPPNamespace extends PDOMCPPBinding
|
|||
}
|
||||
}
|
||||
} else {
|
||||
FindBindingsInBTree visitor = new FindBindingsInBTree(getLinkageImpl(), name.toCharArray(),
|
||||
(name.getParent() instanceof ICPPASTQualifiedName
|
||||
&& ((ICPPASTQualifiedName)name.getParent()).getLastName() != name)
|
||||
? PDOMCPPLinkage.CPPNAMESPACE : PDOMCPPLinkage.CPPVARIABLE);
|
||||
getIndex().accept(visitor);
|
||||
IBinding[] bindings = visitor.getBinding();
|
||||
return bindings.length > 0
|
||||
? bindings[0]
|
||||
: null;
|
||||
int desiredType = ((name.getParent() instanceof ICPPASTQualifiedName)
|
||||
&& ((ICPPASTQualifiedName)name.getParent()).getLastName() != name)
|
||||
? PDOMCPPLinkage.CPPNAMESPACE : PDOMCPPLinkage.CPPVARIABLE;
|
||||
FindBindingByLinkageConstant visitor2 = new FindBindingByLinkageConstant(getLinkageImpl(), name.toCharArray(), desiredType);
|
||||
getIndex().accept(visitor2);
|
||||
if(visitor2.getResult()!=null) {
|
||||
return visitor2.getResult();
|
||||
}
|
||||
|
||||
visitor2 = new FindBindingByLinkageConstant(getLinkageImpl(), name.toCharArray(), PDOMCPPLinkage.CPPTYPEDEF);
|
||||
getIndex().accept(visitor2);
|
||||
if(visitor2.getResult()!=null) {
|
||||
return visitor2.getResult();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
} else if (parent instanceof IASTNamedTypeSpecifier) {
|
||||
FindBindingsInBTree visitor = new FindBindingsInBTree(getLinkageImpl(), name.toCharArray(), PDOMCPPLinkage.CPPCLASSTYPE);
|
||||
|
|
|
@ -11,11 +11,13 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -27,9 +29,14 @@ import org.eclipse.core.runtime.CoreException;
|
|||
class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements
|
||||
ICPPNamespaceAlias {
|
||||
|
||||
private static final int NAMESPACE_BINDING = PDOMCPPBinding.RECORD_SIZE + 0;
|
||||
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 4;
|
||||
|
||||
public PDOMCPPNamespaceAlias(PDOM pdom, PDOMNode parent, ICPPNamespaceAlias alias)
|
||||
throws CoreException {
|
||||
super(pdom, parent, alias.getNameCharArray());
|
||||
PDOMBinding namespace = getLinkageImpl().adaptBinding(alias.getBinding());
|
||||
pdom.getDB().putInt(record + NAMESPACE_BINDING, namespace.getRecord());
|
||||
}
|
||||
|
||||
public PDOMCPPNamespaceAlias(PDOM pdom, int record) {
|
||||
|
@ -45,7 +52,7 @@ class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements
|
|||
}
|
||||
|
||||
public ICPPNamespaceScope getNamespaceScope() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
return (ICPPNamespaceScope) getBinding();
|
||||
}
|
||||
|
||||
public IBinding[] getMemberBindings() throws DOMException {
|
||||
|
@ -57,7 +64,12 @@ class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements
|
|||
}
|
||||
|
||||
public IBinding getBinding() {
|
||||
throw new PDOMNotImplementedError();
|
||||
try {
|
||||
return (IBinding) getLinkageImpl().getNode(getPDOM().getDB().getInt(record + NAMESPACE_BINDING));
|
||||
} catch(CoreException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,16 +17,16 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
class PDOMCPPTypedef extends PDOMBinding implements ITypedef {
|
||||
class PDOMCPPTypedef extends PDOMBinding implements ITypedef, ITypeContainer {
|
||||
|
||||
private static final int TYPE = PDOMBinding.RECORD_SIZE + 0;
|
||||
|
||||
|
@ -67,12 +67,30 @@ class PDOMCPPTypedef extends PDOMBinding implements ITypedef {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isSameType(IType type) {
|
||||
throw new PDOMNotImplementedError();
|
||||
public boolean isSameType(IType o) {
|
||||
if( o == this )
|
||||
return true;
|
||||
if( o instanceof ITypedef )
|
||||
try {
|
||||
IType t = getType();
|
||||
if( t != null )
|
||||
return t.isSameType( ((ITypedef)o).getType());
|
||||
return false;
|
||||
} catch ( DOMException e ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
IType t = getType();
|
||||
if( t != null )
|
||||
return t.isSameType( o );
|
||||
} catch(DOMException de) {
|
||||
CCorePlugin.log(de);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public Object clone() { fail(); return null; }
|
||||
public void setType(IType type) { fail(); }
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
|||
* Offset of annotation information (relative to the beginning of the
|
||||
* record).
|
||||
*/
|
||||
private static final int ANNOTATIONS = PDOMBinding.RECORD_SIZE + 4; // byte
|
||||
protected static final int ANNOTATIONS = PDOMBinding.RECORD_SIZE + 4; // byte
|
||||
|
||||
/**
|
||||
* The size in bytes of a PDOMCPPVariable record in the database.
|
||||
|
|
Loading…
Add table
Reference in a new issue