Search in sources :

Example 6 with PlainPrefixMatcher

use of com.intellij.codeInsight.completion.PlainPrefixMatcher in project Intellij-Plugin by getgauge.

the class DynamicArgCompletionProvider method addCompletions.

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);
        }
    }
}
Also used : SpecDetail(com.thoughtworks.gauge.language.psi.SpecDetail) SpecTable(com.thoughtworks.gauge.language.psi.SpecTable) PlainPrefixMatcher(com.intellij.codeInsight.completion.PlainPrefixMatcher) LookupElementBuilder(com.intellij.codeInsight.lookup.LookupElementBuilder)

Example 7 with PlainPrefixMatcher

use of com.intellij.codeInsight.completion.PlainPrefixMatcher in project intellij-community by JetBrains.

the class ListTemplatesHandler method showTemplatesLookup.

private static void showTemplatesLookup(final Project project, final Editor editor, final PsiFile file, @NotNull Map<TemplateImpl, String> matchingTemplates, @NotNull MultiMap<String, CustomLiveTemplateLookupElement> customTemplatesLookupElements) {
    LookupImpl lookup = (LookupImpl) LookupManager.getInstance(project).createLookup(editor, LookupElement.EMPTY_ARRAY, "", new TemplatesArranger());
    for (Map.Entry<TemplateImpl, String> entry : matchingTemplates.entrySet()) {
        TemplateImpl template = entry.getKey();
        lookup.addItem(createTemplateElement(template), new PlainPrefixMatcher(StringUtil.notNullize(entry.getValue())));
    }
    for (Map.Entry<String, Collection<CustomLiveTemplateLookupElement>> entry : customTemplatesLookupElements.entrySet()) {
        for (CustomLiveTemplateLookupElement lookupElement : entry.getValue()) {
            lookup.addItem(lookupElement, new PlainPrefixMatcher(entry.getKey()));
        }
    }
    showLookup(lookup, file);
}
Also used : LookupImpl(com.intellij.codeInsight.lookup.impl.LookupImpl) PlainPrefixMatcher(com.intellij.codeInsight.completion.PlainPrefixMatcher) MultiMap(com.intellij.util.containers.MultiMap)

Example 8 with PlainPrefixMatcher

use of com.intellij.codeInsight.completion.PlainPrefixMatcher in project Intellij-Plugin by getgauge.

the class ConceptStaticArgCompletionProvider method addCompletions.

@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));
        }
    }
}
Also used : ConceptStaticArg(com.thoughtworks.gauge.language.psi.ConceptStaticArg) PlainPrefixMatcher(com.intellij.codeInsight.completion.PlainPrefixMatcher)

Example 9 with PlainPrefixMatcher

use of com.intellij.codeInsight.completion.PlainPrefixMatcher in project Intellij-Plugin by getgauge.

the class ConceptDynamicArgCompletionProvider method addCompletions.

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);
    }
}
Also used : ConceptDynamicArg(com.thoughtworks.gauge.language.psi.ConceptDynamicArg) PlainPrefixMatcher(com.intellij.codeInsight.completion.PlainPrefixMatcher) LookupElementBuilder(com.intellij.codeInsight.lookup.LookupElementBuilder)

Aggregations

PlainPrefixMatcher (com.intellij.codeInsight.completion.PlainPrefixMatcher)9 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)4 LookupImpl (com.intellij.codeInsight.lookup.impl.LookupImpl)2 PsiElement (com.intellij.psi.PsiElement)2 PsiFile (com.intellij.psi.PsiFile)2 SpecDetail (com.thoughtworks.gauge.language.psi.SpecDetail)2 CompletionResultSet (com.intellij.codeInsight.completion.CompletionResultSet)1 Document (com.intellij.openapi.editor.Document)1 ComboBox (com.intellij.openapi.ui.ComboBox)1 MultiMap (com.intellij.util.containers.MultiMap)1 PsiPerlMethod (com.perl5.lang.perl.psi.PsiPerlMethod)1 ConceptDynamicArg (com.thoughtworks.gauge.language.psi.ConceptDynamicArg)1 ConceptStaticArg (com.thoughtworks.gauge.language.psi.ConceptStaticArg)1 SpecStep (com.thoughtworks.gauge.language.psi.SpecStep)1 SpecTable (com.thoughtworks.gauge.language.psi.SpecTable)1 ArrayList (java.util.ArrayList)1