|
From: <caw...@us...> - 2007-03-13 18:00:21
|
Revision: 2145
http://svn.sourceforge.net/rubyeclipse/?rev=2145&view=rev
Author: cawilliams
Date: 2007-03-13 11:00:18 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/InternalSearchPattern.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-03-13 17:39:10 UTC (rev 2144)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-03-13 18:00:18 UTC (rev 2145)
@@ -3,7 +3,7 @@
import org.rubypeople.rdt.internal.core.search.matching.InternalSearchPattern;
import org.rubypeople.rdt.internal.core.util.CharOperation;
-public class SearchPattern extends InternalSearchPattern {
+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,
@@ -129,5 +129,115 @@
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;
+
+ private int matchRule;
+
+ /**
+ * Creates a search pattern with the rule to apply for matching index keys.
+ * It can be exact match, prefix match, pattern match or regexp match.
+ * Rule can also be combined with a case sensitivity flag.
+ *
+ * @param matchRule one of {@link #R_EXACT_MATCH}, {@link #R_PREFIX_MATCH}, {@link #R_PATTERN_MATCH},
+ * {@link #R_REGEXP_MATCH}, {@link #R_CAMELCASE_MATCH} combined with one of following values:
+ * {@link #R_CASE_SENSITIVE}, {@link #R_ERASURE_MATCH} or {@link #R_EQUIVALENT_MATCH}.
+ * e.g. {@link #R_EXACT_MATCH} | {@link #R_CASE_SENSITIVE} if an exact and case sensitive match is requested,
+ * {@link #R_PREFIX_MATCH} if a prefix non case sensitive match is requested or {@link #R_EXACT_MATCH} | {@link #R_ERASURE_MATCH}
+ * if a non case sensitive and erasure match is requested.<br>
+ * Note that {@link #R_ERASURE_MATCH} or {@link #R_EQUIVALENT_MATCH} have no effect
+ * on non-generic types/methods search.<br>
+ * Note also that default behavior for generic types/methods search is to find exact matches.
+ */
+ public SearchPattern(int matchRule) {
+ this.matchRule = matchRule;
+ // Set full match implicit mode
+ if ((matchRule & (R_EQUIVALENT_MATCH | R_ERASURE_MATCH )) == 0) {
+ this.matchRule |= R_FULL_MATCH;
+ }
+ }
+
+ /**
+ * Returns a blank pattern that can be used as a record to decode an index key.
+ * <p>
+ * Implementors of this method should return a new search pattern that is going to be used
+ * to decode index keys.
+ * </p>
+ *
+ * @return a new blank pattern
+ * @see #decodeIndexKey(char[])
+ */
+ public abstract SearchPattern getBlankPattern();
+ /**
+ * Decode the given index key in this pattern. The decoded index key is used by
+ * {@link #matchesDecodedKey(SearchPattern)} to find out if the corresponding index entry
+ * should be considered.
+ * <p>
+ * This method should be re-implemented in subclasses that need to decode an index key.
+ * </p>
+ *
+ * @param key the given index key
+ */
+ public void decodeIndexKey(char[] key) {
+ // called from findIndexMatches(), override as necessary
+ }
+
+ /**
+ * Returns whether this pattern matches the given pattern (representing a decoded index key).
+ * <p>
+ * This method should be re-implemented in subclasses that need to narrow down the
+ * index query.
+ * </p>
+ *
+ * @param decodedPattern a pattern representing a decoded index key
+ * @return whether this pattern matches the given pattern
+ */
+ public boolean matchesDecodedKey(SearchPattern decodedPattern) {
+ return true; // called from findIndexMatches(), override as necessary if index key is encoded
+ }
+
+ /**
+ * Returns an array of index categories to consider for this index query.
+ * These potential matches will be further narrowed by the match locator, but precise
+ * match locating can be expensive, and index query should be as accurate as possible
+ * so as to eliminate obvious false hits.
+ * <p>
+ * This method should be re-implemented in subclasses that need to narrow down the
+ * index query.
+ * </p>
+ *
+ * @return an array of index categories
+ */
+ public char[][] getIndexCategories() {
+ return CharOperation.NO_CHAR_CHAR; // called from queryIn(), override as necessary
+ }
+
+ /**
+ * Returns a key to find in relevant index categories, if null then all index entries are matched.
+ * The key will be matched according to some match rule. These potential matches
+ * will be further narrowed by the match locator, but precise match locating can be expensive,
+ * and index query should be as accurate as possible so as to eliminate obvious false hits.
+ * <p>
+ * This method should be re-implemented in subclasses that need to narrow down the
+ * index query.
+ * </p>
+ *
+ * @return an index key from this pattern, or <code>null</code> if all index entries are matched.
+ */
+ public char[] getIndexKey() {
+ return null; // called from queryIn(), override as necessary
+ }
+
+ /**
+ * Returns the rule to apply for matching index keys. Can be exact match, prefix match, pattern match or regexp match.
+ * Rule can also be combined with a case sensitivity flag.
+ *
+ * @return one of R_EXACT_MATCH, R_PREFIX_MATCH, R_PATTERN_MATCH, R_REGEXP_MATCH combined with R_CASE_SENSITIVE,
+ * e.g. R_EXACT_MATCH | R_CASE_SENSITIVE if an exact and case sensitive match is requested,
+ * or R_PREFIX_MATCH if a prefix non case sensitive match is requested.
+ * [TODO (frederic) I hope R_ERASURE_MATCH doesn't need to be on this list. Because it would be a breaking API change.]
+ */
+ public final int getMatchRule() {
+ return this.matchRule;
+ }
+
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/InternalSearchPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/InternalSearchPattern.java 2007-03-13 17:39:10 UTC (rev 2144)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/InternalSearchPattern.java 2007-03-13 18:00:18 UTC (rev 2145)
@@ -62,7 +62,7 @@
return (SearchPattern) this;
}
String documentPath(String containerPath, String relativePath) {
- String separator = Util.isArchiveFileName(containerPath) ? IRubySearchScope.JAR_FILE_ENTRY_SEPARATOR : "/"; //$NON-NLS-1$
+ String separator = "/"; //$NON-NLS-1$
StringBuffer buffer = new StringBuffer(containerPath.length() + separator.length() + relativePath.length());
buffer.append(containerPath);
buffer.append(separator);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|