mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Cleaning up the Full and Fast indexers. They are pretty close now.
This commit is contained in:
parent
7f420507cd
commit
c7708b4e2b
7 changed files with 183 additions and 202 deletions
|
@ -11,18 +11,20 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
|
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
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.ICElementDelta;
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
@ -32,9 +34,9 @@ class PDOMFastHandleDelta extends PDOMFastIndexerJob {
|
||||||
|
|
||||||
private final ICElementDelta delta;
|
private final ICElementDelta delta;
|
||||||
|
|
||||||
private List addedTUs;
|
private List added = new ArrayList();
|
||||||
private List changedTUs;
|
private List changed = new ArrayList();
|
||||||
private List removedTUs;
|
private List removed = new ArrayList();
|
||||||
|
|
||||||
public PDOMFastHandleDelta(PDOM pdom, ICElementDelta delta) {
|
public PDOMFastHandleDelta(PDOM pdom, ICElementDelta delta) {
|
||||||
super(pdom);
|
super(pdom);
|
||||||
|
@ -47,52 +49,40 @@ class PDOMFastHandleDelta extends PDOMFastIndexerJob {
|
||||||
|
|
||||||
processDelta(delta);
|
processDelta(delta);
|
||||||
|
|
||||||
int count = (addedTUs != null ? addedTUs.size() : 0)
|
int count = changed.size() + added.size() + removed.size();
|
||||||
+ (changedTUs != null ? changedTUs.size() : 0)
|
|
||||||
+ (removedTUs != null ? removedTUs.size() : 0);
|
|
||||||
|
|
||||||
if (count == 0) {
|
if (count > 0) {
|
||||||
return Status.OK_STATUS;
|
monitor.beginTask("Indexing", count);
|
||||||
}
|
|
||||||
|
|
||||||
if (addedTUs != null)
|
Iterator i = changed.iterator();
|
||||||
for (Iterator i = addedTUs.iterator(); i.hasNext();) {
|
while (i.hasNext()) {
|
||||||
if (monitor.isCanceled())
|
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||||
return Status.CANCEL_STATUS;
|
monitor.subTask(tu.getElementName());
|
||||||
ITranslationUnit tu = (ITranslationUnit) i.next();
|
|
||||||
monitor.subTask(String.valueOf(count--) + " files remaining - "
|
|
||||||
+ tu.getPath().toString());
|
|
||||||
addTU(tu);
|
|
||||||
}
|
|
||||||
|
|
||||||
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());
|
|
||||||
changeTU(tu);
|
changeTU(tu);
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (removedTUs != null)
|
i = added.iterator();
|
||||||
for (Iterator i = removedTUs.iterator(); i.hasNext();) {
|
while (i.hasNext()) {
|
||||||
if (monitor.isCanceled())
|
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||||
return Status.CANCEL_STATUS;
|
monitor.subTask(tu.getElementName());
|
||||||
ITranslationUnit tu = (ITranslationUnit) i.next();
|
addTU(tu);
|
||||||
monitor.subTask(String.valueOf(count--) + " files remaining - "
|
monitor.worked(1);
|
||||||
+ tu.getPath().toString());
|
}
|
||||||
|
|
||||||
|
i = removed.iterator();
|
||||||
|
while (i.hasNext()) {
|
||||||
|
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||||
|
monitor.subTask(tu.getElementName());
|
||||||
removeTU(tu);
|
removeTU(tu);
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID
|
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID
|
||||||
+ "/debug/pdomtimings"); //$NON-NLS-1$
|
+ "/debug/pdomtimings"); //$NON-NLS-1$
|
||||||
if (showTimings != null)
|
if (showTimings != null && showTimings.equalsIgnoreCase("true")) //$NON-NLS-1$
|
||||||
if (showTimings.equalsIgnoreCase("true")) //$NON-NLS-1$
|
System.out.println("PDOM Full Delta Time: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
|
||||||
System.out
|
}
|
||||||
.println("PDOM Update Time: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
|
|
||||||
|
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -102,79 +92,68 @@ class PDOMFastHandleDelta extends PDOMFastIndexerJob {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processDelta(ICElementDelta delta) {
|
protected void processDelta(ICElementDelta delta) throws CoreException {
|
||||||
ICElement element = delta.getElement();
|
int flags = delta.getFlags();
|
||||||
|
|
||||||
// If this is a project add skip over to the reindex job
|
if ((flags & ICElementDelta.F_CHILDREN) != 0) {
|
||||||
if (element.getElementType() == ICElement.C_PROJECT
|
ICElementDelta[] children = delta.getAffectedChildren();
|
||||||
&& delta.getKind() == ICElementDelta.ADDED) {
|
for (int i = 0; i < children.length; ++i) {
|
||||||
new PDOMFastReindex(pdom).schedule();
|
processDelta(children[i]);
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// process the children first
|
ICElement element = delta.getElement();
|
||||||
ICElementDelta[] children = delta.getAffectedChildren();
|
switch (element.getElementType()) {
|
||||||
for (int i = 0; i < children.length; ++i)
|
case ICElement.C_UNIT:
|
||||||
processDelta(children[i]);
|
ITranslationUnit tu = (ITranslationUnit)element;
|
||||||
|
|
||||||
// what have we got
|
|
||||||
if (element.getElementType() == ICElement.C_UNIT) {
|
|
||||||
ITranslationUnit tu = (ITranslationUnit) element;
|
|
||||||
if (tu.isWorkingCopy())
|
|
||||||
// Don't care about working copies either
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch (delta.getKind()) {
|
switch (delta.getKind()) {
|
||||||
case ICElementDelta.ADDED:
|
|
||||||
if (addedTUs == null)
|
|
||||||
addedTUs = new LinkedList();
|
|
||||||
addedTUs.add(element);
|
|
||||||
break;
|
|
||||||
case ICElementDelta.CHANGED:
|
case ICElementDelta.CHANGED:
|
||||||
if (changedTUs == null)
|
if ((flags & ICElementDelta.F_CONTENT) != 0)
|
||||||
changedTUs = new LinkedList();
|
changed.add(tu);
|
||||||
changedTUs.add(element);
|
break;
|
||||||
|
case ICElementDelta.ADDED:
|
||||||
|
if (!tu.isWorkingCopy())
|
||||||
|
added.add(tu);
|
||||||
break;
|
break;
|
||||||
case ICElementDelta.REMOVED:
|
case ICElementDelta.REMOVED:
|
||||||
if (removedTUs == null)
|
if (!tu.isWorkingCopy())
|
||||||
removedTUs = new LinkedList();
|
removed.add(tu);
|
||||||
removedTUs.add(element);
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected void changeTU(ITranslationUnit tu) throws InterruptedException, CoreException {
|
|
||||||
ILanguage language = tu.getLanguage();
|
|
||||||
if (language == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// get the AST in a "Fast" way
|
|
||||||
IASTTranslationUnit ast = language.getASTTranslationUnit(tu,
|
|
||||||
ILanguage.AST_USE_INDEX |
|
|
||||||
ILanguage.AST_SKIP_INDEXED_HEADERS |
|
|
||||||
ILanguage.AST_SKIP_IF_NO_BUILD_INFO);
|
|
||||||
|
|
||||||
|
protected void changeTU(ITranslationUnit tu) throws CoreException, InterruptedException {
|
||||||
|
IASTTranslationUnit ast = parse(tu);
|
||||||
if (ast == null)
|
if (ast == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pdom.acquireWriteLock();
|
pdom.acquireWriteLock();
|
||||||
try {
|
try {
|
||||||
pdom.removeSymbols(tu);
|
// Remove the old symbols in the tu
|
||||||
pdom.addSymbols(language, ast);
|
IPath path = ((IFile)tu.getResource()).getLocation();
|
||||||
|
PDOMFile file = pdom.getFile(path);
|
||||||
|
if (file != null)
|
||||||
|
file.clear();
|
||||||
|
|
||||||
|
// Add the new symbols
|
||||||
|
pdom.addSymbols(tu.getLanguage(), ast);
|
||||||
} finally {
|
} finally {
|
||||||
pdom.releaseWriteLock();
|
pdom.releaseWriteLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeTU(ITranslationUnit tu) throws InterruptedException, CoreException {
|
protected void removeTU(ITranslationUnit tu) throws CoreException, InterruptedException {
|
||||||
pdom.acquireWriteLock();
|
pdom.acquireWriteLock();
|
||||||
try {
|
try {
|
||||||
pdom.removeSymbols(tu);
|
IPath path = ((IFile)tu.getResource()).getLocation();
|
||||||
// TODO delete the file itself from the database
|
PDOMFile file = pdom.getFile(path);
|
||||||
// the removeSymbols only removes the names in the file
|
if (file != null)
|
||||||
|
file.clear();
|
||||||
} finally {
|
} finally {
|
||||||
pdom.releaseWriteLock();
|
pdom.releaseWriteLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,19 +24,18 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
*/
|
*/
|
||||||
public class PDOMFastIndexer implements IPDOMIndexer {
|
public class PDOMFastIndexer implements IPDOMIndexer {
|
||||||
|
|
||||||
private PDOM pdom;
|
private IPDOM pdom;
|
||||||
|
|
||||||
public void setPDOM(IPDOM pdom) {
|
public void setPDOM(IPDOM pdom) {
|
||||||
if (pdom instanceof PDOM)
|
this.pdom = pdom;
|
||||||
this.pdom = (PDOM)pdom;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleDelta(ICElementDelta delta) {
|
public void handleDelta(ICElementDelta delta) {
|
||||||
new PDOMFastHandleDelta(pdom, delta).schedule();
|
new PDOMFastHandleDelta((PDOM)pdom, delta).schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reindex() throws CoreException {
|
public void reindex() throws CoreException {
|
||||||
new PDOMFastReindex(pdom).schedule();
|
new PDOMFastReindex((PDOM)pdom).schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,22 +33,26 @@ public abstract class PDOMFastIndexerJob extends Job {
|
||||||
setRule(CCorePlugin.getPDOMManager().getIndexerSchedulingRule());
|
setRule(CCorePlugin.getPDOMManager().getIndexerSchedulingRule());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addTU(ITranslationUnit tu) throws InterruptedException, CoreException {
|
protected IASTTranslationUnit parse(ITranslationUnit tu) throws CoreException {
|
||||||
ILanguage language = tu.getLanguage();
|
ILanguage language = tu.getLanguage();
|
||||||
if (language == null)
|
if (language == null)
|
||||||
return;
|
return null;
|
||||||
|
|
||||||
// get the AST in a "Fast" way
|
// get the AST in a "Fast" way
|
||||||
IASTTranslationUnit ast = language.getASTTranslationUnit(tu,
|
return language.getASTTranslationUnit(tu,
|
||||||
ILanguage.AST_USE_INDEX
|
ILanguage.AST_USE_INDEX
|
||||||
| ILanguage.AST_SKIP_INDEXED_HEADERS
|
| ILanguage.AST_SKIP_INDEXED_HEADERS
|
||||||
| ILanguage.AST_SKIP_IF_NO_BUILD_INFO);
|
| ILanguage.AST_SKIP_IF_NO_BUILD_INFO);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addTU(ITranslationUnit tu) throws InterruptedException, CoreException {
|
||||||
|
IASTTranslationUnit ast = parse(tu);
|
||||||
if (ast == null)
|
if (ast == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pdom.acquireWriteLock();
|
pdom.acquireWriteLock();
|
||||||
try {
|
try {
|
||||||
pdom.addSymbols(language, ast);
|
pdom.addSymbols(tu.getLanguage(), ast);
|
||||||
} finally {
|
} finally {
|
||||||
pdom.releaseWriteLock();
|
pdom.releaseWriteLock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,24 +11,17 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
|
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
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.ICElementVisitor;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.core.resources.IFile;
|
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.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.content.IContentType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -40,67 +33,82 @@ public class PDOMFastReindex extends PDOMFastIndexerJob {
|
||||||
super(pdom);
|
super(pdom);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(final IProgressMonitor monitor) {
|
||||||
try {
|
try {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
// First clear out the DB
|
// First clear out the DB
|
||||||
pdom.clear();
|
pdom.clear();
|
||||||
|
|
||||||
// First index all the source files (i.e. not headers)
|
// Get a count of all the elements that we'll be visiting for the monitor
|
||||||
final List addedSources = new ArrayList();
|
final int[] count = { 0 };
|
||||||
|
pdom.getProject().accept(new ICElementVisitor() {
|
||||||
pdom.getProject().getProject().accept(new IResourceProxyVisitor() {
|
public boolean visit(ICElement element) throws CoreException {
|
||||||
public boolean visit(IResourceProxy proxy) throws CoreException {
|
switch (element.getElementType()) {
|
||||||
if (proxy.getType() == IResource.FILE) {
|
case ICElement.C_UNIT:
|
||||||
String fileName = proxy.getName();
|
++count[0];
|
||||||
IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(fileName);
|
return false;
|
||||||
if (contentType == null)
|
case ICElement.C_CCONTAINER:
|
||||||
|
case ICElement.C_PROJECT:
|
||||||
return true;
|
return true;
|
||||||
String contentTypeId = contentType.getId();
|
|
||||||
|
|
||||||
if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(contentTypeId)
|
|
||||||
|| CCorePlugin.CONTENT_TYPE_CSOURCE.equals(contentTypeId)) {
|
|
||||||
addedSources.add((ITranslationUnit)CoreModel.getDefault().create((IFile)proxy.requestResource()));
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
monitor.beginTask("Indexing", count[0]);
|
||||||
|
|
||||||
|
// First index all the source files (i.e. not headers)
|
||||||
|
pdom.getProject().accept(new ICElementVisitor() {
|
||||||
|
public boolean visit(ICElement element) throws CoreException {
|
||||||
|
switch (element.getElementType()) {
|
||||||
|
case ICElement.C_UNIT:
|
||||||
|
ITranslationUnit tu = (ITranslationUnit)element;
|
||||||
|
if (tu.isSourceUnit()) {
|
||||||
|
monitor.subTask(tu.getElementName());
|
||||||
|
try {
|
||||||
|
addTU(tu);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new CoreException(Status.CANCEL_STATUS);
|
||||||
|
}
|
||||||
|
monitor.worked(1);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case ICElement.C_CCONTAINER:
|
||||||
|
case ICElement.C_PROJECT:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}, 0);
|
});
|
||||||
|
|
||||||
for (Iterator i = addedSources.iterator(); i.hasNext();)
|
|
||||||
addTU((ITranslationUnit)i.next());
|
|
||||||
|
|
||||||
// Now add in the header files but only if they aren't already indexed
|
// Now add in the header files but only if they aren't already indexed
|
||||||
final List addedHeaders = new ArrayList();
|
pdom.getProject().accept(new ICElementVisitor() {
|
||||||
|
public boolean visit(ICElement element) throws CoreException {
|
||||||
pdom.getProject().getProject().accept(new IResourceProxyVisitor() {
|
switch (element.getElementType()) {
|
||||||
public boolean visit(IResourceProxy proxy) throws CoreException {
|
case ICElement.C_UNIT:
|
||||||
if (proxy.getType() == IResource.FILE) {
|
ITranslationUnit tu = (ITranslationUnit)element;
|
||||||
String fileName = proxy.getName();
|
if (tu.isHeaderUnit()) {
|
||||||
IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(fileName);
|
IFile rfile = (IFile)tu.getUnderlyingResource();
|
||||||
if (contentType == null)
|
|
||||||
return true;
|
|
||||||
String contentTypeId = contentType.getId();
|
|
||||||
|
|
||||||
if (CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(contentTypeId)
|
|
||||||
|| CCorePlugin.CONTENT_TYPE_CHEADER.equals(contentTypeId)) {
|
|
||||||
IFile rfile = (IFile)proxy.requestResource();
|
|
||||||
String filename = rfile.getLocation().toOSString();
|
String filename = rfile.getLocation().toOSString();
|
||||||
if (pdom.getFile(filename) == null)
|
if (pdom.getFile(filename) == null) {
|
||||||
addedHeaders.add((ITranslationUnit)CoreModel.getDefault().create(rfile));
|
monitor.subTask(tu.getElementName());
|
||||||
|
try {
|
||||||
|
addTU(tu);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new CoreException(Status.CANCEL_STATUS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
monitor.worked(1);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
case ICElement.C_CCONTAINER:
|
||||||
|
case ICElement.C_PROJECT:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}, 0);
|
});
|
||||||
|
|
||||||
for (Iterator i = addedHeaders.iterator(); i.hasNext();)
|
|
||||||
addTU((ITranslationUnit)i.next());
|
|
||||||
|
|
||||||
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID
|
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID
|
||||||
+ "/debug/pdomtimings"); //$NON-NLS-1$
|
+ "/debug/pdomtimings"); //$NON-NLS-1$
|
||||||
|
@ -110,8 +118,6 @@ public class PDOMFastReindex extends PDOMFastIndexerJob {
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
return e.getStatus();
|
return e.getStatus();
|
||||||
} catch (InterruptedException e) {
|
|
||||||
return Status.CANCEL_STATUS;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,11 +172,13 @@ public class PDOMFullHandleDelta extends PDOMFullIndexerJob {
|
||||||
if (ast == null)
|
if (ast == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pdom.acquireWriteLock();
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Remove the old symbols in the tu and all the headers
|
// Remove the old symbols in the tu and all the headers
|
||||||
removeTU(tu);
|
pdom.acquireWriteLock();
|
||||||
|
try {
|
||||||
|
IPath path = ((IFile)tu.getResource()).getLocation();
|
||||||
|
PDOMFile file = pdom.getFile(path);
|
||||||
|
if (file != null)
|
||||||
|
file.clear();
|
||||||
|
|
||||||
IASTPreprocessorIncludeStatement[] includes = ast.getIncludeDirectives();
|
IASTPreprocessorIncludeStatement[] includes = ast.getIncludeDirectives();
|
||||||
for (int i = 0; i < includes.length; ++i) {
|
for (int i = 0; i < includes.length; ++i) {
|
||||||
|
@ -193,24 +195,16 @@ public class PDOMFullHandleDelta extends PDOMFullIndexerJob {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addTU(ITranslationUnit tu) throws CoreException, InterruptedException {
|
protected void removeTU(ITranslationUnit tu) throws CoreException, InterruptedException {
|
||||||
IASTTranslationUnit ast = parse(tu);
|
|
||||||
if (ast == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
pdom.acquireWriteLock();
|
pdom.acquireWriteLock();
|
||||||
try {
|
try {
|
||||||
pdom.addSymbols(tu.getLanguage(), ast);
|
IPath path = ((IFile)tu.getResource()).getLocation();
|
||||||
|
PDOMFile file = pdom.getFile(path);
|
||||||
|
if (file != null)
|
||||||
|
file.clear();
|
||||||
} finally {
|
} finally {
|
||||||
pdom.releaseWriteLock();
|
pdom.releaseWriteLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeTU(ITranslationUnit tu) throws CoreException, InterruptedException {
|
|
||||||
IPath path = ((IFile)tu.getResource()).getLocation();
|
|
||||||
PDOMFile file = pdom.getFile(path);
|
|
||||||
if (file != null)
|
|
||||||
file.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,4 +42,17 @@ public abstract class PDOMFullIndexerJob extends Job {
|
||||||
return language.getASTTranslationUnit(tu, ILanguage.AST_SKIP_IF_NO_BUILD_INFO);
|
return language.getASTTranslationUnit(tu, ILanguage.AST_SKIP_IF_NO_BUILD_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void addTU(ITranslationUnit tu) throws InterruptedException, CoreException {
|
||||||
|
IASTTranslationUnit ast = parse(tu);
|
||||||
|
if (ast == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
pdom.acquireWriteLock();
|
||||||
|
try {
|
||||||
|
pdom.addSymbols(tu.getLanguage(), ast);
|
||||||
|
} finally {
|
||||||
|
pdom.releaseWriteLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.full;
|
package org.eclipse.cdt.internal.core.pdom.indexer.full;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
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.ICElementVisitor;
|
import org.eclipse.cdt.core.model.ICElementVisitor;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
@ -122,17 +121,4 @@ public class PDOMFullReindex extends PDOMFullIndexerJob {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addTU(ITranslationUnit tu) throws InterruptedException, CoreException {
|
|
||||||
IASTTranslationUnit ast = parse(tu);
|
|
||||||
if (ast == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
pdom.acquireWriteLock();
|
|
||||||
try {
|
|
||||||
pdom.addSymbols(tu.getLanguage(), ast);
|
|
||||||
} finally {
|
|
||||||
pdom.releaseWriteLock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue