mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Created the PDOM Updator which directly hooks up as a resource change listener, thus bypassing all the madness with the indexer.
This commit is contained in:
parent
e453669717
commit
ee2db04840
5 changed files with 101 additions and 32 deletions
|
@ -24,6 +24,7 @@ import java.util.MissingResourceException;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.CDOM;
|
import org.eclipse.cdt.core.dom.CDOM;
|
||||||
|
import org.eclipse.cdt.core.dom.PDOM;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||||
|
@ -291,6 +292,9 @@ public class CCorePlugin extends Plugin {
|
||||||
|
|
||||||
//Fired up the indexer
|
//Fired up the indexer
|
||||||
fCoreModel.startIndexing();
|
fCoreModel.startIndexing();
|
||||||
|
|
||||||
|
// Fire up the PDOM
|
||||||
|
PDOM.startup();
|
||||||
|
|
||||||
// Set the default for using the structual parse mode to build the CModel
|
// Set the default for using the structual parse mode to build the CModel
|
||||||
getPluginPreferences().setDefault(PREF_USE_STRUCTURAL_PARSE_MODE, false);
|
getPluginPreferences().setDefault(PREF_USE_STRUCTURAL_PARSE_MODE, false);
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.core.dom;
|
package org.eclipse.cdt.core.dom;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,5 +34,13 @@ public interface IPDOMProvider {
|
||||||
* @return the PDOM for the project
|
* @return the PDOM for the project
|
||||||
*/
|
*/
|
||||||
public IPDOM getPDOM(IProject project);
|
public IPDOM getPDOM(IProject project);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the element changed listener that will handled change
|
||||||
|
* events that require the PDOM be updated.
|
||||||
|
*
|
||||||
|
* @return the element changed listener
|
||||||
|
*/
|
||||||
|
public IElementChangedListener getElementChangedListener();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.model.CoreModel;
|
||||||
|
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.NullPDOMProvider;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Doug Schaefer
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PDOM {
|
||||||
|
|
||||||
|
private static IPDOMProvider pdomProvider;
|
||||||
|
|
||||||
|
private static synchronized void initPDOMProvider() {
|
||||||
|
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;
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Couldn't find one
|
||||||
|
pdomProvider = new NullPDOMProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IPDOMProvider getPDOMProvider() {
|
||||||
|
if (pdomProvider == null) {
|
||||||
|
initPDOMProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
return pdomProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the PDOM for the given project.
|
||||||
|
*
|
||||||
|
* @param project
|
||||||
|
* @return the PDOM for the project
|
||||||
|
*/
|
||||||
|
public static IPDOM getPDOM(IProject project) {
|
||||||
|
return getPDOMProvider().getPDOM(project);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Startup the PDOM. This mainly sets us up to handle model
|
||||||
|
* change events.
|
||||||
|
*/
|
||||||
|
public static void startup() {
|
||||||
|
IElementChangedListener listener = getPDOMProvider().getElementChangedListener();
|
||||||
|
if (listener != null) {
|
||||||
|
CoreModel.getDefault().addElementChangedListener(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -13,8 +13,8 @@ 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.PDOM;
|
||||||
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;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
|
@ -43,11 +43,6 @@ 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,31 +59,6 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
||||||
"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()
|
||||||
*/
|
*/
|
||||||
|
@ -201,7 +171,7 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
||||||
// Parse
|
// Parse
|
||||||
IASTTranslationUnit tu = parser.parse();
|
IASTTranslationUnit tu = parser.parse();
|
||||||
// Set the PDOM if we can find one
|
// Set the PDOM if we can find one
|
||||||
tu.setPDOM(getPDOMProvider().getPDOM(project));
|
tu.setPDOM(PDOM.getPDOM(project));
|
||||||
return tu;
|
return tu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IPDOM;
|
import org.eclipse.cdt.core.dom.IPDOM;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMProvider;
|
import org.eclipse.cdt.core.dom.IPDOMProvider;
|
||||||
|
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,4 +26,9 @@ public class NullPDOMProvider implements IPDOMProvider {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IElementChangedListener getElementChangedListener() {
|
||||||
|
// here too
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue