1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 12:03:16 +02:00

2005-08-12 Chris Wiebe

Fix PR 106778: IndexerTypesJob2 painfully slow
	* browser/org/eclipse/cdt/internal/core/browser/cache/IndexerTypesJob2.java
	Fix progress monitor
	* browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacheManager.java
This commit is contained in:
Chris Wiebe 2005-08-12 18:37:21 +00:00
parent c63d1a13eb
commit fdc0a1e7ed
3 changed files with 37 additions and 44 deletions

View file

@ -1,3 +1,9 @@
2005-08-12 Chris Wiebe
Fix PR 106778: IndexerTypesJob2 painfully slow
* browser/org/eclipse/cdt/internal/core/browser/cache/IndexerTypesJob2.java
Fix progress monitor
* browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacheManager.java
2005-08-11 Chris Wiebe
Fix PR 104907,106415: type cache always running in background
* browser/org/eclipse/cdt/core/browser/AllTypesCache.java

View file

@ -38,16 +38,27 @@ public class IndexerTypesJob2 extends IndexerJob2 {
}
protected boolean processIndex(IProgressMonitor progressMonitor) throws InterruptedException {
IndexInput input = null;
try {
updateNamespaces(progressMonitor);
updateTypes(progressMonitor);
input = new BlocksIndexInput( fProjectIndex.getIndexFile() );
input.open();
updateNamespaces(input, progressMonitor);
updateTypes(input, progressMonitor);
return true;
} catch (IOException e) {
return false;
}
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
// do nothing
}
}
}
}
private void updateNamespaces(IProgressMonitor monitor)
private void updateNamespaces(IndexInput input, IProgressMonitor monitor)
throws InterruptedException, IOException {
if (monitor.isCanceled())
throw new InterruptedException();
@ -65,13 +76,13 @@ public class IndexerTypesJob2 extends IndexerJob2 {
String name = entry.getName();
if (name.length() != 0) {
String[] enclosingNames = entry.getEnclosingNames();
addType(entry, namespacePaths[i].getPath(), ICElement.C_NAMESPACE, name, enclosingNames, monitor);
addType(input, entry, namespacePaths[i].getPath(), ICElement.C_NAMESPACE, name, enclosingNames, monitor);
}
}
}
}
private void updateTypes(IProgressMonitor monitor)
private void updateTypes(IndexInput input, IProgressMonitor monitor)
throws InterruptedException, IOException {
if (monitor.isCanceled())
throw new InterruptedException();
@ -96,7 +107,7 @@ public class IndexerTypesJob2 extends IndexerJob2 {
case IIndex.TYPE_ENUM :
case IIndex.TYPE_UNION :
if (counter != 0 && name.length() != 0) { // skip anonymous structs
addType(entry, getPathForEntry( entry ), index2ICElement( entry.getKind() ), name, entry.getEnclosingNames(), monitor);
addType(input, entry, null, index2ICElement( entry.getKind() ), name, entry.getEnclosingNames(), monitor);
}
break;
default:
@ -119,7 +130,7 @@ public class IndexerTypesJob2 extends IndexerJob2 {
{
case IIndex.TYPE_DERIVED :
if (name.length() != 0) { // skip anonymous structs
addSuperTypeReference(entry, name, entry.getEnclosingNames(), monitor);
addSuperTypeReference(input, entry, name, entry.getEnclosingNames(), monitor);
}
break;
default:
@ -129,12 +140,8 @@ public class IndexerTypesJob2 extends IndexerJob2 {
}
}
private String getPathForEntry(IEntryResult entry) {
return getPathForEntry(entry, 0);
}
private void addType(IEntryResult entry, String pth, int type, String name, String[] enclosingNames, IProgressMonitor monitor)
throws InterruptedException, IOException {
private void addType(IndexInput input, IEntryResult entry, String pth, int type, String name, String[] enclosingNames, IProgressMonitor monitor)
throws InterruptedException, IOException {
QualifiedTypeName qualifiedName = new QualifiedTypeName(name, enclosingNames);
ITypeInfo info = fTypeCache.getType(type, qualifiedName);
if (info == null || info.isUndefinedType()) {
@ -158,6 +165,10 @@ public class IndexerTypesJob2 extends IndexerJob2 {
// info.addReference(new TypeReference(path, project));
// }
// }
if (pth == null) {
pth = input.getIndexedFile( references[0] ).getPath();
}
final IPath workspaceRelativePath = PathUtil.getWorkspaceRelativePath(pth);
int offset = entry.getOffsets()[0][0];
// int offsetType = Integer.valueOf(String.valueOf(offsets[i][j]).substring(0,1)).intValue();
@ -183,7 +194,7 @@ public class IndexerTypesJob2 extends IndexerJob2 {
}
}
private void addSuperTypeReference(IEntryResult entry, String name, String[] enclosingNames, IProgressMonitor monitor) throws InterruptedException, IOException {
private void addSuperTypeReference(IndexInput input, IEntryResult entry, String name, String[] enclosingNames, IProgressMonitor monitor) throws InterruptedException, IOException {
QualifiedTypeName qualifiedName = new QualifiedTypeName(name, enclosingNames);
ITypeInfo info = fTypeCache.getType(ICElement.C_CLASS, qualifiedName);
if (info == null)
@ -198,8 +209,9 @@ public class IndexerTypesJob2 extends IndexerJob2 {
for (int i = 0; i < references.length; ++i) {
if (monitor.isCanceled())
throw new InterruptedException();
IPath path = PathUtil.getWorkspaceRelativePath(getPathForEntry( entry, i ));
String pth = input.getIndexedFile( references[i] ).getPath();
IPath path = PathUtil.getWorkspaceRelativePath(pth);
info.addDerivedReference(new TypeReference(path, fProject));
//
@ -214,30 +226,4 @@ public class IndexerTypesJob2 extends IndexerJob2 {
}
}
}
private String getPathForEntry(IEntryResult entry, int i) {
int [] references = entry.getFileReferences();
IndexInput input = new BlocksIndexInput( fProjectIndex.getIndexFile() );
try {
input.open();
} catch (IOException e) {
return ""; //$NON-NLS-1$
}
try
{
return input.getIndexedFile( references[i] ).getPath();
}
catch( IOException io )
{
}
finally
{
try {
input.close();
} catch (IOException e) {
}
}
return ""; //$NON-NLS-1$
}
}

View file

@ -38,6 +38,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.Job;
@ -306,7 +307,7 @@ public class TypeCacheManager implements ITypeCacheChangedListener, IndexManager
for (int i = 0; i < projects.length; ++i) {
IProject project = projects[i];
// wait for any running jobs to finish
getCache(project).reconcileAndWait(true, Job.SHORT, monitor);
getCache(project).reconcileAndWait(true, Job.SHORT, new SubProgressMonitor(monitor, 1));
}
monitor.done();
}