mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
CORE
Cleaned up the ParserFactory interface to check for validity of input arguments. Moved NullSourceElementRequestor and ScannerInfo to public interface as requested. Restructured code so that no Eclipse/CDT source outside the parser source directory is used. Updated parser clients to use new ParserFactory (stand-alone parser work item). UI & TESTS Updated parser clients to use new ParserFactory (stand-alone parser work item).
This commit is contained in:
parent
6189ea9764
commit
97e203468e
37 changed files with 459 additions and 138 deletions
|
@ -1,3 +1,6 @@
|
|||
2003-11-05 John Camelon
|
||||
Updated parser clients to use new ParserFactory (stand-alone parser work item).
|
||||
|
||||
2003-11-05 John Camelon
|
||||
Updated parser clients to use new IProblem strategy.
|
||||
|
||||
|
|
|
@ -28,10 +28,10 @@ import org.eclipse.cdt.core.parser.IScannerInfo;
|
|||
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
|
@ -982,9 +982,9 @@ public class ManagedBuildTests extends TestCase {
|
|||
ISourceElementRequestor callback = new NullSourceElementRequestor();
|
||||
|
||||
IScanner scanner = ParserFactory.createScanner( new StringReader( "#include <header.h>\n int A::i = 1;" ),
|
||||
"TEST", info, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, callback );
|
||||
"TEST", info, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, callback, null);
|
||||
|
||||
IParser parser = ParserFactory.createParser( scanner, callback, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP );
|
||||
IParser parser = ParserFactory.createParser( scanner, callback, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, null );
|
||||
assertTrue( parser.parse() );
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import junit.framework.TestCase;
|
|||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -23,10 +23,10 @@ import junit.framework.Test;
|
|||
|
||||
import org.eclipse.cdt.core.parser.ILineOffsetReconciler;
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class AutomatedTest extends AutomatedFramework {
|
|||
|
||||
String filePath = file.getCanonicalPath();
|
||||
ParserLanguage language = ((String)natures.get( filePath )).equalsIgnoreCase("cpp") ? ParserLanguage.CPP : ParserLanguage.C;
|
||||
parser = ParserFactory.createParser( ParserFactory.createScanner( new InputStreamReader (stream), filePath, new ScannerInfo(), ParserMode.QUICK_PARSE, language, nullCallback ), nullCallback, ParserMode.QUICK_PARSE, language);
|
||||
parser = ParserFactory.createParser( ParserFactory.createScanner( new InputStreamReader (stream), filePath, new ScannerInfo(), ParserMode.QUICK_PARSE, language, nullCallback, null ), nullCallback, ParserMode.QUICK_PARSE, language, null);
|
||||
|
||||
mapping = ParserFactory.createLineOffsetReconciler( new InputStreamReader( stream ) );
|
||||
|
||||
|
|
|
@ -17,9 +17,11 @@ import junit.framework.TestCase;
|
|||
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
|
@ -29,7 +31,6 @@ import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -45,38 +46,38 @@ public class BaseASTTest extends TestCase
|
|||
protected IQuickParseCallback quickParseCallback;
|
||||
protected IParser parser;
|
||||
|
||||
protected IASTCompilationUnit parse( String code, boolean quick, boolean throwExceptionOnError, ParserLanguage lang ) throws ParserException
|
||||
protected IASTCompilationUnit parse( String code, boolean quick, boolean throwExceptionOnError, ParserLanguage lang ) throws ParserException, ParserFactoryException
|
||||
{
|
||||
ParserMode mode = quick ? ParserMode.QUICK_PARSE : ParserMode.COMPLETE_PARSE;
|
||||
quickParseCallback = ParserFactory.createQuickParseCallback();
|
||||
parser = ParserFactory.createParser( ParserFactory.createScanner( new StringReader( code ), "code", new ScannerInfo(), mode, lang, quickParseCallback), quickParseCallback, mode, lang );
|
||||
parser = ParserFactory.createParser( ParserFactory.createScanner( new StringReader( code ), "code", new ScannerInfo(), mode, lang, quickParseCallback, null), quickParseCallback, mode, lang, null );
|
||||
if( ! parser.parse() && throwExceptionOnError )
|
||||
throw new ParserException("Parse failure");
|
||||
return quickParseCallback.getCompilationUnit();
|
||||
}
|
||||
|
||||
|
||||
protected IASTCompilationUnit parse( String code, boolean quick, boolean throwExceptionOnError ) throws ParserException
|
||||
protected IASTCompilationUnit parse( String code, boolean quick, boolean throwExceptionOnError ) throws ParserException, ParserFactoryException
|
||||
{
|
||||
return parse( code, quick, throwExceptionOnError, ParserLanguage.CPP );
|
||||
}
|
||||
|
||||
protected IASTCompilationUnit parse( String code )throws ParserException
|
||||
protected IASTCompilationUnit parse( String code )throws ParserException, ParserFactoryException
|
||||
{
|
||||
return parse( code, true, true );
|
||||
}
|
||||
|
||||
protected IASTCompilationUnit fullParse( String code ) throws ParserException
|
||||
protected IASTCompilationUnit fullParse( String code ) throws ParserException, ParserFactoryException
|
||||
{
|
||||
return parse( code, false, true );
|
||||
}
|
||||
|
||||
protected IASTDeclaration assertSoleDeclaration( String code ) throws ParserException
|
||||
protected IASTDeclaration assertSoleDeclaration( String code ) throws ParserException, ParserFactoryException
|
||||
{
|
||||
return assertSoleDeclaration( code, ParserLanguage.CPP );
|
||||
}
|
||||
|
||||
protected IASTDeclaration assertSoleDeclaration( String code, ParserLanguage language ) throws ParserException
|
||||
protected IASTDeclaration assertSoleDeclaration( String code, ParserLanguage language ) throws ParserException, ParserFactoryException
|
||||
{
|
||||
Iterator declarationIter = null;
|
||||
try
|
||||
|
|
|
@ -18,12 +18,13 @@ import junit.framework.TestCase;
|
|||
import org.eclipse.cdt.core.parser.EndOfFile;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerException;
|
||||
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -38,13 +39,13 @@ public class BaseScannerTest extends TestCase {
|
|||
super(x);
|
||||
}
|
||||
|
||||
protected void initializeScanner( String input, ParserMode mode )
|
||||
protected void initializeScanner( String input, ParserMode mode ) throws ParserFactoryException
|
||||
{
|
||||
scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", new ScannerInfo(), mode, ParserLanguage.CPP, new NullSourceElementRequestor( mode ) );
|
||||
scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", new ScannerInfo(), mode, ParserLanguage.CPP, new NullSourceElementRequestor( mode ), null );
|
||||
}
|
||||
|
||||
|
||||
protected void initializeScanner(String input)
|
||||
protected void initializeScanner(String input) throws ParserFactoryException
|
||||
{
|
||||
initializeScanner( input, ParserMode.COMPLETE_PARSE );
|
||||
}
|
||||
|
|
|
@ -26,8 +26,10 @@ 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.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
||||
|
@ -64,7 +66,6 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -672,22 +673,22 @@ public class CompleteParseBaseTest extends TestCase
|
|||
}
|
||||
protected FullParseCallback callback;
|
||||
|
||||
protected IASTScope parse( String code ) throws ParserException
|
||||
protected IASTScope parse( String code ) throws ParserException, ParserFactoryException
|
||||
{
|
||||
return parse( code, true, ParserLanguage.CPP );
|
||||
}
|
||||
|
||||
protected IASTScope parse( String code, boolean throwOnError ) throws ParserException
|
||||
protected IASTScope parse( String code, boolean throwOnError ) throws ParserException, ParserFactoryException
|
||||
{
|
||||
return parse( code, throwOnError, ParserLanguage.CPP );
|
||||
}
|
||||
|
||||
protected IASTScope parse(String code, boolean throwOnError, ParserLanguage language) throws ParserException
|
||||
protected IASTScope parse(String code, boolean throwOnError, ParserLanguage language) throws ParserException, ParserFactoryException
|
||||
{
|
||||
callback = new FullParseCallback();
|
||||
IParser parser = ParserFactory.createParser(
|
||||
ParserFactory.createScanner( new StringReader( code ), "test-code", new ScannerInfo(),
|
||||
ParserMode.COMPLETE_PARSE, language, callback ), callback, ParserMode.COMPLETE_PARSE, language
|
||||
ParserMode.COMPLETE_PARSE, language, callback, null ), callback, ParserMode.COMPLETE_PARSE, language, null
|
||||
);
|
||||
if( ! parser.parse() && throwOnError ) throw new ParserException( "FAILURE");
|
||||
return callback.getCompilationUnit();
|
||||
|
|
|
@ -7,12 +7,12 @@ import junit.framework.TestCase;
|
|||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
|
||||
public class ExprEvalTest extends TestCase {
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class ExprEvalTest extends TestCase {
|
|||
public void runTest(String code, int expectedValue) throws Exception {
|
||||
|
||||
final NullSourceElementRequestor nullCallback = new NullSourceElementRequestor();
|
||||
IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), null, ParserLanguage.CPP, nullCallback ), nullCallback, ParserMode.QUICK_PARSE, ParserLanguage.CPP );
|
||||
IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), getClass().getName(), new ScannerInfo(), null, ParserLanguage.CPP, nullCallback, null ), nullCallback, ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
|
||||
IASTExpression expression = parser.expression(null);
|
||||
assertEquals(expectedValue, expression.evaluateExpression());
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ import java.util.StringTokenizer;
|
|||
import junit.framework.Test;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
|
@ -241,7 +241,7 @@ public class FractionalAutomatedTest extends AutomatedFramework {
|
|||
result = null;
|
||||
ParserLanguage language = cppNature ? ParserLanguage.CPP : ParserLanguage.C;
|
||||
IParser parser = ParserFactory.createParser(
|
||||
ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), ParserMode.QUICK_PARSE, language, nullCallback ), nullCallback, ParserMode.QUICK_PARSE, language);
|
||||
ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), ParserMode.QUICK_PARSE, language, nullCallback, null ), nullCallback, ParserMode.QUICK_PARSE, language, null );
|
||||
|
||||
parser.parse();
|
||||
} catch ( Exception e ){
|
||||
|
|
|
@ -17,12 +17,12 @@ import java.util.Map;
|
|||
import org.eclipse.cdt.core.parser.EndOfFile;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerException;
|
||||
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -34,13 +34,13 @@ public class PreprocessorConditionalTest extends BaseScannerTest
|
|||
private ISourceElementRequestor nullSourceElementRequestor = new NullSourceElementRequestor();
|
||||
|
||||
|
||||
protected void initializeScanner(String input, Map definitions )
|
||||
protected void initializeScanner(String input, Map definitions ) throws Exception
|
||||
{
|
||||
scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", new ScannerInfo( definitions, null), ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, nullSourceElementRequestor );
|
||||
scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", new ScannerInfo( definitions, null), ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, nullSourceElementRequestor, null );
|
||||
}
|
||||
|
||||
|
||||
protected void evaluateConditionalsPositive( String conditional, Map definitions )
|
||||
protected void evaluateConditionalsPositive( String conditional, Map definitions ) throws Exception
|
||||
{
|
||||
|
||||
StringBuffer buff = new StringBuffer();
|
||||
|
@ -51,7 +51,7 @@ public class PreprocessorConditionalTest extends BaseScannerTest
|
|||
evaluate();
|
||||
}
|
||||
|
||||
protected void evaluateConditionalsNegative( String conditional, Map definitions )
|
||||
protected void evaluateConditionalsNegative( String conditional, Map definitions )throws Exception
|
||||
{
|
||||
|
||||
StringBuffer buff = new StringBuffer();
|
||||
|
@ -94,7 +94,7 @@ public class PreprocessorConditionalTest extends BaseScannerTest
|
|||
super(x);
|
||||
}
|
||||
|
||||
public void testConditionals()
|
||||
public void testConditionals()throws Exception
|
||||
{
|
||||
Map definitions = new HashMap();
|
||||
definitions.put( "DEFED", "" );
|
||||
|
|
|
@ -19,12 +19,12 @@ import junit.framework.TestCase;
|
|||
|
||||
import org.eclipse.cdt.core.parser.IPreprocessor;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
||||
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -75,7 +75,7 @@ public class PreprocessorTest extends TestCase {
|
|||
public IPreprocessor setupPreprocessor( String text, List includePaths, Map defns, ISourceElementRequestor rq )
|
||||
{
|
||||
IPreprocessor p = ParserFactory.createPreprocessor( new StringReader( text ), "test", new ScannerInfo( defns,
|
||||
includePaths == null ? null : (String [])includePaths.toArray()), ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, rq );
|
||||
includePaths == null ? null : (String [])includePaths.toArray()), ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, rq, null );
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1800,7 +1800,7 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
parse( "const int x = 4; int y = ::x;");
|
||||
}
|
||||
|
||||
public void testBug40419() throws ParserException
|
||||
public void testBug40419() throws Exception
|
||||
{
|
||||
Writer code = new StringWriter();
|
||||
try
|
||||
|
@ -1850,6 +1850,7 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
{
|
||||
Iterator i = parse( "void foo();{ int x; }", true, false ).getDeclarations();
|
||||
IASTFunction f = (IASTFunction)i.next();
|
||||
assertEquals( f.getName(), "foo");
|
||||
assertFalse( i.hasNext() );
|
||||
}
|
||||
|
||||
|
@ -1894,11 +1895,11 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
writer.write( "};\n" );
|
||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
|
||||
IASTTemplateDeclaration templateDecl = (IASTTemplateDeclaration)i.next();
|
||||
assertTrue( i.next() instanceof IASTTemplateDeclaration );
|
||||
IASTClassSpecifier classB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||
Iterator members = classB.getDeclarations();
|
||||
IASTTemplateDeclaration friend = (IASTTemplateDeclaration)members.next();
|
||||
IASTMethod method = (IASTMethod)members.next();
|
||||
assertTrue (members.next() instanceof IASTTemplateDeclaration );
|
||||
assertTrue( members.next() instanceof IASTMethod );
|
||||
assertFalse( i.hasNext() );
|
||||
}
|
||||
|
||||
|
@ -1910,7 +1911,7 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
public void testBug41935() throws Exception
|
||||
{
|
||||
Iterator i = parse( "namespace A { int x; } namespace B = A;" ).getDeclarations();
|
||||
IASTNamespaceDefinition n = (IASTNamespaceDefinition)i.next();
|
||||
assertTrue( i.next() instanceof IASTNamespaceDefinition );
|
||||
IASTNamespaceAlias a = (IASTNamespaceAlias)i.next();
|
||||
assertEquals( a.getName(), "B" );
|
||||
assertFalse( i.hasNext() );
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.eclipse.cdt.core.parser.EndOfFile;
|
|||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerException;
|
||||
import org.eclipse.cdt.internal.core.parser.Token;
|
||||
|
@ -156,7 +157,7 @@ public class ScannerTestCase extends BaseScannerTest
|
|||
public final static int SIZEOF_TRUTHTABLE = 10;
|
||||
|
||||
|
||||
public void testWeirdStrings()
|
||||
public void testWeirdStrings() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -174,7 +175,7 @@ public class ScannerTestCase extends BaseScannerTest
|
|||
}
|
||||
|
||||
|
||||
public void testNumerics()
|
||||
public void testNumerics()throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -205,7 +206,7 @@ public class ScannerTestCase extends BaseScannerTest
|
|||
super(name);
|
||||
}
|
||||
|
||||
public void testPreprocessorDefines()
|
||||
public void testPreprocessorDefines()throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -848,7 +849,7 @@ public class ScannerTestCase extends BaseScannerTest
|
|||
}
|
||||
}
|
||||
|
||||
public void testQuickScan() throws EndOfFile
|
||||
public void testQuickScan() throws EndOfFile, ParserFactoryException
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -924,7 +925,7 @@ public class ScannerTestCase extends BaseScannerTest
|
|||
|
||||
}
|
||||
|
||||
public void testOtherPreprocessorCommands()
|
||||
public void testOtherPreprocessorCommands() throws ParserFactoryException
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -1033,7 +1034,7 @@ public class ScannerTestCase extends BaseScannerTest
|
|||
validateEOF();
|
||||
}
|
||||
|
||||
public void testBug35892()
|
||||
public void testBug35892() throws ParserFactoryException
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -1064,7 +1065,7 @@ public class ScannerTestCase extends BaseScannerTest
|
|||
validateString( "\\\"\\\\");
|
||||
}
|
||||
|
||||
public void testConditionalWithBraces()
|
||||
public void testConditionalWithBraces() throws ParserFactoryException
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.eclipse.cdt.core.parser.IParser;
|
|||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
|
||||
|
@ -280,7 +280,7 @@ public class TortureTest extends FractionalAutomatedTest {
|
|||
ParserMode parserMode = quickParse ? ParserMode.QUICK_PARSE : ParserMode.COMPLETE_PARSE;
|
||||
ParserLanguage language = cppNature ? ParserLanguage.CPP : ParserLanguage.C;
|
||||
parser = ParserFactory.createParser(
|
||||
ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), parserMode, language, nullCallback ), nullCallback, parserMode, language);
|
||||
ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), parserMode, language, nullCallback, null ), nullCallback, parserMode, language, null);
|
||||
|
||||
mapping = ParserFactory.createLineOffsetReconciler( new StringReader( code ) );
|
||||
|
||||
|
|
|
@ -18,11 +18,11 @@ import junit.framework.TestCase;
|
|||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
|
@ -55,11 +55,11 @@ public class ParseTestOnSearchFiles extends TestCase
|
|||
fileIn = new FileInputStream(name);
|
||||
}
|
||||
|
||||
public void testParseOfAndrewsFile()
|
||||
public void testParseOfAndrewsFile() throws Exception
|
||||
{
|
||||
ISourceElementRequestor requestor = new NullSourceElementRequestor();
|
||||
IScanner scanner = ParserFactory.createScanner( new InputStreamReader( fileIn ), name, new ScannerInfo(), ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, requestor );
|
||||
IParser parser = ParserFactory.createParser( scanner, requestor, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP );
|
||||
IScanner scanner = ParserFactory.createScanner( new InputStreamReader( fileIn ), name, new ScannerInfo(), ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, requestor, null );
|
||||
IParser parser = ParserFactory.createParser( scanner, requestor, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, null );
|
||||
assertTrue( parser.parse() );
|
||||
}
|
||||
|
||||
|
|
|
@ -21,15 +21,17 @@ import java.io.StringReader;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.ICLogConstants;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.index.IDocument;
|
||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
||||
|
@ -84,9 +86,16 @@ public class SourceIndexer extends AbstractIndexer {
|
|||
//C or CPP?
|
||||
ParserLanguage language = CoreModel.getDefault().hasCCNature(currentProject) ? ParserLanguage.CPP : ParserLanguage.C;
|
||||
|
||||
IParser parser = ParserFactory.createParser(
|
||||
ParserFactory.createScanner( new StringReader( document.getStringContent() ), resourceFile.getLocation().toOSString(), scanInfo, ParserMode.COMPLETE_PARSE, language, requestor ),
|
||||
requestor, ParserMode.COMPLETE_PARSE, language );
|
||||
IParser parser = null;
|
||||
|
||||
try
|
||||
{
|
||||
parser = ParserFactory.createParser(
|
||||
ParserFactory.createScanner( new StringReader( document.getStringContent() ), resourceFile.getLocation().toOSString(), scanInfo, ParserMode.COMPLETE_PARSE, language, requestor, ParserUtil.getParserLogService() ),
|
||||
requestor, ParserMode.COMPLETE_PARSE, language, ParserUtil.getParserLogService() );
|
||||
} catch( ParserFactoryException pfe )
|
||||
{
|
||||
}
|
||||
|
||||
boolean retVal = parser.parse();
|
||||
|
||||
|
|
|
@ -22,8 +22,11 @@ import org.eclipse.cdt.core.model.ITemplate;
|
|||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
||||
|
@ -48,7 +51,6 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifierOwner;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.parser.util.ASTUtil;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
||||
|
@ -71,9 +73,18 @@ public class CModelBuilder {
|
|||
quickParseCallback = ParserFactory.createQuickParseCallback();
|
||||
|
||||
ParserLanguage language = hasCppNature ? ParserLanguage.CPP : ParserLanguage.C;
|
||||
IParser parser = ParserFactory.createParser(
|
||||
ParserFactory.createScanner( new StringReader( code ), "code",
|
||||
new ScannerInfo(), mode, language, quickParseCallback), quickParseCallback, mode, language );
|
||||
|
||||
IParser parser = null;
|
||||
try
|
||||
{
|
||||
parser = ParserFactory.createParser(
|
||||
ParserFactory.createScanner( new StringReader( code ), "code",
|
||||
new ScannerInfo(), mode, language, quickParseCallback, ParserUtil.getParserLogService()), quickParseCallback, mode, language, ParserUtil.getParserLogService() );
|
||||
}
|
||||
catch( ParserFactoryException pfe )
|
||||
{
|
||||
throw new ParserException( "Parser/Scanner construction failure.");
|
||||
}
|
||||
|
||||
if( ! parser.parse() && throwExceptionOnError )
|
||||
throw new ParserException("Parse failure");
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2003-11-05 John Camelon
|
||||
Cleaned up the ParserFactory interface to check for validity of input arguments.
|
||||
Moved NullSourceElementRequestor and ScannerInfo to public interface as requested.
|
||||
Restructured code so that no Eclipse/CDT source outside the parser source directory is used.
|
||||
Updated parser clients to use new ParserFactory (stand-alone parser work item).
|
||||
|
||||
2003-11-05 John Camelon
|
||||
Removed warnings from parser source tree.
|
||||
Removed preliminary task tags support to clean up parser interfaces and implementation.
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/**********************************************************************
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class DefaultLogService implements IParserLogService
|
||||
{
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IParserLogService#traceLog(java.lang.String)
|
||||
*/
|
||||
public void traceLog(String message)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IParserLogService#errorLog(java.lang.String)
|
||||
*/
|
||||
public void errorLog(String message)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/**********************************************************************
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IParserLogService
|
||||
{
|
||||
|
||||
public void traceLog( String message );
|
||||
public void errorLog( String message );
|
||||
|
||||
}
|
|
@ -1,9 +1,5 @@
|
|||
package org.eclipse.cdt.internal.core.parser;
|
||||
package org.eclipse.cdt.core.parser;
|
||||
|
||||
import org.eclipse.cdt.core.parser.DefaultProblemHandler;
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
|
@ -14,7 +14,6 @@ import java.io.Reader;
|
|||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.LineOffsetReconciler;
|
||||
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
||||
import org.eclipse.cdt.internal.core.parser.Preprocessor;
|
||||
import org.eclipse.cdt.internal.core.parser.QuickParseCallback;
|
||||
|
@ -37,26 +36,34 @@ public class ParserFactory {
|
|||
return new CompleteParseASTFactory( language );
|
||||
}
|
||||
|
||||
public static IParser createParser( IScanner scanner, ISourceElementRequestor callback, ParserMode mode, ParserLanguage language )
|
||||
public static IParser createParser( IScanner scanner, ISourceElementRequestor callback, ParserMode mode, ParserLanguage language, IParserLogService log ) throws ParserFactoryException
|
||||
{
|
||||
if( scanner == null ) throw new ParserFactoryException( ParserFactoryException.Kind.NULL_SCANNER );
|
||||
if( language == null ) throw new ParserFactoryException( ParserFactoryException.Kind.NULL_LANGUAGE );
|
||||
IParserLogService logService = ( log == null ) ? createDefaultLogService() : log;
|
||||
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode );
|
||||
ISourceElementRequestor ourCallback = (( callback == null) ? new NullSourceElementRequestor() : callback );
|
||||
return new Parser( scanner, ourCallback, ourMode, language );
|
||||
return new Parser( scanner, ourCallback, ourMode, language, logService );
|
||||
}
|
||||
|
||||
public static IScanner createScanner( Reader input, String fileName, IScannerInfo config, ParserMode mode, ParserLanguage language, ISourceElementRequestor requestor )
|
||||
public static IScanner createScanner( Reader input, String fileName, IScannerInfo config, ParserMode mode, ParserLanguage language, ISourceElementRequestor requestor, IParserLogService log ) throws ParserFactoryException
|
||||
{
|
||||
if( input == null ) throw new ParserFactoryException( ParserFactoryException.Kind.NULL_READER );
|
||||
if( fileName == null ) throw new ParserFactoryException( ParserFactoryException.Kind.NULL_FILENAME );
|
||||
if( config == null ) throw new ParserFactoryException( ParserFactoryException.Kind.NULL_CONFIG );
|
||||
if( language == null ) throw new ParserFactoryException( ParserFactoryException.Kind.NULL_LANGUAGE );
|
||||
IParserLogService logService = ( log == null ) ? createDefaultLogService() : log;
|
||||
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode );
|
||||
ISourceElementRequestor ourRequestor = (( requestor == null) ? new NullSourceElementRequestor() : requestor );
|
||||
IScanner s = new Scanner( input, fileName, config, ourRequestor, ourMode, language );
|
||||
IScanner s = new Scanner( input, fileName, config, ourRequestor, ourMode, language, logService );
|
||||
return s;
|
||||
}
|
||||
|
||||
public static IPreprocessor createPreprocessor( Reader input, String fileName, IScannerInfo info, ParserMode mode, ParserLanguage language, ISourceElementRequestor requestor )
|
||||
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 );
|
||||
IPreprocessor s = new Preprocessor( input, fileName, info, ourRequestor, ourMode, language, logService );
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -70,4 +77,10 @@ public class ParserFactory {
|
|||
return new QuickParseCallback();
|
||||
}
|
||||
|
||||
public static IParserLogService createDefaultLogService()
|
||||
{
|
||||
return defaultLogService;
|
||||
}
|
||||
|
||||
private static IParserLogService defaultLogService = new DefaultLogService();
|
||||
}
|
||||
|
|
|
@ -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.core.parser;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ParserFactoryException extends Exception {
|
||||
|
||||
public static class Kind extends Enum {
|
||||
|
||||
public static final Kind NULL_READER = new Kind( 1 );
|
||||
public static final Kind NULL_FILENAME = new Kind( 2 );
|
||||
public static final Kind NULL_CONFIG = new Kind( 3 );
|
||||
public static final Kind NULL_LANGUAGE = new Kind( 4 );
|
||||
public static final Kind NULL_SCANNER = new Kind( 5 );
|
||||
|
||||
protected Kind( int arg )
|
||||
{
|
||||
super( arg );
|
||||
}
|
||||
}
|
||||
|
||||
public ParserFactoryException( Kind e )
|
||||
{
|
||||
kind = e;
|
||||
}
|
||||
|
||||
public Kind getKind()
|
||||
{
|
||||
return kind;
|
||||
}
|
||||
|
||||
private Kind kind;
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser;
|
||||
package org.eclipse.cdt.core.parser;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -14,10 +14,10 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
import org.eclipse.cdt.core.ICLogConstants;
|
||||
import org.eclipse.cdt.core.parser.Backtrack;
|
||||
import org.eclipse.cdt.core.parser.EndOfFile;
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
|
@ -60,8 +60,6 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||
import org.eclipse.cdt.internal.core.model.IDebugLogConstants;
|
||||
import org.eclipse.cdt.internal.core.model.Util;
|
||||
|
||||
/**
|
||||
* This is our first implementation of the IParser interface, serving as a parser for
|
||||
|
@ -73,7 +71,8 @@ import org.eclipse.cdt.internal.core.model.Util;
|
|||
*/
|
||||
public class Parser implements IParser
|
||||
{
|
||||
private static final List EMPTY_LIST = new ArrayList();
|
||||
protected final IParserLogService log;
|
||||
private static final List EMPTY_LIST = new ArrayList();
|
||||
private static int DEFAULT_OFFSET = -1;
|
||||
// sentinel initial value for offsets
|
||||
private int firstErrorOffset = DEFAULT_OFFSET;
|
||||
|
@ -119,7 +118,7 @@ public class Parser implements IParser
|
|||
IScanner scanner,
|
||||
ISourceElementRequestor callback,
|
||||
ParserMode mode,
|
||||
ParserLanguage language )
|
||||
ParserLanguage language, IParserLogService log )
|
||||
{
|
||||
this.scanner = scanner;
|
||||
requestor = callback;
|
||||
|
@ -127,6 +126,7 @@ public class Parser implements IParser
|
|||
this.language = language;
|
||||
astFactory = ParserFactory.createASTFactory( mode, language);
|
||||
scanner.setASTFactory(astFactory);
|
||||
this.log = log;
|
||||
}
|
||||
// counter that keeps track of the number of times Parser.parse() is called
|
||||
private static int parseCount = 0;
|
||||
|
@ -140,13 +140,13 @@ public class Parser implements IParser
|
|||
// For the debuglog to take place, you have to call
|
||||
// Util.setDebugging(true);
|
||||
// Or set debug to true in the core plugin preference
|
||||
Util.debugLog(
|
||||
log.traceLog(
|
||||
"Parse "
|
||||
+ (++parseCount)
|
||||
+ ": "
|
||||
+ (System.currentTimeMillis() - startTime)
|
||||
+ "ms"
|
||||
+ (parsePassed ? "" : " - parse failure"), IDebugLogConstants.PARSER);
|
||||
+ (parsePassed ? "" : " - parse failure") );
|
||||
return parsePassed;
|
||||
}
|
||||
|
||||
|
@ -2254,9 +2254,9 @@ public class Parser implements IParser
|
|||
catch (Backtrack e)
|
||||
{
|
||||
failParse();
|
||||
Util.debugLog(
|
||||
log.traceLog(
|
||||
"Unexpected Token ="
|
||||
+ image,IDebugLogConstants.PARSER);
|
||||
+ image );
|
||||
consume();
|
||||
// eat this token anyway
|
||||
continue;
|
||||
|
@ -5142,8 +5142,8 @@ public class Parser implements IParser
|
|||
}
|
||||
catch (ScannerException e)
|
||||
{
|
||||
Util.debugLog( "ScannerException thrown : " + e.getMessage(), IDebugLogConstants.PARSER );
|
||||
org.eclipse.cdt.internal.core.model.Util.log(e, "Scanner Exception: " + e.getMessage() , ICLogConstants.CDT); //$NON-NLS-1$h
|
||||
log.traceLog( "ScannerException thrown : " + e.getProblem().getMessage() );
|
||||
log.errorLog( "Scanner Exception: " + e.getProblem().getMessage()); //$NON-NLS-1$h
|
||||
failParse();
|
||||
return fetchToken();
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@ package org.eclipse.cdt.internal.core.parser;
|
|||
|
||||
import java.io.Reader;
|
||||
|
||||
import org.eclipse.cdt.core.ICLogConstants;
|
||||
import org.eclipse.cdt.core.parser.EndOfFile;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IPreprocessor;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
|
@ -33,8 +33,8 @@ public class Preprocessor extends Scanner implements IPreprocessor {
|
|||
* @param filename
|
||||
* @param defns
|
||||
*/
|
||||
public Preprocessor(Reader reader, String filename, IScannerInfo info, ISourceElementRequestor requestor, ParserMode mode, ParserLanguage language ) {
|
||||
super(reader, filename, info, requestor, mode, language );
|
||||
public Preprocessor(Reader reader, String filename, IScannerInfo info, ISourceElementRequestor requestor, ParserMode mode, ParserLanguage language, IParserLogService logService ) {
|
||||
super(reader, filename, info, requestor, mode, language, logService );
|
||||
}
|
||||
|
||||
public void process()
|
||||
|
@ -47,8 +47,7 @@ public class Preprocessor extends Scanner implements IPreprocessor {
|
|||
catch( ScannerException se )
|
||||
{
|
||||
// callback IProblem here
|
||||
org.eclipse.cdt.internal.core.model.Util.log(se, "Preprocessor Exception", ICLogConstants.CDT); //$NON-NLS-1$h
|
||||
|
||||
log.errorLog("Preprocessor Exception "+ se.getProblem().getMessage()); //$NON-NLS-1$h
|
||||
}
|
||||
catch( EndOfFile eof )
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.eclipse.cdt.core.parser.*;
|
||||
import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
|
|
|
@ -31,22 +31,23 @@ import org.eclipse.cdt.core.parser.EndOfFile;
|
|||
import org.eclipse.cdt.core.parser.ILineOffsetReconciler;
|
||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerException;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ast.ExpressionEvaluationException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
||||
import org.eclipse.cdt.internal.core.model.IDebugLogConstants;
|
||||
import org.eclipse.cdt.internal.core.model.Util;
|
||||
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -55,6 +56,8 @@ import org.eclipse.cdt.internal.core.model.Util;
|
|||
|
||||
public class Scanner implements IScanner {
|
||||
|
||||
protected final IParserLogService log;
|
||||
private final static String SCRATCH = "<scratch>";
|
||||
private Reader backupReader;
|
||||
private IProblemFactory problemFactory = new ScannerProblemFactory();
|
||||
|
||||
|
@ -76,7 +79,8 @@ public class Scanner implements IScanner {
|
|||
throw new ScannerException( p );
|
||||
}
|
||||
|
||||
public Scanner(Reader reader, String filename, IScannerInfo info, ISourceElementRequestor requestor, ParserMode parserMode, ParserLanguage language ) {
|
||||
public Scanner(Reader reader, String filename, IScannerInfo info, ISourceElementRequestor requestor, ParserMode parserMode, ParserLanguage language, IParserLogService log ) {
|
||||
this.log = log;
|
||||
this.requestor = requestor;
|
||||
this.mode = parserMode;
|
||||
this.language = language;
|
||||
|
@ -1887,14 +1891,21 @@ public class Scanner implements IScanner {
|
|||
else
|
||||
{
|
||||
final NullSourceElementRequestor nullCallback = new NullSourceElementRequestor();
|
||||
IScanner trial =
|
||||
ParserFactory.createScanner(
|
||||
new StringReader(expression + ";"),
|
||||
EXPRESSION,
|
||||
new ScannerInfo( definitions, originalConfig.getIncludePaths()),
|
||||
ParserMode.QUICK_PARSE, language, nullCallback );
|
||||
IParser parser = ParserFactory.createParser(trial, nullCallback, ParserMode.QUICK_PARSE, language );
|
||||
|
||||
IParser parser = null;
|
||||
try
|
||||
{
|
||||
IScanner trial =
|
||||
ParserFactory.createScanner(
|
||||
new StringReader(expression + ";"),
|
||||
EXPRESSION,
|
||||
new ScannerInfo( definitions, originalConfig.getIncludePaths()),
|
||||
ParserMode.QUICK_PARSE, language, nullCallback, log );
|
||||
parser = ParserFactory.createParser(trial, nullCallback, ParserMode.QUICK_PARSE, language, log );
|
||||
} catch( ParserFactoryException pfe )
|
||||
{
|
||||
// TODO - make INTERNAL IProblem
|
||||
// should never happen
|
||||
}
|
||||
try {
|
||||
IASTExpression exp = parser.expression(null);
|
||||
if( exp.evaluateExpression() == 0 )
|
||||
|
@ -1988,7 +1999,7 @@ public class Scanner implements IScanner {
|
|||
new ScannerInfo(definitions, originalConfig.getIncludePaths()),
|
||||
new NullSourceElementRequestor(),
|
||||
mode,
|
||||
language );
|
||||
language, log );
|
||||
IToken t = null;
|
||||
|
||||
try {
|
||||
|
@ -2142,7 +2153,18 @@ public class Scanner implements IScanner {
|
|||
|
||||
if( ! replacementString.equals( "" ) )
|
||||
{
|
||||
IScanner helperScanner = ParserFactory.createScanner( new StringReader(replacementString), null, new ScannerInfo( ), mode, language, new NullSourceElementRequestor() );
|
||||
IScanner helperScanner=null;
|
||||
try {
|
||||
helperScanner =
|
||||
ParserFactory.createScanner(
|
||||
new StringReader(replacementString),
|
||||
SCRATCH,
|
||||
new ScannerInfo(),
|
||||
mode,
|
||||
language,
|
||||
new NullSourceElementRequestor(), log);
|
||||
} catch (ParserFactoryException e1) {
|
||||
}
|
||||
helperScanner.setTokenizingMacroReplacementList( true );
|
||||
IToken t = helperScanner.nextToken(false);
|
||||
|
||||
|
@ -2227,7 +2249,7 @@ public class Scanner implements IScanner {
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
Util.debugLog("Scanner : Encountered unexpected character " + ((char) c), IDebugLogConstants.PARSER);
|
||||
log.traceLog("Scanner : Encountered unexpected character " + ((char) c));
|
||||
handleProblem( IProblem.PREPROCESSOR_INVALID_MACRO_DEFN, "#define " + key + (char)c + getRestOfPreprocessorLine(), beginning, false, true, true );
|
||||
return;
|
||||
}
|
||||
|
@ -2266,9 +2288,9 @@ public class Scanner implements IScanner {
|
|||
if( previousDefinition instanceof String )
|
||||
{
|
||||
Scanner previous = new Scanner( new StringReader( (String)previousDefinition ), "redef-test", new ScannerInfo(), new NullSourceElementRequestor(),
|
||||
mode, language );
|
||||
mode, language, log );
|
||||
Scanner current = new Scanner( new StringReader( (String)newDefinition ), "redef-test", new ScannerInfo(), new NullSourceElementRequestor(),
|
||||
mode, language );
|
||||
mode, language, log );
|
||||
for ( ; ; )
|
||||
{
|
||||
IToken p = null;
|
||||
|
@ -2309,7 +2331,7 @@ public class Scanner implements IScanner {
|
|||
|
||||
protected Vector getMacroParameters (String params, boolean forStringizing) throws ScannerException {
|
||||
|
||||
Scanner tokenizer = new Scanner(new StringReader(params), TEXT, new ScannerInfo( definitions, originalConfig.getIncludePaths() ), new NullSourceElementRequestor(), mode, language);
|
||||
Scanner tokenizer = new Scanner(new StringReader(params), TEXT, new ScannerInfo( definitions, originalConfig.getIncludePaths() ), new NullSourceElementRequestor(), mode, language, log);
|
||||
tokenizer.setThrowExceptionOnBadCharacterRead(false);
|
||||
Vector parameterValues = new Vector();
|
||||
Token t = null;
|
||||
|
@ -2512,9 +2534,9 @@ public class Scanner implements IScanner {
|
|||
}
|
||||
|
||||
} else {
|
||||
Util.debugLog(
|
||||
log.traceLog(
|
||||
"Unexpected class stored in definitions table. "
|
||||
+ expansion.getClass().getName(), IDebugLogConstants.PARSER);
|
||||
+ expansion.getClass().getName() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,10 +24,14 @@ import org.eclipse.cdt.core.parser.IProblem;
|
|||
import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.cdt.core.parser.ScannerException;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||
|
@ -47,8 +51,6 @@ import org.eclipse.cdt.internal.core.index.IEntryResult;
|
|||
import org.eclipse.cdt.internal.core.index.IIndex;
|
||||
import org.eclipse.cdt.internal.core.index.impl.BlocksIndexInput;
|
||||
import org.eclipse.cdt.internal.core.index.impl.IndexInput;
|
||||
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
@ -171,7 +173,20 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
return orPattern;
|
||||
}
|
||||
|
||||
IScanner scanner = ParserFactory.createScanner( new StringReader( patternString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, callback );
|
||||
IScanner scanner = null;
|
||||
try {
|
||||
scanner =
|
||||
ParserFactory.createScanner(
|
||||
new StringReader(patternString),
|
||||
"TEXT",
|
||||
new ScannerInfo(),
|
||||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,
|
||||
ParserUtil.getParserLogService());
|
||||
} catch (ParserFactoryException e) {
|
||||
|
||||
}
|
||||
LinkedList list = scanForNames( scanner, null );
|
||||
|
||||
char [] name = (char []) list.removeLast();
|
||||
|
@ -229,7 +244,19 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
return orPattern;
|
||||
}
|
||||
|
||||
IScanner scanner = ParserFactory.createScanner( new StringReader( patternString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, callback );
|
||||
IScanner scanner=null;
|
||||
try {
|
||||
scanner =
|
||||
ParserFactory.createScanner(
|
||||
new StringReader(patternString),
|
||||
"TEXT",
|
||||
new ScannerInfo(),
|
||||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,ParserUtil.getParserLogService());
|
||||
} catch (ParserFactoryException e) {
|
||||
|
||||
}
|
||||
LinkedList list = scanForNames( scanner, null );
|
||||
|
||||
char [] name = (char []) list.removeLast();
|
||||
|
@ -259,7 +286,18 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
String paramString = ( index == -1 ) ? "" : patternString.substring( index );
|
||||
String nameString = ( index == -1 ) ? patternString : patternString.substring( 0, index );
|
||||
|
||||
IScanner scanner = ParserFactory.createScanner( new StringReader( nameString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, callback );
|
||||
IScanner scanner=null;
|
||||
try {
|
||||
scanner =
|
||||
ParserFactory.createScanner(
|
||||
new StringReader(nameString),
|
||||
"TEXT",
|
||||
new ScannerInfo(),
|
||||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,ParserUtil.getParserLogService());
|
||||
} catch (ParserFactoryException e) {
|
||||
}
|
||||
|
||||
LinkedList names = scanForNames( scanner, null );
|
||||
|
||||
|
@ -306,7 +344,18 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
// return orPattern;
|
||||
// }
|
||||
|
||||
IScanner scanner = ParserFactory.createScanner( new StringReader( patternString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, callback );
|
||||
IScanner scanner =null;
|
||||
try {
|
||||
scanner =
|
||||
ParserFactory.createScanner(
|
||||
new StringReader(patternString),
|
||||
"TEXT",
|
||||
new ScannerInfo(),
|
||||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,ParserUtil.getParserLogService());
|
||||
} catch (ParserFactoryException e1) {
|
||||
}
|
||||
|
||||
IToken token = null;
|
||||
ASTClassKind kind = null;
|
||||
|
@ -359,9 +408,29 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
|
||||
String functionString = "void f " + paramString + ";";
|
||||
|
||||
IScanner scanner = ParserFactory.createScanner( new StringReader( functionString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, callback );
|
||||
IScanner scanner=null;
|
||||
try {
|
||||
scanner =
|
||||
ParserFactory.createScanner(
|
||||
new StringReader(functionString),
|
||||
"TEXT",
|
||||
new ScannerInfo(),
|
||||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,ParserUtil.getParserLogService());
|
||||
} catch (ParserFactoryException e1) {
|
||||
}
|
||||
IQuickParseCallback callback = ParserFactory.createQuickParseCallback();
|
||||
IParser parser = ParserFactory.createParser( scanner, callback, ParserMode.QUICK_PARSE, ParserLanguage.CPP );
|
||||
IParser parser=null;
|
||||
try {
|
||||
parser =
|
||||
ParserFactory.createParser(
|
||||
scanner,
|
||||
callback,
|
||||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP, ParserUtil.getParserLogService());
|
||||
} catch (ParserFactoryException e2) {
|
||||
}
|
||||
|
||||
if( parser.parse() ){
|
||||
IASTCompilationUnit compUnit = callback.getCompilationUnit();
|
||||
|
|
|
@ -35,8 +35,11 @@ import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
|||
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.ParserFactoryException;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
||||
|
@ -78,7 +81,6 @@ import org.eclipse.cdt.core.search.ICSearchResultCollector;
|
|||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.core.search.IMatch;
|
||||
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -434,8 +436,17 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
|||
//TODO no project, what language do we use?
|
||||
language = ParserLanguage.CPP;
|
||||
}
|
||||
IScanner scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETE_PARSE, language, this );
|
||||
IParser parser = ParserFactory.createParser( scanner, this, ParserMode.COMPLETE_PARSE, language );
|
||||
|
||||
IParser parser = null;
|
||||
try
|
||||
{
|
||||
IScanner scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETE_PARSE, language, this, ParserUtil.getParserLogService() );
|
||||
parser = ParserFactory.createParser( scanner, this, ParserMode.COMPLETE_PARSE, language, ParserUtil.getParserLogService() );
|
||||
}
|
||||
catch( ParserFactoryException pfe )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (VERBOSE)
|
||||
MatchLocator.verbose("*** New Search for path: " + pathString);
|
||||
|
|
|
@ -25,7 +25,6 @@ public interface ICLogConstants {
|
|||
|
||||
|
||||
public static final LogConst PDE = new LogConst( 1 );
|
||||
|
||||
public static final LogConst CDT = new LogConst( 2 );
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/**********************************************************************
|
||||
* 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;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.ParserLogService;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ParserUtil
|
||||
{
|
||||
public static IParserLogService getParserLogService()
|
||||
{
|
||||
return parserLogService;
|
||||
}
|
||||
|
||||
private static IParserLogService parserLogService = new ParserLogService();
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/**********************************************************************
|
||||
* 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 org.eclipse.cdt.core.ICLogConstants;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.internal.core.model.IDebugLogConstants;
|
||||
import org.eclipse.cdt.internal.core.model.Util;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ParserLogService implements IParserLogService
|
||||
{
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IParserLogService#traceLog(java.lang.String)
|
||||
*/
|
||||
public void traceLog(String message)
|
||||
{
|
||||
Util.debugLog( message, IDebugLogConstants.PARSER );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IParserLogService#errorLog(java.lang.String)
|
||||
*/
|
||||
public void errorLog(String message)
|
||||
{
|
||||
Util.log( message, ICLogConstants.CDT );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,3 +1,6 @@
|
|||
2003-11-05 John Camelon
|
||||
Updated parser clients to use new ParserFactory (stand-alone parser work item).
|
||||
|
||||
2003-11-05 John Camelon
|
||||
Updated parser clients to use new IProblem strategy.
|
||||
|
||||
|
|
|
@ -12,13 +12,14 @@ import java.io.InputStreamReader;
|
|||
import java.io.StringReader;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.compare.IEditableContent;
|
||||
import org.eclipse.compare.IStreamContentAccessor;
|
||||
|
@ -72,13 +73,15 @@ public class CStructureCreator implements IStructureCreator {
|
|||
//are bugs while parsing C files, we might want to create a separate Structure
|
||||
//compare for c files, but we'll never be completely right about .h files
|
||||
IScanner scanner =
|
||||
ParserFactory.createScanner(new StringReader(s), "code", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, builder);
|
||||
IParser parser = ParserFactory.createParser(scanner, builder, ParserMode.QUICK_PARSE, ParserLanguage.CPP );
|
||||
ParserFactory.createScanner(new StringReader(s), "code", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, builder,ParserUtil.getParserLogService());
|
||||
IParser parser = ParserFactory.createParser(scanner, builder, ParserMode.QUICK_PARSE, ParserLanguage.CPP, ParserUtil.getParserLogService() );
|
||||
parser.parse();
|
||||
} catch (Exception e) {
|
||||
// What to do when error ?
|
||||
// The CParseTreeBuilder will throw CParseTreeBuilder.ParseError
|
||||
// for acceptProblem.
|
||||
|
||||
//TODO : New : ParserFactoryException gets thrown by ParserFactory primitives
|
||||
}
|
||||
|
||||
return root;
|
||||
|
|
Loading…
Add table
Reference in a new issue