mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 11:55:40 +02:00
A little more PDOM magic. Project deletes, incremental parsing.
This commit is contained in:
parent
79e643ba6d
commit
cb04187d5b
7 changed files with 50 additions and 12 deletions
|
@ -34,6 +34,7 @@ import org.eclipse.cdt.core.ICExtensionReference;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||||
|
import org.eclipse.cdt.core.dom.PDOM;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||||
|
@ -63,8 +64,8 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.ISafeRunnable;
|
import org.eclipse.core.runtime.ISafeRunnable;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.content.IContentTypeManager.IContentTypeChangeListener;
|
|
||||||
import org.eclipse.core.runtime.content.IContentTypeManager.ContentTypeChangeEvent;
|
import org.eclipse.core.runtime.content.IContentTypeManager.ContentTypeChangeEvent;
|
||||||
|
import org.eclipse.core.runtime.content.IContentTypeManager.IContentTypeChangeListener;
|
||||||
|
|
||||||
public class CModelManager implements IResourceChangeListener, ICDescriptorListener, IContentTypeChangeListener {
|
public class CModelManager implements IResourceChangeListener, ICDescriptorListener, IContentTypeChangeListener {
|
||||||
|
|
||||||
|
@ -1112,10 +1113,16 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
return this.fDeltaProcessor.indexManager;
|
return this.fDeltaProcessor.indexManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void deleting(IProject project) {
|
public void deleting(IProject project) {
|
||||||
// discard all indexing jobs for this project
|
// discard all indexing jobs for this project
|
||||||
this.getIndexManager().discardJobs(project.getName());
|
this.getIndexManager().discardJobs(project.getName());
|
||||||
|
// delete the PDOM for this project
|
||||||
|
try {
|
||||||
|
PDOM.deletePDOM(project);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
// stop the binary runner for this project
|
||||||
removeBinaryRunner(project);
|
removeBinaryRunner(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.core.dom;
|
||||||
|
|
||||||
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.model.IWorkingCopy;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,4 +28,10 @@ public interface IPDOM {
|
||||||
|
|
||||||
public IASTName[] getDeclarations(IBinding binding) throws CoreException;
|
public IASTName[] getDeclarations(IBinding binding) throws CoreException;
|
||||||
|
|
||||||
|
public void delete() throws CoreException;
|
||||||
|
|
||||||
|
public ICodeReaderFactory getCodeReaderFactory();
|
||||||
|
|
||||||
|
public ICodeReaderFactory getCodeReaderFactory(IWorkingCopy root);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ 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.cdt.core.model.IElementChangedListener;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -35,6 +36,13 @@ public interface IPDOMProvider {
|
||||||
*/
|
*/
|
||||||
public IPDOM getPDOM(IProject project);
|
public IPDOM getPDOM(IProject project);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the PDOM for the given project.
|
||||||
|
*
|
||||||
|
* @param project
|
||||||
|
*/
|
||||||
|
public void deletePDOM(IProject project) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the element changed listener that will handled change
|
* Return the element changed listener that will handled change
|
||||||
* events that require the PDOM be updated.
|
* events that require the PDOM be updated.
|
||||||
|
|
|
@ -66,6 +66,10 @@ public class PDOM {
|
||||||
return getPDOMProvider().getPDOM(project);
|
return getPDOMProvider().getPDOM(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void deletePDOM(IProject project) throws CoreException {
|
||||||
|
getPDOMProvider().getPDOM(project).delete();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Startup the PDOM. This mainly sets us up to handle model
|
* Startup the PDOM. This mainly sets us up to handle model
|
||||||
* change events.
|
* change events.
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class ParserUtil
|
||||||
{
|
{
|
||||||
// this is the file for sure
|
// this is the file for sure
|
||||||
// check the working copy
|
// check the working copy
|
||||||
if( workingCopies.hasNext() )
|
if( workingCopies != null && workingCopies.hasNext() )
|
||||||
{
|
{
|
||||||
char[] buffer = findWorkingCopy( resultingResource, workingCopies );
|
char[] buffer = findWorkingCopy( resultingResource, workingCopies );
|
||||||
if( buffer != null )
|
if( buffer != null )
|
||||||
|
|
|
@ -31,4 +31,7 @@ public class NullPDOMProvider implements IPDOMProvider {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deletePDOM(IProject project) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,15 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.CDOM;
|
import org.eclipse.cdt.core.dom.CDOM;
|
||||||
import org.eclipse.cdt.core.dom.IASTServiceProvider;
|
import org.eclipse.cdt.core.dom.IASTServiceProvider;
|
||||||
|
import org.eclipse.cdt.core.dom.IPDOM;
|
||||||
|
import org.eclipse.cdt.core.dom.PDOM;
|
||||||
import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
|
import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
@ -36,6 +39,7 @@ import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
|
||||||
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||||
|
@ -98,7 +102,12 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd
|
||||||
}
|
}
|
||||||
|
|
||||||
if (project instanceof ICProject) {
|
if (project instanceof ICProject) {
|
||||||
tu = CDOM.getInstance().getASTService().getTranslationUnit(input.getStorage(), ((ICProject)project).getProject());
|
IProject p = ((ICProject)project).getProject();
|
||||||
|
IPDOM pdom = PDOM.getPDOM(p);
|
||||||
|
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
||||||
|
input.getStorage(),
|
||||||
|
p,
|
||||||
|
pdom.getCodeReaderFactory());
|
||||||
lang = DOMSearchUtil.getLanguage(input.getStorage().getFullPath(), ((ICProject)project).getProject());
|
lang = DOMSearchUtil.getLanguage(input.getStorage().getFullPath(), ((ICProject)project).getProject());
|
||||||
projectName = ((ICProject)project).getElementName();
|
projectName = ((ICProject)project).getElementName();
|
||||||
}
|
}
|
||||||
|
@ -107,15 +116,15 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IFile resourceFile = null;
|
// an awful lot of cass goingo on here...
|
||||||
resourceFile = fEditor.getInputFile();
|
IWorkingCopy workingCopy = (IWorkingCopy)fEditor.getInputCElement();
|
||||||
|
IFile resourceFile = (IFile)workingCopy.getResource();
|
||||||
project = new CProject(null, resourceFile.getProject());
|
project = new CProject(null, resourceFile.getProject());
|
||||||
|
IPDOM pdom = PDOM.getPDOM(resourceFile.getProject());
|
||||||
try {
|
try {
|
||||||
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
||||||
resourceFile,
|
resourceFile,
|
||||||
CDOM.getInstance().getCodeReaderFactory(
|
pdom.getCodeReaderFactory(workingCopy));
|
||||||
CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE));
|
|
||||||
} catch (IASTServiceProvider.UnsupportedDialectException e) {
|
} catch (IASTServiceProvider.UnsupportedDialectException e) {
|
||||||
operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
|
operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue