mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Hooked up the Fast indexer so it should work now. Also changed a few interfaces so that they use ICProject instead of IProject. We should be sticking to the CModel as much as possible so we can leverage CDTisms like source folders and path entry info.
This commit is contained in:
parent
2ff46eeeab
commit
44c81e1db6
30 changed files with 482 additions and 623 deletions
|
@ -13,9 +13,6 @@ package org.eclipse.cdt.core.model;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
|
||||
/**
|
||||
|
@ -66,25 +63,8 @@ public interface ILanguage extends IAdaptable {
|
|||
* @param style
|
||||
* @return
|
||||
*/
|
||||
public IASTTranslationUnit getTranslationUnit(IFile file, int style);
|
||||
public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, int style);
|
||||
|
||||
/**
|
||||
* Create the AST for the given external file with the given style.
|
||||
*
|
||||
* @param file
|
||||
* @param style
|
||||
* @return
|
||||
*/
|
||||
public IASTTranslationUnit getTranslationUnit(IStorage file, IProject project, int style);
|
||||
|
||||
/**
|
||||
* Return the ASt for the given working copy
|
||||
* @param workingCopy
|
||||
* @param style
|
||||
* @return
|
||||
*/
|
||||
public IASTTranslationUnit getTranslationUnit(IWorkingCopy workingCopy, int style);
|
||||
|
||||
/**
|
||||
* Return the AST Completion Node for the given working copy at the given
|
||||
* offset.
|
||||
|
|
|
@ -1136,12 +1136,6 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
public void deleting(IProject project) {
|
||||
// discard all indexing jobs for this project
|
||||
this.getIndexManager().discardJobs(project.getName());
|
||||
// delete the PDOM for this project
|
||||
try {
|
||||
CCorePlugin.getPDOMManager().deletePDOM(project);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
// stop the binary runner for this project
|
||||
removeBinaryRunner(project);
|
||||
}
|
||||
|
|
|
@ -697,7 +697,7 @@ public class CProject extends Openable implements ICProject {
|
|||
}
|
||||
|
||||
public IPDOM getIndex() {
|
||||
return CCorePlugin.getPDOMManager().getPDOM(getProject());
|
||||
return CCorePlugin.getPDOMManager().getPDOM(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,4 +35,7 @@ public interface IPDOM extends IAdaptable {
|
|||
|
||||
public ICodeReaderFactory getCodeReaderFactory(IWorkingCopy root);
|
||||
|
||||
public IPDOMIndexer getIndexer();
|
||||
public void setIndexer(IPDOMIndexer indexer) throws CoreException;
|
||||
|
||||
}
|
||||
|
|
|
@ -11,16 +11,20 @@
|
|||
|
||||
package org.eclipse.cdt.core.dom;
|
||||
|
||||
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public interface IPDOMIndexer extends IElementChangedListener {
|
||||
public interface IPDOMIndexer {
|
||||
|
||||
public void setPDOM(IPDOM pdom);
|
||||
|
||||
public void handleDelta(ICElementDelta delta);
|
||||
|
||||
public void reindex();
|
||||
public void reindex() throws CoreException;
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
package org.eclipse.cdt.core.dom;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -21,13 +21,14 @@ import org.eclipse.core.runtime.CoreException;
|
|||
public interface IPDOMManager {
|
||||
|
||||
// Getting and deleting a PDOM for a project
|
||||
public IPDOM getPDOM(IProject project);
|
||||
public void deletePDOM(IProject project) throws CoreException;
|
||||
public IPDOM getPDOM(ICProject project);
|
||||
public void deletePDOM(ICProject project) throws CoreException;
|
||||
|
||||
// Getting and setting indexer Ids
|
||||
public String getDefaultIndexerId();
|
||||
public void setDefaultIndexerId(String indexerId);
|
||||
|
||||
public String getIndexerId(IProject project);
|
||||
public void setIndexerId(IProject project, String indexerId);
|
||||
public String getIndexerId(ICProject project) throws CoreException;
|
||||
public void setIndexerId(ICProject project, String indexerId) throws CoreException;
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IContributedModelBuilder;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
|
@ -42,7 +43,6 @@ import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkageFactory;
|
|||
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.PlatformObject;
|
||||
|
||||
/**
|
||||
|
@ -66,26 +66,15 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
|
|||
return super.getAdapter(adapter);
|
||||
}
|
||||
|
||||
public IASTTranslationUnit getTranslationUnit(IStorage file, IProject project, int style) {
|
||||
return getTranslationUnit(file.getFullPath().toOSString(), project, project, style, null);
|
||||
}
|
||||
|
||||
public IASTTranslationUnit getTranslationUnit(IFile file, int style) {
|
||||
return getTranslationUnit(file.getLocation().toOSString(), file.getProject(), file, style, null);
|
||||
}
|
||||
|
||||
public IASTTranslationUnit getTranslationUnit(IWorkingCopy workingCopy, int style) {
|
||||
IFile file = (IFile)workingCopy.getResource();
|
||||
String path = file.getLocation().toOSString();
|
||||
CodeReader reader = new CodeReader(path, workingCopy.getContents());
|
||||
return getTranslationUnit(path, file.getProject(), file, style, reader);
|
||||
}
|
||||
|
||||
protected IASTTranslationUnit getTranslationUnit(String path, IProject project, IResource infoResource, int style,
|
||||
CodeReader reader) {
|
||||
public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, int style) {
|
||||
IResource resource = file.getResource();
|
||||
ICProject project = file.getCProject();
|
||||
IProject rproject = project.getProject();
|
||||
|
||||
IScannerInfo scanInfo = null;
|
||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
|
||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject);
|
||||
if (provider != null){
|
||||
IResource infoResource = resource != null ? resource : rproject;
|
||||
IScannerInfo buildScanInfo = provider.getScannerInformation(infoResource);
|
||||
if (buildScanInfo != null)
|
||||
scanInfo = buildScanInfo;
|
||||
|
@ -102,12 +91,19 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
|
|||
else
|
||||
fileCreator = SavedCodeReaderFactory.getInstance();
|
||||
|
||||
if (reader == null) {
|
||||
CodeReader reader;
|
||||
if (file instanceof IWorkingCopy) {
|
||||
// get the working copy contents
|
||||
IFile rfile = (IFile)file.getResource();
|
||||
reader = new CodeReader(rfile.getLocation().toOSString(), file.getContents());
|
||||
} else {
|
||||
String path = file.getPath().toOSString();
|
||||
reader = fileCreator.createCodeReaderForTranslationUnit(path);
|
||||
if( reader == null )
|
||||
return null;
|
||||
if (reader == null)
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
IScannerExtensionConfiguration scannerExtensionConfiguration =
|
||||
scannerExtensionConfiguration = C_GNU_SCANNER_EXTENSION;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IContributedModelBuilder;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
|
@ -42,7 +43,6 @@ import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory;
|
|||
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.PlatformObject;
|
||||
|
||||
/**
|
||||
|
@ -65,26 +65,15 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
|
|||
return super.getAdapter(adapter);
|
||||
}
|
||||
|
||||
public IASTTranslationUnit getTranslationUnit(IStorage file, IProject project, int style) {
|
||||
return getTranslationUnit(file.getFullPath().toOSString(), project, project, style, null);
|
||||
}
|
||||
|
||||
public IASTTranslationUnit getTranslationUnit(IFile file, int style) {
|
||||
return getTranslationUnit(file.getLocation().toOSString(), file.getProject(), file, style, null);
|
||||
}
|
||||
|
||||
public IASTTranslationUnit getTranslationUnit(IWorkingCopy workingCopy, int style) {
|
||||
IFile file = (IFile)workingCopy.getResource();
|
||||
String path = file.getLocation().toOSString();
|
||||
CodeReader reader = new CodeReader(path, workingCopy.getContents());
|
||||
return getTranslationUnit(path, file.getProject(), file, style, reader);
|
||||
}
|
||||
|
||||
protected IASTTranslationUnit getTranslationUnit(String path, IProject project, IResource infoResource, int style,
|
||||
CodeReader reader) {
|
||||
public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, int style) {
|
||||
IResource resource = file.getResource();
|
||||
ICProject project = file.getCProject();
|
||||
IProject rproject = project.getProject();
|
||||
|
||||
IScannerInfo scanInfo = null;
|
||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
|
||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject);
|
||||
if (provider != null){
|
||||
IResource infoResource = resource != null ? resource : rproject;
|
||||
IScannerInfo buildScanInfo = provider.getScannerInformation(infoResource);
|
||||
if (buildScanInfo != null)
|
||||
scanInfo = buildScanInfo;
|
||||
|
@ -100,17 +89,28 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
|
|||
fileCreator = new PDOMCodeReaderFactory(pdom);
|
||||
else
|
||||
fileCreator = SavedCodeReaderFactory.getInstance();
|
||||
|
||||
if (reader == null) {
|
||||
|
||||
IFile rfile = (IFile)file.getResource();
|
||||
CodeReader reader;
|
||||
if (file instanceof IWorkingCopy) {
|
||||
// get the working copy contents
|
||||
reader = new CodeReader(rfile.getLocation().toOSString(), file.getContents());
|
||||
} else {
|
||||
String path
|
||||
= rfile != null
|
||||
? rfile.getLocation().toOSString()
|
||||
: file.getPath().toOSString();
|
||||
reader = fileCreator.createCodeReaderForTranslationUnit(path);
|
||||
if( reader == null )
|
||||
if (reader == null)
|
||||
return null;
|
||||
}
|
||||
|
||||
IScannerExtensionConfiguration scannerExtensionConfiguration = CPP_GNU_SCANNER_EXTENSION;
|
||||
|
||||
IScannerExtensionConfiguration scannerExtensionConfiguration =
|
||||
scannerExtensionConfiguration = CPP_GNU_SCANNER_EXTENSION;
|
||||
|
||||
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
||||
ParserLanguage.CPP, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, fileCreator );
|
||||
//assume GCC
|
||||
ISourceCodeParser parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(),
|
||||
new GPPParserExtensionConfiguration() );
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
|
|||
|
||||
if ((style & AST_USE_INDEX) != 0)
|
||||
ast.setIndex(pdom);
|
||||
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
|
@ -50,7 +51,7 @@ import org.eclipse.core.runtime.jobs.Job;
|
|||
*/
|
||||
public class PDOM extends PlatformObject implements IPDOM {
|
||||
|
||||
private final IProject project;
|
||||
private final ICProject project;
|
||||
private IPDOMIndexer indexer;
|
||||
|
||||
private final IPath dbPath;
|
||||
|
@ -66,16 +67,18 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
private static final QualifiedName dbNameProperty
|
||||
= new QualifiedName(CCorePlugin.PLUGIN_ID, "dbName"); //$NON-NLS-1$
|
||||
|
||||
public PDOM(IProject project, IPDOMIndexer indexer) throws CoreException {
|
||||
public PDOM(ICProject project, IPDOMIndexer indexer) throws CoreException {
|
||||
this.project = project;
|
||||
this.indexer = indexer;
|
||||
indexer.setPDOM(this);
|
||||
|
||||
// Load up the database
|
||||
String dbName = project.getPersistentProperty(dbNameProperty);
|
||||
IProject rproject = project.getProject();
|
||||
String dbName = rproject.getPersistentProperty(dbNameProperty);
|
||||
if (dbName == null) {
|
||||
dbName = project.getName() + "_"
|
||||
dbName = project.getElementName() + "_"
|
||||
+ System.currentTimeMillis() + ".pdom";
|
||||
project.setPersistentProperty(dbNameProperty, dbName);
|
||||
rproject.setPersistentProperty(dbNameProperty, dbName);
|
||||
}
|
||||
dbPath = CCorePlugin.getDefault().getStateLocation().append(dbName);
|
||||
db = new Database(dbPath.toOSString(), VERSION);
|
||||
|
@ -90,7 +93,7 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
return super.getAdapter(adapter);
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
public ICProject getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
|
@ -98,6 +101,16 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
return indexer;
|
||||
}
|
||||
|
||||
public void setIndexer(IPDOMIndexer indexer) throws CoreException {
|
||||
// Force a reindex if indexer changes
|
||||
boolean reindex = indexer != null && this.indexer != indexer;
|
||||
this.indexer = indexer;
|
||||
indexer.setPDOM(this);
|
||||
|
||||
if (reindex)
|
||||
indexer.reindex();
|
||||
}
|
||||
|
||||
public static interface IListener {
|
||||
public void handleChange(PDOM pdom);
|
||||
}
|
||||
|
@ -149,7 +162,7 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
if (linkage == null)
|
||||
return;
|
||||
|
||||
IASTTranslationUnit ast = language.getTranslationUnit((IFile)tu.getResource(),
|
||||
IASTTranslationUnit ast = language.getASTTranslationUnit(tu,
|
||||
ILanguage.AST_USE_INDEX |
|
||||
ILanguage.AST_SKIP_INDEXED_HEADERS |
|
||||
ILanguage.AST_SKIP_IF_NO_BUILD_INFO);
|
||||
|
|
|
@ -18,6 +18,9 @@ import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
|||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ProjectScope;
|
||||
|
@ -28,8 +31,6 @@ import org.eclipse.core.runtime.IStatus;
|
|||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
|
||||
import org.eclipse.core.runtime.jobs.IJobChangeListener;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.IPreferencesService;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
|
@ -42,20 +43,19 @@ import org.osgi.service.prefs.BackingStoreException;
|
|||
*
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public class PDOMManager implements IPDOMManager, IElementChangedListener, IJobChangeListener {
|
||||
public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
||||
|
||||
private PDOMUpdator currJob;
|
||||
|
||||
private static final QualifiedName pdomProperty
|
||||
= new QualifiedName(CCorePlugin.PLUGIN_ID, "pdom"); //$NON-NLS-1$
|
||||
|
||||
public IPDOM getPDOM(IProject project) {
|
||||
public IPDOM getPDOM(ICProject project) {
|
||||
try {
|
||||
IPDOM pdom = (IPDOM)project.getSessionProperty(pdomProperty);
|
||||
IProject rproject = project.getProject();
|
||||
IPDOM pdom = (IPDOM)rproject.getSessionProperty(pdomProperty);
|
||||
|
||||
if (pdom == null) {
|
||||
pdom = new PDOM(project, createIndexer(project));
|
||||
project.setSessionProperty(pdomProperty, pdom);
|
||||
pdom = new PDOM(project, createIndexer(getIndexerId(project)));
|
||||
rproject.setSessionProperty(pdomProperty, pdom);
|
||||
}
|
||||
|
||||
return pdom;
|
||||
|
@ -70,36 +70,31 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener, IJobC
|
|||
if (event.getType() != ElementChangedEvent.POST_CHANGE)
|
||||
return;
|
||||
|
||||
// TODO turn off indexing for now.
|
||||
return;
|
||||
// currJob = new PDOMUpdator(event.getDelta(), currJob);
|
||||
// currJob.addJobChangeListener(this);
|
||||
// currJob.schedule();
|
||||
// Walk the delta sending the subtrees to the appropriate indexers
|
||||
processDelta(event.getDelta());
|
||||
}
|
||||
|
||||
public void aboutToRun(IJobChangeEvent event) {
|
||||
|
||||
private void processDelta(ICElementDelta delta) {
|
||||
int type = delta.getElement().getElementType();
|
||||
switch (type) {
|
||||
case ICElement.C_MODEL:
|
||||
// Loop through the children
|
||||
ICElementDelta[] children = delta.getAffectedChildren();
|
||||
for (int i = 0; i < children.length; ++i)
|
||||
processDelta(children[i]);
|
||||
break;
|
||||
case ICElement.C_PROJECT:
|
||||
// Find the appropriate indexer and pass the delta on
|
||||
ICProject project = (ICProject)delta.getElement();
|
||||
IPDOM pdom = getPDOM(project);
|
||||
pdom.getIndexer().handleDelta(delta);
|
||||
}
|
||||
}
|
||||
|
||||
public void awake(IJobChangeEvent event) {
|
||||
}
|
||||
|
||||
public synchronized void done(IJobChangeEvent event) {
|
||||
if (currJob == event.getJob())
|
||||
currJob = null;
|
||||
}
|
||||
|
||||
public void running(IJobChangeEvent event) {
|
||||
}
|
||||
|
||||
public void scheduled(IJobChangeEvent event) {
|
||||
}
|
||||
|
||||
public void sleeping(IJobChangeEvent event) {
|
||||
}
|
||||
|
||||
public void deletePDOM(IProject project) throws CoreException {
|
||||
IPDOM pdom = (IPDOM)project.getSessionProperty(pdomProperty);
|
||||
project.setSessionProperty(pdomProperty, null);
|
||||
|
||||
public void deletePDOM(ICProject project) throws CoreException {
|
||||
IProject rproject = project.getProject();
|
||||
IPDOM pdom = (IPDOM)rproject.getSessionProperty(pdomProperty);
|
||||
rproject.setSessionProperty(pdomProperty, null);
|
||||
pdom.delete();
|
||||
}
|
||||
|
||||
|
@ -127,8 +122,8 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener, IJobC
|
|||
}
|
||||
}
|
||||
|
||||
public String getIndexerId(IProject project) {
|
||||
IEclipsePreferences prefs = new ProjectScope(project).getNode(CCorePlugin.PLUGIN_ID);
|
||||
public String getIndexerId(ICProject project) throws CoreException {
|
||||
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID);
|
||||
if (prefs == null)
|
||||
return getDefaultIndexerId();
|
||||
|
||||
|
@ -136,7 +131,7 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener, IJobC
|
|||
if (indexerId == null) {
|
||||
// See if it is in the ICDescriptor
|
||||
try {
|
||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(project, true);
|
||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(project.getProject(), true);
|
||||
ICExtensionReference[] ref = desc.get(CCorePlugin.INDEXER_UNIQ_ID);
|
||||
if (ref != null && ref.length > 0) {
|
||||
indexerId = ref[0].getID();
|
||||
|
@ -153,8 +148,8 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener, IJobC
|
|||
return indexerId;
|
||||
}
|
||||
|
||||
public void setIndexerId(IProject project, String indexerId) {
|
||||
IEclipsePreferences prefs = new ProjectScope(project).getNode(CCorePlugin.PLUGIN_ID);
|
||||
public void setIndexerId(ICProject project, String indexerId) throws CoreException {
|
||||
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID);
|
||||
if (prefs == null)
|
||||
return; // TODO why would this be null?
|
||||
|
||||
|
@ -163,11 +158,12 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener, IJobC
|
|||
prefs.flush();
|
||||
} catch (BackingStoreException e) {
|
||||
}
|
||||
|
||||
IPDOM pdom = getPDOM(project);
|
||||
pdom.setIndexer(createIndexer(indexerId));
|
||||
}
|
||||
|
||||
private IPDOMIndexer createIndexer(IProject project) throws CoreException {
|
||||
String indexerId = getIndexerId(project);
|
||||
|
||||
private IPDOMIndexer createIndexer(String indexerId) throws CoreException {
|
||||
// Look up in extension point
|
||||
IExtension indexerExt = Platform.getExtensionRegistry()
|
||||
.getExtension(CCorePlugin.INDEXER_UNIQ_ID, indexerId);
|
||||
|
|
|
@ -1,244 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* 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.pdom;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceProxy;
|
||||
import org.eclipse.core.resources.IResourceProxyVisitor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.content.IContentType;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMUpdator extends Job {
|
||||
|
||||
private PDOMUpdator prevJob;
|
||||
private ICElementDelta delta;
|
||||
private ICProject project;
|
||||
private List addedTUs;
|
||||
private List changedTUs;
|
||||
private List removedTUs;
|
||||
|
||||
public PDOMUpdator(ICElementDelta delta, PDOMUpdator prevJob) {
|
||||
super("PDOM Updator");
|
||||
this.prevJob = prevJob;
|
||||
this.delta = delta;
|
||||
}
|
||||
|
||||
public PDOMUpdator(ICProject project, PDOMUpdator prevJob) {
|
||||
super("PDOM Project Updator");
|
||||
this.prevJob = prevJob;
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
if (prevJob != null)
|
||||
try {
|
||||
prevJob.join();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
String taskName = null;
|
||||
if (delta != null) {
|
||||
processDelta(delta);
|
||||
taskName = "Update PDOM";
|
||||
}
|
||||
if (project != null) {
|
||||
processNewProject(project);
|
||||
taskName = "Rebuild PDOM";
|
||||
}
|
||||
|
||||
int count
|
||||
= (addedTUs != null ? addedTUs.size() : 0)
|
||||
+ (changedTUs != null ? changedTUs.size() : 0)
|
||||
+ (removedTUs != null ? removedTUs.size() : 0);
|
||||
|
||||
if (taskName == null || count == 0)
|
||||
return Status.OK_STATUS;
|
||||
|
||||
monitor.beginTask(taskName, count);
|
||||
|
||||
if (addedTUs != null)
|
||||
for (Iterator i = addedTUs.iterator(); i.hasNext();) {
|
||||
if (monitor.isCanceled())
|
||||
return Status.CANCEL_STATUS;
|
||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||
monitor.subTask(String.valueOf(count--)
|
||||
+" files remaining - "
|
||||
+ tu.getPath().toString());
|
||||
processAddedTU(tu);
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
if (changedTUs != null)
|
||||
for (Iterator i = changedTUs.iterator(); i.hasNext();) {
|
||||
if (monitor.isCanceled())
|
||||
return Status.CANCEL_STATUS;
|
||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||
monitor.subTask(String.valueOf(count--)
|
||||
+" files remaining - "
|
||||
+ tu.getPath().toString());
|
||||
processChangedTU(tu);
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
if (removedTUs != null)
|
||||
for (Iterator i = removedTUs.iterator(); i.hasNext();) {
|
||||
if (monitor.isCanceled())
|
||||
return Status.CANCEL_STATUS;
|
||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||
monitor.subTask(String.valueOf(count--)
|
||||
+" files remaining - "
|
||||
+ tu.getPath().toString());
|
||||
processRemovedTU(tu);
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/pdomtimings"); //$NON-NLS-1$
|
||||
if (showTimings!= null)
|
||||
if (showTimings.equalsIgnoreCase("true")) //$NON-NLS-1$
|
||||
System.out.println("Updator Time: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
|
||||
|
||||
return Status.OK_STATUS;
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return e.getStatus();
|
||||
}
|
||||
}
|
||||
|
||||
private void processDelta(ICElementDelta delta) {
|
||||
// First make sure this project is PDOMable
|
||||
ICElement element = delta.getElement();
|
||||
if (element instanceof ICProject && CCorePlugin.getPDOMManager().getPDOM(((ICProject)element).getProject()) == null)
|
||||
return;
|
||||
|
||||
// process the children first
|
||||
ICElementDelta[] children = delta.getAffectedChildren();
|
||||
for (int i = 0; i < children.length; ++i)
|
||||
processDelta(children[i]);
|
||||
|
||||
// what have we got
|
||||
if (element.getElementType() == ICElement.C_PROJECT) {
|
||||
switch (delta.getKind()) {
|
||||
case ICElementDelta.ADDED:
|
||||
processNewProject((ICProject)element);
|
||||
break;
|
||||
}
|
||||
} else if (element.getElementType() == ICElement.C_UNIT) {
|
||||
ITranslationUnit tu = (ITranslationUnit)element;
|
||||
if (tu.isWorkingCopy())
|
||||
// Don't care about working copies either
|
||||
return;
|
||||
|
||||
switch (delta.getKind()) {
|
||||
case ICElementDelta.ADDED:
|
||||
if (addedTUs == null)
|
||||
addedTUs = new LinkedList();
|
||||
addedTUs.add(element);
|
||||
break;
|
||||
case ICElementDelta.CHANGED:
|
||||
if (changedTUs == null)
|
||||
changedTUs = new LinkedList();
|
||||
changedTUs.add(element);
|
||||
break;
|
||||
case ICElementDelta.REMOVED:
|
||||
if (removedTUs == null)
|
||||
removedTUs = new LinkedList();
|
||||
removedTUs.add(element);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processNewProject(final ICProject project) {
|
||||
try {
|
||||
project.getProject().accept(new IResourceProxyVisitor() {
|
||||
public boolean visit(IResourceProxy proxy) throws CoreException {
|
||||
if (proxy.getType() == IResource.FILE) {
|
||||
String fileName = proxy.getName();
|
||||
IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(fileName);
|
||||
if (contentType == null)
|
||||
return true;
|
||||
String contentTypeId = contentType.getId();
|
||||
|
||||
if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(contentTypeId)
|
||||
|| CCorePlugin.CONTENT_TYPE_CSOURCE.equals(contentTypeId)) {
|
||||
if (addedTUs == null)
|
||||
addedTUs = new LinkedList();
|
||||
addedTUs.add(CoreModel.getDefault().create((IFile)proxy.requestResource()));
|
||||
}
|
||||
// TODO handle header files
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void processAddedTU(ITranslationUnit tu) throws CoreException {
|
||||
IPDOM pdom = tu.getCProject().getIndex();
|
||||
if (pdom == null || !(pdom instanceof PDOM))
|
||||
return;
|
||||
|
||||
PDOM mypdom = (PDOM)pdom;
|
||||
mypdom.addSymbols(tu);
|
||||
}
|
||||
|
||||
private void processRemovedTU(ITranslationUnit tu) throws CoreException {
|
||||
IProject project = tu.getCProject().getProject();
|
||||
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
if (pdom == null || !(pdom instanceof PDOM))
|
||||
return;
|
||||
|
||||
PDOM mypdom = (PDOM)pdom;
|
||||
mypdom.removeSymbols(tu);
|
||||
// TODO delete the file itself from the database
|
||||
// the removeSymbols only removes the names in the file
|
||||
}
|
||||
|
||||
private void processChangedTU(ITranslationUnit tu) throws CoreException {
|
||||
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(tu.getCProject().getProject());
|
||||
if (pdom == null || !(pdom instanceof PDOM))
|
||||
return;
|
||||
PDOM mypdom = (PDOM)pdom;
|
||||
|
||||
mypdom.removeSymbols(tu);
|
||||
mypdom.addSymbols(tu);
|
||||
}
|
||||
|
||||
}
|
|
@ -35,7 +35,7 @@ public class PDOMBindingAdapterFactory implements IAdapterFactory {
|
|||
IBinding binding = (IBinding)adaptableObject;
|
||||
ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
|
||||
for (int i = 0; i < projects.length; ++i) {
|
||||
IPDOM ipdom = CCorePlugin.getPDOMManager().getPDOM(projects[i].getProject());
|
||||
IPDOM ipdom = CCorePlugin.getPDOMManager().getPDOM(projects[i]);
|
||||
|
||||
if (ipdom == null || !(ipdom instanceof PDOM))
|
||||
continue;
|
||||
|
|
|
@ -11,12 +11,10 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
@ -32,32 +30,35 @@ public class PDOMFastAddTU extends Job {
|
|||
private final ITranslationUnit tu;
|
||||
private final PDOM pdom;
|
||||
|
||||
public PDOMFastAddTU(IPDOM pdom, ITranslationUnit tu) {
|
||||
super("PDOM Fast Add TU");
|
||||
this.pdom = (pdom instanceof PDOM) ? (PDOM)pdom : null;
|
||||
public PDOMFastAddTU(PDOM pdom, ITranslationUnit tu, IProgressMonitor group) {
|
||||
super("PDOM Fast Add: " + tu.getElementName());
|
||||
this.pdom = pdom;
|
||||
this.tu = tu;
|
||||
setPriority(PDOM.WRITER_PRIORITY);
|
||||
setProgressGroup(group, 1);
|
||||
}
|
||||
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
if (pdom == null)
|
||||
return Status.CANCEL_STATUS;
|
||||
|
||||
try {
|
||||
ILanguage language = tu.getLanguage();
|
||||
if (language == null)
|
||||
return Status.CANCEL_STATUS;
|
||||
|
||||
// begin the rule before the parse so that we are only parsing once at a time
|
||||
// maybe we can do more than one some day
|
||||
getJobManager().beginRule(pdom.getWriterLockRule(), monitor);
|
||||
monitor.beginTask("Adding: " + tu.getElementName(), 1);
|
||||
|
||||
// get the AST in a "Fast" way
|
||||
IASTTranslationUnit ast = language.getTranslationUnit((IFile)tu.getResource(),
|
||||
IASTTranslationUnit ast = language.getASTTranslationUnit(tu,
|
||||
ILanguage.AST_USE_INDEX |
|
||||
ILanguage.AST_SKIP_INDEXED_HEADERS |
|
||||
ILanguage.AST_SKIP_IF_NO_BUILD_INFO);
|
||||
if (ast == null)
|
||||
return Status.CANCEL_STATUS;
|
||||
|
||||
getJobManager().beginRule(pdom.getWriterLockRule(), monitor);
|
||||
pdom.addSymbols(language, ast);
|
||||
monitor.done();
|
||||
getJobManager().endRule(pdom.getWriterLockRule());
|
||||
return Status.OK_STATUS;
|
||||
} catch (CoreException e) {
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
|||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
@ -46,15 +45,16 @@ public class PDOMFastChangeTU extends Job {
|
|||
if (language == null)
|
||||
return Status.CANCEL_STATUS;
|
||||
|
||||
getJobManager().beginRule(pdom.getWriterLockRule(), monitor);
|
||||
|
||||
// get the AST in a "Fast" way
|
||||
IASTTranslationUnit ast = language.getTranslationUnit((IFile)tu.getResource(),
|
||||
IASTTranslationUnit ast = language.getASTTranslationUnit(tu,
|
||||
ILanguage.AST_USE_INDEX |
|
||||
ILanguage.AST_SKIP_INDEXED_HEADERS |
|
||||
ILanguage.AST_SKIP_IF_NO_BUILD_INFO);
|
||||
if (ast == null)
|
||||
return Status.CANCEL_STATUS;
|
||||
|
||||
getJobManager().beginRule(pdom.getWriterLockRule(), monitor);
|
||||
pdom.removeSymbols(tu);
|
||||
pdom.addSymbols(language, ast);
|
||||
getJobManager().endRule(pdom.getWriterLockRule());
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 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.pdom.indexer.fast;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceProxy;
|
||||
import org.eclipse.core.resources.IResourceProxyVisitor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.content.IContentType;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
|
||||
class PDOMFastHandleDelta extends Job {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final PDOM pdom;
|
||||
private final ICElementDelta delta;
|
||||
private final IProgressMonitor group;
|
||||
|
||||
private List addedTUs;
|
||||
private List changedTUs;
|
||||
private List removedTUs;
|
||||
|
||||
public PDOMFastHandleDelta(PDOM pdom, ICElementDelta delta, IProgressMonitor group) {
|
||||
super("Delta Handler");
|
||||
this.pdom = pdom;
|
||||
this.delta = delta;
|
||||
this.group = group;
|
||||
setProgressGroup(group, 1);
|
||||
}
|
||||
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
monitor.subTask("Delta");
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
processDelta(delta);
|
||||
|
||||
int count
|
||||
= (addedTUs != null ? addedTUs.size() : 0)
|
||||
+ (changedTUs != null ? changedTUs.size() : 0)
|
||||
+ (removedTUs != null ? removedTUs.size() : 0);
|
||||
|
||||
if (count == 0) {
|
||||
monitor.done();
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
if (addedTUs != null)
|
||||
for (Iterator i = addedTUs.iterator(); i.hasNext();) {
|
||||
if (monitor.isCanceled())
|
||||
return Status.CANCEL_STATUS;
|
||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||
monitor.subTask(String.valueOf(count--)
|
||||
+" files remaining - "
|
||||
+ tu.getPath().toString());
|
||||
new PDOMFastAddTU(pdom, tu, group).schedule();
|
||||
}
|
||||
|
||||
if (changedTUs != null)
|
||||
for (Iterator i = changedTUs.iterator(); i.hasNext();) {
|
||||
if (monitor.isCanceled())
|
||||
return Status.CANCEL_STATUS;
|
||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||
monitor.subTask(String.valueOf(count--)
|
||||
+" files remaining - "
|
||||
+ tu.getPath().toString());
|
||||
new PDOMFastChangeTU(pdom, tu).schedule();
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
if (removedTUs != null)
|
||||
for (Iterator i = removedTUs.iterator(); i.hasNext();) {
|
||||
if (monitor.isCanceled())
|
||||
return Status.CANCEL_STATUS;
|
||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||
monitor.subTask(String.valueOf(count--)
|
||||
+" files remaining - "
|
||||
+ tu.getPath().toString());
|
||||
new PDOMFastRemoveTU(pdom, tu).schedule();
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/pdomtimings"); //$NON-NLS-1$
|
||||
if (showTimings!= null)
|
||||
if (showTimings.equalsIgnoreCase("true")) //$NON-NLS-1$
|
||||
System.out.println("Updator Time: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
|
||||
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
private void processDelta(ICElementDelta delta) {
|
||||
// First make sure this project is PDOMable
|
||||
ICElement element = delta.getElement();
|
||||
if (element instanceof ICProject && CCorePlugin.getPDOMManager().getPDOM((ICProject)element) == null)
|
||||
return;
|
||||
|
||||
// process the children first
|
||||
ICElementDelta[] children = delta.getAffectedChildren();
|
||||
for (int i = 0; i < children.length; ++i)
|
||||
processDelta(children[i]);
|
||||
|
||||
// what have we got
|
||||
if (element.getElementType() == ICElement.C_PROJECT) {
|
||||
switch (delta.getKind()) {
|
||||
case ICElementDelta.ADDED:
|
||||
processNewProject((ICProject)element);
|
||||
break;
|
||||
}
|
||||
} else if (element.getElementType() == ICElement.C_UNIT) {
|
||||
ITranslationUnit tu = (ITranslationUnit)element;
|
||||
if (tu.isWorkingCopy())
|
||||
// Don't care about working copies either
|
||||
return;
|
||||
|
||||
switch (delta.getKind()) {
|
||||
case ICElementDelta.ADDED:
|
||||
if (addedTUs == null)
|
||||
addedTUs = new LinkedList();
|
||||
addedTUs.add(element);
|
||||
break;
|
||||
case ICElementDelta.CHANGED:
|
||||
if (changedTUs == null)
|
||||
changedTUs = new LinkedList();
|
||||
changedTUs.add(element);
|
||||
break;
|
||||
case ICElementDelta.REMOVED:
|
||||
if (removedTUs == null)
|
||||
removedTUs = new LinkedList();
|
||||
removedTUs.add(element);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processNewProject(final ICProject project) {
|
||||
try {
|
||||
project.getProject().accept(new IResourceProxyVisitor() {
|
||||
public boolean visit(IResourceProxy proxy) throws CoreException {
|
||||
if (proxy.getType() == IResource.FILE) {
|
||||
String fileName = proxy.getName();
|
||||
IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(fileName);
|
||||
if (contentType == null)
|
||||
return true;
|
||||
String contentTypeId = contentType.getId();
|
||||
|
||||
if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(contentTypeId)
|
||||
|| CCorePlugin.CONTENT_TYPE_CSOURCE.equals(contentTypeId)) {
|
||||
if (addedTUs == null)
|
||||
addedTUs = new LinkedList();
|
||||
addedTUs.add(CoreModel.getDefault().create((IFile)proxy.requestResource()));
|
||||
}
|
||||
// TODO handle header files
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,31 +11,14 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceProxy;
|
||||
import org.eclipse.core.resources.IResourceProxyVisitor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.content.IContentType;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
|
@ -50,170 +33,15 @@ public class PDOMFastIndexer implements IPDOMIndexer {
|
|||
this.pdom = (PDOM)pdom;
|
||||
}
|
||||
|
||||
private IProgressMonitor progressGroup;
|
||||
|
||||
private IProgressMonitor getProgressGroup() {
|
||||
if (progressGroup == null)
|
||||
progressGroup = Platform.getJobManager().createProgressGroup();
|
||||
return progressGroup;
|
||||
public void handleDelta(ICElementDelta delta) {
|
||||
IProgressMonitor group = Platform.getJobManager().createProgressGroup();
|
||||
new PDOMFastHandleDelta(pdom, delta, group).schedule();
|
||||
}
|
||||
|
||||
private class ChangeHandler extends Job {
|
||||
private final ICElementDelta delta;
|
||||
private List addedTUs;
|
||||
private List changedTUs;
|
||||
private List removedTUs;
|
||||
|
||||
public ChangeHandler(ElementChangedEvent event) {
|
||||
super("Change Handler");
|
||||
delta = event.getDelta();
|
||||
}
|
||||
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
String taskName = null;
|
||||
processDelta(delta);
|
||||
taskName = "Update PDOM";
|
||||
|
||||
// if (project != null) {
|
||||
// processNewProject(project);
|
||||
// taskName = "Rebuild PDOM";
|
||||
// }
|
||||
|
||||
int count
|
||||
= (addedTUs != null ? addedTUs.size() : 0)
|
||||
+ (changedTUs != null ? changedTUs.size() : 0)
|
||||
+ (removedTUs != null ? removedTUs.size() : 0);
|
||||
|
||||
if (taskName == null || count == 0)
|
||||
return Status.OK_STATUS;
|
||||
|
||||
monitor.beginTask(taskName, count);
|
||||
|
||||
if (addedTUs != null)
|
||||
for (Iterator i = addedTUs.iterator(); i.hasNext();) {
|
||||
if (monitor.isCanceled())
|
||||
return Status.CANCEL_STATUS;
|
||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||
monitor.subTask(String.valueOf(count--)
|
||||
+" files remaining - "
|
||||
+ tu.getPath().toString());
|
||||
new PDOMFastAddTU(pdom, tu).schedule();
|
||||
}
|
||||
|
||||
if (changedTUs != null)
|
||||
for (Iterator i = changedTUs.iterator(); i.hasNext();) {
|
||||
if (monitor.isCanceled())
|
||||
return Status.CANCEL_STATUS;
|
||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||
monitor.subTask(String.valueOf(count--)
|
||||
+" files remaining - "
|
||||
+ tu.getPath().toString());
|
||||
new PDOMFastChangeTU(pdom, tu).schedule();
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
if (removedTUs != null)
|
||||
for (Iterator i = removedTUs.iterator(); i.hasNext();) {
|
||||
if (monitor.isCanceled())
|
||||
return Status.CANCEL_STATUS;
|
||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||
monitor.subTask(String.valueOf(count--)
|
||||
+" files remaining - "
|
||||
+ tu.getPath().toString());
|
||||
new PDOMFastRemoveTU(pdom, tu).schedule();
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/pdomtimings"); //$NON-NLS-1$
|
||||
if (showTimings!= null)
|
||||
if (showTimings.equalsIgnoreCase("true")) //$NON-NLS-1$
|
||||
System.out.println("Updator Time: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
|
||||
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
private void processDelta(ICElementDelta delta) {
|
||||
// First make sure this project is PDOMable
|
||||
ICElement element = delta.getElement();
|
||||
if (element instanceof ICProject && CCorePlugin.getPDOMManager().getPDOM(((ICProject)element).getProject()) == null)
|
||||
return;
|
||||
|
||||
// process the children first
|
||||
ICElementDelta[] children = delta.getAffectedChildren();
|
||||
for (int i = 0; i < children.length; ++i)
|
||||
processDelta(children[i]);
|
||||
|
||||
// what have we got
|
||||
if (element.getElementType() == ICElement.C_PROJECT) {
|
||||
switch (delta.getKind()) {
|
||||
case ICElementDelta.ADDED:
|
||||
processNewProject((ICProject)element);
|
||||
break;
|
||||
}
|
||||
} else if (element.getElementType() == ICElement.C_UNIT) {
|
||||
ITranslationUnit tu = (ITranslationUnit)element;
|
||||
if (tu.isWorkingCopy())
|
||||
// Don't care about working copies either
|
||||
return;
|
||||
|
||||
switch (delta.getKind()) {
|
||||
case ICElementDelta.ADDED:
|
||||
if (addedTUs == null)
|
||||
addedTUs = new LinkedList();
|
||||
addedTUs.add(element);
|
||||
break;
|
||||
case ICElementDelta.CHANGED:
|
||||
if (changedTUs == null)
|
||||
changedTUs = new LinkedList();
|
||||
changedTUs.add(element);
|
||||
break;
|
||||
case ICElementDelta.REMOVED:
|
||||
if (removedTUs == null)
|
||||
removedTUs = new LinkedList();
|
||||
removedTUs.add(element);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processNewProject(final ICProject project) {
|
||||
try {
|
||||
project.getProject().accept(new IResourceProxyVisitor() {
|
||||
public boolean visit(IResourceProxy proxy) throws CoreException {
|
||||
if (proxy.getType() == IResource.FILE) {
|
||||
String fileName = proxy.getName();
|
||||
IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(fileName);
|
||||
if (contentType == null)
|
||||
return true;
|
||||
String contentTypeId = contentType.getId();
|
||||
|
||||
if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(contentTypeId)
|
||||
|| CCorePlugin.CONTENT_TYPE_CSOURCE.equals(contentTypeId)) {
|
||||
if (addedTUs == null)
|
||||
addedTUs = new LinkedList();
|
||||
addedTUs.add(CoreModel.getDefault().create((IFile)proxy.requestResource()));
|
||||
}
|
||||
// TODO handle header files
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void elementChanged(ElementChangedEvent event) {
|
||||
new ChangeHandler(event).schedule();
|
||||
}
|
||||
|
||||
public void reindex() {
|
||||
|
||||
public void reindex() throws CoreException {
|
||||
IProgressMonitor group = Platform.getJobManager().createProgressGroup();
|
||||
group.beginTask("Reindexing", 100);
|
||||
new PDOMFastReindex(pdom, group).schedule();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 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.pdom.indexer.fast;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceProxy;
|
||||
import org.eclipse.core.resources.IResourceProxyVisitor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.content.IContentType;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMFastReindex extends Job {
|
||||
|
||||
private final PDOM pdom;
|
||||
private final IProgressMonitor group;
|
||||
|
||||
public PDOMFastReindex(PDOM pdom, IProgressMonitor group) {
|
||||
super("Reindex");
|
||||
this.pdom = pdom;
|
||||
this.group = group;
|
||||
setProgressGroup(group, 1);
|
||||
}
|
||||
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
// First clear out the DB
|
||||
pdom.delete();
|
||||
|
||||
// Now repopulate it
|
||||
pdom.getProject().getProject().accept(new IResourceProxyVisitor() {
|
||||
public boolean visit(IResourceProxy proxy) throws CoreException {
|
||||
if (proxy.getType() == IResource.FILE) {
|
||||
String fileName = proxy.getName();
|
||||
IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(fileName);
|
||||
if (contentType == null)
|
||||
return true;
|
||||
String contentTypeId = contentType.getId();
|
||||
|
||||
if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(contentTypeId)
|
||||
|| CCorePlugin.CONTENT_TYPE_CSOURCE.equals(contentTypeId)) {
|
||||
new PDOMFastAddTU(pdom, (ITranslationUnit)CoreModel.getDefault().create((IFile)proxy.requestResource()), group).schedule();
|
||||
}
|
||||
// TODO handle header files
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
monitor.done();
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
}
|
|
@ -13,21 +13,30 @@ package org.eclipse.cdt.internal.core.pdom.indexer.nulli;
|
|||
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
* The Null Indexer which does nothing.
|
||||
*/
|
||||
public class PDOMNullIndexer implements IPDOMIndexer {
|
||||
|
||||
private IPDOM pdom;
|
||||
|
||||
public void setPDOM(IPDOM pdom) {
|
||||
this.pdom = pdom;
|
||||
}
|
||||
|
||||
public void reindex() {
|
||||
public void handleDelta(ICElementDelta delta) {
|
||||
}
|
||||
|
||||
public void elementChanged(ElementChangedEvent event) {
|
||||
|
||||
public void reindex() throws CoreException {
|
||||
// Just clear out the old index
|
||||
pdom.delete();
|
||||
((PDOM)pdom).fireChange();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package org.eclipse.cdt.internal.ui.actions;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMUpdator;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
@ -34,11 +34,10 @@ public class PDOMUpdateProjectAction implements IObjectActionDelegate {
|
|||
if (!(objs[i] instanceof ICProject))
|
||||
continue;
|
||||
|
||||
ICProject cproject = (ICProject)objs[i];
|
||||
ICProject project = (ICProject)objs[i];
|
||||
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
try {
|
||||
CCorePlugin.getPDOMManager().deletePDOM(cproject.getProject());
|
||||
PDOMUpdator job = new PDOMUpdator(cproject, null);
|
||||
job.schedule();
|
||||
pdom.getIndexer().reindex();
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ public class IndexView extends ViewPart implements PDOM.IListener {
|
|||
public Object[] getChildren(Object parentElement) {
|
||||
if (parentElement instanceof ICProject) {
|
||||
try {
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(((ICProject)parentElement).getProject());
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM((ICProject)parentElement);
|
||||
int n = 0;
|
||||
for (PDOMLinkage linkage = pdom.getFirstLinkage(); linkage != null; linkage = linkage.getNextLinkage())
|
||||
++n;
|
||||
|
@ -325,7 +325,7 @@ public class IndexView extends ViewPart implements PDOM.IListener {
|
|||
|
||||
public boolean hasChildren(Object element) {
|
||||
if (element instanceof ICProject) {
|
||||
IPDOM ipdom = CCorePlugin.getPDOMManager().getPDOM(((ICProject)element).getProject());
|
||||
IPDOM ipdom = CCorePlugin.getPDOMManager().getPDOM((ICProject)element);
|
||||
if (ipdom == null || !(ipdom instanceof PDOM))
|
||||
return false;
|
||||
|
||||
|
@ -429,10 +429,10 @@ public class IndexView extends ViewPart implements PDOM.IListener {
|
|||
ICModel model = CoreModel.getDefault().getCModel();
|
||||
viewer.setInput(model);
|
||||
try {
|
||||
ICProject[] cprojects = model.getCProjects();
|
||||
ICProject[] projects = model.getCProjects();
|
||||
int n = 0;
|
||||
for (int i = 0; i < cprojects.length; ++i) {
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(cprojects[i].getProject());
|
||||
for (int i = 0; i < projects.length; ++i) {
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(projects[i]);
|
||||
if (pdom != null) {
|
||||
++n;
|
||||
pdom.addListener(this);
|
||||
|
|
|
@ -12,15 +12,14 @@
|
|||
package org.eclipse.cdt.internal.ui.indexview;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMUpdator;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
|
@ -41,11 +40,10 @@ public class RebuildIndexAction extends IndexAction {
|
|||
if (!(objs[i] instanceof ICProject))
|
||||
continue;
|
||||
|
||||
ICProject cproject = (ICProject)objs[i];
|
||||
ICProject project = (ICProject)objs[i];
|
||||
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
try {
|
||||
CCorePlugin.getPDOMManager().deletePDOM(cproject.getProject());
|
||||
PDOMUpdator job = new PDOMUpdator(cproject, null);
|
||||
job.schedule();
|
||||
pdom.getIndexer().reindex();
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.List;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -93,7 +94,8 @@ public class PDOMSearchPatternQuery extends PDOMSearchQuery {
|
|||
// Not a CDT project
|
||||
return;
|
||||
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
ICProject cproject = CoreModel.getDefault().create(project);
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(cproject);
|
||||
PDOMBinding[] bindings = pdom.findBindings(pattern);
|
||||
|
||||
for (int i = 0; i < bindings.length; ++i) {
|
||||
|
|
|
@ -127,12 +127,12 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd
|
|||
IWorkingCopy workingCopy = (IWorkingCopy)fEditor.getInputCElement();
|
||||
IFile resourceFile = (IFile)workingCopy.getResource();
|
||||
project = new CProject(null, resourceFile.getProject());
|
||||
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(resourceFile.getProject());
|
||||
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(workingCopy.getCProject());
|
||||
try {
|
||||
if (pdom != null) {
|
||||
try {
|
||||
ILanguage language = workingCopy.getLanguage();
|
||||
tu = language.getTranslationUnit(workingCopy,
|
||||
tu = language.getASTTranslationUnit(workingCopy,
|
||||
ILanguage.AST_USE_INDEX |
|
||||
ILanguage.AST_SKIP_INDEXED_HEADERS);
|
||||
} catch (CoreException e) {
|
||||
|
|
|
@ -82,8 +82,7 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
|||
|
||||
IFile file = (IFile)workingCopy.getResource();
|
||||
if (file != null) {
|
||||
IProject project = file.getProject();
|
||||
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(workingCopy.getCProject());
|
||||
ICodeReaderFactory readerFactory;
|
||||
if (pdom != null)
|
||||
readerFactory = pdom.getCodeReaderFactory(workingCopy);
|
||||
|
@ -93,7 +92,7 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
|||
} else if (editor.getEditorInput() instanceof ExternalEditorInput) {
|
||||
IStorage storage = ((ExternalEditorInput)(editor.getEditorInput())).getStorage();
|
||||
IProject project = workingCopy.getCProject().getProject();
|
||||
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(workingCopy.getCProject());
|
||||
ICodeReaderFactory readerFactory;
|
||||
if (pdom != null)
|
||||
readerFactory = pdom.getCodeReaderFactory(workingCopy);
|
||||
|
|
|
@ -13,7 +13,7 @@ package org.eclipse.cdt.ui.dialogs;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.ICDescriptor;
|
||||
import org.eclipse.cdt.core.ICExtensionReference;
|
||||
import org.eclipse.cdt.core.index.ICDTIndexer;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.index.ctagsindexer.CTagsIndexer;
|
||||
import org.eclipse.cdt.internal.ui.CUIMessages;
|
||||
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
||||
|
@ -64,11 +64,11 @@ public class CTagsIndexerBlock extends AbstractIndexerPage {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.ui.index.AbstractIndexerPage#initialize(org.eclipse.core.resources.IProject)
|
||||
*/
|
||||
public void initialize(IProject project) {
|
||||
public void initialize(ICProject project) {
|
||||
|
||||
this.currentProject = project;
|
||||
try {
|
||||
loadPersistedValues(project);
|
||||
loadPersistedValues(project.getProject());
|
||||
} catch (CoreException e) {}
|
||||
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class CTagsIndexerBlock extends AbstractIndexerPage {
|
|||
proj = container.getProject();
|
||||
}
|
||||
else{
|
||||
proj = currentProject;
|
||||
proj = currentProject.getProject();
|
||||
}
|
||||
|
||||
if (proj != null) {
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.ICDescriptor;
|
||||
import org.eclipse.cdt.core.ICExtensionReference;
|
||||
import org.eclipse.cdt.core.index.ICDTIndexer;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.index.domsourceindexer.DOMSourceIndexer;
|
||||
import org.eclipse.cdt.internal.ui.CUIMessages;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
@ -64,7 +65,7 @@ public class DOMSourceIndexerBlock extends AbstractIndexerPage {
|
|||
proj = container.getProject();
|
||||
}
|
||||
else{
|
||||
proj = currentProject;
|
||||
proj = currentProject.getProject();
|
||||
}
|
||||
|
||||
if (proj != null) {
|
||||
|
@ -92,12 +93,12 @@ public class DOMSourceIndexerBlock extends AbstractIndexerPage {
|
|||
if (currentProject == null)
|
||||
return;
|
||||
|
||||
ICDTIndexer indexer = CCorePlugin.getDefault().getCoreModel().getIndexManager().getIndexerForProject(currentProject);
|
||||
ICDTIndexer indexer = CCorePlugin.getDefault().getCoreModel().getIndexManager().getIndexerForProject(currentProject.getProject());
|
||||
|
||||
int indexMarkersInt = Integer.parseInt(indexMarkers);
|
||||
if (indexMarkersInt != oldIndexerProblemsValue && indexMarkersInt == 0)
|
||||
if (indexer instanceof DOMSourceIndexer)
|
||||
((DOMSourceIndexer) indexer).removeIndexerProblems(currentProject);
|
||||
((DOMSourceIndexer) indexer).removeIndexerProblems(currentProject.getProject());
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
|
@ -142,10 +143,10 @@ public class DOMSourceIndexerBlock extends AbstractIndexerPage {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.ui.index2.AbstractIndexerPage#initialize(org.eclipse.core.resources.IProject)
|
||||
*/
|
||||
public void initialize(IProject project) {
|
||||
public void initialize(ICProject project) {
|
||||
|
||||
try {
|
||||
loadPersistedValues(project);
|
||||
loadPersistedValues(project.getProject());
|
||||
this.currentProject = project;
|
||||
} catch (CoreException e) {}
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.index.nullindexer.NullIndexer;
|
||||
import org.eclipse.cdt.internal.ui.CUIMessages;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
@ -340,7 +342,8 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
: ((AbstractIndexerPage) currentPage).getCurrentProject();
|
||||
|
||||
if ( project != null) {
|
||||
CCorePlugin.getPDOMManager().setIndexerId(project, indexerID);
|
||||
ICProject cproject = CoreModel.getDefault().create(project);
|
||||
CCorePlugin.getPDOMManager().setIndexerId(cproject, indexerID);
|
||||
if (currentPage != null && currentPage.getControl() != null) {
|
||||
currentPage.performApply(new SubProgressMonitor(monitor, 1));
|
||||
}
|
||||
|
@ -377,14 +380,14 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
* This is needed since we need to pass in the project if we are trying to save changes made to the
|
||||
* property page.
|
||||
*/
|
||||
public void persistIndexerSettings(IProject project, IProgressMonitor monitor) throws CoreException{
|
||||
public void persistIndexerSettings(ICProject project, IProgressMonitor monitor) throws CoreException{
|
||||
if (currentPage instanceof AbstractIndexerPage)
|
||||
((AbstractIndexerPage)currentPage).setCurrentProject(project);
|
||||
|
||||
this.performApply(monitor);
|
||||
}
|
||||
|
||||
public void resetIndexerPageSettings(IProject project){
|
||||
public void resetIndexerPageSettings(ICProject project){
|
||||
if (currentPage instanceof AbstractIndexerPage)
|
||||
((AbstractIndexerPage)currentPage).setCurrentProject(project);
|
||||
|
||||
|
@ -411,7 +414,7 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
* @param oldIndexerID
|
||||
* @param project
|
||||
*/
|
||||
public void setIndexerID(String indexerID, IProject project) {
|
||||
public void setIndexerID(String indexerID, ICProject project) {
|
||||
//Get the corresponding text for the given indexer id
|
||||
selectedIndexerId = getIndexerPageName(indexerID);
|
||||
//Store the currently selected indexer id
|
||||
|
|
|
@ -12,7 +12,10 @@
|
|||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
@ -45,18 +48,22 @@ public class IndexerOptionPropertyPage extends PropertyPage {
|
|||
}
|
||||
|
||||
protected void performDefaults() {
|
||||
IProject tempProject = getProject();
|
||||
ICProject tempProject = CoreModel.getDefault().create(getProject());
|
||||
optionPage.resetIndexerPageSettings(tempProject);
|
||||
}
|
||||
|
||||
private void initialize(){
|
||||
IProject project = getProject();
|
||||
oldIndexerID = CCorePlugin.getPDOMManager().getIndexerId(project);
|
||||
optionPage.setIndexerID(oldIndexerID, project);
|
||||
ICProject project = CoreModel.getDefault().create(getProject());
|
||||
try {
|
||||
oldIndexerID = CCorePlugin.getPDOMManager().getIndexerId(project);
|
||||
optionPage.setIndexerID(oldIndexerID, project);
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean performOk() {
|
||||
IProject tempProject = getProject();
|
||||
ICProject tempProject = CoreModel.getDefault().create(getProject());
|
||||
try {
|
||||
optionPage.persistIndexerSettings(tempProject, new NullProgressMonitor());
|
||||
} catch (CoreException e) {}
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.ui.index.AbstractIndexerPage;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -22,8 +22,7 @@ import org.eclipse.swt.widgets.Composite;
|
|||
*/
|
||||
public class NullIndexerBlock extends AbstractIndexerPage {
|
||||
|
||||
|
||||
public void initialize(IProject currentProject) {}
|
||||
public void initialize(ICProject currentProject) {}
|
||||
|
||||
public void performApply(IProgressMonitor monitor) throws CoreException {}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.index;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -20,7 +21,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
|
|||
*/
|
||||
public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
||||
|
||||
protected IProject currentProject;
|
||||
protected ICProject currentProject;
|
||||
protected IPreferenceStore prefStore=CUIPlugin.getDefault().getPreferenceStore();
|
||||
|
||||
protected AbstractIndexerPage() {
|
||||
|
@ -31,7 +32,7 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
* Called by BaseIndexerBlock to give the indexer page a chance to load its state from store
|
||||
* @param currentProject - the project that this page is being created for
|
||||
*/
|
||||
abstract public void initialize(IProject currentProject);
|
||||
abstract public void initialize(ICProject currentProject);
|
||||
/**
|
||||
* Called by the indexer block to give the indexer page an opportunity to
|
||||
* load any preferecnes previously set
|
||||
|
@ -44,9 +45,10 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
abstract public void removePreferences();
|
||||
|
||||
public IProject getCurrentProject() {
|
||||
return currentProject;
|
||||
return currentProject.getProject();
|
||||
}
|
||||
public void setCurrentProject(IProject currentProject) {
|
||||
|
||||
public void setCurrentProject(ICProject currentProject) {
|
||||
this.currentProject = currentProject;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue