diff options
author | david_williams | 2008-10-01 22:56:28 +0000 |
---|---|---|
committer | david_williams | 2008-10-01 22:56:28 +0000 |
commit | 544d1c6d4bc569a0c4c0870004b1550a2b5e0532 (patch) | |
tree | 01d45d26276d701622bc60cf8ab185a1bcc1be4c /plugins/org.eclipse.wst.common.core/src-search/org | |
parent | b4a4029a3b6d8e66c440b88e7f034c490312951e (diff) | |
download | webtools.common-200810012256.tar.gz webtools.common-200810012256.tar.xz webtools.common-200810012256.zip |
This commit was manufactured by cvs2svn to create tag 'v200810012256'.v200810012256
Diffstat (limited to 'plugins/org.eclipse.wst.common.core/src-search/org')
32 files changed, 0 insertions, 2761 deletions
diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/ISearchOptions.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/ISearchOptions.java deleted file mode 100644 index 33305e5ce..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/ISearchOptions.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.core.search; - -/** - * This interface provides values that can be used in the map of search options passed - * to - * {@link SearchEngine#search(org.eclipse.wst.common.core.search.pattern.SearchPattern, SearchRequestor, org.eclipse.wst.common.core.search.scope.SearchScope, java.util.Map, org.eclipse.core.runtime.IProgressMonitor) - * SearchEngine.search()}. - * <p> - * Note that not all search participants will provide specialized behavior based on - * use of these search options. - * <p> - * Also note that individual search participants may support additional options not - * listed here. These search options should be formed so that a search participant can - * safely ignore any that it does not understand. - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - */ -public interface ISearchOptions { - - /** - * Search option specifying a trade-off choice between search performance and - * completeness. - */ - public static final String PRIORITY_OPTION = "org.eclipse.wst.common.core.search.PRIORITY"; //$NON_NLS_1$ - /** - * Choice for the {@link #PRIORITY_OPTION} search option that emphasizes - * performance at the possible expense of accuracy. This value should be used for - * all search calls made on the user interface thread. In some cases, search - * results may not be complete because of inaccuracies caused by timing windows. - */ - public static final String PRIORITY_VALUE_TIMELINESS = "FAST_SEARCH"; //$NON_NLS_1$ - /** - * Choice for the {@link #PRIORITY_OPTION} search option that emphasizes - * accuracy at the possible expense of timeliness. This value should never be used - * for search calls made on the user interface thread, because some search - * participants may choose to use time-consuming background processing to return a - * complete set of matches. - */ - public static final String PRIORITY_VALUE_COMPLETENESS = "COMPLETE_SEARCH"; //$NON_NLS_1$ - /** - * Default choice for the {@link #PRIORITY_OPTION} search option. - */ - public static final String PRIORITY_VALUE_DEFAULT = PRIORITY_VALUE_TIMELINESS; - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/SearchEngine.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/SearchEngine.java deleted file mode 100644 index 3fed11741..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/SearchEngine.java +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search; - -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.wst.common.core.search.document.SearchDocumentSet; -import org.eclipse.wst.common.core.search.internal.Messages; -import org.eclipse.wst.common.core.search.internal.SearchDocumentSetImpl; -import org.eclipse.wst.common.core.search.pattern.SearchPattern; -import org.eclipse.wst.common.core.search.scope.SearchScope; - -/** - * The {@link SearchEngine} class provides a generic way of searching for information - * without the need of knowing how or where that information is stored. The results - * returned by a search could be scattered in a number of files or stored in an index. - * Examples of the information you can search for include element declarations and - * references, references between files, and use of qualifiers. - * <p> - * The search can be limited to a specified search scope, or the entire workspace can - * be searched. Search matches are returned to the specified {@link SearchRequestor}. - * <p> - * This class may be instantiated; it is not intended to be subclassed. - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - */ -public class SearchEngine implements ISearchOptions -{ - - /** - * Searches for matches of a given search pattern using a specified set of search - * participants and search scope. Search patterns can be created using factory - * methods and encapsulate the description of the information to be searched for - * (for example, element declarations of a specified type, in a case sensitive - * manner). - * @param pattern - * The pattern describing the information to search for - * @param requestor - * Callback object to notify with the results of the search (each match - * is reported to {@link SearchRequestor#acceptSearchMatch(SearchMatch)}) - * @param participants - * The search participants that will conduct the search - * @param scope - * Optional search scope to limit the source of search candidates; - * specify <code>null</code> to search the entire workspace - * @param searchOptions - * Optional map of options and values defining behavior of the search; - * some options and values are provided by {@link ISearchOptions} - * @param monitor - * Optional progress monitor used to report work completed - * @exception CoreException - * if the search fails - */ - public void search(SearchPattern pattern, SearchRequestor requestor, - SearchParticipant[] participants, SearchScope scope, Map searchOptions, - IProgressMonitor monitor) throws CoreException - { - - if (monitor != null && monitor.isCanceled()) - throw new OperationCanceledException(); - - /* initialize progress monitor */ - if (monitor != null) - monitor.beginTask(Messages.engine_searching, 100); - - SearchDocumentSet set = new SearchDocumentSetImpl(); - try - { - // requestor.beginReporting(); - SearchScope[] scopeArray = new SearchScope[participants.length]; - for (int i = 0, l = participants == null ? 0 : participants.length; i < l; i++) - { - if (monitor != null && monitor.isCanceled()) - throw new OperationCanceledException(); - - SearchParticipant participant = participants[i]; - SubProgressMonitor subMonitor = monitor == null ? null - : new SubProgressMonitor(monitor, 1000); - if (subMonitor != null) - subMonitor.beginTask("", 1000); //$NON-NLS-1$ - try - { - if (subMonitor != null) - subMonitor.subTask(Messages.bind( - Messages.engine_searching_locatingDocuments, - new String[] - { participant.getDescription() })); - participant.beginSearching(pattern, searchOptions); - // requestor.enterParticipant(participant); - // participant creates it's own search scope - SearchScope newScope = - participant.selectDocumentLocations(pattern, scope, searchOptions, monitor); - scopeArray[i] = newScope; - // participant creates search documents based on it's search scope - participant.createSearchDocuments(set, pattern, newScope, searchOptions, subMonitor); - } - catch(Exception e) - { - } - } - for (int i = 0, l = participants == null ? 0 : participants.length; i < l; i++) - { - if (monitor != null && monitor.isCanceled()) - throw new OperationCanceledException(); - - SearchParticipant participant = participants[i]; - SubProgressMonitor subMonitor = monitor == null ? null - : new SubProgressMonitor(monitor, 1000); - if (subMonitor != null && subMonitor.isCanceled()) - throw new OperationCanceledException(); - try - { - // locate index matches if any (note that all search matches - // could have been issued during index querying) - if (subMonitor != null) - subMonitor.subTask(Messages.bind( - Messages.engine_searching_matching, - new String[] - { participant.getDescription() })); - // a search document set should contain enough info to reduce the search scope even further - // before finding precize locations - - // the scope could be null if the partcipant barfed and exeption in the first loop - if (scopeArray[i] != null) - { - participant.locateMatches(set, pattern, scopeArray[i], requestor, searchOptions, subMonitor); - } - } - catch (Exception e) - { - - } - finally - { - // requestor.exitParticipant(participant); - participant.doneSearching(pattern, searchOptions); - } - } - } finally - { - set.dispose(); - // requestor.endReporting(); - if (monitor != null) - monitor.done(); - } - } - - /** - * Searches for matches of a given search pattern. Search patterns can be created - * using factory methods and encapsulate the description of the information to be - * searched for (for example, element declarations of a specified type, in a case - * sensitive manner). - * @param pattern - * The pattern describing the information to search for - * @param requestor - * Callback object to notify with the results of the search (each match - * is reported to {@link SearchRequestor#acceptSearchMatch(SearchMatch)}) - * @param scope - * Optional search scope to limit the source of search candidates; - * specify <code>null</code> to search the entire workspace - * @param searchOptions - * Optional map of options and values defining behavior of the search; - * some options and values are provided by {@link ISearchOptions} - * @param monitor - * Optional progress monitor used to report work completed - * @exception CoreException - * if the search fails - */ - public void search(SearchPattern pattern, SearchRequestor requestor, - SearchScope scope, Map searchOptions, IProgressMonitor monitor) - throws CoreException - { - SearchParticipant[] participants = - getApplicableParticipants(pattern, searchOptions); - //System.out.println("participants = " + participants.length); - search(pattern, requestor, participants, scope, searchOptions, monitor); - } - - /** - * Queries the set of participants that support searches described by the - * specified search pattern and options. - * @param pattern - * The pattern describing the information to search for - * @param searchOptions - * Optional map of options and values defining behavior of the search; - * some options and values are provided by {@link ISearchOptions} - * @return Array of applicable search participants - */ - public SearchParticipant[] getApplicableParticipants(SearchPattern pattern, - Map searchOptions) - { - return SearchPlugin.getDefault().loadSearchParticipants(pattern, searchOptions); - } - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/SearchMatch.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/SearchMatch.java deleted file mode 100644 index 11969e55a..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/SearchMatch.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Platform; - -/** - * A search match represents the result of a search query. - * <p> - * This class is intended to be instantiated and subclassed by clients. - * </p> - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - * - * @see SearchEngine#search(org.eclipse.wst.common.core.search.pattern.SearchPattern, SearchParticipant[], ISearchScope, - * SearchRequestor, org.eclipse.core.runtime.IProgressMonitor) - */ -public class SearchMatch implements IAdaptable -{ - - /** - * Optional resource of the element - */ - IFile file; // resource where match is found - - /** - * The offset the match starts at, or -1 if unknown - */ - int offset; - - /** - * The length the length of the match, or -1 if unknown - */ - int length; - - /** - * Optional element that encloses or corresponds to the match - */ - Object object; - - /** - * Creates a new search match. - * - * @param element - * the element that encloses or corresponds to the match, or - * <code>null</code> if none - * @param offset - * the offset the match starts at, or -1 if unknown - * @param length - * the length of the match, or -1 if unknown - * @param participant - * the search participant that created the match - * @param resource - * the resource of the element, or <code>null</code> if none - */ - public SearchMatch(Object element, int offset, int length, IFile resource) - { - this.object = element; - this.offset = offset; - this.length = length; - this.file = resource; - } - - public IFile getFile() - { - return file; - } - - public void setFile(IFile file) - { - this.file = file; - } - - public int getLength() - { - return length; - } - - public void setLength(int length) - { - this.length = length; - } - - // issue (cs/eb) holding objects is a bit odd, since it implies the object's - // life span - // is the same as the SearchMatch. What happens when an object is deleted? - // does the SearchMatch get deleted? Aren't coordinates good enough? - // at the very least we should document that using this field has some - // consequences - /** - * (eb) see comments for {@link #setObject(Object)} - */ - public Object getObject() - { - return object; - } - - /** - * @param object - * Object is an instance of some part of the model that represent - * the content that was searched. It may require to calculate - * some additional information that may be required by the tools - * through {@link #getObject()) (e.g. XML node namespace, - * nessesary to obtain the prefix for the refactoring tool). - * <p> - * There should be no danger here of preventing the object from - * garbage collection because instances of the search matches - * supposed to be short lived. {@link SearchMatch} is usually - * collected by {@link SearchRequestor} which itself is lived for - * the time of the search and then discarded or re-initialized. - * Usually the tool that requested a search extracts the - * information from the collected {@link SearchMatch} and after - * that {@link SearchMatch} could be garbage collected, releasing - * object that they hold to. - * </p> - */ - public void setObject(Object object) - { - this.object = object; - } - - public int getOffset() - { - return offset; - } - - public void setOffset(int offset) - { - this.offset = offset; - } - - public Object getAdapter(Class adapter) - { - return Platform.getAdapterManager().getAdapter(this, adapter); - } - - public Map map = new HashMap(); - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/SearchParticipant.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/SearchParticipant.java deleted file mode 100644 index 95a044641..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/SearchParticipant.java +++ /dev/null @@ -1,281 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search; - -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.wst.common.core.search.document.SearchDocument; -import org.eclipse.wst.common.core.search.document.SearchDocumentSet; -import org.eclipse.wst.common.core.search.pattern.SearchPattern; -import org.eclipse.wst.common.core.search.scope.SearchScope; - -/** - * <p> - * A search participant describes a particular extension to a generic search - * mechanism, permitting combined search actions which will involve all required - * participants. - * </p> - * <p> - * When there is a need to search a document that has some mixed content, then - * using a one participant will not be enough. E.g. for the searching of the JSP - * content, a JSP participant needs to create {@link SearchDocument} that - * contain Java compilation unit and then pass it to the default Java search - * participant of the Java Search Engine. The same with XML: when there is an - * XML content that default search participant could not process, but it is - * required to be search on, a new search participant needs to be defined. That - * search participant would know how create search document from the content and - * then it can call default XML search participant. - * </p> - * <p> - * Passing its own {@link SearchRequestor} this participant can then map the - * match positions back to the original contents, create its own matches and - * report them to the original requestor. - * </p> - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - * - */ -public abstract class SearchParticipant implements ISearchOptions -{ - - protected static final boolean debugPerf = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.common.core/perf")); //$NON-NLS-1$ //$NON-NLS-2$ - - protected String id; - /** - * Creates a new search participant. - */ - protected SearchParticipant() - { - // do nothing - } - - /** - * Callback method allowing a search participant to indicate whether it supports - * the specified search pattern and options. - * <p> - * If this method returns <code>true</code>, the participant will participate in - * finding matches for the search defined by the search pattern. In this case, the - * search pattern and options will be passed to the following methods of the - * search participant: - * <ol> - * <li>{@link #beginSearching(SearchPattern, Map)} - * <li>{@link #selectDocumentLocations(SearchPattern, SearchScope, Map, IProgressMonitor)} - * <li>{@link #createSearchDocuments(SearchDocumentSet, SearchPattern, SearchScope, Map, IProgressMonitor)} - * <li>{@link #locateMatches(SearchDocumentSet, SearchPattern, SearchScope, SearchRequestor, Map, IProgressMonitor)} - * <li>{@link #doneSearching(SearchPattern, Map)} - * </ol> - * <p> - * If this method returns <code>false</code>, none of the above methods will be - * called, and the search participant contributes no matches for the search - * requrest. - * <p> - * A search participant should only participate in a search when in understands - * the search pattern. Unrecognized search options, however, can be ignored. - * <p> - * This method returns <code>false</code> by default. As a result, subclasses must - * override this method to participate in any searches. - * @param pattern The pattern describing the information to search for - * @param searchOptions Map of options and values defining behavior of the search; - * <code>null</code> if no options are specified; - * some options and values are provided by {@link ISearchOptions} - * @return <code>true</code> if the search participant will participate in the - * search request; <code>false</code> otherwise - */ - public abstract boolean isApplicable(SearchPattern pattern, Map searchOptions); - - /** - * Notification that this participant's help is needed in a search. - * <p> - * This method should be re-implemented in subclasses that need to do - * something when the participant is needed in a search. - * </p> - * @param pattern The pattern describing the information to search for - * @param searchOptions Map of options and values defining behavior of the search; - * <code>null</code> if no options are specified; - * some options and values are provided by {@link ISearchOptions} - */ - public void beginSearching(SearchPattern pattern, Map searchOptions) - { - // do nothing - } - - /** - * Notification that this participant's help is no longer needed. - * <p> - * This method should be re-implemented in subclasses that need to do - * something when the participant is no longer needed in a search. - * </p> - * @param pattern - * The pattern describing the information to search for - * @param searchOptions - * Map of options and values defining behavior of the search; - * <code>null</code> if no options are specified; - * some options and values are provided by {@link ISearchOptions} - */ - public void doneSearching(SearchPattern pattern, Map searchOptions) - { - // do nothing - } - - /** - * Returns a displayable name of this search participant. - * <p> - * This method should be re-implemented in subclasses that need to display a - * meaningfull name. - * </p> - * - * @return the displayable name of this search participant - */ - public String getDescription() - { - return "Search participant"; //$NON-NLS-1$ - } - - /** - * Returns a search document for the given path. The given document path is - * a string that uniquely identifies the document. Most of the time it is a - * workspace-relative path, but it can also be a file system path, or a path - * inside a zip file. - * <p> - * Implementors of this method can either create an instance of their own - * subclass of {@link SearchDocument} or return an existing instance of such - * a subclass. - * </p> - * - * @param documentPath - * the path of the document. - * @return a search document - */ - public abstract SearchDocument createSearchDocument(String documentPath); - - /** - * Locates the matches in the given documents. This method should be called - * by the other search participant or search client once it has - * pre-processed documents and delegating search to this search participant. - * @param documentSet - * The documents to locate matches in - * @param pattern - * The pattern describing the information to search for - * @param scope - * Search scope to limit the source of search candidates; - * <code>null</code> indicates that the entire workspace is to be - * searched - * @param requestor - * Callback object to notify with the results of the search (each match - * is reported to {@link SearchRequestor#acceptSearchMatch(SearchMatch)}) - * @param searchOptions - * Map of options and values defining behavior of the search; - * <code>null</code> if no options are specified; - * some options and values are provided by {@link ISearchOptions} - * @param monitor - * Progress monitor used to report work completed; <code>null</code> - * if no progress needs to be reported - * @throws CoreException - * If the requestor had problem accepting one of the matches - */ - public abstract void locateMatches(SearchDocumentSet documentSet, - SearchPattern pattern, SearchScope scope, - SearchRequestor requestor, Map searchOptions, IProgressMonitor monitor) - throws CoreException; - - /** - * - * @param document - * @param pattern - */ - public abstract void populateSearchDocument(SearchDocument document, - SearchPattern pattern); - - /** - * Returns the collection of document locations to consider when performing - * the given search query in the given scope. The search engine calls this - * method before locating matches. - * <p> - * An document location represents a path workspace to the file with the - * content that has potential matches - * </p> - * <p> - * Clients are not expected to call this method. - * </p> - * @param pattern - * The pattern describing the information to search for - * @param scope - * Search scope to limit the source of search candidates; - * <code>null</code> indicates that the entire workspace is to be - * searched - * @param searchOptions - * Map of options and values defining behavior of the search; - * <code>null</code> if no options are specified; - * some options and values are provided by {@link ISearchOptions} - * @param monitor - * Progress monitor used to report work completed; <code>null</code> - * if no progress needs to be reported - * @return the collection of document paths to consider - */ - public SearchScope selectDocumentLocations(SearchPattern pattern, - SearchScope scope, Map searchOptions, IProgressMonitor monitor) - { - return scope; - } - - /** - * <p> - * This method calls the following methods for each file in the search scope: - * <ol> - * <li>{@link #createSearchDocument(String)} - * <li>{@link #populateSearchDocument(SearchDocument, SearchPattern)} - * </ol> - * @param documentSet - * The documents to locate matches in - * @param pattern - * The pattern describing the information to search for - * @param scope - * Search scope to limit the source of search candidates; - * <code>null</code> indicates that the entire workspace is to be - * searched - * @param searchOptions - * Map of options and values defining behavior of the search; - * <code>null</code> if no options are specified; - * some options and values are provided by {@link ISearchOptions} - * @param monitor - * Progress monitor used to report work completed; <code>null</code> - * if no progress needs to be reported - */ - public void createSearchDocuments(SearchDocumentSet documentSet, - SearchPattern pattern, SearchScope scope, Map searchOptions, - IProgressMonitor monitor) - { - Assert.isNotNull(id, "The SearchPartipants id has not been initalized"); - IFile[] files = scope.enclosingFiles(); - - for (int i = 0; i < files.length; i++) - { - String location = files[i].getLocation().toString(); - SearchDocument document = documentSet.getSearchDocument(location, id); - if(document == null && id != null){ - documentSet.putSearchDocument(id, document = createSearchDocument(location)); - } - populateSearchDocument(document, pattern); - - } - - } -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/SearchPlugin.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/SearchPlugin.java deleted file mode 100644 index cf7a9fc01..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/SearchPlugin.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search; - -import java.util.Map; - -import org.eclipse.core.runtime.Plugin; -import org.eclipse.wst.common.core.search.internal.SearchParticipantRegistry; -import org.eclipse.wst.common.core.search.internal.SearchParticipantRegistryReader; -import org.eclipse.wst.common.core.search.pattern.SearchPattern; -import org.osgi.framework.BundleContext; - -/** - * The main plugin class to be used in the desktop. - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - */ -public class SearchPlugin extends Plugin implements ISearchOptions -{ - - private SearchParticipantRegistry searchParticipantRegistry; - - // The shared instance. - private static SearchPlugin plugin; - - /** - * The constructor. - */ - public SearchPlugin() - { - plugin = this; - } - - /** - * This method is called upon plug-in activation - */ - public void start(BundleContext context) throws Exception - { - super.start(context); - } - - /** - * This method is called when the plug-in is stopped - */ - public void stop(BundleContext context) throws Exception - { - super.stop(context); - plugin = null; - } - - /** - * Returns the shared instance. - */ - public static SearchPlugin getDefault() - { - return plugin; - } - - private SearchParticipantRegistry getSearchParticipantRegistry() - { - if (searchParticipantRegistry == null) - { - searchParticipantRegistry = new SearchParticipantRegistry(); - new SearchParticipantRegistryReader(searchParticipantRegistry) - .readRegistry(); - } - return searchParticipantRegistry; - } - - - public SearchParticipant getSearchParticipant(String id) - { - return getSearchParticipantRegistry().getSearchParticipant(id); - } - - /** - * Returns the registered search participants that support the specified search - * pattern and options, loading and creating the search participants if necessary. - * @param pattern The pattern representing a search request - * @param searchOptions Map of options and values defining behavior of the search; - * <code>null</code> if no options are specified; - * some options and values are provided by {@link ISearchOptions} - * @return Array of search participants that support the specified search request - */ - SearchParticipant[] loadSearchParticipants(SearchPattern pattern, Map searchOptions) - { - return getSearchParticipantRegistry().getParticipants(pattern, searchOptions); - } - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/SearchRequestor.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/SearchRequestor.java deleted file mode 100644 index 460b589a8..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/SearchRequestor.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search; - -import org.eclipse.core.runtime.CoreException; - -/** - * Collects the results from a search engine query. Clients implement a subclass - * to pass to <code>SearchEngine.search</code> and implement the - * {@link #acceptSearchMatch(SearchMatch)} method. - * <p> - * The subclasses of the SearchRequestor could collected search matches, filter, - * sort and group them. It's up to the client to pass the required extension of - * the SearchRequestor to the search engine. - * </p> - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - * - * @see SearchEngine - */ -public abstract class SearchRequestor -{ - - /** - * Accepts the given search match. - * - * @param match - * the found match - * @throws CoreException - */ - public abstract void acceptSearchMatch(SearchMatch match) - throws CoreException; - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/ComponentDeclarationEntry.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/ComponentDeclarationEntry.java deleted file mode 100644 index f19393724..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/ComponentDeclarationEntry.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.document; - -import org.eclipse.wst.common.core.search.pattern.QualifiedName; - -/** - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - * - */ -public class ComponentDeclarationEntry extends Entry -{ - QualifiedName metaName; - QualifiedName name; - - public QualifiedName getName() - { - return name; - } - - public void setName(QualifiedName name) - { - this.name = name; - } - - public QualifiedName getMetaName() - { - return metaName; - } - - public void setMetaName(QualifiedName metaName) - { - this.metaName = metaName; - } -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/ComponentReferenceEntry.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/ComponentReferenceEntry.java deleted file mode 100644 index d532f267d..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/ComponentReferenceEntry.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.document; - -import org.eclipse.wst.common.core.search.pattern.QualifiedName; - -/** - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - * - */ -public class ComponentReferenceEntry extends Entry -{ - QualifiedName name; - - public QualifiedName getName() - { - return name; - } - - public void setName(QualifiedName name) - { - this.name = name; - } -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/Entry.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/Entry.java deleted file mode 100644 index acd10a628..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/Entry.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.document; - -/** - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - * - */ -public class Entry -{ - String key; - String category; - - public Entry() -{ - super(); - -} - - public String getCategory() - { - return category; - } - - - - public String getKey() - { - return key; - } - - public void setCategory(String category) - { - this.category = category; - } - - public void setKey(String key) - { - this.key = key; - } - - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/FileReferenceEntry.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/FileReferenceEntry.java deleted file mode 100644 index 278950304..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/FileReferenceEntry.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.document; - -/** - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - * - */ -public class FileReferenceEntry extends Entry -{ - String relativeFilePath; - String resolvedURI; - String publicIdentifier; - - public String getPublicIdentifier() - { - return publicIdentifier; - } - - public void setPublicIdentifier(String publicIdentifier) - { - this.publicIdentifier = publicIdentifier; - } - - public String getRelativeFilePath() - { - return relativeFilePath; - } - - public void setRelativeFilePath(String relativeFilePath) - { - this.relativeFilePath = relativeFilePath; - } - - public String getResolvedURI() - { - return resolvedURI; - } - - public void setResolvedURI(String resolvedURI) - { - this.resolvedURI = resolvedURI; - } -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/SearchDocument.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/SearchDocument.java deleted file mode 100644 index d9bfcb9b5..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/SearchDocument.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.document; - -import org.eclipse.wst.common.core.search.SearchParticipant; - -/** - * A search document encapsulates a content to be searched in. A search - * participant creates a search document based on the file locations to locate - * matches. - * <p> - * This class is intended to be subclassed by clients. - * </p> - * issue (cs/eb) does a search participant always create a SearchDocument? - * - * <p> - * SearchParticipant or search client create search documents for the search - * pass where precise locations of the matches will be determined by calling - * {@link SearchParticipan#locateMatches} - * </p> - * <p> - * SearchParticipant knows how to create search document that it can process. - * </p> - * <p> - * The intent of the separation of the {@link SearchDocument} from the - * {@link SearchParticipant} is to enable the other search participants to - * process parts of the document. For example, if XML document has a fragment - * that it can not process, e.g. Java, then XML participant would create - * SearchDocument for that fragment which contains Java compilation unit, and - * pass it to the Java search participant. Passing its own - * {@link org.eclipse.wst.common.core.search.SearchRequestor} this participant can then map the match positions - * back to the original contents, create its own matches and report them to the - * original requestor. - * </p> - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - * - * @see SearchParticipant - */ -public abstract class SearchDocument -{ - - private String documentPath; - private SearchParticipant participant; - - /** - * Creates a new search document. The given document path is a string that - * uniquely identifies the document. Most of the time it is a - * workspace-relative path, but it can also be a file system path, or a path - * inside a zip file. - * - * @param documentPath - * the path to the document, or <code>null</code> if none - */ - protected SearchDocument(String documentPath, SearchParticipant participant) - { - this.documentPath = documentPath; - this.participant = participant; - } - - public abstract Entry[] getEntries(String category, String key, int matchRule); - - /** - * Returns the model of this document. Model may be different from actual - * resource at corresponding document path due to preprocessing. - * <p> - * This method must be implemented in subclasses. - * </p> - * - * @return the model of this document, or <code>null</code> if none - */ - public abstract Object getModel(); - - - /** - * Returns the participant that created this document. - * - * @return the participant that created this document - */ - public final SearchParticipant getParticipant() { - return this.participant; - } - - -// this class represents a collection of information -// that has been produced by a search participant -// typically after a file has been processed -// an Entry is typically course grained info that results from the SearchParticipants -// first step ... and is used to compute more accurate SearchMatches during a SearchParticipants 2nd step - - /** - * Returns the path to the original document. - * - * @return the path to the document - */ - public final String getPath() - { - return this.documentPath; - } - - public abstract void putEntry(Entry entry); - - public void dispose() - { - } -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/SearchDocumentSet.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/SearchDocumentSet.java deleted file mode 100644 index 42fb34cd5..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/document/SearchDocumentSet.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.document; - -/** - * The class is used to manage a set of search documents - * that have been constructed by various participants - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - * - */ -public abstract class SearchDocumentSet -{ - public abstract SearchDocument getSearchDocument(String resourcePath, String participantId); - public abstract SearchDocument[] getSearchDocuments(String participantId); - public abstract void putSearchDocument(String participantId, SearchDocument document); - public abstract SearchDocument _tempGetSearchDocumetn(String resourcePath); - public abstract void dispose(); -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/Messages.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/Messages.java deleted file mode 100644 index 8041e9c52..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/Messages.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.internal; - -import org.eclipse.osgi.util.NLS; - -// issue (cs) is this a UI issue? where does the framework need to expose stings? -public class Messages extends NLS -{ - - private static final String BUNDLE_NAME = "org.eclipse.wst.common.core.search.internal.messages";//$NON-NLS-1$ - - public static String engine_searching; - - public static String engine_searching_locatingDocuments; - - public static String engine_searching_matching; - - private Messages() - { - // Do not instantiate - } - - static - { - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/SearchDocumentSetImpl.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/SearchDocumentSetImpl.java deleted file mode 100644 index e3f6c33c8..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/SearchDocumentSetImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.internal; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.wst.common.core.search.document.SearchDocument; -import org.eclipse.wst.common.core.search.document.SearchDocumentSet; - -public class SearchDocumentSetImpl extends SearchDocumentSet -{ - public Map documentPathMap = new HashMap(); //path --> documetn - Map documentMap = new HashMap(); // participantId - > list (document) - - public SearchDocumentSetImpl() - { - super(); - } - - public SearchDocument _tempGetSearchDocumetn(String resourcePath) - { - return (SearchDocument)documentPathMap.get(resourcePath); - } - - public SearchDocument getSearchDocument(String resourcePath, String participantId) - { - if(resourcePath == null){ - return null; - } - SearchDocument[] documents = getSearchDocuments(participantId); - for (int i = 0; i < documents.length; i++) - { - SearchDocument document = documents[i]; - if(resourcePath.equals(document.getPath())){ - return document; - } - } - return null; - } - - public SearchDocument[] getSearchDocuments(String participantId) - { - - Object object = documentMap.get(participantId); - List documentList = null; - if(object instanceof List){ - documentList = (List)object; - } - else{ - documentMap.put(participantId, documentList = new ArrayList()); - } - return (SearchDocument[]) documentList.toArray(new SearchDocument[documentList.size()]); - - } - - public void putSearchDocument(String participantId, SearchDocument document) - { - Object object = documentMap.get(participantId); - List documentList = null; - if(object instanceof List){ - documentList = (List)object; - } - else{ - documentMap.put(participantId, documentList = new ArrayList()); - } - documentList.add(document); - documentPathMap.put(document.getPath(), document); - } - - - public void dispose() - { - try - { - for (Iterator i = documentMap.values().iterator(); i.hasNext(); ) - { - Object o = i.next(); - if (o instanceof List) - { - for (Iterator j = ((List)o).iterator(); j.hasNext(); ) - { - Object o2 = j.next(); - if (o2 instanceof SearchDocument) - { - SearchDocument searchDocument = (SearchDocument)o2; - searchDocument.dispose(); - } - } - } - } - } - catch (Exception e) - { - e.printStackTrace(); - } - } - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/SearchParticipantDescriptor.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/SearchParticipantDescriptor.java deleted file mode 100644 index 8e39e12fa..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/SearchParticipantDescriptor.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.internal; - -import org.eclipse.core.expressions.EvaluationResult; -import org.eclipse.core.expressions.Expression; -import org.eclipse.core.expressions.ExpressionConverter; -import org.eclipse.core.expressions.ExpressionTagNames; -import org.eclipse.core.expressions.IEvaluationContext; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.wst.common.core.search.SearchParticipant; - -public class SearchParticipantDescriptor -{ - - private IConfigurationElement fElement; - - private SearchParticipant participant; - - public SearchParticipantDescriptor(IConfigurationElement element) - { - this.fElement = element; - } - - public SearchParticipant getSearchParticipant() - { - if (participant == null) - { - try - { - participant = (SearchParticipant) fElement - .createExecutableExtension("class"); //$NON-NLS-1$ - } catch (Exception e) - { - // e.printStackTrace(); - } - } - return participant; - } - - public boolean matches(IEvaluationContext context) throws CoreException - { - IConfigurationElement[] elements = fElement - .getChildren(ExpressionTagNames.ENABLEMENT); - if (elements.length == 0) - return false; - Assert.isTrue(elements.length == 1); - Expression exp = ExpressionConverter.getDefault().perform(elements[0]); - return convert(exp.evaluate(context)); - } - - private boolean convert(EvaluationResult eval) - { - if (eval == EvaluationResult.FALSE) - return false; - return true; - } - - /** - * @deprecated No replacement - */ - public String[] getSupportedContentTypes() - { - return new String[0]; - } - - /** - * @deprecated No replacement - */ - public void addSupportedContentTypeId(String contentTypeId) - { - } - - public String getElementId(){ - return fElement.getAttribute("id"); - - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/SearchParticipantRegistry.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/SearchParticipantRegistry.java deleted file mode 100644 index a169e91b9..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/SearchParticipantRegistry.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.internal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.eclipse.core.expressions.EvaluationContext; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.wst.common.core.search.SearchParticipant; -import org.eclipse.wst.common.core.search.pattern.SearchPattern; - -public class SearchParticipantRegistry -{ - - protected Map idMap = new HashMap(); // maps searchParticipant id to a - // searchParticipant descriptor - - public SearchParticipantRegistry() - { - } - - public void putSearchParticipant(String id, - SearchParticipantDescriptor searchParticipantDescriptor) - { - idMap.put(id, searchParticipantDescriptor); - } - - public String[] getSearchParticipantIds() - { - Set ids = idMap.keySet(); - return (String[]) ids.toArray(new String[ids.size()]); - } - - public Collection getSearchParticipants() - { - return idMap.values(); - } - - - public SearchParticipant getSearchParticipant(String id) - { - SearchParticipantDescriptor searchParticipantDescriptor = null; - if (id != null) - { - searchParticipantDescriptor = (SearchParticipantDescriptor) idMap - .get(id); - } - return searchParticipantDescriptor != null ? searchParticipantDescriptor - .getSearchParticipant() - : null; - - } - - public SearchParticipant[] getParticipants(SearchPattern pattern, Map searchOptions) - { - - EvaluationContext evalContext = createEvaluationContext(pattern); - List result = new ArrayList(); - for (Iterator iter = getSearchParticipants().iterator(); iter.hasNext();) - { - SearchParticipantDescriptor descriptor = (SearchParticipantDescriptor) iter - .next(); - try - { - if (descriptor.matches(evalContext)) - { - try - { - SearchParticipant participant = descriptor - .getSearchParticipant(); - if (!SearchParticipant.class.isInstance(participant)) - throw new ClassCastException(); - if (participant.isApplicable(pattern, searchOptions)) - { - result.add(participant); - } - } catch (ClassCastException e) - { - iter.remove(); - } - } - - } catch (CoreException e) - { - iter.remove(); - } - - } - - return (SearchParticipant[]) result - .toArray(new SearchParticipant[result.size()]); - } - - private static EvaluationContext createEvaluationContext( - SearchPattern pattern) - { - EvaluationContext result = new EvaluationContext(null, pattern); - result.addVariable("pattern", pattern); //$NON-NLS-1$ - return result; - } - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/SearchParticipantRegistryReader.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/SearchParticipantRegistryReader.java deleted file mode 100644 index 7757ce3e7..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/SearchParticipantRegistryReader.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.internal; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.Platform; - -public class SearchParticipantRegistryReader -{ - protected static final String EXTENSION_POINT_ID = "searchParticipants"; //$NON-NLS-1$ - - protected static final String TAG_NAME = "searchParticipant"; //$NON-NLS-1$ - - protected static final String ATT_CLASS = "class"; //$NON-NLS-1$ - - protected static final String ATT_ID = "id"; //$NON-NLS-1$ - - protected String pluginId, extensionPointId; - - protected SearchParticipantRegistry registry; - - public SearchParticipantRegistryReader(SearchParticipantRegistry registry) - { - this.registry = registry; - } - - public void readRegistry() - { - String bundleid = "org.eclipse.wst.common.core"; //$NON-NLS-1$ - IExtensionPoint point = Platform.getExtensionRegistry() - .getExtensionPoint(bundleid, EXTENSION_POINT_ID); - if (point != null) - { - IConfigurationElement[] elements = point.getConfigurationElements(); - for (int i = 0; i < elements.length; i++) - { - readElement(elements[i]); - } - } - } - - protected void readElement(IConfigurationElement element) - { - if (element.getName().equals(TAG_NAME)) - { - String contributorClass = element.getAttribute(ATT_CLASS); - String id = element.getAttribute(ATT_ID); - if (id != null) - { - if (contributorClass != null) - { - SearchParticipantDescriptor descriptor = new SearchParticipantDescriptor( - element); - registry.putSearchParticipant(id, descriptor); - } - } - } - } -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/messages.properties b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/messages.properties deleted file mode 100644 index e3a01a83e..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/internal/messages.properties +++ /dev/null @@ -1,15 +0,0 @@ -############################################################################### -# Copyright (c) 2005, 2006 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -### Search messages. - -engine_searching = Searching... -engine_searching_locatingDocuments = {0}: locate search documents... -engine_searching_matching = {0}: locate matches... diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/ComponentDeclarationPattern.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/ComponentDeclarationPattern.java deleted file mode 100644 index 16f3ffe8f..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/ComponentDeclarationPattern.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.pattern; - -/** - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - * - */ -public class ComponentDeclarationPattern extends ComponentSearchPattern -{ - - public ComponentDeclarationPattern(QualifiedName name, - QualifiedName metaName, int matchRule) - { - super(null, name, metaName, matchRule); - - } - - public ComponentDeclarationPattern(QualifiedName name, - QualifiedName metaName) - { - super(null, name, metaName); - } - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/ComponentReferencePattern.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/ComponentReferencePattern.java deleted file mode 100644 index 2f1e101cc..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/ComponentReferencePattern.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.pattern; - -import org.eclipse.core.resources.IFile; - -/** - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - * - */ -public class ComponentReferencePattern extends ComponentSearchPattern -{ - - public ComponentReferencePattern(IFile file, QualifiedName elementQName, - QualifiedName typeQName, int matchRule) - { - super(file, elementQName, typeQName, matchRule); - - } - - public ComponentReferencePattern(IFile file, QualifiedName elementQName, - QualifiedName typeQName) - { - super(file, elementQName, typeQName); - - } - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/ComponentSearchPattern.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/ComponentSearchPattern.java deleted file mode 100644 index 4741a10e2..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/ComponentSearchPattern.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.pattern; - -import org.eclipse.core.resources.IFile; - -/** - * This class defines generic component pattern. Usually there are two types of - * component search patterns: pattern for component declaration and for - * component definition. - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - */ -public abstract class ComponentSearchPattern extends SearchPattern -{ - - QualifiedName name; - - QualifiedName metaName; - - IFile file; // (optional) location where component is defined - - public ComponentSearchPattern(IFile file, QualifiedName elementQName, - QualifiedName typeQName, int matchRule) - { - super(matchRule); - this.file = file; - name = elementQName; - metaName = typeQName; - - } - - public ComponentSearchPattern(IFile file, QualifiedName elementQName, - QualifiedName typeQName) - { - - this.file = file; - name = elementQName; - metaName = typeQName; - - } - - public IFile getFile() - { - return file; - } - - public QualifiedName getMetaName() - { - return metaName; - } - - public QualifiedName getName() - { - return name; - } - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/FileReferencePattern.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/FileReferencePattern.java deleted file mode 100644 index 27c116593..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/FileReferencePattern.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.pattern; - -import org.eclipse.core.resources.IFile; - -/** - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - * - */ -public class FileReferencePattern extends SearchPattern -{ - - IFile file; - - public FileReferencePattern(IFile file) - { - this.file = file; - } - - public FileReferencePattern(IFile file, int matchRule) - { - super(matchRule); - this.file = file; - } - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/QualifiedName.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/QualifiedName.java deleted file mode 100644 index 0f7ab170d..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/QualifiedName.java +++ /dev/null @@ -1,226 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.pattern; - -/** - * This data class represents a qualified name, consisting of a local name and a - * qualifier - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - */ -// issue (cs) should this go in the 'matching' package (BTW... rename -// matching->pattern) -public class QualifiedName -{ - - private String qualifier; - - private String name; - - private static final String NS_DELIM_1 = "{"; //$NON-NLS-1$ - - private static final String NS_DELIM_2 = "}"; //$NON-NLS-1$ - - /** - * Constructor Creates a qualified name from a namespace and local name. - * - * @param namespace - * @param localName - */ - public QualifiedName(String namespace, String localName) - { - - super(); - - this.qualifier = namespace; - if (namespace != null && namespace.length() == 0) - { - this.qualifier = null; - } - if (this.qualifier != null && this.qualifier.length() == 0) - { - this.qualifier = null; - } - - this.name = localName; - if (localName != null && localName.length() == 0) - { - this.name = null; - } - - } - - /** - * Returns the namespace component of the qualified name. - * - * @return The namespace; <code>null</code> if none is specified - */ - public String getNamespace() - { - return this.qualifier; - } - - /** - * Returns the local name component of the qualified name. - * - * @return The local name; <code>null</code> if none is specified - */ - public String getLocalName() - { - return this.name; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) - { - boolean isEqual = false; - if (this == obj) - { - isEqual = true; - } - else - { - if (obj instanceof QualifiedName) - { - QualifiedName that = (QualifiedName) obj; - isEqual = isMatch(this.getNamespace(), that.getNamespace()) && - isMatch(this.getLocalName(), that.getLocalName()); - } - } - return isEqual; - } - - protected boolean isMatch(String a, String b) - { - return a != null ? a.equals(b) : a == b; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - public int hashCode() - { - int hash = 0; - if (this.qualifier != null) - { - hash += this.qualifier.hashCode(); - } - if (this.name != null) - { - hash += this.name.hashCode(); - } - return hash; - } - - /** - * Returns a string representation of the qualified name, of the form: - * {namespace}localname. If no namespace is specified, the string has the - * form: {}localname. Note that the string format may change in the future. - * - * @return The string value - */ - public String toString() - { - - return appendStrings(new String[] - { NS_DELIM_1, // { - this.qualifier, NS_DELIM_2, // } - this.name }); - - } - - /** - * Factory-like method to create a QName object from the string form of a - * QName. The string must have the same format as returned by - * QName.toString(). - * - * @param qnameString - - * String form of a QName - * @return The created QName object created from the specified string - * @throws IllegalArgumentException - - * Missing namespace delimiters - */ - public static QualifiedName valueOf(String qnameString) - throws IllegalArgumentException - { - - String namespace = null; - String localName = null; - if (qnameString == null || qnameString.length() == 0) - { - // Both namespace and local name are null. - } else if (qnameString.startsWith(NS_DELIM_1)) - { - // The QName has the notation specifying a namespace. - int index = qnameString.indexOf(NS_DELIM_2); - if (index == -1) - { - // The end delimiter for the namespace was not found. The QName - // string - // is malformed. - throw new IllegalArgumentException( - "qnameString = " + qnameString); //$NON-NLS-1$ - } - namespace = qnameString.substring(1, index); - localName = qnameString.substring(index + 1); - } else - { - // Assume no namespace is specified and the string is a local name. - localName = qnameString; - } - return new QualifiedName(namespace, localName); - - } - - /** - * Creates a single string by appending together an array of strings, - * skipping null strings. - * - * @param strings - - * Strings to be appended together - * @return Resulting string - */ - public static String appendStrings(String[] strings) - { - - String result = null; - if (strings != null) - { - StringBuffer tokenBuffer = new StringBuffer(); - int maxCount = strings.length; - String string; - for (int i = 0; i < maxCount; i++) - { - string = strings[i]; - if (string != null && string.length() > 0) - { - tokenBuffer.append(string); - }// if - }// for - result = tokenBuffer.toString(); - }// if - return result; - - }// appendStrings() - -}// class QName diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/SearchPattern.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/SearchPattern.java deleted file mode 100644 index df0aaf6d2..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/pattern/SearchPattern.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.common.core.search.pattern; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Platform; - -/** - * A search defines how search results are found. - * - * This class is intended to be subclassed by clients. - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - */ -public abstract class SearchPattern implements IAdaptable -{ - - /** - * Match rule: The search pattern matches the search result only if cases - * are the same. Can be combined to previous rules, e.g. - * {@link #R_EXACT_MATCH} | {@link #R_CASE_SENSITIVE} - */ - public static final int R_CASE_SENSITIVE = 8; - - // Rules for pattern matching: (exact, prefix, pattern) [ | case sensitive] - /** - * Match rule: The search pattern matches exactly the search result, that - * is, the source of the search result equals the search pattern. - */ - public static final int R_EXACT_MATCH = 0; - - /** - * Match rule: The search pattern contains one or more wild cards ('*') - * where a wild-card can replace 0 or more characters in the search result. - */ - public static final int R_PATTERN_MATCH = 2; - - /** - * Match rule: The search pattern is a prefix of the search result. - */ - public static final int R_PREFIX_MATCH = 1; - - /** - * Match rule: The search pattern contains a regular expression. - */ - public static final int R_REGEXP_MATCH = 4; - - private int matchRule; - - public SearchPattern() - { - this.matchRule = R_EXACT_MATCH | R_CASE_SENSITIVE; - } - - public SearchPattern(int matchRule) - { - this.matchRule = matchRule; - - } - - public final int getMatchRule() - { - return this.matchRule; - } - - public Object getAdapter(Class adapter) - { - return Platform.getAdapterManager().getAdapter(this, adapter); - } - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/ContentTypeSearchScope.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/ContentTypeSearchScope.java deleted file mode 100644 index c67af173a..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/ContentTypeSearchScope.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.core.search.scope; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.content.IContentDescription; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.core.runtime.content.IContentTypeManager; - -/** - * Scope that has filterers files based on content types. It can limit other - * scopes with the given file content types. - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - */ -public class ContentTypeSearchScope extends SearchScopeImpl -{ - - private List validContentIds = new ArrayList(); - - public ContentTypeSearchScope(SearchScope scope, String[] validContentTypes) - { - if (validContentTypes != null) - { - for (int i = 0; i < validContentTypes.length; i++) - { - this.validContentIds.add(validContentTypes[i]); - } - } - if (scope.enclosingFiles() != null) - { - for (int i = 0; i < scope.enclosingFiles().length; i++) - { - IFile file = (IFile) scope.enclosingFiles()[i]; - acceptFile(file); - } - } - - } - - protected boolean acceptFile(IFile file) - { - - if (file == null) - { - return false; - } else - { - try - { - IContentDescription description = file.getContentDescription(); - if (description != null) - { - IContentType contentType = description.getContentType(); - if (contentType != null) - { - // TODO use IContentType.isKindOf - for (Iterator iter = validContentIds.iterator(); iter - .hasNext();) - { - String contentId = (String) iter.next(); - IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); - IContentType supportedContentType = contentTypeManager.getContentType(contentId); - if (supportedContentType != null) - { - if (contentType.isKindOf(supportedContentType)) - { - files.add(file); - projects.add(file.getProject()); - return true; - } - } - - } - - } - } - } catch (CoreException e) - { - // ignore the file - } - } - return false; - } - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/ProjectSearchScope.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/ProjectSearchScope.java deleted file mode 100644 index 12ace7127..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/ProjectSearchScope.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.core.search.scope; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; - -/** - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - */ -public class ProjectSearchScope extends SearchScopeImpl -{ - - /** - * Creates a scope that ecloses workspace path and eclosing project - * - * @param workspacePath - - * path to the resource in the workspace, e.g. - * /MyProject/MyFile.xml - */ - public ProjectSearchScope(IPath workspacePath) - { - super(); - initialize(workspacePath); - - } - - protected void initialize(IPath workspacePath) - { - IResource resource = ResourcesPlugin.getWorkspace().getRoot() - .findMember(workspacePath); - if (resource != null) - { - IProject project = resource.getProject(); - traverseContainer(project); - } - } - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/SearchScope.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/SearchScope.java deleted file mode 100644 index 1dd3efd27..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/SearchScope.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.core.search.scope; - -import org.eclipse.core.resources.IFile; - -/** - * A <code>SearchScope</code> defines where search result should be found by a - * <code>SearchEngine</code> (e.g. project, workspace). - * - * Clients must pass an instance of this class to the <code>search(...)</code> - * methods. Such an instance can be created using the following factory methods - * on <code>SearchScope</code>: <code>newSearchScope(IResource[])</code>, - * <code>newWorkspaceScope()</code> - * - * The default implementaion of the search scope has no filter, and at creation - * does not contain any files, It could accept any workspace file. - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - */ -public abstract class SearchScope -{ - /** - * Returns the path to the workspace files that belong in this search scope. - * (see <code>IResource.getFullPath()</code>). For example, - * /MyProject/MyFile.txt - * - * @return an array of files in the workspace that belong to this scope. - */ - public abstract IFile[] enclosingFiles(); - - - - - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/SearchScopeImpl.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/SearchScopeImpl.java deleted file mode 100644 index 33c4c691d..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/SearchScopeImpl.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.core.search.scope; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; - -/** - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - */ -public class SearchScopeImpl extends SearchScope -{ - - protected List files = new ArrayList(); - - protected HashSet projects = new HashSet(); - - public SearchScopeImpl() - { - super(); - } - - /** - * Checks whether the resource at the given path is belongs to this scope. - * Resource path could be added to the scope, if scope conditions are met. - * if {@link ISearchScope.encloses(String resourcePath)} returns false and - * then this method is called and returns true, next call to - * {@link ISearchScope.eclipses(String resourcePath)} should return true. - * - * @param file - - * workspace file - * @return whether the resource is enclosed by this scope - */ - protected boolean acceptFile(IFile file) - { - if (file == null) - { - return false; - } - files.add(file); - projects.add(file.getProject()); - return true; - - } - - /** - * Checks whether the resource at the given path is enclosed by this scope. - * - * @param resourcePath - - * workspace relative resource path - * @return whether the resource is enclosed by this scope - */ - protected boolean encloses(String resourcePath) - { - IResource resource = ResourcesPlugin.getWorkspace().getRoot() - .findMember(resourcePath); - if (resource == null) - return false; - return (files.contains(resource)); - } - - /** - * Returns the path to the workspace files that belong in this search scope. - * (see <code>IResource.getFullPath()</code>). For example, - * /MyProject/MyFile.txt - * - * @return an array of files in the workspace that belong to this scope. - */ - public IFile[] enclosingFiles() - { - if (files == null) - return new IFile[0]; - return (IFile[]) files.toArray(new IFile[files.size()]); - } - - /** - * Returns the paths to the enclosing projects for this search scope. (see - * <code>IResource.getFullPath()</code>). For example, /MyProject - * - * @return an array of paths to the enclosing projects. - */ - protected IProject[] enclosingProjects() - { - - return (IProject[]) projects.toArray(new IProject[projects.size()]); - - } - - protected void traverseContainer(IContainer container) - { - - IResourceVisitor visitor = new IResourceVisitor() - { - public boolean visit(IResource resource) - { - if (resource.getType() == IResource.FILE) - acceptFile((IFile) resource); - return true; - } - }; - try - { - container.accept(visitor); - } catch (CoreException e) - { - // ignore resource - } - - } -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/SelectionSearchScope.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/SelectionSearchScope.java deleted file mode 100644 index 4ffcd3ea7..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/SelectionSearchScope.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.core.search.scope; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; - -/** - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - */ -public class SelectionSearchScope extends SearchScopeImpl -{ - - protected IResource[] resources; - - /** - * Creates a scope that ecloses workspace path and eclosing project - * - * @param workspacePath - - * path to the resource in the workspace, e.g. - * /MyProject/MyFile.xml - */ - public SelectionSearchScope(IResource[] resources) - { - super(); - this.resources = resources; - initialize(); - - } - - protected void initialize() - { - if (resources == null) - return; - for (int index = 0; index < resources.length; index++) - { - IResource resource = resources[index]; - if (resource != null) - { - if (resource.getType() == IResource.FOLDER) - { - traverseContainer((IFolder) resource); - } else if (resource.getType() == IResource.FILE) - { - acceptFile((IFile) resource); - } - } - - } - - } - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/WorkingSetSearchScope.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/WorkingSetSearchScope.java deleted file mode 100644 index cab1a1909..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/WorkingSetSearchScope.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ -package org.eclipse.wst.common.core.search.scope; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IAdaptable; - -/** - * This class is required to wrap the content of an IWorkingSet. - * We can't use IWorkingSet directly because it's part of an eclipse.ui - * component. Therefore, we need to create this object as a surrogate. - * <br> - * Usage: We get the array IAdaptable[] of the IWorkingSet object and use this - * array as argument for all methods of this class including the constructor. - */ -public class WorkingSetSearchScope extends SearchScopeImpl{ - - /** - * Creates an empty scope when no resources is given. - */ - public WorkingSetSearchScope(){ - super(); - } - - /** - * Intended to be used with an IWorkingSet - * <br> - * For example: - * <pre> - * IWorkingSet oneWorkingSet; - * ... - * IAdaptable[] elements = oneWorkingSet.getElements(); - * WorkingSetSearchScope scope = new WorkingSetSearchScope(elements); - * </pre> - */ - public WorkingSetSearchScope(IAdaptable[] elements) - { - super(); - addElementsOfWorkingSet(elements); - } - - /** - * Intended to be used with an IWorkingSet - * <br> - * For example: - * <pre> - * WorkingSetSearchScope scope = ..; - * ... - * IWorkingSet anotherWorkingSet; - * IAdaptable[] elements = anotherWorkingSet.getElements(); - * scope.addAWorkingSetToScope(elements); - * </pre> - */ - public void addAWorkingSetToScope(IAdaptable[] elements){ - addElementsOfWorkingSet(elements); - } - - private void addElementsOfWorkingSet(IAdaptable[] elements){ - for (int j = 0; j < elements.length; j++){ - IContainer container = (IContainer) elements[j].getAdapter(IContainer.class); - if ( container != null ){ - traverseContainer(container); - } - else{ - IFile aFile = (IFile) elements[j].getAdapter(IFile.class); - if ( aFile != null) - acceptFile(aFile); - } - } - } -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/WorkspaceSearchScope.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/WorkspaceSearchScope.java deleted file mode 100644 index e01c20123..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/scope/WorkspaceSearchScope.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.core.search.scope; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; - -/** - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - */ -public class WorkspaceSearchScope extends SearchScopeImpl -{ - - protected IResource currentResource; - - /** - * Creates a scope that ecloses workspace path and eclosing project - * - * @param workspacePath - - * path to the resource in the workspace, e.g. - * /MyProject/MyFile.xml - */ - public WorkspaceSearchScope() - { - super(); - initialize(); - - } - - protected void initialize() - { - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - traverseContainer(root); - - } - -} diff --git a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/util/CollectingSearchRequestor.java b/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/util/CollectingSearchRequestor.java deleted file mode 100644 index d227f9317..000000000 --- a/plugins/org.eclipse.wst.common.core/src-search/org/eclipse/wst/common/core/search/util/CollectingSearchRequestor.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.core.search.util; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.wst.common.core.search.SearchMatch; -import org.eclipse.wst.common.core.search.SearchRequestor; - -/** - * Collects the results returned by a <code>ISearchEngine</code>. - * - * <p> - * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - */ -// issue should you move this to a util package? what does jdt do? -public class CollectingSearchRequestor extends SearchRequestor -{ - private ArrayList fFound; - - public CollectingSearchRequestor() - { - fFound = new ArrayList(); - } - - /** - * @return a List of {@link SearchMatch}es (not sorted) - */ - public List/* <SearchMatch> */getResults() - { - return fFound; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.core.search.internal.provisional.SearchRequestor#acceptSearchMatch(org.eclipse.wst.common.search.internal.provisional.SearchMatch) - */ - public void acceptSearchMatch(SearchMatch match) throws CoreException - { - fFound.add(match); - - } -} |