Search in sources :

Example 1 with SpecDetail

use of com.thoughtworks.gauge.language.psi.SpecDetail in project Intellij-Plugin by getgauge.

the class StaticArgCompletionProvider method addCompletions.

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

Example 2 with SpecDetail

use of com.thoughtworks.gauge.language.psi.SpecDetail 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)

Aggregations

PlainPrefixMatcher (com.intellij.codeInsight.completion.PlainPrefixMatcher)2 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)2 SpecDetail (com.thoughtworks.gauge.language.psi.SpecDetail)2 PsiFile (com.intellij.psi.PsiFile)1 SpecStep (com.thoughtworks.gauge.language.psi.SpecStep)1 SpecTable (com.thoughtworks.gauge.language.psi.SpecTable)1 ArrayList (java.util.ArrayList)1