|
From: <caw...@us...> - 2007-04-17 13:01:26
|
Revision: 2324
http://svn.sourceforge.net/rubyeclipse/?rev=2324&view=rev
Author: cawilliams
Date: 2007-04-17 06:01:24 -0700 (Tue, 17 Apr 2007)
Log Message:
-----------
Merged changes from r2302:2323 in search_engine branch over to trunk
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/Flags.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleLookupTable.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRoot.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/InternalSearchDocument.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Messages.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/messages.properties
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/FieldDeclarationMatch.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchScope.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/MethodDeclarationMatch.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchMatch.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchParticipant.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchRequestor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/TypeDeclarationMatch.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfLong.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/CollectingSearchRequestor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexQueryRequestor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexSelector.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/PathCollector.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/PatternSearchJob.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchDocument.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchParticipant.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchScope.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubyWorkspaceScope.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllProject.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexRequest.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/RemoveFromIndex.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SaveIndex.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexer.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexerRequestor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/AndPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/ConstructorPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/FieldLocator.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/FieldPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/InternalSearchPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchingNodeSet.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodLocator.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/OrPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PatternLocator.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatch.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatchSet.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/QualifiedTypeDeclarationPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/RubySearchPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeDeclarationLocator.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeDeclarationPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeReferencePattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/VariablePattern.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllJob.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/AndPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/ConstructorPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/FieldLocator.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/FieldPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/InternalSearchPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchingNodeSet.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodLocator.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/OrPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PatternLocator.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatch.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatchSet.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/QualifiedTypeDeclarationPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/RubySearchPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeDeclarationLocator.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeDeclarationPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeReferencePattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/VariablePattern.java
Modified: trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF 2007-04-17 11:42:39 UTC (rev 2323)
+++ trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF 2007-04-17 13:01:24 UTC (rev 2324)
@@ -11,12 +11,14 @@
org.rubypeople.rdt.core,
org.rubypeople.rdt.core.compiler,
org.rubypeople.rdt.core.formatter,
+ org.rubypeople.rdt.core.search,
org.rubypeople.rdt.internal.compiler,
org.rubypeople.rdt.internal.core,
org.rubypeople.rdt.internal.core.buffer,
org.rubypeople.rdt.internal.core.builder,
org.rubypeople.rdt.internal.core.parser,
org.rubypeople.rdt.internal.core.parser.warnings,
+ org.rubypeople.rdt.internal.core.search,
org.rubypeople.rdt.internal.core.symbols,
org.rubypeople.rdt.internal.core.util,
org.rubypeople.rdt.internal.formatter,
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/Flags.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/Flags.java 2007-04-17 11:42:39 UTC (rev 2323)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/Flags.java 2007-04-17 13:01:24 UTC (rev 2324)
@@ -16,6 +16,8 @@
* @since 3.0
*/
public static final int AccDefault = 0;
+
+ public static final int AccModule = 0x0001;
/**
* Returns whether the given integer includes the <code>private</code> modifier.
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-04-17 11:42:39 UTC (rev 2323)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-04-17 13:01:24 UTC (rev 2324)
@@ -321,8 +321,6 @@
List rubyProjects = Arrays.asList(getRubyProjects());
MassIndexUpdaterJob massUpdater = new MassIndexUpdaterJob(indexUpdater, rubyProjects);
massUpdater.schedule();
- addElementChangedListener(IndexManager.instance());
- IndexManager.start();
}
/*
@@ -334,7 +332,6 @@
public void stop(BundleContext context) throws Exception {
try {
RubyModelManager.getRubyModelManager().shutdown();
- removeElementChangedListener(IndexManager.instance());
} finally {
// ensure we call super.stop as the last thing
super.stop(context);
Copied: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/FieldDeclarationMatch.java (from rev 2323, branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/FieldDeclarationMatch.java)
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/FieldDeclarationMatch.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/FieldDeclarationMatch.java 2007-04-17 13:01:24 UTC (rev 2324)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 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.rubypeople.rdt.core.search;
+
+import org.eclipse.core.resources.IResource;
+import org.rubypeople.rdt.core.IRubyElement;
+
+/**
+ * A Java search match that represents a field declaration.
+ * The element is an <code>IField</code>.
+ * <p>
+ * This class is intended to be instantiated and subclassed by clients.
+ * </p>
+ *
+ * @since 3.0
+ */
+public class FieldDeclarationMatch extends SearchMatch {
+
+ /**
+ * Creates a new field declaration match.
+ *
+ * @param element the field declaration
+ * @param accuracy one of A_ACCURATE or A_INACCURATE
+ * @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
+ */
+ public FieldDeclarationMatch(IRubyElement element, int accuracy, int offset, int length, SearchParticipant participant, IResource resource) {
+ super(element, accuracy, offset, length, participant, resource);
+ }
+}
Copied: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java (from rev 2323, branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java)
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java 2007-04-17 13:01:24 UTC (rev 2324)
@@ -0,0 +1,53 @@
+package org.rubypeople.rdt.core.search;
+
+import org.rubypeople.rdt.internal.core.search.processing.IJob;
+
+public interface IRubySearchConstants {
+ /**
+ * The search operation waits for the underlying indexer to finish indexing
+ * the workspace before starting the search.
+ */
+ int WAIT_UNTIL_READY_TO_SEARCH = IJob.WaitUntilReady;
+
+ /**
+ * The search result is a declaration.
+ * Can be used in conjunction with any of the nature of searched elements
+ * so as to better narrow down the search.
+ */
+ int DECLARATIONS= 0;
+
+ /**
+ * The search result is a reference.
+ * Can be used in conjunction with any of the nature of searched elements
+ * so as to better narrow down the search.
+ * References can contain implementers since they are more generic kind
+ * of matches.
+ */
+ int REFERENCES= 2;
+
+ /**
+ * The search result is a declaration, a reference, or an implementer
+ * of an interface.
+ * Can be used in conjunction with any of the nature of searched elements
+ * so as to better narrow down the search.
+ */
+ int ALL_OCCURRENCES= 3;
+
+ /**
+ * When searching for field matches, it will exclusively find read accesses, as
+ * opposed to write accesses. Note that some expressions are considered both
+ * as field read/write accesses: for example, x++; x+= 1;
+ *
+ * @since 2.0
+ */
+ int READ_ACCESSES = 4;
+
+ /**
+ * When searching for field matches, it will exclusively find write accesses, as
+ * opposed to read accesses. Note that some expressions are considered both
+ * as field read/write accesses: for example, x++; x+= 1;
+ *
+ * @since 2.0
+ */
+ int WRITE_ACCESSES = 5;
+}
Copied: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchScope.java (from rev 2323, branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchScope.java)
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchScope.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchScope.java 2007-04-17 13:01:24 UTC (rev 2324)
@@ -0,0 +1,71 @@
+package org.rubypeople.rdt.core.search;
+
+import org.eclipse.core.runtime.IPath;
+
+public interface IRubySearchScope {
+
+ /**
+ * Include type constant (bit mask) indicating that source folders should be
+ * considered in the search scope.
+ *
+ * @since 0.9.0
+ */
+ int SOURCES = 1;
+ /**
+ * Include type constant (bit mask) indicating that application libraries
+ * should be considered in the search scope.
+ *
+ * @since 0.9.0
+ */
+ int APPLICATION_LIBRARIES = 2;
+ /**
+ * Include type constant (bit mask) indicating that system libraries should
+ * be considered in the search scope.
+ *
+ * @since 0.9.0
+ */
+ int SYSTEM_LIBRARIES = 4;
+ /**
+ * Include type constant (bit mask) indicating that referenced projects
+ * should be considered in the search scope.
+ *
+ * @since 0.9.0
+ */
+ int REFERENCED_PROJECTS = 8;
+
+ /**
+ * Returns the paths to the enclosing projects and JARs for this search
+ * scope.
+ * <ul>
+ * <li> If the path is a project path, this is the full path of the project
+ * (see <code>IResource.getFullPath()</code>). For example, /MyProject
+ * </li>
+ * <li> If the path is a JAR path and this JAR is internal to the workspace,
+ * this is the full path of the JAR file (see
+ * <code>IResource.getFullPath()</code>). For example,
+ * /MyProject/mylib.jar </li>
+ * <li> If the path is a JAR path and this JAR is external to the workspace,
+ * this is the full OS path to the JAR file on the file system. For example,
+ * d:\libs\mylib.jar </li>
+ * </ul>
+ *
+ * @return an array of paths to the enclosing projects and JARS.
+ */
+ IPath[] enclosingProjectsAndJars();
+
+ /**
+ * Checks whether the resource at the given path is enclosed by this scope.
+ *
+ * @param resourcePath
+ * if the resource is contained in a JAR file, the path is
+ * composed of 2 paths separated by
+ * <code>JAR_FILE_ENTRY_SEPARATOR</code>: the first path is
+ * the full OS path to the JAR (if it is an external JAR), or the
+ * workspace relative <code>IPath</code> to the JAR (if it is
+ * an internal JAR), the second path is the path to the resource
+ * inside the JAR.
+ * @return whether the resource is enclosed by this scope
+ */
+ public boolean encloses(String resourcePath);
+
+}
Copied: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/MethodDeclarationMatch.java (from rev 2323, branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/MethodDeclarationMatch.java)
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/MethodDeclarationMatch.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/MethodDeclarationMatch.java 2007-04-17 13:01:24 UTC (rev 2324)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 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.rubypeople.rdt.core.search;
+
+import org.eclipse.core.resources.IResource;
+import org.rubypeople.rdt.core.IRubyElement;
+
+/**
+ * A Java search match that represents a method declaration.
+ * The element is an <code>IMethod</code>.
+ * <p>
+ * This class is intended to be instantiated and subclassed by clients.
+ * </p>
+ *
+ * @since 3.0
+ */
+public class MethodDeclarationMatch extends SearchMatch {
+
+ /**
+ * Creates a new method declaration match.
+ *
+ * @param element the method declaration
+ * @param accuracy one of A_ACCURATE or A_INACCURATE
+ * @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
+ */
+ public MethodDeclarationMatch(IRubyElement element, int accuracy, int offset, int length, SearchParticipant participant, IResource resource) {
+ super(element, accuracy, offset, length, participant, resource);
+ }
+
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java 2007-04-17 11:42:39 UTC (rev 2323)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java 2007-04-17 13:01:24 UTC (rev 2324)
@@ -1,135 +1,177 @@
-package org.rubypeople.rdt.core.search;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.rubypeople.rdt.core.IParent;
-import org.rubypeople.rdt.core.IRubyElement;
-import org.rubypeople.rdt.core.IRubyScript;
-import org.rubypeople.rdt.core.IType;
-import org.rubypeople.rdt.core.RubyModelException;
-import org.rubypeople.rdt.internal.core.Openable;
-import org.rubypeople.rdt.internal.core.search.HandleFactory;
-import org.rubypeople.rdt.internal.core.search.indexing.InternalSearchDocument;
-
-public class SearchDocument extends InternalSearchDocument {
-
- private static HandleFactory factory = new HandleFactory();
- private IRubyScript script;
-
- private static final String SEPARATOR = "/";
-
- private List<String> indices = new ArrayList<String>();
-
- private String documentPath;
-
- public SearchDocument(String documentPath) {
- this.documentPath = documentPath;
- }
-
- public void addIndexEntry(char[] category, char[] key) {
- super.addIndexEntry(category, key);
- }
-
- /**
- * Removes all index entries from the index for the given document.
- * This method must be called from
- * {@link SearchParticipant#indexDocument(SearchDocument document, org.eclipse.core.runtime.IPath indexPath)}.
- */
- public void removeAllIndexEntries() {
- super.removeAllIndexEntries();
- }
-
- public Set<String> getElementNamesOfType(int type) {
- Set<String> names = new HashSet<String>();
- for (String indexKey : indices) {
- if (getTypeFromKey(indexKey) != type) continue;
- names.add(getNameFromKey(indexKey));
- }
- return names;
- }
-
- public List<IRubyElement> getElementsOfType(int type) {
- IRubyScript script = getScript();
- return getChildrenOfType(script, type);
- }
-
- private IRubyScript getScript() {
- if (this.script == null) {
- Openable openable = factory.createOpenable(documentPath);
- this.script = (IRubyScript) openable;
- }
- return this.script;
- }
-
- private List<IRubyElement> getChildrenOfType(IParent parent, int type) {
- List<IRubyElement> elements = new ArrayList<IRubyElement>();
- if (parent == null) return elements;
- try {
- IRubyElement[] children = parent.getChildren();
- if (children == null)
- return elements;
- for (int i = 0; i < children.length; i++) {
- if (children[i].isType(type))
- elements.add(children[i]);
- if (children[i] instanceof IParent) {
- IParent childParent = (IParent) children[i];
- elements.addAll(getChildrenOfType(childParent, type));
- }
- }
- } catch (RubyModelException e) {
- // ignore
- }
- return elements;
- }
-
- public boolean isEmpty() {
- return indices.isEmpty();
- }
-
- public void removeElement(IRubyElement element) {
- indices.remove(createKey(element));
- }
-
- private String createKey(IRubyElement element) {
- return createKey(element.getElementType(), element.getElementName());
- }
-
- private String createKey(int type, String name) {
- return type + SEPARATOR + name;
- }
-
- public void addElement(IRubyElement element) {
- indices.add(createKey(element));
- }
-
- public IType findType(String name) {
- return (IType) findElement(createKey(IRubyElement.TYPE, name));
- }
-
- private IRubyElement findElement(String key) {
- for (String indexKey : indices) {
- if (!indexKey.equals(key))
- continue;
- IRubyScript script = getScript();
- List<IRubyElement> children = getChildrenOfType(script, getTypeFromKey(key));
- for (IRubyElement element : children) {
- if (element.getElementName().equals(getNameFromKey(key)))
- return element;
- }
- }
- return null;
- }
-
- private String getNameFromKey(String key) {
- String[] parts = key.split(SEPARATOR);
- return parts[1];
- }
-
- private int getTypeFromKey(String key) {
- String[] parts = key.split(SEPARATOR);
- return Integer.parseInt(parts[0]);
- }
-}
+package org.rubypeople.rdt.core.search;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.rubypeople.rdt.core.IParent;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.core.Openable;
+import org.rubypeople.rdt.internal.core.index.EntryResult;
+import org.rubypeople.rdt.internal.core.search.HandleFactory;
+import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
+import org.rubypeople.rdt.internal.core.search.indexing.InternalSearchDocument;
+
+public abstract class SearchDocument extends InternalSearchDocument {
+
+ private static HandleFactory factory = new HandleFactory();
+ private IRubyScript script;
+
+ private String documentPath;
+ private SearchParticipant participant;
+
+ public SearchDocument(String documentPath, SearchParticipant participant) {
+ this.documentPath = documentPath;
+ this.participant = participant;
+ }
+
+ public void addIndexEntry(char[] category, char[] key) {
+ super.addIndexEntry(category, key);
+ }
+
+ /**
+ * Removes all index entries from the index for the given document.
+ * This method must be called from
+ * {@link SearchParticipant#indexDocument(SearchDocument document, org.eclipse.core.runtime.IPath indexPath)}.
+ */
+ public void removeAllIndexEntries() {
+ super.removeAllIndexEntries();
+ }
+
+ public Set<String> getElementNamesOfType(int type) {
+ Set<String> names = new HashSet<String>();
+ try {
+ EntryResult[] results = index.query(new char[][] {getCategory(type)}, new char[] {'*'}, SearchPattern.R_PATTERN_MATCH);
+ for (int i = 0; i < results.length; i++) {
+ String name = new String(results[i].getWord());
+ names.add(name);
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return names;
+ }
+
+ public List<IRubyElement> getElementsOfType(int type) {
+ IRubyScript script = getScript();
+ return getChildrenOfType(script, type);
+ }
+
+ private IRubyScript getScript() {
+ if (this.script == null) {
+ Openable openable = factory.createOpenable(documentPath);
+ this.script = (IRubyScript) openable;
+ }
+ return this.script;
+ }
+
+ /**
+ * Returns the path to the original document to publicly mention in index
+ * or search results. This 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.
+ *
+ * @return the path to the document
+ */
+ public final String getPath() {
+ return this.documentPath;
+ }
+
+ private List<IRubyElement> getChildrenOfType(IParent parent, int type) {
+ List<IRubyElement> elements = new ArrayList<IRubyElement>();
+ if (parent == null) return elements;
+ try {
+ IRubyElement[] children = parent.getChildren();
+ if (children == null)
+ return elements;
+ for (int i = 0; i < children.length; i++) {
+ if (children[i].isType(type))
+ elements.add(children[i]);
+ if (children[i] instanceof IParent) {
+ IParent childParent = (IParent) children[i];
+ elements.addAll(getChildrenOfType(childParent, type));
+ }
+ }
+ } catch (RubyModelException e) {
+ // ignore
+ }
+ return elements;
+ }
+
+ public void removeElement(IRubyElement element) {
+ // FIXME Rebuild the index?!
+ }
+
+ public void addElement(IRubyElement element) {
+ addIndexEntry(getCategory(element), element.getElementName().toCharArray());
+ }
+
+ private char[] getCategory(IRubyElement element) {
+ return getCategory(element.getElementType());
+ }
+
+ private char[] getCategory(int elementType) {
+ switch (elementType) {
+ case IRubyElement.TYPE:
+ return IIndexConstants.TYPE_DECL;
+ case IRubyElement.METHOD:
+ return IIndexConstants.METHOD_DECL;
+ case IRubyElement.CONSTANT:
+ case IRubyElement.GLOBAL:
+ case IRubyElement.CLASS_VAR:
+ case IRubyElement.INSTANCE_VAR:
+ case IRubyElement.LOCAL_VARIABLE:
+ return IIndexConstants.FIELD_DECL;
+ default:
+ return new char[0];
+ }
+ }
+
+ public IType findType(String name) {
+ return (IType) findElement(IRubyElement.TYPE, name);
+ }
+
+ private IRubyElement findElement(int type, String name) {
+ IRubyScript script = getScript();
+ List<IRubyElement> children = getChildrenOfType(script, type);
+ for (IRubyElement element : children) {
+ if (element.getElementName().equals(name))
+ return element;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the contents of this document.
+ * Contents may be different from actual resource at corresponding document
+ * path due to preprocessing.
+ * <p>
+ * This method must be implemented in subclasses.
+ * </p><p>
+ * Note: some implementation may choose to cache the contents directly on the
+ * document for performance reason. However, this could induce scalability issues due
+ * to the fact that collections of documents are manipulated throughout the search
+ * operation, and cached contents would then consume lots of memory until they are
+ * all released at once in the end.
+ * </p>
+ *
+ * @return the contents of this document,
+ * or <code>null</code> if none
+ */
+ public abstract char[] getCharContents();
+
+ /**
+ * Returns the participant that created this document.
+ *
+ * @return the participant that created this document
+ */
+ public final SearchParticipant getParticipant() {
+ return this.participant;
+ }
+}
Copied: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchMatch.java (from rev 2323, branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchMatch.java)
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchMatch.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchMatch.java 2007-04-17 13:01:24 UTC (rev 2324)
@@ -0,0 +1,376 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 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.rubypeople.rdt.core.search;
+
+import org.eclipse.core.resources.IResource;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.internal.core.RubyElement;
+
+/**
+ * A search match represents the result of a search query.
+ *
+ * Search matches may be accurate (<code>A_ACCURATE</code>) or they might be
+ * merely potential matches (<code>A_INACCURATE</code>). The latter occurs when
+ * a compile-time problem prevents the search engine from completely resolving
+ * the match.
+ * <p>
+ * This class is intended to be instantiated and subclassed by clients.
+ * </p>
+ *
+ * @see SearchEngine#search(SearchPattern, SearchParticipant[], IJavaSearchScope, SearchRequestor, org.eclipse.core.runtime.IProgressMonitor)
+ * @since 3.0
+ */
+public class SearchMatch {
+
+ /**
+ * The search result corresponds an exact match of the search pattern.
+ *
+ * @see #getAccuracy()
+ */
+ public static final int A_ACCURATE = 0;
+
+ /**
+ * The search result is potentially a match for the search pattern,
+ * but the search engine is unable to fully check it (for example, because
+ * there are errors in the code or the classpath are not correctly set).
+ *
+ * @see #getAccuracy()
+ */
+ public static final int A_INACCURATE = 1;
+
+ private Object element;
+ private int length;
+ private int offset;
+
+ private int accuracy;
+ private SearchParticipant participant;
+ private IResource resource;
+
+ private boolean insideDocComment = false;
+
+ // store the rule used while reporting the match
+ private final static int ALL_GENERIC_FLAVORS = SearchPattern.R_FULL_MATCH |
+ SearchPattern.R_EQUIVALENT_MATCH |
+ SearchPattern.R_ERASURE_MATCH;
+ private int rule = ALL_GENERIC_FLAVORS;
+
+ // store other necessary information
+ private boolean raw = false;
+ private boolean implicit = false;
+
+ /**
+ * Creates a new search match.
+ * <p>
+ * Note that <code>isInsideDocComment()</code> defaults to false.
+ * </p>
+ *
+ * @param element the element that encloses or corresponds to the match,
+ * or <code>null</code> if none
+ * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
+ * @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(
+ IRubyElement element,
+ int accuracy,
+ int offset,
+ int length,
+ SearchParticipant participant,
+ IResource resource) {
+ this.element = element;
+ this.offset = offset;
+ this.length = length;
+ this.accuracy = accuracy & A_INACCURATE;
+ if (accuracy > A_INACCURATE) {
+ int genericFlavors = accuracy & ALL_GENERIC_FLAVORS;
+ if (genericFlavors > 0) {
+ this.rule &= ~ALL_GENERIC_FLAVORS; // reset generic flavors
+ }
+ this.rule |= accuracy & ~A_INACCURATE; // accuracy may have also some rule information
+ }
+ this.participant = participant;
+ this.resource = resource;
+ }
+
+ /**
+ * Returns the accuracy of this search match.
+ *
+ * @return one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
+ */
+ public final int getAccuracy() {
+ return this.accuracy;
+ }
+
+ /**
+ * Returns the element of this search match.
+ * In case of a reference match, this is the inner-most enclosing element of the reference.
+ * In case of a declaration match, this is the declaration.
+ *
+ * @return the element of the search match, or <code>null</code> if none
+ */
+ public final Object getElement() {
+ return this.element;
+ }
+
+ /**
+ * Returns the length of this search match.
+ *
+ * @return the length of this search match, or -1 if unknown
+ */
+ public final int getLength() {
+ return this.length;
+ }
+
+ /**
+ * Returns the offset of this search match.
+ *
+ * @return the offset of this search match, or -1 if unknown
+ */
+ public final int getOffset() {
+ return this.offset;
+ }
+
+ /**
+ * Returns the search participant which issued this search match.
+ *
+ * @return the participant which issued this search match
+ */
+ public final SearchParticipant getParticipant() {
+ return this.participant;
+ }
+
+ /**
+ * Returns the resource containing this search match.
+ *
+ * @return the resource of the match, or <code>null</code> if none
+ */
+ public final IResource getResource() {
+ return this.resource;
+ }
+
+ /**
+ * Returns the rule used while creating the match.
+ *
+ * @return one of {@link SearchPattern#R_FULL_MATCH}, {@link SearchPattern#R_EQUIVALENT_MATCH}
+ * or {@link SearchPattern#R_ERASURE_MATCH}
+ * @since 3.1
+ */
+ public final int getRule() {
+ return this.rule;
+ }
+
+ /**
+ * Returns whether match element is compatible with searched pattern or not.
+ * Note that equivalent matches are also erasure ones.
+ *
+ * @return <code>true</code> if match element is compatible
+ * <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final boolean isEquivalent() {
+ return isErasure() && (this.rule & SearchPattern.R_EQUIVALENT_MATCH) != 0;
+ }
+
+ /**
+ * Returns whether match element only has same erasure than searched pattern or not.
+ * Note that this is always true for both generic and non-generic element as soon
+ * as the accuracy is accurate.
+ *
+ * @return <code>true</code> if match element has same erasure
+ * <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final boolean isErasure() {
+ return (this.rule & SearchPattern.R_ERASURE_MATCH) != 0;
+ }
+
+ /**
+ * Returns whether element matches exactly searched pattern or not.
+ * Note that exact matches are also erasure and equivalent ones.
+ *
+ * @return <code>true</code> if match is exact
+ * <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final boolean isExact() {
+ return isEquivalent() && (this.rule & SearchPattern.R_FULL_MATCH) != 0;
+ }
+
+ /**
+ * Returns whether the associated element is implicit or not.
+ *
+ * Note that this piece of information is currently only implemented
+ * for implicit member pair value in annotation.
+ *
+ * @return <code>true</code> if this match is associated to an implicit
+ * element and <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final boolean isImplicit() {
+ return this.implicit;
+ }
+
+ /**
+ * Returns whether the associated element is a raw type/method or not.
+ *
+ * @return <code>true</code> if this match is associated to a raw
+ * type or method and <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final boolean isRaw() {
+ return this.raw;
+ }
+
+ /**
+ * Returns whether this search match is inside a doc comment of a Java
+ * source file.
+ *
+ * @return <code>true</code> if this search match is inside a doc
+ * comment, and <code>false</code> otherwise
+ */
+ public final boolean isInsideDocComment() {
+ // default is outside a doc comment
+ return this.insideDocComment;
+ }
+
+ /**
+ * Sets the accuracy of this match.
+ *
+ * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
+ */
+ public final void setAccuracy (int accuracy) {
+ this.accuracy = accuracy;
+ }
+
+ /**
+ * Sets the element of this search match.
+ *
+ * @param element the element that encloses or corresponds to the match,
+ * or <code>null</code> if none
+ */
+ public final void setElement (Object element) {
+ this.element = element;
+ }
+
+ /**
+ * Sets whether this search match is inside a doc comment of a Java
+ * source file.
+ *
+ * @param insideDoc <code>true</code> if this search match is inside a doc
+ * comment, and <code>false</code> otherwise
+ */
+ public final void setInsideDocComment (boolean insideDoc) {
+ this.insideDocComment = insideDoc;
+ }
+
+ /**
+ * Sets whether the associated element is implicit or not.
+ * Typically, this is the case when match is on an implicit constructor
+ * or an implicit member pair value in annotation.
+ *
+ * @param implicit <code>true</code> if this match is associated to an implicit
+ * element and <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final void setImplicit(boolean implicit) {
+ this.implicit = implicit;
+ }
+
+ /**
+ * Sets the length of this search match.
+ *
+ * @param length the length of the match, or -1 if unknown
+ */
+ public final void setLength(int length) {
+ this.length = length;
+ }
+
+ /**
+ * Sets the offset of this search match.
+ *
+ * @param offset the offset the match starts at, or -1 if unknown
+ */
+ public final void setOffset(int offset) {
+ this.offset = offset;
+ }
+
+ /**
+ * Sets the participant of this match.
+ *
+ * @param participant the search participant that created this match
+ */
+ public final void setParticipant (SearchParticipant participant) {
+ this.participant = participant;
+ }
+
+ /**
+ * Sets the resource of this match.
+ *
+ * @param resource the resource of the match, or <code>null</code> if none
+ */
+ public final void setResource (IResource resource) {
+ this.resource = resource;
+ }
+
+ /**
+ * Set the rule used while reporting the match.
+ *
+ * @param rule one of {@link SearchPattern#R_FULL_MATCH}, {@link SearchPattern#R_EQUIVALENT_MATCH}
+ * or {@link SearchPattern#R_ERASURE_MATCH}
+ * @since 3.1
+ */
+ public final void setRule(int rule) {
+ this.rule = rule;
+ }
+
+ /**
+ * Set whether the associated element is a raw type/method or not.
+ *
+ * @param raw <code>true</code> if this search match is associated to a raw
+ * type or method and <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final void setRaw(boolean raw) {
+ this.raw = raw;
+ }
+
+ /* (non-javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Search match"); //$NON-NLS-1$
+ buffer.append("\n accuracy="); //$NON-NLS-1$
+ buffer.append(this.accuracy == A_ACCURATE ? "ACCURATE" : "INACCURATE"); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append("\n rule="); //$NON-NLS-1$
+ if ((this.rule & SearchPattern.R_FULL_MATCH) != 0) {
+ buffer.append("EXACT"); //$NON-NLS-1$
+ } else if ((this.rule & SearchPattern.R_EQUIVALENT_MATCH) != 0) {
+ buffer.append("EQUIVALENT"); //$NON-NLS-1$
+ } else if ((this.rule & SearchPattern.R_ERASURE_MATCH) != 0) {
+ buffer.append("ERASURE"); //$NON-NLS-1$
+ }
+ buffer.append("\n raw="); //$NON-NLS-1$
+ buffer.append(this.raw);
+ buffer.append("\n offset="); //$NON-NLS-1$
+ buffer.append(this.offset);
+ buffer.append("\n length="); //$NON-NLS-1$
+ buffer.append(this.length);
+ if (this.element != null) {
+ buffer.append("\n element="); //$NON-NLS-1$
+ buffer.append(((RubyElement)getElement()).toStringWithAncestors());
+ }
+ buffer.append("\n"); //$NON-NLS-1$
+ return buffer.toString();
+ }
+}
Copied: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchParticipant.java (from rev 2323, branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchParticipant.java)
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchParticipant.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchParticipant.java 2007-04-17 13:01:24 UTC (rev 2324)
@@ -0,0 +1,127 @@
+package org.rubypeople.rdt.core.search;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public abstract class SearchParticipant {
+
+ /**
+ * Indexes the given document in the given index. A search participant
+ * asked to index a document should parse it and call
+ * {@link SearchDocument#addIndexEntry(char[], char[])} as many times as
+ * needed to add index entries to the index. If delegating to another
+ * participant, it should use the original index location (and not the
+ * delegatee's one). In the particular case of delegating to the default
+ * search participant (see {@link SearchEngine#getDefaultSearchParticipant()}),
+ * the provided document's path must be a path ending with one of the
+ * {@link org.eclipse.jdt.core.JavaCore#getJavaLikeExtensions() Java-like extensions}
+ * or with '.class'.
+ * <p>
+ * The given index location must represent a path in the file system to a file that
+ * either already exists or is going to be created. If it exists, it must be an index file,
+ * otherwise its data might be overwritten.
+ * </p><p>
+ * Clients are not expected to call this method.
+ * </p>
+ *
+ * @param document the document to index
+ * @param indexLocation the location in the file system to the index
+ */
+ public abstract void indexDocument(SearchDocument document, IPath indexLocation);
+
+ /**
+ * 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 getDocument(String documentPath);
+
+ /**
+ * Returns the collection of index locations to consider when performing the
+ * given search query in the given scope. The search engine calls this
+ * method before locating matches.
+ * <p>
+ * An index location represents a path in the file system to a file that holds index information.
+ * </p><p>
+ * Clients are not expected to call this method.
+ * </p>
+ *
+ * @param query the search pattern to consider
+ * @param scope the given search scope
+ * @return the collection of index paths to consider
+ */
+ public abstract IPath[] selectIndexes(SearchPattern pattern, IRubySearchScope scope);
+
+ /**
+ * Locates the matches in the given documents using the given search pattern
+ * and search scope, and reports them to the givenn search requestor. This
+ * method is called by the search engine once it has search documents
+ * matching the given pattern in the given search scope.
+ * <p>
+ * Note that a participant (e.g. a JSP participant) can pre-process the contents of the given documents,
+ * create its own documents whose contents are Java compilation units and delegate the match location
+ * to the default participant (see {@link SearchEngine#getDefaultSearchParticipant()}). Passing its own
+ * {@link SearchRequestor} this particpant can then map the match positions back to the original
+ * contents, create its own matches and report them to the original requestor.
+ * </p><p>
+ * Implementors of this method should check the progress monitor
+ * for cancelation when it is safe and appropriate to do so. The cancelation
+ * request should be propagated to the caller by throwing
+ * <code>OperationCanceledException</code>.
+ * </p>
+ *
+ * @param documents the documents to locate matches in
+ * @param pattern the search pattern to use when locating matches
+ * @param scope the scope to limit the search to
+ * @param requestor the requestor to report matches to
+ * @param monitor the progress monitor to report progress to,
+ * or <code>null</code> if no progress should be reported
+ * @throws CoreException if the requestor had problem accepting one of the matches
+ */
+ public abstract void locateMatches(SearchDocument[] documents, SearchPattern pattern, IRubySearchScope scope, SearchRequestor requestor, IProgressMonitor monitor) throws CoreException;
+
+
+ /**
+ * 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>
+ */
+ public void beginSearching() {
+ // 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>
+ */
+ public void doneSearching() {
+ // 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$
+ }
+
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-04-17 11:42:39 UTC (rev 2323)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-04-17 13:01:24 UTC (rev 2324)
@@ -1,132 +1,470 @@
-package org.rubypeople.rdt.core.search;
-
-import org.rubypeople.rdt.internal.core.util.CharOperation;
-
-public class SearchPattern {
-// 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 is a prefix of the search result.
- */
- public static final int R_PREFIX_MATCH = 0x0001;
-
- /**
- * Match rule: The search pattern contains one or more wild cards ('*' or '?').
- * A '*' wild-card can replace 0 or more characters in the search result.
- * A '?' wild-card replaces exactly 1 character in the search result.
- */
- public static final int R_PATTERN_MATCH = 0x0002;
-
- /**
- * Match rule: The search pattern contains a regular expression.
- */
- public static final int R_REGEXP_MATCH = 0x0004;
-
- /**
- * 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 = 0x0008;
-
- /**
- * Match rule: The search pattern matches search results as raw/parameterized types/methods with same erasure.
- * This mode has no effect on other java elements search.<br>
- * Type search example:
- * <ul>
- * <li>pattern: <code>List<Exception></code></li>
- * <li>match: <code>List<Object></code></li>
- * </ul>
- * Method search example:
- * <ul>
- * <li>declaration: <code><T>foo(T t)</code></li>
- * <li>pattern: <code><Exception>foo(new Exception())</code></li>
- * <li>match: <code><Object>foo(new Object())</code></li>
- * </ul>
- * Can be combined to all other match rules, e.g. {@link #R_CASE_SENSITIVE} | {@link #R_ERASURE_MATCH}
- * This rule is not activated by default, so raw types or parameterized types with same erasure will not be found
- * for pattern List<String>,
- * Note that with this pattern, the match selection will be only on the erasure even for parameterized types.
- * @since 3.1
- */
- public static final int R_ERASURE_MATCH = 0x0010;
-
- /**
- * Match rule: The search pattern matches search results as raw/parameterized types/methods with equivalent type parameters.
- * This mode has no effect on other java elements search.<br>
- * Type search example:
- * <ul>
- * <li>pattern: <code>List<Exception></code></li>
- * <li>match:
- * <ul>
- * <li><code>List<? extends Throwable></code></li>
- * <li><code>List<? super RuntimeException></code></li>
- * <li><code>List<?></code></li>
- * </ul>
- * </li>
- * </ul>
- * Method search example:
- * <ul>
- * <li>declaration: <code><T>foo(T t)</code></li>
- * <li>pattern: <code><Exception>foo(new Exception())</code></li>
- * <li>match:
- * <ul>
- * <li><code><? extends Throwable>foo(new Exception())</code></li>
- * <li><code><? super RuntimeException>foo(new Exception())</code></li>
- * <li><code>foo(new Exception())</code></li>
- * </ul>
- * </ul>
- * Can be combined to all other match rules, e.g. {@link #R_CASE_SENSITIVE} | {@link #R_EQUIVALENT_MATCH}
- * This rule is not activated by default, so raw types or equivalent parameterized types will not be found
- * for pattern List<String>,
- * This mode is overridden by {@link #R_ERASURE_MATCH} as erasure matches obviously include equivalent ones.
- * That means that pattern with rule set to {@link #R_EQUIVALENT_MATCH} | {@link #R_ERASURE_MATCH}
- * will return same results than rule only set with {@link #R_ERASURE_MATCH}.
- * @since 3.1
- */
- public static final int R_EQUIVALENT_MATCH = 0x0020;
-
- /**
- * Match rule: The search pattern matches exactly the search result,
- * that is, the source of the search result equals the search pattern.
- * @since 3.1
- */
- public static final int R_FULL_MATCH = 0x0040;
-
- /**
- * Match rule: The search pattern contains a Camel Case expression.
- * <br>
- * Examples:
- * <ul>
- * <li><code>NPE</code> type string pattern will match
- * <code>NullPointerException</code> and <code>NpPermissionException</code> types,</li>
- * <li><code>NuPoEx</code> type string pattern will only match
- * <code>NullPointerException</code> type.</li>
- * </ul>
- * @see CharOperation#camelCaseMatch(char[], char[]) for a detailed explanation
- * of Camel Case matching.
- *<br>
- * Can be combined to {@link #R_PREFIX_MATCH} match rule. For example,
- * when prefix match rule is combined with Camel Case match rule,
- * <code>"nPE"</code> pattern will match <code>nPException</code>.
- *<br>
- * Match rule {@link #R_PATTERN_MATCH} may also be combined but both rules
- * will not be used simultaneously as they are mutually exclusive.
- * Used match rule depends on whether string pattern contains specific pattern
- * characters (e.g. '*' or '?') or not. If it does, then only Pattern match rule
- * will be used, otherwise only Camel Case match will be used.
- * For example, with <code>"NPE"</code> string pattern, search will only use
- * Camel Case match rule, but with <code>N*P*E*</code> string pattern, it will
- * use only Pattern match rule.
- *
- * @since 3.2
- */
- public static final int R_CAMELCASE_MATCH = 0x0080;
-
- private static final int MODE_MASK = R_EXACT_MATCH | R_PREFIX_MATCH | R_PATTERN_MATCH | R_REGEXP_MATCH;
-
-}
+package org.rubypeople.rdt.core.search;
+
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
+import org.rubypeople.rdt.internal.core.search.matching.ConstructorPattern;
+import org.rubypeople.rdt.internal.core.search.matching.FieldPattern;
+import org.rubypeople.rdt.internal.core.search.matching.InternalSearchPattern;
+import org.rubypeople.rdt.internal.core.search.matching.MethodPattern;
+import org.rubypeople.rdt.internal.core.search.matching.OrPattern;
+import org.rubypeople.rdt.internal.core.search.matching.QualifiedTypeDeclarationPattern;
+import org.rubypeople.rdt.internal.core.search.matching.TypeReferencePattern;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+public abstract class SearchPattern extends InternalSearchPattern {
+// 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 is a prefix of the search result.
+ */
+ public static final int R_PREFIX_MATCH = 0x0001;
+
+ /**
+ * Match rule: The search pattern contains one or more wild cards ('*' or '?').
+ * A '*' wild-card can replace 0 or more characters in the search result.
+ * A '?' wild-card replaces exactly 1 character in the search result.
+ */
+ public static final int R_PATTERN_MATCH = 0x0002;
+
+ /**
+ * Match rule: The search pattern contains a regular expression.
+ */
+ public static final int R_REGEXP_MATCH = 0x0004;
+
+ /**
+ * 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 = 0x0008;
+
+ /**
+ * Match rule: The search pattern matches search results as raw/parameterized types/methods with same erasure.
+ * This mode has no effect on other java elements search.<br>
+ * Type search example:
+ * <ul>
+ * <li>pattern: <code>List<Exception></code></li>
+ * <li>match: <code>List<Object></code></li>
+ * </ul>
+ * Method search example:
+ * <ul>
+ * <li>declaration: <code><T>foo(T t)</code></li>
+ * <li>pattern: <code><Exception>foo(new Exception())</code></li>
+ * <li>match: <code><Object>foo(new Object())</code></li>
+ * </ul>
+ * Can be combined to all other match rules, e.g. {@link #R_CASE_SENSITIVE} | {@link #R_ERASURE_MATCH}
+ * This rule is not activated by default, so raw types or parameterized types with same erasure will not be found
+ * for pattern List<String>,
+ * Note that with this pattern, the match selection will be only on the erasure even for parameterized types.
+ * @since 3.1
+ */
+ public static final int R_ERASURE_MATCH = 0x0010;
+
+ /**
+ * Match rule: The search pattern matches search results as raw/parameterized types/methods with equivalent type parameters.
+ * This mode has no effect on other java elements search.<br>
+ * Type search example:
+ * <ul>
+ * <li>pattern: <code>List<Exception></code></li>
+ * <li>match:
+ * <ul>
+ * <li><code>List<? extends Throwable></code></li>
+ * <li><code>List<? super RuntimeException></code></li>
+ * <li><code>List<?></code></li>
+ * </ul>
+ * </li>
+ * </ul>
+ * Method search example:
+ * <ul>
+ * <li>declaration: <code><T>foo(T t)</code></li>
+ * <li>pattern: <code><Exception>foo(new Exception())</code></li>
+ * <li>match:
+ * <ul>
+ * <li><code><? extends Throwable>foo(new Exception())</code></li>
+ * <li><code><? super RuntimeException>foo(new Exception())</code></li>
+ * <li><code>foo(new Exception())</code></li>
+ * </ul>
+ * </ul>
+ * Can be combined to all other match rules, e.g. {@link #R_CASE_SENSITIVE} | {@link #R_EQUIVALENT_MATCH}
+ * This rule is not activated by default, so raw types or equivalent parameterized types will not be found
+ * for pattern List<String>,
+ * This mode is overridden by {@link #R_ERASURE_MATCH} as erasure matches obviously include equivalent ones.
+ * That means that pattern with rule set to {@link #R_EQUIVALENT_MATCH} | {@link #R_ERASURE_MATCH}
+ * will return same results than rule only set with {@link #R_ERASURE_MATCH}.
+ * @since 3.1
+ */
+ public static final int R_EQUIVALENT_MATCH = 0x0020;
+
+ /**
+ * Match rule: The search pattern matches exactly the search result,
+ * that is, the source of the search result equals the search pattern.
+ * @since 3.1
+ */
+ public static final int R_FULL_MATCH = 0x0040;
+
+ /**
+ * Match rule: The search pattern contains a Camel Case expression.
+ * <br>
+ * Examples:
+ * <ul>
+ * <li><code>NPE</code> type string pattern will match
+ * <code>NullPointerException</code> and <code>NpPermissionException</code> types,</li>
+ * <li><code>NuPoEx</code> type string pattern will only match
+ * <code>NullPointerException</code> type.</li>
+ * </ul>
+ * @see CharOperation#camelCaseMatch(char[], char[]) for a detailed explanation
+ * of Camel Case matching.
+ *<br>
+ * Can be combined to {@link #R_PREFIX_MATCH} match rule. For example,
+ * when prefix match rule is combined with Camel Case match rule,
+ * <code>"nPE"</code> pattern will match <code>nPException</code>.
+ *<br>
+ * Match rule {@link #R_PATTERN_MATCH} may also be combined but both rules
+ * will not be used simultaneously as they are mutually exclusive.
+ * Used match rule depends on whether string pattern contains specific pattern
+ * characters (e.g. '*' or '?') or not. If it does, then only Pattern match rule
+ * will be used, otherwise only Camel Case match will be used.
+ * For example, with <code>"NPE"</code> string pattern, se...
[truncated message content] |