mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
bug 49990 - ASTUtil.getExpressionString( IASTExpression )
- created ASTUnaryIdExpression classes - improved handling of POSTFIX_TYPENAME_TEMPLATEID expressions - modified handling of initializer clause for new expressions - expression toString() functions use ASTUtil
This commit is contained in:
parent
af881d96fc
commit
5a66875392
28 changed files with 1037 additions and 126 deletions
|
@ -58,7 +58,7 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite= new TestSuite(StructuralCModelElementsTests.class.getName());
|
TestSuite suite= new TestSuite(StructuralCModelElementsTests.class.getName());
|
||||||
suite.addTest(new StructuralCModelElementsTests("testCModelElements"));
|
suite.addTest(new StructuralCModelElementsTests("testCModelElements")); //$NON-NLS-1$
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,16 +68,16 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
fCProject= CProjectHelper.createCCProject("TestProject1", "bin");
|
fCProject= CProjectHelper.createCCProject("TestProject1", "bin"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
headerFile = fCProject.getProject().getFile("CModelElementsTest.h");
|
headerFile = fCProject.getProject().getFile("CModelElementsTest.h"); //$NON-NLS-1$
|
||||||
includedFile = fCProject.getProject().getFile("included.h");
|
includedFile = fCProject.getProject().getFile("included.h"); //$NON-NLS-1$
|
||||||
if (!headerFile.exists()) {
|
if (!headerFile.exists()) {
|
||||||
try{
|
try{
|
||||||
FileInputStream fileIn = new FileInputStream(
|
FileInputStream fileIn = new FileInputStream(
|
||||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/CModelElementsTestStart.h")));
|
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/CModelElementsTestStart.h"))); //$NON-NLS-1$
|
||||||
headerFile.create(fileIn,false, monitor);
|
headerFile.create(fileIn,false, monitor);
|
||||||
FileInputStream includedFileIn = new FileInputStream(
|
FileInputStream includedFileIn = new FileInputStream(
|
||||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/included.h")));
|
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/included.h"))); //$NON-NLS-1$
|
||||||
includedFile.create(includedFileIn,false, monitor);
|
includedFile.create(includedFileIn,false, monitor);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -110,7 +110,7 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
// tu ---> namespace: MyPackage
|
// tu ---> namespace: MyPackage
|
||||||
List tuPackages = tu.getChildrenOfType(ICElement.C_NAMESPACE);
|
List tuPackages = tu.getChildrenOfType(ICElement.C_NAMESPACE);
|
||||||
INamespace namespace = (INamespace) tuPackages.get(0);
|
INamespace namespace = (INamespace) tuPackages.get(0);
|
||||||
assertEquals(namespace.getElementName(), new String("MyPackage"));
|
assertEquals(namespace.getElementName(), new String("MyPackage")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)namespace);
|
checkElementOffset((CElement)namespace);
|
||||||
checkLineNumbers((CElement)namespace, 8, 130);
|
checkLineNumbers((CElement)namespace, 8, 130);
|
||||||
checkClass(namespace);
|
checkClass(namespace);
|
||||||
|
@ -137,7 +137,7 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
private void checkInclude(IParent tu) throws CModelException{
|
private void checkInclude(IParent tu) throws CModelException{
|
||||||
List tuIncludes = tu.getChildrenOfType(ICElement.C_INCLUDE);
|
List tuIncludes = tu.getChildrenOfType(ICElement.C_INCLUDE);
|
||||||
IInclude inc1 = (IInclude) tuIncludes.get(0);
|
IInclude inc1 = (IInclude) tuIncludes.get(0);
|
||||||
assertEquals(inc1.getElementName(), new String("included.h"));
|
assertEquals(inc1.getElementName(), new String("included.h")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)inc1);
|
checkElementOffset((CElement)inc1);
|
||||||
checkLineNumbers((CElement)inc1, 2, 2);
|
checkLineNumbers((CElement)inc1, 2, 2);
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
private void checkMacro(IParent tu) throws CModelException{
|
private void checkMacro(IParent tu) throws CModelException{
|
||||||
List tuMacros = tu.getChildrenOfType(ICElement.C_MACRO);
|
List tuMacros = tu.getChildrenOfType(ICElement.C_MACRO);
|
||||||
IMacro mac1 = (IMacro) tuMacros.get(0);
|
IMacro mac1 = (IMacro) tuMacros.get(0);
|
||||||
assertEquals(mac1.getElementName(), new String("PRINT"));
|
assertEquals(mac1.getElementName(), new String("PRINT")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)mac1);
|
checkElementOffset((CElement)mac1);
|
||||||
checkLineNumbers((CElement)mac1, 5, 5);
|
checkLineNumbers((CElement)mac1, 5, 5);
|
||||||
}
|
}
|
||||||
|
@ -154,35 +154,35 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
// MyPackage ---> class: Hello
|
// MyPackage ---> class: Hello
|
||||||
List nsClasses = namespace.getChildrenOfType(ICElement.C_CLASS);
|
List nsClasses = namespace.getChildrenOfType(ICElement.C_CLASS);
|
||||||
IStructure classHello = (IStructure) nsClasses.get(0);
|
IStructure classHello = (IStructure) nsClasses.get(0);
|
||||||
assertEquals(classHello.getElementName(), new String("Hello"));
|
assertEquals(classHello.getElementName(), new String("Hello")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)classHello);
|
checkElementOffset((CElement)classHello);
|
||||||
checkLineNumbers((CElement)classHello, 12, 53);
|
checkLineNumbers((CElement)classHello, 12, 53);
|
||||||
|
|
||||||
// Hello --> field: int x
|
// Hello --> field: int x
|
||||||
List helloFields = classHello.getChildrenOfType(ICElement.C_FIELD);
|
List helloFields = classHello.getChildrenOfType(ICElement.C_FIELD);
|
||||||
IField intX = (IField) helloFields.get(0);
|
IField intX = (IField) helloFields.get(0);
|
||||||
assertEquals(intX.getElementName(), new String("x"));
|
assertEquals(intX.getElementName(), new String("x")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)intX);
|
checkElementOffset((CElement)intX);
|
||||||
assertEquals(intX.getTypeName(), new String("int"));
|
assertEquals(intX.getTypeName(), new String("int")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)intX, 17, 17);
|
checkLineNumbers((CElement)intX, 17, 17);
|
||||||
|
|
||||||
ASTAccessVisibility xVisibility = intX.getVisibility();
|
ASTAccessVisibility xVisibility = intX.getVisibility();
|
||||||
if (xVisibility != ASTAccessVisibility.PROTECTED)
|
if (xVisibility != ASTAccessVisibility.PROTECTED)
|
||||||
fail("visibility should be protected!");
|
fail("visibility should be protected!"); //$NON-NLS-1$
|
||||||
|
|
||||||
// Hello ---> method: void setX(int X)
|
// Hello ---> method: void setX(int X)
|
||||||
List helloMethods = classHello.getChildrenOfType(ICElement.C_METHOD);
|
List helloMethods = classHello.getChildrenOfType(ICElement.C_METHOD);
|
||||||
IMethod setX = (IMethod) helloMethods.get(0);
|
IMethod setX = (IMethod) helloMethods.get(0);
|
||||||
assertEquals(setX.getElementName(), new String("setX"));
|
assertEquals(setX.getElementName(), new String("setX")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)setX);
|
checkElementOffset((CElement)setX);
|
||||||
assertEquals(setX.getReturnType(), new String("void"));
|
assertEquals(setX.getReturnType(), new String("void")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)setX, 19, 22);
|
checkLineNumbers((CElement)setX, 19, 22);
|
||||||
int setXNumOfParam = setX.getNumberOfParameters();
|
int setXNumOfParam = setX.getNumberOfParameters();
|
||||||
if(setXNumOfParam != 1)
|
if(setXNumOfParam != 1)
|
||||||
fail("setX should have one parameter!");
|
fail("setX should have one parameter!"); //$NON-NLS-1$
|
||||||
String[] setXParamTypes = setX.getParameterTypes();
|
String[] setXParamTypes = setX.getParameterTypes();
|
||||||
String firstParamType = setXParamTypes[0];
|
String firstParamType = setXParamTypes[0];
|
||||||
assertEquals(firstParamType, new String("int"));
|
assertEquals(firstParamType, new String("int")); //$NON-NLS-1$
|
||||||
// TODO : check for the inline here
|
// TODO : check for the inline here
|
||||||
|
|
||||||
checkNestedNamespace(classHello);
|
checkNestedNamespace(classHello);
|
||||||
|
@ -191,7 +191,7 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
// Hello ---> namespace: MyNestedPackage
|
// Hello ---> namespace: MyNestedPackage
|
||||||
List helloNamespaces = classHello.getChildrenOfType(ICElement.C_NAMESPACE);
|
List helloNamespaces = classHello.getChildrenOfType(ICElement.C_NAMESPACE);
|
||||||
INamespace myNestedPackage = (INamespace) helloNamespaces.get(0);
|
INamespace myNestedPackage = (INamespace) helloNamespaces.get(0);
|
||||||
assertEquals(myNestedPackage.getElementName(), new String("MyNestedPackage"));
|
assertEquals(myNestedPackage.getElementName(), new String("MyNestedPackage")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)myNestedPackage);
|
checkElementOffset((CElement)myNestedPackage);
|
||||||
checkLineNumbers((CElement)myNestedPackage, 25, 52);
|
checkLineNumbers((CElement)myNestedPackage, 25, 52);
|
||||||
|
|
||||||
|
@ -202,21 +202,21 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
// MyNestedPackage ---> class: Y
|
// MyNestedPackage ---> class: Y
|
||||||
List nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
|
List nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
|
||||||
IStructure classY = (IStructure) nestedClasses.get(0);
|
IStructure classY = (IStructure) nestedClasses.get(0);
|
||||||
assertEquals(classY.getElementName(), new String("Y"));
|
assertEquals(classY.getElementName(), new String("Y")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)classY);
|
checkElementOffset((CElement)classY);
|
||||||
checkLineNumbers((CElement)classY, 28, 35);
|
checkLineNumbers((CElement)classY, 28, 35);
|
||||||
|
|
||||||
// Y ---> constructor: Y
|
// Y ---> constructor: Y
|
||||||
List yMethods = classY.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
|
List yMethods = classY.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
|
||||||
IMethodDeclaration constructor = (IMethodDeclaration) yMethods.get(0);
|
IMethodDeclaration constructor = (IMethodDeclaration) yMethods.get(0);
|
||||||
assertEquals(constructor.getElementName(), new String("Y"));
|
assertEquals(constructor.getElementName(), new String("Y")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)constructor);
|
checkElementOffset((CElement)constructor);
|
||||||
assertTrue (constructor.isConstructor());
|
assertTrue (constructor.isConstructor());
|
||||||
checkLineNumbers((CElement)constructor, 32, 32);
|
checkLineNumbers((CElement)constructor, 32, 32);
|
||||||
|
|
||||||
// Y ---> destructor: ~Y
|
// Y ---> destructor: ~Y
|
||||||
IMethodDeclaration destructor = (IMethodDeclaration) yMethods.get(1);
|
IMethodDeclaration destructor = (IMethodDeclaration) yMethods.get(1);
|
||||||
assertEquals(destructor.getElementName(), new String("~Y"));
|
assertEquals(destructor.getElementName(), new String("~Y")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)destructor);
|
checkElementOffset((CElement)destructor);
|
||||||
assertTrue (destructor.isDestructor());
|
assertTrue (destructor.isDestructor());
|
||||||
checkLineNumbers((CElement)destructor, 34, 34);
|
checkLineNumbers((CElement)destructor, 34, 34);
|
||||||
|
@ -228,7 +228,7 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
// MyNestedPackage ---> class: X public Y
|
// MyNestedPackage ---> class: X public Y
|
||||||
List nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
|
List nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
|
||||||
IStructure classX = (IStructure) nestedClasses.get(1);
|
IStructure classX = (IStructure) nestedClasses.get(1);
|
||||||
assertEquals(classX.getElementName(), new String("X"));
|
assertEquals(classX.getElementName(), new String("X")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)classX);
|
checkElementOffset((CElement)classX);
|
||||||
checkLineNumbers((CElement)classX, 38, 51);
|
checkLineNumbers((CElement)classX, 38, 51);
|
||||||
// TODO : Check for base classes here
|
// TODO : Check for base classes here
|
||||||
|
@ -236,18 +236,18 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
// X --> field: B b
|
// X --> field: B b
|
||||||
List xFieldChildren = classX.getChildrenOfType(ICElement.C_FIELD);
|
List xFieldChildren = classX.getChildrenOfType(ICElement.C_FIELD);
|
||||||
IField bB = (IField) xFieldChildren.get(0);
|
IField bB = (IField) xFieldChildren.get(0);
|
||||||
assertEquals(bB.getElementName(), new String("b"));
|
assertEquals(bB.getElementName(), new String("b")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)bB);
|
checkElementOffset((CElement)bB);
|
||||||
assertEquals(bB.getTypeName(), new String("B"));
|
assertEquals(bB.getTypeName(), new String("B")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)bB, 42, 42);
|
checkLineNumbers((CElement)bB, 42, 42);
|
||||||
ASTAccessVisibility bVisibility = bB.getVisibility();
|
ASTAccessVisibility bVisibility = bB.getVisibility();
|
||||||
if (bVisibility != ASTAccessVisibility.PRIVATE)
|
if (bVisibility != ASTAccessVisibility.PRIVATE)
|
||||||
fail("visibility should be private!");
|
fail("visibility should be private!"); //$NON-NLS-1$
|
||||||
|
|
||||||
// X ---> constructor chain: X
|
// X ---> constructor chain: X
|
||||||
List xMethodChildren = classX.getChildrenOfType(ICElement.C_METHOD);
|
List xMethodChildren = classX.getChildrenOfType(ICElement.C_METHOD);
|
||||||
IMethod xconstructor = (IMethod) xMethodChildren.get(0);
|
IMethod xconstructor = (IMethod) xMethodChildren.get(0);
|
||||||
assertEquals(xconstructor.getElementName(), new String("X"));
|
assertEquals(xconstructor.getElementName(), new String("X")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)xconstructor);
|
checkElementOffset((CElement)xconstructor);
|
||||||
assertTrue (xconstructor.isConstructor());
|
assertTrue (xconstructor.isConstructor());
|
||||||
checkLineNumbers((CElement)xconstructor, 46, 48);
|
checkLineNumbers((CElement)xconstructor, 46, 48);
|
||||||
|
@ -255,9 +255,9 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
// X ---> method declaration: doNothing
|
// X ---> method declaration: doNothing
|
||||||
List xMethodDeclarations = classX.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
|
List xMethodDeclarations = classX.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
|
||||||
IMethodDeclaration xDoNothing = (IMethodDeclaration) xMethodDeclarations.get(0);
|
IMethodDeclaration xDoNothing = (IMethodDeclaration) xMethodDeclarations.get(0);
|
||||||
assertEquals(xDoNothing.getElementName(), new String("doNothing"));
|
assertEquals(xDoNothing.getElementName(), new String("doNothing")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)xDoNothing);
|
checkElementOffset((CElement)xDoNothing);
|
||||||
assertEquals(xDoNothing.getReturnType(), new String("int"));
|
assertEquals(xDoNothing.getReturnType(), new String("int")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)xDoNothing, 50, 50);
|
checkLineNumbers((CElement)xDoNothing, 50, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,44 +265,44 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
// MyPackage ---> enum: Noname
|
// MyPackage ---> enum: Noname
|
||||||
List nsEnums = namespace.getChildrenOfType(ICElement.C_ENUMERATION);
|
List nsEnums = namespace.getChildrenOfType(ICElement.C_ENUMERATION);
|
||||||
IEnumeration enum = (IEnumeration) nsEnums.get(0);
|
IEnumeration enum = (IEnumeration) nsEnums.get(0);
|
||||||
assertEquals(enum.getElementName(), new String(""));
|
assertEquals(enum.getElementName(), new String("")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)enum);
|
checkElementOffset((CElement)enum);
|
||||||
checkLineNumbers((CElement)enum, 57, 61);
|
checkLineNumbers((CElement)enum, 57, 61);
|
||||||
|
|
||||||
// enum ---> enumerator: first = 1
|
// enum ---> enumerator: first = 1
|
||||||
List enumEnumerators = enum.getChildrenOfType(ICElement.C_ENUMERATOR);
|
List enumEnumerators = enum.getChildrenOfType(ICElement.C_ENUMERATOR);
|
||||||
IEnumerator first = (IEnumerator) enumEnumerators.get(0);
|
IEnumerator first = (IEnumerator) enumEnumerators.get(0);
|
||||||
assertEquals(first.getElementName(), new String("first"));
|
assertEquals(first.getElementName(), new String("first")); //$NON-NLS-1$
|
||||||
assertEquals("1", first.getConstantExpression());
|
assertEquals("1", first.getConstantExpression()); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)first);
|
checkElementOffset((CElement)first);
|
||||||
// enum ---> enumerator: second
|
// enum ---> enumerator: second
|
||||||
IEnumerator second = (IEnumerator) enumEnumerators.get(1);
|
IEnumerator second = (IEnumerator) enumEnumerators.get(1);
|
||||||
assertEquals(second.getElementName(), new String("second"));
|
assertEquals(second.getElementName(), new String("second")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)second);
|
checkElementOffset((CElement)second);
|
||||||
// enum ---> enumerator: third
|
// enum ---> enumerator: third
|
||||||
IEnumerator third = (IEnumerator) enumEnumerators.get(2);
|
IEnumerator third = (IEnumerator) enumEnumerators.get(2);
|
||||||
checkElementOffset((CElement)third);
|
checkElementOffset((CElement)third);
|
||||||
assertEquals(third.getElementName(), new String("third"));
|
assertEquals(third.getElementName(), new String("third")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)third);
|
checkElementOffset((CElement)third);
|
||||||
|
|
||||||
// MyPackage ---> enum: MyEnum
|
// MyPackage ---> enum: MyEnum
|
||||||
IEnumeration myEnum = (IEnumeration) nsEnums.get(1);
|
IEnumeration myEnum = (IEnumeration) nsEnums.get(1);
|
||||||
assertEquals(myEnum.getElementName(), new String("MyEnum"));
|
assertEquals(myEnum.getElementName(), new String("MyEnum")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)myEnum);
|
checkElementOffset((CElement)myEnum);
|
||||||
checkLineNumbers((CElement)myEnum, 64, 67);
|
checkLineNumbers((CElement)myEnum, 64, 67);
|
||||||
|
|
||||||
// enum ---> enumerator: first
|
// enum ---> enumerator: first
|
||||||
List myEnumEnumerators = myEnum.getChildrenOfType(ICElement.C_ENUMERATOR);
|
List myEnumEnumerators = myEnum.getChildrenOfType(ICElement.C_ENUMERATOR);
|
||||||
IEnumerator f = (IEnumerator) myEnumEnumerators.get(0);
|
IEnumerator f = (IEnumerator) myEnumEnumerators.get(0);
|
||||||
assertEquals(f.getElementName(), new String("f"));
|
assertEquals(f.getElementName(), new String("f")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)f);
|
checkElementOffset((CElement)f);
|
||||||
// enum ---> enumerator: second
|
// enum ---> enumerator: second
|
||||||
IEnumerator s = (IEnumerator) myEnumEnumerators.get(1);
|
IEnumerator s = (IEnumerator) myEnumEnumerators.get(1);
|
||||||
assertEquals(s.getElementName(), new String("s"));
|
assertEquals(s.getElementName(), new String("s")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)s);
|
checkElementOffset((CElement)s);
|
||||||
// enum ---> enumerator: third
|
// enum ---> enumerator: third
|
||||||
IEnumerator t = (IEnumerator) myEnumEnumerators.get(2);
|
IEnumerator t = (IEnumerator) myEnumEnumerators.get(2);
|
||||||
assertEquals(t.getElementName(), new String("t"));
|
assertEquals(t.getElementName(), new String("t")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)t);
|
checkElementOffset((CElement)t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,30 +310,30 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
// MyPackage ---> int v
|
// MyPackage ---> int v
|
||||||
List nsVars = namespace.getChildrenOfType(ICElement.C_VARIABLE);
|
List nsVars = namespace.getChildrenOfType(ICElement.C_VARIABLE);
|
||||||
IVariable var1 = (IVariable) nsVars.get(0);
|
IVariable var1 = (IVariable) nsVars.get(0);
|
||||||
assertEquals(var1.getElementName(), new String("v"));
|
assertEquals(var1.getElementName(), new String("v")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)var1);
|
checkElementOffset((CElement)var1);
|
||||||
assertEquals(var1.getTypeName(), new String("int"));
|
assertEquals(var1.getTypeName(), new String("int")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)var1, 71, 71);
|
checkLineNumbers((CElement)var1, 71, 71);
|
||||||
|
|
||||||
// MyPackage ---> unsigned long vuLong
|
// MyPackage ---> unsigned long vuLong
|
||||||
IVariable var2 = (IVariable) nsVars.get(1);
|
IVariable var2 = (IVariable) nsVars.get(1);
|
||||||
assertEquals(var2.getElementName(), new String("vuLong"));
|
assertEquals(var2.getElementName(), new String("vuLong")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)var2);
|
checkElementOffset((CElement)var2);
|
||||||
assertEquals(var2.getTypeName(), new String("unsigned long"));
|
assertEquals(var2.getTypeName(), new String("unsigned long")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)var2, 73, 73);
|
checkLineNumbers((CElement)var2, 73, 73);
|
||||||
|
|
||||||
// MyPackage ---> unsigned short vuShort
|
// MyPackage ---> unsigned short vuShort
|
||||||
IVariable var3 = (IVariable) nsVars.get(2);
|
IVariable var3 = (IVariable) nsVars.get(2);
|
||||||
assertEquals(var3.getElementName(), new String("vuShort"));
|
assertEquals(var3.getElementName(), new String("vuShort")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)var3);
|
checkElementOffset((CElement)var3);
|
||||||
assertEquals(var3.getTypeName(), new String("unsigned short"));
|
assertEquals(var3.getTypeName(), new String("unsigned short")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)var3, 75, 75);
|
checkLineNumbers((CElement)var3, 75, 75);
|
||||||
|
|
||||||
// MyPackage ---> function pointer: orig_malloc_hook
|
// MyPackage ---> function pointer: orig_malloc_hook
|
||||||
IVariable vDecl2 = (IVariable) nsVars.get(3);
|
IVariable vDecl2 = (IVariable) nsVars.get(3);
|
||||||
assertEquals(vDecl2.getElementName(), new String("orig_malloc_hook"));
|
assertEquals(vDecl2.getElementName(), new String("orig_malloc_hook")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)vDecl2);
|
checkElementOffset((CElement)vDecl2);
|
||||||
assertEquals(vDecl2.getTypeName(), new String ("void*(*)(const char*, int, int)"));
|
assertEquals(vDecl2.getTypeName(), new String ("void*(*)(const char*, int, int)")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)vDecl2, 81, 81);
|
checkLineNumbers((CElement)vDecl2, 81, 81);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -342,9 +342,9 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
// MyPackage ---> extern int evar
|
// MyPackage ---> extern int evar
|
||||||
List nsVarDecls = namespace.getChildrenOfType(ICElement.C_VARIABLE_DECLARATION);
|
List nsVarDecls = namespace.getChildrenOfType(ICElement.C_VARIABLE_DECLARATION);
|
||||||
IVariableDeclaration vDecl1 = (IVariableDeclaration) nsVarDecls.get(0);
|
IVariableDeclaration vDecl1 = (IVariableDeclaration) nsVarDecls.get(0);
|
||||||
assertEquals(vDecl1.getElementName(), new String("evar"));
|
assertEquals(vDecl1.getElementName(), new String("evar")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)vDecl1);
|
checkElementOffset((CElement)vDecl1);
|
||||||
assertEquals(vDecl1.getTypeName(), new String("int"));
|
assertEquals(vDecl1.getTypeName(), new String("int")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)vDecl1, 79, 79);
|
checkLineNumbers((CElement)vDecl1, 79, 79);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,30 +353,30 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
|
|
||||||
// MyPackage ---> function: void foo()
|
// MyPackage ---> function: void foo()
|
||||||
IFunctionDeclaration f1 = (IFunctionDeclaration) nsFunctionDeclarations.get(0);
|
IFunctionDeclaration f1 = (IFunctionDeclaration) nsFunctionDeclarations.get(0);
|
||||||
assertEquals(f1.getElementName(), new String("foo"));
|
assertEquals(f1.getElementName(), new String("foo")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)f1);
|
checkElementOffset((CElement)f1);
|
||||||
assertEquals(f1.getReturnType(), new String("void"));
|
assertEquals(f1.getReturnType(), new String("void")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)f1, 85, 85);
|
checkLineNumbers((CElement)f1, 85, 85);
|
||||||
|
|
||||||
// MyPackage ---> function: char* foo(int&, char**)
|
// MyPackage ---> function: char* foo(int&, char**)
|
||||||
IFunctionDeclaration f2 = (IFunctionDeclaration) nsFunctionDeclarations.get(1);
|
IFunctionDeclaration f2 = (IFunctionDeclaration) nsFunctionDeclarations.get(1);
|
||||||
assertEquals(f2.getElementName(), new String("foo"));
|
assertEquals(f2.getElementName(), new String("foo")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)f2);
|
checkElementOffset((CElement)f2);
|
||||||
assertEquals(f2.getReturnType(), new String("char*"));
|
assertEquals(f2.getReturnType(), new String("char*")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)f2, 87, 88);
|
checkLineNumbers((CElement)f2, 87, 88);
|
||||||
int fooNumOfParam = f2.getNumberOfParameters();
|
int fooNumOfParam = f2.getNumberOfParameters();
|
||||||
if(fooNumOfParam != 2)
|
if(fooNumOfParam != 2)
|
||||||
fail("foo should have two parameter!");
|
fail("foo should have two parameter!"); //$NON-NLS-1$
|
||||||
String[] paramTypes = f2.getParameterTypes();
|
String[] paramTypes = f2.getParameterTypes();
|
||||||
assertEquals(paramTypes[0], new String("int&"));
|
assertEquals(paramTypes[0], new String("int&")); //$NON-NLS-1$
|
||||||
assertEquals(paramTypes[1], new String("char**"));
|
assertEquals(paramTypes[1], new String("char**")); //$NON-NLS-1$
|
||||||
|
|
||||||
// MyPackage ---> function: void boo() {}
|
// MyPackage ---> function: void boo() {}
|
||||||
List nsFunctions = namespace.getChildrenOfType(ICElement.C_FUNCTION);
|
List nsFunctions = namespace.getChildrenOfType(ICElement.C_FUNCTION);
|
||||||
IFunction f3 = (IFunction) nsFunctions.get(0);
|
IFunction f3 = (IFunction) nsFunctions.get(0);
|
||||||
assertEquals(f3.getElementName(), new String("boo"));
|
assertEquals(f3.getElementName(), new String("boo")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)f3);
|
checkElementOffset((CElement)f3);
|
||||||
assertEquals(f3.getReturnType(), new String("void"));
|
assertEquals(f3.getReturnType(), new String("void")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)f3, 90, 92);
|
checkLineNumbers((CElement)f3, 90, 92);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,70 +384,70 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
// struct with name
|
// struct with name
|
||||||
List nsStructs = namespace.getChildrenOfType(ICElement.C_STRUCT);
|
List nsStructs = namespace.getChildrenOfType(ICElement.C_STRUCT);
|
||||||
IStructure struct1 = (IStructure) nsStructs.get(0);
|
IStructure struct1 = (IStructure) nsStructs.get(0);
|
||||||
assertEquals(struct1.getElementName(), new String ("MyStruct"));
|
assertEquals(struct1.getElementName(), new String ("MyStruct")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)struct1);
|
checkElementOffset((CElement)struct1);
|
||||||
checkLineNumbers((CElement)struct1, 95, 97);
|
checkLineNumbers((CElement)struct1, 95, 97);
|
||||||
List struct1Fields = struct1.getChildrenOfType(ICElement.C_FIELD);
|
List struct1Fields = struct1.getChildrenOfType(ICElement.C_FIELD);
|
||||||
IField field1 = (IField) struct1Fields.get(0);
|
IField field1 = (IField) struct1Fields.get(0);
|
||||||
assertEquals(field1.getElementName(), new String("sint"));
|
assertEquals(field1.getElementName(), new String("sint")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)field1);
|
checkElementOffset((CElement)field1);
|
||||||
assertEquals(field1.getTypeName(), new String("int"));
|
assertEquals(field1.getTypeName(), new String("int")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)field1, 96, 96);
|
checkLineNumbers((CElement)field1, 96, 96);
|
||||||
|
|
||||||
if(field1.getVisibility() != ASTAccessVisibility.PUBLIC)
|
if(field1.getVisibility() != ASTAccessVisibility.PUBLIC)
|
||||||
fail("field visibility should be public!");
|
fail("field visibility should be public!"); //$NON-NLS-1$
|
||||||
|
|
||||||
// struct no name
|
// struct no name
|
||||||
IStructure struct2 = (IStructure) nsStructs.get(1);
|
IStructure struct2 = (IStructure) nsStructs.get(1);
|
||||||
assertEquals(struct2.getElementName(), new String (""));
|
assertEquals(struct2.getElementName(), new String ("")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)struct2);
|
checkElementOffset((CElement)struct2);
|
||||||
checkLineNumbers((CElement)struct2, 101, 103);
|
checkLineNumbers((CElement)struct2, 101, 103);
|
||||||
List struct2Fields = struct2.getChildrenOfType(ICElement.C_FIELD);
|
List struct2Fields = struct2.getChildrenOfType(ICElement.C_FIELD);
|
||||||
IField field2 = (IField) struct2Fields.get(0);
|
IField field2 = (IField) struct2Fields.get(0);
|
||||||
assertEquals(field2.getElementName(), new String("ss"));
|
assertEquals(field2.getElementName(), new String("ss")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)field2);
|
checkElementOffset((CElement)field2);
|
||||||
assertEquals(field2.getTypeName(), new String("int"));
|
assertEquals(field2.getTypeName(), new String("int")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)field2, 102, 102);
|
checkLineNumbers((CElement)field2, 102, 102);
|
||||||
if(field2.getVisibility() != ASTAccessVisibility.PUBLIC)
|
if(field2.getVisibility() != ASTAccessVisibility.PUBLIC)
|
||||||
fail("field visibility should be public!");
|
fail("field visibility should be public!"); //$NON-NLS-1$
|
||||||
|
|
||||||
// typedefs
|
// typedefs
|
||||||
List nsTypeDefs = namespace.getChildrenOfType(ICElement.C_TYPEDEF);
|
List nsTypeDefs = namespace.getChildrenOfType(ICElement.C_TYPEDEF);
|
||||||
ITypeDef td1 = (ITypeDef) nsTypeDefs.get(0);
|
ITypeDef td1 = (ITypeDef) nsTypeDefs.get(0);
|
||||||
assertEquals(td1.getElementName(), new String ("myStruct"));
|
assertEquals(td1.getElementName(), new String ("myStruct")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)td1);
|
checkElementOffset((CElement)td1);
|
||||||
assertEquals(td1.getTypeName(), new String ("struct MyStruct"));
|
assertEquals(td1.getTypeName(), new String ("struct MyStruct")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)td1, 99, 99);
|
checkLineNumbers((CElement)td1, 99, 99);
|
||||||
ITypeDef td2 = (ITypeDef) nsTypeDefs.get(1);
|
ITypeDef td2 = (ITypeDef) nsTypeDefs.get(1);
|
||||||
assertEquals(td2.getElementName(), new String ("myTypedef"));
|
assertEquals(td2.getElementName(), new String ("myTypedef")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)td2);
|
checkElementOffset((CElement)td2);
|
||||||
assertEquals(td2.getTypeName(), new String (""));
|
assertEquals(td2.getTypeName(), new String ("")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)td2, 101, 103);
|
checkLineNumbers((CElement)td2, 101, 103);
|
||||||
|
|
||||||
// union
|
// union
|
||||||
List nsUnions = namespace.getChildrenOfType(ICElement.C_UNION);
|
List nsUnions = namespace.getChildrenOfType(ICElement.C_UNION);
|
||||||
IStructure u0 = (IStructure) nsUnions.get(0);
|
IStructure u0 = (IStructure) nsUnions.get(0);
|
||||||
assertEquals(u0.getElementName(), new String("U"));
|
assertEquals(u0.getElementName(), new String("U")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)u0);
|
checkElementOffset((CElement)u0);
|
||||||
checkLineNumbers((CElement)u0, 105, 107);
|
checkLineNumbers((CElement)u0, 105, 107);
|
||||||
List u0Fields = u0.getChildrenOfType(ICElement.C_FIELD);
|
List u0Fields = u0.getChildrenOfType(ICElement.C_FIELD);
|
||||||
IField field3 = (IField) u0Fields.get(0);
|
IField field3 = (IField) u0Fields.get(0);
|
||||||
assertEquals(field3.getElementName(), new String("U1"));
|
assertEquals(field3.getElementName(), new String("U1")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)field3);
|
checkElementOffset((CElement)field3);
|
||||||
assertEquals(field3.getTypeName(), new String("int"));
|
assertEquals(field3.getTypeName(), new String("int")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)field3, 106, 106);
|
checkLineNumbers((CElement)field3, 106, 106);
|
||||||
if(field3.getVisibility() != ASTAccessVisibility.PUBLIC)
|
if(field3.getVisibility() != ASTAccessVisibility.PUBLIC)
|
||||||
fail("field visibility should be public!");
|
fail("field visibility should be public!"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkTemplates(IParent namespace) throws CModelException{
|
private void checkTemplates(IParent namespace) throws CModelException{
|
||||||
// template function
|
// template function
|
||||||
List functionTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION);
|
List functionTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION);
|
||||||
FunctionTemplate ft = (FunctionTemplate)functionTemplates.get(0);
|
FunctionTemplate ft = (FunctionTemplate)functionTemplates.get(0);
|
||||||
assertEquals(ft.getElementName(), new String("aTemplatedFunction"));
|
assertEquals(ft.getElementName(), new String("aTemplatedFunction")); //$NON-NLS-1$
|
||||||
checkElementOffset(ft);
|
checkElementOffset(ft);
|
||||||
ft.getTemplateSignature();
|
ft.getTemplateSignature();
|
||||||
assertEquals(ft.getTemplateSignature(), new String("aTemplatedFunction<A, B>(B) : A"));
|
assertEquals(ft.getTemplateSignature(), new String("aTemplatedFunction<A, B>(B) : A")); //$NON-NLS-1$
|
||||||
checkLineNumbers(ft, 112, 113);
|
checkLineNumbers(ft, 112, 113);
|
||||||
|
|
||||||
// template method
|
// template method
|
||||||
|
@ -456,26 +456,26 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
checkLineNumbers((CElement)enclosingClass, 115, 120);
|
checkLineNumbers((CElement)enclosingClass, 115, 120);
|
||||||
List methodTemplates = enclosingClass.getChildrenOfType(ICElement.C_TEMPLATE_METHOD);
|
List methodTemplates = enclosingClass.getChildrenOfType(ICElement.C_TEMPLATE_METHOD);
|
||||||
MethodTemplate mt = (MethodTemplate)methodTemplates.get(0);
|
MethodTemplate mt = (MethodTemplate)methodTemplates.get(0);
|
||||||
assertEquals(mt.getElementName(), new String("aTemplatedMethod"));
|
assertEquals(mt.getElementName(), new String("aTemplatedMethod")); //$NON-NLS-1$
|
||||||
checkElementOffset(mt);
|
checkElementOffset(mt);
|
||||||
assertEquals(mt.getTemplateSignature(), new String("aTemplatedMethod<A, B>(B) : A"));
|
assertEquals(mt.getTemplateSignature(), new String("aTemplatedMethod<A, B>(B) : A")); //$NON-NLS-1$
|
||||||
checkLineNumbers(mt, 118, 119 );
|
checkLineNumbers(mt, 118, 119 );
|
||||||
assertEquals(mt.getVisibility(), ASTAccessVisibility.PUBLIC);
|
assertEquals(mt.getVisibility(), ASTAccessVisibility.PUBLIC);
|
||||||
|
|
||||||
// template class
|
// template class
|
||||||
List classTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_CLASS);
|
List classTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_CLASS);
|
||||||
StructureTemplate ct = (StructureTemplate)classTemplates.get(0);
|
StructureTemplate ct = (StructureTemplate)classTemplates.get(0);
|
||||||
assertEquals(ct.getElementName(), new String("myarray"));
|
assertEquals(ct.getElementName(), new String("myarray")); //$NON-NLS-1$
|
||||||
checkElementOffset(ct);
|
checkElementOffset(ct);
|
||||||
assertEquals(ct.getTemplateSignature(), new String("myarray<T, Tibor>"));
|
assertEquals(ct.getTemplateSignature(), new String("myarray<T, Tibor>")); //$NON-NLS-1$
|
||||||
checkLineNumbers(ct, 122, 123);
|
checkLineNumbers(ct, 122, 123);
|
||||||
|
|
||||||
// template struct
|
// template struct
|
||||||
List structTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT);
|
List structTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT);
|
||||||
StructureTemplate st = (StructureTemplate)structTemplates.get(0);
|
StructureTemplate st = (StructureTemplate)structTemplates.get(0);
|
||||||
assertEquals(st.getElementName(), new String("mystruct"));
|
assertEquals(st.getElementName(), new String("mystruct")); //$NON-NLS-1$
|
||||||
checkElementOffset(st);
|
checkElementOffset(st);
|
||||||
assertEquals(st.getTemplateSignature(), new String("mystruct<T, Tibor>"));
|
assertEquals(st.getTemplateSignature(), new String("mystruct<T, Tibor>")); //$NON-NLS-1$
|
||||||
checkLineNumbers(st, 125, 126);
|
checkLineNumbers(st, 125, 126);
|
||||||
|
|
||||||
// moved to failed tests
|
// moved to failed tests
|
||||||
|
@ -493,24 +493,24 @@ public class StructuralCModelElementsTests extends TestCase {
|
||||||
// array variable
|
// array variable
|
||||||
List variables = tu.getChildrenOfType(ICElement.C_VARIABLE);
|
List variables = tu.getChildrenOfType(ICElement.C_VARIABLE);
|
||||||
IVariable arrayVar = (IVariable) variables.get(0);
|
IVariable arrayVar = (IVariable) variables.get(0);
|
||||||
assertEquals(arrayVar.getElementName(), new String("myArray"));
|
assertEquals(arrayVar.getElementName(), new String("myArray")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)arrayVar);
|
checkElementOffset((CElement)arrayVar);
|
||||||
assertEquals(arrayVar.getTypeName(), new String("int[][]"));
|
assertEquals(arrayVar.getTypeName(), new String("int[][]")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)arrayVar, 133, 133);
|
checkLineNumbers((CElement)arrayVar, 133, 133);
|
||||||
|
|
||||||
// array parameter in function main
|
// array parameter in function main
|
||||||
List functions = tu.getChildrenOfType(ICElement.C_FUNCTION);
|
List functions = tu.getChildrenOfType(ICElement.C_FUNCTION);
|
||||||
IFunction mainFunction = (IFunction) functions.get(0);
|
IFunction mainFunction = (IFunction) functions.get(0);
|
||||||
assertEquals(mainFunction.getElementName(), new String("main"));
|
assertEquals(mainFunction.getElementName(), new String("main")); //$NON-NLS-1$
|
||||||
checkElementOffset((CElement)mainFunction);
|
checkElementOffset((CElement)mainFunction);
|
||||||
assertEquals(mainFunction.getReturnType(), new String("int"));
|
assertEquals(mainFunction.getReturnType(), new String("int")); //$NON-NLS-1$
|
||||||
checkLineNumbers((CElement)mainFunction, 134, 136);
|
checkLineNumbers((CElement)mainFunction, 134, 136);
|
||||||
int NumOfParam = mainFunction.getNumberOfParameters();
|
int NumOfParam = mainFunction.getNumberOfParameters();
|
||||||
if(NumOfParam != 2)
|
if(NumOfParam != 2)
|
||||||
fail("main should have two parameter!");
|
fail("main should have two parameter!"); //$NON-NLS-1$
|
||||||
String[] paramTypes = mainFunction.getParameterTypes();
|
String[] paramTypes = mainFunction.getParameterTypes();
|
||||||
assertEquals(paramTypes[0], new String("int"));
|
assertEquals(paramTypes[0], new String("int")); //$NON-NLS-1$
|
||||||
assertEquals(paramTypes[1], new String("char*[]"));
|
assertEquals(paramTypes[1], new String("char*[]")); //$NON-NLS-1$
|
||||||
|
|
||||||
}
|
}
|
||||||
private void checkLineNumbers(CElement element, int startLine, int endLine){
|
private void checkLineNumbers(CElement element, int startLine, int endLine){
|
||||||
|
|
|
@ -14,9 +14,12 @@ import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTField;
|
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,6 +42,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences(1, createTaskList( new Task( f2 ) ));
|
assertAllReferences(1, createTaskList( new Task( f2 ) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "f()" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind PRIMARY_INTEGER_LITERAL : int
|
// Kind PRIMARY_INTEGER_LITERAL : int
|
||||||
public void testPrimaryIntegerLiteral() throws Exception
|
public void testPrimaryIntegerLiteral() throws Exception
|
||||||
|
@ -48,6 +54,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 1, createTaskList( new Task( f1 )));
|
assertAllReferences( 1, createTaskList( new Task( f1 )));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "f(1, 2 + 3)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind PRIMARY_CHAR_LITERAL : char
|
// Kind PRIMARY_CHAR_LITERAL : char
|
||||||
public void testPrimaryCharLiteral() throws Exception
|
public void testPrimaryCharLiteral() throws Exception
|
||||||
|
@ -57,6 +66,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 1, createTaskList( new Task( f2 )));
|
assertAllReferences( 1, createTaskList( new Task( f2 )));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "f('c')" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind PRIMARY_FLOAT_LITERAL : float
|
// Kind PRIMARY_FLOAT_LITERAL : float
|
||||||
public void testPrimaryFloatLiteral() throws Exception
|
public void testPrimaryFloatLiteral() throws Exception
|
||||||
|
@ -66,6 +78,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 1, createTaskList( new Task( f2 )));
|
assertAllReferences( 1, createTaskList( new Task( f2 )));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "f(1.13)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind PRIMARY_STRING_LITERAL : char*
|
// Kind PRIMARY_STRING_LITERAL : char*
|
||||||
public void testPrimaryStringLiteral() throws Exception
|
public void testPrimaryStringLiteral() throws Exception
|
||||||
|
@ -75,6 +90,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 1, createTaskList( new Task( f2 )));
|
assertAllReferences( 1, createTaskList( new Task( f2 )));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "f(\"str\")" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind PRIMARY_BOOLEAN_LITERAL : bool
|
// Kind PRIMARY_BOOLEAN_LITERAL : bool
|
||||||
public void testPrimaryBooleanLiteral() throws Exception
|
public void testPrimaryBooleanLiteral() throws Exception
|
||||||
|
@ -84,6 +102,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 1, createTaskList( new Task( f1 )));
|
assertAllReferences( 1, createTaskList( new Task( f1 )));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "f(true)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind PRIMARY_THIS : type of inner most enclosing structure scope
|
// Kind PRIMARY_THIS : type of inner most enclosing structure scope
|
||||||
public void testPrimaryThis() throws Exception
|
public void testPrimaryThis() throws Exception
|
||||||
|
@ -98,6 +119,11 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTMethod m = (IASTMethod) i.next();
|
IASTMethod m = (IASTMethod) i.next();
|
||||||
Iterator r = callback.getReferences().iterator();
|
Iterator r = callback.getReferences().iterator();
|
||||||
assertAllReferences( 4, createTaskList( new Task( cl, 3 ), new Task( f2 )));
|
assertAllReferences( 4, createTaskList( new Task( cl, 3 ), new Task( f2 )));
|
||||||
|
|
||||||
|
Iterator body = getDeclarations( m );
|
||||||
|
IASTVariable x = (IASTVariable) body.next();
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "f(this)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind PRIMARY_BRACKETED_EXPRESSION : LHS
|
// Kind PRIMARY_BRACKETED_EXPRESSION : LHS
|
||||||
public void testPrimaryBracketedExpression() throws Exception
|
public void testPrimaryBracketedExpression() throws Exception
|
||||||
|
@ -107,6 +133,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 1, createTaskList( new Task( f1 )));
|
assertAllReferences( 1, createTaskList( new Task( f1 )));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "f(1, (2 + 3))" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind ID_EXPRESSION : type of the ID
|
// Kind ID_EXPRESSION : type of the ID
|
||||||
public void testIdExpression() throws Exception
|
public void testIdExpression() throws Exception
|
||||||
|
@ -120,6 +149,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
|
|
||||||
assertAllReferences( 3, createTaskList( new Task( cl ), new Task( f1 ),new Task( a ) ) );
|
assertAllReferences( 3, createTaskList( new Task( cl ), new Task( f1 ),new Task( a ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "f(a)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind ID_EXPRESSION ( refers to a pointer ) : pointer to type of ID
|
// Kind ID_EXPRESSION ( refers to a pointer ) : pointer to type of ID
|
||||||
public void testIdExpressionToPointer() throws Exception
|
public void testIdExpressionToPointer() throws Exception
|
||||||
|
@ -131,7 +163,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 4, createTaskList( new Task( cl, 2 ), new Task( f1 ), new Task( a ) ) );
|
assertAllReferences( 4, createTaskList( new Task( cl, 2 ), new Task( f1 ), new Task( a ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "f(pa)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind POSTFIX_SUBSCRIPT
|
// Kind POSTFIX_SUBSCRIPT
|
||||||
public void testPostfixSubscript() throws Exception
|
public void testPostfixSubscript() throws Exception
|
||||||
|
@ -142,6 +176,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 2, createTaskList( new Task( f1 ), new Task( pa ) ) );
|
assertAllReferences( 2, createTaskList( new Task( f1 ), new Task( pa ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "f(pa[1])" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPostfixSubscriptA() throws Exception
|
public void testPostfixSubscriptA() throws Exception
|
||||||
|
@ -152,6 +189,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 2, createTaskList( new Task( f1 ), new Task( pa ) ) );
|
assertAllReferences( 2, createTaskList( new Task( f1 ), new Task( pa ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "f(pa[1][2])" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPostfixSubscriptB() throws Exception
|
public void testPostfixSubscriptB() throws Exception
|
||||||
|
@ -162,6 +202,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 2, createTaskList( new Task( f1 ), new Task( pa ) ) );
|
assertAllReferences( 2, createTaskList( new Task( f1 ), new Task( pa ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "f(pa[1][2])" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPostfixSubscriptWithReferences() throws Exception
|
public void testPostfixSubscriptWithReferences() throws Exception
|
||||||
|
@ -181,9 +224,14 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
Iterator i = parse( "int foo( float b ); int bar( int a, int b ); int test( void ) { int x = bar( foo( 3.0 ), foo( 5.0 ) ) ; }").getDeclarations(); //$NON-NLS-1$
|
Iterator i = parse( "int foo( float b ); int bar( int a, int b ); int test( void ) { int x = bar( foo( 3.0 ), foo( 5.0 ) ) ; }").getDeclarations(); //$NON-NLS-1$
|
||||||
IASTFunction foo = (IASTFunction)i.next();
|
IASTFunction foo = (IASTFunction)i.next();
|
||||||
IASTFunction bar = (IASTFunction)i.next();
|
IASTFunction bar = (IASTFunction)i.next();
|
||||||
i.next();
|
IASTFunction test = (IASTFunction) i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 3, createTaskList( new Task( bar ), new Task( foo, 2 )));
|
assertAllReferences( 3, createTaskList( new Task( bar ), new Task( foo, 2 )));
|
||||||
|
|
||||||
|
i = getDeclarations( test );
|
||||||
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "bar(foo(3.0), foo(5.0))" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind POSTFIX_SIMPLETYPE_* : simple type
|
// Kind POSTFIX_SIMPLETYPE_* : simple type
|
||||||
public void testPostfixSimpletypesBug42823() throws Exception
|
public void testPostfixSimpletypesBug42823() throws Exception
|
||||||
|
@ -196,6 +244,11 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction test = (IASTFunction)i.next();
|
IASTFunction test = (IASTFunction)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 1, createTaskList( new Task( foo )));
|
assertAllReferences( 1, createTaskList( new Task( foo )));
|
||||||
|
|
||||||
|
i = getDeclarations( test );
|
||||||
|
IASTVariable someInt = (IASTVariable) i.next();
|
||||||
|
IASTExpression exp = someInt.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(int(3), short(4), double(3.0), float(4.0), char('a'), wchar_t('a'), signed(2), unsigned(3), bool(false), long(3))" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kind POSTFIX_TYPENAME_IDENTIFIER
|
// Kind POSTFIX_TYPENAME_IDENTIFIER
|
||||||
|
@ -206,9 +259,39 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 3, createTaskList( new Task( cl, 2 ), new Task( f2) ) );
|
assertAllReferences( 3, createTaskList( new Task( cl, 2 ), new Task( f2) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(typename A())" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kind POSTFIX_TYPENAME_TEMPLATEID
|
// Kind POSTFIX_TYPENAME_TEMPLATEID
|
||||||
|
public void testPostfixTypeNameTemplateId() throws Exception{
|
||||||
|
Iterator i = parse( " template<class T> class A {}; int foo( A<int> a ); \n int x = foo( typename template A< int >() );").getDeclarations(); //$NON-NLS-1$
|
||||||
|
IASTTemplateDeclaration template = (IASTTemplateDeclaration) i.next();
|
||||||
|
IASTClassSpecifier A = (IASTClassSpecifier) template.getOwnedDeclaration();
|
||||||
|
IASTFunction f = (IASTFunction) i.next();
|
||||||
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
|
assertAllReferences( 3, createTaskList( new Task( A, 2 ), new Task( f ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(typename template A<int>())" ); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testPostfixTypeNameTemplateId_2() throws Exception{
|
||||||
|
Iterator i = parse( "namespace NS{ template<class T> class A {}; } int foo( NS::A<int> a ); \n int x = foo( typename NS::template A< int >() );").getDeclarations(); //$NON-NLS-1$
|
||||||
|
IASTNamespaceDefinition NS = (IASTNamespaceDefinition) i.next();
|
||||||
|
IASTFunction f = (IASTFunction) i.next();
|
||||||
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
|
|
||||||
|
i = getDeclarations( NS );
|
||||||
|
IASTTemplateDeclaration template = (IASTTemplateDeclaration) i.next();
|
||||||
|
IASTClassSpecifier A = (IASTClassSpecifier) template.getOwnedDeclaration();
|
||||||
|
|
||||||
|
assertAllReferences( 5, createTaskList( new Task( NS, 2 ), new Task( A, 2 ), new Task( f ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(typename NS::template A<int>())" ); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
// Kind POSTFIX_DOT_IDEXPRESSION : type of member in the scope of the container
|
// Kind POSTFIX_DOT_IDEXPRESSION : type of member in the scope of the container
|
||||||
public void testPostfixDotExpression() throws Exception{
|
public void testPostfixDotExpression() throws Exception{
|
||||||
|
@ -221,6 +304,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
Iterator members = getDeclarations(cl);
|
Iterator members = getDeclarations(cl);
|
||||||
IASTField m = (IASTField)members.next();
|
IASTField m = (IASTField)members.next();
|
||||||
assertAllReferences( 4, createTaskList( new Task(cl), new Task(a), new Task(m), new Task(f2) ));
|
assertAllReferences( 4, createTaskList( new Task(cl), new Task(a), new Task(m), new Task(f2) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a.m)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind POSTFIX_ARROW_IDEXPRESSION : type of member in the scope of the container
|
// Kind POSTFIX_ARROW_IDEXPRESSION : type of member in the scope of the container
|
||||||
public void testPostfixArrowExpression() throws Exception{
|
public void testPostfixArrowExpression() throws Exception{
|
||||||
|
@ -233,6 +319,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
Iterator members = getDeclarations(cl);
|
Iterator members = getDeclarations(cl);
|
||||||
IASTField m = (IASTField)members.next();
|
IASTField m = (IASTField)members.next();
|
||||||
assertAllReferences( 4, createTaskList( new Task(cl), new Task(a), new Task(m), new Task(f2) ));
|
assertAllReferences( 4, createTaskList( new Task(cl), new Task(a), new Task(m), new Task(f2) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a->m)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind POSTFIX_DOT_TEMPL_IDEXPRESS
|
// Kind POSTFIX_DOT_TEMPL_IDEXPRESS
|
||||||
// Kind POSTFIX_ARROW_TEMPL_IDEXP
|
// Kind POSTFIX_ARROW_TEMPL_IDEXP
|
||||||
|
@ -253,6 +342,11 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
assertFalse( subDecls.hasNext() );
|
assertFalse( subDecls.hasNext() );
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task( x ), new Task( foo2)));
|
assertAllReferences( 2, createTaskList( new Task( x ), new Task( foo2)));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "5" ); //$NON-NLS-1$
|
||||||
|
exp = y.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(x++)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind POSTFIX_DECREMENT : LHS
|
// Kind POSTFIX_DECREMENT : LHS
|
||||||
public void testPostfixDecrement() throws Exception
|
public void testPostfixDecrement() throws Exception
|
||||||
|
@ -267,6 +361,11 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
assertFalse( subDecls.hasNext() );
|
assertFalse( subDecls.hasNext() );
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task( x ), new Task( foo2)));
|
assertAllReferences( 2, createTaskList( new Task( x ), new Task( foo2)));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "5" ); //$NON-NLS-1$
|
||||||
|
exp = y.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(x--)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind POSTFIX_DYNAMIC_CAST
|
// Kind POSTFIX_DYNAMIC_CAST
|
||||||
public void testPostfixDynamicCast() throws Exception{
|
public void testPostfixDynamicCast() throws Exception{
|
||||||
|
@ -279,6 +378,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 6, createTaskList( new Task( cla, 2 ), new Task( clb, 2), new Task(a), new Task(f2)));
|
assertAllReferences( 6, createTaskList( new Task( cla, 2 ), new Task( clb, 2), new Task(a), new Task(f2)));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(dynamic_cast<B*>(a))" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind POSTFIX_REINTERPRET_CAST
|
// Kind POSTFIX_REINTERPRET_CAST
|
||||||
public void testPostfixReinterpretCast() throws Exception{
|
public void testPostfixReinterpretCast() throws Exception{
|
||||||
|
@ -288,7 +390,10 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task(a), new Task(f2)));
|
assertAllReferences( 2, createTaskList( new Task(a), new Task(f2)));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(reinterpret_cast<double*>(a))" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind POSTFIX_STATIC_CAST
|
// Kind POSTFIX_STATIC_CAST
|
||||||
public void testPostfixStaticCast() throws Exception{
|
public void testPostfixStaticCast() throws Exception{
|
||||||
|
@ -299,6 +404,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task(a), new Task(f2)));
|
assertAllReferences( 2, createTaskList( new Task(a), new Task(f2)));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(static_cast<char>(a))" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind POSTFIX_CONST_CAST
|
// Kind POSTFIX_CONST_CAST
|
||||||
public void testPostfixConstCast() throws Exception{
|
public void testPostfixConstCast() throws Exception{
|
||||||
|
@ -309,6 +417,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task(a), new Task(f2)));
|
assertAllReferences( 2, createTaskList( new Task(a), new Task(f2)));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(const_cast<int*>(&a))" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind POSTFIX_TYPEID_EXPRESSION : LHS
|
// Kind POSTFIX_TYPEID_EXPRESSION : LHS
|
||||||
public void testPostfixTypeIdExpression() throws Exception{
|
public void testPostfixTypeIdExpression() throws Exception{
|
||||||
|
@ -316,7 +427,10 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f1 = (IASTFunction) i.next();
|
IASTFunction f1 = (IASTFunction) i.next();
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 1, createTaskList( new Task( f2 )));
|
assertAllReferences( 1, createTaskList( new Task( f2 )));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(typeid(5))" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind POSTFIX_TYPEID_EXPRESSION : type of the ID
|
// Kind POSTFIX_TYPEID_EXPRESSION : type of the ID
|
||||||
public void testPostfixTypeIdExpression2() throws Exception{
|
public void testPostfixTypeIdExpression2() throws Exception{
|
||||||
|
@ -327,6 +441,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 4, createTaskList( new Task(cl, 2),new Task(a),new Task(f1)));
|
assertAllReferences( 4, createTaskList( new Task(cl, 2),new Task(a),new Task(f1)));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(typeid(a))" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind POSTFIX_TYPEID_TYPEID : type of the ID
|
// Kind POSTFIX_TYPEID_TYPEID : type of the ID
|
||||||
public void testPostfixTypeIdTypeId() throws Exception{
|
public void testPostfixTypeIdTypeId() throws Exception{
|
||||||
|
@ -336,7 +453,10 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f1 = (IASTFunction) i.next();
|
IASTFunction f1 = (IASTFunction) i.next();
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 4, createTaskList( new Task(cl, 3), new Task(f1)));
|
assertAllReferences( 4, createTaskList( new Task(cl, 3), new Task(f1)));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(typeid(A))" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind POSTFIX_TYPEID_TYPEID : type of the ID
|
// Kind POSTFIX_TYPEID_TYPEID : type of the ID
|
||||||
public void testPostfixTypeIdTypeId2() throws Exception{
|
public void testPostfixTypeIdTypeId2() throws Exception{
|
||||||
|
@ -347,6 +467,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 4, createTaskList( new Task(cl, 3), new Task(f1)));
|
assertAllReferences( 4, createTaskList( new Task(cl, 3), new Task(f1)));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(typeid(const A))" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind UNARY_INCREMENT : LHS
|
// Kind UNARY_INCREMENT : LHS
|
||||||
public void testUnaryIncrement() throws Exception
|
public void testUnaryIncrement() throws Exception
|
||||||
|
@ -361,6 +484,11 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
assertFalse( subDecls.hasNext() );
|
assertFalse( subDecls.hasNext() );
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task(foo2), new Task(x) ));
|
assertAllReferences( 2, createTaskList( new Task(foo2), new Task(x) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "5" ); //$NON-NLS-1$
|
||||||
|
exp = y.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(++x)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind UNARY_DECREMENT : LHS
|
// Kind UNARY_DECREMENT : LHS
|
||||||
public void testUnaryDecrement() throws Exception
|
public void testUnaryDecrement() throws Exception
|
||||||
|
@ -375,6 +503,11 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
assertFalse( subDecls.hasNext() );
|
assertFalse( subDecls.hasNext() );
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task(foo2), new Task(x) ));
|
assertAllReferences( 2, createTaskList( new Task(foo2), new Task(x) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "5" ); //$NON-NLS-1$
|
||||||
|
exp = y.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(--x)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind UNARY_STAR_CASTEXPRESSION : LHS + t_pointer
|
// Kind UNARY_STAR_CASTEXPRESSION : LHS + t_pointer
|
||||||
public void testUnaryStarCastExpression() throws Exception
|
public void testUnaryStarCastExpression() throws Exception
|
||||||
|
@ -386,6 +519,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 4, createTaskList( new Task(cl, 2 ), new Task( a ), new Task(f1) ));
|
assertAllReferences( 4, createTaskList( new Task(cl, 2 ), new Task( a ), new Task(f1) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "f(*pa)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind UNARY_AMPSND_CASTEXPRESSION : LHS + t_reference
|
// Kind UNARY_AMPSND_CASTEXPRESSION : LHS + t_reference
|
||||||
public void testUnaryAmpersandCastExpression() throws Exception
|
public void testUnaryAmpersandCastExpression() throws Exception
|
||||||
|
@ -397,6 +533,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertAllReferences( 4, createTaskList( new Task(cl, 2 ), new Task( a ), new Task(f1) ));
|
assertAllReferences( 4, createTaskList( new Task(cl, 2 ), new Task( a ), new Task(f1) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "f(&pa)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind UNARY_PLUS_CASTEXPRESSION : LHS
|
// Kind UNARY_PLUS_CASTEXPRESSION : LHS
|
||||||
public void testUnaryPlusCastExpression() throws Exception {
|
public void testUnaryPlusCastExpression() throws Exception {
|
||||||
|
@ -406,6 +545,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 1, createTaskList( new Task( foo2 )));
|
assertAllReferences( 1, createTaskList( new Task( foo2 )));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(+5)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind UNARY_MINUS_CASTEXPRESSION : LHS
|
// Kind UNARY_MINUS_CASTEXPRESSION : LHS
|
||||||
public void testUnaryMinusCastExpression() throws Exception {
|
public void testUnaryMinusCastExpression() throws Exception {
|
||||||
|
@ -415,6 +557,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 1, createTaskList( new Task( foo2 )));
|
assertAllReferences( 1, createTaskList( new Task( foo2 )));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(-5)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind UNARY_NOT_CASTEXPRESSION : LHS
|
// Kind UNARY_NOT_CASTEXPRESSION : LHS
|
||||||
public void testUnaryNotCastExpression() throws Exception {
|
public void testUnaryNotCastExpression() throws Exception {
|
||||||
|
@ -425,6 +570,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task( b ), new Task( foo2 )));
|
assertAllReferences( 2, createTaskList( new Task( b ), new Task( foo2 )));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(!b)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind UNARY_TILDE_CASTEXPRESSION : LHS
|
// Kind UNARY_TILDE_CASTEXPRESSION : LHS
|
||||||
public void testTildeNotCastExpression() throws Exception {
|
public void testTildeNotCastExpression() throws Exception {
|
||||||
|
@ -435,6 +583,11 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable y = (IASTVariable)i.next();
|
IASTVariable y = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task( x ), new Task( foo2 )));
|
assertAllReferences( 2, createTaskList( new Task( x ), new Task( foo2 )));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "5" ); //$NON-NLS-1$
|
||||||
|
exp = y.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(~x)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind UNARY_SIZEOF_UNARYEXPRESSION : unsigned int
|
// Kind UNARY_SIZEOF_UNARYEXPRESSION : unsigned int
|
||||||
public void testUnarySizeofUnaryExpression() throws Exception {
|
public void testUnarySizeofUnaryExpression() throws Exception {
|
||||||
|
@ -445,6 +598,11 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable y = (IASTVariable)i.next();
|
IASTVariable y = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 1, createTaskList( new Task( foo2 )));
|
assertAllReferences( 1, createTaskList( new Task( foo2 )));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "5" ); //$NON-NLS-1$
|
||||||
|
exp = y.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(sizeof (5))" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind UNARY_SIZEOF_TYPEID : unsigned int
|
// Kind UNARY_SIZEOF_TYPEID : unsigned int
|
||||||
public void testUnarySizeofTypeId() throws Exception {
|
public void testUnarySizeofTypeId() throws Exception {
|
||||||
|
@ -455,6 +613,11 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable y = (IASTVariable)i.next();
|
IASTVariable y = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task( x ), new Task( foo2 )));
|
assertAllReferences( 2, createTaskList( new Task( x ), new Task( foo2 )));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "5" ); //$NON-NLS-1$
|
||||||
|
exp = y.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(sizeof (x))" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind NEW_NEWTYPEID
|
// Kind NEW_NEWTYPEID
|
||||||
// Kind NEW_TYPEID
|
// Kind NEW_TYPEID
|
||||||
|
@ -466,6 +629,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 3, createTaskList( new Task( cl, 2), new Task( foo2 )));
|
assertAllReferences( 3, createTaskList( new Task( cl, 2), new Task( foo2 )));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(new A())" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kind DELETE_CASTEXPRESSION
|
// Kind DELETE_CASTEXPRESSION
|
||||||
|
@ -481,7 +647,10 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTFunction f2 = (IASTFunction) i.next();
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
IASTVariable x = (IASTVariable) i.next();
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 6, createTaskList( new Task( cla, 3 ), new Task( clb, 1), new Task(b), new Task(f2)));
|
assertAllReferences( 6, createTaskList( new Task( cla, 3 ), new Task( clb, 1), new Task(b), new Task(f2)));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo((A*)b)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kind PM_DOTSTAR
|
// Kind PM_DOTSTAR
|
||||||
|
@ -501,6 +670,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertEquals( callback.getReferences().size(), 3 );
|
assertEquals( callback.getReferences().size(), 3 );
|
||||||
assertAllReferences( 3, createTaskList( new Task(a), new Task(b), new Task( foo2 ) ) );
|
assertAllReferences( 3, createTaskList( new Task(a), new Task(b), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a * b)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind MULTIPLICATIVE_DIVIDE : usual arithmetic conversions
|
// Kind MULTIPLICATIVE_DIVIDE : usual arithmetic conversions
|
||||||
public void testMultiplicativeDivide() throws Exception {
|
public void testMultiplicativeDivide() throws Exception {
|
||||||
|
@ -512,6 +684,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 3, createTaskList( new Task(a), new Task(b), new Task( foo2 ) ) );
|
assertAllReferences( 3, createTaskList( new Task(a), new Task(b), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(b / a)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind MULTIPLICATIVE_MODULUS : usual arithmetic conversions
|
// Kind MULTIPLICATIVE_MODULUS : usual arithmetic conversions
|
||||||
public void testMultiplicativeModulus() throws Exception {
|
public void testMultiplicativeModulus() throws Exception {
|
||||||
|
@ -523,6 +698,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 3, createTaskList( new Task(a), new Task(b), new Task( foo2 ) ) );
|
assertAllReferences( 3, createTaskList( new Task(a), new Task(b), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(b % a)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind ADDITIVE_PLUS : usual arithmetic conversions
|
// Kind ADDITIVE_PLUS : usual arithmetic conversions
|
||||||
public void testAdditivePlus() throws Exception {
|
public void testAdditivePlus() throws Exception {
|
||||||
|
@ -534,6 +712,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 3, createTaskList( new Task(a), new Task(b), new Task( foo2 ) ) );
|
assertAllReferences( 3, createTaskList( new Task(a), new Task(b), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(b + a)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind ADDITIVE_MINUS : usual arithmetic conversions
|
// Kind ADDITIVE_MINUS : usual arithmetic conversions
|
||||||
public void testAdditiveMinus() throws Exception {
|
public void testAdditiveMinus() throws Exception {
|
||||||
|
@ -545,6 +726,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 3, createTaskList( new Task(a), new Task(b), new Task( foo2 ) ) );
|
assertAllReferences( 3, createTaskList( new Task(a), new Task(b), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(b - a)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind SHIFT_LEFT : LHS
|
// Kind SHIFT_LEFT : LHS
|
||||||
public void testShiftLeft() throws Exception {
|
public void testShiftLeft() throws Exception {
|
||||||
|
@ -555,6 +739,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task(a), new Task( foo1 ) ) );
|
assertAllReferences( 2, createTaskList( new Task(a), new Task( foo1 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a << 5)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind SHIFT_RIGHT : LHS
|
// Kind SHIFT_RIGHT : LHS
|
||||||
public void testShiftRight() throws Exception {
|
public void testShiftRight() throws Exception {
|
||||||
|
@ -565,6 +752,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task(a), new Task( foo1 ) ) );
|
assertAllReferences( 2, createTaskList( new Task(a), new Task( foo1 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a >> 5)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind RELATIONAL_LESSTHAN : bool
|
// Kind RELATIONAL_LESSTHAN : bool
|
||||||
public void testRelationalLessThan() throws Exception {
|
public void testRelationalLessThan() throws Exception {
|
||||||
|
@ -575,6 +765,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
|
assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(b < 3)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind RELATIONAL_GREATERTHAN : bool
|
// Kind RELATIONAL_GREATERTHAN : bool
|
||||||
public void testRelationalGreaterThan() throws Exception {
|
public void testRelationalGreaterThan() throws Exception {
|
||||||
|
@ -585,6 +778,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
|
assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(b > 3)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind RELATIONAL_LESSTHANEQUALTO : bool
|
// Kind RELATIONAL_LESSTHANEQUALTO : bool
|
||||||
public void testRelationalLessThanOrEqual() throws Exception {
|
public void testRelationalLessThanOrEqual() throws Exception {
|
||||||
|
@ -595,6 +791,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
|
assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(b <= 3)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind RELATIONAL_GREATERTHANEQUALTO : bool
|
// Kind RELATIONAL_GREATERTHANEQUALTO : bool
|
||||||
public void testRelationalGreaterThanOrEqual() throws Exception {
|
public void testRelationalGreaterThanOrEqual() throws Exception {
|
||||||
|
@ -605,6 +804,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
|
assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(b >= 3)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind EQUALITY_EQUALS : bool
|
// Kind EQUALITY_EQUALS : bool
|
||||||
public void testEqualityEquals() throws Exception {
|
public void testEqualityEquals() throws Exception {
|
||||||
|
@ -615,6 +817,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
|
assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(b == 3)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind EQUALITY_NOTEQUALS : bool
|
// Kind EQUALITY_NOTEQUALS : bool
|
||||||
public void testEqualityNotEquals() throws Exception {
|
public void testEqualityNotEquals() throws Exception {
|
||||||
|
@ -625,6 +830,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
|
assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(b != 3)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind ANDEXPRESSION : usual arithmetic conversions
|
// Kind ANDEXPRESSION : usual arithmetic conversions
|
||||||
public void testAndExpression() throws Exception {
|
public void testAndExpression() throws Exception {
|
||||||
|
@ -636,6 +844,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 3, createTaskList( new Task( a ), new Task(b), new Task( foo2 ) ) );
|
assertAllReferences( 3, createTaskList( new Task( a ), new Task(b), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a & b)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind EXCLUSIVEOREXPRESSION : usual arithmetic conversions
|
// Kind EXCLUSIVEOREXPRESSION : usual arithmetic conversions
|
||||||
public void testExclusiveOrExpression() throws Exception {
|
public void testExclusiveOrExpression() throws Exception {
|
||||||
|
@ -647,6 +858,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 3, createTaskList( new Task( a ), new Task(b), new Task( foo2 ) ) );
|
assertAllReferences( 3, createTaskList( new Task( a ), new Task(b), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a ^ b)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind INCLUSIVEOREXPRESSION : : usual arithmetic conversions
|
// Kind INCLUSIVEOREXPRESSION : : usual arithmetic conversions
|
||||||
public void testInclusiveOrExpression() throws Exception {
|
public void testInclusiveOrExpression() throws Exception {
|
||||||
|
@ -658,6 +872,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 3, createTaskList( new Task( a ), new Task(b), new Task( foo2 ) ) );
|
assertAllReferences( 3, createTaskList( new Task( a ), new Task(b), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a | b)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind LOGICALANDEXPRESSION : bool
|
// Kind LOGICALANDEXPRESSION : bool
|
||||||
public void testLogicalAndExpression() throws Exception {
|
public void testLogicalAndExpression() throws Exception {
|
||||||
|
@ -669,6 +886,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 3, createTaskList( new Task( a ), new Task(b), new Task( foo2 ) ) );
|
assertAllReferences( 3, createTaskList( new Task( a ), new Task(b), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a && b)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind LOGICALOREXPRESSION : bool
|
// Kind LOGICALOREXPRESSION : bool
|
||||||
public void testLogicalOrExpression() throws Exception {
|
public void testLogicalOrExpression() throws Exception {
|
||||||
|
@ -679,7 +899,10 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable b = (IASTVariable)i.next();
|
IASTVariable b = (IASTVariable)i.next();
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 3, createTaskList( new Task( a ), new Task(b), new Task( foo2 ) ) );
|
assertAllReferences( 3, createTaskList( new Task( a ), new Task(b), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a || b)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind CONDITIONALEXPRESSION : conditional Expression Conversions
|
// Kind CONDITIONALEXPRESSION : conditional Expression Conversions
|
||||||
public void testConditionalExpression() throws Exception {
|
public void testConditionalExpression() throws Exception {
|
||||||
|
@ -692,6 +915,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 4, createTaskList( new Task( a ), new Task(b), new Task( c ), new Task( foo2 ) ) );
|
assertAllReferences( 4, createTaskList( new Task( a ), new Task(b), new Task( c ), new Task( foo2 ) ) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a > 5 ? b : c)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind CONDITIONALEXPRESSION with references : conditional Expression Conversions
|
// Kind CONDITIONALEXPRESSION with references : conditional Expression Conversions
|
||||||
public void testConditionalExpressionWithReferencesA() throws Exception {
|
public void testConditionalExpressionWithReferencesA() throws Exception {
|
||||||
|
@ -706,6 +932,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences(8, createTaskList( new Task( cla, 3 ), new Task( clb ), new Task( c ), new Task( b ), new Task( a ), new Task( foo2 )) );
|
assertAllReferences(8, createTaskList( new Task( cla, 3 ), new Task( clb ), new Task( c ), new Task( b ), new Task( a ), new Task( foo2 )) );
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(c > 5 ? b : a)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
public void testConditionalExpressionWithReferencesB_Bug43106() throws Exception {
|
public void testConditionalExpressionWithReferencesB_Bug43106() throws Exception {
|
||||||
Iterator i = parse( "class A{}; class B : public A{}; int foo(); int foo(A&); A a ; B b; int c = 0; int x = foo( c > 5 ? b : a );").getDeclarations(); //$NON-NLS-1$
|
Iterator i = parse( "class A{}; class B : public A{}; int foo(); int foo(A&); A a ; B b; int c = 0; int x = foo( c > 5 ? b : a );").getDeclarations(); //$NON-NLS-1$
|
||||||
|
@ -720,6 +949,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 8,
|
assertAllReferences( 8,
|
||||||
createTaskList( new Task( cla, 3 ), new Task( clb ), new Task( c), new Task( b ), new Task( a ), new Task( foo2) ));
|
createTaskList( new Task( cla, 3 ), new Task( clb ), new Task( c), new Task( b ), new Task( a ), new Task( foo2) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(c > 5 ? b : a)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind THROWEXPRESSION
|
// Kind THROWEXPRESSION
|
||||||
|
|
||||||
|
@ -732,6 +964,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a = 5)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind ASSIGNMENTEXPRESSION_PLUS : LHS
|
// Kind ASSIGNMENTEXPRESSION_PLUS : LHS
|
||||||
public void testAssignmentExpressionPlus() throws Exception {
|
public void testAssignmentExpressionPlus() throws Exception {
|
||||||
|
@ -742,6 +977,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a += 5)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind ASSIGNMENTEXPRESSION_MINUS : LHS
|
// Kind ASSIGNMENTEXPRESSION_MINUS : LHS
|
||||||
public void testAssignmentExpressionMinus() throws Exception {
|
public void testAssignmentExpressionMinus() throws Exception {
|
||||||
|
@ -752,6 +990,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a -= 5)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind ASSIGNMENTEXPRESSION_MULT : LHS
|
// Kind ASSIGNMENTEXPRESSION_MULT : LHS
|
||||||
public void testAssignmentExpressionMulti() throws Exception {
|
public void testAssignmentExpressionMulti() throws Exception {
|
||||||
|
@ -762,6 +1003,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a *= 5)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind ASSIGNMENTEXPRESSION_DIV : LHS
|
// Kind ASSIGNMENTEXPRESSION_DIV : LHS
|
||||||
public void testAssignmentExpressionDiv() throws Exception {
|
public void testAssignmentExpressionDiv() throws Exception {
|
||||||
|
@ -772,6 +1016,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a /= 5)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind ASSIGNMENTEXPRESSION_MOD : LHS
|
// Kind ASSIGNMENTEXPRESSION_MOD : LHS
|
||||||
public void testAssignmentExpressionMod() throws Exception {
|
public void testAssignmentExpressionMod() throws Exception {
|
||||||
|
@ -782,6 +1029,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a %= 5)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind ASSIGNMENTEXPRESSION_LSHIFT : LHS
|
// Kind ASSIGNMENTEXPRESSION_LSHIFT : LHS
|
||||||
public void testAssignmentExpressionLShift() throws Exception {
|
public void testAssignmentExpressionLShift() throws Exception {
|
||||||
|
@ -792,6 +1042,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a >>= 5)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind ASSIGNMENTEXPRESSION_RSHIFT : LHS
|
// Kind ASSIGNMENTEXPRESSION_RSHIFT : LHS
|
||||||
public void testAssignmentExpressionRShift() throws Exception {
|
public void testAssignmentExpressionRShift() throws Exception {
|
||||||
|
@ -802,6 +1055,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a <<= 5)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind ASSIGNMENTEXPRESSION_AND : LHS
|
// Kind ASSIGNMENTEXPRESSION_AND : LHS
|
||||||
public void testAssignmentExpressionAnd() throws Exception {
|
public void testAssignmentExpressionAnd() throws Exception {
|
||||||
|
@ -812,6 +1068,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a &= 5)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind ASSIGNMENTEXPRESSION_OR : LHS
|
// Kind ASSIGNMENTEXPRESSION_OR : LHS
|
||||||
public void testAssignmentExpressionOr() throws Exception {
|
public void testAssignmentExpressionOr() throws Exception {
|
||||||
|
@ -822,6 +1081,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a |= 5)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind ASSIGNMENTEXPRESSION_XOR : LHS
|
// Kind ASSIGNMENTEXPRESSION_XOR : LHS
|
||||||
public void testAssignmentExpressionXOr() throws Exception {
|
public void testAssignmentExpressionXOr() throws Exception {
|
||||||
|
@ -832,6 +1094,9 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
|
||||||
IASTVariable x = (IASTVariable)i.next();
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
|
||||||
|
|
||||||
|
IASTExpression exp = x.getInitializerClause().getAssigmentExpression();
|
||||||
|
assertEquals( exp.toString(), "foo(a ^= 5)" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Kind EXPRESSIONLIST : list of LHS, RHS
|
// Kind EXPRESSIONLIST : list of LHS, RHS
|
||||||
// Already tested with each test trying to find a reference to function.
|
// Already tested with each test trying to find a reference to function.
|
||||||
|
|
|
@ -302,7 +302,7 @@ public class CModelBuilder {
|
||||||
private void generateModelElements (Parent parent, IASTTemplateDeclaration templateDeclaration) throws CModelException, ASTNotImplementedException
|
private void generateModelElements (Parent parent, IASTTemplateDeclaration templateDeclaration) throws CModelException, ASTNotImplementedException
|
||||||
{
|
{
|
||||||
// Template Declaration
|
// Template Declaration
|
||||||
IASTDeclaration declaration = (IASTDeclaration)templateDeclaration.getOwnedDeclaration();
|
IASTDeclaration declaration = templateDeclaration.getOwnedDeclaration();
|
||||||
if(declaration instanceof IASTAbstractTypeSpecifierDeclaration){
|
if(declaration instanceof IASTAbstractTypeSpecifierDeclaration){
|
||||||
IASTAbstractTypeSpecifierDeclaration abstractDeclaration = (IASTAbstractTypeSpecifierDeclaration)declaration ;
|
IASTAbstractTypeSpecifierDeclaration abstractDeclaration = (IASTAbstractTypeSpecifierDeclaration)declaration ;
|
||||||
CElement element = createAbstractElement(parent, abstractDeclaration , true);
|
CElement element = createAbstractElement(parent, abstractDeclaration , true);
|
||||||
|
@ -478,10 +478,7 @@ public class CModelBuilder {
|
||||||
Enumerator element = new Enumerator (enum, enumDef.getName().toString());
|
Enumerator element = new Enumerator (enum, enumDef.getName().toString());
|
||||||
IASTExpression initialValue = enumDef.getInitialValue();
|
IASTExpression initialValue = enumDef.getInitialValue();
|
||||||
if(initialValue != null){
|
if(initialValue != null){
|
||||||
if(initialValue.getLiteralString().length() > 0)
|
element.setConstantExpression( ASTUtil.getExpressionString( initialValue ) );
|
||||||
element.setConstantExpression(initialValue.getLiteralString());
|
|
||||||
else
|
|
||||||
element.setConstantExpression(initialValue.getIdExpression());
|
|
||||||
}
|
}
|
||||||
// add to parent
|
// add to parent
|
||||||
enum.addChild(element);
|
enum.addChild(element);
|
||||||
|
|
|
@ -11,8 +11,14 @@
|
||||||
package org.eclipse.cdt.core.parser.ast;
|
package org.eclipse.cdt.core.parser.ast;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,12 +100,10 @@ public class ASTUtil {
|
||||||
if(clause != null){
|
if(clause != null){
|
||||||
IASTExpression expression = clause.getAssigmentExpression();
|
IASTExpression expression = clause.getAssigmentExpression();
|
||||||
if(expression != null){
|
if(expression != null){
|
||||||
String literal = (expression.getLiteralString().length() > 0
|
String init = getExpressionString( expression );
|
||||||
? expression.getLiteralString()
|
if(init.length() > 0){
|
||||||
: expression.getIdExpression() );
|
|
||||||
if(literal.length() > 0){
|
|
||||||
initializer.append("="); //$NON-NLS-1$
|
initializer.append("="); //$NON-NLS-1$
|
||||||
initializer.append(literal);
|
initializer.append(init);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,4 +239,431 @@ public class ASTUtil {
|
||||||
return parameters.toString();
|
return parameters.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getTypeId( IASTTypeId id ){
|
||||||
|
StringBuffer type = new StringBuffer();
|
||||||
|
|
||||||
|
if( id.isTypename() ){
|
||||||
|
type.append( Keywords.TYPENAME );
|
||||||
|
type.append( ' ' );
|
||||||
|
}
|
||||||
|
type.append( id.getFullSignature() );
|
||||||
|
|
||||||
|
Iterator i = id.getPointerOperators();
|
||||||
|
while(i.hasNext()){
|
||||||
|
ASTPointerOperator po = (ASTPointerOperator) i.next();
|
||||||
|
type.append(getPointerOperator(po));
|
||||||
|
}
|
||||||
|
|
||||||
|
i = id.getArrayModifiers();
|
||||||
|
while (i.hasNext()){
|
||||||
|
i.next();
|
||||||
|
type.append("[]"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
return type.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||||
|
public static String getExpressionString( IASTExpression expression ){
|
||||||
|
String literal = expression.getLiteralString();
|
||||||
|
String idExpression = expression.getIdExpression();
|
||||||
|
|
||||||
|
IASTExpression lhs = expression.getLHSExpression();
|
||||||
|
IASTExpression rhs = expression.getRHSExpression();
|
||||||
|
IASTExpression third = expression.getThirdExpression();
|
||||||
|
IASTNewExpressionDescriptor descriptor = expression.getNewExpressionDescriptor();
|
||||||
|
IASTTypeId typeId = expression.getTypeId();
|
||||||
|
|
||||||
|
if( literal != null && !literal.equals( EMPTY_STRING ) && ( idExpression == null || idExpression.equals( EMPTY_STRING ) ) )
|
||||||
|
return getLiteralExpression( expression );
|
||||||
|
|
||||||
|
if( idExpression != null && !idExpression.equals( EMPTY_STRING ) && lhs == null )
|
||||||
|
return getIdExpression( expression );
|
||||||
|
|
||||||
|
if( third != null )
|
||||||
|
return getConditionalExpression( expression );
|
||||||
|
|
||||||
|
if( descriptor != null )
|
||||||
|
return getNewExpression( expression );
|
||||||
|
|
||||||
|
if( lhs != null && rhs != null )
|
||||||
|
return getBinaryExpression( expression );
|
||||||
|
|
||||||
|
if( lhs != null && typeId != null )
|
||||||
|
return getUnaryTypeIdExpression( expression );
|
||||||
|
|
||||||
|
if( lhs != null && ( idExpression != null && !idExpression.equals( EMPTY_STRING ) ) )
|
||||||
|
return getUnaryIdExpression( expression );
|
||||||
|
|
||||||
|
if( lhs != null )
|
||||||
|
return getUnaryExpression( expression );
|
||||||
|
|
||||||
|
if( typeId != null )
|
||||||
|
return getTypeIdExpression( expression );
|
||||||
|
|
||||||
|
return getEmptyExpression( expression );
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getEmptyExpression( IASTExpression expression ){
|
||||||
|
if( expression.getExpressionKind() == Kind.PRIMARY_THIS )
|
||||||
|
return Keywords.THIS;
|
||||||
|
|
||||||
|
return EMPTY_STRING;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getLiteralExpression( IASTExpression expression ){
|
||||||
|
Kind kind = expression.getExpressionKind();
|
||||||
|
|
||||||
|
if( kind != Kind.PRIMARY_CHAR_LITERAL && kind != Kind.PRIMARY_STRING_LITERAL )
|
||||||
|
return expression.getLiteralString();
|
||||||
|
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
if( kind == Kind.PRIMARY_CHAR_LITERAL ){
|
||||||
|
buffer.append( '\'' );
|
||||||
|
buffer.append( expression.getLiteralString() );
|
||||||
|
buffer.append( '\'' );
|
||||||
|
} else if( kind == Kind.PRIMARY_STRING_LITERAL ) {
|
||||||
|
buffer.append( '"' );
|
||||||
|
buffer.append( expression.getLiteralString() );
|
||||||
|
buffer.append( '"' );
|
||||||
|
}
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getIdExpression( IASTExpression expression ){
|
||||||
|
return expression.getIdExpression();
|
||||||
|
}
|
||||||
|
private static String getConditionalExpression( IASTExpression expression ){
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
|
buffer.append( getExpressionString( expression.getLHSExpression() ) );
|
||||||
|
buffer.append( " ? " ); //$NON-NLS-1$
|
||||||
|
buffer.append( getExpressionString( expression.getRHSExpression() ) );
|
||||||
|
buffer.append( " : " ); //$NON-NLS-1$
|
||||||
|
buffer.append( getExpressionString( expression.getThirdExpression() ) );
|
||||||
|
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
private static String getNewExpression( IASTExpression expression ){
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
|
buffer.append( Keywords.NEW );
|
||||||
|
buffer.append( ' ' );
|
||||||
|
|
||||||
|
IASTNewExpressionDescriptor descriptor = expression.getNewExpressionDescriptor();
|
||||||
|
Iterator iter = descriptor.getNewPlacementExpressions();
|
||||||
|
if( iter.hasNext() ){
|
||||||
|
buffer.append( '(' );
|
||||||
|
buffer.append( getExpressionString( (IASTExpression) iter.next() ) );
|
||||||
|
buffer.append( ") " ); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
iter = descriptor.getNewTypeIdExpressions();
|
||||||
|
if( iter.hasNext() ){
|
||||||
|
buffer.append( getExpressionString( (IASTExpression) iter.next() ) );
|
||||||
|
buffer.append( ' ' );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( expression.getTypeId() != null ){
|
||||||
|
buffer.append( getTypeId( expression.getTypeId() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
iter = descriptor.getNewInitializerExpressions();
|
||||||
|
if( iter.hasNext() ){
|
||||||
|
buffer.append( '(' );
|
||||||
|
buffer.append( getExpressionString( (IASTExpression) iter.next() ) );
|
||||||
|
buffer.append( ')' );
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
private static String getBinaryExpression( IASTExpression expression ){
|
||||||
|
Kind kind = expression.getExpressionKind();
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append( getExpressionString( expression.getLHSExpression() ) );
|
||||||
|
|
||||||
|
boolean appendSpace = false;
|
||||||
|
if( kind != Kind.EXPRESSIONLIST &&
|
||||||
|
kind != Kind.PM_DOTSTAR &&
|
||||||
|
kind != Kind.PM_ARROWSTAR &&
|
||||||
|
kind != Kind.POSTFIX_SUBSCRIPT &&
|
||||||
|
kind != Kind.POSTFIX_FUNCTIONCALL &&
|
||||||
|
kind != Kind.POSTFIX_DOT_TEMPL_IDEXPRESS &&
|
||||||
|
kind != Kind.POSTFIX_DOT_IDEXPRESSION &&
|
||||||
|
kind != Kind.POSTFIX_DOT_DESTRUCTOR &&
|
||||||
|
kind != Kind.POSTFIX_ARROW_TEMPL_IDEXP &&
|
||||||
|
kind != Kind.POSTFIX_ARROW_IDEXPRESSION &&
|
||||||
|
kind != Kind.POSTFIX_ARROW_DESTRUCTOR)
|
||||||
|
{
|
||||||
|
appendSpace = true;
|
||||||
|
buffer.append( ' ' );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( kind == Kind.ANDEXPRESSION ||
|
||||||
|
kind == Kind.EXPRESSIONLIST ||
|
||||||
|
kind == Kind.EXCLUSIVEOREXPRESSION ||
|
||||||
|
kind == Kind.PM_DOTSTAR ||
|
||||||
|
kind == Kind.PM_ARROWSTAR ||
|
||||||
|
kind == Kind.LOGICALANDEXPRESSION ||
|
||||||
|
kind == Kind.LOGICALOREXPRESSION ||
|
||||||
|
kind == Kind.RELATIONAL_GREATERTHAN ||
|
||||||
|
kind == Kind.RELATIONAL_LESSTHAN ||
|
||||||
|
kind == Kind.RELATIONAL_LESSTHANEQUALTO ||
|
||||||
|
kind == Kind.RELATIONAL_GREATERTHANEQUALTO ||
|
||||||
|
kind == Kind.EQUALITY_EQUALS ||
|
||||||
|
kind == Kind.EQUALITY_NOTEQUALS ||
|
||||||
|
kind == Kind.ADDITIVE_PLUS ||
|
||||||
|
kind == Kind.ADDITIVE_MINUS ||
|
||||||
|
kind == Kind.INCLUSIVEOREXPRESSION ||
|
||||||
|
kind == Kind.MULTIPLICATIVE_MULTIPLY ||
|
||||||
|
kind == Kind.MULTIPLICATIVE_DIVIDE ||
|
||||||
|
kind == Kind.MULTIPLICATIVE_MODULUS ||
|
||||||
|
kind == Kind.POSTFIX_DOT_TEMPL_IDEXPRESS ||
|
||||||
|
kind == Kind.POSTFIX_DOT_IDEXPRESSION ||
|
||||||
|
kind == Kind.POSTFIX_DOT_DESTRUCTOR ||
|
||||||
|
kind == Kind.POSTFIX_ARROW_TEMPL_IDEXP ||
|
||||||
|
kind == Kind.POSTFIX_ARROW_IDEXPRESSION ||
|
||||||
|
kind == Kind.POSTFIX_ARROW_DESTRUCTOR ||
|
||||||
|
kind == Kind.ASSIGNMENTEXPRESSION_NORMAL ||
|
||||||
|
kind == Kind.ASSIGNMENTEXPRESSION_MULT ||
|
||||||
|
kind == Kind.ASSIGNMENTEXPRESSION_DIV ||
|
||||||
|
kind == Kind.ASSIGNMENTEXPRESSION_MOD ||
|
||||||
|
kind == Kind.ASSIGNMENTEXPRESSION_PLUS ||
|
||||||
|
kind == Kind.ASSIGNMENTEXPRESSION_MINUS ||
|
||||||
|
kind == Kind.ASSIGNMENTEXPRESSION_RSHIFT ||
|
||||||
|
kind == Kind.ASSIGNMENTEXPRESSION_LSHIFT ||
|
||||||
|
kind == Kind.ASSIGNMENTEXPRESSION_AND ||
|
||||||
|
kind == Kind.ASSIGNMENTEXPRESSION_XOR ||
|
||||||
|
kind == Kind.ASSIGNMENTEXPRESSION_OR ||
|
||||||
|
kind == Kind.SHIFT_LEFT ||
|
||||||
|
kind == Kind.SHIFT_RIGHT)
|
||||||
|
{
|
||||||
|
buffer.append( ASTUtil.getStringForKind( kind ) );
|
||||||
|
} else if( kind == Kind.POSTFIX_SUBSCRIPT )
|
||||||
|
buffer.append( '[' );
|
||||||
|
else if( kind == Kind.POSTFIX_FUNCTIONCALL )
|
||||||
|
buffer.append( '(' );
|
||||||
|
|
||||||
|
if( kind == Kind.POSTFIX_DOT_TEMPL_IDEXPRESS ||
|
||||||
|
kind == IASTExpression.Kind.POSTFIX_ARROW_TEMPL_IDEXP)
|
||||||
|
{
|
||||||
|
buffer.append( ' ' );
|
||||||
|
buffer.append( Keywords.TEMPLATE );
|
||||||
|
buffer.append( ' ' );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( appendSpace || kind == Kind.EXPRESSIONLIST )
|
||||||
|
buffer.append( ' ' );
|
||||||
|
|
||||||
|
buffer.append( getExpressionString( expression.getRHSExpression() ) );
|
||||||
|
|
||||||
|
if( kind == Kind.POSTFIX_SUBSCRIPT )
|
||||||
|
buffer.append( ']' );
|
||||||
|
else if( kind == Kind.POSTFIX_FUNCTIONCALL )
|
||||||
|
buffer.append( ')' );
|
||||||
|
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getUnaryTypeIdExpression( IASTExpression expression ){
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
|
Kind kind = expression.getExpressionKind();
|
||||||
|
if( kind == Kind.CASTEXPRESSION ){
|
||||||
|
buffer.append( '(' );
|
||||||
|
buffer.append( getTypeId( expression.getTypeId() ) );
|
||||||
|
buffer.append( ')' );
|
||||||
|
buffer.append( getExpressionString( expression.getLHSExpression() ) );
|
||||||
|
|
||||||
|
} else if ( kind == Kind.POSTFIX_DYNAMIC_CAST ||
|
||||||
|
kind == Kind.POSTFIX_STATIC_CAST ||
|
||||||
|
kind == Kind.POSTFIX_REINTERPRET_CAST ||
|
||||||
|
kind == Kind.POSTFIX_CONST_CAST )
|
||||||
|
{
|
||||||
|
buffer.append( ASTUtil.getStringForKind( kind ) );
|
||||||
|
buffer.append( '<' );
|
||||||
|
buffer.append( getTypeId( expression.getTypeId() ) );
|
||||||
|
buffer.append( ">(" ); //$NON-NLS-1$
|
||||||
|
buffer.append( getExpressionString( expression.getLHSExpression() ) );
|
||||||
|
buffer.append( ')' );
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getUnaryIdExpression( IASTExpression expression ){
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
|
buffer.append( Keywords.TYPENAME );
|
||||||
|
buffer.append( ' ' );
|
||||||
|
if( expression.getExpressionKind() == Kind.POSTFIX_TYPENAME_TEMPLATEID ){
|
||||||
|
buffer.append( Keywords.TEMPLATE );
|
||||||
|
buffer.append( ' ' );
|
||||||
|
}
|
||||||
|
buffer.append( expression.getIdExpression() );
|
||||||
|
buffer.append( '(' );
|
||||||
|
buffer.append( getExpressionString( expression.getLHSExpression() ) );
|
||||||
|
buffer.append( ')' );
|
||||||
|
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
private static String getUnaryExpression( IASTExpression expression ){
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
Kind kind = expression.getExpressionKind();
|
||||||
|
|
||||||
|
boolean bracketsAroundExpression = ( kind == Kind.PRIMARY_BRACKETED_EXPRESSION );
|
||||||
|
|
||||||
|
if ( kind == Kind.UNARY_SIZEOF_UNARYEXPRESSION ){
|
||||||
|
buffer.append( Keywords.SIZEOF );
|
||||||
|
buffer.append( ' ' );
|
||||||
|
}
|
||||||
|
else if ( kind == Kind.UNARY_STAR_CASTEXPRESSION ||
|
||||||
|
kind == Kind.UNARY_AMPSND_CASTEXPRESSION ||
|
||||||
|
kind == Kind.UNARY_PLUS_CASTEXPRESSION ||
|
||||||
|
kind == Kind.UNARY_MINUS_CASTEXPRESSION ||
|
||||||
|
kind == Kind.UNARY_NOT_CASTEXPRESSION ||
|
||||||
|
kind == Kind.UNARY_TILDE_CASTEXPRESSION ||
|
||||||
|
kind == Kind.UNARY_DECREMENT ||
|
||||||
|
kind == Kind.THROWEXPRESSION
|
||||||
|
)
|
||||||
|
{
|
||||||
|
buffer.append( ASTUtil.getStringForKind( kind ) );
|
||||||
|
}
|
||||||
|
else if ( kind == Kind.UNARY_INCREMENT )
|
||||||
|
buffer.append( "++" ); //$NON-NLS-1$
|
||||||
|
else if( kind == Kind.DELETE_VECTORCASTEXPRESSION || kind == Kind.DELETE_CASTEXPRESSION ){
|
||||||
|
buffer.append( Keywords.DELETE );
|
||||||
|
buffer.append(' ');
|
||||||
|
if( kind == Kind.DELETE_VECTORCASTEXPRESSION )
|
||||||
|
buffer.append( "[ ] " ); //$NON-NLS-1$
|
||||||
|
} else if( kind == Kind.POSTFIX_SIMPLETYPE_CHAR ||
|
||||||
|
kind == Kind.POSTFIX_SIMPLETYPE_WCHART ||
|
||||||
|
kind == Kind.POSTFIX_SIMPLETYPE_BOOL ||
|
||||||
|
kind == Kind.POSTFIX_SIMPLETYPE_SHORT ||
|
||||||
|
kind == Kind.POSTFIX_SIMPLETYPE_INT ||
|
||||||
|
kind == Kind.POSTFIX_SIMPLETYPE_LONG ||
|
||||||
|
kind == Kind.POSTFIX_SIMPLETYPE_SIGNED ||
|
||||||
|
kind == Kind.POSTFIX_SIMPLETYPE_UNSIGNED ||
|
||||||
|
kind == Kind.POSTFIX_SIMPLETYPE_FLOAT ||
|
||||||
|
kind == Kind.POSTFIX_SIMPLETYPE_DOUBLE
|
||||||
|
)
|
||||||
|
{
|
||||||
|
buffer.append( ASTUtil.getStringForKind( kind ) );
|
||||||
|
bracketsAroundExpression = true;
|
||||||
|
} else if( kind == Kind.POSTFIX_TYPEID_EXPRESSION )
|
||||||
|
{
|
||||||
|
buffer.append( Keywords.TYPEID );
|
||||||
|
bracketsAroundExpression = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( bracketsAroundExpression )
|
||||||
|
buffer.append( '(' );
|
||||||
|
|
||||||
|
buffer.append( getExpressionString( expression.getLHSExpression() ) );
|
||||||
|
|
||||||
|
if( bracketsAroundExpression )
|
||||||
|
buffer.append( ')' );
|
||||||
|
|
||||||
|
if( kind == Kind.POSTFIX_INCREMENT ||
|
||||||
|
kind == Kind.POSTFIX_DECREMENT )
|
||||||
|
{
|
||||||
|
buffer.append( ASTUtil.getStringForKind( kind ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
private static String getTypeIdExpression( IASTExpression expression ){
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
|
Kind kind = expression.getExpressionKind();
|
||||||
|
|
||||||
|
boolean addBrackets = false;
|
||||||
|
if( kind == Kind.UNARY_SIZEOF_TYPEID ){
|
||||||
|
buffer.append( Keywords.SIZEOF );
|
||||||
|
buffer.append( ' ' );
|
||||||
|
addBrackets = true;
|
||||||
|
} else if( kind == Kind.POSTFIX_TYPEID_TYPEID ){
|
||||||
|
buffer.append( Keywords.TYPEID );
|
||||||
|
addBrackets = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( addBrackets )
|
||||||
|
buffer.append( '(' );
|
||||||
|
buffer.append( ASTUtil.getTypeId( expression.getTypeId() ) );
|
||||||
|
if( addBrackets )
|
||||||
|
buffer.append( ')' );
|
||||||
|
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Map expressionKindStringMap = new HashMap();
|
||||||
|
static {
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_DYNAMIC_CAST, Keywords.DYNAMIC_CAST );
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_STATIC_CAST, Keywords.STATIC_CAST );
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_REINTERPRET_CAST, Keywords.REINTERPRET_CAST );
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_CONST_CAST, Keywords.CONST_CAST );
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_SIMPLETYPE_CHAR, Keywords.CHAR );
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_SIMPLETYPE_WCHART, Keywords.WCHAR_T );
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_SIMPLETYPE_BOOL, Keywords.BOOL );
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_SIMPLETYPE_SHORT, Keywords.SHORT );
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_SIMPLETYPE_INT, Keywords.INT );
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_SIMPLETYPE_LONG, Keywords.LONG );
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_SIMPLETYPE_SIGNED, Keywords.SIGNED );
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_SIMPLETYPE_UNSIGNED, Keywords.UNSIGNED );
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_SIMPLETYPE_FLOAT, Keywords.FLOAT );
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_SIMPLETYPE_DOUBLE, Keywords.DOUBLE );
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.THROWEXPRESSION, Keywords.THROW );
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.ANDEXPRESSION, "&" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.UNARY_AMPSND_CASTEXPRESSION, "&" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.EXPRESSIONLIST, "," ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.EXCLUSIVEOREXPRESSION, "^" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.PM_DOTSTAR, ".*" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.PM_ARROWSTAR, "->*" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.LOGICALANDEXPRESSION, "&&" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.LOGICALOREXPRESSION, "||" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.RELATIONAL_GREATERTHAN, ">" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.RELATIONAL_LESSTHAN, "<" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.RELATIONAL_LESSTHANEQUALTO, "<=" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.RELATIONAL_GREATERTHANEQUALTO, ">=" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.EQUALITY_EQUALS, "==" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.EQUALITY_NOTEQUALS, "!=" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.UNARY_STAR_CASTEXPRESSION, "*" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.MULTIPLICATIVE_MULTIPLY, "*" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.UNARY_PLUS_CASTEXPRESSION, "+" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.ADDITIVE_PLUS, "+" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.UNARY_MINUS_CASTEXPRESSION, "-" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.ADDITIVE_MINUS, "-" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.UNARY_NOT_CASTEXPRESSION, "!" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.UNARY_TILDE_CASTEXPRESSION, "~" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.UNARY_DECREMENT, "--" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_DECREMENT, "--" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.UNARY_INCREMENT, "++" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_INCREMENT, "++" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.INCLUSIVEOREXPRESSION, "|" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.MULTIPLICATIVE_DIVIDE, "/" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.MULTIPLICATIVE_MODULUS, "%" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS, "." ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION, "." ); //$NON-NLS-1$ |
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_DOT_DESTRUCTOR, "." ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_ARROW_TEMPL_IDEXP, "->" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_ARROW_DESTRUCTOR, "->" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.POSTFIX_ARROW_IDEXPRESSION, "->" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.ASSIGNMENTEXPRESSION_NORMAL, "=" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.ASSIGNMENTEXPRESSION_MULT, "*=" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.ASSIGNMENTEXPRESSION_DIV, "/=" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.ASSIGNMENTEXPRESSION_MOD, "%=" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.ASSIGNMENTEXPRESSION_PLUS, "+=" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.ASSIGNMENTEXPRESSION_MINUS, "-=" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.ASSIGNMENTEXPRESSION_RSHIFT, ">>=" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.ASSIGNMENTEXPRESSION_LSHIFT, "<<=" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.ASSIGNMENTEXPRESSION_AND, "&=" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.ASSIGNMENTEXPRESSION_XOR, "^=" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.ASSIGNMENTEXPRESSION_OR, "|=" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.SHIFT_LEFT, "<<" ); //$NON-NLS-1$
|
||||||
|
expressionKindStringMap.put( IASTExpression.Kind.SHIFT_RIGHT, ">>" ); //$NON-NLS-1$
|
||||||
|
|
||||||
|
}
|
||||||
|
private static String getStringForKind( IASTExpression.Kind kind ){
|
||||||
|
return (String) expressionKindStringMap.get( kind );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1966,8 +1966,9 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
setCompletionValues( scope, CompletionKind.CONSTRUCTOR_REFERENCE );
|
setCompletionValues( scope, CompletionKind.CONSTRUCTOR_REFERENCE );
|
||||||
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLPAREN ) ); }
|
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLPAREN ) ); }
|
||||||
|
|
||||||
if ( queryLookaheadCapability() && (LT(1) != IToken.tRPAREN))
|
//we want to know the difference between no newInitializer and an empty new Initializer
|
||||||
newInitializerExpressions.add(expression(scope, CompletionKind.CONSTRUCTOR_REFERENCE, key));
|
//if the next token is the RPAREN, then we have an Empty expression in our list.
|
||||||
|
newInitializerExpressions.add(expression(scope, CompletionKind.CONSTRUCTOR_REFERENCE, key));
|
||||||
|
|
||||||
setCurrentFunctionName( EMPTY_STRING );
|
setCurrentFunctionName( EMPTY_STRING );
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
|
@ -2139,26 +2140,15 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
{
|
{
|
||||||
case IToken.t_typename :
|
case IToken.t_typename :
|
||||||
consume(IToken.t_typename);
|
consume(IToken.t_typename);
|
||||||
ITokenDuple nestedName = name(scope, CompletionKind.TYPE_REFERENCE, KeywordSetKey.EMPTY);
|
|
||||||
boolean templateTokenConsumed = false;
|
boolean templateTokenConsumed = false;
|
||||||
if( LT(1) == IToken.t_template )
|
if( LT(1) == IToken.t_template )
|
||||||
{
|
{
|
||||||
consume( IToken.t_template );
|
consume( IToken.t_template );
|
||||||
templateTokenConsumed = true;
|
templateTokenConsumed = true;
|
||||||
}
|
}
|
||||||
IToken current = mark();
|
ITokenDuple nestedName = name(scope, CompletionKind.TYPE_REFERENCE, KeywordSetKey.EMPTY);
|
||||||
ITokenDuple templateId = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
templateId = TokenFactory.createTokenDuple( current, templateId(scope, CompletionKind.SINGLE_NAME_REFERENCE ) );
|
|
||||||
}
|
|
||||||
catch( BacktrackException bt )
|
|
||||||
{
|
|
||||||
if( templateTokenConsumed )
|
|
||||||
throw bt;
|
|
||||||
backup( current );
|
|
||||||
}
|
|
||||||
current = null;
|
|
||||||
consume( IToken.tLPAREN );
|
consume( IToken.tLPAREN );
|
||||||
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLPAREN ) ); }
|
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLPAREN ) ); }
|
||||||
IASTExpression expressionList = expression( scope, CompletionKind.TYPE_REFERENCE, key );
|
IASTExpression expressionList = expression( scope, CompletionKind.TYPE_REFERENCE, key );
|
||||||
|
@ -2167,7 +2157,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
try {
|
try {
|
||||||
firstExpression =
|
firstExpression =
|
||||||
astFactory.createExpression( scope,
|
astFactory.createExpression( scope,
|
||||||
(( templateId != null )? IASTExpression.Kind.POSTFIX_TYPENAME_TEMPLATEID : IASTExpression.Kind.POSTFIX_TYPENAME_IDENTIFIER ),
|
( templateTokenConsumed ? IASTExpression.Kind.POSTFIX_TYPENAME_TEMPLATEID : IASTExpression.Kind.POSTFIX_TYPENAME_IDENTIFIER ),
|
||||||
expressionList,
|
expressionList,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
||||||
|
|
||||||
|
@ -88,4 +89,8 @@ public class ASTBinaryExpression extends ASTUnaryExpression {
|
||||||
super.freeReferences(manager);
|
super.freeReferences(manager);
|
||||||
rhs.freeReferences(manager);
|
rhs.freeReferences(manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
||||||
|
|
||||||
|
@ -92,4 +93,7 @@ public class ASTConditionalExpression extends ASTBinaryExpression {
|
||||||
super.freeReferences(manager);
|
super.freeReferences(manager);
|
||||||
thirdExpression.freeReferences(manager);
|
thirdExpression.freeReferences(manager);
|
||||||
}
|
}
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,4 +33,8 @@ public class ASTEmptyExpression extends ASTExpression {
|
||||||
*/
|
*/
|
||||||
public void freeReferences(IReferenceManager manager) {
|
public void freeReferences(IReferenceManager manager) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -44,6 +45,7 @@ public class ASTIdExpression extends ASTExpression {
|
||||||
return idExpression;
|
return idExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
*
|
||||||
|
@ -35,4 +37,8 @@ public class ASTLiteralExpression extends ASTExpression {
|
||||||
public String getLiteralString() {
|
public String getLiteralString() {
|
||||||
return literal;
|
return literal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
||||||
|
@ -80,4 +81,8 @@ public class ASTNewExpression extends ASTExpression {
|
||||||
super.freeReferences(manager);
|
super.freeReferences(manager);
|
||||||
typeId.freeReferences( manager );
|
typeId.freeReferences( manager );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
||||||
|
|
||||||
|
@ -51,4 +52,8 @@ public class ASTTypeIdExpression extends ASTExpression {
|
||||||
super.freeReferences(manager);
|
super.freeReferences(manager);
|
||||||
typeId.freeReferences(manager);
|
typeId.freeReferences(manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
||||||
|
|
||||||
|
@ -84,4 +85,8 @@ public class ASTUnaryExpression extends ASTExpression {
|
||||||
super.freeReferences(manager);
|
super.freeReferences(manager);
|
||||||
lhs.freeReferences(manager);
|
lhs.freeReferences(manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM - Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
/*
|
||||||
|
* Created on Jun 7, 2004
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author aniefer
|
||||||
|
*/
|
||||||
|
public class ASTUnaryIdExpression extends ASTIdExpression {
|
||||||
|
private final IASTExpression lhs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param kind
|
||||||
|
* @param references
|
||||||
|
* @param idExpression
|
||||||
|
*/
|
||||||
|
public ASTUnaryIdExpression(Kind kind, List references, IASTExpression lhs, ITokenDuple idExpression) {
|
||||||
|
super(kind, references, idExpression);
|
||||||
|
this.lhs = lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTExpression getLHSExpression(){
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.ast.complete.ASTExpression#findOwnerExpressionForIDExpression(org.eclipse.cdt.core.parser.ITokenDuple)
|
||||||
|
*/
|
||||||
|
public ASTExpression findOwnerExpressionForIDExpression(ITokenDuple duple) {
|
||||||
|
if( isIDExpressionForDuple( lhs, duple ) )
|
||||||
|
return this;
|
||||||
|
ASTExpression result = recursiveFindExpressionForDuple(lhs, duple);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#reconcileReferences()
|
||||||
|
*/
|
||||||
|
public void reconcileReferences(IReferenceManager manager) throws ASTNotImplementedException {
|
||||||
|
lhs.reconcileReferences(manager);
|
||||||
|
reconcileSubExpression((ASTExpression) lhs, manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#purgeReferences()
|
||||||
|
*/
|
||||||
|
public void purgeReferences() throws ASTNotImplementedException {
|
||||||
|
lhs.purgeReferences();
|
||||||
|
purgeSubExpression( (ASTExpression) lhs );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.ast.complete.ASTExpression#processCallbacks()
|
||||||
|
*/
|
||||||
|
protected void processCallbacks( ISourceElementRequestor requestor, IReferenceManager manager ) {
|
||||||
|
super.processCallbacks(requestor, manager);
|
||||||
|
lhs.acceptElement( requestor, manager );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#freeReferences(org.eclipse.cdt.core.parser.ast.IReferenceManager)
|
||||||
|
*/
|
||||||
|
public void freeReferences(IReferenceManager manager) {
|
||||||
|
super.freeReferences(manager);
|
||||||
|
lhs.freeReferences(manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
||||||
|
@ -57,4 +58,7 @@ public class ASTUnaryTypeIdExpression extends ASTUnaryExpression {
|
||||||
typeId.acceptElement( requestor, manager );
|
typeId.acceptElement( requestor, manager );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,7 +373,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
if( t.getType() == IToken.tCOLONCOLON ){
|
if( t.getType() == IToken.tCOLONCOLON ){
|
||||||
idx++;
|
idx++;
|
||||||
continue;
|
continue;
|
||||||
}
|
} else if( t.getType() == IToken.t_template ){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if( t.isPointer() ) break;
|
if( t.isPointer() ) break;
|
||||||
|
|
||||||
image = t.getImage();
|
image = t.getImage();
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class ExpressionFactory {
|
||||||
if( !literal.equals( "") && idExpression == null ) //$NON-NLS-1$
|
if( !literal.equals( "") && idExpression == null ) //$NON-NLS-1$
|
||||||
return new ASTLiteralExpression( kind, references, literal );
|
return new ASTLiteralExpression( kind, references, literal );
|
||||||
|
|
||||||
if( idExpression != null )
|
if( idExpression != null && lhs == null )
|
||||||
return new ASTIdExpression( kind, references, idExpression );
|
return new ASTIdExpression( kind, references, idExpression );
|
||||||
|
|
||||||
if( thirdExpression != null )
|
if( thirdExpression != null )
|
||||||
|
@ -44,6 +44,9 @@ public class ExpressionFactory {
|
||||||
if( lhs != null && typeId != null )
|
if( lhs != null && typeId != null )
|
||||||
return new ASTUnaryTypeIdExpression( kind, references, lhs, typeId );
|
return new ASTUnaryTypeIdExpression( kind, references, lhs, typeId );
|
||||||
|
|
||||||
|
if( lhs != null && idExpression != null )
|
||||||
|
return new ASTUnaryIdExpression( kind, references, lhs, idExpression );
|
||||||
|
|
||||||
if( lhs != null )
|
if( lhs != null )
|
||||||
return new ASTUnaryExpression( kind, references, lhs );
|
return new ASTUnaryExpression( kind, references, lhs );
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,4 +38,8 @@ public class ASTBinaryExpression extends ASTUnaryExpression
|
||||||
public IASTExpression getRHSExpression() {
|
public IASTExpression getRHSExpression() {
|
||||||
return rhs;
|
return rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,4 +39,8 @@ public class ASTConditionalExpression extends ASTBinaryExpression
|
||||||
public IASTExpression getThirdExpression() {
|
public IASTExpression getThirdExpression() {
|
||||||
return thirdExpression;
|
return thirdExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,4 +26,8 @@ public class ASTEmptyExpression extends ASTExpression implements IASTExpression
|
||||||
super(kind);
|
super(kind);
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,4 +38,8 @@ public class ASTIdExpression extends ASTExpression implements IASTExpression {
|
||||||
public String getIdExpression() {
|
public String getIdExpression() {
|
||||||
return idExpression;
|
return idExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -33,4 +35,8 @@ public class ASTLiteralExpression extends ASTExpression {
|
||||||
public String getLiteralString() {
|
public String getLiteralString() {
|
||||||
return literal;
|
return literal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
|
|
||||||
|
@ -44,4 +45,8 @@ public class ASTNewExpression extends ASTExpression implements IASTExpression {
|
||||||
public IASTTypeId getTypeId() {
|
public IASTTypeId getTypeId() {
|
||||||
return typeId;
|
return typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
|
|
||||||
|
@ -39,4 +40,8 @@ public class ASTTypeIdExpression extends ASTExpression
|
||||||
public IASTTypeId getTypeId() {
|
public IASTTypeId getTypeId() {
|
||||||
return typeId;
|
return typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,4 +35,8 @@ public class ASTUnaryExpression extends ASTExpression implements IASTExpression
|
||||||
public IASTExpression getLHSExpression() {
|
public IASTExpression getLHSExpression() {
|
||||||
return lhs;
|
return lhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM - Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
/*
|
||||||
|
* Created on Jun 7, 2004
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author aniefer
|
||||||
|
*/
|
||||||
|
public class ASTUnaryIdExpression extends ASTIdExpression {
|
||||||
|
private final IASTExpression lhs;
|
||||||
|
/**
|
||||||
|
* @param kind
|
||||||
|
* @param idExpression
|
||||||
|
*/
|
||||||
|
public ASTUnaryIdExpression(Kind kind, IASTExpression lhs, String idExpression) {
|
||||||
|
super(kind, idExpression);
|
||||||
|
this.lhs = lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTExpression getLHSExpression(){
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
|
|
||||||
|
@ -40,4 +41,8 @@ public class ASTUnaryTypeIdExpression extends ASTUnaryExpression
|
||||||
public IASTTypeId getTypeId() {
|
public IASTTypeId getTypeId() {
|
||||||
return typeId;
|
return typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ASTUtil.getExpressionString( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class ExpressionFactory {
|
||||||
if( !literal.equals( EMPTY_STRING ) && idExpression.equals( EMPTY_STRING )) //$NON-NLS-1$
|
if( !literal.equals( EMPTY_STRING ) && idExpression.equals( EMPTY_STRING )) //$NON-NLS-1$
|
||||||
return new ASTLiteralExpression( kind, literal );
|
return new ASTLiteralExpression( kind, literal );
|
||||||
|
|
||||||
if( !idExpression.equals( EMPTY_STRING ) )
|
if( !idExpression.equals( EMPTY_STRING ) && lhs == null )
|
||||||
return new ASTIdExpression( kind, idExpression );
|
return new ASTIdExpression( kind, idExpression );
|
||||||
|
|
||||||
if( thirdExpression != null )
|
if( thirdExpression != null )
|
||||||
|
@ -58,6 +58,9 @@ public class ExpressionFactory {
|
||||||
if( lhs != null && typeId != null )
|
if( lhs != null && typeId != null )
|
||||||
return new ASTUnaryTypeIdExpression( kind, lhs, typeId );
|
return new ASTUnaryTypeIdExpression( kind, lhs, typeId );
|
||||||
|
|
||||||
|
if( lhs != null && !idExpression.equals( EMPTY_STRING ) )
|
||||||
|
return new ASTUnaryIdExpression( kind, lhs, idExpression );
|
||||||
|
|
||||||
if( lhs != null )
|
if( lhs != null )
|
||||||
return new ASTUnaryExpression( kind, lhs );
|
return new ASTUnaryExpression( kind, lhs );
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue