mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
181735: (part II) fix index related resolution problems
This commit is contained in:
parent
dbaba763e1
commit
512a83717e
13 changed files with 396 additions and 139 deletions
|
@ -36,6 +36,7 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
@ -141,10 +142,14 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
||||||
return names[0].resolveBinding();
|
return names[0].resolveBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void assertQNEquals(String expectedQn, IBinding b12) {
|
protected static void assertQNEquals(String expectedQN, IBinding b) {
|
||||||
try {
|
try {
|
||||||
assertTrue(b12 instanceof ICPPBinding);
|
assertInstance(b, IBinding.class);
|
||||||
assertEquals(expectedQn, CPPVisitor.renderQualifiedName(((ICPPBinding)b12).getQualifiedName()));
|
if(b instanceof ICPPBinding) {
|
||||||
|
assertEquals(expectedQN, CPPVisitor.renderQualifiedName(((ICPPBinding)b).getQualifiedName()));
|
||||||
|
} else {
|
||||||
|
assertEquals(expectedQN, b.getName());
|
||||||
|
}
|
||||||
} catch(DOMException de) {
|
} catch(DOMException de) {
|
||||||
fail(de.getMessage());
|
fail(de.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -176,7 +181,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
||||||
assertEquals(qn, CPPVisitor.renderQualifiedName(((ICPPClassType)ft.getParameterTypes()[index]).getQualifiedName()));
|
assertEquals(qn, CPPVisitor.renderQualifiedName(((ICPPClassType)ft.getParameterTypes()[index]).getQualifiedName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertInstance(Object o, Class c) {
|
protected static void assertInstance(Object o, Class c) {
|
||||||
assertNotNull(o);
|
assertNotNull(o);
|
||||||
assertTrue("Expected "+c.getName()+" but got "+o.getClass().getName(), c.isInstance(o));
|
assertTrue("Expected "+c.getName()+" but got "+o.getClass().getName(), c.isInstance(o));
|
||||||
}
|
}
|
||||||
|
@ -199,6 +204,37 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
||||||
public boolean isCompositeIndex();
|
public boolean isCompositeIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static void assertVariable(IBinding b, String qn, Class expType, String expTypeQN) {
|
||||||
|
try {
|
||||||
|
assertInstance(b, IVariable.class);
|
||||||
|
IVariable variable = (IVariable) b;
|
||||||
|
assertQNEquals(qn, variable);
|
||||||
|
assertInstance(variable.getType(), expType);
|
||||||
|
if(expTypeQN!=null) {
|
||||||
|
IType type= variable.getType();
|
||||||
|
assertInstance(type, IBinding.class);
|
||||||
|
assertQNEquals(expTypeQN, (IBinding) type);
|
||||||
|
}
|
||||||
|
} catch(DOMException de) {
|
||||||
|
fail(de.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void assertTypeContainer(IType conType, String expQN, Class containerType, Class expContainedType, String expContainedTypeQN) {
|
||||||
|
try {
|
||||||
|
assertInstance(conType, ITypeContainer.class);
|
||||||
|
assertInstance(conType, containerType);
|
||||||
|
IType containedType= ((ITypeContainer)conType).getType();
|
||||||
|
assertInstance(containedType, expContainedType);
|
||||||
|
if(expContainedTypeQN!=null) {
|
||||||
|
assertInstance(containedType, IBinding.class);
|
||||||
|
assertQNEquals(expContainedTypeQN, (IBinding) containedType);
|
||||||
|
}
|
||||||
|
} catch(DOMException de) {
|
||||||
|
fail(de.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class SinglePDOMTestStrategy implements ITestStrategy {
|
class SinglePDOMTestStrategy implements ITestStrategy {
|
||||||
private IIndex index;
|
private IIndex index;
|
||||||
private ICProject cproject;
|
private ICProject cproject;
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
// {
|
// {
|
||||||
// void* v= func1;
|
// void* v= func1;
|
||||||
// }
|
// }
|
||||||
public void _testBug181735() throws DOMException {
|
public void testBug181735() throws DOMException {
|
||||||
IBinding b0 = getBindingFromASTName("func1;", 5);
|
IBinding b0 = getBindingFromASTName("func1;", 5);
|
||||||
assertTrue(b0 instanceof IFunction);
|
assertTrue(b0 instanceof IFunction);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,13 @@ import java.io.IOException;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For testing PDOM binding C language resolution
|
* For testing PDOM binding C language resolution
|
||||||
|
@ -45,20 +49,36 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
||||||
}
|
}
|
||||||
|
|
||||||
// // header file
|
// // header file
|
||||||
// struct S {}; union U {}; enum E {ER1,ER2,ER3};
|
// struct S {int x;};
|
||||||
// int var1; S var2; S *var3; void func1(E); void func2(S);
|
// union U {int x;};
|
||||||
// typedef int Int; typedef int *IntPtr;
|
// enum E {ER1,ER2,ER3};
|
||||||
// void func3(int** ppi); void func4(int);
|
// void func1(enum E e) {}
|
||||||
|
// void func2(struct S s) {}
|
||||||
|
// void func3(int** ppi) {}
|
||||||
|
// void func4(int n) {}
|
||||||
|
//
|
||||||
|
// int var1;
|
||||||
|
// struct S var2;
|
||||||
|
// struct S *var3;
|
||||||
|
// typedef int Int;
|
||||||
|
// typedef int *IntPtr;
|
||||||
|
|
||||||
// // referencing file
|
// // referencing file
|
||||||
// #include "header.h"
|
|
||||||
// void references() {
|
// void references() {
|
||||||
// struct S s; /*s*/ union U u; /*u*/ E e; /*e*/
|
// struct S s; /*s*/
|
||||||
// var1 = 1; /*var1*/ var2 = s; /*var2*/ var3 = &s; /*var3*/
|
// union U u; /*u*/
|
||||||
// func1(e); /*func1*/ func1(var1); /*func2*/ func2(s); /*func3*/
|
// enum E e; /*e*/
|
||||||
// Int a; /*a*/
|
// Int a; /*a*/
|
||||||
// IntPtr b = &a; /*b*/
|
// IntPtr b = &a; /*b*/
|
||||||
// func3(*b); /*func4*/ func4(a); /*func5*/
|
// func3(&b); /*func4*/
|
||||||
|
// func4(a); /*func5*/
|
||||||
|
//
|
||||||
|
// var1 = 1; /*var1*/
|
||||||
|
// var2 = s; /*var2*/
|
||||||
|
// var3 = &s; /*var3*/
|
||||||
|
// func1(e); /*func1*/
|
||||||
|
// func1(var1); /*func2*/
|
||||||
|
// func2(s); /*func3*/
|
||||||
// }
|
// }
|
||||||
public void testSimpleGlobalBindings() throws IOException {
|
public void testSimpleGlobalBindings() throws IOException {
|
||||||
IBinding b2 = getBindingFromASTName("S s;", 1);
|
IBinding b2 = getBindingFromASTName("S s;", 1);
|
||||||
|
@ -77,12 +97,45 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
||||||
IBinding b15 = getBindingFromASTName("a; ", 1);
|
IBinding b15 = getBindingFromASTName("a; ", 1);
|
||||||
IBinding b16 = getBindingFromASTName("IntPtr b = &a; ", 6);
|
IBinding b16 = getBindingFromASTName("IntPtr b = &a; ", 6);
|
||||||
IBinding b17 = getBindingFromASTName("b = &a; /*b*/", 1);
|
IBinding b17 = getBindingFromASTName("b = &a; /*b*/", 1);
|
||||||
IBinding b18 = getBindingFromASTName("func3(*b);", 5);
|
IBinding b18 = getBindingFromASTName("func3(&b);", 5);
|
||||||
IBinding b19 = getBindingFromASTName("b); /*func4*/", 1);
|
IBinding b19 = getBindingFromASTName("b); /*func4*/", 1);
|
||||||
IBinding b20 = getBindingFromASTName("func4(a);", 5);
|
IBinding b20 = getBindingFromASTName("func4(a);", 5);
|
||||||
IBinding b21 = getBindingFromASTName("a); /*func5*/", 1);
|
IBinding b21 = getBindingFromASTName("a); /*func5*/", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// // empty
|
||||||
|
|
||||||
|
// typedef struct S {int a;} S;
|
||||||
|
// typedef enum E {A,B} E;
|
||||||
|
// struct A {
|
||||||
|
// S *s;
|
||||||
|
// E *e;
|
||||||
|
// };
|
||||||
|
public void testTypedefA() throws Exception {
|
||||||
|
IBinding b1 = getBindingFromASTName("S {", 1);
|
||||||
|
IBinding b2 = getBindingFromASTName("S;", 1);
|
||||||
|
IBinding b3 = getBindingFromASTName("E {", 1);
|
||||||
|
IBinding b4 = getBindingFromASTName("E;", 1);
|
||||||
|
IBinding b5 = getBindingFromASTName("S *s", 1);
|
||||||
|
IBinding b6 = getBindingFromASTName("E *e", 1);
|
||||||
|
|
||||||
|
assertInstance(b1, ICompositeType.class);
|
||||||
|
assertInstance(b2, ITypedef.class);
|
||||||
|
|
||||||
|
assertInstance(b3, IEnumeration.class);
|
||||||
|
assertInstance(b4, ITypedef.class);
|
||||||
|
|
||||||
|
assertInstance(b5, ITypedef.class);
|
||||||
|
ITypedef t5= (ITypedef) b5;
|
||||||
|
assertInstance(t5.getType(), ICompositeType.class);
|
||||||
|
assertEquals(ICompositeType.k_struct, ((ICompositeType)t5.getType()).getKey());
|
||||||
|
|
||||||
|
assertInstance(b6, ITypedef.class);
|
||||||
|
ITypedef t6= (ITypedef) b6;
|
||||||
|
assertInstance(t6.getType(), IEnumeration.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// typedef struct S {int a;} S;
|
// typedef struct S {int a;} S;
|
||||||
// typedef enum E {A,B} E;
|
// typedef enum E {A,B} E;
|
||||||
|
|
||||||
|
@ -90,18 +143,116 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
||||||
// S *s;
|
// S *s;
|
||||||
// E *e;
|
// E *e;
|
||||||
// };
|
// };
|
||||||
public void testTypedef() {
|
public void testTypedefB() throws Exception {
|
||||||
IBinding b1 = getBindingFromASTName("S", 1);
|
IBinding b1 = getBindingFromASTName("S *s", 1);
|
||||||
assertTrue(b1 instanceof ICompositeType);
|
IBinding b2 = getBindingFromASTName("E *e", 1);
|
||||||
IBinding b2 = getBindingFromASTName("E", 1);
|
|
||||||
assertTrue(b2 instanceof IEnumeration);
|
assertInstance(b1, ITypedef.class);
|
||||||
|
ITypedef t1= (ITypedef) b1;
|
||||||
|
assertInstance(t1.getType(), ICompositeType.class);
|
||||||
|
assertEquals(ICompositeType.k_struct, ((ICompositeType)t1.getType()).getKey());
|
||||||
|
|
||||||
|
assertInstance(b2, ITypedef.class);
|
||||||
|
ITypedef t2= (ITypedef) b2;
|
||||||
|
assertInstance(t2.getType(), IEnumeration.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void _testEnumeratorInFileScope() {fail("todo");}
|
// union U {
|
||||||
public void _testEnumeratorInStructScope() {fail("todo");}
|
// int x;
|
||||||
public void _testEnumeratorInUnionScope() {fail("todo");}
|
// int y;
|
||||||
public void _testFieldReference() {fail("todo");}
|
// };
|
||||||
public void _testMemberAccess() {fail("todo");}
|
// struct S {
|
||||||
|
// union U u;
|
||||||
|
// int z;
|
||||||
|
// };
|
||||||
|
// typedef struct S TS;
|
||||||
|
|
||||||
|
// void refs() {
|
||||||
|
// union U b1;
|
||||||
|
// struct S b2;
|
||||||
|
// union U *b3 = &b1;
|
||||||
|
// struct S *b4 = &b2;
|
||||||
|
// TS b5;
|
||||||
|
// TS *b6 = &b5;
|
||||||
|
//
|
||||||
|
// b1.x = 0;
|
||||||
|
// b1.y = 1;
|
||||||
|
// b2.u.x = 2;
|
||||||
|
// b2.u.y = 3;
|
||||||
|
// b3->x = 4;
|
||||||
|
// b3->y = 5;
|
||||||
|
// b4->u.x = 6;
|
||||||
|
// b4->u.y = 7;
|
||||||
|
// b4->z = 8;
|
||||||
|
// b5.u.x = 9;
|
||||||
|
// b5.u.y = 10;
|
||||||
|
// b6->u.x = 11;
|
||||||
|
// b6->u.y = 12;
|
||||||
|
// b6->z = 13;
|
||||||
|
// }
|
||||||
|
public void testFieldReference() throws Exception {
|
||||||
|
IBinding b01 = getBindingFromASTName("b1;",2);
|
||||||
|
assertVariable(b01, "b1", ICompositeType.class, "U");
|
||||||
|
IBinding b02 = getBindingFromASTName("b2;",2);
|
||||||
|
assertVariable(b02, "b2", ICompositeType.class, "S");
|
||||||
|
IBinding b03 = getBindingFromASTName("b3 =",2);
|
||||||
|
assertVariable(b03, "b3", IPointerType.class, null);
|
||||||
|
assertTypeContainer(((IVariable)b03).getType(), null, IPointerType.class, ICompositeType.class, "U");
|
||||||
|
IBinding b04 = getBindingFromASTName("b4 =",2);
|
||||||
|
assertVariable(b04, "b4", IPointerType.class, null);
|
||||||
|
assertTypeContainer(((IVariable)b04).getType(), null, IPointerType.class, ICompositeType.class, "S");
|
||||||
|
IBinding b05 = getBindingFromASTName("b5;",2);
|
||||||
|
assertVariable(b05, "b5", ITypedef.class, null);
|
||||||
|
assertTypeContainer(((IVariable)b05).getType(), null, ITypedef.class, ICompositeType.class, "S");
|
||||||
|
IBinding b06 = getBindingFromASTName("b6 =",2);
|
||||||
|
assertVariable(b06, "b6", IPointerType.class, null);
|
||||||
|
assertTypeContainer(((IVariable)b06).getType(), null, IPointerType.class, ITypedef.class, "TS");
|
||||||
|
assertTypeContainer(((IPointerType)((IVariable)b06).getType()).getType(), null, ITypedef.class, ICompositeType.class, "S");
|
||||||
|
IBinding b07 = getBindingFromASTName("x = 0",1);
|
||||||
|
assertVariable(b07, "x", IBasicType.class, null);
|
||||||
|
IBinding b08 = getBindingFromASTName("y = 1",1);
|
||||||
|
assertVariable(b08, "y", IBasicType.class, null);
|
||||||
|
IBinding b09 = getBindingFromASTName("x = 0",1);
|
||||||
|
assertVariable(b09, "x", IBasicType.class, null);
|
||||||
|
IBinding b10 = getBindingFromASTName("y = 1",1);
|
||||||
|
assertVariable(b08, "y", IBasicType.class, null);
|
||||||
|
IBinding b11 = getBindingFromASTName("u.x = 2",1);
|
||||||
|
assertVariable(b11, "u", ICompositeType.class, "U");
|
||||||
|
IBinding b12 = getBindingFromASTName("x = 2",1);
|
||||||
|
assertVariable(b12, "x", IBasicType.class, null);
|
||||||
|
IBinding b13 = getBindingFromASTName("u.y = 3",1);
|
||||||
|
assertVariable(b13, "u", ICompositeType.class, "U");
|
||||||
|
IBinding b14 = getBindingFromASTName("y = 3",1);
|
||||||
|
assertVariable(b08, "y", IBasicType.class, null);
|
||||||
|
IBinding b15 = getBindingFromASTName("x = 4",1);
|
||||||
|
assertVariable(b15, "x", IBasicType.class, null);
|
||||||
|
IBinding b16 = getBindingFromASTName("y = 5",1);
|
||||||
|
assertVariable(b16, "y", IBasicType.class, null);
|
||||||
|
IBinding b17 = getBindingFromASTName("u.x = 6",1);
|
||||||
|
assertVariable(b17, "u", ICompositeType.class, "U");
|
||||||
|
IBinding b18 = getBindingFromASTName("x = 6",1);
|
||||||
|
assertVariable(b18, "x", IBasicType.class, null);
|
||||||
|
IBinding b19 = getBindingFromASTName("u.y = 7",1);
|
||||||
|
assertVariable(b19, "u", ICompositeType.class, "U");
|
||||||
|
IBinding b20 = getBindingFromASTName("y = 7",1);
|
||||||
|
assertVariable(b20, "y", IBasicType.class, null);
|
||||||
|
IBinding b21 = getBindingFromASTName("z = 8",1);
|
||||||
|
assertVariable(b21, "z", IBasicType.class, null);
|
||||||
|
IBinding b22 = getBindingFromASTName("x = 9",1);
|
||||||
|
assertVariable(b22, "x", IBasicType.class, null);
|
||||||
|
IBinding b23 = getBindingFromASTName("y = 10",1);
|
||||||
|
assertVariable(b23, "y", IBasicType.class, null);
|
||||||
|
IBinding b24 = getBindingFromASTName("u.x = 11",1);
|
||||||
|
assertVariable(b24, "u", ICompositeType.class, "U");
|
||||||
|
IBinding b25 = getBindingFromASTName("x = 11",1);
|
||||||
|
assertVariable(b25, "x", IBasicType.class, null);
|
||||||
|
IBinding b26 = getBindingFromASTName("u.y = 12",1);
|
||||||
|
assertVariable(b26, "u", ICompositeType.class, "U");
|
||||||
|
IBinding b27 = getBindingFromASTName("y = 12",1);
|
||||||
|
assertVariable(b27, "y", IBasicType.class, null);
|
||||||
|
IBinding b28 = getBindingFromASTName("z = 13",1);
|
||||||
|
assertVariable(b28, "z", IBasicType.class, null);
|
||||||
|
}
|
||||||
|
|
||||||
// // header file
|
// // header file
|
||||||
// struct S {struct S* sp;};
|
// struct S {struct S* sp;};
|
||||||
|
@ -110,7 +261,6 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
||||||
// int foo3(int i);
|
// int foo3(int i);
|
||||||
// int foo4(int i, struct S s);
|
// int foo4(int i, struct S s);
|
||||||
|
|
||||||
// /* aftodo - latter cases need review */
|
|
||||||
// // referencing content
|
// // referencing content
|
||||||
// void references() {
|
// void references() {
|
||||||
// struct S s, *sp;
|
// struct S s, *sp;
|
||||||
|
@ -125,32 +275,27 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
||||||
// foo3/*i*/(23489); // IASTLiteralExpression
|
// foo3/*i*/(23489); // IASTLiteralExpression
|
||||||
// foo3/*j*/(sizeof(struct S));/*8*/ // IASTTypeIdExpression
|
// foo3/*j*/(sizeof(struct S));/*8*/ // IASTTypeIdExpression
|
||||||
// foo1/*k*/(*sp);/*9*/ // IASTUnaryExpression
|
// foo1/*k*/(*sp);/*9*/ // IASTUnaryExpression
|
||||||
// /* not applicable */ // ICPPASTDeleteExpression
|
|
||||||
// /* not applicable */ // ICPPASTNewExpression
|
|
||||||
// // ?? foo/*n*/(); // ICPPASTSimpleTypeConstructorExpression
|
|
||||||
// // ?? foo/*o*/(); // ICPPASTTypenameExprssion
|
|
||||||
// // foo/*p*/(MADE_UP_SYMBOL); // ICPPASTTypenameExprssion
|
|
||||||
// }
|
// }
|
||||||
public void _testExpressionKindForFunctionCalls() {
|
public void testExpressionKindForFunctionCalls() {
|
||||||
IBinding b0 = getBindingFromASTName("foo1/*a*/", 4);
|
IBinding b0 = getBindingFromASTName("foo1/*a*/", 4);
|
||||||
IBinding b0a = getBindingFromASTName("ap[1]", 2);
|
IBinding b0a = getBindingFromASTName("sp[1]", 2);
|
||||||
|
|
||||||
IBinding b1 = getBindingFromASTName("foo2/*b*/", 4);
|
IBinding b1 = getBindingFromASTName("foo2/*b*/", 4);
|
||||||
IBinding b1a = getBindingFromASTName("ap+1);", 2);
|
IBinding b1a = getBindingFromASTName("sp+1);", 2);
|
||||||
|
|
||||||
IBinding b2 = getBindingFromASTName("foo2/*c*/", 4);
|
IBinding b2 = getBindingFromASTName("foo2/*c*/", 4);
|
||||||
IBinding b2a = getBindingFromASTName("ap);/*1*/", 2);
|
IBinding b2a = getBindingFromASTName("sp);/*1*/", 2);
|
||||||
|
|
||||||
IBinding b3 = getBindingFromASTName("foo1/*d*/", 4);
|
IBinding b3 = getBindingFromASTName("foo1/*d*/", 4);
|
||||||
IBinding b3a = getBindingFromASTName("a : a);/*2*/", 1);
|
IBinding b3a = getBindingFromASTName("s : s);/*2*/", 1);
|
||||||
IBinding b3b = getBindingFromASTName("a);/*2*/", 1);
|
IBinding b3b = getBindingFromASTName("s);/*2*/", 1);
|
||||||
|
|
||||||
IBinding b4 = getBindingFromASTName("foo4/*e*/", 4);
|
IBinding b4 = getBindingFromASTName("foo4/*e*/", 4);
|
||||||
IBinding b4a = getBindingFromASTName("a);/*3*/", 1);
|
IBinding b4a = getBindingFromASTName("s);/*3*/", 1);
|
||||||
|
|
||||||
IBinding b5 = getBindingFromASTName("foo2/*f*/", 4);
|
IBinding b5 = getBindingFromASTName("foo2/*f*/", 4);
|
||||||
IBinding b5a = getBindingFromASTName("a.ap);/*4*/", 1);
|
IBinding b5a = getBindingFromASTName("s.sp);/*4*/", 1);
|
||||||
IBinding b5b = getBindingFromASTName("ap);/*4*/", 2);
|
IBinding b5b = getBindingFromASTName("sp);/*4*/", 2);
|
||||||
IBinding b5c = getBindingFromASTName("sp->sp);/*5*/", 2);
|
IBinding b5c = getBindingFromASTName("sp->sp);/*5*/", 2);
|
||||||
IBinding b5d = getBindingFromASTName("sp);/*5*/", 2);
|
IBinding b5d = getBindingFromASTName("sp);/*5*/", 2);
|
||||||
|
|
||||||
|
@ -169,4 +314,9 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
||||||
IBinding b10 = getBindingFromASTName("foo1/*k*/", 4);
|
IBinding b10 = getBindingFromASTName("foo1/*k*/", 4);
|
||||||
IBinding b10a = getBindingFromASTName("sp);/*9*/ ", 2);
|
IBinding b10a = getBindingFromASTName("sp);/*9*/ ", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void _testEnumeratorInFileScope() {fail("todo");}
|
||||||
|
public void _testEnumeratorInStructScope() {fail("todo");}
|
||||||
|
public void _testEnumeratorInUnionScope() {fail("todo");}
|
||||||
|
public void _testMemberAccess() {fail("todo");}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1126,27 +1126,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
||||||
/* CPP assertion helpers */
|
/* CPP assertion helpers */
|
||||||
/* ##################################################################### */
|
/* ##################################################################### */
|
||||||
|
|
||||||
static protected void assertVariable(
|
|
||||||
IBinding binding,
|
|
||||||
String qn,
|
|
||||||
Class expType,
|
|
||||||
String expTypeQN
|
|
||||||
) {
|
|
||||||
try {
|
|
||||||
assertTrue(binding instanceof ICPPVariable);
|
|
||||||
ICPPVariable variable = (ICPPVariable) binding;
|
|
||||||
assertQNEquals(qn, variable);
|
|
||||||
assertTrue(expType.isInstance(variable.getType()));
|
|
||||||
if(expTypeQN!=null) {
|
|
||||||
assert(variable.getType() instanceof ICPPBinding);
|
|
||||||
ICPPBinding tyBinding = (ICPPBinding) variable.getType();
|
|
||||||
assertQNEquals(expTypeQN, tyBinding);
|
|
||||||
}
|
|
||||||
} catch(DOMException de) {
|
|
||||||
fail(de.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static protected void assertField(
|
static protected void assertField(
|
||||||
IBinding binding,
|
IBinding binding,
|
||||||
String qn,
|
String qn,
|
||||||
|
|
|
@ -10,8 +10,15 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.pdom.tests;
|
package org.eclipse.cdt.internal.pdom.tests;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||||
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
|
import org.eclipse.cdt.internal.core.index.CIndex;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,4 +39,36 @@ public class PDOMPrettyPrinter implements IPDOMVisitor {
|
||||||
System.out.println(indent+""+node);
|
System.out.println(indent+""+node);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps the contents of the specified linkage for all primary fragments of the specified index
|
||||||
|
* to standard out, including file local scopes.
|
||||||
|
* @param index
|
||||||
|
* @param linkageID
|
||||||
|
*/
|
||||||
|
public static void dumpLinkage(IIndex index, final String linkageID) {
|
||||||
|
final IPDOMVisitor v= new PDOMPrettyPrinter();
|
||||||
|
IIndexFragment[] frg= ((CIndex)index).getPrimaryFragments();
|
||||||
|
for(int i=0; i<frg.length; i++) {
|
||||||
|
final PDOM pdom = (PDOM) frg[i];
|
||||||
|
try {
|
||||||
|
pdom.getLinkage(linkageID).getIndex().accept(
|
||||||
|
new IBTreeVisitor() {
|
||||||
|
public int compare(int record) throws CoreException {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
public boolean visit(int record) throws CoreException {
|
||||||
|
if(record==0) return false;
|
||||||
|
PDOMNode node= pdom.getLinkage(linkageID).getNode(record);
|
||||||
|
if(v.visit(node))
|
||||||
|
node.accept(v);
|
||||||
|
v.leave(node);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch(CoreException ce) {
|
||||||
|
CCorePlugin.log(ce);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -16,27 +17,38 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.IName;
|
import org.eclipse.cdt.core.dom.IName;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICScope;
|
import org.eclipse.cdt.core.dom.ast.c.ICScope;
|
||||||
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
|
@ -175,8 +187,22 @@ public class CScope implements ICScope, IASTInternalScope {
|
||||||
int type = getNamespaceType( name );
|
int type = getNamespaceType( name );
|
||||||
Object o = bindings[type].get( name.toCharArray() );
|
Object o = bindings[type].get( name.toCharArray() );
|
||||||
|
|
||||||
if( o == null )
|
if( o == null ) {
|
||||||
return null;
|
IBinding result= null;
|
||||||
|
if(physicalNode instanceof IASTTranslationUnit) {
|
||||||
|
IIndex index= ((IASTTranslationUnit)physicalNode).getIndex();
|
||||||
|
if(index!=null) {
|
||||||
|
try {
|
||||||
|
IBinding[] bindings= index.findBindings(name.toCharArray(), getIndexFilter(type), new NullProgressMonitor());
|
||||||
|
result= processIndexResults(name, bindings);
|
||||||
|
} catch(CoreException ce) {
|
||||||
|
CCorePlugin.log(ce);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if( o instanceof IBinding )
|
if( o instanceof IBinding )
|
||||||
return (IBinding) o;
|
return (IBinding) o;
|
||||||
|
@ -187,6 +213,74 @@ public class CScope implements ICScope, IASTInternalScope {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index results from global scope, differ from ast results from translation unit scope. This routine
|
||||||
|
* is intended to fix results from the index to be consistent with ast scope behaviour.
|
||||||
|
* @param name the name as it occurs in the ast
|
||||||
|
* @param bindings the set of candidate bindings
|
||||||
|
* @return the appropriate binding, or null if no binding is appropriate for the ast name
|
||||||
|
*/
|
||||||
|
private IBinding processIndexResults(IASTName name, IBinding[] bindings) {
|
||||||
|
if(bindings.length!=1)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
IBinding candidate= bindings[0];
|
||||||
|
if(candidate instanceof IFunction) {
|
||||||
|
IASTNode parent= name.getParent();
|
||||||
|
if(parent instanceof IASTFunctionDeclarator) {
|
||||||
|
IASTNode parent2= parent.getParent();
|
||||||
|
if(parent2 instanceof IASTFunctionDefinition) {
|
||||||
|
IASTFunctionDefinition def= (IASTFunctionDefinition) parent2;
|
||||||
|
if(def.getDeclSpecifier().getStorageClass()==IASTDeclSpecifier.sc_static) {
|
||||||
|
try {
|
||||||
|
if(!((IFunction)candidate).isStatic()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch(DOMException de) {
|
||||||
|
CCorePlugin.log(de);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return candidate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a C-linkage filter suitable for searching the index for the types of bindings
|
||||||
|
* specified
|
||||||
|
* @param type the types of bindings to search for. One of {@link CScope#NAMESPACE_TYPE_TAG}
|
||||||
|
* or {@link CScope#NAMESPACE_TYPE_OTHER}, otherwise the C-linkage will not be filtered
|
||||||
|
* @return a C-linkage filter suitable for searching the index for the types of bindings
|
||||||
|
* specified
|
||||||
|
*/
|
||||||
|
private IndexFilter getIndexFilter(final int type) {
|
||||||
|
switch(type) {
|
||||||
|
case NAMESPACE_TYPE_TAG:
|
||||||
|
return new IndexFilter() {
|
||||||
|
public boolean acceptBinding(IBinding binding) {
|
||||||
|
return binding instanceof ICompositeType || binding instanceof IEnumeration;
|
||||||
|
}
|
||||||
|
public boolean acceptLinkage(ILinkage linkage) {
|
||||||
|
return linkage.getID().equals(ILinkage.C_LINKAGE_ID);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
case NAMESPACE_TYPE_OTHER:
|
||||||
|
return new IndexFilter() {
|
||||||
|
public boolean acceptBinding(IBinding binding) {
|
||||||
|
return !(binding instanceof ICompositeType || binding instanceof IEnumeration);
|
||||||
|
}
|
||||||
|
public boolean acceptLinkage(ILinkage linkage) {
|
||||||
|
return linkage.getID().equals(ILinkage.C_LINKAGE_ID);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
default:
|
||||||
|
return IndexFilter.getFilter(ILinkage.C_LINKAGE_ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.c.ICScope#setFullyCached(boolean)
|
* @see org.eclipse.cdt.core.dom.ast.c.ICScope#setFullyCached(boolean)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
@ -95,6 +96,7 @@ import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||||
|
@ -498,10 +500,13 @@ public class CVisitor {
|
||||||
binding = null;
|
binding = null;
|
||||||
}
|
}
|
||||||
if( binding != null ){
|
if( binding != null ){
|
||||||
if( binding instanceof CEnumeration )
|
if(binding instanceof IEnumeration && (binding instanceof IIndexBinding || binding instanceof CEnumeration) ) {
|
||||||
|
if( binding instanceof CEnumeration ) {
|
||||||
((CEnumeration)binding).addDefinition( name );
|
((CEnumeration)binding).addDefinition( name );
|
||||||
else
|
}
|
||||||
|
} else {
|
||||||
return new ProblemBinding( name, IProblemBinding.SEMANTIC_INVALID_OVERLOAD, name.toCharArray() );
|
return new ProblemBinding( name, IProblemBinding.SEMANTIC_INVALID_OVERLOAD, name.toCharArray() );
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
binding = new CEnumeration( name );
|
binding = new CEnumeration( name );
|
||||||
try {
|
try {
|
||||||
|
@ -1243,7 +1248,8 @@ public class CVisitor {
|
||||||
}
|
}
|
||||||
if( binding != null )
|
if( binding != null )
|
||||||
return binding;
|
return binding;
|
||||||
} else if (!prefix && scope != null && scope.getParent() == null && scope.getBinding( name, false ) != null) {
|
} else if (!prefix && scope != null && scope.getParent() == null
|
||||||
|
&& scope.getBinding( name, false ) != null) {
|
||||||
binding = scope.getBinding( name, false );
|
binding = scope.getBinding( name, false );
|
||||||
return binding;
|
return binding;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1351,17 +1357,6 @@ public class CVisitor {
|
||||||
return ArrayUtil.trim( IBinding.class, result );
|
return ArrayUtil.trim( IBinding.class, result );
|
||||||
}
|
}
|
||||||
if( blockItem != null) {
|
if( blockItem != null) {
|
||||||
// We're at the end of our rope, check the PDOM if we can
|
|
||||||
IASTTranslationUnit tu = (IASTTranslationUnit)blockItem;
|
|
||||||
IIndex index = tu.getIndex();
|
|
||||||
if (index != null) {
|
|
||||||
try {
|
|
||||||
binding = index.findBinding(name);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (binding == null)
|
if (binding == null)
|
||||||
return externalBinding( (IASTTranslationUnit) blockItem, name );
|
return externalBinding( (IASTTranslationUnit) blockItem, name );
|
||||||
else
|
else
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
|
@ -27,7 +28,10 @@ class CompositeCFunction extends CompositeCBinding implements IIndexBinding, IFu
|
||||||
super(cf, rbinding);
|
super(cf, rbinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IScope getFunctionScope() throws DOMException {fail(); return null;}
|
public IScope getFunctionScope() throws DOMException {
|
||||||
|
IScope scope= ((IFunction)rbinding).getFunctionScope();
|
||||||
|
return cf.getCompositeScope((IIndexScope)scope);
|
||||||
|
}
|
||||||
|
|
||||||
public IParameter[] getParameters() throws DOMException {
|
public IParameter[] getParameters() throws DOMException {
|
||||||
IParameter[] preResult = ((IFunction)rbinding).getParameters();
|
IParameter[] preResult = ((IFunction)rbinding).getParameters();
|
||||||
|
|
|
@ -178,7 +178,13 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
||||||
|
|
||||||
public abstract PDOMBinding adaptBinding(IBinding binding) throws CoreException;
|
public abstract PDOMBinding adaptBinding(IBinding binding) throws CoreException;
|
||||||
|
|
||||||
public abstract PDOMBinding resolveBinding(IASTName name) throws CoreException;
|
public final PDOMBinding resolveBinding(IASTName name) throws CoreException {
|
||||||
|
IBinding binding= name.resolveBinding();
|
||||||
|
if (binding != null) {
|
||||||
|
return adaptBinding(binding);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -125,7 +125,7 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
|
||||||
return PDOMCFunction.this.getReturnType();
|
return PDOMCFunction.this.getReturnType();
|
||||||
}
|
}
|
||||||
public boolean isSameType(IType type) {
|
public boolean isSameType(IType type) {
|
||||||
return PDOMCFunction.this.isSameType(type);
|
fail(); return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IScope getFunctionScope() throws DOMException {fail(); return null;}
|
public IScope getFunctionScope() throws DOMException {
|
||||||
public boolean isSameType(IType type) {fail(); return false;}
|
return null;
|
||||||
public Object clone() {fail(); return null;}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,7 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
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.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.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
|
@ -31,7 +27,6 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICBasicType;
|
import org.eclipse.cdt.core.dom.ast.c.ICBasicType;
|
||||||
import org.eclipse.cdt.internal.core.Util;
|
import org.eclipse.cdt.internal.core.Util;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
|
@ -215,26 +210,6 @@ class PDOMCLinkage extends PDOMLinkage {
|
||||||
return super.getNode(record);
|
return super.getNode(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMBinding resolveBinding(IASTName name) throws CoreException {
|
|
||||||
int[] constants;
|
|
||||||
IASTNode parent = name.getParent();
|
|
||||||
if (parent instanceof IASTIdExpression) { // reference
|
|
||||||
IASTNode eParent = parent.getParent();
|
|
||||||
if (eParent instanceof IASTFunctionCallExpression) {
|
|
||||||
constants = new int[] {CFUNCTION};
|
|
||||||
} else {
|
|
||||||
constants = new int[] {CVARIABLE, CENUMERATOR};
|
|
||||||
}
|
|
||||||
} else if (parent instanceof ICASTElaboratedTypeSpecifier) {
|
|
||||||
constants = new int[] {CSTRUCTURE};
|
|
||||||
} else if (parent instanceof IASTNamedTypeSpecifier){
|
|
||||||
constants= new int [] {CSTRUCTURE, CENUMERATION, CTYPEDEF};
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return FindBinding.findBinding(getIndex(), getPDOM(), name.toCharArray(), constants);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PDOMNode addType(PDOMNode parent, IType type) throws CoreException {
|
public PDOMNode addType(PDOMNode parent, IType type) throws CoreException {
|
||||||
if(type instanceof IProblemBinding)
|
if(type instanceof IProblemBinding)
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -405,19 +405,6 @@ ICPPClassScope, IPDOMMemberOwner, IIndexType, IIndexScope {
|
||||||
public IField findField(String name) throws DOMException {fail();return null;}
|
public IField findField(String name) throws DOMException {fail();return null;}
|
||||||
public IBinding[] getFriends() throws DOMException {fail();return null;}
|
public IBinding[] getFriends() throws DOMException {fail();return null;}
|
||||||
|
|
||||||
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 boolean mayHaveChildren() {
|
public boolean mayHaveChildren() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -520,14 +520,6 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMBinding resolveBinding(IASTName name) throws CoreException {
|
|
||||||
IBinding binding= name.resolveBinding();
|
|
||||||
if (binding != null) {
|
|
||||||
return adaptBinding(binding);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PDOMNode addType(PDOMNode parent, IType type) throws CoreException {
|
public PDOMNode addType(PDOMNode parent, IType type) throws CoreException {
|
||||||
if (type instanceof IProblemBinding) {
|
if (type instanceof IProblemBinding) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue