Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/search/matching/SuperTypeReferencePattern.java')
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/search/matching/SuperTypeReferencePattern.java298
1 files changed, 117 insertions, 181 deletions
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/search/matching/SuperTypeReferencePattern.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/search/matching/SuperTypeReferencePattern.java
index 9611618a..925dab70 100644
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/search/matching/SuperTypeReferencePattern.java
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/search/matching/SuperTypeReferencePattern.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 20112 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
@@ -19,203 +19,139 @@ import org.eclipse.wst.jsdt.internal.core.index.Index;
public class SuperTypeReferencePattern extends JavaSearchPattern {
-public char[] superQualification;
-public char[] superSimpleName;
-
-public char[] pkgName;
-public char[] simpleName;
-public char[] enclosingTypeName;
-public int modifiers;
-
-protected static char[][] CATEGORIES = { SUPER_REF };
-
-public static char[] createIndexKey(
- int modifiers,
- char[] packageName,
- char[] typeName,
- char[][] enclosingTypeNames,
- char[] superTypeName) {
-
- if (superTypeName == null)
- superTypeName = OBJECT;
- char[] superSimpleName = superTypeName;//CharOperation.lastSegment(superTypeName, '.');
- char[] superQualification = null;
-// if (superSimpleName != superTypeName) {
-// int length = superTypeName.length - superSimpleName.length - 1;
-// superQualification = new char[length];
-// System.arraycopy(superTypeName, 0, superQualification, 0, length);
-// }
-
- // if the supertype name contains a $, then split it into: source name and append the $ prefix to the qualification
- // e.g. p.A$B ---> p.A$ + B
- char[] superTypeSourceName = CharOperation.lastSegment(superSimpleName, '$');
- if (superTypeSourceName != superSimpleName) {
- int start = superQualification == null ? 0 : superQualification.length + 1;
- int prefixLength = superSimpleName.length - superTypeSourceName.length;
- char[] mangledQualification = new char[start + prefixLength];
- if (superQualification != null) {
- System.arraycopy(superQualification, 0, mangledQualification, 0, start-1);
- mangledQualification[start-1] = '.';
+ public char[] superTypeName;
+ public char[] typeName;
+
+ protected static char[][] CATEGORIES = {SUPER_REF};
+
+ public static char[] createIndexKey(char[] typeName, char[] superTypeName) {
+ if (superTypeName == null) {
+ superTypeName = OBJECT;
}
- System.arraycopy(superSimpleName, 0, mangledQualification, start, prefixLength);
- superQualification = mangledQualification;
- superSimpleName = superTypeSourceName;
- }
- char[] simpleName = CharOperation.lastSegment(typeName, '.');
- char[] simpleNameTemp = new char[simpleName.length + packageName.length + 1];
- System.arraycopy(packageName, 0, simpleNameTemp, 0, packageName.length);
- simpleNameTemp[packageName.length] = '.';
- System.arraycopy(simpleName, 0, simpleNameTemp, packageName.length + 1, simpleName.length);
-
- simpleName = simpleNameTemp;
- char[] enclosingTypeName = CharOperation.concatWith(enclosingTypeNames, '$');
- if (superQualification != null && CharOperation.equals(superQualification, packageName))
- packageName = ONE_ZERO; // save some space
-
- // superSimpleName / superQualification / simpleName / enclosingTypeName / typeParameters / packageName / superClassOrInterface classOrInterface modifiers
- int superLength = superSimpleName == null ? 0 : superSimpleName.length;
- int superQLength = superQualification == null ? 0 : superQualification.length;
- int simpleLength = simpleName == null ? 0 : simpleName.length;
- int enclosingLength = enclosingTypeName == null ? 0 : enclosingTypeName.length;
- int packageLength = packageName == null ? 0 : packageName.length;
- char[] result = new char[superLength + superQLength + simpleLength + enclosingLength + packageLength + 9];
- int pos = 0;
- if (superLength > 0) {
- System.arraycopy(superSimpleName, 0, result, pos, superLength);
- pos += superLength;
+ // superSimpleName / superQualification / simpleName /
+ // enclosingTypeName / typeParameters / packageName / superClassOrInterface
+ // classOrInterface modifiers
+ // superTypeName / typeName / modifiers
+ int superLength = superTypeName == null ? 0 : superTypeName.length;
+ int typeLength = typeName == null ? 0 : typeName.length;
+ char[] result = new char[superLength + typeLength + 1];
+ int pos = 0;
+ if (superLength > 0) {
+ System.arraycopy(superTypeName, 0, result, pos, superLength);
+ pos += superLength;
+ }
+ result[pos++] = SEPARATOR;
+ if (typeLength > 0) {
+ System.arraycopy(typeName, 0, result, pos, typeLength);
+ pos += typeLength;
+ }
+ return result;
}
- result[pos++] = SEPARATOR;
- if (superQLength > 0) {
- System.arraycopy(superQualification, 0, result, pos, superQLength);
- pos += superQLength;
+
+ public SuperTypeReferencePattern(char[] superTypeName, int matchRule) {
+ this(matchRule);
+
+ this.superTypeName = isCaseSensitive() ? superTypeName : CharOperation.toLowerCase(superTypeName);
}
- result[pos++] = SEPARATOR;
- if (simpleLength > 0) {
- System.arraycopy(simpleName, 0, result, pos, simpleLength);
- pos += simpleLength;
+
+ SuperTypeReferencePattern(int matchRule) {
+ super(SUPER_REF_PATTERN, matchRule);
}
- result[pos++] = SEPARATOR;
- if (enclosingLength > 0) {
- System.arraycopy(enclosingTypeName, 0, result, pos, enclosingLength);
- pos += enclosingLength;
+
+ /**
+ * <p>
+ * superSimpleName / superQualification / simpleName / enclosingTypeName /
+ * typeParameters / pkgName / superClassOrInterface classOrInterface modifiers
+ * </p>
+ *
+ * @see org.eclipse.wst.jsdt.core.search.SearchPattern#decodeIndexKey(char[])
+ */
+ public void decodeIndexKey(char[] key) {
+ int slash = CharOperation.indexOf(SEPARATOR, key, 0);
+ this.superTypeName = CharOperation.subarray(key, 0, slash);
+
+ // some values may not have been know when indexed so decode as null
+ int start = slash + 1;
+ slash = CharOperation.indexOf(SEPARATOR, key, start);
+ this.typeName = CharOperation.subarray(key, start, slash);
}
- result[pos++] = SEPARATOR;
- if (packageLength > 0) {
- System.arraycopy(packageName, 0, result, pos, packageLength);
- pos += packageLength;
+
+ /**
+ * @see org.eclipse.wst.jsdt.internal.core.search.matching.JavaSearchPattern#getBlankPattern()
+ */
+ public SearchPattern getBlankPattern() {
+ return new SuperTypeReferencePattern(R_EXACT_MATCH | R_CASE_SENSITIVE);
}
- result[pos++] = SEPARATOR;
- result[pos] = (char) modifiers;
- return result;
-}
-public SuperTypeReferencePattern(
- char[] superQualification,
- char[] superSimpleName,
- int matchRule) {
+ /**
+ * @see org.eclipse.wst.jsdt.core.search.SearchPattern#getIndexCategories()
+ */
+ public char[][] getIndexCategories() {
+ return CATEGORIES;
+ }
- this(matchRule);
+ /**
+ * @see org.eclipse.wst.jsdt.core.search.SearchPattern#matchesDecodedKey(org.eclipse.wst.jsdt.core.search.SearchPattern)
+ */
+ public boolean matchesDecodedKey(SearchPattern decodedPattern) {
+ SuperTypeReferencePattern pattern = (SuperTypeReferencePattern) decodedPattern;
- this.superQualification = isCaseSensitive() ? superQualification : CharOperation.toLowerCase(superQualification);
- this.superSimpleName = (isCaseSensitive() || isCamelCase()) ? superSimpleName : CharOperation.toLowerCase(superSimpleName);
- ((InternalSearchPattern)this).mustResolve = superQualification != null;
-}
-SuperTypeReferencePattern(int matchRule) {
- super(SUPER_REF_PATTERN, matchRule);
-}
-/*
- * superSimpleName / superQualification / simpleName / enclosingTypeName / typeParameters / pkgName / superClassOrInterface classOrInterface modifiers
- */
-public void decodeIndexKey(char[] key) {
- int slash = CharOperation.indexOf(SEPARATOR, key, 0);
- this.superSimpleName = CharOperation.subarray(key, 0, slash);
-
- // some values may not have been know when indexed so decode as null
- int start = slash + 1;
- slash = CharOperation.indexOf(SEPARATOR, key, start);
- this.superQualification = slash == start ? null : CharOperation.subarray(key, start, slash);
-
- slash = CharOperation.indexOf(SEPARATOR, key, start = slash + 1);
- this.simpleName = CharOperation.subarray(key, start, slash);
-
- start = ++slash;
- if (key[start] == SEPARATOR) {
- this.enclosingTypeName = null;
- } else {
- slash = CharOperation.indexOf(SEPARATOR, key, start);
- if (slash == (start+1) && key[start] == ZERO_CHAR) {
- this.enclosingTypeName = ONE_ZERO;
- } else {
- char[] names = CharOperation.subarray(key, start, slash);
- this.enclosingTypeName = names;
+ if (pattern.superTypeName != null) {
+ if (!matchesName(this.superTypeName, pattern.superTypeName)) {
+ return false;
+ }
}
- }
- start = ++slash;
- if (key[start] == SEPARATOR) {
- this.pkgName = null;
- } else {
- slash = CharOperation.indexOf(SEPARATOR, key, start);
- if (slash == (start+1) && key[start] == ZERO_CHAR) {
- this.pkgName = this.superQualification;
- } else {
- char[] names = CharOperation.subarray(key, start, slash);
- this.pkgName = names;
- }
+ return matchesName(this.typeName, pattern.typeName);
}
- this.modifiers = key[slash + 3]; // implicit cast to int type
-}
-public SearchPattern getBlankPattern() {
- return new SuperTypeReferencePattern(R_EXACT_MATCH | R_CASE_SENSITIVE);
-}
-public char[][] getIndexCategories() {
- return CATEGORIES;
-}
-public boolean matchesDecodedKey(SearchPattern decodedPattern) {
- SuperTypeReferencePattern pattern = (SuperTypeReferencePattern) decodedPattern;
-
- if (pattern.superQualification != null)
- if (!matchesName(this.superQualification, pattern.superQualification)) return false;
+ /**
+ * @see org.eclipse.wst.jsdt.internal.core.search.matching.InternalSearchPattern#queryIn(org.eclipse.wst.jsdt.internal.core.index.Index)
+ */
+ EntryResult[] queryIn(Index index) throws IOException {
+ char[] key = this.superTypeName; // can be null
+ int matchRule = getMatchRule();
+
+ // cannot include the superQualification since it may not exist in the index
+ switch (getMatchMode()) {
+ case R_EXACT_MATCH :
+ if (this.isCamelCase)
+ break;
+ // do a prefix query with the superSimpleName
+ matchRule &= ~R_EXACT_MATCH;
+ matchRule |= R_PREFIX_MATCH;
+ if (this.superTypeName != null)
+ key = CharOperation.append(this.superTypeName, SEPARATOR);
+ break;
+ case R_PREFIX_MATCH :
+ // do a prefix query with the superSimpleName
+ break;
+ case R_PATTERN_MATCH :
+ // do a pattern query with the superSimpleName
+ break;
+ case R_REGEXP_MATCH :
+ // TODO (frederic) implement regular expression match
+ break;
+ }
- return matchesName(this.superSimpleName, pattern.superSimpleName);
-}
-EntryResult[] queryIn(Index index) throws IOException {
- char[] key = this.superSimpleName; // can be null
- int matchRule = getMatchRule();
-
- // cannot include the superQualification since it may not exist in the index
- switch(getMatchMode()) {
- case R_EXACT_MATCH :
- if (this.isCamelCase) break;
- // do a prefix query with the superSimpleName
- matchRule &= ~R_EXACT_MATCH;
- matchRule |= R_PREFIX_MATCH;
- if (this.superSimpleName != null)
- key = CharOperation.append(this.superSimpleName, SEPARATOR);
- break;
- case R_PREFIX_MATCH :
- // do a prefix query with the superSimpleName
- break;
- case R_PATTERN_MATCH :
- // do a pattern query with the superSimpleName
- break;
- case R_REGEXP_MATCH :
- // TODO (frederic) implement regular expression match
- break;
+ // match rule is irrelevant when the key is null
+ return index.query(getIndexCategories(), key, matchRule);
}
- return index.query(getIndexCategories(), key, matchRule); // match rule is irrelevant when the key is null
-}
-protected StringBuffer print(StringBuffer output) {
+ /**
+ * @see org.eclipse.wst.jsdt.internal.core.search.matching.JavaSearchPattern#print(java.lang.StringBuffer)
+ */
+ protected StringBuffer print(StringBuffer output) {
output.append("SuperClassReferencePattern: <"); //$NON-NLS-1$
- if (superSimpleName != null)
- output.append(superSimpleName);
- else
- output.append("*"); //$NON-NLS-1$
- output.append(">"); //$NON-NLS-1$
- return super.print(output);
-}
+ if (superTypeName != null) {
+ output.append(superTypeName);
+ } else {
+ output.append("*"); //$NON-NLS-1$
+ }
+
+ output.append(">"); //$NON-NLS-1$
+ return super.print(output);
+ }
}

Back to the top