1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 12:03:16 +02:00

org.eclipse.cdt.core

Partial fix for Bug 47752 - Outline does not recognize functions with full body try/catch blocks 

org.eclipse.cdt.core.tests
	Added QuickParseASTTest::testBug47752.
This commit is contained in:
John Camelon 2004-01-30 23:36:05 +00:00
parent de5b46412d
commit 695df66284
8 changed files with 63 additions and 23 deletions

View file

@ -1,3 +1,6 @@
2004-01-30 John Camelon
Added QuickParseASTTest::testBug47752.
2004-01-28 John Camelon
Added ScannerTestCase::testBug50821().

View file

@ -2080,4 +2080,9 @@ public class QuickParseASTTests extends BaseASTTest
private void validateToken(IToken token, int signal) {
assertEquals( token.getType(), signal );
}
public void testBug47752() throws Exception
{
parse("void func( cFoo bar ) try { } catch ( const char * error ){ }" );
}
}

View file

@ -1,3 +1,6 @@
2004-01-30 John Camelon
Partial fix for Bug 47752 - Outline does not recognize functions with full body try/catch blocks
2004-01-30 John Camelon
Updated Scanner to allow for more robust completion in #if directives.

View file

@ -68,4 +68,6 @@ public class CompleteParser extends Parser {
throw new ParseError( ParseError.ParseErrorKind.METHOD_NOT_IMPLEMENTED );
}
}

View file

@ -297,4 +297,25 @@ public class ContextualParser extends Parser implements IParser {
setCompletionValues(scope,kind,key, getCompletionContextForExpression(firstExpression,isTemplate) );
}
protected void catchHandlerSequence(IASTScope scope)
throws EndOfFileException, BacktrackException {
if( LT(1) != IToken.t_catch )
throw backtrack; // error, need at least one of these
while (LT(1) == IToken.t_catch)
{
consume(IToken.t_catch);
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,Key.EMPTY);
consume(IToken.tLPAREN);
setCompletionValues(scope,CompletionKind.EXCEPTION_REFERENCE,Key.DECL_SPECIFIER_SEQUENCE );
if( LT(1) == IToken.tELLIPSIS )
consume( IToken.tELLIPSIS );
else
declaration(scope, null, CompletionKind.EXCEPTION_REFERENCE); // was exceptionDeclaration
consume(IToken.tRPAREN);
catchBlockCompoundStatement(scope);
}
}
}

View file

@ -793,7 +793,7 @@ public abstract class Parser implements IParser
simpleDeclaration(
SimpleDeclarationStrategy.TRY_CONSTRUCTOR,
scope,
ownerTemplate, overide);
ownerTemplate, overide, false);
// try it first with the original strategy
}
catch (BacktrackException bt)
@ -806,7 +806,7 @@ public abstract class Parser implements IParser
simpleDeclaration(
SimpleDeclarationStrategy.TRY_FUNCTION,
scope,
ownerTemplate, overide);
ownerTemplate, overide, false);
}
catch( BacktrackException bt2 )
{
@ -817,7 +817,7 @@ public abstract class Parser implements IParser
simpleDeclaration(
SimpleDeclarationStrategy.TRY_VARIABLE,
scope,
ownerTemplate, overide);
ownerTemplate, overide, false);
}
catch( BacktrackException b3 )
{
@ -948,7 +948,7 @@ public abstract class Parser implements IParser
protected void simpleDeclaration(
SimpleDeclarationStrategy strategy,
IASTScope scope,
IASTTemplate ownerTemplate, CompletionKind overideKind)
IASTTemplate ownerTemplate, CompletionKind overideKind, boolean fromCatchHandler)
throws BacktrackException, EndOfFileException
{
IToken firstToken = LA(1);
@ -1009,6 +1009,10 @@ public abstract class Parser implements IParser
break;
case IToken.tLBRACE:
break;
case IToken.tRPAREN:
if( ! fromCatchHandler )
throw backtrack;
break;
default:
throw backtrack;
}
@ -1023,6 +1027,9 @@ public abstract class Parser implements IParser
hasFunctionBody = true;
}
if( fromCatchHandler )
return;
if( hasFunctionTryBlock && ! hasFunctionBody )
throw backtrack;
}
@ -3093,26 +3100,24 @@ public abstract class Parser implements IParser
}
protected void catchHandlerSequence(IASTScope scope)
throws EndOfFileException, BacktrackException
{
throws EndOfFileException, BacktrackException {
if( LT(1) != IToken.t_catch )
throw backtrack; // error, need at least one of these
while (LT(1) == IToken.t_catch)
{
consume(IToken.t_catch);
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,Key.EMPTY);
consume(IToken.tLPAREN);
setCompletionValues(scope,CompletionKind.EXCEPTION_REFERENCE,Key.DECL_SPECIFIER_SEQUENCE );
if( LT(1) == IToken.tELLIPSIS )
consume( IToken.tELLIPSIS );
else
declaration(scope, null, CompletionKind.EXCEPTION_REFERENCE); // was exceptionDeclaration
consume(IToken.tRPAREN);
catchBlockCompoundStatement(scope);
}
while (LT(1) == IToken.t_catch)
{
consume(IToken.t_catch);
consume(IToken.tLPAREN);
if( LT(1) == IToken.tELLIPSIS )
consume( IToken.tELLIPSIS );
else
simpleDeclaration( SimpleDeclarationStrategy.TRY_VARIABLE, scope, null, CompletionKind.EXCEPTION_REFERENCE, true); // was exceptionDeclaration
consume(IToken.tRPAREN);
catchBlockCompoundStatement(scope);
}
}
protected abstract void catchBlockCompoundStatement(IASTScope scope) throws BacktrackException, EndOfFileException;
protected void singleStatementScope(IASTScope scope) throws EndOfFileException, BacktrackException
@ -5267,7 +5272,7 @@ public abstract class Parser implements IParser
}
// the static instance we always use
private static BacktrackException backtrack = new BacktrackException();
protected static BacktrackException backtrack = new BacktrackException();
// Token management
protected IScanner scanner;

View file

@ -65,6 +65,5 @@ public class QuickParser extends Parser {
public IASTNode parse(int startingOffset, int endingOffset) throws ParseError {
throw new ParseError( ParseErrorKind.METHOD_NOT_IMPLEMENTED );
}
}

View file

@ -75,4 +75,6 @@ public class StructuralParser extends Parser implements IParser {
}
}