Java Code Examples for com.intellij.codeInsight.lookup.LookupElement#getAllLookupStrings()

The following examples show how to use com.intellij.codeInsight.lookup.LookupElement#getAllLookupStrings() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LookupTypedHandler.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static boolean completeTillTypedCharOccurrence(char charTyped, LookupImpl lookup, LookupElement item) {
  PrefixMatcher matcher = lookup.itemMatcher(item);
  final String oldPrefix = matcher.getPrefix() + lookup.getAdditionalPrefix();
  PrefixMatcher expanded = matcher.cloneWithPrefix(oldPrefix + charTyped);
  if (expanded.prefixMatches(item)) {
    for (String s : item.getAllLookupStrings()) {
      if (matcher.prefixMatches(s)) {
        int i = -1;
        while (true) {
          i = s.indexOf(charTyped, i + 1);
          if (i < 0) break;
          final String newPrefix = s.substring(0, i + 1);
          if (expanded.prefixMatches(newPrefix)) {
            lookup.replacePrefix(oldPrefix, newPrefix);
            return true;
          }
        }
      }
    }
  }
  return false;
}
 
Example 2
Source File: PrefixMatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
public boolean prefixMatches(@Nonnull LookupElement element) {
  for (String s : element.getAllLookupStrings()) {
    if (prefixMatches(s)) {
      return true;
    }
  }
  return false;
}
 
Example 3
Source File: PrefixMatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
public boolean isStartMatch(LookupElement element) {
  for (String s : element.getAllLookupStrings()) {
    if (isStartMatch(s)) {
      return true;
    }
  }
  return false;
}
 
Example 4
Source File: RealPrefixMatchingWeigher.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static int getBestMatchingDegree(LookupElement element, PrefixMatcher matcher) {
  int max = Integer.MIN_VALUE;
  for (String lookupString : element.getAllLookupStrings()) {
    max = Math.max(max, matcher.matchingDegree(lookupString));
  }
  return -max;
}
 
Example 5
Source File: CamelHumpMatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean prefixMatchersInternal(final LookupElement element, final boolean itemCaseInsensitive) {
  for (final String name : element.getAllLookupStrings()) {
    if (itemCaseInsensitive && StringUtil.startsWithIgnoreCase(name, myPrefix) || prefixMatches(name)) {
      return true;
    }
    if (itemCaseInsensitive && CodeInsightSettings.ALL != CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE) {
      if (myCaseInsensitiveMatcher.matches(name)) {
        return true;
      }
    }
  }
  return false;
}