Java Code Examples for com.intellij.psi.codeStyle.NameUtil#buildMatcher()

The following examples show how to use com.intellij.psi.codeStyle.NameUtil#buildMatcher() . 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: OptionsTopHitProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public final void consumeTopHits(@NonNls String pattern, Consumer<Object> collector, Project project) {
  if (!pattern.startsWith("#")) return;
  pattern = pattern.substring(1);
  final List<String> parts = StringUtil.split(pattern, " ");

  if (parts.size() == 0) return;

  String id = parts.get(0);
  if (getId().startsWith(id)) {
    pattern = pattern.substring(id.length()).trim().toLowerCase();
    final MinusculeMatcher matcher = NameUtil.buildMatcher("*" + pattern, NameUtil.MatchingCaseSensitivity.NONE);
    for (BooleanOptionDescription option : getOptions(project)) {
      if (matcher.matches(option.getOption())) {
        collector.accept(option);
      }
    }
  }
}
 
Example 2
Source File: CamelHumpMatcher.java    From consulo with Apache License 2.0 6 votes vote down vote up
private MinusculeMatcher createMatcher(final boolean caseSensitive) {
  String prefix = applyMiddleMatching(myPrefix);

  NameUtil.MatcherBuilder builder = NameUtil.buildMatcher(prefix);
  if (caseSensitive) {
    int setting = CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE;
    if (setting == CodeInsightSettings.FIRST_LETTER) {
      builder = builder.withCaseSensitivity(NameUtil.MatchingCaseSensitivity.FIRST_LETTER);
    }
    else if (setting == CodeInsightSettings.ALL) {
      builder = builder.withCaseSensitivity(NameUtil.MatchingCaseSensitivity.ALL);
    }
  }
  if (myTypoTolerant) {
    builder = builder.typoTolerant();
  }
  return builder.build();
}
 
Example 3
Source File: GotoFileItemProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
SuffixMatches(String pattern, int from, @Nonnull ProgressIndicator indicator) {
  patternSuffix = pattern.substring(from);
  matcher = NameUtil.buildMatcher((from > 0 ? " " : "*") + patternSuffix, NameUtil.MatchingCaseSensitivity.NONE);
  this.indicator = indicator;
}
 
Example 4
Source File: DefaultChooseByNameItemProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static MinusculeMatcher buildPatternMatcher(@Nonnull String pattern) {
  return NameUtil.buildMatcher(pattern, NameUtil.MatchingCaseSensitivity.NONE);
}
 
Example 5
Source File: GotoActionItemProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
static Matcher buildMatcher(String pattern) {
  return pattern.contains(" ") ? new WordPrefixMatcher(pattern) : NameUtil.buildMatcher("*" + pattern, NameUtil.MatchingCaseSensitivity.NONE);
}
 
Example 6
Source File: ChooseByNameBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static Matcher buildPatternMatcher(@Nonnull String pattern) {
  return NameUtil.buildMatcher(pattern, NameUtil.MatchingCaseSensitivity.NONE);
}
 
Example 7
Source File: FileTextFieldImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static MinusculeMatcher createMatcher(String prefix) {
  return NameUtil.buildMatcher("*" + prefix, NameUtil.MatchingCaseSensitivity.NONE);
}