mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-01 13:25:45 +02:00
Removed the -a option from ctags so that it creates a new file for each request. Speeds things up a little. Also made a copy of the include references array since the prefix removal was blowing up the CModel.
This commit is contained in:
parent
9cbc718f2b
commit
13d87eb554
2 changed files with 58 additions and 41 deletions
|
@ -74,7 +74,6 @@ public class CtagsIndexer implements IPDOMIndexer {
|
||||||
"--c-types=cdefgmnpstuvx", //$NON-NLS-1$
|
"--c-types=cdefgmnpstuvx", //$NON-NLS-1$
|
||||||
"--c++-types=cdefgmnpstuvx", //$NON-NLS-1$
|
"--c++-types=cdefgmnpstuvx", //$NON-NLS-1$
|
||||||
"--languages=c,c++", //$NON-NLS-1$
|
"--languages=c,c++", //$NON-NLS-1$
|
||||||
"-a", //$NON-NLS-1$ // All locations are collected in one file
|
|
||||||
"-f", //$NON-NLS-1$
|
"-f", //$NON-NLS-1$
|
||||||
ctagsFileName,
|
ctagsFileName,
|
||||||
"-R", //$NON-NLS-2$
|
"-R", //$NON-NLS-2$
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.ctags;
|
package org.eclipse.cdt.internal.core.pdom.indexer.ctags;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IIncludeReference;
|
import org.eclipse.cdt.core.model.IIncludeReference;
|
||||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
|
@ -23,6 +25,8 @@ import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
|
|
||||||
|
import com.sun.corba.se.impl.interceptors.PINoOpHandlerImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*
|
*
|
||||||
|
@ -33,39 +37,18 @@ public class CtagsReindex extends Job {
|
||||||
private final PDOM pdom;
|
private final PDOM pdom;
|
||||||
|
|
||||||
public CtagsReindex(CtagsIndexer indexer) {
|
public CtagsReindex(CtagsIndexer indexer) {
|
||||||
super("Ctags Indexer");
|
super("ctags Indexer: " + ((PDOM)indexer.getPDOM()).getProject().getElementName());
|
||||||
this.indexer = indexer;
|
this.indexer = indexer;
|
||||||
this.pdom = (PDOM)indexer.getPDOM();
|
this.pdom = (PDOM)indexer.getPDOM();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
try {
|
try {
|
||||||
// Index the include path
|
// What do we need to index
|
||||||
indexIncludes();
|
|
||||||
|
|
||||||
// Index the source roots
|
|
||||||
final ICProject project = pdom.getProject();
|
final ICProject project = pdom.getProject();
|
||||||
ISourceRoot[] sourceRoots = project.getAllSourceRoots();
|
final IIncludeReference[] pincludes = project.getIncludeReferences();
|
||||||
|
IIncludeReference[] includes = new IIncludeReference[pincludes.length];
|
||||||
for (int i = 0; i < sourceRoots.length; ++i) {
|
System.arraycopy(pincludes, 0, includes, 0, pincludes.length);
|
||||||
ISourceRoot sourceRoot = sourceRoots[i];
|
|
||||||
IPath sourcePath = sourceRoot.getResource().getLocation();
|
|
||||||
if (sourcePath != null)
|
|
||||||
indexer.runCtags(sourcePath);
|
|
||||||
}
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
} catch (CoreException e) {
|
|
||||||
return e.getStatus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void indexIncludes() throws CoreException {
|
|
||||||
ICProject project = pdom.getProject();
|
|
||||||
IIncludeReference[] includes = project.getIncludeReferences();
|
|
||||||
|
|
||||||
// This project has no references, don't bother processing any further
|
|
||||||
if (includes.length == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Find common prefix paths
|
// Find common prefix paths
|
||||||
for (int i = 0; i < includes.length; ++i) {
|
for (int i = 0; i < includes.length; ++i) {
|
||||||
|
@ -86,10 +69,45 @@ public class CtagsReindex extends Job {
|
||||||
}
|
}
|
||||||
|
|
||||||
includes = (IIncludeReference[])ArrayUtil.removeNulls(IIncludeReference.class, includes);
|
includes = (IIncludeReference[])ArrayUtil.removeNulls(IIncludeReference.class, includes);
|
||||||
|
|
||||||
|
ISourceRoot[] sourceRoots = project.getAllSourceRoots();
|
||||||
|
|
||||||
|
monitor.beginTask("Indexing", sourceRoots.length + includes.length);
|
||||||
|
|
||||||
|
// Clear out the PDOM
|
||||||
|
if (monitor.isCanceled())
|
||||||
|
return Status.CANCEL_STATUS;
|
||||||
|
monitor.subTask("Clearing Index");
|
||||||
|
pdom.clear();
|
||||||
|
monitor.worked(1);
|
||||||
|
|
||||||
|
// Index the include path
|
||||||
for (int i = 0; i < includes.length; ++i) {
|
for (int i = 0; i < includes.length; ++i) {
|
||||||
|
if (monitor.isCanceled())
|
||||||
|
return Status.CANCEL_STATUS;
|
||||||
|
monitor.subTask(includes[i].getElementName());
|
||||||
indexer.runCtags(includes[i].getPath());
|
indexer.runCtags(includes[i].getPath());
|
||||||
}
|
monitor.worked(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Index the source roots
|
||||||
|
for (int i = 0; i < sourceRoots.length; ++i) {
|
||||||
|
ISourceRoot sourceRoot = sourceRoots[i];
|
||||||
|
IPath sourcePath = sourceRoot.getResource().getLocation();
|
||||||
|
if (sourcePath != null) {
|
||||||
|
if (monitor.isCanceled())
|
||||||
|
return Status.CANCEL_STATUS;
|
||||||
|
monitor.subTask(sourceRoot.getElementName());
|
||||||
|
indexer.runCtags(sourcePath);
|
||||||
|
monitor.worked(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
return e.getStatus();
|
||||||
|
} finally {
|
||||||
|
monitor.done();
|
||||||
|
}
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue