/** * 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()); }
/** * 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; } }
/** * 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; } }
@Override public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) { if (!isCamelCaseMatching()) return getReplacementString(); String prefix= getPrefix(document, completionOffset); return getCamelCaseCompound(prefix, getReplacementString()); }
@Override public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) { if (!isCamelCaseMatching()) return getReplacementString(); String prefix= getPrefix(document, completionOffset); return getCamelCaseCompound(prefix, getReplacementString()); }
public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) { if (!isCamelCaseMatching()) return getReplacementString(); String prefix= getPrefix(document, completionOffset); return getCamelCaseCompound(prefix, getReplacementString()); }