diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java index e422474df69..50acfbe3b29 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -42,6 +42,16 @@ import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.c.CASTVisitor; import org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression; import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; +import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.ISourceCodeParser; +import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration; import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.IParserLogService; import org.eclipse.cdt.core.parser.IScanner; @@ -52,23 +62,13 @@ import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; -import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser; -import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; -import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration; import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner; import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory; -import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration; /** * @author aniefer diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseBaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseBaseTest.java index fe2324790d6..1dab1ee80a7 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseBaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseBaseTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,16 @@ import org.eclipse.cdt.core.dom.CDOM; import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.ISourceCodeParser; +import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration; import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.IParserLogService; import org.eclipse.cdt.core.parser.IScanner; @@ -22,23 +32,13 @@ import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.core.parser.tests.FileBasePluginTest; -import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser; -import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; -import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration; import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner; import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory; -import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration; import org.eclipse.core.resources.IFile; /** diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java index 5e927f215f1..c0de688eae0 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,6 +19,16 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.c.CASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; +import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.ISourceCodeParser; +import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration; import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.IParserLogService; import org.eclipse.cdt.core.parser.IScanner; @@ -26,23 +36,13 @@ import org.eclipse.cdt.core.parser.NullLogService; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerInfo; -import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser; -import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; -import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration; import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner; import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory; -import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration; import junit.framework.TestCase; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java index 313c1cd83fa..8f0708bc786 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java @@ -63,6 +63,16 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; +import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.ISourceCodeParser; +import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration; import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.NullLogService; @@ -70,23 +80,13 @@ import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; -import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser; -import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; -import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration; import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner; import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory; -import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration; import org.eclipse.core.runtime.Platform; /** diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java index b1edc751aa0..5505c1173f0 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,6 +18,16 @@ import junit.framework.TestCase; import org.eclipse.cdt.core.dom.ast.IASTProblem; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.ISourceCodeParser; +import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration; import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.IScannerInfo; @@ -25,23 +35,13 @@ import org.eclipse.cdt.core.parser.NullLogService; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerInfo; -import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser; -import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; -import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration; import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner; import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory; -import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration; /** * @author jcamelon diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java index f9837163669..82243bc5174 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2004, 2005 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,6 +17,16 @@ import junit.framework.TestCase; import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.ISourceCodeParser; +import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration; import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.IParserLogService; import org.eclipse.cdt.core.parser.IScanner; @@ -24,21 +34,11 @@ import org.eclipse.cdt.core.parser.NullLogService; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerInfo; -import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser; -import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration; -import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration; import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration; import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner; import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory; -import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration; public class CompletionTestBase extends TestCase { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/BaseScanner2Test.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/BaseScanner2Test.java index f0c8018d6ed..2624be9a0b2 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/BaseScanner2Test.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/BaseScanner2Test.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2006 IBM Corporation and others. + * Copyright (c) 2001, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,6 +17,9 @@ import java.util.List; import junit.framework.ComparisonFailure; import junit.framework.TestCase; +import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration; import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.EndOfFileException; import org.eclipse.cdt.core.parser.IParserLogService; @@ -31,9 +34,6 @@ import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.core.parser.util.CharArrayUtils; -import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration; import org.eclipse.cdt.internal.core.parser.scanner2.ObjectStyleMacro; import org.eclipse.cdt.internal.core.parser.scanner2.Scanner2; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/SpeedTest2.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/SpeedTest2.java index 037622b2977..42298d74e54 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/SpeedTest2.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/SpeedTest2.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,6 +17,9 @@ import java.util.Map; import junit.framework.TestCase; +import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration; import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.IParser; import org.eclipse.cdt.core.parser.IParserLogService; @@ -29,9 +32,6 @@ import org.eclipse.cdt.core.parser.ParserFactoryError; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerInfo; -import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration; import org.eclipse.cdt.internal.core.parser.scanner2.Scanner2; // A test that just calculates the speed of the parser diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF index 04a7b1ced98..09200e0bbf6 100644 --- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF @@ -16,6 +16,9 @@ Export-Package: org.eclipse.cdt.core, org.eclipse.cdt.core.dom.ast.gnu, org.eclipse.cdt.core.dom.ast.gnu.c, org.eclipse.cdt.core.dom.ast.gnu.cpp, + org.eclipse.cdt.core.dom.parser, + org.eclipse.cdt.core.dom.parser.c, + org.eclipse.cdt.core.dom.parser.cpp, org.eclipse.cdt.core.envvar, org.eclipse.cdt.core.formatter, org.eclipse.cdt.core.index, diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBuiltinSymbolProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBuiltinSymbolProvider.java index 381f6b73207..6708e0a727b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBuiltinSymbolProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBuiltinSymbolProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM - Initial API and implementation + * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -15,6 +16,8 @@ package org.eclipse.cdt.core.dom.ast; * provided by a Built-in Symbol Provider that implements this interface. * * @author dsteffle + * + * @deprecated Use {@link org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider} instead */ public interface IASTBuiltinSymbolProvider { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java index 0c21d886669..f13b39355e4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java @@ -9,50 +9,27 @@ * QNX - Initial API and implementation * Markus Schorn (Wind River Systems) * IBM Corporation + * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.gnu.c; -import java.util.ArrayList; -import java.util.List; - import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.dom.ICodeReaderFactory; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; -import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.ast.c.CASTVisitor; import org.eclipse.cdt.core.dom.ast.gnu.Messages; -import org.eclipse.cdt.core.index.IIndex; -import org.eclipse.cdt.core.model.AbstractLanguage; -import org.eclipse.cdt.core.model.IContributedModelBuilder; -import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.core.parser.CodeReader; -import org.eclipse.cdt.core.parser.DefaultLogService; -import org.eclipse.cdt.core.parser.IParserLogService; -import org.eclipse.cdt.core.parser.IScanner; -import org.eclipse.cdt.core.parser.IScannerInfo; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.ParserMode; -import org.eclipse.cdt.core.parser.ParserUtil; -import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser; -import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration; -import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; -import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner; -import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory; -import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkageFactory; -import org.eclipse.core.runtime.CoreException; +import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.AbstractCLanguage; +import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration; /** * @author Doug Schaefer * */ -public class GCCLanguage extends AbstractLanguage { +public class GCCLanguage extends AbstractCLanguage { protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration(); + protected static final GCCParserExtensionConfiguration C_GNU_PARSER_EXTENSION = new GCCParserExtensionConfiguration(); // Must match the id in the extension public static final String ID = CCorePlugin.PLUGIN_ID + ".gcc"; //$NON-NLS-1$ @@ -67,83 +44,21 @@ public class GCCLanguage extends AbstractLanguage { } public String getName() { - return new String(Messages.getString("GCCLanguage.name")); //$NON-NLS-1$ - } - - public Object getAdapter(Class adapter) { - if (adapter == IPDOMLinkageFactory.class) - return new PDOMCLinkageFactory(); - else - return super.getAdapter(adapter); - } - - public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, - IScannerInfo scanInfo, ICodeReaderFactory codeReaderFactory, IIndex index, IParserLogService log) throws CoreException { - IScannerExtensionConfiguration scannerExtensionConfiguration= C_GNU_SCANNER_EXTENSION; - IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, - ParserLanguage.C, new DefaultLogService(), scannerExtensionConfiguration, codeReaderFactory); - //assume GCC - ISourceCodeParser parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, log, - new GCCParserExtensionConfiguration(), index); - - // Parse - IASTTranslationUnit ast = parser.parse(); - return ast; - } - - public ASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException { - IScannerExtensionConfiguration scannerExtensionConfiguration - = C_GNU_SCANNER_EXTENSION; - IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, - ParserLanguage.C, new DefaultLogService(), scannerExtensionConfiguration, fileCreator ); - scanner.setContentAssistMode(offset); - - ISourceCodeParser parser = new GNUCSourceParser( - scanner, - ParserMode.COMPLETION_PARSE, - ParserUtil.getParserLogService(), - new GCCParserExtensionConfiguration(), - index); - - // Run the parse and return the completion node - parser.parse(); - ASTCompletionNode node = parser.getCompletionNode(); - if (node != null) { - node.count = scanner.getCount(); - } - return node; + return Messages.getString("GCCLanguage.name"); //$NON-NLS-1$ } - private static class NameCollector extends CASTVisitor { - { - shouldVisitNames = true; - } - private List nameList = new ArrayList(); - public int visit( IASTName name ){ - nameList.add( name ); - return PROCESS_CONTINUE; - } - public IASTName[] getNames() { - return (IASTName[])nameList.toArray(new IASTName[nameList.size()]); - } + /* + * @see org.eclipse.cdt.core.parser.AbstractCLanguage#getParserExtensionConfiguration() + */ + protected ICParserExtensionConfiguration getParserExtensionConfiguration() { + return C_GNU_PARSER_EXTENSION; + } + + /* + * @see org.eclipse.cdt.core.parser.AbstractCLanguage#getScannerExtensionConfiguration() + */ + protected IScannerExtensionConfiguration getScannerExtensionConfiguration() { + return C_GNU_SCANNER_EXTENSION; } - public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) { - IASTNode selectedNode = ast.selectNodeForLocation(ast.getFilePath(), start, length); - - if (selectedNode == null) - return new IASTName[0]; - - if (selectedNode instanceof IASTName) - return new IASTName[] { (IASTName)selectedNode }; - - NameCollector collector = new NameCollector(); - selectedNode.accept(collector); - return collector.getNames(); - } - - public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) { - // Use the default CDT model builder - return null; - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java index 9eae2d58025..5f9eeeae0e2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java @@ -9,50 +9,26 @@ * QNX - Initial API and implementation * Markus Schorn (Wind River Systems) * IBM Corporation + * Anton Leherbauer (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.core.dom.ast.gnu.cpp; -import java.util.ArrayList; -import java.util.List; - import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.dom.ICodeReaderFactory; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; -import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.dom.ast.gnu.Messages; -import org.eclipse.cdt.core.index.IIndex; -import org.eclipse.cdt.core.model.AbstractLanguage; -import org.eclipse.cdt.core.model.IContributedModelBuilder; -import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.core.parser.CodeReader; -import org.eclipse.cdt.core.parser.DefaultLogService; -import org.eclipse.cdt.core.parser.IParserLogService; -import org.eclipse.cdt.core.parser.IScanner; -import org.eclipse.cdt.core.parser.IScannerInfo; -import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.core.parser.ParserMode; -import org.eclipse.cdt.core.parser.ParserUtil; -import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser; -import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner; -import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration; -import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory; -import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory; -import org.eclipse.core.runtime.CoreException; +import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPLanguage; +import org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration; /** * @author Doug Schaefer * */ -public class GPPLanguage extends AbstractLanguage { +public class GPPLanguage extends AbstractCPPLanguage { protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION = new GPPScannerExtensionConfiguration(); + protected static final GPPParserExtensionConfiguration CPP_GNU_PARSER_EXTENSION = new GPPParserExtensionConfiguration(); public static final String ID = CCorePlugin.PLUGIN_ID + ".g++"; //$NON-NLS-1$ private static final GPPLanguage myDefault = new GPPLanguage(); @@ -66,84 +42,21 @@ public class GPPLanguage extends AbstractLanguage { } public String getName() { - return new String(Messages.getString("GPPLanguage.name")); //$NON-NLS-1$ - } - - public Object getAdapter(Class adapter) { - if (adapter == IPDOMLinkageFactory.class) - return new PDOMCPPLinkageFactory(); - else - return super.getAdapter(adapter); - } - - - public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo, - ICodeReaderFactory codeReaderFactory, IIndex index, IParserLogService log) throws CoreException { - IScannerExtensionConfiguration scannerExtensionConfiguration= CPP_GNU_SCANNER_EXTENSION; - IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, - ParserLanguage.CPP, new DefaultLogService(), scannerExtensionConfiguration, codeReaderFactory); - //assume GCC - ISourceCodeParser parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, log, - new GPPParserExtensionConfiguration(), index ); - - // Parse - IASTTranslationUnit ast= parser.parse(); - return ast; + return Messages.getString("GPPLanguage.name"); //$NON-NLS-1$ } - public ASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException { - IScannerExtensionConfiguration scannerExtensionConfiguration - = CPP_GNU_SCANNER_EXTENSION; - IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, - ParserLanguage.CPP, new DefaultLogService(), scannerExtensionConfiguration, fileCreator ); - scanner.setContentAssistMode(offset); - - ISourceCodeParser parser = new GNUCPPSourceParser( - scanner, - ParserMode.COMPLETION_PARSE, - ParserUtil.getParserLogService(), - new GPPParserExtensionConfiguration(), - index); - - // Run the parse and return the completion node - parser.parse(); - ASTCompletionNode node = parser.getCompletionNode(); - if (node != null) { - node.count = scanner.getCount(); - } - return node; + /* + * @see org.eclipse.cdt.core.dom.ast.gnu.cpp.AbstractCPPLanguage#getScannerExtensionConfiguration() + */ + protected IScannerExtensionConfiguration getScannerExtensionConfiguration() { + return CPP_GNU_SCANNER_EXTENSION; } - - private static class NameCollector extends CPPASTVisitor { - { - shouldVisitNames = true; - } - private List nameList = new ArrayList(); - public int visit( IASTName name ){ - nameList.add( name ); - return PROCESS_CONTINUE; - } - public IASTName[] getNames() { - return (IASTName[])nameList.toArray(new IASTName[nameList.size()]); - } - } - - public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) { - IASTNode selectedNode = ast.selectNodeForLocation(ast.getFilePath(), start, length); - - if (selectedNode == null) - return new IASTName[0]; - - if (selectedNode instanceof IASTName) - return new IASTName[] { (IASTName)selectedNode }; - - NameCollector collector = new NameCollector(); - selectedNode.accept(collector); - return collector.getNames(); - } - - public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) { - // Use the default CDT model builder - return null; + + /* + * @see org.eclipse.cdt.core.dom.ast.gnu.cpp.AbstractCPPLanguage#getParserExtensionConfiguration() + */ + protected AbstractCPPParserExtensionConfiguration getParserExtensionConfiguration() { + return CPP_GNU_PARSER_EXTENSION; } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractScannerExtensionConfiguration.java new file mode 100644 index 00000000000..6041949acc7 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractScannerExtensionConfiguration.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * Copyright (c) 2007 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Anton Leherbauer (Wind River Systems) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.dom.parser; + +import org.eclipse.cdt.core.parser.util.CharArrayIntMap; +import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; +import org.eclipse.cdt.internal.core.parser.scanner2.FunctionStyleMacro; +import org.eclipse.cdt.internal.core.parser.scanner2.ObjectStyleMacro; + +/** + * Abstract scanner extension configuration to help model C/C++ dialects. + * + *
+ * EXPERIMENTAL. This class or interface has been added as + * part of a work in progress. There is no guarantee that this API will work or + * that it will remain the same. Please do not use this API without consulting + * with the CDT team. + *
+ * + * @since 4.0 + */ +public abstract class AbstractScannerExtensionConfiguration implements IScannerExtensionConfiguration { + + /* + * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#getAdditionalKeywords() + */ + public CharArrayIntMap getAdditionalKeywords() { + return null; + } + + /* + * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#getAdditionalMacros() + */ + public CharArrayObjectMap getAdditionalMacros() { + return null; + } + + /* + * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#getAdditionalPreprocessorKeywords() + */ + public CharArrayIntMap getAdditionalPreprocessorKeywords() { + return null; + } + + /* + * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#initializeMacroValuesTo1() + */ + public boolean initializeMacroValuesTo1() { + return false; + } + + /* + * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#support$InIdentifiers() + */ + public boolean support$InIdentifiers() { + return false; + } + + /* + * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#supportAdditionalNumericLiteralSuffixes() + */ + public char[] supportAdditionalNumericLiteralSuffixes() { + return null; + } + + /* + * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#supportMinAndMaxOperators() + */ + public boolean supportMinAndMaxOperators() { + return false; + } + + /** + * Helper method to add an object style macro to the given map. + * + * @param macros the macro map + * @param name the macro name + * @param value the macro value + */ + protected void addObjectStyleMacro(CharArrayObjectMap macros, String name, String value) { + char[] nameChars= name.toCharArray(); + macros.put(nameChars, new ObjectStyleMacro(nameChars, value.toCharArray())); + } + + /** + * Helper method to add a function style macro to the given map. + * + * @param macros the macro map + * @param name the macro name + * @param value the macro value + * @param arguments the macro arguments + */ + protected void addFunctionStyleMacro(CharArrayObjectMap macros, String name, String value, String[] arguments) { + char[] nameChars= name.toCharArray(); + char[][] argumentsArray= new char[arguments.length][]; + for (int i = 0; i < arguments.length; i++) { + argumentsArray[i]= arguments[i].toCharArray(); + } + macros.put(nameChars, new FunctionStyleMacro(nameChars, value.toCharArray(), argumentsArray)); + } + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/GNUScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java similarity index 76% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/GNUScannerExtensionConfiguration.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java index f0169566922..6d20f3d4af4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/GNUScannerExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,15 +7,21 @@ * * Contributors: * IBM - Initial API and implementation + * Anton Leherbauer (Wind River Systems) *******************************************************************************/ -package org.eclipse.cdt.internal.core.parser.scanner2; +package org.eclipse.cdt.core.dom.parser; +import org.eclipse.cdt.core.parser.IPreprocessorDirective; +import org.eclipse.cdt.core.parser.Keywords; +import org.eclipse.cdt.core.parser.util.CharArrayIntMap; import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; +import org.eclipse.cdt.internal.core.parser.scanner2.FunctionStyleMacro; +import org.eclipse.cdt.internal.core.parser.scanner2.ObjectStyleMacro; /** * @author jcamelon */ -public abstract class GNUScannerExtensionConfiguration implements IScannerExtensionConfiguration { +public abstract class GNUScannerExtensionConfiguration extends AbstractScannerExtensionConfiguration { protected static final char[] emptyCharArray = "".toCharArray(); //$NON-NLS-1$ @@ -105,4 +111,18 @@ public abstract class GNUScannerExtensionConfiguration implements IScannerExtens return realDefinitions; } + /* + * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#getAdditionalPreprocessorKeywords() + */ + public CharArrayIntMap getAdditionalPreprocessorKeywords() { + CharArrayIntMap additionalPPKeywords= new CharArrayIntMap(8, IPreprocessorDirective.ppInvalid); + additionalPPKeywords.put(Keywords.cINCLUDE_NEXT, IPreprocessorDirective.ppInclude_next); + additionalPPKeywords.put(Keywords.cIMPORT, IPreprocessorDirective.ppImport); + additionalPPKeywords.put(Keywords.cWARNING, IPreprocessorDirective.ppWarning); + additionalPPKeywords.put(Keywords.cIDENT, IPreprocessorDirective.ppIgnore); + additionalPPKeywords.put(Keywords.cSCCS, IPreprocessorDirective.ppIgnore); + additionalPPKeywords.put(Keywords.cASSERT, IPreprocessorDirective.ppIgnore); + additionalPPKeywords.put(Keywords.cUNASSERT, IPreprocessorDirective.ppIgnore); + return additionalPPKeywords; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/IBuiltinBindingsProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/IBuiltinBindingsProvider.java new file mode 100644 index 00000000000..f806e1676f5 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/IBuiltinBindingsProvider.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2007 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Anton Leherbauer (Wind River Systems) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.dom.parser; + +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IScope; + +/** + * Provides built-in symbols to the parser. + * + *+ * EXPERIMENTAL. This class or interface has been added as + * part of a work in progress. There is no guarantee that this API will work or + * that it will remain the same. Please do not use this API without consulting + * with the CDT team. + *
+ * + * @since 4.0 + */ +public interface IBuiltinBindingsProvider { + + /** + * Get additional built-in bindings for the given scope. + * + * @param scope the scope the bindings are added to + * @return an array of {@link IBinding}s, may not returnnull
+ */
+ public IBinding[] getBuiltinBindings(IScope scope);
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/IExtensionToken.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/IExtensionToken.java
new file mode 100644
index 00000000000..17601d55bb8
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/IExtensionToken.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.parser;
+
+import org.eclipse.cdt.core.parser.IToken;
+
+/**
+ * Token types for parser extensions.
+ * + * This interface is not intended to be implemented. + *
+ *+ * EXPERIMENTAL. This class or interface has been added as + * part of a work in progress. There is no guarantee that this API will work or + * that it will remain the same. Please do not use this API without consulting + * with the CDT team. + *
+ * + * @since 4.0 + */ +public interface IExtensionToken { + + int t__otherDeclSpecModifierFirst= IToken.tLAST + 100; + int t__otherDeclSpecModifierLast= IToken.tLAST + 110; + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/IScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/IScannerExtensionConfiguration.java similarity index 70% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/IScannerExtensionConfiguration.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/IScannerExtensionConfiguration.java index 2c399cc2754..2e319c7b593 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/IScannerExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/IScannerExtensionConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,8 +7,9 @@ * * Contributors: * IBM - Initial API and implementation + * Anton Leherbauer (Wind River Systems) *******************************************************************************/ -package org.eclipse.cdt.internal.core.parser.scanner2; +package org.eclipse.cdt.core.dom.parser; import org.eclipse.cdt.core.parser.util.CharArrayIntMap; import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; @@ -26,4 +27,12 @@ public interface IScannerExtensionConfiguration { public char [] supportAdditionalNumericLiteralSuffixes(); public CharArrayObjectMap getAdditionalMacros(); + + /** + * @return a mapping of preprocessor directive keyword to one of the constants defined in + * {@link org.eclipse.cdt.core.parser.IPreprocessorDirective IPreprocessorDirective}. + * + * @since 4.0 + */ + public CharArrayIntMap getAdditionalPreprocessorKeywords(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/ISourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/ISourceCodeParser.java new file mode 100644 index 00000000000..dc252f2e423 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/ISourceCodeParser.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2005, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.dom.parser; + +import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; + +/** + * Interface for an AST source code parser. + *+ * This interface is not intended to be implemented directly. + *
+ *+ * EXPERIMENTAL. This class or interface has been added as + * part of a work in progress. There is no guarantee that this API will work or + * that it will remain the same. Please do not use this API without consulting + * with the CDT team. + *
+ * + * @author jcamelon + */ +public interface ISourceCodeParser { + + /** + * Compute an abstract syntax tree (AST). + * @return the AST, should not returnnull
+ *
+ * @throws ParseError if parsing has been cancelled or for other reasons
+ */
+ public IASTTranslationUnit parse();
+
+ /**
+ * Cancel the parsing.
+ */
+ public void cancel();
+
+ /**
+ * Check whether there were errors.
+ * @return true
if there were errors
+ */
+ public boolean encounteredError();
+
+ /**
+ * Compute an {@link ASTCompletionNode} for code completion.
+ * @return a completion node or null
if none could be computed
+ *
+ * @throws ParseError if parsing has been cancelled or for other reasons
+ */
+ public ASTCompletionNode getCompletionNode();
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ISourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/ANSICParserExtensionConfiguration.java
similarity index 55%
rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ISourceCodeParser.java
rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/ANSICParserExtensionConfiguration.java
index a6c95e98f86..c32b4b31100 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ISourceCodeParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/ANSICParserExtensionConfiguration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
+ * Copyright (c) 2002, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,23 +7,15 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
+ * Ed Swartz (Nokia)
+ * Anton Leherbauer (Wind River Systems)
*******************************************************************************/
-package org.eclipse.cdt.internal.core.dom.parser;
+package org.eclipse.cdt.core.dom.parser.c;
-import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
/**
* @author jcamelon
*/
-public interface ISourceCodeParser {
-
- public void cancel();
-
- public IASTTranslationUnit parse();
-
- public boolean encounteredError();
-
- public ASTCompletionNode getCompletionNode();
-
+public class ANSICParserExtensionConfiguration extends AbstractCParserExtensionConfiguration {
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/AbstractCLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/AbstractCLanguage.java
new file mode 100644
index 00000000000..5557b4b69cc
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/AbstractCLanguage.java
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.parser.c;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.dom.ICodeReaderFactory;
+import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
+import org.eclipse.cdt.core.dom.parser.AbstractScannerExtensionConfiguration;
+import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
+import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.AbstractLanguage;
+import org.eclipse.cdt.core.model.IContributedModelBuilder;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.CodeReader;
+import org.eclipse.cdt.core.parser.IParserLogService;
+import org.eclipse.cdt.core.parser.IScanner;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.ParserMode;
+import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
+import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
+import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
+import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkageFactory;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Abstract C language. Derived classes need only implement
+ * {@link getScannerExtensionConfiguration()} and
+ * {@link getParserExtensionConfiguration()}.
+ *
+ * + * EXPERIMENTAL. This class or interface has been added as + * part of a work in progress. There is no guarantee that this API will work or + * that it will remain the same. Please do not use this API without consulting + * with the CDT team. + *
+ * + * @see AbstractScannerExtensionConfiguration + * @see AbstractCParserExtensionConfiguration + * + * @since 4.0 + */ +public abstract class AbstractCLanguage extends AbstractLanguage { + + protected static class NameCollector extends CASTVisitor { + { + shouldVisitNames= true; + } + + private List nameList= new ArrayList(); + + public int visit(IASTName name) { + nameList.add(name); + return PROCESS_CONTINUE; + } + + public IASTName[] getNames() { + return (IASTName[]) nameList.toArray(new IASTName[nameList.size()]); + } + } + + public Object getAdapter(Class adapter) { + if (adapter == IPDOMLinkageFactory.class) + return new PDOMCLinkageFactory(); + else + return super.getAdapter(adapter); + } + + public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo, + ICodeReaderFactory codeReaderFactory, IIndex index, IParserLogService log) throws CoreException { + + IScanner scanner= createScanner(reader, scanInfo, codeReaderFactory, log); + ISourceCodeParser parser= createParser(scanner, log, index, false); + + // Parse + IASTTranslationUnit ast= parser.parse(); + return ast; + } + + public ASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo, + ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException { + + IScanner scanner= createScanner(reader, scanInfo, fileCreator, log); + scanner.setContentAssistMode(offset); + + ISourceCodeParser parser= createParser(scanner, log, index, true); + + // Run the parse and return the completion node + parser.parse(); + ASTCompletionNode node= parser.getCompletionNode(); + if (node != null) { + node.count= scanner.getCount(); + } + return node; + } + + + public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) { + IASTNode selectedNode= ast.selectNodeForLocation(ast.getFilePath(), start, length); + + if (selectedNode == null) + return new IASTName[0]; + + if (selectedNode instanceof IASTName) + return new IASTName[] { (IASTName) selectedNode }; + + NameCollector collector= new NameCollector(); + selectedNode.accept(collector); + return collector.getNames(); + } + + public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) { + // Use the default CDT model builder + return null; + } + + /** + * Create the scanner to be used with the parser. + * + * @param reader the code reader for the main file + * @param scanInfo the scanner information (macros, include pathes) + * @param fileCreator the code reader factory for inclusions + * @param log the log for debugging + * @return an instance of IScanner + */ + protected IScanner createScanner(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IParserLogService log) { + return new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, ParserLanguage.C, + log, getScannerExtensionConfiguration(), fileCreator); + } + + /** + * Create the parser. + * + * @param scanner the IScanner to get tokens from + * @param log the parser log service + * @param index the index to help resolve bindings + * @param forCompletion whether the parser is used for code completion + * @return an instance of ISourceCodeParser + */ + protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion) { + ParserMode mode= forCompletion ? ParserMode.COMPLETION_PARSE : ParserMode.COMPLETE_PARSE; + return new GNUCSourceParser(scanner, mode, log, getParserExtensionConfiguration(), index); + } + + /** + * @return the scanner extension configuration for this language, may not + * returnnull
+ */
+ protected abstract IScannerExtensionConfiguration getScannerExtensionConfiguration();
+
+ /**
+ * @return the parser extension configuration for this language, may not
+ * return null
+ */
+ protected abstract ICParserExtensionConfiguration getParserExtensionConfiguration();
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/AbstractCParserExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/AbstractCParserExtensionConfiguration.java
new file mode 100644
index 00000000000..dc04f787875
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/AbstractCParserExtensionConfiguration.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.parser.c;
+
+import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
+
+
+/**
+ * Abstract C parser extension configuration to help model C dialects.
+ *
+ * + * EXPERIMENTAL. This class or interface has been added as + * part of a work in progress. There is no guarantee that this API will work or + * that it will remain the same. Please do not use this API without consulting + * with the CDT team. + *
+ * + * @since 4.0 + */ +public abstract class AbstractCParserExtensionConfiguration implements ICParserExtensionConfiguration { + + /* + * @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#supportAlignOfUnaryExpression() + */ + public boolean supportAlignOfUnaryExpression() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#supportAttributeSpecifiers() + */ + public boolean supportAttributeSpecifiers() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#supportDeclspecSpecifiers() + */ + public boolean supportDeclspecSpecifiers() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#supportGCCOtherBuiltinSymbols() + */ + public boolean supportGCCOtherBuiltinSymbols() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#supportGCCStyleDesignators() + */ + public boolean supportGCCStyleDesignators() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#supportKnRC() + */ + public boolean supportKnRC() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#supportStatementsInExpressions() + */ + public boolean supportStatementsInExpressions() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#supportTypeofUnaryExpressions() + */ + public boolean supportTypeofUnaryExpressions() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#getBuiltinSymbolProvider() + */ + public IBuiltinBindingsProvider getBuiltinBindingsProvider() { + if (supportGCCOtherBuiltinSymbols()) { + return new GCCBuiltinSymbolProvider(ParserLanguage.C); + } + return null; + } + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCParserExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCParserExtensionConfiguration.java new file mode 100644 index 00000000000..aa2ba353965 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCParserExtensionConfiguration.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + * Ed Swartz (Nokia) + *******************************************************************************/ +package org.eclipse.cdt.core.dom.parser.c; + +import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider; +import org.eclipse.cdt.core.parser.ParserLanguage; +import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider; +import org.eclipse.core.runtime.Platform; + +/** + * @author jcamelon + */ +public class GCCParserExtensionConfiguration extends AbstractCParserExtensionConfiguration { + + /* + * @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportStatementsInExpressions() + */ + public boolean supportStatementsInExpressions() { + return true; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportGCCStyleDesignators() + */ + public boolean supportGCCStyleDesignators() { + return true; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportTypeofUnaryExpressions() + */ + public boolean supportTypeofUnaryExpressions() { + return true; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportAlignOfUnaryExpression() + */ + public boolean supportAlignOfUnaryExpression() { + return true; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportKnRC() + */ + public boolean supportKnRC() { + return true; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportAttributeSpecifiers() + */ + public boolean supportAttributeSpecifiers() { + return true; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportDeclspecSpecifiers() + */ + public boolean supportDeclspecSpecifiers() { + // XXX Yes, this is a hack -- should use the target platform + if (Platform.getOS().equals(Platform.OS_WIN32)) + return true; + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#getBuiltinSymbolProvider() + */ + public IBuiltinBindingsProvider getBuiltinBindingsProvider() { + return new GCCBuiltinSymbolProvider(ParserLanguage.C); + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/GCCScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java similarity index 87% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/GCCScannerExtensionConfiguration.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java index 3a946e1540c..83366f2aafd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/GCCScannerExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,18 +9,21 @@ * IBM - Initial API and implementation * Ed Swartz (Nokia) *******************************************************************************/ -package org.eclipse.cdt.internal.core.parser.scanner2; +package org.eclipse.cdt.core.dom.parser.c; +import org.eclipse.cdt.core.dom.parser.GNUScannerExtensionConfiguration; import org.eclipse.cdt.core.parser.GCCKeywords; import org.eclipse.cdt.core.parser.IGCCToken; import org.eclipse.cdt.core.parser.util.CharArrayIntMap; import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; -import org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner.ExpressionEvaluator; +import org.eclipse.cdt.internal.core.parser.scanner2.DynamicFunctionStyleMacro; +import org.eclipse.cdt.internal.core.parser.scanner2.ExpressionEvaluator; +import org.eclipse.cdt.internal.core.parser.scanner2.FunctionStyleMacro; /** * @author jcamelon */ -public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfiguration implements IScannerExtensionConfiguration { +public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfiguration { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#supportMinAndMaxOperators() diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/ICParserExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/ICParserExtensionConfiguration.java new file mode 100644 index 00000000000..344de50f588 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/ICParserExtensionConfiguration.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright (c) 2002, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + * Ed Swartz (Nokia) + * Anton Leherbauer (Wind River Systems) + *******************************************************************************/ +package org.eclipse.cdt.core.dom.parser.c; + +import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider; + + +/** + * C parser extension configuration interface. + * + *+ * This interface is not intended to be implemented directly. + * Clients should subclass {@link AbstractCParserExtensionConfiguration} instead. + *
+ *+ * EXPERIMENTAL. This class or interface has been added as + * part of a work in progress. There is no guarantee that this API will work or + * that it will remain the same. Please do not use this API without consulting + * with the CDT team. + *
+ * + * @see http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html + * + * @author jcamelon + * @since 4.0 + */ +public interface ICParserExtensionConfiguration { + + /** + * Support for GNU extension "Statements and Declarations in Expressions". + * @see http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html + * @returntrue
if support for the extension should be enabled
+ */
+ public boolean supportStatementsInExpressions();
+
+ /**
+ * Support for GNU extension "Designated Initializers".
+ * @see http://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html
+ * @return true
if support for the extension should be enabled
+ */
+ public boolean supportGCCStyleDesignators();
+
+ /**
+ * Support for GNU extension "Referring to a Type with typeof".
+ * @see http://gcc.gnu.org/onlinedocs/gcc/Typeof.html
+ * @return true
if support for the extension should be enabled
+ */
+ public boolean supportTypeofUnaryExpressions();
+
+ /**
+ * Support for GNU extension "Inquiring on Alignment of Types or Variables".
+ * @see http://gcc.gnu.org/onlinedocs/gcc/Alignment.html
+ * @return true
if support for the extension should be enabled
+ */
+ public boolean supportAlignOfUnaryExpression();
+
+ /**
+ * Support for Kernighan and Richie (K&R) C.
+ * @return true
if support for K&R C should be enabled
+ */
+ public boolean supportKnRC();
+
+ /**
+ * See http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
+ * for more information on GCC's Other Built-in Symbols.
+ * @return true
if support for the extension should be enabled
+ * @deprecated use {@link #getBuiltinBindingsProvider()} instead.
+ */
+ public boolean supportGCCOtherBuiltinSymbols();
+
+ /**
+ * See http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html
+ * for more information on GCC's Attribute Specifiers.
+ * @return true
if support for the extension should be enabled
+ */
+ public boolean supportAttributeSpecifiers();
+
+ /**
+ * Win32 compiler extensions also supported by GCC on Win32
+ * @return true
if support for the extension should be enabled
+ */
+ public boolean supportDeclspecSpecifiers();
+
+ /**
+ * Provide additional built-in bindings.
+ * @return an instance of {@link IBuiltinBindingsProvider} or null
+ */
+ public IBuiltinBindingsProvider getBuiltinBindingsProvider();
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/ANSICPPParserExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/ANSICPPParserExtensionConfiguration.java
new file mode 100644
index 00000000000..975c4a049c8
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/ANSICPPParserExtensionConfiguration.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ * Ed Swartz (Nokia)
+ * Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.parser.cpp;
+
+/**
+ * @author jcamelon
+ */
+public class ANSICPPParserExtensionConfiguration extends AbstractCPPParserExtensionConfiguration {
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/AbstractCPPLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/AbstractCPPLanguage.java
new file mode 100644
index 00000000000..d62207ff02d
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/AbstractCPPLanguage.java
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.parser.cpp;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.dom.ICodeReaderFactory;
+import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
+import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
+import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.AbstractLanguage;
+import org.eclipse.cdt.core.model.IContributedModelBuilder;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.CodeReader;
+import org.eclipse.cdt.core.parser.IParserLogService;
+import org.eclipse.cdt.core.parser.IScanner;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.ParserMode;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
+import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
+import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
+import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Abstract C++ language. Derived classes need only implement
+ * {@link getScannerExtensionConfiguration()} and
+ * {@link getParserExtensionConfiguration()}.
+ *
+ * + * EXPERIMENTAL. This class or interface has been added as + * part of a work in progress. There is no guarantee that this API will work or + * that it will remain the same. Please do not use this API without consulting + * with the CDT team. + *
+ * + * @see IScannerExtensionConfiguration + * @see ICPPParserExtensionConfiguration + * + * @since 4.0 + */ +public abstract class AbstractCPPLanguage extends AbstractLanguage { + + protected static class NameCollector extends CPPASTVisitor { + { + shouldVisitNames= true; + } + + private List nameList= new ArrayList(); + + public int visit(IASTName name) { + nameList.add(name); + return PROCESS_CONTINUE; + } + + public IASTName[] getNames() { + return (IASTName[]) nameList.toArray(new IASTName[nameList.size()]); + } + } + + public Object getAdapter(Class adapter) { + if (adapter == IPDOMLinkageFactory.class) + return new PDOMCPPLinkageFactory(); + else + return super.getAdapter(adapter); + } + + public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo, + ICodeReaderFactory codeReaderFactory, IIndex index, IParserLogService log) throws CoreException { + + IScanner scanner= createScanner(reader, scanInfo, codeReaderFactory, log); + ISourceCodeParser parser= createParser(scanner, log, index, false); + + // Parse + IASTTranslationUnit ast= parser.parse(); + return ast; + } + + public ASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo, + ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException { + IScanner scanner= createScanner(reader, scanInfo, fileCreator, log); + scanner.setContentAssistMode(offset); + + ISourceCodeParser parser= createParser(scanner, log, index, true); + + // Run the parse and return the completion node + parser.parse(); + ASTCompletionNode node= parser.getCompletionNode(); + if (node != null) { + node.count= scanner.getCount(); + } + return node; + } + + public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) { + IASTNode selectedNode= ast.selectNodeForLocation(ast.getFilePath(), start, length); + + if (selectedNode == null) + return new IASTName[0]; + + if (selectedNode instanceof IASTName) + return new IASTName[] { (IASTName) selectedNode }; + + NameCollector collector= new NameCollector(); + selectedNode.accept(collector); + return collector.getNames(); + } + + public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) { + // Use the default CDT model builder + return null; + } + + /** + * Create the scanner to be used with the parser. + * + * @param reader the code reader for the main file + * @param scanInfo the scanner information (macros, include pathes) + * @param fileCreator the code reader factory for inclusions + * @param log the log for debugging + * @return an instance of IScanner + */ + protected IScanner createScanner(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IParserLogService log) { + return new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, ParserLanguage.C, + log, getScannerExtensionConfiguration(), fileCreator); + } + + /** + * Create the parser. + * + * @param scanner the IScanner to get tokens from + * @param log the parser log service + * @param index the index to help resolve bindings + * @param forCompletion whether the parser is used for code completion + * @return an instance of ISourceCodeParser + */ + protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion) { + ParserMode mode= forCompletion ? ParserMode.COMPLETION_PARSE : ParserMode.COMPLETE_PARSE; + return new GNUCPPSourceParser(scanner, mode, log, getParserExtensionConfiguration(), index); + } + + /** + * @return the scanner extension configuration for this language, may not + * returnnull
+ */
+ protected abstract IScannerExtensionConfiguration getScannerExtensionConfiguration();
+
+ /**
+ * @return the parser extension configuration for this language, may not
+ * return null
+ */
+ protected abstract AbstractCPPParserExtensionConfiguration getParserExtensionConfiguration();
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/AbstractCPPParserExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/AbstractCPPParserExtensionConfiguration.java
new file mode 100644
index 00000000000..5bd847a0f25
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/AbstractCPPParserExtensionConfiguration.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.dom.parser.cpp;
+
+import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
+
+
+/**
+ * Abstract C++ parser extension configuration to help model C++ dialects.
+ *
+ * + * EXPERIMENTAL. This class or interface has been added as + * part of a work in progress. There is no guarantee that this API will work or + * that it will remain the same. Please do not use this API without consulting + * with the CDT team. + *
+ * + * @since 4.0 + */ +public abstract class AbstractCPPParserExtensionConfiguration implements ICPPParserExtensionConfiguration { + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#allowRestrictPointerOperators() + */ + public boolean allowRestrictPointerOperators() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportAlignOfUnaryExpression() + */ + public boolean supportAlignOfUnaryExpression() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportAttributeSpecifiers() + */ + public boolean supportAttributeSpecifiers() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportComplexNumbers() + */ + public boolean supportComplexNumbers() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportDeclspecSpecifiers() + */ + public boolean supportDeclspecSpecifiers() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportExtendedTemplateSyntax() + */ + public boolean supportExtendedTemplateSyntax() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportGCCOtherBuiltinSymbols() + */ + public boolean supportGCCOtherBuiltinSymbols() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportKnRC() + */ + public boolean supportKnRC() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportLongLongs() + */ + public boolean supportLongLongs() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportMinAndMaxOperators() + */ + public boolean supportMinAndMaxOperators() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportRestrictKeyword() + */ + public boolean supportRestrictKeyword() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportStatementsInExpressions() + */ + public boolean supportStatementsInExpressions() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportTypeofUnaryExpressions() + */ + public boolean supportTypeofUnaryExpressions() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#getBuiltinBindingsProvider() + */ + public IBuiltinBindingsProvider getBuiltinBindingsProvider() { + if (supportGCCOtherBuiltinSymbols()) { + return new GCCBuiltinSymbolProvider(ParserLanguage.CPP); + } + return null; + } + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPParserExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPParserExtensionConfiguration.java new file mode 100644 index 00000000000..b3e82a2a1e7 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPParserExtensionConfiguration.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * Copyright (c) 2002, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + * Ed Swartz (Nokia) + *******************************************************************************/ +package org.eclipse.cdt.core.dom.parser.cpp; + +import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider; +import org.eclipse.cdt.core.parser.ParserLanguage; +import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider; +import org.eclipse.core.runtime.Platform; + +/** + * @author jcamelon + */ +public class GPPParserExtensionConfiguration extends AbstractCPPParserExtensionConfiguration { + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#allowRestrictPointerOperators() + */ + public boolean allowRestrictPointerOperators() { + return true; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportTypeofUnaryExpressions() + */ + public boolean supportTypeofUnaryExpressions() { + return true; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportAlignOfUnaryExpression() + */ + public boolean supportAlignOfUnaryExpression() { + return true; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportExtendedTemplateSyntax() + */ + public boolean supportExtendedTemplateSyntax() { + return true; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportMinAndMaxOperators() + */ + public boolean supportMinAndMaxOperators() { + return true; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportStatementsInExpressions() + */ + public boolean supportStatementsInExpressions() { + return true; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportComplexNumbers() + */ + public boolean supportComplexNumbers() { + return true; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportRestrictKeyword() + */ + public boolean supportRestrictKeyword() { + return true; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportLongLongs() + */ + public boolean supportLongLongs() { + return true; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportKnRC() + */ + public boolean supportKnRC() { + return false; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportAttributeSpecifiers() + */ + public boolean supportAttributeSpecifiers() { + return true; + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportDeclspecSpecifiers() + */ + public boolean supportDeclspecSpecifiers() { + // XXX: a hack, should use the target's platform + return Platform.getOS().equals(Platform.OS_WIN32); + } + + /* + * @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#getBuiltinBindingsProvider() + */ + public IBuiltinBindingsProvider getBuiltinBindingsProvider() { + return new GCCBuiltinSymbolProvider(ParserLanguage.CPP); + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/GPPScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java similarity index 91% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/GPPScannerExtensionConfiguration.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java index 5c799a02e4f..2984be5df35 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/GPPScannerExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java @@ -9,8 +9,10 @@ * IBM - Initial API and implementation * Ed Swartz (Nokia) *******************************************************************************/ -package org.eclipse.cdt.internal.core.parser.scanner2; +package org.eclipse.cdt.core.dom.parser.cpp; +import org.eclipse.cdt.core.dom.parser.GNUScannerExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; import org.eclipse.cdt.core.parser.GCCKeywords; import org.eclipse.cdt.core.parser.IGCCToken; import org.eclipse.cdt.core.parser.IToken; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/ICPPParserExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/ICPPParserExtensionConfiguration.java new file mode 100644 index 00000000000..56bfe54aded --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/ICPPParserExtensionConfiguration.java @@ -0,0 +1,135 @@ +/******************************************************************************* + * Copyright (c) 2002, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + * Ed Swartz (Nokia) + * Anton Leherbauer (Wind River Systems) + *******************************************************************************/ +package org.eclipse.cdt.core.dom.parser.cpp; + +import org.eclipse.cdt.core.dom.ast.IScope; +import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider; + + +/** + * C++ parser extension configuration interface. + * + *+ * This interface is not intended to be implemented directly. + * Clients should subclass {@link AbstractCPPParserExtensionConfiguration} instead. + *
+ *+ * EXPERIMENTAL. This class or interface has been added as + * part of a work in progress. There is no guarantee that this API will work or + * that it will remain the same. Please do not use this API without consulting + * with the CDT team. + *
+ * + * @see http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html + * @see http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Extensions.html + * + * @author jcamelon + * @since 4.0 + */ +public interface ICPPParserExtensionConfiguration { + + /** + * Support for GNU extension "Restricting Pointer Aliasing". + * @see http://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html + * @returntrue
if support for the extension should be enabled
+ */
+ public boolean allowRestrictPointerOperators();
+
+ /**
+ * Support for GNU extension "Extended Syntax for Template Instantiation".
+ * @see http://gcc.gnu.org/onlinedocs/gcc/Template-Instantiation.html
+ * @return true
if support for the extension should be enabled
+ */
+ public boolean supportExtendedTemplateSyntax();
+
+ /**
+ * Support for (deprecated) GNU minimum and maximum operators (`' and `>?').
+ * @see http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.html
+ * @return true
if support for the extension should be enabled
+ */
+ public boolean supportMinAndMaxOperators();
+
+ /**
+ * Support for GNU extension "Data types for complex numbers".
+ * @see http://gcc.gnu.org/onlinedocs/gcc/Complex.html#Complex
+ * @return true
if support for the extension should be enabled
+ */
+ public boolean supportComplexNumbers();
+
+ /**
+ * Support for the GNU __restrict__
keyword.
+ * @return true
if support for the extension should be enabled
+ */
+ public boolean supportRestrictKeyword();
+
+ /**
+ * Support for GNU long long types.
+ * @see http://gcc.gnu.org/onlinedocs/gcc/Long-Long.html
+ * @return true
if support for the extension should be enabled
+ */
+ public boolean supportLongLongs();
+
+ /**
+ * Support for GNU extension "Statements and Declarations in Expressions".
+ * @see http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
+ * @return true
if support for the extension should be enabled
+ */
+ public boolean supportStatementsInExpressions();
+
+ /**
+ * Support for GNU extension "Referring to a Type with typeof".
+ * @see http://gcc.gnu.org/onlinedocs/gcc/Typeof.html
+ * @return true
if support for the extension should be enabled
+ */
+ public boolean supportTypeofUnaryExpressions();
+
+ /**
+ * Support for GNU extension "Inquiring on Alignment of Types or Variables".
+ * @see http://gcc.gnu.org/onlinedocs/gcc/Alignment.html
+ * @return true
if support for the extension should be enabled
+ */
+ public boolean supportAlignOfUnaryExpression();
+
+ /**
+ * Support for Kernighan and Richie (K&R) C.
+ * @return true
if support for K&R C should be enabled
+ */
+ public boolean supportKnRC();
+
+ /**
+ * See http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
+ * for more information on GCC's Other Built-in Symbols.
+ * @return true
if support for the extension should be enabled
+ * @deprecated use {@link #getBuiltinSymbolProvider(IScope)} instead.
+ */
+ public boolean supportGCCOtherBuiltinSymbols();
+
+ /**
+ * See http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html
+ * for more information on GCC's Attribute Specifiers.
+ * @return true
if support for the extension should be enabled
+ */
+ public boolean supportAttributeSpecifiers();
+
+ /**
+ * Win32 compiler extensions also supported by GCC on Win32
+ * @return true
if support for the extension should be enabled
+ */
+ public boolean supportDeclspecSpecifiers();
+
+ /**
+ * Provide additional built-in bindings.
+ * @return an instance of {@link IBuiltinBindingsProvider} or null
+ */
+ public IBuiltinBindingsProvider getBuiltinBindingsProvider();
+}
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 ecd407f0653..31f399850e0 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation and others.
+ * Copyright (c) 2002, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,6 +14,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Set;
+import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
import org.eclipse.cdt.core.parser.ast.IASTFactory;
import org.eclipse.cdt.core.parser.extension.ExtensionDialect;
import org.eclipse.cdt.core.parser.extension.IParserExtension;
@@ -26,7 +27,6 @@ import org.eclipse.cdt.internal.core.parser.ast.complete.CompleteParseASTFactory
import org.eclipse.cdt.internal.core.parser.ast.quick.QuickParseASTFactory;
import org.eclipse.cdt.internal.core.parser.scanner2.GCCOldScannerExtensionConfiguration;
import org.eclipse.cdt.internal.core.parser.scanner2.GPPOldScannerExtensionConfiguration;
-import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
import org.eclipse.cdt.internal.core.parser.scanner2.Scanner2;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
index 6ed751465ff..6bb1731b037 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
@@ -60,6 +60,8 @@ import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
+import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
+import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
import org.eclipse.cdt.core.parser.AbstractParserLogService;
import org.eclipse.cdt.core.parser.EndOfFileException;
import org.eclipse.cdt.core.parser.IGCCToken;
@@ -89,18 +91,19 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
protected final boolean supportKnRC;
- protected final boolean supportGCCOtherBuiltinSymbols;
-
protected final boolean supportAttributeSpecifiers;
protected final boolean supportDeclspecSpecifiers;
+ protected final IBuiltinBindingsProvider builtinBindingsProvider;
+
protected AbstractGNUSourceCodeParser(IScanner scanner,
IParserLogService logService, ParserMode parserMode,
boolean supportStatementsInExpressions,
boolean supportTypeOfUnaries, boolean supportAlignOfUnaries,
- boolean supportKnRC, boolean supportGCCOtherBuiltinSymbols,
- boolean supportAttributeSpecifiers, boolean supportDeclspecSpecifiers) {
+ boolean supportKnRC, boolean supportAttributeSpecifiers,
+ boolean supportDeclspecSpecifiers,
+ IBuiltinBindingsProvider builtinBindingsProvider) {
this.scanner = scanner;
this.log = wrapLogService(logService);
this.mode = parserMode;
@@ -108,9 +111,9 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
this.supportTypeOfUnaries = supportTypeOfUnaries;
this.supportAlignOfUnaries = supportAlignOfUnaries;
this.supportKnRC = supportKnRC;
- this.supportGCCOtherBuiltinSymbols = supportGCCOtherBuiltinSymbols;
this.supportAttributeSpecifiers = supportAttributeSpecifiers;
this.supportDeclspecSpecifiers = supportDeclspecSpecifiers;
+ this.builtinBindingsProvider= builtinBindingsProvider;
}
protected boolean parsePassed = true;
@@ -2303,7 +2306,36 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
}
}
}
-
+
+ /**
+ * Hook method to support (skip) additional declspec modifiers.
+ * @throws BacktrackException
+ * @throws EndOfFileException
+ */
+ protected void handleOtherDeclSpecModifier() throws BacktrackException, EndOfFileException {
+ // default action: consume keyword plus optional parenthesised "something"
+ consume();
+
+ IToken token = LA(1);
+
+ if (token.getType() == IToken.tLPAREN) {
+ consume();
+ int openParen= 1;
+ while(true) {
+ token = LA(1);
+ consume();
+ if (token.getType() == IToken.tLPAREN) {
+ ++openParen;
+ } else if (token.getType() == IToken.tRPAREN) {
+ --openParen;
+ if (openParen == 0) {
+ break;
+ }
+ }
+ }
+ }
+ }
+
/**
* In case a cast expression is followed by +/- or & we should avoid it:
* (a)+1 vs. (int)+1;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java
index fd7f132cab4..1ca22d324fe 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2005, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,12 +8,12 @@
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
+ * Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
-import org.eclipse.cdt.core.dom.ast.IASTBuiltinSymbolProvider;
import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
@@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
+import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
@@ -42,12 +43,12 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPPointerType;
import org.eclipse.core.runtime.PlatformObject;
/**
- * This is the IASTBuiltinSymbolProvider used to implement the "Other" built-in GCC symbols defined:
+ * This is the IBuiltinBindingsProvider used to implement the "Other" built-in GCC symbols defined:
* http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#Other-Builtins
*
* @author dsteffle
*/
-public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
+public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
/**
* BUILTIN_GCC_SYMBOL
is a built-in GCC symbol.
*/
@@ -290,12 +291,11 @@ public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
private IBinding[] bindings=new IBinding[NUM_OTHER_GCC_BUILTINS];
private IScope scope=null;
private ParserLanguage lang=null;
- public GCCBuiltinSymbolProvider(IScope scope, ParserLanguage lang) {
- this.scope = scope;
+ public GCCBuiltinSymbolProvider(ParserLanguage lang) {
this.lang = lang;
}
- public void initialize() {
+ private void initialize() {
__builtin_va_list();
__builtin_expect();
__builtin_prefetch();
@@ -913,7 +913,7 @@ public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
bindings = (IBinding[])ArrayUtil.append(IBinding.class, bindings, temp);
}
- public void __builtin_exit() {
+ private void __builtin_exit() {
// void __builtin_abort(void)
IBinding temp = null;
if (lang == ParserLanguage.C) {
@@ -2148,7 +2148,7 @@ public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
bindings = (IBinding[])ArrayUtil.append(IBinding.class, bindings, temp);
}
- public void __builtin_less_greater() {
+ private void __builtin_less_greater() {
IBinding temp = null;
// int __builtin_isgreater(real-floating, real-floating)
if (lang == ParserLanguage.C) {
@@ -2294,7 +2294,8 @@ public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
bindings = (IBinding[])ArrayUtil.append(IBinding.class, bindings, temp);
}
- public IBinding[] getBuiltinBindings() {
+ public IBinding[] getBuiltinBindings(IScope scope) {
+ this.scope= scope;
initialize();
return (IBinding[])ArrayUtil.trim(IBinding.class, bindings);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/ANSICParserExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/ANSICParserExtensionConfiguration.java
deleted file mode 100644
index 15441b2015d..00000000000
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/ANSICParserExtensionConfiguration.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Rational Software - Initial API and implementation
- * Ed Swartz (Nokia)
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.dom.parser.c;
-
-/**
- * @author jcamelon
- */
-public class ANSICParserExtensionConfiguration implements
- ICParserExtensionConfiguration {
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportStatementsInExpressions()
- */
- public boolean supportStatementsInExpressions() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportGCCStyleDesignators()
- */
- public boolean supportGCCStyleDesignators() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportTypeofUnaryExpressions()
- */
- public boolean supportTypeofUnaryExpressions() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportAlignOfUnaryExpression()
- */
- public boolean supportAlignOfUnaryExpression() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportKnRC()
- */
- public boolean supportKnRC() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportGCCBuiltinSymbols()
- */
- public boolean supportGCCOtherBuiltinSymbols() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportAttributeSpecifiers()
- */
- public boolean supportAttributeSpecifiers() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration#supportDeclspecSpecifiers()
- */
- public boolean supportDeclspecSpecifiers() {
- return false;
- }
-}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
index 8ef0ac4a401..abc5489c71a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
@@ -40,10 +40,7 @@ import org.eclipse.cdt.core.dom.ast.IMacroBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
-import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
import org.eclipse.cdt.core.index.IIndex;
-import org.eclipse.cdt.core.model.ILanguage;
-import org.eclipse.cdt.core.model.LanguageManager;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCParserExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCParserExtensionConfiguration.java
deleted file mode 100644
index 307a702fdd5..00000000000
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCParserExtensionConfiguration.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Rational Software - Initial API and implementation
- * Ed Swartz (Nokia)
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.dom.parser.c;
-
-import org.eclipse.core.runtime.Platform;
-
-/**
- * @author jcamelon
- */
-public class GCCParserExtensionConfiguration implements
- ICParserExtensionConfiguration {
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportStatementsInExpressions()
- */
- public boolean supportStatementsInExpressions() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportGCCStyleDesignators()
- */
- public boolean supportGCCStyleDesignators() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportTypeofUnaryExpressions()
- */
- public boolean supportTypeofUnaryExpressions() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportAlignOfUnaryExpression()
- */
- public boolean supportAlignOfUnaryExpression() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration#supportKRCSyntax()
- */
- public boolean supportKnRC() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportGCCOtherBuiltinSymbols()
- */
- public boolean supportGCCOtherBuiltinSymbols() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportAttributeSpecifiers()
- */
- public boolean supportAttributeSpecifiers() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration#supportDeclspecSpecifiers()
- */
- public boolean supportDeclspecSpecifiers() {
- // XXX Yes, this is a hack -- should use the target platform
- if (Platform.getOS().equals(Platform.OS_WIN32))
- return true;
- return false;
- }
-}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
index 914b3b98b87..dba24e9a19e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
@@ -94,6 +94,8 @@ import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.parser.IExtensionToken;
+import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.parser.EndOfFileException;
import org.eclipse.cdt.core.parser.IGCCToken;
@@ -101,7 +103,6 @@ import org.eclipse.cdt.core.parser.IParserLogService;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.ParseError;
-import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
@@ -109,7 +110,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
import org.eclipse.cdt.internal.core.dom.parser.BacktrackException;
-import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement;
@@ -143,13 +143,14 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
public GNUCSourceParser(IScanner scanner, ParserMode parserMode,
IParserLogService logService, ICParserExtensionConfiguration config,
IIndex index) {
- super(scanner, logService, parserMode, config
- .supportStatementsInExpressions(), config
- .supportTypeofUnaryExpressions(), config
- .supportAlignOfUnaryExpression(), config
- .supportKnRC(), config.supportGCCOtherBuiltinSymbols(),
- config.supportAttributeSpecifiers(),
- config.supportDeclspecSpecifiers());
+ super(scanner, logService, parserMode,
+ config.supportStatementsInExpressions(),
+ config.supportTypeofUnaryExpressions(),
+ config.supportAlignOfUnaryExpression(),
+ config.supportKnRC(),
+ config.supportAttributeSpecifiers(),
+ config.supportDeclspecSpecifiers(),
+ config.getBuiltinBindingsProvider());
supportGCCStyleDesignators = config.supportGCCStyleDesignators();
this.index= index;
}
@@ -593,10 +594,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
translationUnit.setIndex(index);
// add built-in names to the scope
- if (supportGCCOtherBuiltinSymbols) {
+ if (builtinBindingsProvider != null) {
IScope tuScope = translationUnit.getScope();
- IBinding[] bindings = new GCCBuiltinSymbolProvider(translationUnit.getScope(), ParserLanguage.C).getBuiltinBindings();
+ IBinding[] bindings = builtinBindingsProvider.getBuiltinBindings(tuScope);
for(int i=0; i