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

Introducing the PDOM. It is currently in optional plugins while under development.

This commit is contained in:
Doug Schaefer 2005-09-28 20:50:11 +00:00
parent 18d33b21ec
commit 43b6989c8f
10 changed files with 182 additions and 14 deletions

View file

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

View file

@ -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();
}
/**
* Set the PDOM to be used for this translation unit.
*
* @param pdom
*/
public void setPDOM(IPDOM pdom);
}

View file

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

View file

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

View file

@ -69,3 +69,5 @@ cxxHeaderName=C++ Header File
asmSourceName=Assembly Source File
cdt_pathentry_var.description=CDT PathEntry Variable
PDOMProviderName=PDOM Provider

View file

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

View file

@ -3,10 +3,10 @@
<schema targetNamespace="org.eclipse.cdt.core">
<annotation>
<appInfo>
<meta.schema plugin="org.eclipse.cdt.core" id="PDOMDatabaseProvider" name="%PDOMDatabaseProvider"/>
<meta.schema plugin="org.eclipse.cdt.core" id="PDOMProvider" name="%PDOMProviderName"/>
</appInfo>
<documentation>
This extension point provides the database to be used for the Persistent DOM.
[Enter description of this extension point.]
</documentation>
</annotation>
@ -44,20 +44,27 @@
<element name="provider">
<complexType>
<attribute name="id" type="string" use="required">
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="class" type="string">
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn="org.eclipse.cdt.core.pdom.IPDOMDatabaseProvider"/>
<meta.attribute kind="java" basedOn="org.eclipse.cdt.core.dom.IPDOMProvider"/>
</appInfo>
</annotation>
</attribute>

View file

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

View file

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

View file

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