Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.core/pdom/org/eclipse/cdt/core/pdom/IPDOMDatabaseProvider.java27
-rw-r--r--core/org.eclipse.cdt.core/pdom/org/eclipse/cdt/core/pdom/PDOM.java68
-rw-r--r--core/org.eclipse.cdt.core/pdom/org/eclipse/cdt/core/pdom/PDOMASTServiceProvider.java59
-rw-r--r--core/org.eclipse.cdt.core/plugin.xml1
-rw-r--r--core/org.eclipse.cdt.core/schema/PDOMDatabaseProvider.exsd112
5 files changed, 259 insertions, 8 deletions
diff --git a/core/org.eclipse.cdt.core/pdom/org/eclipse/cdt/core/pdom/IPDOMDatabaseProvider.java b/core/org.eclipse.cdt.core/pdom/org/eclipse/cdt/core/pdom/IPDOMDatabaseProvider.java
new file mode 100644
index 00000000000..5ff32cdd9c5
--- /dev/null
+++ b/core/org.eclipse.cdt.core/pdom/org/eclipse/cdt/core/pdom/IPDOMDatabaseProvider.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.pdom;
+
+import java.sql.Connection;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.core.runtime.QualifiedName;
+
+public interface IPDOMDatabaseProvider {
+
+ public static final QualifiedName dbNameKey
+ = new QualifiedName(CCorePlugin.PLUGIN_ID, "pdomDBName");
+
+ Connection getDatabase(String dbName, boolean create);
+
+ void shutdownDatabase(String dbName);
+
+}
diff --git a/core/org.eclipse.cdt.core/pdom/org/eclipse/cdt/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/pdom/org/eclipse/cdt/core/pdom/PDOM.java
index 0bda0ecc05c..c48d1b19055 100644
--- a/core/org.eclipse.cdt.core/pdom/org/eclipse/cdt/core/pdom/PDOM.java
+++ b/core/org.eclipse.cdt.core/pdom/org/eclipse/cdt/core/pdom/PDOM.java
@@ -1,21 +1,30 @@
package org.eclipse.cdt.core.pdom;
-import java.util.HashSet;
+import java.sql.Connection;
+import java.util.HashMap;
import java.util.Iterator;
-import java.util.Set;
+import java.util.Map;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.core.resources.IProject;
+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;
public class PDOM {
- // To reduce storage requirements we have a single table that contains all
- // of the strings in the PDOM. To check for equality, all you need to do
- // is compare string handles.
- private Set stringTable = new HashSet();
+ // The DOM hash map
+ private static Map pdomMap = new HashMap();
+
+ private Connection dbConn;
- private IScope globalScope;
+ private PDOM(Connection conn) {
+ dbConn = conn;
+ }
/**
* Look up the name from the DOM in the PDOM and return the PDOM
@@ -79,4 +88,47 @@ public class PDOM {
}
+ /**
+ * Return the PDOM for the given project
+ *
+ * @param project
+ * @return the PDOM for the project
+ * @throws CoreException
+ */
+ public static PDOM getPDOM(IProject project) throws CoreException {
+ // Get the name for the db
+ boolean create = false;
+ String dbName = project.getPersistentProperty(IPDOMDatabaseProvider.dbNameKey);
+ if (dbName == null) {
+ // New database
+ create = true;
+ // TODO - the name shouldn't be the project name in case the
+ // user changes it and creates a new one with the old name
+ dbName = project.getName();
+ project.setPersistentProperty(IPDOMDatabaseProvider.dbNameKey, dbName);
+ } else {
+ // See if we got one already
+ PDOM pdom = (PDOM)pdomMap.get(dbName);
+ if (pdom != null)
+ return pdom;
+ }
+
+ // Find our database provider
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, "PDOMDatabaseProvider"); //$NON-NLS-1$
+ IExtension[] extensions = extensionPoint.getExtensions();
+
+ if (extensions.length == 0)
+ // No DB providers
+ return null;
+
+ // For now pick the first one. In the future we may want to support more
+ IConfigurationElement[] elements = extensions[0].getConfigurationElements();
+ IPDOMDatabaseProvider dbProvider
+ = (IPDOMDatabaseProvider)elements[0].createExecutableExtension("class"); //$NON-NLS-1$
+
+ // create the PDOM
+ PDOM pdom = new PDOM(dbProvider.getDatabase(dbName, create));
+ pdomMap.put(dbName, pdom);
+ return pdom;
+ }
}
diff --git a/core/org.eclipse.cdt.core/pdom/org/eclipse/cdt/core/pdom/PDOMASTServiceProvider.java b/core/org.eclipse.cdt.core/pdom/org/eclipse/cdt/core/pdom/PDOMASTServiceProvider.java
new file mode 100644
index 00000000000..55b8b2ee4e4
--- /dev/null
+++ b/core/org.eclipse.cdt.core/pdom/org/eclipse/cdt/core/pdom/PDOMASTServiceProvider.java
@@ -0,0 +1,59 @@
+package org.eclipse.cdt.core.pdom;
+
+import org.eclipse.cdt.core.dom.IASTServiceProvider;
+import org.eclipse.cdt.core.dom.ICodeReaderFactory;
+import org.eclipse.cdt.core.dom.IParserConfiguration;
+import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IStorage;
+
+public class PDOMASTServiceProvider implements IASTServiceProvider {
+
+ public IASTTranslationUnit getTranslationUnit(IFile fileToParse)
+ throws UnsupportedDialectException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IASTTranslationUnit getTranslationUnit(IStorage fileToParse,
+ IProject project, ICodeReaderFactory fileCreator)
+ throws UnsupportedDialectException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IASTTranslationUnit getTranslationUnit(IStorage fileToParse,
+ IProject project) throws UnsupportedDialectException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IASTTranslationUnit getTranslationUnit(IFile fileToParse,
+ ICodeReaderFactory fileCreator) throws UnsupportedDialectException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IASTTranslationUnit getTranslationUnit(IFile fileToParse,
+ ICodeReaderFactory fileCreator, IParserConfiguration configuration)
+ throws UnsupportedDialectException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ASTCompletionNode getCompletionNode(IFile fileToParse, int offset,
+ ICodeReaderFactory fileCreator) throws UnsupportedDialectException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ASTCompletionNode getCompletionNode(IStorage fileToParse,
+ IProject project, int offset, ICodeReaderFactory fileCreator)
+ throws UnsupportedDialectException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml
index 22c3a5d9f20..f49e449d65a 100644
--- a/core/org.eclipse.cdt.core/plugin.xml
+++ b/core/org.eclipse.cdt.core/plugin.xml
@@ -63,6 +63,7 @@
<extension-point id="PathEntryContainerInitializer" name="%PathEntryContainerInitializer" schema="schema/PathEntryContainerInitializer.exsd"/>
<extension-point id="CodeFormatter" name="%CodeFormatter.name" schema="schema/CodeFormatter.exsd"/>
<extension-point id="CIndexer" name="C/C++ Indexer" schema="schema/CIndexer.exsd"/>
+ <extension-point id="PDOMDatabaseProvider" name="%PDOMDatabaseProvider" schema="schema/PDOMDatabaseProvider.exsd"/>
<!-- =================================================================================== -->
<!-- Define the list of the Binary Parser provided by the CDT -->
<!-- =================================================================================== -->
diff --git a/core/org.eclipse.cdt.core/schema/PDOMDatabaseProvider.exsd b/core/org.eclipse.cdt.core/schema/PDOMDatabaseProvider.exsd
new file mode 100644
index 00000000000..61cce184201
--- /dev/null
+++ b/core/org.eclipse.cdt.core/schema/PDOMDatabaseProvider.exsd
@@ -0,0 +1,112 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.core" id="PDOMDatabaseProvider" name="%PDOMDatabaseProvider"/>
+ </appInfo>
+ <documentation>
+ This extension point provides the database to be used for the Persistent DOM.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="provider"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="provider">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.cdt.core.pdom.IPDOMDatabaseProvider"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>

Back to the top