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:
parent
18d33b21ec
commit
43b6989c8f
10 changed files with 182 additions and 14 deletions
|
@ -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 {
|
||||||
|
|
||||||
|
}
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.IPDOM;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -188,5 +189,18 @@ public interface IASTTranslationUnit extends IASTNode {
|
||||||
*/
|
*/
|
||||||
public ParserLanguage getParserLanguage();
|
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);
|
||||||
|
|
||||||
}
|
}
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
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.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
|
@ -59,6 +60,8 @@ public class CASTTranslationUnit extends CASTNode implements
|
||||||
|
|
||||||
private ILocationResolver resolver;
|
private ILocationResolver resolver;
|
||||||
|
|
||||||
|
private IPDOM pdom;
|
||||||
|
|
||||||
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
|
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
|
||||||
|
|
||||||
private static final IASTNodeLocation[] EMPTY_PREPROCESSOR_LOCATION_ARRAY = new IASTNodeLocation[0];
|
private static final IASTNodeLocation[] EMPTY_PREPROCESSOR_LOCATION_ARRAY = new IASTNodeLocation[0];
|
||||||
|
@ -511,4 +514,12 @@ public class CASTTranslationUnit extends CASTNode implements
|
||||||
return ParserLanguage.C;
|
return ParserLanguage.C;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IPDOM getPDOM() {
|
||||||
|
return pdom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPDOM(IPDOM pdom) {
|
||||||
|
this.pdom = pdom;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
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.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||||
|
@ -74,6 +75,7 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
|
||||||
|
|
||||||
private ILocationResolver resolver;
|
private ILocationResolver resolver;
|
||||||
|
|
||||||
|
private IPDOM pdom;
|
||||||
|
|
||||||
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
|
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
|
||||||
|
|
||||||
|
@ -563,4 +565,13 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
|
||||||
public ParserLanguage getParserLanguage() {
|
public ParserLanguage getParserLanguage() {
|
||||||
return ParserLanguage.CPP;
|
return ParserLanguage.CPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IPDOM getPDOM() {
|
||||||
|
return pdom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPDOM(IPDOM pdom) {
|
||||||
|
this.pdom = pdom;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,3 +69,5 @@ cxxHeaderName=C++ Header File
|
||||||
asmSourceName=Assembly Source File
|
asmSourceName=Assembly Source File
|
||||||
|
|
||||||
cdt_pathentry_var.description=CDT PathEntry Variable
|
cdt_pathentry_var.description=CDT PathEntry Variable
|
||||||
|
|
||||||
|
PDOMProviderName=PDOM Provider
|
|
@ -63,7 +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"/>
|
<extension-point id="PDOMProvider" name="%PDOMProviderName" schema="schema/PDOMProvider.exsd"/>
|
||||||
<!-- =================================================================================== -->
|
<!-- =================================================================================== -->
|
||||||
<!-- Define the list of the Binary Parser provided by the CDT -->
|
<!-- Define the list of the Binary Parser provided by the CDT -->
|
||||||
<!-- =================================================================================== -->
|
<!-- =================================================================================== -->
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
<schema targetNamespace="org.eclipse.cdt.core">
|
<schema targetNamespace="org.eclipse.cdt.core">
|
||||||
<annotation>
|
<annotation>
|
||||||
<appInfo>
|
<appInfo>
|
||||||
<meta.schema plugin="org.eclipse.cdt.core" id="PDOMDatabaseProvider" name="%PDOMDatabaseProvider"/>
|
<meta.schema plugin="org.eclipse.cdt.core" id="PDOMProvider" name="%PDOMProviderName"/>
|
||||||
</appInfo>
|
</appInfo>
|
||||||
<documentation>
|
<documentation>
|
||||||
This extension point provides the database to be used for the Persistent DOM.
|
[Enter description of this extension point.]
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
|
|
||||||
|
@ -44,20 +44,27 @@
|
||||||
|
|
||||||
<element name="provider">
|
<element name="provider">
|
||||||
<complexType>
|
<complexType>
|
||||||
<attribute name="id" type="string" use="required">
|
<attribute name="id" type="string">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
|
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="class" type="string">
|
<attribute name="name" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="class" type="string" use="required">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
|
|
||||||
</documentation>
|
</documentation>
|
||||||
<appInfo>
|
<appInfo>
|
||||||
<meta.attribute kind="java" basedOn="org.eclipse.cdt.core.pdom.IPDOMDatabaseProvider"/>
|
<meta.attribute kind="java" basedOn="org.eclipse.cdt.core.dom.IPDOMProvider"/>
|
||||||
</appInfo>
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
|
@ -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);
|
||||||
|
|
||||||
|
}
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IASTServiceProvider;
|
import org.eclipse.cdt.core.dom.IASTServiceProvider;
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
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.IParserConfiguration;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
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.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IStorage;
|
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;
|
import org.eclipse.core.runtime.content.IContentType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,16 +57,43 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
||||||
|
|
||||||
protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
|
protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
|
||||||
protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION = new GPPScannerExtensionConfiguration();
|
protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION = new GPPScannerExtensionConfiguration();
|
||||||
private static final String[] dialects = { "C99", //$NON-NLS-1$
|
private static final String[] dialects = {
|
||||||
|
"C99", //$NON-NLS-1$
|
||||||
"C++98", //$NON-NLS-1$
|
"C++98", //$NON-NLS-1$
|
||||||
"GNUC", //$NON-NLS-1$
|
"GNUC", //$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)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.IASTServiceProvider#getName()
|
* @see org.eclipse.cdt.core.dom.IASTServiceProvider#getName()
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
// TODO is this a name or an id?
|
||||||
return "CDT AST Service"; //$NON-NLS-1$
|
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 );
|
parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), config );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Parse
|
||||||
IASTTranslationUnit tu = parser.parse();
|
IASTTranslationUnit tu = parser.parse();
|
||||||
|
// Set the PDOM if we can find one
|
||||||
|
tu.setPDOM(getPDOMProvider().getPDOM(project));
|
||||||
return tu;
|
return tu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue