From d228fe824a333c92859aa19baf16e89150f09590 Mon Sep 17 00:00:00 2001 From: John Camelon Date: Wed, 21 Jan 2004 03:01:14 +0000 Subject: [PATCH] Added traceLog() call into Scanner.handleProblem() and updated ParserFactory.createPreprocessor()'s error handling. --- core/org.eclipse.cdt.core/parser/ChangeLog-parser | 13 ++++++++----- .../org/eclipse/cdt/core/parser/ParserFactory.java | 11 ++++++++--- .../eclipse/cdt/internal/core/parser/Scanner.java | 13 ++++++++++--- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog-parser b/core/org.eclipse.cdt.core/parser/ChangeLog-parser index dac66f18c15..02471848368 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog-parser +++ b/core/org.eclipse.cdt.core/parser/ChangeLog-parser @@ -1,11 +1,14 @@ 2004-01-20 John Camelon - Tidied up Scanner implementation for unused fields, inefficient String manipulations and redundant parameters. + 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. 2004-01-19 John Camelon - Added IToken.getLineNumber() to facilitate adding line numbers to AST. - Added line number support into IASTOffsetableElement. Updated all implementations to use this. - Updated Parser and IASTFactory to populate IASTOffsetableElement with the values retrieved from IToken. - Removed IScanner.getLineNumberForOffset(). + Added IToken.getLineNumber() to facilitate adding line numbers to AST. + Added line number support into IASTOffsetableElement. Updated all implementations to use this. + Updated Parser and IASTFactory to populate IASTOffsetableElement with the values retrieved from IToken. + Removed IScanner.getLineNumberForOffset(). 2004-01-16 Andrew Niefer Created IExtensibleSymbol, which is a new base class for the symbol interfaces diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java index 69f27b82b09..d70e5217275 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java @@ -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 ) { - 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 ); + 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, log ); return s; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java index 88a3b912e7b..4205697cd73 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java @@ -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 ) {