1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Added traceLog() call into Scanner.handleProblem() and updated ParserFactory.createPreprocessor()'s error handling.

This commit is contained in:
John Camelon 2004-01-21 03:01:14 +00:00
parent ee9dc1d5a5
commit d228fe824a
3 changed files with 26 additions and 11 deletions

View file

@ -1,3 +1,6 @@
2004-01-20 John Camelon
Added traceLog() call into Scanner.handleProblem() and updated ParserFactory.createPreprocessor() for extra error handling.
2004-01-20 John Camelon
Tidied up Scanner implementation for unused fields, inefficient String manipulations and redundant parameters.

View file

@ -74,9 +74,14 @@ public class ParserFactory {
public static IPreprocessor createPreprocessor( Reader input, String fileName, IScannerInfo info, ParserMode mode, ParserLanguage language, ISourceElementRequestor requestor, IParserLogService logService )
{
if( input == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_READER );
if( fileName == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_FILENAME );
if( info == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_CONFIG );
if( language == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_LANGUAGE );
IParserLogService log = ( logService == null ) ? createDefaultLogService() : logService;
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode );
ISourceElementRequestor ourRequestor = (( requestor == null) ? new NullSourceElementRequestor() : requestor );
IPreprocessor s = new Preprocessor( input, fileName, info, ourRequestor, ourMode, language, logService );
IPreprocessor s = new Preprocessor( input, fileName, info, ourRequestor, ourMode, language, log );
return s;
}

View file

@ -80,9 +80,16 @@ public class Scanner implements IScanner {
String attributes [] = problemFactory.getRequiredAttributesForId( problemID );
arguments.put( attributes[ 0 ], argument );
}
IProblem p = problemFactory.createProblem( problemID, beginningOffset, getCurrentOffset(), contextStack.getCurrentLineNumber(), getCurrentFile().toCharArray(), arguments, warning, error );
if( (! requestor.acceptProblem( p )) && extra )
throw new ScannerException( p );
IProblem problem = problemFactory.createProblem( problemID, beginningOffset, getCurrentOffset(), contextStack.getCurrentLineNumber(), getCurrentFile().toCharArray(), arguments, warning, error );
// trace log
StringBuffer logMessage = new StringBuffer( "Scanner problem encountered: ");
logMessage.append( problem.getMessage() );
log.traceLog( logMessage.toString() );
if( (! requestor.acceptProblem( problem )) && extra )
throw new ScannerException( problem );
}
public Scanner(Reader reader, String filename, IScannerInfo info, ISourceElementRequestor requestor, ParserMode parserMode, ParserLanguage language, IParserLogService log ) {