/** * @since 2.1 */ protected boolean isJdtAvailable() { try { org.eclipse.jdt.core.compiler.CharOperation.camelCaseMatch(null, null); return true; } catch(Throwable t) { return false; } }
/** * @since 2.1 */ protected boolean camelCaseMatch(String name, String prefix) { return org.eclipse.jdt.core.compiler.CharOperation.camelCaseMatch(prefix.toCharArray(), name.toCharArray()); } }
/** * Case insensitive comparison of <code>prefix</code> with the start of <code>string</code>. * * @param prefix the prefix * @param string the string to look for the prefix * @return <code>true</code> if the string begins with the given prefix and * <code>false</code> if <code>prefix</code> is longer than <code>string</code> * or the string doesn't start with the given prefix * @since 3.2 */ protected boolean isPrefix(String prefix, String string) { if (prefix == null || string ==null || prefix.length() > string.length()) return false; String start= string.substring(0, prefix.length()); return start.equalsIgnoreCase(prefix) || isCamelCaseMatching() && CharOperation.camelCaseMatch(prefix.toCharArray(), string.toCharArray()); }
/** * Checks whether name matches the token according to the current * code completion settings (substring match, camel case match etc.) * and sets whether the current match is a suffix proposal. * * @param token the token that is tested * @param name the name to match * @return <code>true</code> if the token does not match, * <code>false</code> otherwise */ private boolean isFailedMatch(char[] token, char[] name) { if ((this.options.substringMatch && CharOperation.substringMatch(token, name)) || (this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, name)) || CharOperation.prefixEquals(token, name, false)) { return false; } return true; } private boolean isForbidden(ReferenceBinding binding) {
/** * Checks whether name matches the token according to the current * code completion settings (substring match, camel case match etc.) * and sets whether the current match is a suffix proposal. * * @param token the token that is tested * @param name the name to match * @return <code>true</code> if the token does not match, * <code>false</code> otherwise */ private boolean isFailedMatch(char[] token, char[] name) { if ((this.options.substringMatch && CharOperation.substringMatch(token, name)) || (this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, name)) || CharOperation.prefixEquals(token, name, false)) { return false; } return true; } private boolean isForbidden(ReferenceBinding binding) {
/** * Checks whether name matches the token according to the current * code completion settings (substring match, camel case match etc.) * and sets whether the current match is a suffix proposal. * * @param token the token that is tested * @param name the name to match * @return <code>true</code> if the token does not match, * <code>false</code> otherwise */ private boolean isFailedMatch(char[] token, char[] name) { if ((this.options.substringMatch && CharOperation.substringMatch(token, name)) || (this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, name)) || CharOperation.prefixEquals(token, name, false)) { return false; } return true; } private boolean isForbidden(ReferenceBinding binding) {
/** * Matches the given <code>pattern</code> in <code>string</code> and returns the match rule. * * @param pattern the pattern to match * @param string the string to look for the pattern * @return the match rule used to match the given <code>pattern</code> in <code>string</code>, * or -1 if the <code>pattern</code> doesn't match the <code>string</code> based on any * rule * @since 3.12 */ protected int getPatternMatchRule(String pattern, String string) { String start; try { start= string.substring(0, pattern.length()); } catch (StringIndexOutOfBoundsException e) { String message= "Error retrieving proposal text.\nDisplay string:\n" + string + "\nPattern:\n" + pattern; //$NON-NLS-1$//$NON-NLS-2$ JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, message, e)); return -1; } if (start.equalsIgnoreCase(pattern)) { return SearchPattern.R_PREFIX_MATCH; } else if (isCamelCaseMatching() && CharOperation.camelCaseMatch(pattern.toCharArray(), string.toCharArray())) { return SearchPattern.R_CAMELCASE_MATCH; } else if (isSubstringMatching() && CharOperation.substringMatch(pattern.toCharArray(), string.toCharArray())) { return SearchPattern.R_SUBSTRING_MATCH; } else { return -1; } }
boolean match(char[] patternName, int matchRule, char[] name) { boolean isCaseSensitive = (matchRule & SearchPattern.R_CASE_SENSITIVE) != 0; if (patternName != null) { boolean isCamelCase = (matchRule & (SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH)) != 0; int matchMode = matchRule & JavaSearchPattern.MATCH_MODE_MASK; if (!isCaseSensitive && !isCamelCase) { patternName = CharOperation.toLowerCase(patternName); } boolean matchFirstChar = !isCaseSensitive || patternName[0] == name[0]; switch(matchMode) { case SearchPattern.R_EXACT_MATCH : return matchFirstChar && CharOperation.equals(patternName, name, isCaseSensitive); case SearchPattern.R_PREFIX_MATCH : return matchFirstChar && CharOperation.prefixEquals(patternName, name, isCaseSensitive); case SearchPattern.R_PATTERN_MATCH : return CharOperation.match(patternName, name, isCaseSensitive); case SearchPattern.R_REGEXP_MATCH : return Pattern.matches(new String(patternName), new String(name)); case SearchPattern.R_CAMELCASE_MATCH: if (matchFirstChar && CharOperation.camelCaseMatch(patternName, name, false)) { return true; } return !isCaseSensitive && matchFirstChar && CharOperation.prefixEquals(patternName, name, false); case SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH: return matchFirstChar && CharOperation.camelCaseMatch(patternName, name, true); } } return true; }
private void acceptName(char[] name) { // the null check is added to fix bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=166570 if (name == null) return; if (!CharOperation.prefixEquals(this.completionEngine.completionToken, name, false /* ignore case */) && !(this.completionEngine.options.camelCaseMatch && CharOperation.camelCaseMatch(this.completionEngine.completionToken, name))) return; if (this.acceptedNames.includes(name)) return; this.acceptedNames.add(name); // accept result this.requestor.acceptName(name); }
private void acceptName(char[] name) { // the null check is added to fix bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=166570 if (name == null) return; if (!CharOperation.prefixEquals(this.completionEngine.completionToken, name, false /* ignore case */) && !(this.completionEngine.options.camelCaseMatch && CharOperation.camelCaseMatch(this.completionEngine.completionToken, name))) return; if (this.acceptedNames.includes(name)) return; this.acceptedNames.add(name); // accept result this.requestor.acceptName(name); }
private void acceptName(char[] name) { // the null check is added to fix bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=166570 if (name == null) return; if (!CharOperation.prefixEquals(this.completionEngine.completionToken, name, false /* ignore case */) && !(this.completionEngine.options.camelCaseMatch && CharOperation.camelCaseMatch(this.completionEngine.completionToken, name))) return; if (this.acceptedNames.includes(name)) return; this.acceptedNames.add(name); // accept result this.requestor.acceptName(name); }
private void acceptName(char[] name) { // the null check is added to fix bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=166570 if (name == null) return; if (!CharOperation.prefixEquals(this.completionEngine.completionToken, name, false /* ignore case */) && !(this.completionEngine.options.camelCaseMatch && CharOperation.camelCaseMatch(this.completionEngine.completionToken, name))) return; if (this.acceptedNames.includes(name)) return; this.acceptedNames.add(name); // accept result this.requestor.acceptName(name); }
private void acceptName(char[] name) { // the null check is added to fix bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=166570 if (name == null) return; if (!CharOperation.prefixEquals(this.completionEngine.completionToken, name, false /* ignore case */) && !(this.completionEngine.options.camelCaseMatch && CharOperation.camelCaseMatch(this.completionEngine.completionToken, name))) return; if (this.acceptedNames.includes(name)) return; this.acceptedNames.add(name); // accept result this.requestor.acceptName(name); }
private void acceptName(char[] name) { // the null check is added to fix bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=166570 if (name == null) return; if (!CharOperation.prefixEquals(this.completionEngine.completionToken, name, false /* ignore case */) && !(this.completionEngine.options.camelCaseMatch && CharOperation.camelCaseMatch(this.completionEngine.completionToken, name))) return; if (this.acceptedNames.includes(name)) return; this.acceptedNames.add(name); // accept result this.requestor.acceptName(name); }
int computeRelevanceForCaseMatching(char[] token, char[] proposalName){ if(CharOperation.equals(token, proposalName, true)) { return R_EXACT_NAME + R_CASE; } else if(CharOperation.equals(token, proposalName, false)) { return R_EXACT_NAME; } else if (CharOperation.prefixEquals(token, proposalName, false)) { if (CharOperation.prefixEquals(token, proposalName, true)) return R_CASE; } else if (this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, proposalName)){ return R_CAMEL_CASE; } else if (this.options.substringMatch && CharOperation.substringMatch(token, proposalName)) { return R_SUBSTRING; } return 0; }
int computeRelevanceForCaseMatching(char[] token, char[] proposalName){ if(CharOperation.equals(token, proposalName, true)) { return R_EXACT_NAME + R_CASE; } else if(CharOperation.equals(token, proposalName, false)) { return R_EXACT_NAME; } else if (CharOperation.prefixEquals(token, proposalName, false)) { if (CharOperation.prefixEquals(token, proposalName, true)) return R_CASE; } else if (this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, proposalName)){ return R_CAMEL_CASE; } else if (this.options.substringMatch && CharOperation.substringMatch(token, proposalName)) { return R_SUBSTRING; } return 0; }
int computeRelevanceForCaseMatching(char[] token, char[] proposalName){ if(CharOperation.equals(token, proposalName, true)) { return R_EXACT_NAME + R_CASE; } else if(CharOperation.equals(token, proposalName, false)) { return R_EXACT_NAME; } else if (CharOperation.prefixEquals(token, proposalName, false)) { if (CharOperation.prefixEquals(token, proposalName, true)) return R_CASE; } else if (this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, proposalName)){ return R_CAMEL_CASE; } else if (this.options.substringMatch && CharOperation.substringMatch(token, proposalName)) { return R_SUBSTRING; } return 0; }
int computeRelevanceForCaseMatching(char[] token, char[] proposalName){ if (this.options.camelCaseMatch) { if(CharOperation.equals(token, proposalName, true /* do not ignore case */)) { return R_CASE + R_EXACT_NAME; } else if (CharOperation.prefixEquals(token, proposalName, true /* do not ignore case */)) { return R_CASE; } else if (CharOperation.camelCaseMatch(token, proposalName)){ return R_CAMEL_CASE; } else if(CharOperation.equals(token, proposalName, false /* ignore case */)) { return R_EXACT_NAME; } } else if (CharOperation.prefixEquals(token, proposalName, true /* do not ignore case */)) { if(CharOperation.equals(token, proposalName, true /* do not ignore case */)) { return R_CASE + R_EXACT_NAME; } else { return R_CASE; } } else if(CharOperation.equals(token, proposalName, false /* ignore case */)) { return R_EXACT_NAME; } return 0; }
int computeRelevanceForCaseMatching(char[] token, char[] proposalName){ if (this.options.camelCaseMatch) { if(CharOperation.equals(token, proposalName, true /* do not ignore case */)) { return R_CASE + R_EXACT_NAME; } else if (CharOperation.prefixEquals(token, proposalName, true /* do not ignore case */)) { return R_CASE; } else if (CharOperation.camelCaseMatch(token, proposalName)){ return R_CAMEL_CASE; } else if(CharOperation.equals(token, proposalName, false /* ignore case */)) { return R_EXACT_NAME; } } else if (CharOperation.prefixEquals(token, proposalName, true /* do not ignore case */)) { if(CharOperation.equals(token, proposalName, true /* do not ignore case */)) { return R_CASE + R_EXACT_NAME; } else { return R_CASE; } } else if(CharOperation.equals(token, proposalName, false /* ignore case */)) { return R_EXACT_NAME; } return 0; }
int computeRelevanceForCaseMatching(char[] token, char[] proposalName){ if (this.options.camelCaseMatch) { if(CharOperation.equals(token, proposalName, true /* do not ignore case */)) { return R_CASE + R_EXACT_NAME; } else if (CharOperation.prefixEquals(token, proposalName, true /* do not ignore case */)) { return R_CASE; } else if (CharOperation.camelCaseMatch(token, proposalName)){ return R_CAMEL_CASE; } else if(CharOperation.equals(token, proposalName, false /* ignore case */)) { return R_EXACT_NAME; } } else if (CharOperation.prefixEquals(token, proposalName, true /* do not ignore case */)) { if(CharOperation.equals(token, proposalName, true /* do not ignore case */)) { return R_CASE + R_EXACT_NAME; } else { return R_CASE; } } else if(CharOperation.equals(token, proposalName, false /* ignore case */)) { return R_EXACT_NAME; } return 0; }