diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOM.java
new file mode 100644
index 00000000000..50a0f9e57bf
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOM.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2005 QNX Software Systems 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:
+ * QNX - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom;
+
+/**
+ * @author Doug Schaefer
+ *
+ * This is the interface to the Persisted DOM (PDOM).
+ * It provides services to allow access to DOM information
+ * persisted between parses.
+ */
+public interface IPDOM {
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java
index 8f297933ec2..c46c430a73d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
+import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.parser.ParserLanguage;
/**
@@ -188,5 +189,18 @@ public interface IASTTranslationUnit extends IASTNode {
*/
public ParserLanguage getParserLanguage();
+ /**
+ * Return the PDOM associated with this translation unit.
+ *
+ * @return the PDOM for this translation unit
+ */
+ public IPDOM getPDOM();
-}
\ No newline at end of file
+ /**
+ * Set the PDOM to be used for this translation unit.
+ *
+ * @param pdom
+ */
+ public void setPDOM(IPDOM pdom);
+
+}
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 6c5dce00fe8..e5e0ce7b412 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
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
+import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
@@ -58,6 +59,8 @@ public class CASTTranslationUnit extends CASTNode implements
private CScope compilationUnit = null;
private ILocationResolver resolver;
+
+ private IPDOM pdom;
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
@@ -511,4 +514,12 @@ public class CASTTranslationUnit extends CASTNode implements
return ParserLanguage.C;
}
+ public IPDOM getPDOM() {
+ return pdom;
+ }
+
+ public void setPDOM(IPDOM pdom) {
+ this.pdom = pdom;
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java
index d2d29ecb354..f78ebe7e663 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
@@ -74,6 +75,7 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
private ILocationResolver resolver;
+ private IPDOM pdom;
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
@@ -563,4 +565,13 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
public ParserLanguage getParserLanguage() {
return ParserLanguage.CPP;
}
+
+ public IPDOM getPDOM() {
+ return pdom;
+ }
+
+ public void setPDOM(IPDOM pdom) {
+ this.pdom = pdom;
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/plugin.properties b/core/org.eclipse.cdt.core/plugin.properties
index 912bf68b924..af47d7cd99c 100644
--- a/core/org.eclipse.cdt.core/plugin.properties
+++ b/core/org.eclipse.cdt.core/plugin.properties
@@ -69,3 +69,5 @@ cxxHeaderName=C++ Header File
asmSourceName=Assembly Source File
cdt_pathentry_var.description=CDT PathEntry Variable
+
+PDOMProviderName=PDOM Provider
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml
index f49e449d65a..d65d3ec0b57 100644
--- a/core/org.eclipse.cdt.core/plugin.xml
+++ b/core/org.eclipse.cdt.core/plugin.xml
@@ -63,7 +63,7 @@
-
+
diff --git a/core/org.eclipse.cdt.core/schema/PDOMDatabaseProvider.exsd b/core/org.eclipse.cdt.core/schema/PDOMProvider.exsd
similarity index 84%
rename from core/org.eclipse.cdt.core/schema/PDOMDatabaseProvider.exsd
rename to core/org.eclipse.cdt.core/schema/PDOMProvider.exsd
index 61cce184201..2216f0e883e 100644
--- a/core/org.eclipse.cdt.core/schema/PDOMDatabaseProvider.exsd
+++ b/core/org.eclipse.cdt.core/schema/PDOMProvider.exsd
@@ -3,10 +3,10 @@
-
+
- This extension point provides the database to be used for the Persistent DOM.
+ [Enter description of this extension point.]
@@ -44,20 +44,27 @@
-
+
-
+
+
+
+
+
+
+
+
-
+
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/IPDOMProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/IPDOMProvider.java
new file mode 100644
index 00000000000..5097154dc85
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/IPDOMProvider.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2005 QNX Software Systems 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:
+ * QNX - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.core.resources.IProject;
+
+/**
+ * @author Doug Schaefer
+ *
+ * This is the interface to a PDOM Provider. The provider manages the
+ * relationships between PDOMs and projects and provides implementations of
+ * the PDOM interfaces.
+ */
+public interface IPDOMProvider {
+
+ public static final String ID
+ = CCorePlugin.PLUGIN_ID + ".PDOMProvider"; //$NON-NLS-1$
+
+ /**
+ * Get the PDOM for the given project. If the PDOM is unavailable for this
+ * project, null is returned.
+ *
+ * @param project
+ * @return the PDOM for the project
+ */
+ public IPDOM getPDOM(IProject project);
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/InternalASTServiceProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/InternalASTServiceProvider.java
index dcd2b55680f..993d1e18c11 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/InternalASTServiceProvider.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/InternalASTServiceProvider.java
@@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IASTServiceProvider;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
+import org.eclipse.cdt.core.dom.IPDOMProvider;
import org.eclipse.cdt.core.dom.IParserConfiguration;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
@@ -42,6 +43,11 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
/**
@@ -49,18 +55,45 @@ import org.eclipse.core.runtime.content.IContentType;
*/
public class InternalASTServiceProvider implements IASTServiceProvider {
- protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
- protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION = new GPPScannerExtensionConfiguration();
- private static final String[] dialects = { "C99", //$NON-NLS-1$
- "C++98", //$NON-NLS-1$
- "GNUC", //$NON-NLS-1$
- "GNUC++" }; //$NON-NLS-1$
-
+ protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
+ protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION = new GPPScannerExtensionConfiguration();
+ private static final String[] dialects = {
+ "C99", //$NON-NLS-1$
+ "C++98", //$NON-NLS-1$
+ "GNUC", //$NON-NLS-1$
+ "GNUC++" //$NON-NLS-1$
+ };
+ private IPDOMProvider pdomProvider;
+
+ private IPDOMProvider getPDOMProvider() {
+ if (pdomProvider == null) {
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(IPDOMProvider.ID);
+ IExtension[] extensions = extensionPoint.getExtensions();
+ if (extensions.length > 0) {
+ // For now just take the first one
+ IConfigurationElement[] elements= extensions[0].getConfigurationElements();
+ if (elements.length > 0) {
+ // For now just take the first provider
+ try {
+ pdomProvider = (IPDOMProvider)elements[0].createExecutableExtension("class"); //$NON-NLS-1$
+ return pdomProvider;
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ // Couldn't find one
+ pdomProvider = new NullPDOMProvider();
+ }
+ return pdomProvider;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.IASTServiceProvider#getName()
*/
public String getName() {
+ // TODO is this a name or an id?
return "CDT AST Service"; //$NON-NLS-1$
}
@@ -165,7 +198,10 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), config );
}
}
+ // Parse
IASTTranslationUnit tu = parser.parse();
+ // Set the PDOM if we can find one
+ tu.setPDOM(getPDOMProvider().getPDOM(project));
return tu;
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/NullPDOMProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/NullPDOMProvider.java
new file mode 100644
index 00000000000..25d9a91dd52
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/NullPDOMProvider.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2005 QNX Software Systems 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:
+ * QNX - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom;
+
+import org.eclipse.cdt.core.dom.IPDOM;
+import org.eclipse.cdt.core.dom.IPDOMProvider;
+import org.eclipse.core.resources.IProject;
+
+/**
+ * @author Doug Schaefer
+ *
+ */
+public class NullPDOMProvider implements IPDOMProvider {
+
+ public IPDOM getPDOM(IProject project) {
+ // by default return null.
+ return null;
+ }
+
+}