mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 14:15:23 +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.IBinaryFile;
|
||||
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.CoreModel;
|
||||
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.ISafeRunnable;
|
||||
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.IContentTypeChangeListener;
|
||||
|
||||
public class CModelManager implements IResourceChangeListener, ICDescriptorListener, IContentTypeChangeListener {
|
||||
|
||||
|
@ -1112,11 +1113,17 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
return this.fDeltaProcessor.indexManager;
|
||||
}
|
||||
|
||||
|
||||
public void deleting(IProject project) {
|
||||
// discard all indexing jobs for this project
|
||||
// discard all indexing jobs for this project
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.IBinding;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -27,4 +28,10 @@ public interface IPDOM {
|
|||
|
||||
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.model.IElementChangedListener;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
|
@ -35,6 +36,13 @@ public interface IPDOMProvider {
|
|||
*/
|
||||
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
|
||||
* events that require the PDOM be updated.
|
||||
|
@ -42,5 +50,5 @@ public interface IPDOMProvider {
|
|||
* @return the element changed listener
|
||||
*/
|
||||
public IElementChangedListener getElementChangedListener();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -66,6 +66,10 @@ public class PDOM {
|
|||
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
|
||||
* change events.
|
||||
|
|
|
@ -75,7 +75,7 @@ public class ParserUtil
|
|||
{
|
||||
// this is the file for sure
|
||||
// check the working copy
|
||||
if( workingCopies.hasNext() )
|
||||
if( workingCopies != null && workingCopies.hasNext() )
|
||||
{
|
||||
char[] buffer = findWorkingCopy( resultingResource, workingCopies );
|
||||
if( buffer != null )
|
||||
|
|
|
@ -31,4 +31,7 @@ public class NullPDOMProvider implements IPDOMProvider {
|
|||
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.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.ast.IASTFileLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
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.ParserUtil;
|
||||
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.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
|
@ -98,7 +102,12 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd
|
|||
}
|
||||
|
||||
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());
|
||||
projectName = ((ICProject)project).getElementName();
|
||||
}
|
||||
|
@ -107,15 +116,15 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
IFile resourceFile = null;
|
||||
resourceFile = fEditor.getInputFile();
|
||||
// an awful lot of cass goingo on here...
|
||||
IWorkingCopy workingCopy = (IWorkingCopy)fEditor.getInputCElement();
|
||||
IFile resourceFile = (IFile)workingCopy.getResource();
|
||||
project = new CProject(null, resourceFile.getProject());
|
||||
|
||||
IPDOM pdom = PDOM.getPDOM(resourceFile.getProject());
|
||||
try {
|
||||
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
||||
resourceFile,
|
||||
CDOM.getInstance().getCodeReaderFactory(
|
||||
CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE));
|
||||
pdom.getCodeReaderFactory(workingCopy));
|
||||
} catch (IASTServiceProvider.UnsupportedDialectException e) {
|
||||
operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue