diff options
author | Julian Honnen | 2019-11-12 08:33:48 +0000 |
---|---|---|
committer | Andrey Loskutov | 2019-11-12 12:20:07 +0000 |
commit | f287323df9eee66578972d2fe839c1967723855b (patch) | |
tree | 2780a388aec975f104c159b2610c7e1ba4d650bf /org.eclipse.text.quicksearch | |
parent | 10d3d23a9124232a1bb78b7bd5f9b364a7a539ff (diff) | |
download | eclipse.platform.text-f287323df9eee66578972d2fe839c1967723855b.tar.gz eclipse.platform.text-f287323df9eee66578972d2fe839c1967723855b.tar.xz eclipse.platform.text-f287323df9eee66578972d2fe839c1967723855b.zip |
Bug 551970 - replaced eager computation of ignored containersI20191113-2315I20191113-1800I20191112-1800
Instead of computing all project links eagerly, check if a resource is a
linked project on demand.
The use of IWorkspaceRoot::findContainersForLocationURI does not scale
on large workspaces.
Also modified the implementation to handle linked folders the same as
projects.
Change-Id: Ic0f5f9ac1b7082b4cc0daf9e86a04a08d2e35897
Signed-off-by: Julian Honnen <julian.honnen@vector.com>
Diffstat (limited to 'org.eclipse.text.quicksearch')
-rw-r--r-- | org.eclipse.text.quicksearch/META-INF/MANIFEST.MF | 4 | ||||
-rw-r--r-- | org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/core/priority/DefaultPriorityFunction.java | 68 |
2 files changed, 25 insertions, 47 deletions
diff --git a/org.eclipse.text.quicksearch/META-INF/MANIFEST.MF b/org.eclipse.text.quicksearch/META-INF/MANIFEST.MF index 0ea61cc3796..8b0b5cea2d7 100644 --- a/org.eclipse.text.quicksearch/META-INF/MANIFEST.MF +++ b/org.eclipse.text.quicksearch/META-INF/MANIFEST.MF @@ -20,8 +20,8 @@ Bundle-Localization: plugin Export-Package: org.eclipse.text.quicksearch.internal.core;x-internal:=true, org.eclipse.text.quicksearch.internal.core.pathmatch;x-internal:=true, org.eclipse.text.quicksearch.internal.core.preferences;x-internal:=true, - org.eclipse.text.quicksearch.internal.core.priority;x-internal:=true, - org.eclipse.text.quicksearch.internal.ui;x-internal:=true, + org.eclipse.text.quicksearch.internal.core.priority;x-friends:="org.eclipse.text.quicksearch.tests", + org.eclipse.text.quicksearch.internal.ui;x-friends:="org.eclipse.text.quicksearch.tests", org.eclipse.text.quicksearch.internal.util;x-internal:=true Import-Package: org.eclipse.core.runtime;version="3.5.0", org.eclipse.core.runtime.jobs, diff --git a/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/core/priority/DefaultPriorityFunction.java b/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/core/priority/DefaultPriorityFunction.java index fa39c900d8b..c30fac403c1 100644 --- a/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/core/priority/DefaultPriorityFunction.java +++ b/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/core/priority/DefaultPriorityFunction.java @@ -12,14 +12,10 @@ *******************************************************************************/ package org.eclipse.text.quicksearch.internal.core.priority; -import java.net.URI; -import java.util.HashSet; -import java.util.Set; - import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.runtime.IPath; import org.eclipse.text.quicksearch.internal.core.preferences.QuickSearchPreferences; /** @@ -66,15 +62,13 @@ public class DefaultPriorityFunction extends PriorityFunction { "bin", "build", "target" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ }; - public Set<IResource> ignoredResources = null; - @Override public double priority(IResource r) { if (r!=null && r.isAccessible()) { if (ignoreDerived && r.isDerived()) { return PRIORITY_IGNORE; } - if (ignoredResources!=null && ignoredResources.contains(r)) { + if (isIgnoredLinkedContainer(r)) { return PRIORITY_IGNORE; } String name = r.getName(); @@ -99,6 +93,26 @@ public class DefaultPriorityFunction extends PriorityFunction { } /** + * We want to avoid searching the same files / folders twice in cases where users have 'overlapping projects'. + * I.e a project contains folders that are actually correspond to other projects also imported in the workspace. + * <p> + * See https://issuetracker.springsource.com/browse/STS-3783 + */ + private boolean isIgnoredLinkedContainer(IResource resource) { + if (!(resource instanceof IContainer) || !resource.isLinked(IResource.NONE)) { + return false; + } + + IPath location = resource.getLocation(); + if (location == null) { + return true; + } + IWorkspaceRoot root = resource.getWorkspace().getRoot(); + IContainer linkTarget = root.getContainerForLocation(location); + return linkTarget != null; + } + + /** * Initialize some configurable settings from an instance of QuickSearchPreferences */ public void configure(QuickSearchPreferences preferences) { @@ -114,42 +128,6 @@ public class DefaultPriorityFunction extends PriorityFunction { if (pref!=null) { this.ignoredPrefixes = pref; } - computeIgnoredFolders(); } - /** - * We want to avoid searchin the same files / folders twice in cases where users have 'overlapping projects'. - * I.e a project contains folders that are actually correspond to other projects also imported in the workspace. - * <p> - * See https://issuetracker.springsource.com/browse/STS-3783 - * <p> - * This method computes a set of folders to ignore. - */ - private void computeIgnoredFolders() { - //TODO: Hopefully this won't take too long to compute. Otherwise we may need to look at ways of caching it. - // it probably doesn't change that often. - IProject[] allprojects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - for (IProject p : allprojects) { - if (p.isAccessible()) { - URI location = p.getLocationURI(); - if (location!=null) { - IContainer[] containers = ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(location); - if (containers!=null) { - for (IContainer folder : containers) { - if (!folder.equals(p)) { - ignore(folder); - } - } - } - } - } - } - } - - private void ignore(IContainer folder) { - if (ignoredResources==null) { - ignoredResources = new HashSet<>(); - } - ignoredResources.add(folder); - } } |