1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Speed up 'Add Include' operation, bug 228811.

This commit is contained in:
Markus Schorn 2008-05-26 15:59:14 +00:00
parent d7b0743169
commit 4fdda8b8d9

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others. * Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -16,7 +16,6 @@ package org.eclipse.cdt.internal.ui.editor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Pattern;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -154,18 +153,17 @@ public class AddIncludeOnSelectionAction extends Action implements IUpdate {
try { try {
index = CCorePlugin.getIndexManager().getIndex(tu.getCProject(), IIndexManager.ADD_DEPENDENCIES); index = CCorePlugin.getIndexManager().getIndex(tu.getCProject(), IIndexManager.ADD_DEPENDENCIES);
index.acquireReadLock(); index.acquireReadLock();
try {
extractIncludes(fEditor, index);
addInclude(tu);
}
finally {
index.releaseReadLock();
}
} catch (CoreException e) { } catch (CoreException e) {
CUIPlugin.log(e); CUIPlugin.log(e);
return;
} catch (InterruptedException e) { } catch (InterruptedException e) {
return; Thread.currentThread().interrupt();
}
try {
extractIncludes(fEditor, index);
addInclude(tu);
}
finally {
index.releaseReadLock();
} }
fUsings = null; fUsings = null;
fRequiredIncludes = null; fRequiredIncludes = null;
@ -250,11 +248,8 @@ public class AddIncludeOnSelectionAction extends Action implements IUpdate {
} }
try { try {
Pattern pattern = Pattern.compile(name); IndexFilter filter= IndexFilter.ALL_DECLARED_OR_IMPLICIT;
IIndexBinding[] bindings= index.findBindings(name.toCharArray(), false, filter, new NullProgressMonitor());
IndexFilter filter= new IndexFilter() {
};
IIndexBinding[] bindings= index.findBindings(pattern, false, filter, new NullProgressMonitor());
ArrayList<DisplayName> pdomNames= new ArrayList<DisplayName>(); ArrayList<DisplayName> pdomNames= new ArrayList<DisplayName>();
for (int i = 0; i < bindings.length; ++i) { for (int i = 0; i < bindings.length; ++i) {
IIndexBinding binding= bindings[i]; IIndexBinding binding= bindings[i];
@ -267,8 +262,8 @@ public class AddIncludeOnSelectionAction extends Action implements IUpdate {
defs= index.findDeclarations(binding); defs= index.findDeclarations(binding);
} }
if (defs != null) { if (defs != null) {
for (int j = 0; j < defs.length; j++) { for (IIndexName def : defs) {
pdomNames.add(new DisplayName(defs[j], binding)); pdomNames.add(new DisplayName(def, binding));
} }
} }
} }