mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Patch for Andrew Niefer
Core : - Create ParserLanguage.java - Modified ParserFactory functions to take ParserLanguage as parameter - Modifier Parser, Scanner & ParserSymbolTable to use new ParserLanguage class - Update call to ParserFactory in Indexer, Search, CModelBuilder & Dependency Tree Core.tests: - Updated calls to ParserFactory to specify which language to use UI: -CStructorCreator uses the parser, modified call to ParserFactory to specify CPP language. (this is the same behaviour as before)
This commit is contained in:
parent
7f1f51e837
commit
cecd8598a0
36 changed files with 209 additions and 84 deletions
|
@ -1,3 +1,7 @@
|
|||
2003-09-08 Andrew Niefer
|
||||
Modified calls to ParserFactory to specify which language to use
|
||||
Add CC nature to projects in BaseSearchTest & IndexManagerTests
|
||||
|
||||
2003-09-05 Hoda Amer
|
||||
Added tests to CompleteParseASTTest to test the expression result type
|
||||
for function calls that reference variables with pointers (bug#42453).
|
||||
|
|
|
@ -22,6 +22,7 @@ import junit.framework.Test;
|
|||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.CCProjectNature;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IEntryResult;
|
||||
|
@ -128,6 +129,10 @@ public class IndexManagerTests extends TestCase {
|
|||
//Create the project
|
||||
IProject cproject = CCorePlugin.getDefault().createCProject(description,project,monitor,CCorePlugin.PLUGIN_ID + ".make"); //.getCoreModel().create(project);
|
||||
|
||||
if( !cproject.hasNature(CCProjectNature.CC_NATURE_ID) ){
|
||||
addNatureToProject(cproject, CCProjectNature.CC_NATURE_ID, null);
|
||||
}
|
||||
|
||||
return cproject;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,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.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
|
@ -56,9 +57,9 @@ public class AutomatedTest extends AutomatedFramework {
|
|||
FileInputStream stream = new FileInputStream( file );
|
||||
|
||||
String filePath = file.getCanonicalPath();
|
||||
parser = ParserFactory.createParser( ParserFactory.createScanner( new InputStreamReader (stream), filePath, new ScannerInfo(), ParserMode.QUICK_PARSE, nullCallback ), nullCallback, ParserMode.QUICK_PARSE);
|
||||
parser.setCppNature( ((String)natures.get( filePath )).equalsIgnoreCase("cpp") );
|
||||
|
||||
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);
|
||||
|
||||
mapping = ParserFactory.createLineOffsetReconciler( new InputStreamReader( stream ) );
|
||||
|
||||
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.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
|
@ -47,7 +48,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, quickParseCallback), quickParseCallback, mode );
|
||||
parser = ParserFactory.createParser( ParserFactory.createScanner( new StringReader( code ), "code", new ScannerInfo(), mode, ParserLanguage.CPP, quickParseCallback), quickParseCallback, mode, ParserLanguage.CPP );
|
||||
if( ! parser.parse() && throwExceptionOnError )
|
||||
throw new ParserException("Parse failure");
|
||||
return quickParseCallback.getCompilationUnit();
|
||||
|
|
|
@ -18,6 +18,7 @@ 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.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerException;
|
||||
|
@ -39,7 +40,7 @@ public class BaseScannerTest extends TestCase {
|
|||
|
||||
protected void initializeScanner( String input, ParserMode mode )
|
||||
{
|
||||
scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", new ScannerInfo(), mode, callback );
|
||||
scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", new ScannerInfo(), mode, ParserLanguage.CPP, callback );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import junit.framework.TestCase;
|
|||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
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.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||
|
@ -554,7 +555,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, callback ), callback, ParserMode.COMPLETE_PARSE
|
||||
ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, callback ), callback, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP
|
||||
);
|
||||
if( ! parser.parse() ) throw new ParserException( "FAILURE");
|
||||
return callback.getCompilationUnit();
|
||||
|
|
|
@ -7,6 +7,7 @@ import junit.framework.TestCase;
|
|||
import junit.framework.TestSuite;
|
||||
|
||||
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.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
|
@ -26,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, nullCallback ), nullCallback, ParserMode.QUICK_PARSE);
|
||||
IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), null, ParserLanguage.CPP, nullCallback ), nullCallback, ParserMode.QUICK_PARSE, ParserLanguage.CPP );
|
||||
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.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
|
@ -238,9 +239,10 @@ public class FractionalAutomatedTest extends AutomatedFramework {
|
|||
public void run(){
|
||||
try{
|
||||
result = null;
|
||||
ParserLanguage language = cppNature ? ParserLanguage.CPP : ParserLanguage.C;
|
||||
IParser parser = ParserFactory.createParser(
|
||||
ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), ParserMode.QUICK_PARSE, nullCallback ), nullCallback, ParserMode.QUICK_PARSE);
|
||||
parser.setCppNature( cppNature );
|
||||
ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), ParserMode.QUICK_PARSE, language, nullCallback ), nullCallback, ParserMode.QUICK_PARSE, language);
|
||||
|
||||
parser.parse();
|
||||
} catch ( Exception e ){
|
||||
result = e.getClass().toString();
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.util.List;
|
|||
import junit.framework.TestCase;
|
||||
|
||||
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.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
|
||||
|
@ -54,7 +55,7 @@ public class LineNumberTest extends TestCase {
|
|||
public void testDOMLineNos() throws Exception
|
||||
{
|
||||
DOMBuilder domBuilder = new DOMBuilder();
|
||||
IParser parser = ParserFactory.createParser( ParserFactory.createScanner( new InputStreamReader( fileIn ), null, new ScannerInfo(), ParserMode.QUICK_PARSE, domBuilder ), domBuilder, ParserMode.QUICK_PARSE );
|
||||
IParser parser = ParserFactory.createParser( ParserFactory.createScanner( new InputStreamReader( fileIn ), null, new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, domBuilder ), domBuilder, ParserMode.QUICK_PARSE, ParserLanguage.CPP);
|
||||
//parser.mapLineNumbers(true);
|
||||
if( ! parser.parse() ) fail( "Parse of file failed");
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.Map;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol;
|
||||
|
@ -51,10 +52,13 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
}
|
||||
|
||||
public ParserSymbolTable newTable(){
|
||||
table = new ParserSymbolTable();
|
||||
return table;
|
||||
return newTable( ParserLanguage.CPP );
|
||||
}
|
||||
|
||||
public ParserSymbolTable newTable( ParserLanguage language ){
|
||||
table = new ParserSymbolTable( language );
|
||||
return table;
|
||||
}
|
||||
/**
|
||||
* testSimpleAdd.
|
||||
* Add a declaration to the table and confirm it is there.
|
||||
|
|
|
@ -17,6 +17,7 @@ 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.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerException;
|
||||
|
@ -35,7 +36,7 @@ public class PreprocessorConditionalTest extends BaseScannerTest
|
|||
|
||||
protected void initializeScanner(String input, Map definitions )
|
||||
{
|
||||
scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", new ScannerInfo( definitions, null), ParserMode.COMPLETE_PARSE, nullSourceElementRequestor );
|
||||
scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", new ScannerInfo( definitions, null), ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, nullSourceElementRequestor );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import junit.framework.TestCase;
|
|||
|
||||
import org.eclipse.cdt.core.parser.IPreprocessor;
|
||||
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.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
||||
|
@ -73,7 +74,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(), ParserMode.COMPLETE_PARSE, rq );
|
||||
IPreprocessor p = ParserFactory.createPreprocessor( new StringReader( text ), "test", new ScannerInfo(), ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, rq );
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
||||
|
@ -278,11 +279,11 @@ public class TortureTest extends FractionalAutomatedTest {
|
|||
public void run(){
|
||||
try {
|
||||
DOMBuilder domBuilder = new DOMBuilder();
|
||||
ParserMode parserMode = quickParse ? ParserMode.QUICK_PARSE : ParserMode.COMPLETE_PARSE;
|
||||
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, nullCallback ), nullCallback, parserMode);
|
||||
ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), parserMode, language, nullCallback ), nullCallback, parserMode, language);
|
||||
|
||||
parser.setCppNature(cppNature);
|
||||
mapping = ParserFactory.createLineOffsetReconciler( new StringReader( code ) );
|
||||
|
||||
assertTrue(parser.parse());
|
||||
|
|
|
@ -17,8 +17,8 @@ import java.io.FileInputStream;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.cdt.core.CCProjectNature;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||
import org.eclipse.cdt.core.search.ICSearchPattern;
|
||||
import org.eclipse.cdt.core.search.ICSearchResultCollector;
|
||||
|
@ -130,8 +130,8 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
|
|||
monitor,
|
||||
CCorePlugin.PLUGIN_ID + ".make");
|
||||
|
||||
if( !project.hasNature(CProjectNature.C_NATURE_ID) ){
|
||||
addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
|
||||
if( !project.hasNature(CCProjectNature.CC_NATURE_ID) ){
|
||||
addNatureToProject(project, CCProjectNature.CC_NATURE_ID, null);
|
||||
}
|
||||
|
||||
return cproject;
|
||||
|
|
|
@ -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.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
|
||||
|
@ -57,8 +58,8 @@ public class ParseTestOnSearchFiles extends TestCase
|
|||
public void testParseOfAndrewsFile()
|
||||
{
|
||||
ISourceElementRequestor requestor = new NullSourceElementRequestor();
|
||||
IScanner scanner = ParserFactory.createScanner( new InputStreamReader( fileIn ), name, new ScannerInfo(), ParserMode.COMPLETE_PARSE, requestor );
|
||||
IParser parser = ParserFactory.createParser( scanner, requestor, ParserMode.COMPLETE_PARSE );
|
||||
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 );
|
||||
assertTrue( parser.parse() );
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2003-09-08 Andrew Niefer
|
||||
- Modified calls to ParserFactory to specify which language to use
|
||||
- Modified IDependencyTree.add to take ParserLanguage as a parameter so that it can
|
||||
be passed on when creating the preprocessor
|
||||
|
||||
2003-07-23 Bogdan Gheorghe
|
||||
|
||||
Added initial dependency implementation
|
||||
|
|
|
@ -13,7 +13,9 @@ package org.eclipse.cdt.internal.core.sourcedependency;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.internal.core.index.IDocument;
|
||||
import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
|
@ -75,7 +77,9 @@ public class AddFileToDependencyTree extends DependencyRequest {
|
|||
String docPath = resource.getLocation().toOSString();
|
||||
IScannerInfo newInfo = new ScannerInfo((this.buildInfo != null) ? this.buildInfo.getDefinedSymbols() : null,(this.buildInfo != null) ? this.buildInfo.getIncludePaths() : null);
|
||||
|
||||
dTree.add(document,docPath,newInfo);
|
||||
ParserLanguage language = CoreModel.getDefault().hasCCNature( resource.getProject() ) ? ParserLanguage.CPP : ParserLanguage.C;
|
||||
|
||||
dTree.add(document,docPath,newInfo, language);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.util.List;
|
|||
|
||||
import org.eclipse.cdt.core.parser.IPreprocessor;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
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;
|
||||
|
@ -111,7 +112,7 @@ public class DependencyTree implements IDependencyTree {
|
|||
* Add the file that will be preprocessed to the tree, create a new
|
||||
* preprocessor output and preprocess!
|
||||
*/
|
||||
public void add(IDocument document, String docPath, IScannerInfo newInfo) throws IOException {
|
||||
public void add(IDocument document, String docPath, IScannerInfo newInfo, ParserLanguage language) throws IOException {
|
||||
IndexedFile indexedFile= addsTree.getIndexedFile(document.getName());
|
||||
//if (indexedFile != null)
|
||||
//remove(indexedFile, 0);
|
||||
|
@ -120,7 +121,7 @@ public class DependencyTree implements IDependencyTree {
|
|||
|
||||
output.addDocument(document);
|
||||
|
||||
IPreprocessor preprocessor = ParserFactory.createPreprocessor( new StringReader( document.getStringContent() ),docPath , newInfo, ParserMode.COMPLETE_PARSE,depReq);
|
||||
IPreprocessor preprocessor = ParserFactory.createPreprocessor( new StringReader( document.getStringContent() ),docPath , newInfo, ParserMode.COMPLETE_PARSE, language, depReq);
|
||||
preprocessor.process();
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.internal.core.index.IDocument;
|
||||
import org.eclipse.cdt.internal.core.index.IQueryResult;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
@ -23,7 +24,7 @@ public interface IDependencyTree {
|
|||
/**
|
||||
* Adds the given document to the index.
|
||||
*/
|
||||
void add(IDocument document, String docPath, IScannerInfo newInfo) throws IOException;
|
||||
void add(IDocument document, String docPath, IScannerInfo newInfo, ParserLanguage language) throws IOException;
|
||||
/**
|
||||
* Empties the index.
|
||||
*/
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2003-09-08 Andrew Niefer
|
||||
- Modified calls to ParserFactory to specify which language to use
|
||||
|
||||
2003-09-05 Andrew Niefer
|
||||
- Modified how AbstractIndexer creates the fully qualified name for an enumerator (spec 7.2-10)
|
||||
|
||||
|
|
|
@ -19,9 +19,11 @@ import java.io.IOException;
|
|||
import java.io.StringReader;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
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.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.index.IDocument;
|
||||
|
@ -76,9 +78,12 @@ 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, requestor ),
|
||||
requestor, ParserMode.COMPLETE_PARSE);
|
||||
ParserFactory.createScanner( new StringReader( document.getStringContent() ), resourceFile.getLocation().toOSString(), scanInfo, ParserMode.COMPLETE_PARSE, language, requestor ),
|
||||
requestor, ParserMode.COMPLETE_PARSE, language );
|
||||
|
||||
try{
|
||||
boolean retVal = parser.parse();
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.model.IParent;
|
|||
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.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||
|
@ -74,10 +75,12 @@ public class CModelBuilder {
|
|||
{
|
||||
ParserMode mode = quick ? ParserMode.QUICK_PARSE : ParserMode.COMPLETE_PARSE;
|
||||
quickParseCallback = ParserFactory.createQuickParseCallback();
|
||||
|
||||
ParserLanguage language = hasCppNature ? ParserLanguage.CPP : ParserLanguage.C;
|
||||
IParser parser = ParserFactory.createParser(
|
||||
ParserFactory.createScanner( new StringReader( code ), "code",
|
||||
new ScannerInfo(), mode, quickParseCallback), quickParseCallback, mode );
|
||||
parser.setCppNature(hasCppNature);
|
||||
new ScannerInfo(), mode, language, quickParseCallback), quickParseCallback, mode, language );
|
||||
|
||||
if( ! parser.parse() && throwExceptionOnError )
|
||||
throw new ParserException("Parse failure");
|
||||
return quickParseCallback.getCompilationUnit();
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2003-09-08 Andrew Niefer
|
||||
- Created ParserLanguage.java
|
||||
- Updated Factories to take language as parameter when create scanner & parser
|
||||
- Updated Parser, Scanner & ParserSymbolTable to take language in their constructor
|
||||
|
||||
2003-09-05 Hoda Amer
|
||||
- Added references to variables with pointers in solution
|
||||
of bug#42453:Expression result types not computed
|
||||
|
|
|
@ -48,14 +48,14 @@ public interface IParser {
|
|||
*
|
||||
* @return true for C++, false for C
|
||||
*/
|
||||
public boolean isCppNature();
|
||||
public ParserLanguage getLanguage();
|
||||
|
||||
/**
|
||||
* Set the Parser explicitly to be a C or C++ parser.
|
||||
*
|
||||
* @param b true for C++, false for C
|
||||
* @param l CPP or C
|
||||
*/
|
||||
public void setCppNature(boolean b);
|
||||
public void setLanguage( ParserLanguage l);
|
||||
|
||||
/**
|
||||
* If an error was encountered, give us the offset of the token that caused the error.
|
||||
|
|
|
@ -23,7 +23,7 @@ public interface IScanner {
|
|||
public IToken nextToken() throws ScannerException, EndOfFile;
|
||||
public IToken nextToken( boolean next ) throws ScannerException, EndOfFile;
|
||||
|
||||
public void setCppNature( boolean value );
|
||||
public void setLanguage( ParserLanguage value );
|
||||
|
||||
public int getCount();
|
||||
public int getDepth();
|
||||
|
|
|
@ -35,49 +35,49 @@ import org.eclipse.cdt.internal.core.parser.problem.ProblemReporter;
|
|||
*/
|
||||
public class ParserFactory {
|
||||
|
||||
public static IASTFactory createASTFactory( ParserMode mode )
|
||||
public static IASTFactory createASTFactory( ParserMode mode, ParserLanguage language )
|
||||
{
|
||||
if( mode == ParserMode.QUICK_PARSE )
|
||||
return new QuickParseASTFactory();
|
||||
else
|
||||
return new CompleteParseASTFactory();
|
||||
return new CompleteParseASTFactory( language );
|
||||
}
|
||||
|
||||
public static IParser createParser( IScanner scanner, ISourceElementRequestor callback, ParserMode mode )
|
||||
public static IParser createParser( IScanner scanner, ISourceElementRequestor callback, ParserMode mode, ParserLanguage language )
|
||||
{
|
||||
return createParser(scanner, callback, mode, null, null);
|
||||
return createParser(scanner, callback, mode, language, null, null);
|
||||
}
|
||||
|
||||
public static IParser createParser( IScanner scanner, ISourceElementRequestor callback, ParserMode mode, IProblemReporter problemReporter, ITranslationResult unitResult )
|
||||
public static IParser createParser( IScanner scanner, ISourceElementRequestor callback, ParserMode mode, ParserLanguage language, IProblemReporter problemReporter, ITranslationResult unitResult )
|
||||
{
|
||||
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode );
|
||||
ISourceElementRequestor ourCallback = (( callback == null) ? new NullSourceElementRequestor() : callback );
|
||||
return new Parser( scanner, ourCallback, ourMode, problemReporter, unitResult );
|
||||
return new Parser( scanner, ourCallback, ourMode, language, problemReporter, unitResult );
|
||||
}
|
||||
|
||||
public static IScanner createScanner( Reader input, String fileName, IScannerInfo config, ParserMode mode, ISourceElementRequestor requestor )
|
||||
public static IScanner createScanner( Reader input, String fileName, IScannerInfo config, ParserMode mode, ParserLanguage language, ISourceElementRequestor requestor )
|
||||
{
|
||||
return createScanner(input, fileName, config, mode, requestor, null, null);
|
||||
return createScanner(input, fileName, config, mode, language, requestor, null, null);
|
||||
}
|
||||
|
||||
public static IScanner createScanner( Reader input, String fileName, IScannerInfo config, ParserMode mode, ISourceElementRequestor requestor, IProblemReporter problemReporter, ITranslationResult unitResult )
|
||||
public static IScanner createScanner( Reader input, String fileName, IScannerInfo config, ParserMode mode, ParserLanguage language, ISourceElementRequestor requestor, IProblemReporter problemReporter, ITranslationResult unitResult )
|
||||
{
|
||||
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode );
|
||||
ISourceElementRequestor ourRequestor = (( requestor == null) ? new NullSourceElementRequestor() : requestor );
|
||||
IScanner s = new Scanner( input, fileName, config, problemReporter, unitResult, ourRequestor, ourMode );
|
||||
IScanner s = new Scanner( input, fileName, config, problemReporter, unitResult, ourRequestor, ourMode, language );
|
||||
return s;
|
||||
}
|
||||
|
||||
public static IPreprocessor createPreprocessor( Reader input, String fileName, IScannerInfo info, ParserMode mode, ISourceElementRequestor requestor )
|
||||
public static IPreprocessor createPreprocessor( Reader input, String fileName, IScannerInfo info, ParserMode mode, ParserLanguage language, ISourceElementRequestor requestor )
|
||||
{
|
||||
return createPreprocessor(input, fileName, info, mode, requestor, null, null);
|
||||
return createPreprocessor(input, fileName, info, mode, language, requestor, null, null);
|
||||
}
|
||||
|
||||
public static IPreprocessor createPreprocessor( Reader input, String fileName, IScannerInfo info, ParserMode mode, ISourceElementRequestor requestor, IProblemReporter problemReporter, ITranslationResult unitResult )
|
||||
public static IPreprocessor createPreprocessor( Reader input, String fileName, IScannerInfo info, ParserMode mode, ParserLanguage language, ISourceElementRequestor requestor, IProblemReporter problemReporter, ITranslationResult unitResult )
|
||||
{
|
||||
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode );
|
||||
ISourceElementRequestor ourRequestor = (( requestor == null) ? new NullSourceElementRequestor() : requestor );
|
||||
IPreprocessor s = new Preprocessor( input, fileName, info, ourRequestor, problemReporter, unitResult, ourMode );
|
||||
IPreprocessor s = new Preprocessor( input, fileName, info, ourRequestor, problemReporter, unitResult, ourMode, language );
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2003 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;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class ParserLanguage extends Enum {
|
||||
public final static ParserLanguage C = new ParserLanguage( 1 );
|
||||
public final static ParserLanguage CPP = new ParserLanguage( 2 );
|
||||
|
||||
private ParserLanguage( int value )
|
||||
{
|
||||
super( value );
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
|||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.ITranslationResult;
|
||||
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.ScannerException;
|
||||
|
@ -77,7 +78,7 @@ public class Parser implements IParser
|
|||
private ParserMode mode = ParserMode.COMPLETE_PARSE;
|
||||
// are we doing the high-level parse, or an in depth parse?
|
||||
private boolean parsePassed = true; // did the parse pass?
|
||||
private boolean cppNature = true; // true for C++, false for C
|
||||
private ParserLanguage language = ParserLanguage.CPP; // C or CPP
|
||||
private ISourceElementRequestor requestor = null;
|
||||
// new callback mechanism
|
||||
private IASTFactory astFactory = null; // ast factory
|
||||
|
@ -116,6 +117,7 @@ public class Parser implements IParser
|
|||
IScanner scanner,
|
||||
ISourceElementRequestor callback,
|
||||
ParserMode mode,
|
||||
ParserLanguage language,
|
||||
IProblemReporter problemReporter,
|
||||
ITranslationResult unitResult)
|
||||
{
|
||||
|
@ -124,7 +126,8 @@ public class Parser implements IParser
|
|||
this.unitResult = unitResult;
|
||||
requestor = callback;
|
||||
this.mode = mode;
|
||||
astFactory = ParserFactory.createASTFactory(mode);
|
||||
this.language = language;
|
||||
astFactory = ParserFactory.createASTFactory(mode, language);
|
||||
scanner.setASTFactory(astFactory);
|
||||
}
|
||||
// counter that keeps track of the number of times Parser.parse() is called
|
||||
|
@ -4635,20 +4638,20 @@ public class Parser implements IParser
|
|||
lastToken = null; // this is not entirely right ...
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.IParser#isCppNature()
|
||||
* @see org.eclipse.cdt.internal.core.parser.IParser#getLanguage()
|
||||
*/
|
||||
public boolean isCppNature()
|
||||
public ParserLanguage getLanguage()
|
||||
{
|
||||
return cppNature;
|
||||
return language;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.IParser#setCppNature(boolean)
|
||||
* @see org.eclipse.cdt.internal.core.parser.IParser#setLanguage(Language)
|
||||
*/
|
||||
public void setCppNature(boolean b)
|
||||
public void setLanguage( ParserLanguage l )
|
||||
{
|
||||
cppNature = b;
|
||||
if (scanner != null)
|
||||
scanner.setCppNature(b);
|
||||
language = l;
|
||||
if (scanner != null)
|
||||
scanner.setLanguage( l );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.IParser#getLastErrorOffset()
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.parser.IProblemReporter;
|
|||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ITranslationResult;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerException;
|
||||
|
||||
|
@ -33,8 +34,8 @@ public class Preprocessor extends Scanner implements IPreprocessor {
|
|||
* @param filename
|
||||
* @param defns
|
||||
*/
|
||||
public Preprocessor(Reader reader, String filename, IScannerInfo info, ISourceElementRequestor requestor, IProblemReporter problemReporter, ITranslationResult unitResult, ParserMode mode) {
|
||||
super(reader, filename, info, problemReporter, unitResult, requestor, mode );
|
||||
public Preprocessor(Reader reader, String filename, IScannerInfo info, ISourceElementRequestor requestor, IProblemReporter problemReporter, ITranslationResult unitResult, ParserMode mode, ParserLanguage language ) {
|
||||
super(reader, filename, info, problemReporter, unitResult, requestor, mode, language );
|
||||
}
|
||||
|
||||
public void process()
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
|||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ITranslationOptions;
|
||||
import org.eclipse.cdt.core.parser.ITranslationResult;
|
||||
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.ScannerException;
|
||||
|
@ -56,10 +57,11 @@ public class Scanner implements IScanner {
|
|||
|
||||
private Reader backupReader;
|
||||
|
||||
public Scanner(Reader reader, String filename, IScannerInfo info, IProblemReporter problemReporter, ITranslationResult unitResult, ISourceElementRequestor requestor, ParserMode parserMode ) {
|
||||
public Scanner(Reader reader, String filename, IScannerInfo info, IProblemReporter problemReporter, ITranslationResult unitResult, ISourceElementRequestor requestor, ParserMode parserMode, ParserLanguage language ) {
|
||||
this.requestor = requestor;
|
||||
this.mode = parserMode;
|
||||
astFactory = ParserFactory.createASTFactory( mode );
|
||||
this.language = language;
|
||||
astFactory = ParserFactory.createASTFactory( mode, language );
|
||||
this.backupReader = reader;
|
||||
|
||||
try {
|
||||
|
@ -762,7 +764,7 @@ public class Scanner implements IScanner {
|
|||
|
||||
Object tokenTypeObject;
|
||||
|
||||
if( cppNature )
|
||||
if( language == ParserLanguage.CPP )
|
||||
tokenTypeObject = cppKeywords.get(ident);
|
||||
else
|
||||
tokenTypeObject = cKeywords.get(ident);
|
||||
|
@ -1789,8 +1791,8 @@ public class Scanner implements IScanner {
|
|||
new StringReader(expression + ";"),
|
||||
EXPRESSION,
|
||||
new ScannerInfo( definitions, originalConfig.getIncludePaths()),
|
||||
ParserMode.QUICK_PARSE, nullCallback );
|
||||
IParser parser = ParserFactory.createParser(trial, nullCallback, ParserMode.QUICK_PARSE );
|
||||
ParserMode.QUICK_PARSE, language, nullCallback );
|
||||
IParser parser = ParserFactory.createParser(trial, nullCallback, ParserMode.QUICK_PARSE, language );
|
||||
|
||||
try {
|
||||
IASTExpression exp = parser.expression(null);
|
||||
|
@ -1901,7 +1903,8 @@ public class Scanner implements IScanner {
|
|||
problemReporter,
|
||||
translationResult,
|
||||
new NullSourceElementRequestor(),
|
||||
mode);
|
||||
mode,
|
||||
language );
|
||||
IToken t = null;
|
||||
|
||||
try {
|
||||
|
@ -2063,7 +2066,7 @@ public class Scanner implements IScanner {
|
|||
|
||||
if( ! replacementString.equals( "" ) )
|
||||
{
|
||||
IScanner helperScanner = ParserFactory.createScanner( new StringReader(replacementString), null, new ScannerInfo( ), mode, new NullSourceElementRequestor(), problemReporter, translationResult );
|
||||
IScanner helperScanner = ParserFactory.createScanner( new StringReader(replacementString), null, new ScannerInfo( ), mode, language, new NullSourceElementRequestor(), problemReporter, translationResult );
|
||||
helperScanner.setTokenizingMacroReplacementList( true );
|
||||
IToken t = helperScanner.nextToken(false);
|
||||
|
||||
|
@ -2150,7 +2153,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() ), problemReporter, translationResult, new NullSourceElementRequestor(), mode);
|
||||
Scanner tokenizer = new Scanner(new StringReader(params), TEXT, new ScannerInfo( definitions, originalConfig.getIncludePaths() ), problemReporter, translationResult, new NullSourceElementRequestor(), mode, language);
|
||||
Vector parameterValues = new Vector();
|
||||
Token t = null;
|
||||
String str = new String();
|
||||
|
@ -2370,12 +2373,12 @@ public class Scanner implements IScanner {
|
|||
|
||||
|
||||
|
||||
private boolean cppNature = true;
|
||||
private ParserLanguage language = ParserLanguage.CPP;
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.IScanner#setCppNature(boolean)
|
||||
*/
|
||||
public void setCppNature(boolean value) {
|
||||
cppNature = value;
|
||||
public void setLanguage( ParserLanguage value) {
|
||||
language = value;
|
||||
}
|
||||
|
||||
private final ISourceElementRequestor requestor;
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.StringTokenizer;
|
|||
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||
|
@ -87,9 +88,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
*
|
||||
*/
|
||||
|
||||
public CompleteParseASTFactory()
|
||||
public CompleteParseASTFactory( ParserLanguage language )
|
||||
{
|
||||
super();
|
||||
|
||||
pst = new ParserSymbolTable( language );
|
||||
}
|
||||
|
||||
protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, String name, TypeInfo.eType type, List parameters, int offset, List references, boolean throwOnError ) throws ASTSemanticException
|
||||
|
@ -1677,7 +1680,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
return (IASTElaboratedTypeSpecifier)checkSymbol.getASTExtension().getPrimaryDeclaration();
|
||||
}
|
||||
|
||||
protected ParserSymbolTable pst = new ParserSymbolTable();
|
||||
protected ParserSymbolTable pst;
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.ListIterator;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
|
||||
/**
|
||||
|
@ -33,10 +34,11 @@ public class ParserSymbolTable {
|
|||
/**
|
||||
* Constructor for ParserSymbolTable.
|
||||
*/
|
||||
public ParserSymbolTable() {
|
||||
public ParserSymbolTable( ParserLanguage language ) {
|
||||
super();
|
||||
_compilationUnit = new Declaration("");
|
||||
_compilationUnit.setType( TypeInfo.t_namespace );
|
||||
_language = language;
|
||||
}
|
||||
|
||||
public IContainerSymbol getCompilationUnit(){
|
||||
|
@ -102,7 +104,9 @@ public class ParserSymbolTable {
|
|||
//if this name define in this scope?
|
||||
lookupInContained( data, inSymbol );
|
||||
|
||||
if( !data.ignoreUsingDirectives ){
|
||||
if( inSymbol.getSymbolTable().getLanguage() == ParserLanguage.CPP &&
|
||||
!data.ignoreUsingDirectives )
|
||||
{
|
||||
//check nominated namespaces
|
||||
//the transitives list is populated in LookupInNominated, and then
|
||||
//processed in ProcessDirectives
|
||||
|
@ -1799,9 +1803,18 @@ public class ParserSymbolTable {
|
|||
|
||||
//private Stack _contextStack = new Stack();
|
||||
private Declaration _compilationUnit;
|
||||
private ParserLanguage _language;
|
||||
private LinkedList undoList = new LinkedList();
|
||||
private HashSet markSet = new HashSet();
|
||||
|
||||
public void setLanguage( ParserLanguage language ){
|
||||
_language = language;
|
||||
}
|
||||
|
||||
public ParserLanguage getLanguage(){
|
||||
return _language;
|
||||
}
|
||||
|
||||
protected void pushCommand( Command command ){
|
||||
undoList.addFirst( command );
|
||||
}
|
||||
|
@ -2727,6 +2740,10 @@ public class ParserSymbolTable {
|
|||
* of this is volatile X*....
|
||||
*/
|
||||
private boolean addThis( Declaration obj ){
|
||||
if( getSymbolTable().getLanguage() != ParserLanguage.CPP ){
|
||||
return false;
|
||||
}
|
||||
|
||||
TypeInfo type = obj.getTypeInfo();
|
||||
if( ( !type.isType( TypeInfo.t_function ) && !type.isType( TypeInfo.t_constructor) ) ||
|
||||
type.checkBit( TypeInfo.isStatic ) ){
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.LinkedList;
|
|||
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.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerException;
|
||||
|
@ -119,7 +120,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
return orPattern;
|
||||
}
|
||||
|
||||
IScanner scanner = ParserFactory.createScanner( new StringReader( patternString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, null );
|
||||
IScanner scanner = ParserFactory.createScanner( new StringReader( patternString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
|
||||
LinkedList list = scanForNames( scanner, null );
|
||||
|
||||
char [] name = (char []) list.removeLast();
|
||||
|
@ -176,7 +177,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
return orPattern;
|
||||
}
|
||||
|
||||
IScanner scanner = ParserFactory.createScanner( new StringReader( patternString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, null );
|
||||
IScanner scanner = ParserFactory.createScanner( new StringReader( patternString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
|
||||
LinkedList list = scanForNames( scanner, null );
|
||||
|
||||
char [] name = (char []) list.removeLast();
|
||||
|
@ -206,11 +207,11 @@ 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, null );
|
||||
IScanner scanner = ParserFactory.createScanner( new StringReader( nameString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
|
||||
|
||||
LinkedList names = scanForNames( scanner, null );
|
||||
|
||||
scanner = ParserFactory.createScanner( new StringReader( paramString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, null );
|
||||
scanner = ParserFactory.createScanner( new StringReader( paramString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
|
||||
|
||||
LinkedList params = scanForParameters( scanner );
|
||||
|
||||
|
@ -246,7 +247,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
return orPattern;
|
||||
}
|
||||
|
||||
IScanner scanner = ParserFactory.createScanner( new StringReader( patternString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, null );
|
||||
IScanner scanner = ParserFactory.createScanner( new StringReader( patternString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
|
||||
|
||||
IToken token = null;
|
||||
ASTClassKind kind = null;
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Iterator;
|
|||
import java.util.LinkedList;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
|
@ -31,6 +32,7 @@ import org.eclipse.cdt.core.parser.IScannerInfo;
|
|||
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.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||
|
@ -356,8 +358,16 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
|||
IScannerInfo buildScanInfo = provider.getScannerInformation(project);
|
||||
scanInfo = new ScannerInfo(buildScanInfo.getDefinedSymbols(), buildScanInfo.getIncludePaths());
|
||||
}
|
||||
IScanner scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETE_PARSE, this );
|
||||
IParser parser = ParserFactory.createParser( scanner, this, ParserMode.COMPLETE_PARSE );
|
||||
|
||||
ParserLanguage language = null;
|
||||
if( project != null ){
|
||||
language = CoreModel.getDefault().hasCCNature( project ) ? ParserLanguage.CPP : ParserLanguage.C;
|
||||
} else {
|
||||
//TODO no probject, 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 );
|
||||
|
||||
if (VERBOSE)
|
||||
MatchLocator.verbose("*** New Search for path: " + pathString);
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2003-09-08 Andrew Niefer
|
||||
- Modified call to ParserFactory in CStructureCreator to specify which language to use
|
||||
|
||||
2003-09-05 Andrew Niefer
|
||||
C++ Search:
|
||||
- enable Selected Resource Scope
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.eclipse.cdt.core.model.ICElement;
|
|||
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.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
|
@ -67,9 +68,12 @@ public class CStructureCreator implements IStructureCreator {
|
|||
|
||||
ISourceElementRequestor builder = new CParseTreeBuilder(root, doc);
|
||||
try {
|
||||
//Using the CPP parser (was implicit before, now its explicit). If there
|
||||
//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, builder);
|
||||
IParser parser = ParserFactory.createParser(scanner, builder, ParserMode.QUICK_PARSE);
|
||||
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 );
|
||||
parser.parse();
|
||||
} catch (Exception e) {
|
||||
// What to do when error ?
|
||||
|
|
Loading…
Add table
Reference in a new issue