[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Applied [HEAD] IASTTypeId work completion
|
CORE
Fixed Bug 43084 : need to restructure TypeId to allow
dynamic_cast<> type expression references.
Fixed Bug 39504 : sizeof-expressions are not handled properly
TESTS
Replaced ASTFailedTests::testBug39504A() with
CompleteParseASTTest::testBug39504().
Moved testPostfixTypeIdExpression2() && testPostfixTypeIdTypeId2()
to CompleteParseASTExpressionTest.
Restructured expression reference tests so that the order of
arrival will not cause JUnit failures.
JohnC
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.107
diff -u -r1.107 ChangeLog
--- ChangeLog 23 Sep 2003 20:46:12 -0000 1.107
+++ ChangeLog 23 Sep 2003 22:50:28 -0000
@@ -1,3 +1,8 @@
+2003-09-23 John Camelon
+ Replaced ASTFailedTests::testBug39504A() with CompleteParseASTTest::testBug39504().
+ Moved testPostfixTypeIdExpression2() && testPostfixTypeIdTypeId2() to CompleteParseASTExpressionTest.
+ Restructured expression reference tests so that the order of arrival will not cause JUnit failures.
+
2003-09-23 Hoda Amer
Added CompleteParseASTTest.testBug43373()
Added QuickParseASTTests.testBug43371()
Index: failures/org/eclipse/cdt/core/parser/failedTests/ASTFailedTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/parser/failedTests/ASTFailedTests.java,v
retrieving revision 1.14
diff -u -r1.14 ASTFailedTests.java
--- failures/org/eclipse/cdt/core/parser/failedTests/ASTFailedTests.java 15 Sep 2003 22:50:59 -0000 1.14
+++ failures/org/eclipse/cdt/core/parser/failedTests/ASTFailedTests.java 23 Sep 2003 22:50:28 -0000
@@ -37,10 +37,7 @@
{
assertCodeFailsParse("FUNCTION_MACRO( 1, a )\n int i;");
}
- public void testBug39504A() throws Exception
- {
- assertCodeFailsParse("int y = sizeof(x[0]);");
- }
+
public void testBug39525() throws Exception
{
Index: failures/org/eclipse/cdt/core/parser/failedTests/FailedCompleteParseASTExpressionTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/parser/failedTests/FailedCompleteParseASTExpressionTest.java,v
retrieving revision 1.5
diff -u -r1.5 FailedCompleteParseASTExpressionTest.java
--- failures/org/eclipse/cdt/core/parser/failedTests/FailedCompleteParseASTExpressionTest.java 19 Sep 2003 16:00:44 -0000 1.5
+++ failures/org/eclipse/cdt/core/parser/failedTests/FailedCompleteParseASTExpressionTest.java 23 Sep 2003 22:50:28 -0000
@@ -41,62 +41,6 @@
super(name);
}
-// public void testPostfixSubscriptA_Bug43238() throws Exception
-// {
-// Iterator i = parse ("int pa[10][5] ; \n int f(int ia){} \n int f(void); \n int x = f(pa[1][2]);").getDeclarations();
-// IASTVariable pa = (IASTVariable) i.next();
-// IASTFunction f1 = (IASTFunction) i.next();
-// IASTFunction f2 = (IASTFunction) i.next();
-// IASTVariable x = (IASTVariable) i.next();
-// Iterator references = callback.getReferences().iterator();
-// assertEquals( callback.getReferences().size(), 1 ); // should be = 2
-// assertEquals( ((IASTReference)references.next()).getReferencedElement(), pa );
-// //assertEquals( ((IASTReference)references.next()).getReferencedElement(), f1 );
-// }
-// public void testPostfixSubscriptB_Bug43238() throws Exception
-// {
-// Iterator i = parse ("int* pa[10][5] ; \n int f(int* ia){} \n int f(void); \n int x = f(pa[1][2]);").getDeclarations();
-// IASTVariable pa = (IASTVariable) i.next();
-// IASTFunction f1 = (IASTFunction) i.next();
-// IASTFunction f2 = (IASTFunction) i.next();
-// IASTVariable x = (IASTVariable) i.next();
-// Iterator references = callback.getReferences().iterator();
-// assertEquals( callback.getReferences().size(), 1 ); // should be = 2
-// assertEquals( ((IASTReference)references.next()).getReferencedElement(), pa );
-// //assertEquals( ((IASTReference)references.next()).getReferencedElement(), f1 );
-// }
-// public void testPostfixSubscriptWithReferences_Bug43238() throws Exception
-// {
-// Iterator i = parse ("class A{}; \n A *pa[10][5] ; \n int f(A* ia){} \n int f(void); \n int x = f(pa[1][2]);").getDeclarations();
-// IASTClassSpecifier cl = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
-// IASTVariable pa = (IASTVariable) i.next();
-// IASTFunction f1 = (IASTFunction) i.next();
-// IASTFunction f2 = (IASTFunction) i.next();
-// IASTVariable x = (IASTVariable) i.next();
-// Iterator references = callback.getReferences().iterator();
-// assertEquals( ((IASTReference) references.next()).getReferencedElement(), cl );
-// assertEquals( ((IASTReference) references.next()).getReferencedElement(), cl );
-// assertEquals( ((IASTReference)references.next()).getReferencedElement(), pa );
-// assertEquals( ((IASTReference)references.next()).getReferencedElement(), f1 );
-// }
-// public void testConditionalExpression_Bug43159() throws Exception {
-// Iterator i = parse( "int foo(bool); int foo(int); int a = 10, b = 4, c = 2; int x = foo( a > 5 ? b : c );").getDeclarations();
-// IASTFunction foo1 = (IASTFunction)i.next();
-// IASTFunction foo2 = (IASTFunction)i.next();
-// IASTVariable a = (IASTVariable)i.next();
-// IASTVariable b = (IASTVariable)i.next();
-// IASTVariable c = (IASTVariable)i.next();
-// IASTVariable x = (IASTVariable)i.next();
-// assertFalse( i.hasNext() );
-// assertEquals( callback.getReferences().size(), 3 ); // should be 4
-// Iterator references =callback.getReferences().iterator();
-// assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
-// assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
-// assertEquals( ((IASTReference)references.next()).getReferencedElement(), c );
-// //assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
-// assertFalse( references.hasNext() );
-// }
-
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();
IASTClassSpecifier cla = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
@@ -108,18 +52,10 @@
IASTVariable c = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 7 ); // should be 8
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), cla );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), cla );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), cla );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), clb );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), c );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- //assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 7 /* should be 8 */,
+ createTaskList( new Task( cla, 3 ), new Task( clb ), new Task( c), new Task( b ), new Task( a )/*, new Task( foo2) */));
}
+
public void testPMDotStarPointerToMemberFunction_Bug43242() throws Exception
{
Iterator i = parse ("class A { int m(int); }; \n A a; int A::*pm = &A::m; \n int f(){} \n int f(int); \n int x = f((a.*pm)(5));").getDeclarations();
@@ -131,14 +67,10 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- assertEquals( callback.getReferences().size(), 5 ); // should be 6
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), cl );
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), cl );
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), method );
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), pm );
-// assertEquals( ((IASTReference) references.next()).getReferencedElement(), f2 );
+
+ assertAllReferences( 5 /* should be 8 */,
+ createTaskList( new Task( cl, 2 /* should be 3 */ ), new Task( method ), new Task( a ), new Task( pm ) /* should be ,new Task( f2 ) */
+ ));
}
public void testPMArrowStarPointerToMemberFunction_Bug43242() throws Exception
{
@@ -151,14 +83,10 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- assertEquals( callback.getReferences().size(), 5 ); // should be 6
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), cl );
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), cl );
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), method );
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), pm );
-// assertEquals( ((IASTReference) references.next()).getReferencedElement(), f2 );
+
+ assertAllReferences( 5 /* should be more */,
+ createTaskList( new Task( cl, 2 ), new Task( method ), new Task( a /*, 2 */), new Task( pm )/* ,new Task( f2 )*/));
+
}
public void testUnaryStarCastexpressionPointerToFunction_Bug43241() throws Exception
{
@@ -168,11 +96,9 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- assertEquals( callback.getReferences().size(), 2 ); // should be 3
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), m );
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), pm );
-// assertEquals( ((IASTReference) references.next()).getReferencedElement(), f2 );
+ assertAllReferences( 2 /* should be 3 */,
+ createTaskList( new Task( m ), new Task( pm ) /* ,new Task( f2 )*/));
+
}
}
Index: parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTExpressionTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTExpressionTest.java,v
retrieving revision 1.6
diff -u -r1.6 CompleteParseASTExpressionTest.java
--- parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTExpressionTest.java 19 Sep 2003 16:00:44 -0000 1.6
+++ parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTExpressionTest.java 23 Sep 2003 22:50:29 -0000
@@ -16,13 +16,10 @@
import org.eclipse.cdt.core.parser.ast.IASTClassReference;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTField;
-import org.eclipse.cdt.core.parser.ast.IASTFieldReference;
import org.eclipse.cdt.core.parser.ast.IASTFunction;
-import org.eclipse.cdt.core.parser.ast.IASTFunctionReference;
import org.eclipse.cdt.core.parser.ast.IASTMethod;
import org.eclipse.cdt.core.parser.ast.IASTReference;
import org.eclipse.cdt.core.parser.ast.IASTVariable;
-import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
/**
* @author hamer
@@ -43,10 +40,7 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- IASTFunctionReference fr1 = (IASTFunctionReference) references.next();
- assertEquals( fr1.getReferencedElement(), f2 );
-
+ assertAllReferences(1, createTaskList( new Task( f2 ) ));
}
// Kind PRIMARY_INTEGER_LITERAL : int
public void testPrimaryIntegerLiteral() throws Exception
@@ -55,9 +49,10 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- IASTFunctionReference fr1 = (IASTFunctionReference) references.next();
- assertEquals( fr1.getReferencedElement(), f1 );
+ assertAllReferences( 1, createTaskList( new Task( f1 )));
+// Iterator references = callback.getReferences().iterator();
+// IASTFunctionReference fr1 = (IASTFunctionReference) references.next();
+// assertEquals( fr1.getReferencedElement(), f1 );
}
// Kind PRIMARY_CHAR_LITERAL : char
@@ -67,10 +62,7 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- IASTFunctionReference fr1 = (IASTFunctionReference) references.next();
- assertEquals( fr1.getReferencedElement(), f2 );
-
+ assertAllReferences( 1, createTaskList( new Task( f2 )));
}
// Kind PRIMARY_FLOAT_LITERAL : float
public void testPrimaryFloatLiteral() throws Exception
@@ -79,10 +71,7 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- IASTFunctionReference fr1 = (IASTFunctionReference) references.next();
- assertEquals( fr1.getReferencedElement(), f2 );
-
+ assertAllReferences( 1, createTaskList( new Task( f2 )));
}
// Kind PRIMARY_STRING_LITERAL : char*
public void testPrimaryStringLiteral() throws Exception
@@ -91,10 +80,7 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- IASTFunctionReference fr1 = (IASTFunctionReference) references.next();
- assertEquals( fr1.getReferencedElement(), f2 );
-
+ assertAllReferences( 1, createTaskList( new Task( f2 )));
}
// Kind PRIMARY_BOOLEAN_LITERAL : bool
public void testPrimaryBooleanLiteral() throws Exception
@@ -103,10 +89,7 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- IASTFunctionReference fr1 = (IASTFunctionReference) references.next();
- assertEquals( fr1.getReferencedElement(), f1 );
-
+ assertAllReferences( 1, createTaskList( new Task( f1 )));
}
// Kind PRIMARY_THIS : type of inner most enclosing structure scope
public void testPrimaryThis() throws Exception
@@ -119,11 +102,7 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTMethod m = (IASTMethod) i.next();
- Iterator references = callback.getReferences().iterator();
- assertEquals( ((IASTClassReference) references.next()).getReferencedElement(), cl );
- assertEquals( ((IASTClassReference) references.next()).getReferencedElement(), cl );
- assertEquals( ((IASTClassReference) references.next()).getReferencedElement(), cl );
- assertEquals( ((IASTFunctionReference) references.next()).getReferencedElement(), f2 );
+ assertAllReferences( 4, createTaskList( new Task( cl, 3 ), new Task( f2 )));
}
// Kind PRIMARY_BRACKETED_EXPRESSION : LHS
public void testPrimaryBracketedExpression() throws Exception
@@ -132,24 +111,20 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- IASTFunctionReference fr1 = (IASTFunctionReference) references.next();
- assertEquals( fr1.getReferencedElement(), f1 );
- }
+ assertAllReferences( 1, createTaskList( new Task( f1 )));
+ }
// Kind ID_EXPRESSION : type of the ID
public void testIdExpression() throws Exception
{
Iterator i = parse ("class A{}a; \n int f(A a); \n int f(void); \n int x = f(a);").getDeclarations();
+
IASTVariable a = (IASTVariable) i.next();
+ IASTClassSpecifier cl = (IASTClassSpecifier)a.getAbstractDeclaration().getTypeSpecifier();
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- IASTClassReference clr1 = (IASTClassReference) references.next();
- IASTVariableReference ar1 = (IASTVariableReference) references.next();
- IASTFunctionReference fr1 = (IASTFunctionReference) references.next();
- assertEquals( ar1.getReferencedElement(), a );
- assertEquals( fr1.getReferencedElement(), f1 );
+
+ assertAllReferences( 3, createTaskList( new Task( cl ), new Task( f1 ),new Task( a ) ) );
}
// Kind ID_EXPRESSION ( refers to a pointer ) : pointer to type of ID
public void testIdExpressionToPointer() throws Exception
@@ -160,14 +135,8 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- IASTClassReference clr1 = (IASTClassReference) references.next();
- IASTClassReference clr2 = (IASTClassReference) references.next();
- IASTVariableReference ar1 = (IASTVariableReference) references.next();
- IASTFunctionReference fr1 = (IASTFunctionReference) references.next();
- assertEquals( clr1.getReferencedElement(), cl );
- assertEquals( ar1.getReferencedElement(), a );
- assertEquals( fr1.getReferencedElement(), f1 );
+ assertAllReferences( 4, createTaskList( new Task( cl, 2 ), new Task( f1 ), new Task( a ) ) );
+
}
// Kind POSTFIX_SUBSCRIPT
public void testPostfixSubscript() throws Exception
@@ -176,11 +145,8 @@
IASTVariable pa = (IASTVariable) i.next();
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
- IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- assertEquals( callback.getReferences().size(), 2 );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), pa );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), f1 );
+ IASTVariable x = (IASTVariable) i.next();
+ assertAllReferences( 2, createTaskList( new Task( f1 ), new Task( pa ) ) );
}
public void testPostfixSubscriptA() throws Exception
@@ -190,10 +156,7 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- assertEquals( callback.getReferences().size(), 2 ); // should be = 2
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), pa );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), f1 );
+ assertAllReferences( 2, createTaskList( new Task( f1 ), new Task( pa ) ) );
}
public void testPostfixSubscriptB() throws Exception
@@ -203,10 +166,7 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- assertEquals( callback.getReferences().size(), 2 ); // should be = 2
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), pa );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), f1 );
+ assertAllReferences( 2, createTaskList( new Task( f1 ), new Task( pa ) ) );
}
public void testPostfixSubscriptWithReferences() throws Exception
@@ -217,11 +177,7 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- assertEquals( ((IASTClassReference) references.next()).getReferencedElement(), cl );
- assertEquals( ((IASTClassReference) references.next()).getReferencedElement(), cl );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), pa );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), f1 );
+ assertAllReferences( 4, createTaskList( new Task( cl, 2 ), new Task( pa ), new Task( f1 )));
}
// Kind POSTFIX_FUNCTIONCALL : return type of called function
@@ -230,11 +186,9 @@
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();
IASTFunction foo = (IASTFunction)i.next();
IASTFunction bar = (IASTFunction)i.next();
- IASTFunction test = (IASTFunction)i.next();
+ i.next();
assertFalse( i.hasNext() );
- Iterator references = callback.getReferences().iterator();
- //THIS SHOULD BE 3, 2 references of foo(), one reference of bar()
- assertEquals( callback.getReferences().size(), 3 );
+ assertAllReferences( 3, createTaskList( new Task( bar ), new Task( foo, 2 )));
}
// Kind POSTFIX_SIMPLETYPE_* : simple type
public void testPostfixSimpletypesBug42823() throws Exception
@@ -246,10 +200,9 @@
IASTFunction foo = (IASTFunction)i.next();
IASTFunction test = (IASTFunction)i.next();
assertFalse( i.hasNext() );
- Iterator references = callback.getReferences().iterator();
- //should be 1
- assertEquals( callback.getReferences().size(), 1 );
+ assertAllReferences( 1, createTaskList( new Task( foo )));
}
+
// Kind POSTFIX_TYPENAME_IDENTIFIER
// public void testPostfixTypenameIdentifier() throws Exception{
// Iterator i = parse( "class A {}; \n int foo(); int foo( A a ); \n int x = foo( typename A(); );").getDeclarations();
@@ -282,15 +235,7 @@
IASTVariable x = (IASTVariable) i.next();
Iterator members = getDeclarations(cl);
IASTField m = (IASTField)members.next();
- Iterator references = callback.getReferences().iterator();
- IASTClassReference clr= (IASTClassReference)references.next();
- assertEquals(clr.getReferencedElement(), cl);
- IASTVariableReference ar = (IASTVariableReference)references.next();
- assertEquals(ar.getReferencedElement(), a);
- IASTFieldReference mr = (IASTFieldReference) references.next();
- assertEquals(mr.getReferencedElement(), m);
- IASTFunctionReference fr = (IASTFunctionReference) references.next();
- assertEquals(fr.getReferencedElement(), f2);
+ assertAllReferences( 4, createTaskList( new Task(cl), new Task(a), new Task(m), new Task(f2) ));
}
// Kind POSTFIX_ARROW_IDEXPRESSION : type of member in the scope of the container
public void testPostfixArrowExpression() throws Exception{
@@ -302,15 +247,7 @@
IASTVariable x = (IASTVariable) i.next();
Iterator members = getDeclarations(cl);
IASTField m = (IASTField)members.next();
- Iterator references = callback.getReferences().iterator();
- IASTClassReference clr= (IASTClassReference)references.next();
- assertEquals(clr.getReferencedElement(), cl);
- IASTVariableReference ar = (IASTVariableReference)references.next();
- assertEquals(ar.getReferencedElement(), a);
- IASTFieldReference mr = (IASTFieldReference) references.next();
- assertEquals(mr.getReferencedElement(), m);
- IASTFunctionReference fr = (IASTFunctionReference) references.next();
- assertEquals(fr.getReferencedElement(), f2);
+ assertAllReferences( 4, createTaskList( new Task(cl), new Task(a), new Task(m), new Task(f2) ));
}
// Kind POSTFIX_DOT_TEMPL_IDEXPRESS
// Kind POSTFIX_ARROW_TEMPL_IDEXP
@@ -329,11 +266,7 @@
IASTVariable y = (IASTVariable)subDecls.next();
assertFalse( subDecls.hasNext() );
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), x );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 ); // should be foo2
- assertFalse( references.hasNext() );
+ assertAllReferences( 2, createTaskList( new Task( x ), new Task( foo2)));
}
// Kind POSTFIX_DECREMENT : LHS
public void testPostfixDecrement() throws Exception
@@ -347,11 +280,7 @@
IASTVariable y = (IASTVariable)subDecls.next();
assertFalse( subDecls.hasNext() );
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), x );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 ); // should be foo2
- assertFalse( references.hasNext() );
+ assertAllReferences( 2, createTaskList( new Task( x ), new Task( foo2)));
}
// Kind POSTFIX_DYNAMIC_CAST
@@ -382,30 +311,45 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- IASTFunctionReference fr = (IASTFunctionReference) references.next();
- assertEquals(fr.getReferencedElement(), f2);
-
+ assertAllReferences( 1, createTaskList( new Task( f2 )));
}
+
+ // Kind POSTFIX_TYPEID_EXPRESSION : type of the ID
+ public void testPostfixTypeIdExpression2() throws Exception{
+ Iterator i = parse( "class A {}; \n A a; \n int foo(A); int foo( int ); \n int x = foo( typeid(a) );").getDeclarations();
+ IASTClassSpecifier cl = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
+ IASTVariable a = (IASTVariable) i.next();
+ IASTFunction f1 = (IASTFunction) i.next();
+ IASTFunction f2 = (IASTFunction) i.next();
+ IASTVariable x = (IASTVariable) i.next();
+ assertAllReferences( 4, createTaskList( new Task(cl, 2),new Task(a),new Task(f1)));
+ }
+
+
// Kind POSTFIX_TYPEID_TYPEID : type of the ID
public void testPostfixTypeIdTypeId() throws Exception{
- Iterator i = parse( "class A {}; \n A a; \n int foo(A); int foo( int ); \n int x = foo( typeid(a) );").getDeclarations();
+ Iterator i = parse( "class A {}; \n A a; \n int foo(A); int foo( int ); \n int x = foo( typeid(A) );").getDeclarations();
IASTClassSpecifier cl = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
IASTVariable a = (IASTVariable) i.next();
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- IASTClassReference clr= (IASTClassReference)references.next();
- assertEquals(clr.getReferencedElement(), cl);
- IASTClassReference clr2= (IASTClassReference)references.next();
- assertEquals(clr2.getReferencedElement(), cl);
- IASTVariableReference ar = (IASTVariableReference)references.next();
- assertEquals(ar.getReferencedElement(), a);
- IASTFunctionReference fr = (IASTFunctionReference) references.next();
- assertEquals(fr.getReferencedElement(), f1);
-
+ assertAllReferences( 4, createTaskList( new Task(cl, 3), new Task(f1)));
}
+
+ // Kind POSTFIX_TYPEID_TYPEID : type of the ID
+ public void testPostfixTypeIdTypeId2() throws Exception{
+ Iterator i = parse( "class A {}; \n A a; \n int foo(A); int foo( int ); \n int x = foo( typeid(const A) );").getDeclarations();
+ IASTClassSpecifier cl = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
+ IASTVariable a = (IASTVariable) i.next();
+ IASTFunction f1 = (IASTFunction) i.next();
+ IASTFunction f2 = (IASTFunction) i.next();
+ IASTVariable x = (IASTVariable) i.next();
+ assertAllReferences( 4, createTaskList( new Task(cl, 3), new Task(f1)));
+ }
+
+
+
// Kind UNARY_INCREMENT : LHS
public void testUnaryIncrement() throws Exception
{
@@ -418,11 +362,7 @@
IASTVariable y = (IASTVariable)subDecls.next();
assertFalse( subDecls.hasNext() );
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), x );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 ); // should be foo2
- assertFalse( references.hasNext() );
+ assertAllReferences( 2, createTaskList( new Task(foo2), new Task(x) ));
}
// Kind UNARY_DECREMENT : LHS
public void testUnaryDecrement() throws Exception
@@ -436,11 +376,7 @@
IASTVariable y = (IASTVariable)subDecls.next();
assertFalse( subDecls.hasNext() );
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), x );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 ); // should be foo2
- assertFalse( references.hasNext() );
+ assertAllReferences( 2, createTaskList( new Task(foo2), new Task(x) ));
}
// Kind UNARY_STAR_CASTEXPRESSION : LHS + t_pointer
public void testUnaryStarCastExpression() throws Exception
@@ -451,15 +387,7 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- IASTClassReference clr1 = (IASTClassReference) references.next();
- IASTClassReference clr2 = (IASTClassReference) references.next();
- IASTVariableReference ar1 = (IASTVariableReference) references.next();
- IASTFunctionReference fr1 = (IASTFunctionReference) references.next();
- assertEquals( clr1.getReferencedElement(), cl );
- assertEquals( ar1.getReferencedElement(), a );
- assertEquals( fr1.getReferencedElement(), f1 );
-
+ assertAllReferences( 4, createTaskList( new Task(cl, 2 ), new Task( a ), new Task(f1) ));
}
// Kind UNARY_AMPSND_CASTEXPRESSION : LHS + t_reference
public void testUnaryAmpersandCastExpression() throws Exception
@@ -470,14 +398,7 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- IASTClassReference clr1 = (IASTClassReference) references.next();
- IASTClassReference clr2 = (IASTClassReference) references.next();
- IASTVariableReference ar1 = (IASTVariableReference) references.next();
- IASTFunctionReference fr1 = (IASTFunctionReference) references.next();
- assertEquals( clr1.getReferencedElement(), cl );
- assertEquals( ar1.getReferencedElement(), a );
- assertEquals( fr1.getReferencedElement(), f1 );
+ assertAllReferences( 4, createTaskList( new Task(cl, 2 ), new Task( a ), new Task(f1) ));
}
// Kind UNARY_PLUS_CASTEXPRESSION : LHS
public void testUnaryPlusCastExpression() throws Exception {
@@ -486,10 +407,7 @@
IASTFunction foo2 = (IASTFunction)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 1 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 1, createTaskList( new Task( foo2 )));
}
// Kind UNARY_MINUS_CASTEXPRESSION : LHS
public void testUnaryMinusCastExpression() throws Exception {
@@ -498,10 +416,7 @@
IASTFunction foo2 = (IASTFunction)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 1 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 1, createTaskList( new Task( foo2 )));
}
// Kind UNARY_NOT_CASTEXPRESSION : LHS
public void testUnaryNotCastExpression() throws Exception {
@@ -511,11 +426,7 @@
IASTVariable b = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 2, createTaskList( new Task( b ), new Task( foo2 )));
}
// Kind UNARY_TILDE_CASTEXPRESSION : LHS
public void testTildeNotCastExpression() throws Exception {
@@ -525,11 +436,7 @@
IASTVariable x = (IASTVariable)i.next();
IASTVariable y = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), x );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 2, createTaskList( new Task( x ), new Task( foo2 )));
}
// Kind UNARY_SIZEOF_UNARYEXPRESSION : unsigned int
public void testUnarySizeofUnaryExpression() throws Exception {
@@ -539,10 +446,7 @@
IASTVariable x = (IASTVariable)i.next();
IASTVariable y = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 1 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 1, createTaskList( new Task( foo2 )));
}
// Kind UNARY_SIZEOF_TYPEID : unsigned int
public void testUnarySizeofTypeId() throws Exception {
@@ -552,29 +456,20 @@
IASTVariable x = (IASTVariable)i.next();
IASTVariable y = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), x );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 2, createTaskList( new Task( x ), new Task( foo2 )));
}
-
- // Kind NEW_NEWTYPEID
- // Kind NEW_TYPEID
- // There are so many ways to call new, only this case is handeled.
+
+// // Kind NEW_NEWTYPEID
+// // Kind NEW_TYPEID
+// // There are so many ways to call new, only this case is handeled.
// public void testNewTypeId() throws Exception {
-// Iterator i = parse( "class A{}; void foo(); int foo( A a ); int x = foo( new A() );").getDeclarations();
+// Iterator i = parse( "class A{}; void foo(); int foo( A * a ); int x = foo( new A() );").getDeclarations();
// IASTClassSpecifier cl = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
// IASTFunction foo = (IASTFunction)i.next();
// IASTFunction foo2 = (IASTFunction)i.next();
// IASTVariable x = (IASTVariable)i.next();
// assertFalse( i.hasNext() );
-// //assertEquals( callback.getReferences().size(), 3 );
-// Iterator references =callback.getReferences().iterator();
-// IASTClassReference clr1 = (IASTClassReference) references.next();
-// IASTClassReference clr2 = (IASTClassReference) references.next();
-// assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
-// assertFalse( references.hasNext() );
+// assertAllReferences( 3, createTaskList( new Task( cl, 2), new Task( foo2 )));
// }
// Kind DELETE_CASTEXPRESSION
@@ -590,12 +485,7 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), cl );
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), pm );
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), f2 );
-
+ assertAllReferences( 4, createTaskList( new Task( cl ), new Task( a), new Task( pm ), new Task(f2)));
}
// Kind PM_ARROWSTAR
@@ -608,12 +498,7 @@
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
- Iterator references = callback.getReferences().iterator();
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), cl );
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), pm );
- assertEquals( ((IASTReference) references.next()).getReferencedElement(), f2 );
-
+ assertAllReferences( 4, createTaskList( new Task( cl ), new Task( a), new Task( pm), new Task( f2)));
}
// Kind MULTIPLICATIVE_MULTIPLY : usual arithmetic conversions
@@ -626,11 +511,7 @@
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
assertEquals( callback.getReferences().size(), 3 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 3, createTaskList( new Task(a), new Task(b), new Task( foo2 ) ) );
}
// Kind MULTIPLICATIVE_DIVIDE : usual arithmetic conversions
public void testMultiplicativeDivide() throws Exception {
@@ -641,12 +522,7 @@
IASTVariable b = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 3 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 3, createTaskList( new Task(a), new Task(b), new Task( foo2 ) ) );
}
// Kind MULTIPLICATIVE_MODULUS : usual arithmetic conversions
public void testMultiplicativeModulus() throws Exception {
@@ -657,12 +533,7 @@
IASTVariable b = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 3 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 3, createTaskList( new Task(a), new Task(b), new Task( foo2 ) ) );
}
// Kind ADDITIVE_PLUS : usual arithmetic conversions
public void testAdditivePlus() throws Exception {
@@ -673,12 +544,13 @@
IASTVariable b = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 3 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 3, createTaskList( new Task(a), new Task(b), new Task( foo2 ) ) );
+// assertEquals( callback.getReferences().size(), 3 );
+// Iterator references =callback.getReferences().iterator();
+// assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
+// assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
+// assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
+// assertFalse( references.hasNext() );
}
// Kind ADDITIVE_MINUS : usual arithmetic conversions
public void testAdditiveMinus() throws Exception {
@@ -689,12 +561,7 @@
IASTVariable b = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 3 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 3, createTaskList( new Task(a), new Task(b), new Task( foo2 ) ) );
}
// Kind SHIFT_LEFT : LHS
public void testShiftLeft() throws Exception {
@@ -704,11 +571,7 @@
IASTVariable a = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo1 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 2, createTaskList( new Task(a), new Task( foo1 ) ) );
}
// Kind SHIFT_RIGHT : LHS
@@ -719,11 +582,7 @@
IASTVariable a = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo1 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 2, createTaskList( new Task(a), new Task( foo1 ) ) );
}
// Kind RELATIONAL_LESSTHAN : bool
@@ -734,11 +593,7 @@
IASTVariable b = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
}
// Kind RELATIONAL_GREATERTHAN : bool
public void testRelationalGreaterThan() throws Exception {
@@ -748,11 +603,7 @@
IASTVariable b = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
}
// Kind RELATIONAL_LESSTHANEQUALTO : bool
public void testRelationalLessThanOrEqual() throws Exception {
@@ -762,11 +613,7 @@
IASTVariable b = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
}
// Kind RELATIONAL_GREATERTHANEQUALTO : bool
public void testRelationalGreaterThanOrEqual() throws Exception {
@@ -776,11 +623,7 @@
IASTVariable b = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
}
// Kind EQUALITY_EQUALS : bool
public void testEqualityEquals() throws Exception {
@@ -790,11 +633,7 @@
IASTVariable b = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
}
// Kind EQUALITY_NOTEQUALS : bool
public void testEqualityNotEquals() throws Exception {
@@ -804,11 +643,7 @@
IASTVariable b = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 2, createTaskList( new Task(b), new Task( foo2 ) ) );
}
// Kind ANDEXPRESSION : usual arithmetic conversions
public void testAndExpression() throws Exception {
@@ -819,12 +654,7 @@
IASTVariable b = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 3 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 3, createTaskList( new Task( a ), new Task(b), new Task( foo2 ) ) );
}
// Kind EXCLUSIVEOREXPRESSION : usual arithmetic conversions
public void testExclusiveOrExpression() throws Exception {
@@ -835,12 +665,7 @@
IASTVariable b = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 3 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 3, createTaskList( new Task( a ), new Task(b), new Task( foo2 ) ) );
}
// Kind INCLUSIVEOREXPRESSION : : usual arithmetic conversions
public void testInclusiveOrExpression() throws Exception {
@@ -851,12 +676,7 @@
IASTVariable b = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 3 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 3, createTaskList( new Task( a ), new Task(b), new Task( foo2 ) ) );
}
// Kind LOGICALANDEXPRESSION : bool
public void testLogicalAndExpression() throws Exception {
@@ -867,12 +687,7 @@
IASTVariable b = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 3 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 3, createTaskList( new Task( a ), new Task(b), new Task( foo2 ) ) );
}
// Kind LOGICALOREXPRESSION : bool
public void testLogicalOrExpression() throws Exception {
@@ -883,12 +698,7 @@
IASTVariable b = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 3 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 3, createTaskList( new Task( a ), new Task(b), new Task( foo2 ) ) );
}
// Kind CONDITIONALEXPRESSION : conditional Expression Conversions
public void testConditionalExpression() throws Exception {
@@ -900,13 +710,7 @@
IASTVariable c = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 4 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), c );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences( 4, createTaskList( new Task( a ), new Task(b), new Task( c ), new Task( foo2 ) ) );
}
// Kind CONDITIONALEXPRESSION with references : conditional Expression Conversions
public void testConditionalExpressionWithReferencesA() throws Exception {
@@ -920,17 +724,7 @@
IASTVariable c = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 8 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), cla );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), cla );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), cla );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), clb );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), c );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), b );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo2 );
- assertFalse( references.hasNext() );
+ assertAllReferences(8, createTaskList( new Task( cla, 3 ), new Task( clb ), new Task( c ), new Task( b ), new Task( a ), new Task( foo2 )) );
}
// Kind THROWEXPRESSION
@@ -943,11 +737,7 @@
IASTVariable a = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo1 );
- assertFalse( references.hasNext() );
+ assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
}
// Kind ASSIGNMENTEXPRESSION_PLUS : LHS
@@ -958,11 +748,7 @@
IASTVariable a = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo1 );
- assertFalse( references.hasNext() );
+ assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
}
// Kind ASSIGNMENTEXPRESSION_MINUS : LHS
public void testAssignmentExpressionMinus() throws Exception {
@@ -972,11 +758,7 @@
IASTVariable a = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo1 );
- assertFalse( references.hasNext() );
+ assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
}
// Kind ASSIGNMENTEXPRESSION_MULT : LHS
public void testAssignmentExpressionMulti() throws Exception {
@@ -986,11 +768,7 @@
IASTVariable a = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo1 );
- assertFalse( references.hasNext() );
+ assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
}
// Kind ASSIGNMENTEXPRESSION_DIV : LHS
public void testAssignmentExpressionDiv() throws Exception {
@@ -1000,11 +778,7 @@
IASTVariable a = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo1 );
- assertFalse( references.hasNext() );
+ assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
}
// Kind ASSIGNMENTEXPRESSION_MOD : LHS
public void testAssignmentExpressionMod() throws Exception {
@@ -1014,11 +788,7 @@
IASTVariable a = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo1 );
- assertFalse( references.hasNext() );
+ assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
}
// Kind ASSIGNMENTEXPRESSION_LSHIFT : LHS
public void testAssignmentExpressionLShift() throws Exception {
@@ -1028,11 +798,7 @@
IASTVariable a = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo1 );
- assertFalse( references.hasNext() );
+ assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
}
// Kind ASSIGNMENTEXPRESSION_RSHIFT : LHS
public void testAssignmentExpressionRShift() throws Exception {
@@ -1042,11 +808,7 @@
IASTVariable a = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo1 );
- assertFalse( references.hasNext() );
+ assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
}
// Kind ASSIGNMENTEXPRESSION_AND : LHS
public void testAssignmentExpressionAnd() throws Exception {
@@ -1056,11 +818,7 @@
IASTVariable a = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo1 );
- assertFalse( references.hasNext() );
+ assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
}
// Kind ASSIGNMENTEXPRESSION_OR : LHS
public void testAssignmentExpressionOr() throws Exception {
@@ -1070,11 +828,7 @@
IASTVariable a = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo1 );
- assertFalse( references.hasNext() );
+ assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
}
// Kind ASSIGNMENTEXPRESSION_XOR : LHS
public void testAssignmentExpressionXOr() throws Exception {
@@ -1084,11 +838,7 @@
IASTVariable a = (IASTVariable)i.next();
IASTVariable x = (IASTVariable)i.next();
assertFalse( i.hasNext() );
- assertEquals( callback.getReferences().size(), 2 );
- Iterator references =callback.getReferences().iterator();
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), a );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), foo1 );
- assertFalse( references.hasNext() );
+ assertAllReferences(2, createTaskList( new Task(a), new Task(foo1) ));
}
// Kind EXPRESSIONLIST : list of LHS, RHS
// Already tested with each test trying to find a reference to function.
Index: parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java,v
retrieving revision 1.31
diff -u -r1.31 CompleteParseASTTest.java
--- parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java 23 Sep 2003 20:46:12 -0000 1.31
+++ parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java 23 Sep 2003 22:50:29 -0000
@@ -499,11 +499,11 @@
IASTVariable variablep = (IASTVariable)declarations.next();
assertEquals( callback.getReferences().size(), 5 );
Iterator references = callback.getReferences().iterator();
+ assertEquals( ((IASTReference)references.next()).getReferencedElement(), variableA );
assertEquals( ((IASTReference)references.next()).getReferencedElement(), variableP );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), variableB );
+ assertEquals( ((IASTReference)references.next()).getReferencedElement(), variableB );
assertEquals( ((IASTReference)references.next()).getReferencedElement(), variableC );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), variableD );
- assertEquals( ((IASTReference)references.next()).getReferencedElement(), variableA );
+ assertEquals( ((IASTReference)references.next()).getReferencedElement(), variableD );
}
public void testBug41520() throws Exception
@@ -796,5 +796,14 @@
}
}
-
+ public void testBug39504() throws Exception
+ {
+ Iterator i = parse( "const int w = 2; int x[ 5 ]; int y = sizeof (x[w]);" ).getDeclarations();
+ IASTVariable varW = (IASTVariable)i.next();
+ IASTVariable varX = (IASTVariable)i.next();
+ IASTVariable vary = (IASTVariable)i.next();
+ assertFalse( i.hasNext() );
+ assertEquals( callback.getReferences().size(), 2 );
+ }
+
}
Index: parser/org/eclipse/cdt/core/parser/tests/CompleteParseBaseTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseBaseTest.java,v
retrieving revision 1.6
diff -u -r1.6 CompleteParseBaseTest.java
--- parser/org/eclipse/cdt/core/parser/tests/CompleteParseBaseTest.java 15 Sep 2003 22:50:59 -0000 1.6
+++ parser/org/eclipse/cdt/core/parser/tests/CompleteParseBaseTest.java 23 Sep 2003 22:50:30 -0000
@@ -12,15 +12,18 @@
import java.io.StringReader;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import java.util.Stack;
import junit.framework.TestCase;
import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.core.parser.IProblem;
+import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserLanguage;
@@ -48,6 +51,7 @@
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
import org.eclipse.cdt.core.parser.ast.IASTParameterReference;
+import org.eclipse.cdt.core.parser.ast.IASTReference;
import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
@@ -170,6 +174,17 @@
private Stack inclusions = new Stack();
private Scope compilationUnit;
+ public FullParseCallback()
+ {
+// System.out.println( "NEW");
+// System.out.println();
+ }
+
+ public void finalize()
+ {
+// System.out.println( );
+ }
+
public IASTScope getCompilationUnit()
{
return compilationUnit;
@@ -504,7 +519,7 @@
*/
public void acceptClassReference(IASTClassReference reference)
{
- references.add( reference );
+ processReference( reference );
}
/* (non-Javadoc)
@@ -512,7 +527,7 @@
*/
public void acceptTypedefReference(IASTTypedefReference reference)
{
- references.add( reference );
+ processReference( reference );
}
@@ -521,7 +536,7 @@
*/
public void acceptNamespaceReference(IASTNamespaceReference reference)
{
- references.add( reference );
+ processReference( reference );
}
@@ -530,7 +545,7 @@
*/
public void acceptEnumerationReference(IASTEnumerationReference reference)
{
- references.add( reference );
+ processReference( reference );
}
/* (non-Javadoc)
@@ -538,8 +553,7 @@
*/
public void acceptVariableReference(IASTVariableReference reference)
{
- references.add( reference );
-
+ processReference( reference );
}
/* (non-Javadoc)
@@ -547,8 +561,13 @@
*/
public void acceptFunctionReference(IASTFunctionReference reference)
{
- references.add( reference );
-
+ processReference(reference);
+ }
+
+ protected void processReference(IASTReference reference)
+ {
+ references.add( reference );
+// System.out.println( "Callback received Reference to " + reference.getName() + " @ offset " + reference.getOffset() );
}
/* (non-Javadoc)
@@ -556,7 +575,7 @@
*/
public void acceptFieldReference(IASTFieldReference reference)
{
- references.add( reference );
+ processReference( reference );
}
@@ -565,7 +584,7 @@
*/
public void acceptMethodReference(IASTMethodReference reference)
{
- references.add( reference );
+ processReference( reference );
}
@@ -617,7 +636,7 @@
*/
public void acceptEnumeratorReference(IASTEnumeratorReference reference)
{
- references.add( reference );
+ processReference( reference );
}
/* (non-Javadoc)
@@ -625,7 +644,7 @@
*/
public void acceptParameterReference(IASTParameterReference reference)
{
- references.add( reference );
+ processReference( reference );
}
}
@@ -656,4 +675,140 @@
if( ! parser.parse() ) throw new ParserException( "FAILURE");
return callback.getCompilationUnit();
}
+
+ protected void assertReferences(
+ ISourceElementCallbackDelegate element,
+ int expectedDistinctReferenceCount,
+ boolean allowDuplicates )
+ {
+ Set matches = new HashSet();
+ Iterator allReferences = callback.getReferences().iterator();
+ while( allReferences.hasNext() )
+ {
+ IASTReference r = (IASTReference)allReferences.next();
+ if( r.getReferencedElement() == element )
+ if( ! matches.add( r ) && ! allowDuplicates )
+ fail( "Duplicate reference found for ISourceElementCallbackDelegate: " + element + " @ offset " + r.getOffset() );
+ }
+
+ assertEquals( expectedDistinctReferenceCount, matches.size() );
+ }
+
+ protected static class Task
+ {
+ private final boolean unique;
+ private final int count;
+ private final ISourceElementCallbackDelegate element;
+
+
+ public Task( ISourceElementCallbackDelegate element, int referenceCount, boolean distinct )
+ {
+ this.element = element;
+ this.count = referenceCount;
+ this.unique = distinct;
+ }
+
+ public Task( ISourceElementCallbackDelegate element, int referenceCount )
+ {
+ this( element, referenceCount, true );
+ }
+
+ public Task( ISourceElementCallbackDelegate element )
+ {
+ this( element, 1, false );
+ }
+
+ /**
+ * @return
+ */
+ public int getCount()
+ {
+ return count;
+ }
+
+ /**
+ * @return
+ */
+ public ISourceElementCallbackDelegate getElement()
+ {
+ return element;
+ }
+
+ /**
+ * @return
+ */
+ public boolean isUnique()
+ {
+ return unique;
+ }
+
+ }
+
+ protected void assertReferenceTask( Task task )
+ {
+ assertReferences( task.getElement(), task.getCount(), task.isUnique() );
+ }
+
+ protected void assertAllReferences( int count, List tasks )
+ {
+ assertEquals( callback.getReferences().size(), count );
+ if( tasks == null ) return;
+ Iterator i = tasks.iterator();
+ while( i.hasNext() )
+ {
+ assertReferenceTask( (Task)i.next() );
+ }
+ }
+
+ protected List createTaskList( Task t1 )
+ {
+ List result = new ArrayList();
+ result.add( t1 );
+ return result;
+ }
+
+ protected List createTaskList( Task t1, Task t2 )
+ {
+ List result = createTaskList(t1);
+ result.add( t2 );
+ return result;
+ }
+
+ protected List createTaskList( Task t1, Task t2, Task t3 )
+ {
+ List result = createTaskList(t1, t2);
+ result.add( t3 );
+ return result;
+ }
+
+ protected List createTaskList( Task t1, Task t2, Task t3, Task t4 )
+ {
+ List result = createTaskList(t1, t2, t3);
+ result.add( t4 );
+ return result;
+ }
+
+ protected List createTaskList( Task t1, Task t2, Task t3, Task t4, Task t5 )
+ {
+ List result = createTaskList(t1, t2, t3, t4);
+ result.add( t5 );
+ return result;
+ }
+ /**
+ * @param task
+ * @param task2
+ * @param task3
+ * @param task4
+ * @param task5
+ * @param task6
+ * @return
+ */
+ protected List createTaskList(Task task, Task task2, Task task3, Task task4, Task task5, Task task6)
+ {
+ List result = createTaskList( task, task2, task3, task4, task5 );
+ result.add( task6 );
+ return result;
+ }
+
+
}
Index: parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java,v
retrieving revision 1.20
diff -u -r1.20 QuickParseASTTests.java
--- parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java 23 Sep 2003 20:46:12 -0000 1.20
+++ parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java 23 Sep 2003 22:50:31 -0000
@@ -1431,7 +1431,7 @@
assertFalse( enumerators.hasNext() );
assertEquals( enumerator.getName(), "isPointer");
assertEquals( enumerator.getInitialValue().getExpressionKind(), IASTExpression.Kind.ID_EXPRESSION );
- assertEquals( enumerator.getInitialValue().getTypeIdString(), "PointerTraits<T>::result");
+ assertEquals( enumerator.getInitialValue().getIdExpression(), "PointerTraits<T>::result");
}
public void testBug36690() throws Exception {
@@ -1814,7 +1814,9 @@
public void testBug39556() throws Exception
{
parse("int *restrict ip_fn (void);", true, true, ParserLanguage.C).getDeclarations().next();
- }
+
+ }
+
/**
* Test code: struct Example { Example(); Example(int); ~Example();};
* Purpose: tests a declaration in a class scope.
@@ -1842,4 +1844,5 @@
assertTrue(m2.getVisiblity() == ASTAccessVisibility.PUBLIC);
assertTrue(m3.getVisiblity() == ASTAccessVisibility.PUBLIC);
}
+
}
Index: parser/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/ChangeLog,v
retrieving revision 1.134
diff -u -r1.134 ChangeLog
--- parser/ChangeLog 23 Sep 2003 20:46:17 -0000 1.134
+++ parser/ChangeLog 23 Sep 2003 22:49:56 -0000
@@ -1,3 +1,7 @@
+2003-09-23 John Camelon
+ Fixed Bug 43084 : need to restructure TypeId to allow dynamic_cast<> type expression references.
+ Fixed Bug 39504 : sizeof-expressions are not handled properly
+
2003-09-23 Hoda Amer
Solution to bug#43373: No reference to static member in definition
Solution to bug#43371: constructor incorrectly marked private
Index: parser/org/eclipse/cdt/core/parser/ast/IASTExpression.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTExpression.java,v
retrieving revision 1.8
diff -u -r1.8 IASTExpression.java
--- parser/org/eclipse/cdt/core/parser/ast/IASTExpression.java 15 Sep 2003 13:20:30 -0000 1.8
+++ parser/org/eclipse/cdt/core/parser/ast/IASTExpression.java 23 Sep 2003 22:49:56 -0000
@@ -121,7 +121,7 @@
}
- public interface IASTNewExpressionDescriptor
+ public interface IASTNewExpressionDescriptor extends ISourceElementCallbackDelegate
{
public Iterator getNewPlacementExpressions();
public Iterator getNewTypeIdExpressions();
@@ -135,9 +135,11 @@
public IASTExpression getRHSExpression();
public IASTExpression getThirdExpression();
public String getLiteralString();
- public String getTypeIdString();
+ public String getIdExpression();
+ public IASTTypeId getTypeId();
public IASTNewExpressionDescriptor getNewExpressionDescriptor();
public int evaluateExpression() throws ExpressionEvaluationException;
+ public void reconcileReferences() throws ASTNotImplementedException;
}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java,v
retrieving revision 1.33
diff -u -r1.33 IASTFactory.java
--- parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java 23 Sep 2003 20:46:18 -0000 1.33
+++ parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java 23 Sep 2003 22:49:57 -0000
@@ -102,8 +102,8 @@
IASTExpression lhs,
IASTExpression rhs,
IASTExpression thirdExpression,
- ITokenDuple typeId,
- String literal, IASTNewExpressionDescriptor newDescriptor) throws ASTSemanticException;
+ IASTTypeId typeId,
+ ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) throws ASTSemanticException;
public IASTExpression.IASTNewExpressionDescriptor createNewDescriptor(List newPlacementExpressions,List newTypeIdExpressions,List newInitializerExpressions);
public IASTInitializerClause createInitializerClause(
IASTInitializerClause.Kind kind,
@@ -200,5 +200,9 @@
* @return
*/
public IASTCodeScope createNewCodeBlock(IASTScope scope);
+
+ public IASTTypeId createTypeId( IASTScope scope, IASTSimpleTypeSpecifier.Type kind, boolean isConst, boolean isVolatile, boolean isShort,
+ boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename, ITokenDuple name, List pointerOps, List arrayMods ) throws ASTSemanticException;
+
}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTTypeId.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTTypeId.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTTypeId.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTTypeId.java 23 Sep 2003 22:49:57 -0000
@@ -0,0 +1,40 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 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
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+import java.util.Iterator;
+
+import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
+import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTTypeId extends ISourceElementCallbackDelegate
+{
+ public IASTSimpleTypeSpecifier.Type getKind();
+ public String getTypeOrClassName();
+ public Iterator getPointerOperators();
+ public Iterator getArrayModifiers();
+
+ public boolean isConst();
+ public boolean isVolatile();
+ public boolean isLong();
+ public boolean isShort();
+ public boolean isSigned();
+ public boolean isUnsigned();
+ public boolean isTypename();
+
+
+ public String getFullSignature() throws ASTNotImplementedException;
+ public ISymbol getTypeSymbol() throws ASTNotImplementedException;
+}
Index: parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java,v
retrieving revision 1.20
diff -u -r1.20 DeclarationWrapper.java
--- parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java 23 Sep 2003 20:46:17 -0000 1.20
+++ parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java 23 Sep 2003 22:49:57 -0000
@@ -348,7 +348,7 @@
{
Declarator d = declarator.getOwnedDeclarator();
- Iterator i = d.getPtrOps().iterator();
+ Iterator i = d.getPointerOperators().iterator();
if( !i.hasNext() )
{
boolean isWithinClass = scope instanceof IASTClassSpecifier;
@@ -375,7 +375,7 @@
List convertedParms = createParameterList( declarator.getParameters() );
IASTAbstractDeclaration abs = astFactory.createAbstractDeclaration(
- constt, volatil, getTypeSpecifier(), declarator.getPtrOps(), declarator.getArrayModifiers(),
+ constt, volatil, getTypeSpecifier(), declarator.getPointerOperators(), declarator.getArrayModifiers(),
convertedParms, (ASTPointerOperator)i.next() );
String name = ( d.getPointerOperatorNameDuple() != null ) ? d.getPointerOperatorNameDuple().toString() + d.getName() : d.getName();
if( typedef )
@@ -407,7 +407,7 @@
constt,
volatil,
getTypeSpecifier(),
- declarator.getPtrOps(), declarator.getArrayModifiers(), null, null), startingOffset, declarator.getNameStartOffset());
+ declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null), startingOffset, declarator.getNameStartOffset());
}
/**
* @param declarator
@@ -425,7 +425,7 @@
constt,
volatil,
getTypeSpecifier(),
- declarator.getPtrOps(), declarator.getArrayModifiers(), null, null),
+ declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
declarator.getExceptionSpecification(),
inline,
friend,
@@ -455,7 +455,7 @@
constt,
volatil,
getTypeSpecifier(),
- declarator.getPtrOps(), declarator.getArrayModifiers(), null, null),
+ declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
declarator.getExceptionSpecification(),
inline,
friend,
@@ -486,7 +486,7 @@
constt,
volatil,
getTypeSpecifier(),
- declarator.getPtrOps(), declarator.getArrayModifiers(), null, null),
+ declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
mutable,
extern,
register,
@@ -511,7 +511,7 @@
wrapper.isConst(),
wrapper.isVolatile(),
wrapper.getTypeSpecifier(),
- declarator.getPtrOps(),
+ declarator.getPointerOperators(),
declarator.getArrayModifiers(),
null, null, declarator.getName() == null
? ""
@@ -536,7 +536,7 @@
constt,
volatil,
getTypeSpecifier(),
- declarator.getPtrOps(), declarator.getArrayModifiers(), null, null),
+ declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
mutable,
extern,
register,
Index: parser/org/eclipse/cdt/internal/core/parser/Declarator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Declarator.java,v
retrieving revision 1.10
diff -u -r1.10 Declarator.java
--- parser/org/eclipse/cdt/internal/core/parser/Declarator.java 15 Sep 2003 19:04:43 -0000 1.10
+++ parser/org/eclipse/cdt/internal/core/parser/Declarator.java 23 Sep 2003 22:49:57 -0000
@@ -27,7 +27,7 @@
* @author jcamelon
*
*/
-public class Declarator implements IParameterCollection, IDeclaratorOwner
+public class Declarator implements IParameterCollection, IDeclaratorOwner, IDeclarator
{
private ITokenDuple pointerOperatorNameDuple;
private ITokenDuple namedDuple;
@@ -116,12 +116,12 @@
/**
* @return
*/
- public List getPtrOps()
+ public List getPointerOperators()
{
return Collections.unmodifiableList( ptrOps );
}
- public void addPtrOp( ASTPointerOperator ptrOp )
+ public void addPointerOperator( ASTPointerOperator ptrOp )
{
ptrOps.add( ptrOp );
}
@@ -362,7 +362,7 @@
public DeclarationWrapper getDeclarationWrapper()
{
Declarator d = this;
- while( d.getOwner() instanceof Declarator )
+ while( d.getOwner() instanceof IDeclarator )
d = (Declarator)d.getOwner();
return (DeclarationWrapper)d.getOwner();
}
Index: parser/org/eclipse/cdt/internal/core/parser/IDeclarator.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/IDeclarator.java
diff -N parser/org/eclipse/cdt/internal/core/parser/IDeclarator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/IDeclarator.java 23 Sep 2003 22:49:57 -0000
@@ -0,0 +1,44 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 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
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser;
+import java.util.List;
+
+import org.eclipse.cdt.core.parser.ITokenDuple;
+import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
+import org.eclipse.cdt.core.parser.ast.IASTArrayModifier;
+/**
+ * @author jcamelon
+ *
+ */
+public interface IDeclarator
+{
+ /**
+ * @return
+ */
+ public abstract List getPointerOperators();
+ public abstract void addPointerOperator(ASTPointerOperator ptrOp);
+ /**
+ * @param arrayMod
+ */
+ public abstract void addArrayModifier(IASTArrayModifier arrayMod);
+ /**
+ * @return
+ */
+ public abstract List getArrayModifiers();
+
+ /**
+ * @param nameDuple
+ */
+ public void setPointerOperatorName(ITokenDuple nameDuple);
+
+ public ITokenDuple getPointerOperatorNameDuple();
+
+}
\ No newline at end of file
Index: parser/org/eclipse/cdt/internal/core/parser/Parser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java,v
retrieving revision 1.111
diff -u -r1.111 Parser.java
--- parser/org/eclipse/cdt/internal/core/parser/Parser.java 15 Sep 2003 22:50:25 -0000 1.111
+++ parser/org/eclipse/cdt/internal/core/parser/Parser.java 23 Sep 2003 22:49:59 -0000
@@ -52,6 +52,7 @@
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter;
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
+import org.eclipse.cdt.core.parser.ast.IASTTypeId;
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
@@ -521,7 +522,7 @@
: IASTTemplateParameter.ParamKind.TYPENAME;
IToken id = null;
- ITokenDuple typeId = null;
+ IASTTypeId typeId = null;
try
{
if (LT(1) == IToken.tIDENTIFIER) // optional identifier
@@ -531,7 +532,7 @@
if (LT(1) == IToken.tASSIGN) // optional = type-id
{
consume(IToken.tASSIGN);
- typeId = typeId(); // type-id
+ typeId = typeId(scope, false); // type-id
}
}
@@ -544,7 +545,7 @@
astFactory.createTemplateParameter(
kind,
( id == null )? "" : id.getImage(),
- (typeId == null) ? null : typeId.toString(),
+ (typeId == null) ? null : typeId.getTypeOrClassName(),
null,
null));
@@ -558,7 +559,7 @@
consume(IToken.tGT);
consume(IToken.t_class);
IToken optionalId = null;
- ITokenDuple optionalTypeId = null;
+ IASTTypeId optionalTypeId = null;
if (LT(1) == IToken.tIDENTIFIER) // optional identifier
{
optionalId = identifier();
@@ -566,7 +567,7 @@
if (LT(1) == IToken.tASSIGN) // optional = type-id
{
consume(IToken.tASSIGN);
- optionalTypeId = typeId();
+ optionalTypeId = typeId(scope, false);
}
}
@@ -601,7 +602,7 @@
wrapper.isConst(),
wrapper.isVolatile(),
wrapper.getTypeSpecifier(),
- declarator.getPtrOps(),
+ declarator.getPointerOperators(),
declarator.getArrayModifiers(),
null, null, declarator.getName() == null
? ""
@@ -1732,7 +1733,7 @@
* @throws Backtrack
*/
protected IToken cvQualifier(
- Declarator declarator)
+ IDeclarator declarator)
throws Backtrack
{
IToken result = null;
@@ -1740,17 +1741,17 @@
{
case IToken.t_const :
result = consume( IToken.t_const );
- if( declarator != null ) declarator.addPtrOp(ASTPointerOperator.CONST_POINTER);
+ declarator.addPointerOperator(ASTPointerOperator.CONST_POINTER);
break;
case IToken.t_volatile :
result = consume( IToken.t_volatile );
- if( declarator != null ) declarator.addPtrOp(ASTPointerOperator.VOLATILE_POINTER);
+ declarator.addPointerOperator(ASTPointerOperator.VOLATILE_POINTER);
break;
case IToken.t_restrict :
if( language == ParserLanguage.C )
{
result = consume( IToken.t_restrict );
- if( declarator != null ) declarator.addPtrOp(ASTPointerOperator.RESTRICT_POINTER);
+ declarator.addPointerOperator(ASTPointerOperator.RESTRICT_POINTER);
break;
}
else
@@ -1882,7 +1883,7 @@
{
d = new Declarator(owner);
- consumePointerOperators(d, false);
+ consumePointerOperators(d);
if (LT(1) == IToken.tLPAREN)
{
@@ -2014,7 +2015,7 @@
consume(); // throw
consume(IToken.tLPAREN); // (
boolean done = false;
- ITokenDuple duple = null;
+ IASTTypeId duple = null;
while (!done)
{
switch (LT(1))
@@ -2030,7 +2031,7 @@
String image = LA(1).getImage();
try
{
- duple = typeId();
+ duple = typeId(scope, false);
exceptionSpecIds.add(duple);
}
catch (Backtrack e)
@@ -2120,21 +2121,7 @@
}
break;
case IToken.tLBRACKET :
- while (LT(1) == IToken.tLBRACKET)
- {
- consume(); // eat the '['
-
- IASTExpression exp = null;
- if (LT(1) != IToken.tRBRACKET)
- {
- exp = constantExpression(sdw.getScope());
- }
- consume(IToken.tRBRACKET);
- IASTArrayModifier arrayMod =
- astFactory.createArrayModifier(exp);
- d.addArrayModifier(arrayMod);
-
- }
+ consumeArrayModifiers(d, sdw.getScope());
continue;
case IToken.tCOLON :
consume(IToken.tCOLON);
@@ -2151,10 +2138,30 @@
}
while (true);
- if (d.getOwner() instanceof Declarator)
+ if (d.getOwner() instanceof IDeclarator)
((Declarator)d.getOwner()).setOwnedDeclarator(d);
return d;
}
+
+ protected void consumeArrayModifiers( IDeclarator d, IASTScope scope )
+ throws EndOfFile, Backtrack
+ {
+ while (LT(1) == IToken.tLBRACKET)
+ {
+ consume( IToken.tLBRACKET ); // eat the '['
+
+ IASTExpression exp = null;
+ if (LT(1) != IToken.tRBRACKET)
+ {
+ exp = constantExpression(scope);
+ }
+ consume(IToken.tRBRACKET);
+ IASTArrayModifier arrayMod =
+ astFactory.createArrayModifier(exp);
+ d.addArrayModifier(arrayMod);
+ }
+ }
+
protected void operatorId(
Declarator d,
IToken originalToken)
@@ -2195,21 +2202,8 @@
else
{
// must be a conversion function
- toSend = typeId().getLastToken();
-
- try
- {
- // this ptrOp doesn't belong to the declarator,
- // it's just a part of the name
- IToken temp = consumePointerOperators(d, true);
- if( temp != null )
- toSend = temp;
- }
- catch (Backtrack b)
- {
- }
- // In case we'll need better error recovery
- // while( LT(1) != Token.tLPAREN ) { toSend = consume(); }
+ typeId(d.getDeclarationWrapper().getScope(), false );
+ toSend = lastToken;
}
ITokenDuple duple =
new TokenDuple(
@@ -2229,7 +2223,7 @@
* @param owner Declarator that this pointer operator corresponds to.
* @throws Backtrack request a backtrack
*/
- protected IToken consumePointerOperators(Declarator d, boolean consumeOnlyOne) throws Backtrack
+ protected IToken consumePointerOperators(IDeclarator d) throws Backtrack
{
IToken result = null;
for( ; ; )
@@ -2237,9 +2231,9 @@
if (LT(1) == IToken.tAMPER)
{
result = consume( IToken.tAMPER );
- if( d != null ) d.addPtrOp(ASTPointerOperator.REFERENCE);
- /*if( consumeOnlyOne ) */return result;
- /* continue; */
+ d.addPointerOperator(ASTPointerOperator.REFERENCE);
+ return result;
+
}
IToken mark = mark();
@@ -2260,7 +2254,7 @@
{
result = consume(Token.tSTAR); // tokenType = "*"
- if( d != null ) d.setPointerOperatorName(nameDuple);
+ d.setPointerOperatorName(nameDuple);
IToken successful = null;
for (;;)
@@ -2273,9 +2267,8 @@
if( successful == null )
{
- if( d != null ) d.addPtrOp( ASTPointerOperator.POINTER );
+ d.addPointerOperator( ASTPointerOperator.POINTER );
}
- if( consumeOnlyOne ) return result;
continue;
}
backup(mark);
@@ -2871,7 +2864,7 @@
secondExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -2972,7 +2965,7 @@
assignmentExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3005,7 +2998,7 @@
null,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3037,7 +3030,7 @@
secondExpression,
thirdExpression,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3071,7 +3064,7 @@
secondExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3103,7 +3096,7 @@
secondExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3136,7 +3129,7 @@
secondExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3169,7 +3162,7 @@
secondExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3201,7 +3194,7 @@
secondExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3241,7 +3234,7 @@
secondExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3317,7 +3310,7 @@
secondExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3360,7 +3353,7 @@
secondExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3402,7 +3395,7 @@
secondExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3455,7 +3448,7 @@
secondExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3496,7 +3489,7 @@
secondExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3521,13 +3514,11 @@
{
IToken mark = mark();
consume();
- ITokenDuple duple = null;
+ IASTTypeId typeId = null;
// If this isn't a type name, then we shouldn't be here
try
{
- if (LT(1) == IToken.t_const)
- consume();
- duple = typeId();
+ typeId = typeId(scope, false);
consume(IToken.tRPAREN);
IASTExpression castExpression = castExpression(scope);
try
@@ -3538,8 +3529,8 @@
castExpression,
null,
null,
- duple,
- "", null);
+ typeId,
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3558,56 +3549,119 @@
/**
* @throws Backtrack
*/
- protected ITokenDuple typeId( ) throws Backtrack
+ protected IASTTypeId typeId(IASTScope scope, boolean forNewExpression ) throws Backtrack
{
- IToken begin = LA(1);
- IToken end = null;
- try
- {
- ITokenDuple d = name();
- IToken checkForPtrs = consumePointerOperators(null, false);
- if( checkForPtrs == null ) return d;
- return new TokenDuple( d.getFirstToken(), checkForPtrs );
- }
- catch (Backtrack b)
- {
+ IToken mark = mark();
+ ITokenDuple name = null;
+ boolean isConst = false, isVolatile = false;
+ boolean isSigned = false, isUnsigned = false;
+ boolean isShort = false, isLong = false;
+ boolean isTypename = false;
+
+ IASTSimpleTypeSpecifier.Type kind = null;
+ do
+ {
+ try
+ {
+ name = name();
+ kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
+ break;
+ }
+ catch (Backtrack b)
+ {
+ // do nothing
+ }
+
simpleMods : for (;;)
{
switch (LT(1))
{
case IToken.t_signed :
+ consume();
+ isSigned = true;
+ break;
+
case IToken.t_unsigned :
+ consume();
+ isUnsigned = true;
+ break;
+
case IToken.t_short :
+ consume();
+ isShort = true;
+ break;
+
case IToken.t_long :
+ consume();
+ isLong = true;
+ break;
+
case IToken.t_const :
+ consume();
+ isConst = true;
+ break;
+
case IToken.t_volatile :
- end = consume();
+ consume();
+ isVolatile = true;
break;
- case IToken.tAMPER :
- case IToken.tSTAR :
+
case IToken.tIDENTIFIER :
- if (end == null)
- throw backtrack;
- end = consume();
- break;
+ name = name();
+ kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
+ break simpleMods;
+
case IToken.t_int :
+ kind = IASTSimpleTypeSpecifier.Type.INT;
+ consume();
+ break simpleMods;
+
case IToken.t_char :
+ kind = IASTSimpleTypeSpecifier.Type.CHAR;
+ consume();
+ break simpleMods;
+
case IToken.t_bool :
+ kind = IASTSimpleTypeSpecifier.Type.BOOL;
+ consume();
+ break simpleMods;
+
case IToken.t_double :
+ kind = IASTSimpleTypeSpecifier.Type.DOUBLE;
+ consume();
+ break simpleMods;
+
case IToken.t_float :
+ kind = IASTSimpleTypeSpecifier.Type.FLOAT;
+ consume();
+ break simpleMods;
+
case IToken.t_wchar_t :
+ kind = IASTSimpleTypeSpecifier.Type.WCHAR_T;
+ consume();
+ break simpleMods;
+
+
case IToken.t_void :
- end = consume();
+ kind = IASTSimpleTypeSpecifier.Type.VOID;
+ consume();
+ break simpleMods;
+
+
default :
break simpleMods;
}
}
- if (end != null)
- {
- IToken end2 = consumePointerOperators(null, false);
- return new TokenDuple(begin, end2 == null ? end : end2);
- }
- else if (
+
+ if( kind != null ) break;
+
+ if( isShort || isLong || isUnsigned || isSigned )
+ {
+ kind = IASTSimpleTypeSpecifier.Type.INT;
+ break;
+ }
+
+ if (
LT(1) == IToken.t_typename
|| LT(1) == IToken.t_struct
|| LT(1) == IToken.t_class
@@ -3615,12 +3669,42 @@
|| LT(1) == IToken.t_union)
{
consume();
- ITokenDuple d = name();
- IToken end2 = consumePointerOperators(null, false);
- return new TokenDuple(begin, ( (end2 == null) ? d.getLastToken() : end2 ) );
+ try
+ {
+ name = name();
+ kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
+ } catch( Backtrack b )
+ {
+ backup( mark );
+ throw backtrack;
+ }
}
- else
- throw backtrack;
+
+ } while( false );
+
+ if( kind == null )
+ throw backtrack;
+
+ TypeId id = new TypeId();
+ IToken last = mark();
+ consumePointerOperators( id );
+ if( lastToken == null ) lastToken = last;
+
+ if( ! forNewExpression )
+ {
+ last = mark();
+ consumeArrayModifiers( id, scope );
+ if( lastToken == null ) lastToken = last;
+ }
+
+ try
+ {
+ return astFactory.createTypeId( scope, kind, isConst, isVolatile, isShort, isLong, isSigned, isUnsigned, isTypename, name, id.getPointerOperators(), id.getArrayModifiers());
+ }
+ catch (ASTSemanticException e)
+ {
+ backup( mark );
+ throw backtrack;
}
}
/**
@@ -3656,7 +3740,7 @@
null,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3692,7 +3776,7 @@
boolean placementParseFailure = true;
IToken beforeSecondParen = null;
IToken backtrackMarker = null;
- ITokenDuple typeId = null;
+ IASTTypeId typeId = null;
ArrayList newPlacementExpressions = new ArrayList();
ArrayList newTypeIdExpressions = new ArrayList();
ArrayList newInitializerExpressions = new ArrayList();
@@ -3724,7 +3808,7 @@
// CASE: new (typeid-not-looking-as-placement) ...
// the first expression in () is not a placement
// - then it has to be typeId
- typeId = typeId();
+ typeId = typeId(scope, true );
consume(IToken.tRPAREN);
}
else
@@ -3748,7 +3832,7 @@
try
{
backtrackMarker = mark();
- typeId = typeId();
+ typeId = typeId(scope, true);
}
catch (Backtrack e)
{
@@ -3767,7 +3851,7 @@
// The problem is, the first expression might as well be a typeid
try
{
- typeId = typeId();
+ typeId = typeId(scope, true);
consume(IToken.tRPAREN);
if (LT(1) == IToken.tLPAREN
|| LT(1) == IToken.tLBRACKET)
@@ -3788,8 +3872,8 @@
{
return astFactory.createExpression(
scope, IASTExpression.Kind.NEW_TYPEID,
- null, null, null, typeId, "",
- astFactory.createNewDescriptor(newPlacementExpressions, newTypeIdExpressions, newInitializerExpressions));
+ null, null, null, typeId, null,
+ "", astFactory.createNewDescriptor(newPlacementExpressions, newTypeIdExpressions, newInitializerExpressions));
}
catch (ASTSemanticException e)
{
@@ -3812,7 +3896,7 @@
// CASE: new typeid ...
// new parameters do not start with '('
// i.e it has to be a plain typeId
- typeId = typeId();
+ typeId = typeId(scope, true);
}
while (LT(1) == IToken.tLBRACKET)
{
@@ -3833,8 +3917,8 @@
{
return astFactory.createExpression(
scope, IASTExpression.Kind.NEW_TYPEID,
- null, null, null, typeId, "",
- astFactory.createNewDescriptor(newPlacementExpressions, newTypeIdExpressions, newInitializerExpressions));
+ null, null, null, typeId, null,
+ "", astFactory.createNewDescriptor(newPlacementExpressions, newTypeIdExpressions, newInitializerExpressions));
}
catch (ASTSemanticException e)
{
@@ -3856,7 +3940,7 @@
null,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3908,14 +3992,14 @@
case IToken.t_sizeof :
consume(IToken.t_sizeof);
IToken mark = LA(1);
- ITokenDuple d = null;
+ IASTTypeId d = null;
IASTExpression unaryExpression = null;
if (LT(1) == IToken.tLPAREN)
{
try
{
consume(IToken.tLPAREN);
- d = typeId();
+ d = typeId(scope, false);
consume(IToken.tRPAREN);
}
catch (Backtrack bt)
@@ -3938,7 +4022,7 @@
null,
null,
d,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -3955,7 +4039,7 @@
null,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e1)
{
@@ -4072,10 +4156,10 @@
consume(IToken.tLPAREN);
boolean isTypeId = true;
IASTExpression lhs = null;
- ITokenDuple typeId = null;
+ IASTTypeId typeId = null;
try
{
- typeId = typeId();
+ typeId = typeId(scope, false);
}
catch (Backtrack b)
{
@@ -4095,7 +4179,7 @@
null,
null,
typeId,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e6)
{
@@ -4126,7 +4210,7 @@
secondExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e2)
{
@@ -4149,7 +4233,7 @@
secondExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e3)
{
@@ -4169,7 +4253,7 @@
null,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e1)
{
@@ -4189,7 +4273,7 @@
null,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e4)
{
@@ -4218,7 +4302,7 @@
secondExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e5)
{
@@ -4247,7 +4331,7 @@
secondExpression,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -4266,7 +4350,7 @@
{
consume();
consume(IToken.tLT);
- ITokenDuple duple = typeId();
+ IASTTypeId duple = typeId(scope, false);
consume(IToken.tGT);
consume(IToken.tLPAREN);
IASTExpression lhs = expression(scope);
@@ -4280,7 +4364,7 @@
null,
null,
duple,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -4305,7 +4389,7 @@
null,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
@@ -4335,7 +4419,7 @@
null,
null,
null,
- t.getImage(), null);
+ null, t.getImage(), null);
}
catch (ASTSemanticException e1)
{
@@ -4353,7 +4437,7 @@
null,
null,
null,
- t.getImage(), null);
+ null, t.getImage(), null);
}
catch (ASTSemanticException e2)
{
@@ -4365,7 +4449,7 @@
t = consume();
try
{
- return astFactory.createExpression( scope, IASTExpression.Kind.PRIMARY_STRING_LITERAL, null, null, null, null, t.getImage(), null );
+ return astFactory.createExpression( scope, IASTExpression.Kind.PRIMARY_STRING_LITERAL, null, null, null, null, null, t.getImage(), null );
}
catch (ASTSemanticException e5)
{
@@ -4385,7 +4469,7 @@
null,
null,
null,
- t.getImage(), null);
+ null, t.getImage(), null);
}
catch (ASTSemanticException e3)
{
@@ -4406,7 +4490,7 @@
null,
null,
null,
- t.getImage(), null);
+ null, t.getImage(), null);
}
catch (ASTSemanticException e4)
{
@@ -4425,7 +4509,7 @@
null,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e7)
{
@@ -4445,7 +4529,7 @@
null,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e6)
{
@@ -4454,7 +4538,7 @@
}
case IToken.tIDENTIFIER :
case IToken.tCOLONCOLON :
- ITokenDuple duple = name();
+ ITokenDuple duple = name();
//TODO should be an ID Expression really
try
{
@@ -4464,8 +4548,8 @@
null,
null,
null,
- duple,
- "", null);
+ null,
+ duple, "", null);
}
catch (ASTSemanticException e8)
{
@@ -4482,7 +4566,7 @@
null,
null,
null,
- "", null);
+ null, "", null);
}
catch (ASTSemanticException e)
{
Index: parser/org/eclipse/cdt/internal/core/parser/TypeId.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/TypeId.java
diff -N parser/org/eclipse/cdt/internal/core/parser/TypeId.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/TypeId.java 23 Sep 2003 22:49:59 -0000
@@ -0,0 +1,79 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 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
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.parser.ITokenDuple;
+import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
+import org.eclipse.cdt.core.parser.ast.IASTArrayModifier;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class TypeId implements IDeclarator
+{
+ private ITokenDuple name;
+ private List arrayModifiers = new ArrayList();
+ private List pointerOperators = new ArrayList();
+ /**
+ *
+ */
+ public TypeId()
+ {
+ super();
+
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.IDeclarator#getPointerOperators()
+ */
+ public List getPointerOperators()
+ {
+ return pointerOperators;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.IDeclarator#addPointerOperator(org.eclipse.cdt.core.parser.ast.ASTPointerOperator)
+ */
+ public void addPointerOperator(ASTPointerOperator ptrOp)
+ {
+ pointerOperators.add( ptrOp );
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.IDeclarator#addArrayModifier(org.eclipse.cdt.core.parser.ast.IASTArrayModifier)
+ */
+ public void addArrayModifier(IASTArrayModifier arrayMod)
+ {
+ arrayModifiers.add( arrayMod );
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.IDeclarator#getArrayModifiers()
+ */
+ public List getArrayModifiers()
+ {
+ return arrayModifiers;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.IDeclarator#setPointerOperatorName(org.eclipse.cdt.core.parser.ITokenDuple)
+ */
+ public void setPointerOperatorName(ITokenDuple nameDuple)
+ {
+ name = nameDuple;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.IDeclarator#getPointerOperatorNameDuple()
+ */
+ public ITokenDuple getPointerOperatorNameDuple()
+ {
+ return name;
+ }
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTExpression.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTExpression.java,v
retrieving revision 1.3
diff -u -r1.3 ASTExpression.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTExpression.java 4 Sep 2003 14:39:15 -0000 1.3
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTExpression.java 23 Sep 2003 22:49:59 -0000
@@ -11,12 +11,16 @@
package org.eclipse.cdt.internal.core.parser.ast.complete;
import java.util.ArrayList;
+import java.util.Iterator;
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.ExpressionEvaluationException;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
+import org.eclipse.cdt.core.parser.ast.IASTReference;
+import org.eclipse.cdt.core.parser.ast.IASTTypeId;
/**
* @author jcamelon
@@ -28,8 +32,9 @@
private final IASTExpression lhs;
private final IASTExpression rhs;
private final IASTExpression thirdExpression;
- private final String literal;
- private final ITokenDuple typeId;
+ private final String literal, idExpression;
+ private ITokenDuple idExpressionDuple;
+ private final IASTTypeId typeId;
private final IASTNewExpressionDescriptor newDescriptor;
private final List references;
private List resultType;
@@ -37,7 +42,7 @@
*
*/
public ASTExpression( Kind kind, IASTExpression lhs, IASTExpression rhs,
- IASTExpression thirdExpression, ITokenDuple typeId, String literal, IASTNewExpressionDescriptor newDescriptor, List references )
+ IASTExpression thirdExpression, IASTTypeId typeId, ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor, List references )
{
this.kind = kind;
this.lhs = lhs;
@@ -48,6 +53,8 @@
this.newDescriptor = newDescriptor;
this.references = references;
resultType = new ArrayList();
+ this.idExpressionDuple = idExpression;
+ this.idExpression = idExpressionDuple == null ? "" : idExpressionDuple.toString();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#getExpressionKind()
@@ -87,16 +94,17 @@
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#getTypeId()
*/
- public String getTypeIdString()
+ public IASTTypeId getTypeId()
{
- return typeId == null ? "" : typeId.toString();
+ return typeId;
}
/*
* returns the type id token
*/
- public ITokenDuple getTypeId()
+ public ITokenDuple getTypeIdTokenDuple()
{
- return typeId;
+ if( typeId == null ) return null;
+ return ((ASTTypeId)typeId).getTokenDuple();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#getNewExpressionDescriptor()
@@ -122,12 +130,33 @@
*/
public void acceptElement(ISourceElementRequestor requestor)
{
+ try
+ {
+ reconcileReferences();
+ }
+ catch (ASTNotImplementedException e)
+ {
+ // will not get thrown
+ }
if( ! references.isEmpty() )
- {
- ASTReferenceStore store = new ASTReferenceStore( references );
- store.processReferences(requestor);
- }
+ new ASTReferenceStore( references ).processReferences(requestor);
+
+ if( typeId != null )
+ typeId.acceptElement(requestor);
+
+ if( lhs != null )
+ lhs.acceptElement(requestor);
+
+ if( rhs!= null )
+ rhs.acceptElement(requestor);
+
+ if( thirdExpression != null )
+ thirdExpression.acceptElement(requestor);
+
+ if( newDescriptor != null )
+ newDescriptor.acceptElement(requestor);
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
*/
@@ -154,5 +183,48 @@
public void setResultType(List i) {
resultType = i;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTExpression#getIdExpression()
+ */
+ public String getIdExpression()
+ {
+ return idExpression;
+ }
+ /**
+ * @return
+ */
+ public ITokenDuple getIdExpressionTokenDuple()
+ {
+ return idExpressionDuple;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTExpression#reconcileReferences()
+ */
+ public void reconcileReferences() throws ASTNotImplementedException
+ {
+ if( lhs != null )
+ lhs.reconcileReferences();
+ if( rhs != null )
+ rhs.reconcileReferences();
+ if( thirdExpression != null )
+ thirdExpression.reconcileReferences();
+
+ reconcileSubExpression((ASTExpression)lhs);
+ reconcileSubExpression((ASTExpression)rhs);
+ reconcileSubExpression((ASTExpression)thirdExpression);
+ }
+ protected void reconcileSubExpression(ASTExpression subExpression)
+ {
+ if( subExpression != null && subExpression.getReferences() != null )
+ {
+ Iterator subExp = subExpression.getReferences().iterator();
+ while( subExp.hasNext() )
+ {
+ IASTReference aReference = (IASTReference)subExp.next();
+ if( aReference != null && references.contains( aReference ) )
+ subExp.remove();
+ }
+ }
+ }
}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTNewDescriptor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTNewDescriptor.java,v
retrieving revision 1.2
diff -u -r1.2 ASTNewDescriptor.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTNewDescriptor.java 25 Aug 2003 15:41:30 -0000 1.2
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTNewDescriptor.java 23 Sep 2003 22:49:59 -0000
@@ -13,6 +13,8 @@
import java.util.Iterator;
import java.util.List;
+import org.eclipse.cdt.core.parser.ISourceElementRequestor;
+import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
/**
@@ -46,5 +48,43 @@
public Iterator getNewInitializerExpressions() {
return newInitializerExpressions.iterator();
}
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void acceptElement(ISourceElementRequestor requestor)
+ {
+ accept( requestor, getNewPlacementExpressions() );
+ accept( requestor, getNewTypeIdExpressions() );
+ accept( requestor, getNewInitializerExpressions() );
+ }
+
+
+ /**
+ * @param requestor
+ * @param iterator
+ */
+ protected void accept(ISourceElementRequestor requestor, Iterator iterator)
+ {
+ while( iterator.hasNext() )
+ ((IASTExpression)iterator.next()).acceptElement(requestor);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void enterScope(ISourceElementRequestor requestor)
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void exitScope(ISourceElementRequestor requestor)
+ {
+ }
}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTReference.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTReference.java,v
retrieving revision 1.1
diff -u -r1.1 ASTReference.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTReference.java 22 Jul 2003 00:23:56 -0000 1.1
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTReference.java 23 Sep 2003 22:49:59 -0000
@@ -43,4 +43,17 @@
{
return name;
}
+
+ public boolean equals(Object obj)
+ {
+ if( obj == null )
+ return false;
+ if( ! (obj instanceof IASTReference ) )
+ return false;
+
+ if( ((IASTReference)obj).getName().equals( getName() ) &&
+ ((IASTReference)obj).getOffset() == getOffset() )
+ return true;
+ return false;
+ }
}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTTypeId.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTTypeId.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTTypeId.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTTypeId.java 23 Sep 2003 22:49:59 -0000
@@ -0,0 +1,229 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 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
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.complete;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+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.IASTArrayModifier;
+import org.eclipse.cdt.core.parser.ast.IASTTypeId;
+import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
+import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTTypeId implements IASTTypeId
+{
+ private final boolean isTypename;
+ private final boolean isUnsigned;
+ private final boolean isSigned;
+ private final boolean isShort;
+ private final boolean isLong;
+ private final boolean isVolatile;
+ private final boolean isConst;
+ private final String signature;
+ private ITokenDuple tokenDuple;
+ private final List arrayModifiers;
+ private final String typeName;
+ private final List pointerOps;
+ private final Type kind;
+ private List references = new ArrayList();
+ private ISymbol symbol;
+
+ /**
+ *
+ */
+ public ASTTypeId( Type kind, ITokenDuple duple, List pointerOps, List arrayMods, String signature,
+ boolean isConst, boolean isVolatile, boolean isUnsigned, boolean isSigned, boolean isShort, boolean isLong, boolean isTypeName )
+ {
+ typeName = ( duple == null ) ? "" : duple.toString() ;
+ this.tokenDuple = duple;
+ this.kind = kind;
+ this.pointerOps = pointerOps;
+ this.arrayModifiers = arrayMods;
+ this.signature = signature;
+ this.isConst = isConst;
+ this.isVolatile = isVolatile;
+ this.isUnsigned = isUnsigned;
+ this.isSigned = isSigned;
+ this.isShort = isShort;
+ this.isLong = isLong;
+ this.isTypename = isTypeName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#getKind()
+ */
+ public Type getKind()
+ {
+ return kind;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#getType()
+ */
+ public String getTypeOrClassName()
+ {
+ return typeName;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#getPointerOperators()
+ */
+ public Iterator getPointerOperators()
+ {
+ return pointerOps.iterator();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#getArrayModifiers()
+ */
+ public Iterator getArrayModifiers()
+ {
+ return arrayModifiers.iterator();
+ }
+
+ public List getReferences()
+ {
+ return references;
+ }
+
+ public void finalize()
+ {
+ references.clear();
+ references = null;
+ tokenDuple = null;
+ }
+
+ public ITokenDuple getTokenDuple()
+ {
+ return tokenDuple;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#getFullSignature()
+ */
+ public String getFullSignature()
+ {
+ return signature;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#createTypeSymbol(org.eclipse.cdt.core.parser.ast.IASTFactory)
+ */
+ public ISymbol getTypeSymbol() throws ASTNotImplementedException
+ {
+ return symbol;
+ }
+
+ public void setTypeSymbol( ISymbol symbol )
+ {
+ this.symbol = symbol;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#isConst()
+ */
+ public boolean isConst()
+ {
+ return isConst;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#isVolatile()
+ */
+ public boolean isVolatile()
+ {
+ return isVolatile;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#isLong()
+ */
+ public boolean isLong()
+ {
+ return isLong;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#isShort()
+ */
+ public boolean isShort()
+ {
+ return isShort;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#isSigned()
+ */
+ public boolean isSigned()
+ {
+ return isSigned;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#isUnsigned()
+ */
+ public boolean isUnsigned()
+ {
+ return isUnsigned;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#isTypename()
+ */
+ public boolean isTypename()
+ {
+ return isTypename;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void acceptElement(ISourceElementRequestor requestor)
+ {
+ if( references != null && ! references.isEmpty() )
+ {
+ ASTReferenceStore store = new ASTReferenceStore( references );
+ store.processReferences(requestor);
+ }
+ Iterator arrayMods = getArrayModifiers();
+ while( arrayMods.hasNext() )
+ {
+ ((IASTArrayModifier)arrayMods.next()).acceptElement(requestor);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void enterScope(ISourceElementRequestor requestor)
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void exitScope(ISourceElementRequestor requestor)
+ {
+ }
+ /**
+ * @param list
+ */
+ public void addReferences(List list)
+ {
+ references.addAll( list );
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java,v
retrieving revision 1.44
diff -u -r1.44 CompleteParseASTFactory.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java 23 Sep 2003 20:46:17 -0000 1.44
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java 23 Sep 2003 22:50:00 -0000
@@ -21,12 +21,12 @@
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
+import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTArrayModifier;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
@@ -53,6 +53,7 @@
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter;
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
+import org.eclipse.cdt.core.parser.ast.IASTTypeId;
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
@@ -101,6 +102,7 @@
* Overrides an existing reference if it has the same name and offset
*/
protected void addReference(List references, IASTReference reference){
+ if( references == null ) return;
Iterator i = references.iterator();
while (i.hasNext()){
IASTReference ref = (IASTReference)i.next();
@@ -758,40 +760,22 @@
IASTExpression lhs,
IASTExpression rhs,
IASTExpression thirdExpression,
- ITokenDuple typeId,
- String literal, IASTNewExpressionDescriptor newDescriptor) throws ASTSemanticException
+ IASTTypeId typeId,
+ ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) throws ASTSemanticException
{
List references = new ArrayList();
- getExpressionReferences(lhs, references);
- getExpressionReferences(rhs, references);
- getExpressionReferences(thirdExpression,references);
-
- // add newDescriptor's references & add to references
- // if there is a newDescriptor, check related expressions
- if(newDescriptor != null){
- Iterator i = newDescriptor.getNewPlacementExpressions();
- while (i.hasNext()){
- getExpressionReferences((IASTExpression)i.next(), references);
- }
- i = newDescriptor.getNewTypeIdExpressions();
- while (i.hasNext()){
- getExpressionReferences((IASTExpression)i.next(), references);
- }
- i = newDescriptor.getNewInitializerExpressions();
- while (i.hasNext()){
- getExpressionReferences((IASTExpression)i.next(), references);
- }
- }
+
//look up id & add to references
IContainerSymbol startingScope = scopeToSymbol( scope );
//look up typeId & add to references
ISymbol symbol = null;
- if( typeId != null ){
- symbol = lookupQualifiedName( startingScope, typeId, references, false );
- }
+
+ if( idExpression != null )
+ symbol = lookupQualifiedName( startingScope, idExpression, references, false );
+
// "a.m" or "a->m : lookup m in the scope of the declaration of a
if((kind == IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION)
|| (kind == IASTExpression.Kind.POSTFIX_ARROW_IDEXPRESSION)
@@ -803,7 +787,7 @@
TypeInfo lhsInfo = (TypeInfo) ((ASTExpression)lhs).getResultType().iterator().next();
ISymbol containingScope = (ISymbol) lhsInfo.getTypeSymbol().getTypeSymbol();
if(containingScope != null){
- symbol = lookupQualifiedName((IContainerSymbol)containingScope, ((ASTExpression)rhs).getTypeId() , references, false);
+ symbol = lookupQualifiedName((IContainerSymbol)containingScope, ((ASTExpression)rhs).getIdExpressionTokenDuple(), references, false);
}
}
@@ -819,13 +803,13 @@
}
if (kind == IASTExpression.Kind.POSTFIX_FUNCTIONCALL){
- ITokenDuple functionId = ((ASTExpression)lhs).getTypeId();
+ ITokenDuple functionId = ((ASTExpression)lhs).getIdExpressionTokenDuple();
List parameters = ((ASTExpression)rhs).getResultType();
symbol = lookupQualifiedName(startingScope, functionId, TypeInfo.t_function, parameters, references, false);
}
ASTExpression expression = new ASTExpression( kind, lhs, rhs, thirdExpression,
- typeId, literal, newDescriptor, references);
+ typeId, idExpression, literal, newDescriptor, references);
expression.setResultType (getExpressionResultType(expression, symbol));
@@ -1048,9 +1032,8 @@
}
// types that resolve to t_type, symbol already looked up in type id
- if( (expression.getExpressionKind() == IASTExpression.Kind.ID_EXPRESSION)
- || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_TYPEID_TYPEID)
- ){
+ if( expression.getExpressionKind() == IASTExpression.Kind.ID_EXPRESSION )
+ {
info.setType(TypeInfo.t_type);
info.setTypeSymbol(symbol);
result.add(info);
@@ -1067,6 +1050,7 @@
result.add(info);
return result;
}
+
// a star implies a pointer operation of type pointer
if (expression.getExpressionKind() == IASTExpression.Kind.UNARY_STAR_CASTEXPRESSION){
List lhsResult = ((ASTExpression)expression.getLHSExpression()).getResultType();
@@ -1141,17 +1125,23 @@
}
}
// new
-/* if((expression.getExpressionKind() == IASTExpression.Kind.NEW_NEWTYPEID)
- || (expression.getExpressionKind() == IASTExpression.Kind.NEW_TYPEID)
- ){
+ if( expression.getExpressionKind() == IASTExpression.Kind.NEW_TYPEID )
+ {
if(symbol != null){
- info.setType(symbol.getType());
- info.setTypeSymbol(symbol);
+ try
+ {
+ info = expression.getTypeId().getTypeSymbol().getTypeInfo();
+ }
+ catch (ASTNotImplementedException e)
+ {
+ // will never happen
+ }
+ info.addOperatorExpression( TypeInfo.OperatorExpression.indirection);
result.add(info);
return result;
}
}
-*/ // types that use the usual arithmetic conversions
+ // types that use the usual arithmetic conversions
if((expression.getExpressionKind() == IASTExpression.Kind.MULTIPLICATIVE_MULTIPLY)
|| (expression.getExpressionKind() == IASTExpression.Kind.MULTIPLICATIVE_DIVIDE)
|| (expression.getExpressionKind() == IASTExpression.Kind.MULTIPLICATIVE_MODULUS)
@@ -1243,6 +1233,22 @@
result.add(info);
return result;
}
+
+ if( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_TYPEID_TYPEID )
+ {
+ IASTTypeId typeId = expression.getTypeId();
+ try
+ {
+ info = typeId.getTypeSymbol().getTypeInfo();
+ }
+ catch (ASTNotImplementedException e)
+ {
+ // will not ever happen from within CompleteParseASTFactory
+ }
+ result.add(info);
+ return result;
+ }
+
return result;
}
@@ -1273,10 +1279,10 @@
Iterator iter =typeIds.iterator();
while( iter.hasNext() )
{
- ITokenDuple duple = (ITokenDuple)iter.next();
+ IASTTypeId duple = (IASTTypeId)iter.next();
if( duple != null )
{
- lookupQualifiedName( scopeToSymbol( scope ), duple, references, false );
+ lookupQualifiedName( scopeToSymbol( scope ), ((ASTTypeId)duple).getTokenDuple(), references, false );
newTypeIds.add( duple.toString() );
}
}
@@ -1429,7 +1435,7 @@
}
String functionName = oneToken;
- String parentName = name.substring(0, name.lastIndexOf(DOUBLE_COLON));
+// String parentName = name.substring(0, name.lastIndexOf(DOUBLE_COLON));
int numOfTokens = 1;
int offset = nameOffset;
@@ -1688,7 +1694,7 @@
while( arrayModsIterator.hasNext() )
{
- IASTArrayModifier astArrayModifier = (IASTArrayModifier)arrayModsIterator.next();
+ arrayModsIterator.next();
symbol.addPtrOperator( new TypeInfo.PtrOp( TypeInfo.PtrOp.t_array ));
}
}
@@ -2366,4 +2372,70 @@
{
return new ASTParameterDeclaration( null, isConst, isVolatile, typeSpecifier, pointerOperators, arrayModifiers, parameters, pointerOp, parameterName, initializerClause, startingOffset, endingOffset, nameOffset );
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTypeId(org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type, org.eclipse.cdt.core.parser.ITokenDuple, java.util.List, java.util.List)
+ */
+ public IASTTypeId createTypeId(IASTScope scope, Type kind, boolean isConst, boolean isVolatile, boolean isShort,
+ boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename, ITokenDuple name, List pointerOps, List arrayMods) throws ASTSemanticException
+ {
+ ASTTypeId result =
+ new ASTTypeId( kind, name, pointerOps, arrayMods, "", //TODO
+ isConst, isVolatile, isUnsigned, isSigned, isShort, isLong, isTypename );
+ result.setTypeSymbol( createSymbolForTypeId( scope, result ) );
+ return result;
+ }
+
+ /**
+ * @param id
+ * @return
+ */
+ public static TypeInfo.eType getTypeKind(IASTTypeId id)
+ {
+ IASTSimpleTypeSpecifier.Type type = id.getKind();
+ if( type == IASTSimpleTypeSpecifier.Type.BOOL )
+ return TypeInfo.t_bool;
+ else if( type == IASTSimpleTypeSpecifier.Type.CHAR )
+ return TypeInfo.t_char;
+ else if( type == IASTSimpleTypeSpecifier.Type.DOUBLE )
+ return TypeInfo.t_double;
+ else if( type == IASTSimpleTypeSpecifier.Type.FLOAT )
+ return TypeInfo.t_float;
+ else if( type == IASTSimpleTypeSpecifier.Type.INT )
+ return TypeInfo.t_int;
+ else if( type == IASTSimpleTypeSpecifier.Type.VOID )
+ return TypeInfo.t_void;
+ else if( id.isShort() || id.isLong() || id.isUnsigned() || id.isSigned() )
+ return TypeInfo.t_int;
+ else
+ return TypeInfo.t_type;
+ }
+
+ protected ISymbol createSymbolForTypeId( IASTScope scope, IASTTypeId id ) throws ASTSemanticException
+ {
+ if( id == null ) return null;
+
+ ASTTypeId typeId = (ASTTypeId)id;
+ ISymbol result = pst.newSymbol( "", CompleteParseASTFactory.getTypeKind(id));
+
+ result.getTypeInfo().setBit( id.isConst(), TypeInfo.isConst );
+ result.getTypeInfo().setBit( id.isVolatile(), TypeInfo.isVolatile );
+
+ result.getTypeInfo().setBit( id.isShort(), TypeInfo.isShort);
+ result.getTypeInfo().setBit( id.isLong(), TypeInfo.isLong);
+ result.getTypeInfo().setBit( id.isUnsigned(), TypeInfo.isUnsigned);
+
+ List refs = new ArrayList();
+ if( result.getType() == TypeInfo.t_type )
+ {
+ ISymbol typeSymbol = lookupQualifiedName( scopeToSymbol(scope), typeId.getTokenDuple(), refs, true );
+ if( typeSymbol.getType() == TypeInfo.t_type )
+ throw new ASTSemanticException();
+ result.setTypeSymbol( typeSymbol );
+ typeId.addReferences( refs );
+ }
+
+ setPointerOperators( result, id.getPointerOperators(), id.getArrayModifiers() );
+ return result;
+ }
}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExceptionSpecification.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExceptionSpecification.java,v
retrieving revision 1.3
diff -u -r1.3 ASTExceptionSpecification.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExceptionSpecification.java 14 Aug 2003 15:33:27 -0000 1.3
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExceptionSpecification.java 23 Sep 2003 22:50:00 -0000
@@ -15,8 +15,8 @@
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.IASTExceptionSpecification;
+import org.eclipse.cdt.core.parser.ast.IASTTypeId;
/**
* @author jcamelon
@@ -33,7 +33,7 @@
Iterator i = typeIds.iterator();
this.typeIds = new ArrayList();
while( i.hasNext() )
- this.typeIds.add( ((ITokenDuple)i.next()).toString() );
+ this.typeIds.add( ((IASTTypeId)i.next()).getTypeOrClassName());
}
/* (non-Javadoc)
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExpression.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExpression.java,v
retrieving revision 1.3
diff -u -r1.3 ASTExpression.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExpression.java 4 Sep 2003 14:39:15 -0000 1.3
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExpression.java 23 Sep 2003 22:50:00 -0000
@@ -7,8 +7,10 @@
package org.eclipse.cdt.internal.core.parser.ast.quick;
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
+import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
import org.eclipse.cdt.core.parser.ast.ExpressionEvaluationException;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
+import org.eclipse.cdt.core.parser.ast.IASTTypeId;
@@ -22,7 +24,8 @@
private final Kind kind;
private final IASTExpression lhs, rhs, third;
- private final String typeId, literal;
+ private final IASTTypeId typeId;
+ private final String literal, idExpression;
private final IASTNewExpressionDescriptor newDescriptor;
/**
@@ -33,7 +36,7 @@
* @param typeId
* @param literal
*/
- public ASTExpression(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression third, String typeId, String literal, IASTNewExpressionDescriptor newDescriptor) {
+ public ASTExpression(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression third, IASTTypeId typeId, String idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) {
this.kind = kind;
this.lhs =lhs;
this.rhs = rhs;
@@ -41,6 +44,7 @@
this.typeId = typeId;
this.literal = literal;
this.newDescriptor = newDescriptor;
+ this.idExpression = idExpression;
}
/* (non-Javadoc)
@@ -74,7 +78,7 @@
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#getTypeId()
*/
- public String getTypeIdString() {
+ public IASTTypeId getTypeId() {
return typeId;
}
@@ -174,6 +178,22 @@
*/
public void exitScope(ISourceElementRequestor requestor)
{
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTExpression#getIdExpression()
+ */
+ public String getIdExpression()
+ {
+ return idExpression;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTExpression#reconcileReferences()
+ */
+ public void reconcileReferences() throws ASTNotImplementedException
+ {
+ throw new ASTNotImplementedException();
}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTNewDescriptor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTNewDescriptor.java,v
retrieving revision 1.3
diff -u -r1.3 ASTNewDescriptor.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTNewDescriptor.java 25 Aug 2003 15:41:30 -0000 1.3
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTNewDescriptor.java 23 Sep 2003 22:50:00 -0000
@@ -12,6 +12,7 @@
import java.util.Iterator;
+import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
/**
@@ -43,5 +44,26 @@
// TODO Auto-generated method stub
return null;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void acceptElement(ISourceElementRequestor requestor)
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void enterScope(ISourceElementRequestor requestor)
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void exitScope(ISourceElementRequestor requestor)
+ {
+ }
}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTTypeId.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTTypeId.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTTypeId.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTTypeId.java 23 Sep 2003 22:50:00 -0000
@@ -0,0 +1,169 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 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
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.quick;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.parser.ISourceElementRequestor;
+import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
+import org.eclipse.cdt.core.parser.ast.IASTTypeId;
+import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
+import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTTypeId implements IASTTypeId
+{
+ private final boolean isVolatile;
+ private final boolean isUnsigned;
+ private final boolean isTypeName;
+ private final boolean isSigned;
+ private final boolean isShort;
+ private final boolean isLong;
+ private final boolean isConst;
+ private final Type kind;
+ private final String name;
+ private final List pointerOps;
+ private final List arrayMods;
+ /**
+ * @param kind
+ * @param string
+ * @param pointerOps
+ * @param arrayMods
+ */
+ public ASTTypeId(Type kind, String string, List pointerOps, List arrayMods, boolean isConst, boolean isVolatile,
+ boolean isUnsigned, boolean isSigned, boolean isShort, boolean isLong, boolean isTypeName)
+ {
+ this.kind = kind;
+ this.name = string;
+ this.pointerOps = pointerOps;
+ this.arrayMods = arrayMods;
+ this.isVolatile =isVolatile;
+ this.isUnsigned =isUnsigned;
+ this.isTypeName =isTypeName;
+ this.isSigned =isSigned;
+ this.isShort =isShort;
+ this.isLong =isLong;
+ this.isConst =isConst;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#getKind()
+ */
+ public Type getKind()
+ {
+ return kind;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#getType()
+ */
+ public String getTypeOrClassName()
+ {
+ return name;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#getPointerOperators()
+ */
+ public Iterator getPointerOperators()
+ {
+ return pointerOps.iterator();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#getArrayModifiers()
+ */
+ public Iterator getArrayModifiers()
+ {
+ return arrayMods.iterator();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#getFullSignature()
+ */
+ public String getFullSignature() throws ASTNotImplementedException
+ {
+ throw new ASTNotImplementedException();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#createTypeSymbol(org.eclipse.cdt.core.parser.ast.IASTFactory)
+ */
+ public ISymbol getTypeSymbol() throws ASTNotImplementedException
+ {
+ throw new ASTNotImplementedException();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#isConst()
+ */
+ public boolean isConst()
+ {
+ return isConst;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#isVolatile()
+ */
+ public boolean isVolatile()
+ {
+ return isVolatile;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#isLong()
+ */
+ public boolean isLong()
+ {
+ return isLong;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#isShort()
+ */
+ public boolean isShort()
+ {
+ return isShort;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#isSigned()
+ */
+ public boolean isSigned()
+ {
+ return isSigned;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#isUnsigned()
+ */
+ public boolean isUnsigned()
+ {
+ return isUnsigned;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTypeId#isTypename()
+ */
+ public boolean isTypename()
+ {
+ return isTypeName;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void acceptElement(ISourceElementRequestor requestor)
+ {
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void enterScope(ISourceElementRequestor requestor)
+ {
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void exitScope(ISourceElementRequestor requestor)
+ {
+ }
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java,v
retrieving revision 1.35
diff -u -r1.35 QuickParseASTFactory.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java 23 Sep 2003 20:46:17 -0000 1.35
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java 23 Sep 2003 22:50:00 -0000
@@ -46,6 +46,7 @@
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter;
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
+import org.eclipse.cdt.core.parser.ast.IASTTypeId;
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
@@ -150,8 +151,8 @@
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createExpression(org.eclipse.cdt.core.parser.ast.IASTExpression.ExpressionKind, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTExpression, java.lang.String, java.lang.String, java.lang.String)
*/
- public IASTExpression createExpression(IASTScope scope, Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression thirdExpression, ITokenDuple typeId, String literal, IASTNewExpressionDescriptor newDescriptor) {
- return new ASTExpression( kind, lhs, rhs, thirdExpression, typeId == null ? "" : typeId.toString(), literal, newDescriptor );
+ public IASTExpression createExpression(IASTScope scope, Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression thirdExpression, IASTTypeId typeId, ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) {
+ return new ASTExpression( kind, lhs, rhs, thirdExpression, typeId, idExpression == null ? "" : idExpression.toString(), literal, newDescriptor );
}
/* (non-Javadoc)
@@ -295,5 +296,15 @@
public IASTParameterDeclaration createParameterDeclaration(boolean isConst, boolean isVolatile, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause, int startingOffset, int endingOffset, int nameOffset)
{
return new ASTParameterDeclaration( isConst, isVolatile, typeSpecifier, pointerOperators, arrayModifiers, parameters, pointerOp, parameterName, initializerClause, startingOffset, endingOffset, nameOffset );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTypeId(org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type, org.eclipse.cdt.core.parser.ITokenDuple, java.util.List, java.util.List)
+ */
+ public IASTTypeId createTypeId(IASTScope scope, Type kind, boolean isConst, boolean isVolatile, boolean isShort,
+ boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename, ITokenDuple name, List pointerOps, List arrayMods)
+ {
+ return new ASTTypeId( kind, name == null ? "" : name.toString(), pointerOps, arrayMods, isConst,
+ isVolatile, isUnsigned, isSigned, isShort, isLong, isTypename );
}
}