mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 14:15:23 +02:00
Added traceLogs into Scanner. Fixed Bug 46402 : expression evaluation error on branch not taken. Added beginning of IScannerExtension and GCCScannerExtension support for gcc specific aspects. Added separate Scanner log category for tracing and updated clients to use it.
This commit is contained in:
parent
d4ca6eb809
commit
b5d5e34e25
37 changed files with 387 additions and 159 deletions
|
@ -1,3 +1,7 @@
|
|||
2004-01-26 John Camelon
|
||||
Updated clients to use new Scanner logging service.
|
||||
Added ScannerTestCase.testBug46402().
|
||||
|
||||
2004-01-22 John Camelon
|
||||
Updated Scanner tests for package updates in the core.
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ 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.NullLogService;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
|
@ -982,7 +983,7 @@ 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, null);
|
||||
"TEST", info, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, callback, new NullLogService());
|
||||
|
||||
IParser parser = ParserFactory.createParser( scanner, callback, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, null );
|
||||
assertTrue( parser.parse() );
|
||||
|
|
|
@ -17,6 +17,7 @@ import junit.framework.TestCase;
|
|||
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
||||
import org.eclipse.cdt.core.parser.NullLogService;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
|
@ -50,7 +51,7 @@ public class BaseASTTest extends TestCase
|
|||
{
|
||||
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, null), quickParseCallback, mode, lang, null );
|
||||
parser = ParserFactory.createParser( ParserFactory.createScanner( new StringReader( code ), "code", new ScannerInfo(), mode, lang, quickParseCallback, new NullLogService()), quickParseCallback, mode, lang, null );
|
||||
if( ! parser.parse() && throwExceptionOnError )
|
||||
throw new ParserException("Parse failure");
|
||||
return quickParseCallback.getCompilationUnit();
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2003,2004 IBM 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 Corp. - Rational Software - initial implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests;
|
||||
|
||||
import java.util.EmptyStackException;
|
||||
|
@ -8,11 +18,6 @@ import org.eclipse.cdt.internal.core.parser.scanner.BranchTracker;
|
|||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
* To change this generated comment edit the template variable "typecomment":
|
||||
* Window>Preferences>Java>Templates.
|
||||
* To enable and disable the creation of type comments go to
|
||||
* Window>Preferences>Java>Code Generation.
|
||||
*/
|
||||
public class BranchTrackerTest extends TestCase {
|
||||
|
||||
|
@ -42,13 +47,13 @@ public class BranchTrackerTest extends TestCase {
|
|||
* #endif
|
||||
*/
|
||||
|
||||
assertFalse( bt.poundif( false ) );
|
||||
assertFalse( bt.poundif( true ) );
|
||||
assertFalse( bt.poundelif( true ) );
|
||||
assertFalse( bt.poundelse() );
|
||||
assertFalse( bt.poundendif() );
|
||||
assertTrue( bt.poundelse() );
|
||||
assertTrue( bt.poundendif() );
|
||||
assertFalse( bt.poundIf( false ) );
|
||||
assertFalse( bt.poundIf( true ) );
|
||||
assertFalse( bt.poundElif( true ) );
|
||||
assertFalse( bt.poundElse() );
|
||||
assertFalse( bt.poundEndif() );
|
||||
assertTrue( bt.poundElse() );
|
||||
assertTrue( bt.poundEndif() );
|
||||
|
||||
/*
|
||||
* #if 0
|
||||
|
@ -67,19 +72,19 @@ public class BranchTrackerTest extends TestCase {
|
|||
*/
|
||||
|
||||
bt = new BranchTracker();
|
||||
assertFalse( bt.poundif( false ) );
|
||||
assertFalse( bt.poundif( true ));
|
||||
assertFalse( bt.poundelif( true ) );
|
||||
assertFalse( bt.poundelse() );
|
||||
assertFalse( bt.poundendif() );
|
||||
assertTrue( bt.poundelse() );
|
||||
assertFalse( bt.poundif( false ) );
|
||||
assertTrue( bt.poundelif( true ) );
|
||||
assertFalse( bt.poundelif( false ) );
|
||||
assertFalse( bt.poundelif( true ) );
|
||||
assertFalse( bt.poundelse() );
|
||||
assertTrue( bt.poundendif() );
|
||||
assertTrue( bt.poundendif() );
|
||||
assertFalse( bt.poundIf( false ) );
|
||||
assertFalse( bt.poundIf( true ));
|
||||
assertFalse( bt.poundElif( true ) );
|
||||
assertFalse( bt.poundElse() );
|
||||
assertFalse( bt.poundEndif() );
|
||||
assertTrue( bt.poundElse() );
|
||||
assertFalse( bt.poundIf( false ) );
|
||||
assertTrue( bt.poundElif( true ) );
|
||||
assertFalse( bt.poundElif( false ) );
|
||||
assertFalse( bt.poundElif( true ) );
|
||||
assertFalse( bt.poundElse() );
|
||||
assertTrue( bt.poundEndif() );
|
||||
assertTrue( bt.poundEndif() );
|
||||
assertEquals( 0, bt.getDepth() );
|
||||
|
||||
/*
|
||||
|
@ -110,31 +115,31 @@ public class BranchTrackerTest extends TestCase {
|
|||
* #endif
|
||||
*/
|
||||
|
||||
assertFalse(bt.poundif(false));
|
||||
assertFalse(bt.poundif(true));
|
||||
assertFalse(bt.poundelif(false));
|
||||
assertFalse(bt.poundelif(true));
|
||||
assertFalse(bt.poundelse());
|
||||
assertFalse( bt.poundendif() );
|
||||
assertFalse(bt.poundelif(false));
|
||||
assertFalse(bt.poundif(false));
|
||||
assertFalse(bt.poundelif(false));
|
||||
assertFalse(bt.poundelif(true));
|
||||
assertFalse(bt.poundelse());
|
||||
assertFalse( bt.poundendif());
|
||||
assertTrue(bt.poundelif(true));
|
||||
assertFalse(bt.poundif(false));
|
||||
assertFalse(bt.poundelif(false));
|
||||
assertFalse(bt.poundelif(false));
|
||||
assertTrue(bt.poundelse());
|
||||
assertTrue( bt.poundendif() );
|
||||
assertFalse(bt.poundelse());
|
||||
assertFalse(bt.poundif(true));
|
||||
assertFalse(bt.poundelif(false));
|
||||
assertFalse(bt.poundelif(true));
|
||||
assertFalse(bt.poundelse());
|
||||
assertFalse( bt.poundendif() );
|
||||
assertTrue( bt.poundendif() );
|
||||
assertFalse(bt.poundIf(false));
|
||||
assertFalse(bt.poundIf(true));
|
||||
assertFalse(bt.poundElif(false));
|
||||
assertFalse(bt.poundElif(true));
|
||||
assertFalse(bt.poundElse());
|
||||
assertFalse( bt.poundEndif() );
|
||||
assertFalse(bt.poundElif(false));
|
||||
assertFalse(bt.poundIf(false));
|
||||
assertFalse(bt.poundElif(false));
|
||||
assertFalse(bt.poundElif(true));
|
||||
assertFalse(bt.poundElse());
|
||||
assertFalse( bt.poundEndif());
|
||||
assertTrue(bt.poundElif(true));
|
||||
assertFalse(bt.poundIf(false));
|
||||
assertFalse(bt.poundElif(false));
|
||||
assertFalse(bt.poundElif(false));
|
||||
assertTrue(bt.poundElse());
|
||||
assertTrue( bt.poundEndif() );
|
||||
assertFalse(bt.poundElse());
|
||||
assertFalse(bt.poundIf(true));
|
||||
assertFalse(bt.poundElif(false));
|
||||
assertFalse(bt.poundElif(true));
|
||||
assertFalse(bt.poundElse());
|
||||
assertFalse( bt.poundEndif() );
|
||||
assertTrue( bt.poundEndif() );
|
||||
assertEquals(0, bt.getDepth());
|
||||
} catch (EmptyStackException se) {
|
||||
fail("Unexpected Scanner exception thrown");
|
||||
|
@ -152,9 +157,9 @@ public class BranchTrackerTest extends TestCase {
|
|||
* #endif
|
||||
*/
|
||||
BranchTracker bt = new BranchTracker();
|
||||
assertTrue( bt.poundif( true ) );
|
||||
assertFalse( bt.poundelse() );
|
||||
assertTrue( bt.poundendif() );
|
||||
assertTrue( bt.poundIf( true ) );
|
||||
assertFalse( bt.poundElse() );
|
||||
assertTrue( bt.poundEndif() );
|
||||
|
||||
/*
|
||||
* code sequence is
|
||||
|
@ -167,13 +172,13 @@ public class BranchTrackerTest extends TestCase {
|
|||
* #endif
|
||||
*/
|
||||
bt = new BranchTracker();
|
||||
assertTrue( bt.poundif( true ));
|
||||
assertFalse( bt.poundif( false ));
|
||||
assertFalse( bt.poundelif( false ));
|
||||
assertTrue( bt.poundelse());
|
||||
assertTrue( bt.poundendif() );
|
||||
assertFalse( bt.poundelse() );
|
||||
assertTrue( bt.poundendif() );
|
||||
assertTrue( bt.poundIf( true ));
|
||||
assertFalse( bt.poundIf( false ));
|
||||
assertFalse( bt.poundElif( false ));
|
||||
assertTrue( bt.poundElse());
|
||||
assertTrue( bt.poundEndif() );
|
||||
assertFalse( bt.poundElse() );
|
||||
assertTrue( bt.poundEndif() );
|
||||
|
||||
/*
|
||||
* #if 1
|
||||
|
@ -184,11 +189,11 @@ public class BranchTrackerTest extends TestCase {
|
|||
*/
|
||||
|
||||
bt = new BranchTracker();
|
||||
assertTrue( bt.poundif( true ) );
|
||||
assertFalse( bt.poundelif( true ));
|
||||
assertFalse( bt.poundelif( false ));
|
||||
assertFalse( bt.poundelse());
|
||||
assertTrue( bt.poundendif() );
|
||||
assertTrue( bt.poundIf( true ) );
|
||||
assertFalse( bt.poundElif( true ));
|
||||
assertFalse( bt.poundElif( false ));
|
||||
assertFalse( bt.poundElse());
|
||||
assertTrue( bt.poundEndif() );
|
||||
|
||||
|
||||
}
|
||||
|
@ -197,5 +202,4 @@ public class BranchTrackerTest extends TestCase {
|
|||
fail( "Exception" );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.parser.IParser;
|
|||
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.NullLogService;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
|
@ -697,7 +698,7 @@ public class CompleteParseBaseTest extends TestCase
|
|||
callback = new FullParseCallback();
|
||||
IParser parser = ParserFactory.createParser(
|
||||
ParserFactory.createScanner( new StringReader( code ), "test-code", new ScannerInfo(),
|
||||
ParserMode.COMPLETE_PARSE, language, callback, null ), callback, ParserMode.COMPLETE_PARSE, language, null
|
||||
ParserMode.COMPLETE_PARSE, language, callback, new NullLogService() ), callback, ParserMode.COMPLETE_PARSE, language, null
|
||||
);
|
||||
if( ! parser.parse() && throwOnError ) throw new ParserException( "FAILURE");
|
||||
return callback.getCompilationUnit();
|
||||
|
|
|
@ -12,10 +12,11 @@ import java.io.Writer;
|
|||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.NullLogService;
|
||||
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.ParserUtil;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||
|
@ -28,7 +29,6 @@ import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.ILookupResult;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserLogService;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -45,7 +45,6 @@ public class ContextualParseTest extends CompleteParseBaseTest {
|
|||
|
||||
protected IASTCompletionNode parse(String code, int offset)
|
||||
throws Exception {
|
||||
IParserLogService log = new ParserLogService();
|
||||
callback = new FullParseCallback();
|
||||
IParser parser = null;
|
||||
|
||||
|
@ -58,11 +57,11 @@ public class ContextualParseTest extends CompleteParseBaseTest {
|
|||
ParserMode.COMPLETION_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,
|
||||
log),
|
||||
new NullLogService()),
|
||||
callback,
|
||||
ParserMode.COMPLETION_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
log);
|
||||
ParserUtil.getParserLogService());
|
||||
|
||||
return parser.parse( offset );
|
||||
|
||||
|
|
|
@ -7,12 +7,13 @@ import junit.framework.TestCase;
|
|||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.NullLogService;
|
||||
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.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
|
||||
public class ExprEvalTest extends TestCase {
|
||||
|
||||
|
@ -27,7 +28,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 ), getClass().getName(), new ScannerInfo(), null, ParserLanguage.CPP, nullCallback, null ), nullCallback, ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
|
||||
IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), getClass().getName(), new ScannerInfo(), null, ParserLanguage.CPP, nullCallback, new NullLogService() ), nullCallback, ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
|
||||
IASTExpression expression = parser.expression(null);
|
||||
assertEquals(expectedValue, expression.evaluateExpression());
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.StringTokenizer;
|
|||
import junit.framework.Test;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.NullLogService;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
|
@ -241,7 +242,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, null ), nullCallback, ParserMode.QUICK_PARSE, language, null );
|
||||
ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), ParserMode.QUICK_PARSE, language, nullCallback, new NullLogService() ), nullCallback, ParserMode.QUICK_PARSE, language, null );
|
||||
|
||||
parser.parse();
|
||||
} catch ( Exception e ){
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2003,2004 IBM 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 Corp. - Rational Software - initial implementation
|
||||
******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.parser.tests;
|
||||
|
||||
import java.io.StringWriter;
|
||||
|
@ -18,11 +29,6 @@ import org.eclipse.cdt.internal.core.parser.token.Token;
|
|||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
* To change this generated comment edit the template variable "typecomment":
|
||||
* Window>Preferences>Java>Templates.
|
||||
* To enable and disable the creation of type comments go to
|
||||
* Window>Preferences>Java>Code Generation.
|
||||
*/
|
||||
public class ScannerTestCase extends BaseScannerTest
|
||||
{
|
||||
|
@ -1528,4 +1534,17 @@ public class ScannerTestCase extends BaseScannerTest
|
|||
assertEquals( callback.inclusions.size(), 1 );
|
||||
assertEquals( callback.inclusions.get(0), "stdio.h");
|
||||
}
|
||||
|
||||
public void testBug46402() throws Exception
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( "#define X 5\n" );
|
||||
buffer.append( "#if defined( X )\n" );
|
||||
buffer.append( "// blah\n" );
|
||||
buffer.append( "#elif Y > 5 \n" );
|
||||
buffer.append( "// coo\n" );
|
||||
buffer.append( "#endif\n" );
|
||||
initializeScanner( buffer.toString(), ParserMode.COMPLETE_PARSE );
|
||||
validateEOF();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import junit.framework.Test;
|
|||
|
||||
import org.eclipse.cdt.core.parser.ILineOffsetReconciler;
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.NullLogService;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
|
@ -280,7 +281,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, null ), nullCallback, parserMode, language, null);
|
||||
ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), parserMode, language, nullCallback, new NullLogService() ), nullCallback, parserMode, language, null);
|
||||
|
||||
mapping = ParserFactory.createLineOffsetReconciler( new StringReader( code ) );
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ 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.NullLogService;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
|
@ -58,7 +59,7 @@ public class ParseTestOnSearchFiles extends TestCase
|
|||
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, null );
|
||||
IScanner scanner = ParserFactory.createScanner( new InputStreamReader( fileIn ), name, new ScannerInfo(), ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, requestor, new NullLogService() );
|
||||
IParser parser = ParserFactory.createParser( scanner, requestor, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, null );
|
||||
assertTrue( parser.parse() );
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@ org.eclipse.cdt.core/debug/model=false
|
|||
# Reports parser activity
|
||||
org.eclipse.cdt.core/debug/parser=false
|
||||
|
||||
# Reports scanner activity
|
||||
org.eclipse.cdt.core/debug/scanner=false
|
||||
|
||||
# Reports background indexer activity: indexing, saving index file, index queries
|
||||
org.eclipse.cdt.core/debug/indexmanager=false
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2004-01-26 John Camelon
|
||||
Updated clients to use new Scanner logging service.
|
||||
|
||||
2004-01-06 Alain Magloire
|
||||
|
||||
Simple draft implementation of debug format parsing.
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2004-01-26 John Camelon
|
||||
Updated clients to use new Scanner logging service.
|
||||
|
||||
2003-10-22 Bogdan Gheorghe
|
||||
|
||||
Added updateDependencies() to the IndexManager to request
|
||||
|
|
|
@ -91,7 +91,7 @@ public class SourceIndexer extends AbstractIndexer {
|
|||
try
|
||||
{
|
||||
parser = ParserFactory.createParser(
|
||||
ParserFactory.createScanner( new StringReader( document.getStringContent() ), resourceFile.getLocation().toOSString(), scanInfo, ParserMode.COMPLETE_PARSE, language, requestor, ParserUtil.getParserLogService() ),
|
||||
ParserFactory.createScanner( new StringReader( document.getStringContent() ), resourceFile.getLocation().toOSString(), scanInfo, ParserMode.COMPLETE_PARSE, language, requestor, ParserUtil.getScannerLogService() ),
|
||||
requestor, ParserMode.COMPLETE_PARSE, language, ParserUtil.getParserLogService() );
|
||||
} catch( ParserFactoryError pfe )
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.parser.IParser;
|
|||
import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.core.parser.NullLogService;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
|
@ -126,7 +127,7 @@ public class CModelBuilder {
|
|||
mode,
|
||||
language,
|
||||
quickParseCallback,
|
||||
ParserUtil.getParserLogService())
|
||||
quickParseMode ? new NullLogService() : ParserUtil.getScannerLogService())
|
||||
,quickParseCallback,
|
||||
mode,
|
||||
language,
|
||||
|
|
|
@ -1,26 +1,30 @@
|
|||
/*
|
||||
* Created on Aug 25, 2003
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003,2004 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.model;
|
||||
|
||||
import org.eclipse.cdt.core.parser.Enum;
|
||||
|
||||
/**
|
||||
* @author bgheorgh
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public interface IDebugLogConstants {
|
||||
public class DebugLogConstant {
|
||||
private DebugLogConstant( int value )
|
||||
public class DebugLogConstant extends Enum {
|
||||
protected DebugLogConstant( int value )
|
||||
{
|
||||
this.value = value;
|
||||
super( value );
|
||||
}
|
||||
private final int value;
|
||||
|
||||
}
|
||||
|
||||
public static final DebugLogConstant PARSER = new DebugLogConstant( 1 );
|
||||
public static final DebugLogConstant MODEL = new DebugLogConstant ( 2 );
|
||||
public static final DebugLogConstant SCANNER = new DebugLogConstant( 3 );
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.core.runtime.Status;
|
|||
public class Util implements ICLogConstants {
|
||||
|
||||
public static boolean VERBOSE_PARSER = false;
|
||||
public static boolean VERBOSE_SCANNER = false;
|
||||
public static boolean VERBOSE_MODEL = false;
|
||||
|
||||
private Util() {
|
||||
|
@ -214,6 +215,8 @@ public class Util implements ICLogConstants {
|
|||
if (client.equals(IDebugLogConstants.PARSER)){
|
||||
return VERBOSE_PARSER;
|
||||
}
|
||||
else if (client.equals(IDebugLogConstants.SCANNER ))
|
||||
return VERBOSE_SCANNER;
|
||||
else if (client.equals(IDebugLogConstants.MODEL)){
|
||||
return VERBOSE_MODEL;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2004-01-26 John Camelon
|
||||
Added traceLogs into Scanner.
|
||||
Fixed Bug 46402 : expression evaluation error on branch not taken
|
||||
Added beginning of IScannerExtension and GCCScannerExtension support for gcc specific aspects.
|
||||
Added separate Scanner log category for tracing and updated clients to use it.
|
||||
|
||||
2004-01-23 John Camelon
|
||||
Added support for content assist in the scanner..
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/**********************************************************************
|
||||
* 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 IScannerExtension {
|
||||
|
||||
public String initializeMacroValue( String original );
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/**********************************************************************
|
||||
* 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 NullLogService implements IParserLogService {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IParserLogService#traceLog(java.lang.String)
|
||||
*/
|
||||
public void traceLog(String message) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IParserLogService#errorLog(java.lang.String)
|
||||
*/
|
||||
public void errorLog(String message) {
|
||||
}
|
||||
|
||||
}
|
|
@ -26,6 +26,7 @@ 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.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||
|
@ -191,4 +192,18 @@ public class ContextualParser extends Parser implements IParser {
|
|||
{
|
||||
return finalToken;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.Parser#setCompletionContextForExpression(org.eclipse.cdt.core.parser.ast.IASTExpression, boolean)
|
||||
*/
|
||||
protected void setCompletionContextForExpression(
|
||||
IASTExpression firstExpression,
|
||||
boolean isTemplate) {
|
||||
setCompletionContext( astFactory.getCompletionContext( (isTemplate
|
||||
? IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS
|
||||
: IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION),
|
||||
firstExpression ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4805,11 +4805,8 @@ public abstract class Parser implements IParser
|
|||
setCompletionToken( null );
|
||||
}
|
||||
|
||||
IASTNode context = astFactory.getCompletionContext( (isTemplate
|
||||
? IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS
|
||||
: IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION),
|
||||
firstExpression );
|
||||
setCompletionContext( context );
|
||||
|
||||
setCompletionContextForExpression( firstExpression, isTemplate );
|
||||
setCompletionKind( IASTCompletionNode.CompletionKind.MEMBER_REFERENCE );
|
||||
|
||||
secondExpression = primaryExpression(scope);
|
||||
|
@ -4855,11 +4852,7 @@ public abstract class Parser implements IParser
|
|||
setCompletionToken( null );
|
||||
}
|
||||
|
||||
context = astFactory.getCompletionContext( (isTemplate
|
||||
? IASTExpression.Kind.POSTFIX_ARROW_TEMPL_IDEXP
|
||||
: IASTExpression.Kind.POSTFIX_ARROW_IDEXPRESSION),
|
||||
firstExpression );
|
||||
setCompletionContext( context );
|
||||
setCompletionContextForExpression( firstExpression, isTemplate );
|
||||
setCompletionKind( IASTCompletionNode.CompletionKind.MEMBER_REFERENCE );
|
||||
|
||||
secondExpression = primaryExpression(scope);
|
||||
|
@ -4897,6 +4890,12 @@ public abstract class Parser implements IParser
|
|||
|
||||
|
||||
/**
|
||||
* @param firstExpression
|
||||
* @param isTemplate
|
||||
*/
|
||||
protected void setCompletionContextForExpression(IASTExpression firstExpression, boolean isTemplate) {
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
* @throws EndOfFileException
|
||||
*/
|
||||
|
|
|
@ -41,7 +41,7 @@ public class BranchTracker {
|
|||
* evaluates to true or false
|
||||
* @return boolean - are we set to continue scanning or not?
|
||||
*/
|
||||
public boolean poundif( boolean taken )
|
||||
public boolean poundIf( boolean taken )
|
||||
{
|
||||
if( ignore == IGNORE_SENTINEL )
|
||||
{
|
||||
|
@ -63,7 +63,22 @@ public class BranchTracker {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean poundelif( boolean taken ) throws EmptyStackException
|
||||
public boolean queryCurrentBranchForElif()
|
||||
{
|
||||
if( ignore != IGNORE_SENTINEL && ignore < branches.size() )
|
||||
return true;
|
||||
return !((Boolean)branches.peek()).booleanValue();
|
||||
}
|
||||
|
||||
public boolean queryCurrentBranchForIf()
|
||||
{
|
||||
if( branches.isEmpty() ) return true;
|
||||
if( ignore != IGNORE_SENTINEL & ignore < branches.size() )
|
||||
return false;
|
||||
return ((Boolean)branches.peek()).booleanValue();
|
||||
}
|
||||
|
||||
public boolean poundElif( boolean taken ) throws EmptyStackException
|
||||
{
|
||||
if( ignore != IGNORE_SENTINEL && ignore < branches.size() )
|
||||
{
|
||||
|
@ -110,7 +125,7 @@ public class BranchTracker {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean poundelse() throws EmptyStackException
|
||||
public boolean poundElse() throws EmptyStackException
|
||||
{
|
||||
if( ignore != IGNORE_SENTINEL && ignore < branches.size() )
|
||||
{
|
||||
|
@ -151,7 +166,7 @@ public class BranchTracker {
|
|||
}
|
||||
|
||||
// taken only on an #endif
|
||||
public boolean poundendif( )
|
||||
public boolean poundEndif( )
|
||||
{
|
||||
if( ignore == branches.size() )
|
||||
ignore = IGNORE_SENTINEL;
|
||||
|
|
|
@ -69,6 +69,8 @@ public class ContextStack {
|
|||
{
|
||||
if( !inclusions.add( context.getFilename() ) )
|
||||
throw new ContextException( IProblem.PREPROCESSOR_CIRCULAR_INCLUSION );
|
||||
|
||||
log.traceLog( "Scanner::ContextStack: entering inclusion " +context.getFilename());
|
||||
context.getExtension().enterScope( requestor );
|
||||
|
||||
} else if( context.getKind() == IScannerContext.ContextKind.MACROEXPANSION )
|
||||
|
@ -93,6 +95,7 @@ public class ContextStack {
|
|||
|
||||
if( currentContext.getKind() == IScannerContext.ContextKind.INCLUSION )
|
||||
{
|
||||
log.traceLog( "Scanner::ContextStack: ending inclusion " +currentContext.getFilename());
|
||||
inclusions.remove( currentContext.getFilename() );
|
||||
currentContext.getExtension().exitScope( requestor );
|
||||
} else if( currentContext.getKind() == IScannerContext.ContextKind.MACROEXPANSION )
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/**********************************************************************
|
||||
* 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.scanner;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IScannerExtension;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class GCCScannerExtension implements IScannerExtension {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IScannerExtension#initializeMacroValue(java.lang.String)
|
||||
*/
|
||||
public String initializeMacroValue(String original) {
|
||||
if( original == null || original.equals( "") )
|
||||
return "1";
|
||||
return original;
|
||||
}
|
||||
|
||||
}
|
|
@ -34,7 +34,7 @@ public class Preprocessor extends Scanner implements IPreprocessor {
|
|||
* @param defns
|
||||
*/
|
||||
public Preprocessor(Reader reader, String filename, IScannerInfo info, ISourceElementRequestor requestor, ParserMode mode, ParserLanguage language, IParserLogService logService ) {
|
||||
super(reader, filename, info, requestor, mode, language, logService );
|
||||
super(reader, filename, info, requestor, mode, language, logService );
|
||||
}
|
||||
|
||||
public void process()
|
||||
|
|
|
@ -33,10 +33,12 @@ 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.IScannerExtension;
|
||||
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.Keywords;
|
||||
import org.eclipse.cdt.core.parser.NullLogService;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
|
@ -60,7 +62,6 @@ import org.eclipse.cdt.internal.core.parser.token.Token;
|
|||
|
||||
public class Scanner implements IScanner {
|
||||
|
||||
|
||||
protected final IParserLogService log;
|
||||
private final static String SCRATCH = "<scratch>";
|
||||
private IProblemFactory problemFactory = new ScannerProblemFactory();
|
||||
|
@ -68,6 +69,7 @@ public class Scanner implements IScanner {
|
|||
private final String filename;
|
||||
private final Reader reader;
|
||||
protected IToken finalToken;
|
||||
private final IScannerExtension scannerExtension;
|
||||
|
||||
protected void handleProblem( int problemID, String argument, int beginningOffset, boolean warning, boolean error ) throws ScannerException
|
||||
{
|
||||
|
@ -101,6 +103,9 @@ public class Scanner implements IScanner {
|
|||
this.filename = filename;
|
||||
this.reader = reader;
|
||||
this.language = language;
|
||||
|
||||
//support GNU by default for now
|
||||
scannerExtension = new GCCScannerExtension();
|
||||
astFactory = ParserFactory.createASTFactory( mode, language );
|
||||
contextStack = new ContextStack( log );
|
||||
try {
|
||||
|
@ -116,26 +121,48 @@ public class Scanner implements IScanner {
|
|||
}
|
||||
|
||||
originalConfig = info;
|
||||
|
||||
log.traceLog( "Scanner constructed with the following configuration:");
|
||||
log.traceLog( "\tPreprocessor definitions from IScannerInfo: ");
|
||||
|
||||
if( info.getDefinedSymbols() != null )
|
||||
{
|
||||
{
|
||||
Iterator i = info.getDefinedSymbols().keySet().iterator();
|
||||
Map m = info.getDefinedSymbols();
|
||||
int numberOfSymbolsLogged = 0;
|
||||
while( i.hasNext() )
|
||||
{
|
||||
String symbolName = (String) i.next();
|
||||
Object value = m.get( symbolName );
|
||||
|
||||
if( value instanceof String )
|
||||
addDefinition( symbolName, (String) value);
|
||||
{
|
||||
addDefinition( symbolName, scannerExtension.initializeMacroValue((String) value));
|
||||
log.traceLog( "\t\tNAME = " + symbolName + " VALUE = " + value.toString() );
|
||||
++numberOfSymbolsLogged;
|
||||
|
||||
}
|
||||
else if( value instanceof IMacroDescriptor )
|
||||
addDefinition( symbolName, (IMacroDescriptor)value);
|
||||
}
|
||||
}
|
||||
if( numberOfSymbolsLogged == 0 )
|
||||
log.traceLog( "\t\tNo definitions specified.");
|
||||
|
||||
if( info.getIncludePaths() != null )
|
||||
overwriteIncludePath( info.getIncludePaths() );
|
||||
|
||||
}
|
||||
else
|
||||
log.traceLog( "\t\tNo definitions specified.");
|
||||
|
||||
|
||||
log.traceLog( "\tInclude paths from IScannerInfo: ");
|
||||
if( info.getIncludePaths() != null )
|
||||
{
|
||||
overwriteIncludePath( info.getIncludePaths() );
|
||||
for( int i = 0; i < info.getIncludePaths().length; ++i )
|
||||
log.traceLog( "\t\tPATH: " + info.getIncludePaths()[i]);
|
||||
}
|
||||
else
|
||||
log.traceLog("\t\tNo include paths specified.");
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void setupInitialContext()
|
||||
|
@ -174,7 +201,7 @@ public class Scanner implements IScanner {
|
|||
while( i.hasNext() )
|
||||
{
|
||||
String path = (String) i.next();
|
||||
includePaths.add( new File( path ));
|
||||
includePaths.add( new File( path ));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1199,26 +1226,27 @@ public class Scanner implements IScanner {
|
|||
int currentOffset = getCurrentOffset();
|
||||
String expression = getRestOfPreprocessorLine();
|
||||
|
||||
boolean expressionEvalResult = false;
|
||||
try{
|
||||
expressionEvalResult = evaluateExpression(expression, currentOffset);
|
||||
} catch( ScannerException e ){}
|
||||
if (expression.trim().equals(""))
|
||||
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#if", beginningOffset, false, true );
|
||||
|
||||
passOnToClient = branches.poundif( expressionEvalResult );
|
||||
boolean expressionEvalResult = false;
|
||||
|
||||
if( branches.queryCurrentBranchForIf() )
|
||||
expressionEvalResult = evaluateExpression(expression, currentOffset);
|
||||
|
||||
passOnToClient = branches.poundIf( expressionEvalResult );
|
||||
c = getChar();
|
||||
continue;
|
||||
|
||||
|
||||
|
||||
case PreprocessorDirectives.IFDEF :
|
||||
//TODO add in content assist stuff here
|
||||
skipOverWhitespace();
|
||||
if (getDefinition(getNextIdentifier()) == null) {
|
||||
// not defined
|
||||
passOnToClient = branches.poundif( false );
|
||||
passOnToClient = branches.poundIf( false );
|
||||
skipOverTextUntilNewline();
|
||||
} else {
|
||||
passOnToClient = branches.poundif( true );
|
||||
passOnToClient = branches.poundIf( true );
|
||||
// continue along, act like nothing is wrong :-)
|
||||
c = getChar();
|
||||
}
|
||||
|
@ -1231,7 +1259,7 @@ public class Scanner implements IScanner {
|
|||
buffer.append( restOfLine );
|
||||
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, buffer.toString(), beginningOffset, false, true );
|
||||
}
|
||||
passOnToClient = branches.poundendif();
|
||||
passOnToClient = branches.poundEndif();
|
||||
c = getChar();
|
||||
continue;
|
||||
|
||||
|
@ -1241,9 +1269,9 @@ public class Scanner implements IScanner {
|
|||
if (getDefinition(getNextIdentifier()) != null) {
|
||||
// not defined
|
||||
skipOverTextUntilNewline();
|
||||
passOnToClient = branches.poundif( false );
|
||||
passOnToClient = branches.poundIf( false );
|
||||
} else {
|
||||
passOnToClient = branches.poundif( true );
|
||||
passOnToClient = branches.poundIf( true );
|
||||
// continue along, act like nothing is wrong :-)
|
||||
c = getChar();
|
||||
}
|
||||
|
@ -1253,7 +1281,7 @@ public class Scanner implements IScanner {
|
|||
//TODO add in content assist stuff here
|
||||
try
|
||||
{
|
||||
passOnToClient = branches.poundelse();
|
||||
passOnToClient = branches.poundElse();
|
||||
}
|
||||
catch( EmptyStackException ese )
|
||||
{
|
||||
|
@ -1276,11 +1304,12 @@ public class Scanner implements IScanner {
|
|||
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#elif", beginningOffset, false, true );
|
||||
|
||||
boolean elsifResult = false;
|
||||
elsifResult = evaluateExpression(elsifExpression, co );
|
||||
if( branches.queryCurrentBranchForElif() )
|
||||
elsifResult = evaluateExpression(elsifExpression, co );
|
||||
|
||||
try
|
||||
{
|
||||
passOnToClient = branches.poundelif( elsifResult );
|
||||
passOnToClient = branches.poundElif( elsifResult );
|
||||
}
|
||||
catch( EmptyStackException ese )
|
||||
{
|
||||
|
@ -2026,8 +2055,8 @@ public class Scanner implements IScanner {
|
|||
new StringReader(expressionBuffer.toString()),
|
||||
EXPRESSION,
|
||||
new ScannerInfo( definitions, originalConfig.getIncludePaths()),
|
||||
ParserMode.QUICK_PARSE, language, nullCallback, log );
|
||||
parser = ParserFactory.createParser(trial, nullCallback, ParserMode.QUICK_PARSE, language, log );
|
||||
ParserMode.QUICK_PARSE, language, nullCallback, nullLogService );
|
||||
parser = ParserFactory.createParser(trial, nullCallback, ParserMode.QUICK_PARSE, language, nullLogService);
|
||||
} catch( ParserFactoryError pfe )
|
||||
{
|
||||
handleInternalError();
|
||||
|
@ -2129,7 +2158,7 @@ public class Scanner implements IScanner {
|
|||
new ScannerInfo(definitions, originalConfig.getIncludePaths()),
|
||||
new NullSourceElementRequestor(),
|
||||
mode,
|
||||
language, log );
|
||||
language, nullLogService );
|
||||
helperScanner.setForInclusion( true );
|
||||
IToken t = null;
|
||||
|
||||
|
@ -2243,6 +2272,7 @@ public class Scanner implements IScanner {
|
|||
|
||||
|
||||
protected boolean forInclusion = false;
|
||||
private final static IParserLogService nullLogService = new NullLogService();
|
||||
/**
|
||||
* @param b
|
||||
*/
|
||||
|
@ -2265,7 +2295,7 @@ public class Scanner implements IScanner {
|
|||
new ScannerInfo(),
|
||||
mode,
|
||||
language,
|
||||
new NullSourceElementRequestor(), log);
|
||||
new NullSourceElementRequestor(), nullLogService);
|
||||
} catch (ParserFactoryError e1) {
|
||||
}
|
||||
helperScanner.setTokenizingMacroReplacementList( true );
|
||||
|
@ -2533,7 +2563,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, log);
|
||||
Scanner tokenizer = new Scanner(new StringReader(params), TEXT, new ScannerInfo( definitions, originalConfig.getIncludePaths() ), new NullSourceElementRequestor(), mode, language, nullLogService );
|
||||
tokenizer.setThrowExceptionOnBadCharacterRead(false);
|
||||
Vector parameterValues = new Vector();
|
||||
Token t = null;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2004-01-26 John Camelon
|
||||
Updated clients to use new Scanner logging service.
|
||||
|
||||
2003-10-23 Bogdan Gheorghe
|
||||
|
||||
- Added AcceptMatchOperation to get around Bug 45324. The search
|
||||
|
|
|
@ -20,10 +20,12 @@ import java.util.LinkedList;
|
|||
|
||||
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||
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.IQuickParseCallback;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.NullLogService;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||
|
@ -183,7 +185,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,
|
||||
ParserUtil.getParserLogService());
|
||||
nullLog);
|
||||
} catch (ParserFactoryError e) {
|
||||
|
||||
}
|
||||
|
@ -253,7 +255,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
new ScannerInfo(),
|
||||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,ParserUtil.getParserLogService());
|
||||
callback, nullLog);
|
||||
} catch (ParserFactoryError e) {
|
||||
|
||||
}
|
||||
|
@ -295,7 +297,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
new ScannerInfo(),
|
||||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,ParserUtil.getParserLogService());
|
||||
callback, nullLog);
|
||||
} catch (ParserFactoryError e) {
|
||||
}
|
||||
|
||||
|
@ -312,6 +314,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
return new MethodDeclarationPattern( name, qualifications, parameters, matchMode, searchFor, limitTo, caseSensitive );
|
||||
}
|
||||
|
||||
private static final IParserLogService nullLog = new NullLogService();
|
||||
/**
|
||||
* @param patternString
|
||||
* @param limitTo
|
||||
|
@ -353,12 +356,11 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
new ScannerInfo(),
|
||||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,ParserUtil.getParserLogService());
|
||||
callback, nullLog );
|
||||
} catch (ParserFactoryError e1) {
|
||||
}
|
||||
|
||||
IToken token = null;
|
||||
ASTClassKind kind = null;
|
||||
|
||||
try {
|
||||
token = scanner.nextToken();
|
||||
|
@ -417,7 +419,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
new ScannerInfo(),
|
||||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,ParserUtil.getParserLogService());
|
||||
callback,new NullLogService());
|
||||
} catch (ParserFactoryError e1) {
|
||||
}
|
||||
IQuickParseCallback callback = ParserFactory.createQuickParseCallback();
|
||||
|
|
|
@ -440,7 +440,7 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
|||
IParser parser = null;
|
||||
try
|
||||
{
|
||||
IScanner scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETE_PARSE, language, this, ParserUtil.getParserLogService() );
|
||||
IScanner scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETE_PARSE, language, this, ParserUtil.getScannerLogService() );
|
||||
parser = ParserFactory.createParser( scanner, this, ParserMode.COMPLETE_PARSE, language, ParserUtil.getParserLogService() );
|
||||
}
|
||||
catch( ParserFactoryError pfe )
|
||||
|
|
|
@ -718,6 +718,7 @@ public class CCorePlugin extends Plugin {
|
|||
private static final String SEARCH = CCorePlugin.PLUGIN_ID + "/debug/search" ; //$NON-NLS-1$
|
||||
private static final String MATCH_LOCATOR = CCorePlugin.PLUGIN_ID + "/debug/matchlocator" ; //$NON-NLS-1$
|
||||
private static final String PARSER = CCorePlugin.PLUGIN_ID + "/debug/parser" ; //$NON-NLS-1$
|
||||
private static final String SCANNER = CCorePlugin.PLUGIN_ID + "/debug/scanner"; //$NON-NLS-1$
|
||||
private static final String DELTA = CCorePlugin.PLUGIN_ID + "/debug/deltaprocessor" ;
|
||||
private static final String CONTENTASSIST = CCorePlugin.PLUGIN_ID + "/debug/contentassist" ; //$NON-NLS-1$
|
||||
/**
|
||||
|
@ -729,6 +730,9 @@ public class CCorePlugin extends Plugin {
|
|||
String option = Platform.getDebugOption(PARSER);
|
||||
if(option != null) Util.VERBOSE_PARSER = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
|
||||
|
||||
option = Platform.getDebugOption(SCANNER);
|
||||
if( option != null ) Util.VERBOSE_SCANNER = option.equalsIgnoreCase("true");
|
||||
|
||||
option = Platform.getDebugOption(MODEL);
|
||||
if(option != null) Util.VERBOSE_MODEL = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser;
|
||||
|
||||
import org.eclipse.cdt.internal.core.model.IDebugLogConstants;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserLogService;
|
||||
|
||||
/**
|
||||
|
@ -18,10 +19,19 @@ import org.eclipse.cdt.internal.core.parser.ParserLogService;
|
|||
*/
|
||||
public class ParserUtil
|
||||
{
|
||||
|
||||
public static IParserLogService getParserLogService()
|
||||
{
|
||||
return parserLogService;
|
||||
}
|
||||
|
||||
private static IParserLogService parserLogService = new ParserLogService();
|
||||
|
||||
private static IParserLogService parserLogService = new ParserLogService(IDebugLogConstants.PARSER );
|
||||
private static IParserLogService scannerLogService = new ParserLogService(IDebugLogConstants.SCANNER );
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static IParserLogService getScannerLogService() {
|
||||
return scannerLogService;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ 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;
|
||||
import org.eclipse.cdt.internal.core.model.IDebugLogConstants.DebugLogConstant;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -22,12 +23,20 @@ import org.eclipse.cdt.internal.core.model.Util;
|
|||
public class ParserLogService implements IParserLogService
|
||||
{
|
||||
|
||||
final DebugLogConstant topic;
|
||||
/**
|
||||
* @param constant
|
||||
*/
|
||||
public ParserLogService(DebugLogConstant constant) {
|
||||
topic = constant;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IParserLogService#traceLog(java.lang.String)
|
||||
*/
|
||||
public void traceLog(String message)
|
||||
{
|
||||
Util.debugLog( message, IDebugLogConstants.PARSER );
|
||||
Util.debugLog( message, topic );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2004-01-26 John Camelon
|
||||
Updated clients to use new Scanner logging service.
|
||||
|
||||
2004-01-26 Hoda Amer
|
||||
Content Assist Work: More Tuning of Completion Engine
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.io.InputStreamReader;
|
|||
import java.io.StringReader;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.parser.NullLogService;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
|
@ -73,7 +74,7 @@ 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,ParserUtil.getParserLogService());
|
||||
ParserFactory.createScanner(new StringReader(s), "code", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, builder, new NullLogService());
|
||||
IParser parser = ParserFactory.createParser(scanner, builder, ParserMode.QUICK_PARSE, ParserLanguage.CPP, ParserUtil.getParserLogService() );
|
||||
parser.parse();
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
**********************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
||||
import java.io.CharArrayReader;
|
||||
|
@ -73,7 +73,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
|
|||
* and a given completion offset.
|
||||
*
|
||||
*/
|
||||
public class CompletionEngine implements RelevanceConstants{
|
||||
public class CompletionEngine implements RelevanceConstants {
|
||||
ICompletionRequestor requestor;
|
||||
int completionStart = 0;
|
||||
int completionLength = 0;
|
||||
|
@ -191,7 +191,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
macroMap.clear();
|
||||
try
|
||||
{
|
||||
scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETION_PARSE, language, requestor, ParserUtil.getParserLogService() );
|
||||
scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETION_PARSE, language, requestor, ParserUtil.getScannerLogService() );
|
||||
parser = ParserFactory.createParser( scanner, requestor, ParserMode.COMPLETION_PARSE, language, ParserUtil.getParserLogService() );
|
||||
}
|
||||
catch( ParserFactoryError pfe )
|
||||
|
@ -824,7 +824,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
|
||||
StringBuffer kindName = new StringBuffer("Looking For ");
|
||||
for(int i = 0; i<kinds.length; i++){
|
||||
LookupKind kind = (LookupKind) kinds[i];
|
||||
LookupKind kind = kinds[i];
|
||||
if(kind == IASTNode.LookupKind.ALL)
|
||||
kindName.append("ALL");
|
||||
else if(kind == IASTNode.LookupKind.STRUCTURES)
|
||||
|
|
Loading…
Add table
Reference in a new issue