com.intellij.codeInsight.completion.PlainPrefixMatcher Java Examples

The following examples show how to use com.intellij.codeInsight.completion.PlainPrefixMatcher. 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: StaticArgCompletionProvider.java    From Intellij-Plugin with Apache License 2.0 6 votes vote down vote up
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) {
    String prefix = getPrefix(parameters);
    resultSet = resultSet.withPrefixMatcher(new PlainPrefixMatcher(prefix));
    PsiFile specFile = parameters.getOriginalFile();
    SpecDetail specDetail = PsiTreeUtil.getChildOfType(specFile, SpecDetail.class);
    List<SpecStep> stepsInFile = new ArrayList<>();
    addContextSteps(specDetail, stepsInFile);
    addStepsInScenarios(specFile, stepsInFile);

    Set<String> staticArgs = getArgsFromSteps(stepsInFile);
    for (String arg : staticArgs) {
        if (arg != null) {
            LookupElementBuilder item = LookupElementBuilder.create(arg);
            resultSet.addElement(item);
        }
    }
}
 
Example #2
Source File: YamlPropertyPlaceholdersSmartCompletion.java    From camel-idea-plugin with Apache License 2.0 5 votes vote down vote up
private void buildResultSet(CompletionResultSet resultSet, VirtualFile virtualFile, String keyStr, String value) {
    if (!isIgnored(keyStr)) {
        LookupElementBuilder builder = LookupElementBuilder.create(keyStr + "}}")
            .appendTailText(value, true)
            .withTypeText("[" + virtualFile.getPresentableName() + "]", true)
            .withPresentableText(keyStr + " = ");
        resultSet.withPrefixMatcher(new PlainPrefixMatcher("")).addElement(builder);
    }
}
 
Example #3
Source File: PropertiesPropertyPlaceholdersSmartCompletion.java    From camel-idea-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void buildResultSet(CompletionResultSet resultSet, VirtualFile virtualFile) {
    getProperties(virtualFile).forEach((key, value) -> {
        String keyStr = (String) key;
        if (!isIgnored(keyStr)) {
            LookupElementBuilder builder = LookupElementBuilder.create(keyStr + "}}")
                    .appendTailText(String.valueOf(value), true)
                    .withTypeText("[" + virtualFile.getPresentableName() + "]", true)
                    .withPresentableText(keyStr + " = ");
            resultSet.withPrefixMatcher(new PlainPrefixMatcher("")).addElement(builder);
        }
    });
}
 
Example #4
Source File: DynamicArgCompletionProvider.java    From Intellij-Plugin with Apache License 2.0 5 votes vote down vote up
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) {
    String prefix = getPrefix(parameters);
    resultSet = resultSet.withPrefixMatcher(new PlainPrefixMatcher(prefix));
    SpecDetail specDetail = PsiTreeUtil.getChildOfType(parameters.getOriginalFile(), SpecDetail.class);
    if (specDetail == null)
        return;
    SpecTable table = specDetail.getDataTable();
    if (table != null) {
        List<String> headers = table.getTableHeader().getHeaders();
        for (String header : headers) {
            LookupElementBuilder item = LookupElementBuilder.create(header);
            resultSet.addElement(item);
        }
    }
}
 
Example #5
Source File: ConceptStaticArgCompletionProvider.java    From Intellij-Plugin with Apache License 2.0 5 votes vote down vote up
@Override
protected void addCompletions(CompletionParameters parameters, ProcessingContext processingContext, CompletionResultSet resultSet) {
    String prefix = getPrefix(parameters);
    resultSet = resultSet.withPrefixMatcher(new PlainPrefixMatcher(prefix));
    Collection<ConceptStaticArg> staticArgs = PsiTreeUtil.collectElementsOfType(parameters.getOriginalFile(), ConceptStaticArg.class);
    for (ConceptStaticArg arg : staticArgs) {
        if (arg != null) {
            String text = arg.getText().replaceFirst("\"", "");
            String textWithoutQuotes = text.substring(0, text.length() - 1);
            if (!textWithoutQuotes.equals(""))
                resultSet.addElement(LookupElementBuilder.create(textWithoutQuotes));
        }
    }
}
 
Example #6
Source File: ConceptDynamicArgCompletionProvider.java    From Intellij-Plugin with Apache License 2.0 5 votes vote down vote up
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) {
    String prefix = getPrefix(parameters);
    resultSet = resultSet.withPrefixMatcher(new PlainPrefixMatcher(prefix));
    Collection<ConceptDynamicArg> args = PsiTreeUtil.collectElementsOfType(parameters.getOriginalFile(), ConceptDynamicArg.class);
    for (ConceptDynamicArg arg : args) {
        LookupElementBuilder item = LookupElementBuilder.create(arg.getText().replaceAll("<|>", ""));
        resultSet.addElement(item);
    }
}
 
Example #7
Source File: ListTemplatesHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void showTemplatesLookup(final Project project, final Editor editor, Map<TemplateImpl, String> template2Argument) {
  final LookupImpl lookup = (LookupImpl)LookupManager.getInstance(project).createLookup(editor, LookupElement.EMPTY_ARRAY, "",
                                                                                        new LookupArranger.DefaultArranger());
  for (TemplateImpl template : template2Argument.keySet()) {
    String prefix = computePrefix(template, template2Argument.get(template));
    lookup.addItem(createTemplateElement(template), new PlainPrefixMatcher(prefix));
  }

  showLookup(lookup, template2Argument);
}
 
Example #8
Source File: TextFieldWithAutoCompletionListProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
public PrefixMatcher createPrefixMatcher(@Nonnull final String prefix) {
  return new PlainPrefixMatcher(prefix);
}