From d71d9270d85cbf9963deae1b57b6ce99b7e0395d Mon Sep 17 00:00:00 2001 From: John Camelon Date: Wed, 9 Jul 2003 00:47:49 +0000 Subject: [PATCH] CORE Filled out IASTMethod & IASTFunction & added implementations. Updated IScanner, clients & implementations to use IScannerInfo. Finished SimpleDeclaration porting to new architecture, only thing left is templates. TESTS Updated IScanner, clients & implementations to use IScannerInfo. --- core/org.eclipse.cdt.core.tests/ChangeLog | 3 + .../cdt/core/parser/tests/AutomatedTest.java | 3 +- .../cdt/core/parser/tests/BaseDOMTest.java | 3 +- .../core/parser/tests/BaseScannerTest.java | 3 +- .../cdt/core/parser/tests/ExprEvalTest.java | 3 +- .../parser/tests/FractionalAutomatedTest.java | 3 +- .../cdt/core/parser/tests/LineNumberTest.java | 3 +- .../parser/tests/ParserSymbolTableTest.java | 1 + .../tests/PreprocessorConditionalTest.java | 3 +- .../core/parser/tests/PreprocessorTest.java | 3 +- .../cdt/core/parser/tests/TortureTest.java | 4 +- .../cdt/internal/core/dom/DOMBuilder.java | 3 +- .../core/search/indexing/SourceIndexer.java | 3 +- .../indexing/SourceIndexerRequestor.java | 3 +- .../internal/core/model/CModelBuilder.java | 7 +- core/org.eclipse.cdt.core/parser/ChangeLog | 5 + .../org/eclipse/cdt/core/parser/IScanner.java | 6 +- .../core/parser/ISourceElementRequestor.java | 3 +- .../cdt/core/parser/ParserFactory.java | 20 +- ...r.java => ASTNotImplementedException.java} | 6 +- .../parser/ast/IASTAbstractDeclaration.java | 29 + .../core/parser/ast/IASTClassReference.java | 21 + .../cdt/core/parser/ast/IASTEnumerator.java | 2 +- .../ast/IASTExceptionSpecification.java | 4 +- .../cdt/core/parser/ast/IASTFactory.java | 206 +++-- .../cdt/core/parser/ast/IASTField.java | 4 +- .../cdt/core/parser/ast/IASTFunction.java | 10 +- .../parser/ast/IASTInitializerClause.java | 4 +- .../cdt/core/parser/ast/IASTMember.java | 20 + .../cdt/core/parser/ast/IASTMethod.java | 7 +- .../parser/ast/IASTParameterDeclaration.java | 22 + .../parser/ast/IASTTemplateDeclaration.java | 3 +- .../cdt/core/parser/ast/IASTTypedef.java | 5 +- .../cdt/core/parser/ast/IASTVariable.java | 7 +- .../core/parser/DeclarationWrapper.java | 735 +++++++++++------- .../cdt/internal/core/parser/Declarator.java | 5 +- .../parser/NullSourceElementRequestor.java | 3 +- .../cdt/internal/core/parser/Parser.java | 184 ++++- .../internal/core/parser/PointerOperator.java | 97 --- .../internal/core/parser/Preprocessor.java | 6 +- .../cdt/internal/core/parser/Scanner.java | 35 +- .../cdt/internal/core/parser/ScannerInfo.java | 50 ++ .../core/parser/ast/IASTArrayModifier.java | 4 +- .../parser/ast/full/FullParseASTFactory.java | 71 +- .../ast/quick/ASTAbstractDeclaration.java | 70 ++ .../parser/ast/quick/ASTArrayModifier.java | 38 + .../core/parser/ast/quick/ASTEnumerator.java | 14 +- .../ast/quick/ASTExceptionSpecification.java | 4 +- .../core/parser/ast/quick/ASTField.java | 63 ++ .../core/parser/ast/quick/ASTFunction.java | 164 ++++ .../ast/quick/ASTInitializerClause.java | 5 +- .../core/parser/ast/quick/ASTMethod.java | 147 ++++ .../ast/quick/ASTParameterDeclaration.java | 91 +++ .../ast/quick/ASTSimpleTypeSpecifier.java | 2 +- .../ast/quick/ASTTemplateDeclaration.java | 61 ++ .../core/parser/ast/quick/ASTVariable.java | 124 +++ .../ast/quick/QuickParseASTFactory.java | 69 +- .../core/search/matching/CSearchPattern.java | 3 +- .../core/search/matching/MatchLocator.java | 28 +- core/org.eclipse.cdt.ui/ChangeLog | 3 + .../ui/compare/ComparatorModelBuilder.java | 3 +- 61 files changed, 1937 insertions(+), 574 deletions(-) rename core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/{IASTAbstractDeclarator.java => ASTNotImplementedException.java} (80%) create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTAbstractDeclaration.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTClassReference.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTMember.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTParameterDeclaration.java delete mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/PointerOperator.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ScannerInfo.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTAbstractDeclaration.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTArrayModifier.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTField.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTFunction.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTMethod.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTParameterDeclaration.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTTemplateDeclaration.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTVariable.java diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index 52cd4e025be..f26e812d9c0 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -1,3 +1,6 @@ +2003-07-08 John Camelon + Updated IScanner, clients & implementations to use IScannerInfo. + 2003-07-07 John Camelon Update ClassDeclarationPatternTests::testBug39652(). diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/AutomatedTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/AutomatedTest.java index adb397c5a8e..cc87782f5c7 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/AutomatedTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/AutomatedTest.java @@ -25,6 +25,7 @@ import org.eclipse.cdt.core.parser.ILineOffsetReconciler; import org.eclipse.cdt.core.parser.IParser; import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ParserMode; +import org.eclipse.cdt.internal.core.parser.ScannerInfo; import org.eclipse.core.runtime.Path; @@ -55,7 +56,7 @@ public class AutomatedTest extends AutomatedFramework { FileInputStream stream = new FileInputStream( file ); String filePath = file.getCanonicalPath(); - parser = ParserFactory.createParser( ParserFactory.createScanner( new InputStreamReader (stream), filePath, null, null, ParserMode.QUICK_PARSE ), nullCallback, ParserMode.QUICK_PARSE); + parser = ParserFactory.createParser( ParserFactory.createScanner( new InputStreamReader (stream), filePath, new ScannerInfo(), ParserMode.QUICK_PARSE ), nullCallback, ParserMode.QUICK_PARSE); parser.setCppNature( ((String)natures.get( filePath )).equalsIgnoreCase("cpp") ); mapping = ParserFactory.createLineOffsetReconciler( new InputStreamReader( stream ) ); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/BaseDOMTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/BaseDOMTest.java index 6e298ef1327..44a594d228d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/BaseDOMTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/BaseDOMTest.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.internal.core.dom.DOMBuilder; import org.eclipse.cdt.internal.core.dom.TranslationUnit; import org.eclipse.cdt.internal.core.parser.ParserException; +import org.eclipse.cdt.internal.core.parser.ScannerInfo; /** * @author jcamelon @@ -40,7 +41,7 @@ public class BaseDOMTest extends TestCase { public TranslationUnit parse(String code, boolean quickParse, boolean throwOnError ) throws Exception { DOMBuilder domBuilder = new DOMBuilder(); ParserMode mode = quickParse ? ParserMode.QUICK_PARSE : ParserMode.COMPLETE_PARSE; - IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, null, null, mode ), domBuilder, mode ); + IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), mode ), domBuilder, mode ); if( ! parser.parse() ) if( throwOnError ) throw new ParserException( "Parse failure" ); else domBuilder.getTranslationUnit().setParseSuccessful( false ); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/BaseScannerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/BaseScannerTest.java index 62e796996d0..1214e2234b3 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/BaseScannerTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/BaseScannerTest.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ScannerException; +import org.eclipse.cdt.internal.core.parser.ScannerInfo; /** * @author jcamelon @@ -36,7 +37,7 @@ public class BaseScannerTest extends TestCase { protected void initializeScanner(String input) { - scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", null, null, null ); + scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", new ScannerInfo(), null ); } public int fullyTokenize() throws Exception diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ExprEvalTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ExprEvalTest.java index 52f72919472..290d4f5c9ba 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ExprEvalTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ExprEvalTest.java @@ -11,6 +11,7 @@ import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ast.IASTExpression; import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor; +import org.eclipse.cdt.internal.core.parser.ScannerInfo; public class ExprEvalTest extends TestCase { @@ -24,7 +25,7 @@ public class ExprEvalTest extends TestCase { public void runTest(String code, int expectedValue) throws Exception { - IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, null, null, null ), new NullSourceElementRequestor(), ParserMode.QUICK_PARSE); + IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), null ), new NullSourceElementRequestor(), ParserMode.QUICK_PARSE); IASTExpression expression = parser.expression(null); assertEquals(expectedValue, expression.evaluateExpression()); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FractionalAutomatedTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FractionalAutomatedTest.java index a5036a7d388..11a72cff586 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FractionalAutomatedTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FractionalAutomatedTest.java @@ -25,6 +25,7 @@ import junit.framework.Test; import org.eclipse.cdt.core.parser.IParser; import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ParserMode; +import org.eclipse.cdt.internal.core.parser.ScannerInfo; import org.eclipse.core.runtime.Path; /** @@ -238,7 +239,7 @@ public class FractionalAutomatedTest extends AutomatedFramework { try{ result = null; IParser parser = ParserFactory.createParser( - ParserFactory.createScanner( new StringReader( code ), null, null, null, ParserMode.QUICK_PARSE ), nullCallback, ParserMode.QUICK_PARSE); + ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), ParserMode.QUICK_PARSE ), nullCallback, ParserMode.QUICK_PARSE); parser.setCppNature( cppNature ); parser.parse(); } catch ( Exception e ){ diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/LineNumberTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/LineNumberTest.java index b5dff6303ab..a6d2a7b4a94 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/LineNumberTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/LineNumberTest.java @@ -28,6 +28,7 @@ import org.eclipse.cdt.internal.core.dom.IOffsetable; import org.eclipse.cdt.internal.core.dom.NamespaceDefinition; import org.eclipse.cdt.internal.core.dom.SimpleDeclaration; import org.eclipse.cdt.internal.core.dom.TemplateDeclaration; +import org.eclipse.cdt.internal.core.parser.ScannerInfo; import org.eclipse.core.runtime.Path; /** @@ -53,7 +54,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, null, null, ParserMode.QUICK_PARSE ), domBuilder, ParserMode.QUICK_PARSE ); + IParser parser = ParserFactory.createParser( ParserFactory.createScanner( new InputStreamReader( fileIn ), null, new ScannerInfo(), ParserMode.QUICK_PARSE ), domBuilder, ParserMode.QUICK_PARSE ); //parser.mapLineNumbers(true); if( ! parser.parse() ) fail( "Parse of file failed"); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java index 6e3bf312fc1..868599d29f3 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java @@ -26,6 +26,7 @@ import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol; import org.eclipse.cdt.internal.core.parser.pst.ISymbol; import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable; import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableException; +import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Declaration; import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Mark; import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TemplateInstance; import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfo; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/PreprocessorConditionalTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/PreprocessorConditionalTest.java index eb8122fb83b..1d387b33368 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/PreprocessorConditionalTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/PreprocessorConditionalTest.java @@ -19,6 +19,7 @@ import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerException; +import org.eclipse.cdt.internal.core.parser.ScannerInfo; /** * @author jcamelon @@ -29,7 +30,7 @@ public class PreprocessorConditionalTest extends BaseScannerTest protected void initializeScanner(String input, Map definitions ) { - scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", definitions, null, ParserMode.COMPLETE_PARSE ); + scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", new ScannerInfo( definitions, null), ParserMode.COMPLETE_PARSE ); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/PreprocessorTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/PreprocessorTest.java index 3c9cc22f0de..28bd5e7e03a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/PreprocessorTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/PreprocessorTest.java @@ -23,6 +23,7 @@ import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ast.IASTInclusion; import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor; +import org.eclipse.cdt.internal.core.parser.ScannerInfo; /** * @author jcamelon @@ -72,7 +73,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", defns, includePaths, ParserMode.COMPLETE_PARSE ); + IPreprocessor p = ParserFactory.createPreprocessor( new StringReader( text ), "test", new ScannerInfo(), ParserMode.COMPLETE_PARSE ); p.setRequestor( rq ); return p; } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/TortureTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/TortureTest.java index c0a829aca61..3517f990619 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/TortureTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/TortureTest.java @@ -18,6 +18,7 @@ import java.io.StringReader; import java.io.StringWriter; import java.util.NoSuchElementException; import java.util.StringTokenizer; + import junit.framework.AssertionFailedError; import junit.framework.Test; @@ -26,6 +27,7 @@ import org.eclipse.cdt.core.parser.IParser; import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.internal.core.dom.DOMBuilder; +import org.eclipse.cdt.internal.core.parser.ScannerInfo; import org.eclipse.core.runtime.Path; @@ -269,7 +271,7 @@ public class TortureTest extends FractionalAutomatedTest { try { DOMBuilder domBuilder = new DOMBuilder(); parser = ParserFactory.createParser( - ParserFactory.createScanner( new StringReader( code ), null, null, null, ParserMode.QUICK_PARSE ), nullCallback, ParserMode.QUICK_PARSE); + ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), ParserMode.QUICK_PARSE ), nullCallback, ParserMode.QUICK_PARSE); parser.setCppNature(cppNature); mapping = ParserFactory.createLineOffsetReconciler( new StringReader( code ) ); diff --git a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java index fbdade55b2a..1dbde3b4e0c 100644 --- a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java +++ b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java @@ -7,6 +7,7 @@ import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; +import org.eclipse.cdt.core.parser.ast.IASTClassReference; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit; import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier; @@ -1259,7 +1260,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptClassReference(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, int) */ - public void acceptClassReference(IASTClassSpecifier classSpecifier, int referenceOffset) { + public void acceptClassReference(IASTClassReference reference) { // TODO Auto-generated method stub } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java index e1c3c72878e..ab3923e7d34 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java @@ -23,6 +23,7 @@ import org.eclipse.cdt.core.parser.IParser; import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.internal.core.index.IDocument; +import org.eclipse.cdt.internal.core.parser.ScannerInfo; /** * A SourceIndexer indexes source files using the parser. The following items are indexed: @@ -58,7 +59,7 @@ public class SourceIndexer extends AbstractIndexer { // Create a new Parser SourceIndexerRequestor requestor = new SourceIndexerRequestor(this, document); IParser parser = ParserFactory.createParser( - ParserFactory.createScanner( new StringReader( document.getStringContent() ), document.getName(), null, null, ParserMode.QUICK_PARSE ), + ParserFactory.createScanner( new StringReader( document.getStringContent() ), document.getName(), new ScannerInfo(), ParserMode.QUICK_PARSE ), requestor, ParserMode.QUICK_PARSE); try{ parser.parse(); diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java index 85ec812f10b..fe7c7a977ea 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java @@ -21,6 +21,7 @@ import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; +import org.eclipse.cdt.core.parser.ast.IASTClassReference; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit; import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier; @@ -256,7 +257,7 @@ public class SourceIndexerRequestor implements IParserCallback,ISourceElementReq /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptClassReference(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, int) */ - public void acceptClassReference(IASTClassSpecifier classSpecifier,int referenceOffset) { + public void acceptClassReference(IASTClassReference reference) { // TODO Auto-generated method stub //System.out.println("acceptClassReference"); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder.java index 7fc22052559..0f20a1f8d73 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder.java @@ -56,6 +56,7 @@ import org.eclipse.cdt.internal.core.dom.TemplateParameter; import org.eclipse.cdt.internal.core.dom.TranslationUnit; import org.eclipse.cdt.internal.core.dom.TypeSpecifier; import org.eclipse.cdt.internal.core.parser.Name; +import org.eclipse.cdt.internal.core.parser.ScannerInfo; import org.eclipse.core.resources.IProject; @@ -93,9 +94,9 @@ public class CModelBuilder { new StringReader( translationUnit.getBuffer().getContents() ), - null, null, null, - ParserMode.QUICK_PARSE, - problemReporter, unitResult + null, new ScannerInfo(), ParserMode.QUICK_PARSE, + problemReporter, + unitResult ), domBuilder, ParserMode.QUICK_PARSE, diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog b/core/org.eclipse.cdt.core/parser/ChangeLog index 679cff2b274..5fd8cbffa92 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog +++ b/core/org.eclipse.cdt.core/parser/ChangeLog @@ -1,3 +1,8 @@ +2003-07-08 John Camelon + Filled out IASTMethod & IASTFunction & added implementations. + Updated IScanner, clients & implementations to use IScannerInfo. + Finished SimpleDeclaration porting to new architecture, only thing left is templates. + 2003-07-07 John Camelon Bug 39652 - AST: Nested Classes incorrectly report null qualified Names Fuller specification of Field/Method interfaces. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java index 61358e74aad..a448f7ac3af 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java @@ -1,7 +1,5 @@ package org.eclipse.cdt.core.parser; -import java.util.List; - import org.eclipse.cdt.core.parser.ast.IASTFactory; /** @@ -18,9 +16,9 @@ public interface IScanner { public void addDefinition(String key, String value); public Object getDefinition(String key); - public Object[] getIncludePaths(); + public String[] getIncludePaths(); public void addIncludePath(String includePath); - public void overwriteIncludePath( List newIncludePaths ); + public void overwriteIncludePath( String [] newIncludePaths ); public void setRequestor( ISourceElementRequestor r ); public IToken nextToken() throws ScannerException, EndOfFile; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java index ed9e9036c6d..6af5b3dbfd6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java @@ -11,6 +11,7 @@ package org.eclipse.cdt.core.parser; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; +import org.eclipse.cdt.core.parser.ast.IASTClassReference; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit; import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier; @@ -65,7 +66,7 @@ public interface ISourceElementRequestor { public void exitMethodBody( IASTMethod method ); public void acceptField( IASTField field ); - public void acceptClassReference( IASTClassSpecifier classSpecifier, int referenceOffset ); + public void acceptClassReference( IASTClassReference reference ); public void exitTemplateDeclaration( IASTTemplateDeclaration declaration ); public void exitTemplateSpecialization( IASTTemplateSpecialization specialization ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java index 48c3247f157..1be296ae9c9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java @@ -11,10 +11,8 @@ package org.eclipse.cdt.core.parser; import java.io.Reader; -import java.util.List; import java.util.Map; -//import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.parser.ast.IASTFactory; import org.eclipse.cdt.internal.core.parser.DefaultErrorHandlingPolicies; import org.eclipse.cdt.internal.core.parser.LineOffsetReconciler; @@ -56,31 +54,29 @@ public class ParserFactory { return new Parser( scanner, ourCallback, ourMode, problemReporter, unitResult ); } - public static IScanner createScanner( Reader input, String fileName, Map defns, List inclusions, ParserMode mode ) + public static IScanner createScanner( Reader input, String fileName, IScannerInfo config, ParserMode mode ) { - return createScanner(input, fileName, defns, inclusions, mode, null, null); + return createScanner(input, fileName, config, mode, null, null); } - public static IScanner createScanner( Reader input, String fileName, Map defns, List inclusions, ParserMode mode, IProblemReporter problemReporter, ITranslationResult unitResult ) + public static IScanner createScanner( Reader input, String fileName, IScannerInfo config, ParserMode mode, IProblemReporter problemReporter, ITranslationResult unitResult ) { ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode ); - IScanner s = new Scanner( input, fileName, defns, problemReporter, unitResult ); + IScanner s = new Scanner( input, fileName, config, problemReporter, unitResult ); s.setMode( ourMode ); - s.overwriteIncludePath(inclusions); return s; } - public static IPreprocessor createPreprocessor( Reader input, String fileName, Map defns, List inclusions, ParserMode mode ) + public static IPreprocessor createPreprocessor( Reader input, String fileName, IScannerInfo info, ParserMode mode ) { - return createPreprocessor(input, fileName, defns, inclusions, mode, null, null); + return createPreprocessor(input, fileName, info, mode, null, null); } - public static IPreprocessor createPreprocessor( Reader input, String fileName, Map defns, List inclusions, ParserMode mode, IProblemReporter problemReporter, ITranslationResult unitResult ) + public static IPreprocessor createPreprocessor( Reader input, String fileName, IScannerInfo info, ParserMode mode, IProblemReporter problemReporter, ITranslationResult unitResult ) { ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode ); - IPreprocessor s = new Preprocessor( input, fileName, defns, problemReporter, unitResult ); + IPreprocessor s = new Preprocessor( input, fileName, info, problemReporter, unitResult ); s.setMode( ourMode ); - s.overwriteIncludePath(inclusions); return s; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTAbstractDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/ASTNotImplementedException.java similarity index 80% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTAbstractDeclarator.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/ASTNotImplementedException.java index 96a33119c9a..5094f68e0bd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTAbstractDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/ASTNotImplementedException.java @@ -10,14 +10,10 @@ ***********************************************************************/ package org.eclipse.cdt.core.parser.ast; -import java.util.List; - /** * @author jcamelon * */ -public interface IASTAbstractDeclarator +public class ASTNotImplementedException { - public IASTTypeSpecifier getTypeSpecifier(); - public List getPointerOperators(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTAbstractDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTAbstractDeclaration.java new file mode 100644 index 00000000000..ba3a94fecfe --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTAbstractDeclaration.java @@ -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.core.parser.ast; + +import java.util.Iterator; + +/** + * @author jcamelon + * + */ +public interface IASTAbstractDeclaration +{ + public boolean isConst(); + + public IASTTypeSpecifier getTypeSpecifier(); + + public Iterator getPointerOperators(); + + public Iterator getArrayModifiers(); + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTClassReference.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTClassReference.java new file mode 100644 index 00000000000..7b829868293 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTClassReference.java @@ -0,0 +1,21 @@ +/********************************************************************** + * 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.ast; + +/** + * @author jcamelon + * + */ +public interface IASTClassReference +{ + public IASTClassSpecifier getClassSpecifier(); + public int getOffset(); +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTEnumerator.java index e47a568126a..e9922bc2acf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTEnumerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTEnumerator.java @@ -17,5 +17,5 @@ package org.eclipse.cdt.core.parser.ast; public interface IASTEnumerator extends IASTOffsetableNamedElement { public IASTEnumerationSpecifier getOwnerEnumerationSpecifier(); - // public IASTExpression getInitialValue(); + public IASTExpression getInitialValue(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTExceptionSpecification.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTExceptionSpecification.java index d61d742bfb0..66f5ef20afb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTExceptionSpecification.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTExceptionSpecification.java @@ -10,7 +10,7 @@ ***********************************************************************/ package org.eclipse.cdt.core.parser.ast; -import java.util.List; +import java.util.Iterator; /** * @author jcamelon @@ -18,5 +18,5 @@ import java.util.List; */ public interface IASTExceptionSpecification { - public List getTypeIds(); + public Iterator getTypeIds(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java index 6f6e7fa8150..1c79e52d6f3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java @@ -9,76 +9,101 @@ * IBM Rational Software - Initial API and implementation ***********************************************************************/ package org.eclipse.cdt.core.parser.ast; - import java.util.List; - import org.eclipse.cdt.core.parser.Backtrack; import org.eclipse.cdt.core.parser.ITokenDuple; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType; import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor; import org.eclipse.cdt.internal.core.parser.ast.IASTArrayModifier; - /** * @author jcamelon * */ -public interface IASTFactory { - - public IASTMacro createMacro( String name, int startingOffset, int endingOffset, int nameOffset ); - public IASTInclusion createInclusion( String name, String fileName, boolean local, int startingOffset, int endingOffset, int nameOffset ); - - public IASTUsingDirective createUsingDirective( - IASTScope scope, - ITokenDuple duple) - throws Backtrack; - - public IASTUsingDeclaration createUsingDeclaration( - IASTScope scope, - boolean isTypeName, - ITokenDuple name ); - - - public IASTASMDefinition createASMDefinition( - IASTScope scope, - String assembly, - int first, - int last); - - public IASTNamespaceDefinition createNamespaceDefinition( - IASTScope scope, - String identifier, - int startingOffset, int nameOffset); - - public IASTCompilationUnit createCompilationUnit(); - - public IASTLinkageSpecification createLinkageSpecification(IASTScope scope, String spec); - - public IASTClassSpecifier createClassSpecifier( IASTScope scope, - String name, - ASTClassKind kind, - ClassNameType type, - ASTAccessVisibility access, - IASTTemplateDeclaration ownerTemplateDeclaration, int startingOffset, int nameOffset ); - - /** - * @param astClassSpec - * @param isVirtual - * @param visibility - * @param string - */ - public void addBaseSpecifier(IASTClassSpecifier astClassSpec, boolean isVirtual, ASTAccessVisibility visibility, String string); - - public IASTElaboratedTypeSpecifier createElaboratedTypeSpecifier(ASTClassKind elaboratedClassKind, String typeName, int startingOffset, int endOffset ); - public IASTEnumerationSpecifier createEnumerationSpecifier(String name, int startingOffset, int nameOffset ); - public void addEnumerator(IASTEnumerationSpecifier enumeration, String string, int startingOffset, int endingOffset); - - public IASTExpression createExpression( IASTExpression.Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression thirdExpression, String id, String typeId, String literal, IASTNewExpressionDescriptor newDescriptor ); - +public interface IASTFactory +{ + public IASTMacro createMacro( + String name, + int startingOffset, + int endingOffset, + int nameOffset); + public IASTInclusion createInclusion( + String name, + String fileName, + boolean local, + int startingOffset, + int endingOffset, + int nameOffset); + public IASTUsingDirective createUsingDirective( + IASTScope scope, + ITokenDuple duple) + throws Backtrack; + public IASTUsingDeclaration createUsingDeclaration( + IASTScope scope, + boolean isTypeName, + ITokenDuple name); + public IASTASMDefinition createASMDefinition( + IASTScope scope, + String assembly, + int first, + int last); + public IASTNamespaceDefinition createNamespaceDefinition( + IASTScope scope, + String identifier, + int startingOffset, + int nameOffset); + public IASTCompilationUnit createCompilationUnit(); + public IASTLinkageSpecification createLinkageSpecification( + IASTScope scope, + String spec); + public IASTClassSpecifier createClassSpecifier( + IASTScope scope, + String name, + ASTClassKind kind, + ClassNameType type, + ASTAccessVisibility access, + IASTTemplateDeclaration ownerTemplateDeclaration, + int startingOffset, + int nameOffset); + /** + * @param astClassSpec + * @param isVirtual + * @param visibility + * @param string + */ + public void addBaseSpecifier( + IASTClassSpecifier astClassSpec, + boolean isVirtual, + ASTAccessVisibility visibility, + String string); + public IASTElaboratedTypeSpecifier createElaboratedTypeSpecifier( + ASTClassKind elaboratedClassKind, + String typeName, + int startingOffset, + int endOffset); + public IASTEnumerationSpecifier createEnumerationSpecifier( + String name, + int startingOffset, + int nameOffset); + public void addEnumerator( + IASTEnumerationSpecifier enumeration, + String string, + int startingOffset, + int endingOffset, IASTExpression initialValue); + public IASTExpression createExpression( + IASTExpression.Kind kind, + IASTExpression lhs, + IASTExpression rhs, + IASTExpression thirdExpression, + String id, + String typeId, + String literal, + IASTNewExpressionDescriptor newDescriptor); public IASTExpression.IASTNewExpressionDescriptor createNewDescriptor(); - - public IASTInitializerClause createInitializerClause(IASTInitializerClause.Kind kind, IASTExpression assignmentExpression, List initializerClauses); - - public IASTExceptionSpecification createExceptionSpecification( List typeIds ); + public IASTInitializerClause createInitializerClause( + IASTInitializerClause.Kind kind, + IASTExpression assignmentExpression, + List initializerClauses); + public IASTExceptionSpecification createExceptionSpecification(List typeIds); /** * @param exp */ @@ -88,10 +113,63 @@ public interface IASTFactory { * @param expressionList * @return */ - public IASTConstructorMemberInitializer createConstructorMemberInitializer(ITokenDuple duple, IASTExpression expressionList ); - - public IASTSimpleTypeSpecifier createSimpleTypeSpecifier( IASTSimpleTypeSpecifier.SimpleType kind, ITokenDuple typeName, boolean isShort, boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename ); - - + public IASTConstructorMemberInitializer createConstructorMemberInitializer( + ITokenDuple duple, + IASTExpression expressionList); + public IASTSimpleTypeSpecifier createSimpleTypeSpecifier( + IASTSimpleTypeSpecifier.SimpleType kind, + ITokenDuple typeName, + boolean isShort, + boolean isLong, + boolean isSigned, + boolean isUnsigned, + boolean isTypename); + public IASTFunction createFunction( + IASTScope scope, + String name, + List parameters, + IASTAbstractDeclaration returnType, + IASTExceptionSpecification exception, + boolean isInline, + boolean isFriend, + boolean isStatic, + int startOffset, + int nameOffset, + IASTTemplateDeclaration ownerTemplate); + public IASTAbstractDeclaration createAbstractDeclaration( + boolean isConst, + IASTTypeSpecifier typeSpecifier, + List pointerOperators, + List arrayModifiers); + public IASTMethod createMethod( + IASTScope scope, + String name, + List parameters, + IASTAbstractDeclaration returnType, + IASTExceptionSpecification exception, + boolean isInline, + boolean isFriend, + boolean isStatic, + int startOffset, + int nameOffset, + IASTTemplateDeclaration ownerTemplate, + boolean isConst, + boolean isVolatile, + boolean isConstructor, + boolean isDestructor, + boolean isVirtual, + boolean isExplicit, + boolean isPureVirtual, + ASTAccessVisibility visibility); + + public IASTVariable createVariable(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, + IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic ); + + public IASTField createField( IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, ASTAccessVisibility visibility); + public IASTParameterDeclaration createParameterDeclaration( boolean isConst, IASTTypeSpecifier getTypeSpecifier, List pointerOperators, List arrayModifiers, String parameterName, IASTInitializerClause initializerClause ); + + public IASTTemplateDeclaration createTemplateDeclaration( IASTScope scope, List templateParameters ); + + } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTField.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTField.java index 5813d615514..ec66c517dc9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTField.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTField.java @@ -14,6 +14,8 @@ package org.eclipse.cdt.core.parser.ast; * @author jcamelon * */ -public interface IASTField extends IASTVariable { +public interface IASTField extends IASTVariable, IASTMember { + + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFunction.java index 069d1ba1eb0..9f25dc7eec1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFunction.java @@ -10,16 +10,22 @@ ***********************************************************************/ package org.eclipse.cdt.core.parser.ast; +import java.util.Iterator; + /** * @author jcamelon * */ -public interface IASTFunction { +public interface IASTFunction extends IASTScope, IASTOffsetableNamedElement, IASTTemplatedDeclaration, IASTDeclaration { public boolean isInline(); public boolean isFriend(); public boolean isStatic(); - public IASTAbstractDeclarator getReturnType(); + public String getName(); + + public IASTAbstractDeclaration getReturnType(); + public Iterator getParameters(); + public IASTExceptionSpecification getExceptionSpec(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTInitializerClause.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTInitializerClause.java index b630d7fff2a..227324b241e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTInitializerClause.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTInitializerClause.java @@ -10,7 +10,7 @@ ***********************************************************************/ package org.eclipse.cdt.core.parser.ast; -import java.util.List; +import java.util.Iterator; import org.eclipse.cdt.core.parser.Enum; @@ -34,7 +34,7 @@ public interface IASTInitializerClause { } public Kind getKind(); - public List getInitializerList(); + public Iterator getInitializers(); public IASTExpression getAssigmentExpression(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTMember.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTMember.java new file mode 100644 index 00000000000..a2cec3c734f --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTMember.java @@ -0,0 +1,20 @@ +/********************************************************************** + * 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.ast; + +/** + * @author jcamelon + * + */ +public interface IASTMember extends IASTDeclaration +{ + public ASTAccessVisibility getVisiblity(); +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTMethod.java index d44754c1303..717f8e2f282 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTMethod.java @@ -14,7 +14,7 @@ package org.eclipse.cdt.core.parser.ast; * @author jcamelon * */ -public interface IASTMethod extends IASTFunction { +public interface IASTMethod extends IASTFunction, IASTMember { public boolean isVirtual(); public boolean isExplicit(); @@ -22,4 +22,9 @@ public interface IASTMethod extends IASTFunction { public boolean isConstructor(); public boolean isDestructor(); + public boolean isConst(); + public boolean isVolatile(); + public boolean isPureVirtual(); + + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTParameterDeclaration.java new file mode 100644 index 00000000000..0f490b439d1 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTParameterDeclaration.java @@ -0,0 +1,22 @@ +/********************************************************************** + * 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.ast; + +/** + * @author jcamelon + * + */ +public interface IASTParameterDeclaration extends IASTAbstractDeclaration +{ + public String getName(); + public IASTInitializerClause getDefaultValue(); + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTemplateDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTemplateDeclaration.java index cf4260698cd..f201ec56b47 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTemplateDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTemplateDeclaration.java @@ -16,9 +16,10 @@ import java.util.Iterator; * @author jcamelon * */ -public interface IASTTemplateDeclaration { +public interface IASTTemplateDeclaration extends IASTDeclaration { public ASTTemplateDeclarationType getTemplateDeclarationType(); public Iterator getTemplateParameters(); + public IASTDeclaration getOwnedDeclaration(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTypedef.java index 9f44423aba5..8c9d2fca00a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTypedef.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTypedef.java @@ -14,6 +14,9 @@ package org.eclipse.cdt.core.parser.ast; * @author jcamelon * */ -public interface IASTTypedef { +public interface IASTTypedef extends IASTDeclaration { + + public String getName(); + public IASTAbstractDeclaration getAbstractDeclarator(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTVariable.java index 8f20e7dbcdd..fee6dd0ffae 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTVariable.java @@ -14,7 +14,7 @@ package org.eclipse.cdt.core.parser.ast; * @author jcamelon * */ -public interface IASTVariable { +public interface IASTVariable extends IASTDeclaration { public boolean isAuto(); public boolean isRegister(); @@ -22,7 +22,10 @@ public interface IASTVariable { public boolean isExtern(); public boolean isMutable(); - public IASTAbstractDeclarator getAbstractDeclaration(); + public IASTAbstractDeclaration getAbstractDeclaration(); public String getName(); public IASTInitializerClause getInitializerClause(); + + public boolean isBitfield(); + public IASTExpression getBitfieldExpression(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java index 4c865a2a927..647c5bf5f4a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java @@ -9,287 +9,273 @@ * IBM Rational Software - Initial API and implementation ***********************************************************************/ package org.eclipse.cdt.internal.core.parser; - import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; +import org.eclipse.cdt.core.parser.ITokenDuple; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; +import org.eclipse.cdt.core.parser.ast.IASTDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTFactory; import org.eclipse.cdt.core.parser.ast.IASTField; import org.eclipse.cdt.core.parser.ast.IASTFunction; import org.eclipse.cdt.core.parser.ast.IASTMethod; import org.eclipse.cdt.core.parser.ast.IASTScope; +import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier; +import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTVariable; - +import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.SimpleType; /** * @author jcamelon * */ public class DeclarationWrapper implements IDeclaratorOwner { - private final IASTScope scope; - private IASTTypeSpecifier typeSpecifier; - private List declarators = new ArrayList(); - private boolean typeNamed = false; - private String name = null; - private boolean volatil = false; - private boolean virtual = false; - private boolean typedef = false; - private boolean staticc = false; - private boolean register = false; - private boolean extern = false; - private boolean explicit = false; - private boolean constt = false; - private int startingOffset = 0; - private boolean auto = false, - mutable = false, - friend = false, - inline = false; - /** - * @param b - */ - public void setAuto(boolean b) - { - auto = b; - } - /** - * @return - */ - public IASTScope getScope() - { - return scope; - } - /** - * @param scope - */ - public DeclarationWrapper(IASTScope scope) - { - this.scope = scope; - } - /** - * @param b - */ - public void setTypenamed(boolean b) - { - typeNamed = b; - } - /** - * @param string - */ - public void setTypeName(String string) - { - name = string; - } - private int type = -1; - /** - * @param i - */ - public void setType(int i) - { - type = i; - } - /** - * @param b - */ - public void setMutable(boolean b) - { - mutable = b; - } - /** - * @param b - */ - public void setFriend(boolean b) - { - friend = b; - } - /** - * @param b - */ - public void setInline(boolean b) - { - inline = b; - } - /** - * @param b - */ - public void setRegister(boolean b) - { - register = b; - } - /** - * @param b - */ - public void setStatic(boolean b) - { - staticc = b; - } - /** - * @param b - */ - public void setTypedef(boolean b) - { - typedef = b; - } - /** - * @param b - */ - public void setVirtual(boolean b) - { - virtual = b; - } - /** - * @param b - */ - public void setVolatile(boolean b) - { - volatil = b; - } - /** - * @param b - */ - public void setExtern(boolean b) - { - extern = b; - } - /** - * @param b - */ - public void setExplicit(boolean b) - { - explicit = b; - } - /** - * @param b - */ - public void setConst(boolean b) - { - constt = b; - } - /** - * @return - */ - public boolean isAuto() - { - return auto; - } - /** - * @return - */ - public boolean isConst() - { - return constt; - } - /** - * @return - */ - public boolean isExplicit() - { - return explicit; - } - /** - * @return - */ - public boolean isExtern() - { - return extern; - } - /** - * @return - */ - public boolean isFriend() - { - return friend; - } - /** - * @return - */ - public boolean isInline() - { - return inline; - } - /** - * @return - */ - public boolean isMutable() - { - return mutable; - } - /** - * @return - */ - public String getName() - { - return name; - } - /** - * @return - */ - public boolean isRegister() - { - return register; - } - /** - * @return - */ - public int getStartingOffset() - { - return startingOffset; - } - /** - * @return - */ - public boolean isStatic() - { - return staticc; - } - /** - * @return - */ - public int getType() - { - return type; - } - /** - * @return - */ - public boolean isTypedef() - { - return typedef; - } - /** - * @return - */ - public boolean isTypeNamed() - { - return typeNamed; - } - /** - * @return - */ - public boolean isVirtual() - { - return virtual; - } - /** - * @return - */ - public boolean isVolatile() - { - return volatil; - } - - public void addDeclarator( Declarator d ) - { - declarators.add( d ); - } - - public Iterator getDeclarators() - { - return Collections.unmodifiableList( declarators ).iterator(); - } + private ITokenDuple name; + private SimpleType simpleType = IASTSimpleTypeSpecifier.SimpleType.UNSPECIFIED; + private boolean isSigned; + private boolean isLong; + private boolean isShort; + private boolean isUnsigned; + private final IASTTemplateDeclaration templateDeclaration; + private final IASTScope scope; + private IASTTypeSpecifier typeSpecifier; + private List declarators = new ArrayList(); + private boolean typeNamed = false; + private boolean volatil = false; + private boolean virtual = false; + private boolean typedef = false; + private boolean staticc = false; + private boolean register = false; + private boolean extern = false; + private boolean explicit = false; + private boolean constt = false; + private int startingOffset = 0; + private boolean auto = false, + mutable = false, + friend = false, + inline = false; + /** + * @param b + */ + public void setAuto(boolean b) + { + auto = b; + } + /** + * @return + */ + public IASTScope getScope() + { + return scope; + } + /** + * @param scope + */ + public DeclarationWrapper( + IASTScope scope, + int startingOffset, + IASTTemplateDeclaration templateDeclaration) + { + this.scope = scope; + this.startingOffset = startingOffset; + this.templateDeclaration = templateDeclaration; + } + /** + * @param b + */ + public void setTypenamed(boolean b) + { + typeNamed = b; + } + /** + * @param b + */ + public void setMutable(boolean b) + { + mutable = b; + } + /** + * @param b + */ + public void setFriend(boolean b) + { + friend = b; + } + /** + * @param b + */ + public void setInline(boolean b) + { + inline = b; + } + /** + * @param b + */ + public void setRegister(boolean b) + { + register = b; + } + /** + * @param b + */ + public void setStatic(boolean b) + { + staticc = b; + } + /** + * @param b + */ + public void setTypedef(boolean b) + { + typedef = b; + } + /** + * @param b + */ + public void setVirtual(boolean b) + { + virtual = b; + } + /** + * @param b + */ + public void setVolatile(boolean b) + { + volatil = b; + } + /** + * @param b + */ + public void setExtern(boolean b) + { + extern = b; + } + /** + * @param b + */ + public void setExplicit(boolean b) + { + explicit = b; + } + /** + * @param b + */ + public void setConst(boolean b) + { + constt = b; + } + /** + * @return + */ + public boolean isAuto() + { + return auto; + } + /** + * @return + */ + public boolean isConst() + { + return constt; + } + /** + * @return + */ + public boolean isExplicit() + { + return explicit; + } + /** + * @return + */ + public boolean isExtern() + { + return extern; + } + /** + * @return + */ + public boolean isFriend() + { + return friend; + } + /** + * @return + */ + public boolean isInline() + { + return inline; + } + /** + * @return + */ + public boolean isMutable() + { + return mutable; + } + + /** + * @return + */ + public boolean isRegister() + { + return register; + } + /** + * @return + */ + public int getStartingOffset() + { + return startingOffset; + } + /** + * @return + */ + public boolean isStatic() + { + return staticc; + } + + /** + * @return + */ + public boolean isTypedef() + { + return typedef; + } + /** + * @return + */ + public boolean isTypeNamed() + { + return typeNamed; + } + /** + * @return + */ + public boolean isVirtual() + { + return virtual; + } + /** + * @return + */ + public boolean isVolatile() + { + return volatil; + } + public void addDeclarator(Declarator d) + { + declarators.add(d); + } + public Iterator getDeclarators() + { + return Collections.unmodifiableList(declarators).iterator(); + } /** * @return */ @@ -297,7 +283,6 @@ public class DeclarationWrapper implements IDeclaratorOwner { return typeSpecifier; } - /** * @param specifier */ @@ -305,45 +290,66 @@ public class DeclarationWrapper implements IDeclaratorOwner { typeSpecifier = specifier; } - + private IASTFactory astFactory = null; /** * @param requestor */ - public List createAndCallbackASTNodes() + public List createASTNodes(IASTFactory astFactory) { + this.astFactory = astFactory; Iterator i = declarators.iterator(); - List l = new ArrayList(); - while( i.hasNext() ) - l.add( createAndCallbackASTNode( (Declarator)i.next() ) ); + List l = new ArrayList(); + while (i.hasNext()) + l.add(createASTNode((Declarator)i.next())); return l; } /** * @param declarator */ - private Object createAndCallbackASTNode(Declarator declarator) + private IASTDeclaration createASTNode(Declarator declarator) { - boolean isWithinClass = ( getScope() instanceof IASTClassSpecifier ); - boolean isFunction = declarator.isFunction(); - - if( isWithinClass && isFunction ) - return createMethodASTNode( declarator ); - else if( isWithinClass ) - return createFieldASTNode( declarator ); - else if ( ( ! isWithinClass )&& isFunction ) - return createFunctionASTNode( declarator ); - else - return createVariableASTNode( declarator ); - + boolean isWithinClass = (getScope() instanceof IASTClassSpecifier); + boolean isFunction = declarator.isFunction(); + if (isWithinClass && isFunction) + return createMethodASTNode(declarator); + else if (isWithinClass) + return createFieldASTNode(declarator); + else if ((!isWithinClass) && isFunction) + return createFunctionASTNode(declarator); + else + return createVariableASTNode(declarator); } - /** * @param declarator * @return */ private IASTMethod createMethodASTNode(Declarator declarator) { - - return null; + return astFactory + .createMethod( + scope, + declarator.getName(), + createParameterList( declarator.getParameters() ), + astFactory.createAbstractDeclaration( + constt, + getTypeSpecifier(), + declarator.getPtrOps(), + declarator.getArrayModifiers()), + declarator.getExceptionSpecification(), + inline, + friend, + staticc, + startingOffset, + declarator.getNameStartOffset(), + templateDeclaration, + declarator.isConst(), + declarator.isVolatile(), + false, // isConstructor + false, // isDestructor + virtual, + explicit, + declarator.isPureVirtual(), + ((IASTClassSpecifier)scope).getCurrentVisibilityMode()); } /** * @param declarator @@ -351,8 +357,22 @@ public class DeclarationWrapper implements IDeclaratorOwner */ private IASTFunction createFunctionASTNode(Declarator declarator) { - // TODO Auto-generated method stub - return null; + return astFactory.createFunction( + scope, + declarator.getName(), + createParameterList( declarator.getParameters() ), + astFactory.createAbstractDeclaration( + constt, + getTypeSpecifier(), + declarator.getPtrOps(), + declarator.getArrayModifiers()), + declarator.getExceptionSpecification(), + inline, + friend, + staticc, + startingOffset, + declarator.getNameStartOffset(), + templateDeclaration); } /** * @param declarator @@ -360,17 +380,51 @@ public class DeclarationWrapper implements IDeclaratorOwner */ private IASTField createFieldASTNode(Declarator declarator) { - // TODO Auto-generated method stub - return null; + return astFactory.createField( scope, declarator.getName(), auto, declarator.getInitializerClause(), declarator.getBitFieldExpression(), + astFactory.createAbstractDeclaration( constt, getTypeSpecifier(), declarator.getPtrOps(), declarator.getArrayModifiers() ), + mutable, extern, register, staticc, ((IASTClassSpecifier)scope).getCurrentVisibilityMode()); } + + private List createParameterList( List currentParameters ) + { + List result = new ArrayList(); + Iterator i = currentParameters.iterator(); + while( i.hasNext() ) + { + DeclarationWrapper wrapper = (DeclarationWrapper)i.next(); + Iterator j = wrapper.getDeclarators(); + while( j.hasNext() ) + { + Declarator declarator = (Declarator)j.next(); + result.add( astFactory.createParameterDeclaration( wrapper.isConst(), wrapper.getTypeSpecifier(), + declarator.getPtrOps(), declarator.getArrayModifiers(), + declarator.getName() == null ? "" : declarator.getName(), declarator.getInitializerClause() ) ); + } + } + return result; + } + /** * @param declarator * @return */ private IASTVariable createVariableASTNode(Declarator declarator) { - // TODO Auto-generated method stub - return null; + return astFactory.createVariable( + scope, + declarator.getName(), + isAuto(), + declarator.getInitializerClause(), + declarator.getBitFieldExpression(), + astFactory.createAbstractDeclaration( + constt, + getTypeSpecifier(), + declarator.getPtrOps(), + declarator.getArrayModifiers()), + mutable, + extern, + register, + staticc); } /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IDeclaratorOwner#getDeclarationWrapper() @@ -379,6 +433,103 @@ public class DeclarationWrapper implements IDeclaratorOwner { return this; } - -} + /** + * @return + */ + public boolean isUnsigned() + { + return isUnsigned; + } + /** + * @return + */ + public boolean isSigned() + { + return isSigned; + } + /** + * @return + */ + public boolean isShort() + { + return isShort; + } + /** + * @return + */ + public boolean isLong() + { + return isLong; + } + /** + * @param b + */ + public void setLong(boolean b) + { + isLong = b; + } + + /** + * @param b + */ + public void setShort(boolean b) + { + isShort = b; + } + + /** + * @param b + */ + public void setSigned(boolean b) + { + isSigned = b; + } + + /** + * @param b + */ + public void setUnsigned(boolean b) + { + isUnsigned = b; + } + /** + * @return + */ + public SimpleType getSimpleType() + { + return simpleType; + } + + /** + * @param type + */ + public void setSimpleType(SimpleType type) + { + simpleType = type; + } + /** + * @param duple + */ + public void setTypeName(ITokenDuple duple) + { + name = duple; + } + + /** + * @return + */ + public ITokenDuple getName() + { + return name; + } + + /** + * @param duple + */ + public void setName(ITokenDuple duple) + { + name = duple; + } + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Declarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Declarator.java index 2d724fd2751..e00494d04ee 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Declarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Declarator.java @@ -16,11 +16,12 @@ import java.util.Iterator; import java.util.List; import org.eclipse.cdt.core.parser.ITokenDuple; +import org.eclipse.cdt.core.parser.ast.ASTPointerOperator; import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer; import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification; import org.eclipse.cdt.core.parser.ast.IASTExpression; import org.eclipse.cdt.core.parser.ast.IASTInitializerClause; -import org.eclipse.cdt.internal.core.parser.ast.*; +import org.eclipse.cdt.internal.core.parser.ast.IASTArrayModifier; /** * @author jcamelon @@ -118,7 +119,7 @@ public class Declarator implements IParameterCollection, IDeclaratorOwner return Collections.unmodifiableList( ptrOps ); } - public void addPtrOp( PointerOperator ptrOp ) + public void addPtrOp( ASTPointerOperator ptrOp ) { ptrOps.add( ptrOp ); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullSourceElementRequestor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullSourceElementRequestor.java index a34d06b21b0..9f19de49a19 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullSourceElementRequestor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullSourceElementRequestor.java @@ -6,6 +6,7 @@ import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; +import org.eclipse.cdt.core.parser.ast.IASTClassReference; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit; import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier; @@ -876,7 +877,7 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptClassReference(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, int) */ - public void acceptClassReference(IASTClassSpecifier classSpecifier, int referenceOffset) { + public void acceptClassReference(IASTClassReference reference) { // TODO Auto-generated method stub } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java index f421a0290bc..5488f40b3b1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java @@ -27,6 +27,7 @@ import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerException; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.parser.ast.ASTClassKind; +import org.eclipse.cdt.core.parser.ast.ASTPointerOperator; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit; @@ -38,6 +39,7 @@ import org.eclipse.cdt.core.parser.ast.IASTInitializerClause; import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTScope; +import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration; import org.eclipse.cdt.core.parser.ast.IASTUsingDirective; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType; @@ -951,7 +953,7 @@ public class Parser implements IParser throws Backtrack { Object simpleDecl = null; - DeclarationWrapper sdw = new DeclarationWrapper(scope); + DeclarationWrapper sdw = new DeclarationWrapper(scope, LA(1).getOffset(), null); try { simpleDecl = callback.simpleDeclarationBegin(container, LA(1)); @@ -960,6 +962,9 @@ public class Parser implements IParser { } declSpecifierSeq(simpleDecl, false, tryConstructor, sdw); + if( sdw.getTypeSpecifier() == null && sdw.getSimpleType() != IASTSimpleTypeSpecifier.SimpleType.UNSPECIFIED ) + sdw.setTypeSpecifier( astFactory.createSimpleTypeSpecifier( sdw.getSimpleType(), sdw.getName(), sdw.isShort(), sdw.isLong(), sdw.isSigned(), sdw.isUnsigned(), sdw.isTypeNamed() ) ); + Object declarator = null; DeclaratorDuple d = null; if (LT(1) != IToken.tSEMI) @@ -1009,7 +1014,7 @@ public class Parser implements IParser throw backtrack; } - List l = sdw.createAndCallbackASTNodes(); + List l = sdw.createASTNodes(astFactory); if( hasFunctionBody ) { @@ -1188,13 +1193,17 @@ public class Parser implements IParser { } - DeclarationWrapper sdw = new DeclarationWrapper( null ); + DeclarationWrapper sdw = new DeclarationWrapper( null, current.getOffset(), null ); declSpecifierSeq( parameterDecl, true, false, sdw ); + if( sdw.getTypeSpecifier() == null && sdw.getSimpleType() != IASTSimpleTypeSpecifier.SimpleType.UNSPECIFIED ) + sdw.setTypeSpecifier( astFactory.createSimpleTypeSpecifier( sdw.getSimpleType(), sdw.getName(), sdw.isShort(), sdw.isLong(), sdw.isSigned(), sdw.isUnsigned(), sdw.isTypeNamed() ) ); + + if (LT(1) != IToken.tSEMI) try { @@ -1362,6 +1371,19 @@ public class Parser implements IParser || (LT(3) != IToken.tLPAREN && LT(3) != IToken.tASSIGN)) && !LA(2).isPointer()); } + + private void callbackSimpleDeclToken( Object decl, Flags flags ) + { + flags.setEncounteredRawType(true); + try + { + callback.simpleDeclSpecifier(decl, consume()); + } + catch (Exception e) + { + } + + } /** * This function parses a declaration specifier sequence, as according to the ANSI C++ spec. * @@ -1394,6 +1416,8 @@ public class Parser implements IParser throws Backtrack { Flags flags = new Flags(parm, tryConstructor); + IToken typeNameBegin = null; + IToken typeNameEnd = null; declSpecifiers : for (;;) { switch (LT(1)) @@ -1519,26 +1543,97 @@ public class Parser implements IParser } break; case IToken.t_signed : + sdw.setSigned(true); + if( typeNameBegin == null ) + typeNameBegin = LA(1); + typeNameEnd = LA(1); + callbackSimpleDeclToken(decl, flags); + break; case IToken.t_unsigned : + sdw.setUnsigned( true ); + if( typeNameBegin == null ) + typeNameBegin = LA(1); + typeNameEnd = LA(1); + callbackSimpleDeclToken(decl, flags); + break; case IToken.t_short : + sdw.setShort( true ); + if( typeNameBegin == null ) + typeNameBegin = LA(1); + typeNameEnd = LA(1); + callbackSimpleDeclToken(decl, flags); + break; + case IToken.t_long : + if( typeNameBegin == null ) + typeNameBegin = LA(1); + typeNameEnd = LA(1); + + callbackSimpleDeclToken(decl, flags); + sdw.setLong( true ); + break; + case IToken.t_char : + if( typeNameBegin == null ) + typeNameBegin = LA(1); + typeNameEnd = LA(1); + + callbackSimpleDeclToken(decl, flags); + sdw.setSimpleType( IASTSimpleTypeSpecifier.SimpleType.CHAR ); + break; case IToken.t_wchar_t : + if( typeNameBegin == null ) + typeNameBegin = LA(1); + typeNameEnd = LA(1); + + callbackSimpleDeclToken(decl, flags); + sdw.setSimpleType( IASTSimpleTypeSpecifier.SimpleType.WCHAR_T); + break; + case IToken.t_bool : + if( typeNameBegin == null ) + typeNameBegin = LA(1); + typeNameEnd = LA(1); + + callbackSimpleDeclToken(decl, flags); + sdw.setSimpleType( IASTSimpleTypeSpecifier.SimpleType.BOOL); + break; + case IToken.t_int : - case IToken.t_long : + if( typeNameBegin == null ) + typeNameBegin = LA(1); + typeNameEnd = LA(1); + + callbackSimpleDeclToken(decl, flags); + sdw.setSimpleType( IASTSimpleTypeSpecifier.SimpleType.INT); + break; + case IToken.t_float : + if( typeNameBegin == null ) + typeNameBegin = LA(1); + typeNameEnd = LA(1); + + callbackSimpleDeclToken(decl, flags); + sdw.setSimpleType( IASTSimpleTypeSpecifier.SimpleType.FLOAT); + break; + case IToken.t_double : + if( typeNameBegin == null ) + typeNameBegin = LA(1); + typeNameEnd = LA(1); + + callbackSimpleDeclToken(decl, flags); + sdw.setSimpleType( IASTSimpleTypeSpecifier.SimpleType.DOUBLE ); + break; + case IToken.t_void : - sdw.setType(LT(1)); - flags.setEncounteredRawType(true); - try - { - callback.simpleDeclSpecifier(decl, consume()); - } - catch (Exception e) - { - } - break; + if( typeNameBegin == null ) + typeNameBegin = LA(1); + typeNameEnd = LA(1); + + callbackSimpleDeclToken(decl, flags); + sdw.setSimpleType( IASTSimpleTypeSpecifier.SimpleType.VOID ); + break; + case IToken.t_typename : sdw.setTypenamed(true); try @@ -1567,7 +1662,7 @@ public class Parser implements IParser } } ITokenDuple duple = new TokenDuple(first, last); - sdw.setTypeName(duple.toString()); + sdw.setTypeName(duple); try { callback.simpleDeclSpecifierName(decl); @@ -1583,13 +1678,29 @@ public class Parser implements IParser // TODO - Kludgy way to handle constructors/destructors // handle nested later: if (flags.haveEncounteredRawType()) + { + if( typeNameBegin != null ) + sdw.setTypeName( new TokenDuple( typeNameBegin, typeNameEnd )); return; + } if (parm && flags.haveEncounteredTypename()) - return; + { + if( typeNameBegin != null ) + sdw.setTypeName( new TokenDuple( typeNameBegin, typeNameEnd )); + return; + } if (lookAheadForConstructorOrConversion(flags)) - return; + { + if( typeNameBegin != null ) + sdw.setTypeName( new TokenDuple( typeNameBegin, typeNameEnd )); + return; + } if (lookAheadForDeclarator(flags)) - return; + { + if( typeNameBegin != null ) + sdw.setTypeName( new TokenDuple( typeNameBegin, typeNameEnd )); + return; + } try { callback.simpleDeclSpecifier(decl, LA(1)); @@ -1598,7 +1709,7 @@ public class Parser implements IParser { } ITokenDuple d = name(); - sdw.setTypeName(d.toString()); + sdw.setTypeName(d); try { callback.simpleDeclSpecifierName(decl); @@ -1657,6 +1768,9 @@ public class Parser implements IParser break declSpecifiers; } } + if( typeNameBegin != null ) + sdw.setTypeName( new TokenDuple( typeNameBegin, typeNameEnd )); + } /** * Parse an elaborated type specifier. @@ -1882,7 +1996,7 @@ public class Parser implements IParser * @return Returns the same object sent in. * @throws Backtrack */ - protected Object cvQualifier(Object ptrOp, PointerOperator po) throws Backtrack + protected Object cvQualifier(Object ptrOp, boolean hasName, Declarator declarator) throws Backtrack { switch (LT(1)) { @@ -1894,7 +2008,11 @@ public class Parser implements IParser catch (Exception e) { } - po.setConst(true); + + if( hasName ) + declarator.addPtrOp( ASTPointerOperator.CONST_POINTER_TO_FUNCTION ); + else + declarator.addPtrOp( ASTPointerOperator.CONST_POINTER ); return ptrOp; case IToken.t_volatile : @@ -1905,7 +2023,10 @@ public class Parser implements IParser catch (Exception e) { } - po.setVolatile( true ); + if( hasName ) + declarator.addPtrOp( ASTPointerOperator.VOLATILE_POINTER_TO_FUNCTION ); + else + declarator.addPtrOp( ASTPointerOperator.VOLATILE_POINTER ); return ptrOp; default : throw backtrack; @@ -2594,7 +2715,7 @@ public class Parser implements IParser catch (Exception e) { } - d.addPtrOp( new PointerOperator( PointerOperator.Type.REFERENCE ) ); + d.addPtrOp( ASTPointerOperator.REFERENCE ); return; } IToken mark = mark(); @@ -2609,9 +2730,9 @@ public class Parser implements IParser hasName = true; t = LT(1); } + if (t == IToken.tSTAR) { - PointerOperator po = null; if (hasName) { try @@ -2622,15 +2743,11 @@ public class Parser implements IParser catch (Exception e) { } - // just consume "*", so tokenType is left as "::" or Id - po = new PointerOperator( PointerOperator.Type.NAMED ); - po.setName( nameDuple.toString() ); consume(Token.tSTAR); } else { tokenType = consume(Token.tSTAR); // tokenType = "*" - po = new PointerOperator( PointerOperator.Type.POINTER ); } try @@ -2644,7 +2761,7 @@ public class Parser implements IParser { try { - ptrOp = cvQualifier(ptrOp, po); + ptrOp = cvQualifier(ptrOp, hasName, d); } catch (Backtrack b) { @@ -2659,7 +2776,6 @@ public class Parser implements IParser catch (Exception e) { } - d.addPtrOp(po); return; } backup(mark); @@ -2754,6 +2870,7 @@ public class Parser implements IParser } throw backtrack; } + IASTExpression initialValue = null; if (LT(1) == IToken.tASSIGN) { consume(IToken.tASSIGN); @@ -2765,7 +2882,7 @@ public class Parser implements IParser catch (Exception e) { } - constantExpression(expression); + initialValue = constantExpression(expression); try { callback.expressionEnd(expression); @@ -2773,6 +2890,7 @@ public class Parser implements IParser catch (Exception e) { } + } try { @@ -2783,7 +2901,7 @@ public class Parser implements IParser } if (LT(1) == IToken.tRBRACE) { - astFactory.addEnumerator( enumeration, enumeratorIdentifier.toString(), enumeratorIdentifier.getOffset(), enumeratorIdentifier.getEndOffset() ); + astFactory.addEnumerator( enumeration, enumeratorIdentifier.toString(), enumeratorIdentifier.getOffset(), enumeratorIdentifier.getEndOffset(), initialValue); break; } if (LT(1) != IToken.tCOMMA) @@ -2797,7 +2915,7 @@ public class Parser implements IParser } throw backtrack; } - astFactory.addEnumerator( enumeration, enumeratorIdentifier.toString(), enumeratorIdentifier.getOffset(), enumeratorIdentifier.getEndOffset() ); + astFactory.addEnumerator( enumeration, enumeratorIdentifier.toString(), enumeratorIdentifier.getOffset(), enumeratorIdentifier.getEndOffset(), initialValue ); consume(IToken.tCOMMA); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/PointerOperator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/PointerOperator.java deleted file mode 100644 index aaf5323079c..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/PointerOperator.java +++ /dev/null @@ -1,97 +0,0 @@ -/********************************************************************** - * 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; - -/** - * @author jcamelon - * - */ -public class PointerOperator -{ - private String name; - private boolean isConst = false; - private boolean isVolatile = false; - - public static class Type - { - private final int type; - public static final Type REFERENCE = new Type( 1 ); - public static final Type POINTER = new Type( 2 ); - public static final Type NAMED = new Type( 3 ); - - private Type( int type ) - { - this.type = type; - } - } - - private Type type; - - public PointerOperator( Type t ) - { - this.type = t; - } - /** - * @return - */ - public Type getType() - { - return type; - } - - /** - * @return - */ - public boolean isConst() - { - return isConst; - } - - /** - * @return - */ - public boolean isVolatile() - { - return isVolatile; - } - - /** - * @param b - */ - public void setConst(boolean b) - { - isConst = b; - } - - /** - * @param b - */ - public void setVolatile(boolean b) - { - isVolatile = b; - } - /** - * @param string - */ - public void setName(String string) - { - name = string; - } - - /** - * @return - */ - public String getName() - { - return name; - } - -} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Preprocessor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Preprocessor.java index 18dd83e0701..9d53970c7c6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Preprocessor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Preprocessor.java @@ -11,11 +11,11 @@ package org.eclipse.cdt.internal.core.parser; import java.io.Reader; -import java.util.Map; import org.eclipse.cdt.core.parser.EndOfFile; import org.eclipse.cdt.core.parser.IPreprocessor; import org.eclipse.cdt.core.parser.IProblemReporter; +import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.ITranslationResult; import org.eclipse.cdt.core.parser.ScannerException; @@ -31,8 +31,8 @@ public class Preprocessor extends Scanner implements IPreprocessor { * @param filename * @param defns */ - public Preprocessor(Reader reader, String filename, Map defns, IProblemReporter problemReporter, ITranslationResult unitResult) { - super(reader, filename, defns, problemReporter, unitResult); + public Preprocessor(Reader reader, String filename, IScannerInfo info, IProblemReporter problemReporter, ITranslationResult unitResult) { + super(reader, filename, info, problemReporter, unitResult); } public void process() diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java index 502359de0fc..373d0dcc437 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java @@ -21,7 +21,6 @@ import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.StringTokenizer; import java.util.Vector; @@ -32,6 +31,7 @@ import org.eclipse.cdt.core.parser.IParser; import org.eclipse.cdt.core.parser.IParserCallback; import org.eclipse.cdt.core.parser.IProblemReporter; import org.eclipse.cdt.core.parser.IScanner; +import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.ITranslationOptions; @@ -53,7 +53,7 @@ import org.eclipse.cdt.core.parser.ast.IASTMacro; public class Scanner implements IScanner { - public Scanner(Reader reader, String filename, Map defns, IProblemReporter problemReporter, ITranslationResult unitResult) { + public Scanner(Reader reader, String filename, IScannerInfo info, IProblemReporter problemReporter, ITranslationResult unitResult) { try { //this is a hack to get around a sudden EOF experience contextStack.push( @@ -69,10 +69,14 @@ public class Scanner implements IScanner { } catch( ScannerException se ) { //won't happen since we aren't adding an include or a macro } - if( defns != null ) - definitions.putAll( defns ); + + originalConfig = info; + if( info.getDefinedSymbols() != null ) + definitions.putAll( info.getDefinedSymbols() ); + + if( info.getIncludePaths() != null ) + overwriteIncludePath( info.getIncludePaths() ); - this.problemReporter = problemReporter; this.translationResult = unitResult; @@ -88,13 +92,15 @@ public class Scanner implements IScanner { includePaths.add( new File( includePath ) ); } - public void overwriteIncludePath(List newIncludePaths) { + public void overwriteIncludePath(String [] newIncludePaths) { if( newIncludePaths == null ) return; includePathNames = null; includePaths = null; includePathNames = new ArrayList(); - includePaths = new ArrayList(); - includePathNames.addAll(newIncludePaths); + includePaths = new ArrayList(); + + for( int i = 0; i < newIncludePaths.length; ++i ) + includePathNames.add( newIncludePaths[i] ); Iterator i = includePathNames.iterator(); while( i.hasNext() ) @@ -118,8 +124,8 @@ public class Scanner implements IScanner { return definitions.get(key); } - public final Object[] getIncludePaths() { - return includePathNames.toArray(); + public final String[] getIncludePaths() { + return (String[])includePathNames.toArray(); } protected boolean skipOverWhitespace() throws ScannerException { @@ -342,6 +348,7 @@ public class Scanner implements IScanner { private ContextStack contextStack = new ContextStack(); private IScannerContext lastContext = null; + private IScannerInfo originalConfig; private List includePathNames = new ArrayList(); private List includePaths = new ArrayList(); private Hashtable definitions = new Hashtable(); @@ -1658,8 +1665,8 @@ public class Scanner implements IScanner { ParserFactory.createScanner( new StringReader(expression + ";"), EXPRESSION, - definitions, - null, ParserMode.QUICK_PARSE ); + new ScannerInfo( definitions, originalConfig.getIncludePaths()), + ParserMode.QUICK_PARSE ); IParser parser = ParserFactory.createParser(trial, new NullSourceElementRequestor(), ParserMode.QUICK_PARSE ); try { @@ -1897,7 +1904,7 @@ public class Scanner implements IScanner { if( ! replacementString.equals( "" ) ) { - IScanner helperScanner = ParserFactory.createScanner( new StringReader(replacementString), null, null, null, mode, problemReporter, translationResult ); + IScanner helperScanner = ParserFactory.createScanner( new StringReader(replacementString), null, new ScannerInfo( ), mode, problemReporter, translationResult ); helperScanner.setTokenizingMacroReplacementList( true ); IToken t = helperScanner.nextToken(false); @@ -1995,7 +2002,7 @@ public class Scanner implements IScanner { protected Vector getMacroParameters (String params, boolean forStringizing) throws ScannerException { - IScanner tokenizer = ParserFactory.createScanner(new StringReader(params), TEXT, definitions, null, mode, problemReporter, translationResult ); + IScanner tokenizer = ParserFactory.createScanner(new StringReader(params), TEXT, new ScannerInfo( definitions, originalConfig.getIncludePaths() ), mode, problemReporter, translationResult ); Vector parameterValues = new Vector(); Token t = null; String str = new String(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ScannerInfo.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ScannerInfo.java new file mode 100644 index 00000000000..8b126f2824d --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ScannerInfo.java @@ -0,0 +1,50 @@ +/********************************************************************** + * Copyright (c) 2002,2003 Rational Software Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.internal.core.parser; + +import java.util.Map; + +import org.eclipse.cdt.core.parser.IScannerInfo; + +/** + * @author jcamelon + * + */ +public class ScannerInfo implements IScannerInfo +{ + private Map definedSymbols = null; + private String [] includePaths = null; + + public ScannerInfo() + { + } + + public ScannerInfo( Map d, String [] incs ) + { + definedSymbols = d; + includePaths = incs; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.IScannerInfo#getDefinedSymbols() + */ + public Map getDefinedSymbols() + { + return definedSymbols; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.IScannerInfo#getIncludePaths() + */ + public String[] getIncludePaths() + { + return includePaths; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTArrayModifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTArrayModifier.java index 39aa95eaa6d..0e78503dd8c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTArrayModifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTArrayModifier.java @@ -10,11 +10,13 @@ ***********************************************************************/ package org.eclipse.cdt.internal.core.parser.ast; +import org.eclipse.cdt.core.parser.ast.IASTExpression; + /** * @author jcamelon * */ public interface IASTArrayModifier { - + public IASTExpression getExpression(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java index 88342dcb963..fc7cb1fb22d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java @@ -19,6 +19,7 @@ import org.eclipse.cdt.core.parser.ITokenDuple; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.parser.ast.ASTClassKind; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; +import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit; import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer; @@ -27,14 +28,20 @@ import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier; import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification; import org.eclipse.cdt.core.parser.ast.IASTExpression; import org.eclipse.cdt.core.parser.ast.IASTFactory; +import org.eclipse.cdt.core.parser.ast.IASTField; +import org.eclipse.cdt.core.parser.ast.IASTFunction; import org.eclipse.cdt.core.parser.ast.IASTInitializerClause; import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification; +import org.eclipse.cdt.core.parser.ast.IASTMethod; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; +import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration; import org.eclipse.cdt.core.parser.ast.IASTUsingDirective; +import org.eclipse.cdt.core.parser.ast.IASTVariable; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType; import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor; import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind; @@ -199,7 +206,7 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory { /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTFactory#addEnumerator(org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier, java.lang.String, int, int) */ - public void addEnumerator(IASTEnumerationSpecifier enumeration, String string, int startingOffset, int endingOffset) + public void addEnumerator(IASTEnumerationSpecifier enumeration, String string, int startingOffset, int endingOffset, IASTExpression initialValue) { // TODO Auto-generated method stub @@ -266,5 +273,67 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory { return null; } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createFunction(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration) + */ + public IASTFunction createFunction(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplateDeclaration ownerTemplate) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createAbstractDeclaration(boolean, org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier, java.util.List, java.util.List) + */ + public IASTAbstractDeclaration createAbstractDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createMethod(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration, boolean, boolean, boolean, boolean, boolean, boolean, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility) + */ + public IASTMethod createMethod(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplateDeclaration ownerTemplate, boolean isConst, boolean isVolatile, boolean isConstructor, boolean isDestructor, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createVariable(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, boolean, org.eclipse.cdt.core.parser.ast.IASTInitializerClause, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, boolean, boolean, boolean, boolean) + */ + public IASTVariable createVariable(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createField(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, boolean, org.eclipse.cdt.core.parser.ast.IASTInitializerClause, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, boolean, boolean, boolean, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility) + */ + public IASTField createField(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, ASTAccessVisibility visibility) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createParameterDeclaration(boolean, org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier, java.util.List, java.util.List, java.lang.String, org.eclipse.cdt.core.parser.ast.IASTInitializerClause) + */ + public IASTParameterDeclaration createParameterDeclaration(boolean isConst, IASTTypeSpecifier getTypeSpecifier, List pointerOperators, List arrayModifiers, String parameterName, IASTInitializerClause initializerClause) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTemplateDeclaration(java.util.List) + */ + public IASTTemplateDeclaration createTemplateDeclaration(IASTScope scope, List templateParameters) + { + // TODO Auto-generated method stub + return null; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTAbstractDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTAbstractDeclaration.java new file mode 100644 index 00000000000..8dec57e7a5d --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTAbstractDeclaration.java @@ -0,0 +1,70 @@ +/********************************************************************** + * 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.ast.quick; + +import java.util.Iterator; +import java.util.List; + +import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier; + +/** + * @author jcamelon + * + */ +public class ASTAbstractDeclaration implements IASTAbstractDeclaration +{ + private final boolean isConst; + private final IASTTypeSpecifier typeSpecifier; + private final List pointerOperators; + private final List arrayModifiers; + /** + * @param isConst + * @param typeSpecifier + * @param pointerOperators + * @param arrayModifiers + */ + public ASTAbstractDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers) + { + this.isConst = isConst; + this.typeSpecifier = typeSpecifier; + this.pointerOperators = pointerOperators; + this.arrayModifiers = arrayModifiers; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#isConst() + */ + public boolean isConst() + { + return isConst; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getTypeSpecifier() + */ + public IASTTypeSpecifier getTypeSpecifier() + { + return typeSpecifier; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getPointerOperators() + */ + public Iterator getPointerOperators() + { + return pointerOperators.iterator(); + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getArrayModifiers() + */ + public Iterator getArrayModifiers() + { + return arrayModifiers.iterator(); + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTArrayModifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTArrayModifier.java new file mode 100644 index 00000000000..8058426a2df --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTArrayModifier.java @@ -0,0 +1,38 @@ +/********************************************************************** + * 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.ast.quick; + +import org.eclipse.cdt.core.parser.ast.IASTExpression; +import org.eclipse.cdt.internal.core.parser.ast.IASTArrayModifier; + +/** + * @author jcamelon + * + */ +public class ASTArrayModifier implements IASTArrayModifier +{ + private final IASTExpression expression; + /** + * @param exp + */ + public ASTArrayModifier(IASTExpression exp) + { + expression = exp; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.core.parser.ast.IASTArrayModifier#getExpression() + */ + public IASTExpression getExpression() + { + return expression; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTEnumerator.java index bbbd02290ed..486e19d1e33 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTEnumerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTEnumerator.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.parser.ast.quick; import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier; import org.eclipse.cdt.core.parser.ast.IASTEnumerator; +import org.eclipse.cdt.core.parser.ast.IASTExpression; import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement; import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets; @@ -22,7 +23,8 @@ import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets; public class ASTEnumerator implements IASTEnumerator, IASTOffsetableNamedElement { - private final String name; + private final IASTExpression initialValue; + private final String name; private final IASTEnumerationSpecifier enumeration; private final NamedOffsets offsets = new NamedOffsets(); /** @@ -31,7 +33,7 @@ public class ASTEnumerator * @param startingOffset * @param endingOffset */ - public ASTEnumerator(IASTEnumerationSpecifier enumeration, String string, int startingOffset, int endingOffset) + public ASTEnumerator(IASTEnumerationSpecifier enumeration, String string, int startingOffset, int endingOffset, IASTExpression initialValue) { this.enumeration = enumeration; name = string; @@ -39,6 +41,7 @@ public class ASTEnumerator offsets.setNameOffset( startingOffset ); offsets.setEndingOffset( endingOffset ); enumeration.addEnumerator(this); + this.initialValue = initialValue; } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getName() @@ -96,4 +99,11 @@ public class ASTEnumerator { return enumeration; } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTEnumerator#getInitialValue() + */ + public IASTExpression getInitialValue() + { + return initialValue; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExceptionSpecification.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExceptionSpecification.java index b623456a34b..7f80611a1d8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExceptionSpecification.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExceptionSpecification.java @@ -38,8 +38,8 @@ public class ASTExceptionSpecification implements IASTExceptionSpecification /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification#getTypeIds() */ - public List getTypeIds() + public Iterator getTypeIds() { - return typeIds; + return typeIds.iterator(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTField.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTField.java new file mode 100644 index 00000000000..dcfef3a1841 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTField.java @@ -0,0 +1,63 @@ +/********************************************************************** + * 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.ast.quick; + +import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; +import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTExpression; +import org.eclipse.cdt.core.parser.ast.IASTField; +import org.eclipse.cdt.core.parser.ast.IASTInitializerClause; +import org.eclipse.cdt.core.parser.ast.IASTScope; + +/** + * @author jcamelon + * + */ +public class ASTField extends ASTVariable implements IASTField +{ + private final ASTAccessVisibility visibility; + + /** + * @param scope + * @param name + * @param isAuto + * @param initializerClause + * @param bitfieldExpression + * @param abstractDeclaration + * @param isMutable + * @param isExtern + * @param isRegister + * @param isStatic + */ + public ASTField(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, ASTAccessVisibility visibility) + { + super( + scope, + name, + isAuto, + initializerClause, + bitfieldExpression, + abstractDeclaration, + isMutable, + isExtern, + isRegister, + isStatic); + this.visibility = visibility; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTMember#getVisiblity() + */ + public ASTAccessVisibility getVisiblity() + { + return visibility; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTFunction.java new file mode 100644 index 00000000000..1717f616fec --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTFunction.java @@ -0,0 +1,164 @@ +/********************************************************************** + * 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.ast.quick; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification; +import org.eclipse.cdt.core.parser.ast.IASTFunction; +import org.eclipse.cdt.core.parser.ast.IASTScope; +import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; +import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets; + +/** + * @author jcamelon + * + */ +public class ASTFunction extends ASTDeclaration implements IASTFunction +{ + /** + * @param scope + */ + public ASTFunction(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, + boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplateDeclaration ownerTemplate ) + { + super(scope); + this.name = name; + this.parms = parameters; + this.returnType = returnType; + this.exceptionSpec = exception; + this.isInline = isInline; + this.isFriend = isFriend; + this.isStatic = isStatic; + this.ownerTemplateDeclaration = ownerTemplate; + offsets.setStartingOffset( startOffset ); + offsets.setNameOffset( nameOffset ); + } + + private final IASTTemplateDeclaration ownerTemplateDeclaration; + private NamedOffsets offsets = new NamedOffsets(); + private List declarations = new ArrayList(); + private final IASTExceptionSpecification exceptionSpec; + private final String name; + private final List parms; + private final IASTAbstractDeclaration returnType; + private final boolean isInline, isFriend, isStatic; + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFunction#isInline() + */ + public boolean isInline() + { + return isInline; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFunction#isFriend() + */ + public boolean isFriend() + { + return isFriend; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFunction#isStatic() + */ + public boolean isStatic() + { + return isStatic; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getName() + */ + public String getName() + { + return name; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFunction#getReturnType() + */ + public IASTAbstractDeclaration getReturnType() + { + return returnType; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFunction#getParameters() + */ + public Iterator getParameters() + { + return parms.iterator(); + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFunction#getExceptionSpec() + */ + public IASTExceptionSpecification getExceptionSpec() + { + return exceptionSpec; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset() + */ + public int getElementNameOffset() + { + return offsets.getElementNameOffset(); + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int) + */ + public void setNameOffset(int o) + { + offsets.setNameOffset( o ); + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTTemplatedDeclaration#getOwnerTemplateDeclaration() + */ + public IASTTemplateDeclaration getOwnerTemplateDeclaration() + { + return ownerTemplateDeclaration; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int) + */ + public void setStartingOffset(int o) + { + offsets.setStartingOffset(o); + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int) + */ + public void setEndingOffset(int o) + { + offsets.setEndingOffset(o); + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset() + */ + public int getElementStartingOffset() + { + return offsets.getElementStartingOffset(); + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset() + */ + public int getElementEndingOffset() + { + return offsets.getElementEndingOffset(); + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations() + */ + public Iterator getDeclarations() + { + return declarations.iterator(); + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTInitializerClause.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTInitializerClause.java index f01fda1a816..8659d39926d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTInitializerClause.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTInitializerClause.java @@ -10,6 +10,7 @@ ***********************************************************************/ package org.eclipse.cdt.internal.core.parser.ast.quick; +import java.util.Iterator; import java.util.List; import org.eclipse.cdt.core.parser.ast.IASTExpression; @@ -44,8 +45,8 @@ public class ASTInitializerClause implements IASTInitializerClause { /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTInitializerClause#getInitializerList() */ - public List getInitializerList() { - return initializerClauses; + public Iterator getInitializers() { + return initializerClauses.iterator(); } /* (non-Javadoc) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTMethod.java new file mode 100644 index 00000000000..8a9e18399d0 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTMethod.java @@ -0,0 +1,147 @@ +/********************************************************************** + * 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.ast.quick; +import java.util.List; +import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; +import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification; +import org.eclipse.cdt.core.parser.ast.IASTMethod; +import org.eclipse.cdt.core.parser.ast.IASTScope; +import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; +/** + * @author jcamelon + * + */ +public class ASTMethod extends ASTFunction implements IASTMethod +{ + private final boolean isConst; + private final boolean isDestructor; + private final boolean isConstructor; + private final boolean isExplicit; + private final boolean isPureVirtual; + private final boolean isVirtual; + private final boolean isVolatile; + private final ASTAccessVisibility visibility; + /** + * @param scope + * @param name + * @param parameters + * @param returnType + * @param exception + * @param isInline + * @param isFriend + * @param isStatic + * @param startOffset + * @param nameOffset + * @param ownerTemplate + */ + public ASTMethod( + IASTScope scope, + String name, + List parameters, + IASTAbstractDeclaration returnType, + IASTExceptionSpecification exception, + boolean isInline, + boolean isFriend, + boolean isStatic, + int startOffset, + int nameOffset, + IASTTemplateDeclaration ownerTemplate, + boolean isConst, + boolean isVolatile, + boolean isConstructor, + boolean isDestructor, + boolean isVirtual, + boolean isExplicit, + boolean isPureVirtual, ASTAccessVisibility visibility) + { + super( + scope, + name, + parameters, + returnType, + exception, + isInline, + isFriend, + isStatic, + startOffset, + nameOffset, + ownerTemplate); + this.isVirtual = isVirtual; + this.isPureVirtual = isPureVirtual; + this.isConstructor = isConstructor; + this.isDestructor = isDestructor; + this.isExplicit = isExplicit; + this.isConst = isConst; + this.isVolatile = isVolatile; + this.visibility = visibility; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTMethod#isVirtual() + */ + public boolean isVirtual() + { + return isVirtual; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTMethod#isExplicit() + */ + public boolean isExplicit() + { + // TODO Auto-generated method stub + return isExplicit; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTMethod#isConstructor() + */ + public boolean isConstructor() + { + return isConstructor; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTMethod#isDestructor() + */ + public boolean isDestructor() + { + return isDestructor; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTMethod#isConst() + */ + public boolean isConst() + { + return isConst; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTMethod#isVolatile() + */ + public boolean isVolatile() + { + return isVolatile; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTMethod#isPureVirtual() + */ + public boolean isPureVirtual() + { + return isPureVirtual; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTMember#getVisiblity() + */ + public ASTAccessVisibility getVisiblity() + { + return visibility; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTMember#getOwnerClassSpecifier() + */ +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTParameterDeclaration.java new file mode 100644 index 00000000000..6b5ded9ce08 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTParameterDeclaration.java @@ -0,0 +1,91 @@ +/********************************************************************** + * 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.ast.quick; + +import java.util.Iterator; +import java.util.List; + +import org.eclipse.cdt.core.parser.ast.IASTInitializerClause; +import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier; + +/** + * @author jcamelon + * + */ +public class ASTParameterDeclaration implements IASTParameterDeclaration +{ + private final boolean isConst; + private final IASTTypeSpecifier typeSpecifier; + private final List pointerOperators; + private final List arrayModifiers; + private final String parameterName; + private final IASTInitializerClause initializerClause; + /** + * @param isConst + * @param typeSpecifier + * @param pointerOperators + * @param arrayModifiers + * @param parameterName + * @param initializerClause + */ + public ASTParameterDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, String parameterName, IASTInitializerClause initializerClause) + { + this.isConst = isConst; + this.typeSpecifier = typeSpecifier; + this.pointerOperators = pointerOperators; + this.arrayModifiers = arrayModifiers; + this.parameterName = parameterName; + this.initializerClause = initializerClause; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration#getName() + */ + public String getName() + { + return parameterName; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration#getDefaultValue() + */ + public IASTInitializerClause getDefaultValue() + { + return initializerClause; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#isConst() + */ + public boolean isConst() + { + return isConst; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getTypeSpecifier() + */ + public IASTTypeSpecifier getTypeSpecifier() + { + return typeSpecifier; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getPointerOperators() + */ + public Iterator getPointerOperators() + { + return pointerOperators.iterator(); + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getArrayModifiers() + */ + public Iterator getArrayModifiers() + { + return arrayModifiers.iterator(); + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTSimpleTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTSimpleTypeSpecifier.java index 423a6c5cc07..b73800fd273 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTSimpleTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTSimpleTypeSpecifier.java @@ -97,7 +97,7 @@ public class ASTSimpleTypeSpecifier implements IASTSimpleTypeSpecifier if (isSigned()) type.append("signed "); } - this.typeName = typeName.toString(); + this.typeName = type.toString(); } /* (non-Javadoc) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTTemplateDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTTemplateDeclaration.java new file mode 100644 index 00000000000..669812709e2 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTTemplateDeclaration.java @@ -0,0 +1,61 @@ +/********************************************************************** + * 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.ast.quick; + +import java.util.Iterator; +import java.util.List; + +import org.eclipse.cdt.core.parser.ast.ASTTemplateDeclarationType; +import org.eclipse.cdt.core.parser.ast.IASTDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTScope; +import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; + +/** + * @author jcamelon + * + */ +public class ASTTemplateDeclaration extends ASTDeclaration implements IASTTemplateDeclaration +{ + private IASTDeclaration ownedDeclaration; + private List templateParameters; + private ASTTemplateDeclarationType type; + /** + * @param templateParameters + */ + public ASTTemplateDeclaration(IASTScope scope, List templateParameters) + { + super( scope ); + this.templateParameters = templateParameters; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration#getTemplateDeclarationType() + */ + public ASTTemplateDeclarationType getTemplateDeclarationType() + { + return type; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration#getTemplateParameters() + */ + public Iterator getTemplateParameters() + { + // TODO Auto-generated method stub + return templateParameters.iterator(); + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration#getOwnedDeclaration() + */ + public IASTDeclaration getOwnedDeclaration() + { + // TODO Auto-generated method stub + return ownedDeclaration; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTVariable.java new file mode 100644 index 00000000000..5710ac5abed --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTVariable.java @@ -0,0 +1,124 @@ +/********************************************************************** + * 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.ast.quick; + +import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTExpression; +import org.eclipse.cdt.core.parser.ast.IASTInitializerClause; +import org.eclipse.cdt.core.parser.ast.IASTScope; +import org.eclipse.cdt.core.parser.ast.IASTVariable; + +/** + * @author jcamelon + * + */ +public class ASTVariable extends ASTDeclaration implements IASTVariable +{ + private final boolean isAuto; + private final IASTInitializerClause initializerClause; + private final IASTExpression bitfieldExpression; + private final IASTAbstractDeclaration abstractDeclaration; + private final boolean isMutable; + private final boolean isExtern; + private final boolean isRegister; + private final boolean isStatic; + private final String name; + /** + * @param scope + */ + public ASTVariable(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, + IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic ) + { + super(scope); + this.isAuto = isAuto; + this.initializerClause = initializerClause; + this.bitfieldExpression = bitfieldExpression; + this.abstractDeclaration = abstractDeclaration; + this.isMutable= isMutable; + this.isExtern = isExtern; + this.isRegister = isRegister; + this.isStatic = isStatic; + this.name = name; + + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTVariable#isAuto() + */ + public boolean isAuto() + { + return isAuto; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTVariable#isRegister() + */ + public boolean isRegister() + { + return isRegister; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTVariable#isStatic() + */ + public boolean isStatic() + { + return isStatic; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTVariable#isExtern() + */ + public boolean isExtern() + { + return isExtern; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTVariable#isMutable() + */ + public boolean isMutable() + { + return isMutable; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTVariable#getAbstractDeclaration() + */ + public IASTAbstractDeclaration getAbstractDeclaration() + { + return abstractDeclaration; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTVariable#getName() + */ + public String getName() + { + return name; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTVariable#getInitializerClause() + */ + public IASTInitializerClause getInitializerClause() + { + return initializerClause; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTVariable#isBitfield() + */ + public boolean isBitfield() + { + return ( bitfieldExpression != null ); + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTVariable#getBitfieldExpression() + */ + public IASTExpression getBitfieldExpression() + { + // TODO Auto-generated method stub + return bitfieldExpression; + } + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java index b14cdd56aa3..0836f27a0b9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.parser.ITokenDuple; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.parser.ast.ASTClassKind; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; +import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit; @@ -27,14 +28,20 @@ import org.eclipse.cdt.core.parser.ast.IASTEnumerator; import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification; import org.eclipse.cdt.core.parser.ast.IASTExpression; import org.eclipse.cdt.core.parser.ast.IASTFactory; +import org.eclipse.cdt.core.parser.ast.IASTField; +import org.eclipse.cdt.core.parser.ast.IASTFunction; import org.eclipse.cdt.core.parser.ast.IASTInitializerClause; import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification; +import org.eclipse.cdt.core.parser.ast.IASTMethod; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; +import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration; import org.eclipse.cdt.core.parser.ast.IASTUsingDirective; +import org.eclipse.cdt.core.parser.ast.IASTVariable; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType; import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor; import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind; @@ -133,9 +140,9 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTFactory#addEnumerator(org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier, java.lang.String, int, int) */ - public void addEnumerator(IASTEnumerationSpecifier enumeration, String string, int startingOffset, int endingOffset) + public void addEnumerator(IASTEnumerationSpecifier enumeration, String string, int startingOffset, int endingOffset, IASTExpression initialValue) { - IASTEnumerator enumerator = new ASTEnumerator( enumeration, string, startingOffset, endingOffset ); + IASTEnumerator enumerator = new ASTEnumerator( enumeration, string, startingOffset, endingOffset, initialValue ); } /* (non-Javadoc) @@ -172,8 +179,7 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory */ public IASTArrayModifier createArrayModifier(IASTExpression exp) { - // TODO Auto-generated method stub - return null; + return new ASTArrayModifier( exp ); } /* (non-Javadoc) @@ -192,4 +198,59 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory return new ASTSimpleTypeSpecifier( kind, typeName, isShort, isLong, isSigned, isUnsigned, isTypename ); } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createFunction(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration) + */ + public IASTFunction createFunction(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplateDeclaration ownerTemplate) + { + return new ASTFunction(scope, name, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createAbstractDeclaration(boolean, org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier, java.util.List, java.util.List) + */ + public IASTAbstractDeclaration createAbstractDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers) + { + return new ASTAbstractDeclaration( isConst, typeSpecifier, pointerOperators, arrayModifiers ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createMethod(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration, boolean, boolean, boolean, boolean, boolean, boolean, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility) + */ + public IASTMethod createMethod(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplateDeclaration ownerTemplate, boolean isConst, boolean isVolatile, boolean isConstructor, boolean isDestructor, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility) + { + return new ASTMethod(scope, name, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate, isConst, isVolatile, isConstructor, isDestructor, isVirtual, isExplicit, isPureVirtual, visibility); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createVariable(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, boolean, org.eclipse.cdt.core.parser.ast.IASTInitializerClause, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, boolean, boolean, boolean, boolean) + */ + public IASTVariable createVariable(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic) + { + return new ASTVariable(scope, name, isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern, isRegister, isStatic); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createField(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, boolean, org.eclipse.cdt.core.parser.ast.IASTInitializerClause, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, boolean, boolean, boolean, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility) + */ + public IASTField createField(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, ASTAccessVisibility visibility) + { + return new ASTField(scope, name, isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern, isRegister, isStatic, visibility); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createParameterDeclaration(boolean, org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier, java.util.List, java.util.List, java.lang.String, org.eclipse.cdt.core.parser.ast.IASTInitializerClause) + */ + public IASTParameterDeclaration createParameterDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, String parameterName, IASTInitializerClause initializerClause) + { + return new ASTParameterDeclaration( isConst, typeSpecifier, pointerOperators, arrayModifiers, parameterName, initializerClause ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTemplateDeclaration(java.util.List) + */ + public IASTTemplateDeclaration createTemplateDeclaration(IASTScope scope, List templateParameters) + { + return new ASTTemplateDeclaration( scope, templateParameters ); + } } diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java index 0a246787be8..b456b0e3d6d 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java @@ -25,6 +25,7 @@ import org.eclipse.cdt.core.parser.ScannerException; import org.eclipse.cdt.core.parser.ast.ASTClassKind; import org.eclipse.cdt.core.search.ICSearchConstants; import org.eclipse.cdt.core.search.ICSearchPattern; +import org.eclipse.cdt.internal.core.parser.ScannerInfo; import org.eclipse.cdt.internal.core.search.CharOperation; /** @@ -122,7 +123,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte * @return */ private static CSearchPattern createClassPattern(String patternString, SearchFor searchFor, LimitTo limitTo, int matchMode, boolean caseSensitive) { - IScanner scanner = ParserFactory.createScanner( new StringReader( patternString ), "TEXT", null, null, ParserMode.QUICK_PARSE ); + IScanner scanner = ParserFactory.createScanner( new StringReader( patternString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE ); LinkedList list = new LinkedList(); IToken token = null; diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java index 335941df525..679c73027c1 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java @@ -27,11 +27,33 @@ import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ParserMode; -import org.eclipse.cdt.core.parser.ast.*; +import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; +import org.eclipse.cdt.core.parser.ast.IASTClassReference; +import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; +import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit; +import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier; +import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier; +import org.eclipse.cdt.core.parser.ast.IASTEnumerator; +import org.eclipse.cdt.core.parser.ast.IASTField; +import org.eclipse.cdt.core.parser.ast.IASTFunction; +import org.eclipse.cdt.core.parser.ast.IASTInclusion; +import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification; +import org.eclipse.cdt.core.parser.ast.IASTMacro; +import org.eclipse.cdt.core.parser.ast.IASTMethod; +import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; +import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement; +import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation; +import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization; +import org.eclipse.cdt.core.parser.ast.IASTTypedef; +import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTUsingDirective; +import org.eclipse.cdt.core.parser.ast.IASTVariable; import org.eclipse.cdt.core.search.ICSearchPattern; import org.eclipse.cdt.core.search.ICSearchResultCollector; import org.eclipse.cdt.core.search.ICSearchScope; import org.eclipse.cdt.internal.core.model.IWorkingCopy; +import org.eclipse.cdt.internal.core.parser.ScannerInfo; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; @@ -73,7 +95,7 @@ public class MatchLocator implements ISourceElementRequestor { public void acceptTypedef(IASTTypedef typedef) { } public void acceptEnumerator(IASTEnumerator enumerator) { } public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration){ } - public void acceptClassReference(IASTClassSpecifier classSpecifier, int referenceOffset) { } + public void acceptClassReference(IASTClassReference reference) { } public void acceptElaboratedTypeSpecifier(IASTElaboratedTypeSpecifier elaboratedTypeSpec){ } public void acceptMethodDeclaration(IASTMethod method) { } public void acceptField(IASTField field) { } @@ -212,7 +234,7 @@ public class MatchLocator implements ISourceElementRequestor { } } - IScanner scanner = ParserFactory.createScanner( reader, pathString, null, null, ParserMode.QUICK_PARSE ); + IScanner scanner = ParserFactory.createScanner( reader, pathString, new ScannerInfo(), ParserMode.QUICK_PARSE ); IParser parser = ParserFactory.createParser( scanner, null, ParserMode.QUICK_PARSE ); parser.setRequestor( this ); diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index af9f445df1f..ed0095a2d63 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,6 @@ +2003-07-08 John Camelon + Updated IScanner, clients & implementations to use IScannerInfo. + 2003-07-03 Sean Evoy Changed property/wizard tab to use the new StandardBuildManager and the improved IStandardBuildInfo interface to set and retrieve diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/ComparatorModelBuilder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/ComparatorModelBuilder.java index 343997da4f8..77de384b06e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/ComparatorModelBuilder.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/ComparatorModelBuilder.java @@ -35,6 +35,7 @@ import org.eclipse.cdt.internal.core.dom.TemplateDeclaration; import org.eclipse.cdt.internal.core.dom.TranslationUnit; import org.eclipse.cdt.internal.core.dom.TypeSpecifier; import org.eclipse.cdt.internal.core.parser.Name; +import org.eclipse.cdt.internal.core.parser.ScannerInfo; import org.eclipse.cdt.internal.parser.IStructurizerCallback; /** @@ -57,7 +58,7 @@ public class ComparatorModelBuilder { public void parse() { DOMBuilder domBuilder = new DOMBuilder(); try { - IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, null, null, ParserMode.QUICK_PARSE ), domBuilder, ParserMode.QUICK_PARSE); + IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), ParserMode.QUICK_PARSE ), domBuilder, ParserMode.QUICK_PARSE); parser.parse(); } catch (Exception e) { callback.reportError(e);