Search in sources :

Example 1 with SpecTable

use of com.thoughtworks.gauge.language.psi.SpecTable 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)1 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)1 SpecDetail (com.thoughtworks.gauge.language.psi.SpecDetail)1 SpecTable (com.thoughtworks.gauge.language.psi.SpecTable)1