com.intellij.codeInsight.completion.PrefixMatcher Java Examples
The following examples show how to use
com.intellij.codeInsight.completion.PrefixMatcher.
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 |
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: FunctionProvider.java From idea-php-toolbox with MIT License | 5 votes |
@NotNull @Override public Collection<LookupElement> getLookupElements(@NotNull PhpToolboxCompletionContributorParameter parameter) { return PhpIndex.getInstance(parameter.getProject()) .getAllFunctionNames(PrefixMatcher.ALWAYS_TRUE).stream().map( s -> LookupElementBuilder.create(s).withIcon(PhpIcons.FUNCTION) ) .collect(Collectors.toCollection(HashSet::new)); }
Example #3
Source File: LookupArranger.java From consulo with Apache License 2.0 | 5 votes |
public final void prefixReplaced(Lookup lookup, String newPrefix) { ArrayList<LookupElement> itemCopy = new ArrayList<>(myItems); myItems.clear(); for (LookupElement item : itemCopy) { if (item.isValid()) { PrefixMatcher matcher = itemMatcher(item).cloneWithPrefix(newPrefix); if (matcher.prefixMatches(item)) { item.putUserData(myMatcherKey, matcher); myItems.add(item); } } } prefixChanged(lookup); }
Example #4
Source File: LookupArranger.java From consulo with Apache License 2.0 | 5 votes |
private boolean prefixMatches(LookupElement item) { PrefixMatcher matcher = itemMatcher(item); if (!myAdditionalPrefix.isEmpty()) { matcher = matcher.cloneWithPrefix(matcher.getPrefix() + myAdditionalPrefix); } return matcher.prefixMatches(item); }
Example #5
Source File: LookupArranger.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public PrefixMatcher itemMatcher(@Nonnull LookupElement item) { PrefixMatcher matcher = item.getUserData(myMatcherKey); if (matcher == null) { throw new AssertionError("Item not in lookup: item=" + item + "; lookup items=" + myItems); } return matcher; }
Example #6
Source File: FunctionProvider.java From idea-php-toolbox with MIT License | 5 votes |
@NotNull @Override public Collection<LookupElement> getLookupElements(@NotNull PhpToolboxCompletionContributorParameter parameter) { return PhpIndex.getInstance(parameter.getProject()) .getAllFunctionNames(PrefixMatcher.ALWAYS_TRUE).stream().map( s -> LookupElementBuilder.create(s).withIcon(PhpIcons.FUNCTION) ) .collect(Collectors.toCollection(HashSet::new)); }
Example #7
Source File: CamelHumpMatcher.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public PrefixMatcher cloneWithPrefix(@Nonnull final String prefix) { if (prefix.equals(myPrefix)) { return this; } return new CamelHumpMatcher(prefix, myCaseSensitive, myTypoTolerant); }
Example #8
Source File: RealPrefixMatchingWeigher.java From consulo with Apache License 2.0 | 5 votes |
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 #9
Source File: BetterPrefixMatcher.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull protected BetterPrefixMatcher createCopy(PrefixMatcher original, int degree) { return new BetterPrefixMatcher(original, degree); }
Example #10
Source File: TextFieldWithAutoCompletionListProvider.java From consulo with Apache License 2.0 | 4 votes |
@Nullable public PrefixMatcher createPrefixMatcher(@Nonnull final String prefix) { return new PlainPrefixMatcher(prefix); }
Example #11
Source File: LookupArranger.java From consulo with Apache License 2.0 | 4 votes |
public void registerMatcher(@Nonnull LookupElement item, @Nonnull PrefixMatcher matcher) { item.putUserData(myMatcherKey, matcher); }
Example #12
Source File: BetterPrefixMatcher.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override protected BetterPrefixMatcher createCopy(PrefixMatcher original, int degree) { return new AutoRestarting(myResult, original, degree); }
Example #13
Source File: BetterPrefixMatcher.java From consulo with Apache License 2.0 | 4 votes |
private AutoRestarting(CompletionResultSet result, PrefixMatcher original, int minMatchingDegree) { super(original, minMatchingDegree); myResult = result; }
Example #14
Source File: BetterPrefixMatcher.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public PrefixMatcher cloneWithPrefix(@Nonnull String prefix) { return createCopy(myOriginal.cloneWithPrefix(prefix), myMinMatchingDegree); }
Example #15
Source File: ReplacingConsumerTest.java From litho with Apache License 2.0 | 4 votes |
private static CompletionResult createCompletionResultFor(PsiClass cls) { TestLookupElement lookupElement = new TestLookupElement(cls); PrefixMatcher matcher = Mockito.mock(PrefixMatcher.class); Mockito.when(matcher.prefixMatches(any(LookupElement.class))).thenReturn(true); return CompletionResult.wrap(lookupElement, matcher, Mockito.mock(CompletionSorter.class)); }
Example #16
Source File: BetterPrefixMatcher.java From consulo with Apache License 2.0 | 4 votes |
public BetterPrefixMatcher(PrefixMatcher original, int minMatchingDegree) { super(original.getPrefix()); myOriginal = original; myHumpMatcher = original instanceof CamelHumpMatcher ? (CamelHumpMatcher)original : null; myMinMatchingDegree = minMatchingDegree; }
Example #17
Source File: WeighingContext.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull PrefixMatcher itemMatcher(@Nonnull LookupElement item);
Example #18
Source File: Lookup.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull PrefixMatcher itemMatcher(@Nonnull LookupElement item);
Example #19
Source File: LattePhpUtil.java From intellij-latte with MIT License | 4 votes |
public static Collection<String> getAllExistingClassNames(Project project, PrefixMatcher prefixMatcher) { return getPhpIndex(project).getAllClassNames(prefixMatcher); }
Example #20
Source File: LattePhpUtil.java From intellij-latte with MIT License | 4 votes |
public static Collection<String> getAllExistingFunctionNames(Project project, PrefixMatcher prefixMatcher) { return getPhpIndex(project).getAllFunctionNames(prefixMatcher); }
Example #21
Source File: GaugePrefixMatcher.java From Intellij-Plugin with Apache License 2.0 | 4 votes |
@NotNull @Override public PrefixMatcher cloneWithPrefix(@NotNull String prefix) { return new GaugePrefixMatcher(prefix); }
Example #22
Source File: ReplacingConsumerTest.java From litho with Apache License 2.0 | 4 votes |
@Override public CompletionResultSet withPrefixMatcher(PrefixMatcher matcher) { return null; }
Example #23
Source File: ReplacingConsumerTest.java From litho with Apache License 2.0 | 4 votes |
TestCompletionResultSet() { super( Mockito.mock(PrefixMatcher.class), Mockito.mock(Consumer.class), Mockito.mock(CompletionContributor.class)); }