mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-18 13:45:45 +02:00
CORE
Continue to add support for parsing within function bodies. Add workaround for 1.2 for inline function declaration-before-use chicken-and-egg. TESTS Added CompleteParseASTTest::testSimpleIfStatement(), testSimpleWhileStatement(). testSimpleSwitchStatement(), testSimpleDoStatement().
This commit is contained in:
parent
d1d3dec2fe
commit
8b12ea5492
4 changed files with 49 additions and 3 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2003-09-05 John Camelon
|
||||||
|
Added CompleteParseASTTest::testSimpleIfStatement(), testSimpleWhileStatement().
|
||||||
|
testSimpleSwitchStatement(), testSimpleDoStatement().
|
||||||
|
|
||||||
2003-09-05 Andrew Niefer
|
2003-09-05 Andrew Niefer
|
||||||
Added testEnumerators to OtherPatternTests.java
|
Added testEnumerators to OtherPatternTests.java
|
||||||
Modified resources/search/classDecl.cpp to include some enumerators
|
Modified resources/search/classDecl.cpp to include some enumerators
|
||||||
|
|
|
@ -653,4 +653,41 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSimpleIfStatement() throws Exception
|
||||||
|
{
|
||||||
|
Iterator i = parse( "const bool T = true; int foo() { if( T ) { return 5; } else if( ! T ) return 20; else { return 10; } }").getDeclarations();
|
||||||
|
IASTVariable t = (IASTVariable)i.next();
|
||||||
|
IASTFunction foo = (IASTFunction)i.next();
|
||||||
|
assertFalse( i.hasNext() );
|
||||||
|
assertEquals( callback.getReferences().size(), 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSimpleWhileStatement() throws Exception
|
||||||
|
{
|
||||||
|
Iterator i = parse( "const bool T = true; void foo() { int x = 0; while( T ) { ++x; if( x == 100 ) break; } }").getDeclarations();
|
||||||
|
IASTVariable t = (IASTVariable)i.next();
|
||||||
|
IASTFunction foo = (IASTFunction)i.next();
|
||||||
|
assertFalse( i.hasNext() );
|
||||||
|
assertEquals( callback.getReferences().size(), 3 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSimpleSwitchStatement() throws Exception
|
||||||
|
{
|
||||||
|
Iterator i = parse( "const int x = 5; const int y = 10; void foo() { switch( x ) { case 1: break; case 2: goto blah; case y: continue; default: break;} }").getDeclarations();
|
||||||
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
|
IASTVariable y = (IASTVariable)i.next();
|
||||||
|
IASTFunction foo = (IASTFunction)i.next();
|
||||||
|
assertFalse( i.hasNext() );
|
||||||
|
assertEquals( callback.getReferences().size(), 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSimpleDoStatement() throws Exception
|
||||||
|
{
|
||||||
|
Iterator i = parse( "const int x = 3; int counter = 0; void foo() { do { ++counter; } while( counter != x ); } ").getDeclarations();
|
||||||
|
IASTVariable x = (IASTVariable)i.next();
|
||||||
|
IASTVariable counter = (IASTVariable)i.next();
|
||||||
|
IASTFunction foo = (IASTFunction)i.next();
|
||||||
|
assertFalse( i.hasNext() );
|
||||||
|
assertEquals( callback.getReferences().size(), 3 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2003-09-05 John Camelon
|
||||||
|
Continue to add support for parsing within function bodies.
|
||||||
|
Add workaround for 1.2 for inline function declaration-before-use chicken-and-egg.
|
||||||
|
|
||||||
2003-09-05 John Camelon
|
2003-09-05 John Camelon
|
||||||
Fixed NPE on nested declarations in code blocks.
|
Fixed NPE on nested declarations in code blocks.
|
||||||
|
|
||||||
|
|
|
@ -934,7 +934,8 @@ public class Parser implements IParser
|
||||||
IASTDeclaration declaration = (IASTDeclaration)i.next();
|
IASTDeclaration declaration = (IASTDeclaration)i.next();
|
||||||
declaration.enterScope( requestor );
|
declaration.enterScope( requestor );
|
||||||
|
|
||||||
handleFunctionBody((IASTScope)declaration);
|
handleFunctionBody((IASTScope)declaration,
|
||||||
|
sdw.isInline() );
|
||||||
((IASTOffsetableElement)declaration).setEndingOffset(
|
((IASTOffsetableElement)declaration).setEndingOffset(
|
||||||
lastToken.getEndOffset());
|
lastToken.getEndOffset());
|
||||||
|
|
||||||
|
@ -954,9 +955,9 @@ public class Parser implements IParser
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
protected void handleFunctionBody(IASTScope scope) throws Backtrack, EndOfFile
|
protected void handleFunctionBody(IASTScope scope, boolean isInlineFunction) throws Backtrack, EndOfFile
|
||||||
{
|
{
|
||||||
if ( mode == ParserMode.QUICK_PARSE ) // TODO - Enable parsing within function bodies i.e. mode == ParserMode.QUICK_PARSE)
|
if ( mode == ParserMode.QUICK_PARSE || isInlineFunction )
|
||||||
{
|
{
|
||||||
// speed up the parser by skiping the body
|
// speed up the parser by skiping the body
|
||||||
// simply look for matching brace and return
|
// simply look for matching brace and return
|
||||||
|
|
Loading…
Add table
Reference in a new issue