1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Added in hooks to plugin a database for the PDOM.

This commit is contained in:
Doug Schaefer 2005-09-09 19:31:41 +00:00
parent 0d47484eda
commit 5d8d0dacaa
5 changed files with 259 additions and 8 deletions

View file

@ -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);
}

View file

@ -1,21 +1,30 @@
package org.eclipse.cdt.core.pdom; 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.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.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding; 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 { public class PDOM {
// To reduce storage requirements we have a single table that contains all // The DOM hash map
// of the strings in the PDOM. To check for equality, all you need to do private static Map pdomMap = new HashMap();
// is compare string handles.
private Set stringTable = new HashSet();
private IScope globalScope; private Connection dbConn;
private PDOM(Connection conn) {
dbConn = conn;
}
/** /**
* Look up the name from the DOM in the PDOM and return the PDOM * 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;
}
} }

View file

@ -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;
}
}

View file

@ -63,6 +63,7 @@
<extension-point id="PathEntryContainerInitializer" name="%PathEntryContainerInitializer" schema="schema/PathEntryContainerInitializer.exsd"/> <extension-point id="PathEntryContainerInitializer" name="%PathEntryContainerInitializer" schema="schema/PathEntryContainerInitializer.exsd"/>
<extension-point id="CodeFormatter" name="%CodeFormatter.name" schema="schema/CodeFormatter.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="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 --> <!-- Define the list of the Binary Parser provided by the CDT -->
<!-- =================================================================================== --> <!-- =================================================================================== -->

View file

@ -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>