/** Method entries are encoded as selector '/' Arity: e.g. 'foo/0' */ public static char[] createIndexKey(char[] selector, int argCount) { char[] countChars = argCount < 10 ? COUNTS[argCount] : (SEPARATOR + String.valueOf(argCount)).toCharArray(); // $NON-NLS-1$ return CharOperation.concat(selector, countChars); }
public EntryResult[] queryIn(Index index) throws IOException { char[] key = this.selector; // can be null int matchRule = getMatchRule(); switch (getMatchMode()) { case R_EXACT_MATCH: if (this.isCamelCase) break; if (this.selector != null && this.parameterCount >= 0) key = createIndexKey(this.selector, this.parameterCount); else { // do a prefix query with the selector matchRule &= ~R_EXACT_MATCH; matchRule |= R_PREFIX_MATCH; } break; case R_PREFIX_MATCH: // do a prefix query with the selector break; case R_PATTERN_MATCH: if (this.parameterCount >= 0) key = createIndexKey(this.selector == null ? ONE_STAR : this.selector, this.parameterCount); else if (this.selector != null && this.selector[this.selector.length - 1] != '*') key = CharOperation.concat(this.selector, ONE_STAR, SEPARATOR); // else do a pattern query with just the selector break; case R_REGEXP_MATCH: // TODO (frederic) implement regular expression match break; } return index.query(getIndexCategories(), key, matchRule); // match // rule is // irrelevant // when the // key is // null }
public MethodPattern( boolean findDeclarations, boolean findReferences, char[] selector, char[] declaringQualification, char[] declaringSimpleName, IType declaringType, int matchRule, IDLTKLanguageToolkit toolkit) { this(matchRule, toolkit); this.findDeclarations = findDeclarations; this.findReferences = findReferences; this.selector = (isCaseSensitive() || isCamelCase()) ? selector : CharOperation.toLowerCase(selector); this.declaringSimpleName = isCaseSensitive() ? declaringSimpleName : CharOperation.toLowerCase(declaringSimpleName); this.declaringQualificationName = isCaseSensitive() ? declaringQualification : CharOperation.toLowerCase(declaringQualification); if (parameterSimpleNames != null) { this.parameterCount = parameterSimpleNames.length; this.parameterQualifications = new char[this.parameterCount][]; this.parameterSimpleNames = new char[this.parameterCount][]; for (int i = 0; i < this.parameterCount; i++) { this.parameterQualifications[i] = isCaseSensitive() ? parameterQualifications[i] : CharOperation.toLowerCase(parameterQualifications[i]); this.parameterSimpleNames[i] = isCaseSensitive() ? parameterSimpleNames[i] : CharOperation.toLowerCase(parameterSimpleNames[i]); } } else { this.parameterCount = -1; } this.declaringType = declaringType; }
/** * Returns the proposed sequence of characters to insert into the source file buffer, replacing * the characters at the specified source range. The string can be arbitrary; for example, it * might include not only the name of a method but a set of parentheses. * * <p>The client must not modify the array returned. * * @return the completion string */ public char[] getCompletion() { if (this.completionKind == METHOD_DECLARATION) { this.findParameterNames(null); if (this.updateCompletion) { this.updateCompletion = false; if (this.parameterNames != null) { int length = this.parameterNames.length; StringBuffer completionBuffer = new StringBuffer(this.completion.length); int start = 0; int end = CharOperation.indexOf('%', this.completion); completionBuffer.append(this.completion, start, end - start); for (int i = 0; i < length; i++) { completionBuffer.append(this.parameterNames[i]); start = end + 1; end = CharOperation.indexOf('%', this.completion, start); if (end > -1) { completionBuffer.append(this.completion, start, end - start); } else { completionBuffer.append(this.completion, start, this.completion.length - start); } } int nameLength = completionBuffer.length(); this.completion = new char[nameLength]; completionBuffer.getChars(0, nameLength, this.completion, 0); } } } else if (this.completionKind == METHOD_REF) { this.findParameterNames(null); if (this.updateCompletion) { this.updateCompletion = false; if (this.parameterNames != null) { int length = this.parameterNames.length; StringBuffer completionBuffer = new StringBuffer(this.completion.length); int start = 0; int end = CharOperation.indexOf('%', this.completion); completionBuffer.append(this.completion, start, end - start); for (int i = 0; i < length; i++) { completionBuffer.append(this.parameterNames[i]); start = end + 1; end = CharOperation.indexOf('%', this.completion, start); if (end > -1) { completionBuffer.append(this.completion, start, end - start); } else { completionBuffer.append(this.completion, start, this.completion.length - start); } } int nameLength = completionBuffer.length(); this.completion = new char[nameLength]; completionBuffer.getChars(0, nameLength, this.completion, 0); } } } return this.completion; }
public boolean equals(Object obj) { if (!(obj instanceof AccessRule)) return false; AccessRule other = (AccessRule) obj; if (this.problemId != other.problemId) return false; return CharOperation.equals(this.pattern, other.pattern); }
public int hashCode() { return this.problemId * 17 + CharOperation.hashCode(this.pattern); }