Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchScope.java')
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchScope.java163
1 files changed, 0 insertions, 163 deletions
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchScope.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchScope.java
deleted file mode 100644
index b39efca6afa..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchScope.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.core.text;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.runtime.IAdaptable;
-
-import org.eclipse.ui.IWorkingSet;
-
-import org.eclipse.search.internal.core.SearchScope;
-import org.eclipse.search.internal.ui.SearchMessages;
-import org.eclipse.search.internal.ui.util.StringMatcher;
-
-/**
- * A special text search scope that take file extensions into account.
- */
-public class TextSearchScope extends SearchScope {
-
- private static class WorkspaceScope extends TextSearchScope {
-
- private WorkspaceScope() {
- super(SearchMessages.getString("WorkspaceScope")); //$NON-NLS-1$
- }
-
- public void add(IResource element) {
- // do nothing
- }
-
- /**
- * @see ISearchScope#encloses(Object)
- */
- public boolean encloses(IResourceProxy proxy) {
- if (proxy.getType() == IResource.FILE && skipFile(proxy))
- return false;
- return true;
- }
- }
-
- private Set fExtensions= new HashSet(3);
-
- /**
- * Returns a new Workbench scope.
- */
- public static TextSearchScope newWorkspaceScope() {
- return new WorkspaceScope();
- }
-
- public TextSearchScope(String description) {
- super(description);
- }
-
- public TextSearchScope(String description, IResource[] resources) {
- super(description, resources);
- }
-
- public TextSearchScope(String description, IAdaptable[] elements) {
- super(description, convertToResources(elements));
-
- }
-
- public TextSearchScope(String description, IWorkingSet[] workingSets) {
- super(description, convertToResources(getElements(workingSets)));
- }
-
- private static IResource[] convertToResources(IAdaptable[] elements) {
- int length= elements.length;
- Set resources= new HashSet(length);
- for (int i= 0; i < length; i++) {
- IResource resource= (IResource)elements[i].getAdapter(IResource.class);
- if (resource != null)
- resources.add(resource);
- }
- return (IResource[])resources.toArray(new IResource[resources.size()]);
- }
-
- private static IAdaptable[] getElements(IWorkingSet[] workingSets) {
- int length= workingSets.length;
- Set elements= new HashSet(length);
- for (int i= 0; i < length; i++) {
- elements.addAll(Arrays.asList(workingSets[i].getElements()));
- }
- return (IAdaptable[])elements.toArray(new IAdaptable[elements.size()]);
- }
-
- /**
- * Adds an extension to the scope.
- */
- public void addExtension(String extension) {
- fExtensions.add(new StringMatcher(extension, true, false));
- }
- /**
- * Adds all string patterns contained in <code>extensions</code> to this
- * scope. The allowed pattern characters are <code>*</code> for any character
- * and <code>?</code> for one character.
- */
- public void addExtensions(Set extensions) {
- if (extensions == null)
- return;
- Iterator iter= extensions.iterator();
- while (iter.hasNext()) {
- Object obj= iter.next();
- if (obj instanceof String)
- addExtension((String)obj);
- }
- }
-
- /*
- * Implements method from ISearchScope
- */
- public boolean encloses(IResourceProxy proxy) {
- if (proxy.getType() == IResource.FILE && skipFile(proxy))
- return false;
- return super.encloses(proxy);
- }
-
- boolean skipFile(IResourceProxy proxy) {
- if (proxy != null) {
- Iterator iter= fExtensions.iterator();
- while (iter.hasNext()) {
- if (((StringMatcher)iter.next()).match(proxy.getName()))
- return false;
- }
- }
- return true;
- }
-
- /**
- * Implements method from ISearchScope
- *
- * @deprecated As of 2.1, replaced by {@link #encloses(IResourceProxy)}
- */
- public boolean encloses(IResource element) {
- if (element.getType() == IResource.FILE && skipFile((IFile)element))
- return false;
- return super.encloses(element);
- }
-
- boolean skipFile(IFile file) {
- if (file != null) {
- Iterator iter= fExtensions.iterator();
- while (iter.hasNext()) {
- if (((StringMatcher)iter.next()).match(file.getName()))
- return false;
- }
- }
- return true;
- }
-}

Back to the top