Search in sources :

Example 1 with SpecStep

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

the class ImplUsageProviderTest method TestIsImplicitUsageForMethodParameter.

@Test
public void TestIsImplicitUsageForMethodParameter() throws Exception {
    ModuleHelper helper = mock(ModuleHelper.class);
    SpecStep element = mock(SpecStepImpl.class);
    PsiParameter parameter = mock(PsiParameterImpl.class);
    when(parameter.getDeclarationScope()).thenReturn(element);
    when(helper.isGaugeModule(parameter)).thenReturn(true);
    boolean isUsed = new ImplUsageProvider(null, helper).isImplicitUsage(parameter);
    assertTrue(isUsed);
}
Also used : ModuleHelper(com.thoughtworks.gauge.helper.ModuleHelper) SpecStep(com.thoughtworks.gauge.language.psi.SpecStep) Test(org.junit.Test)

Example 2 with SpecStep

use of com.thoughtworks.gauge.language.psi.SpecStep 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 3 with SpecStep

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

the class StaticArgCompletionProvider method getArgsFromSteps.

private Set<String> getArgsFromSteps(List<SpecStep> steps) {
    Set<String> staticArgs = new HashSet<>();
    for (SpecStep step : steps) {
        List<SpecStaticArg> args = step.getStaticArgList();
        args.stream().filter(arg -> arg.getText() != null).forEach((arg) -> staticArgs.add(arg.getText()));
    }
    return staticArgs;
}
Also used : ProcessingContext(com.intellij.util.ProcessingContext) StepCompletionContributor.getPrefix(com.thoughtworks.gauge.autocomplete.StepCompletionContributor.getPrefix) PlainPrefixMatcher(com.intellij.codeInsight.completion.PlainPrefixMatcher) SpecScenario(com.thoughtworks.gauge.language.psi.SpecScenario) LookupElementBuilder(com.intellij.codeInsight.lookup.LookupElementBuilder) SpecDetail(com.thoughtworks.gauge.language.psi.SpecDetail) CompletionParameters(com.intellij.codeInsight.completion.CompletionParameters) Set(java.util.Set) SpecStep(com.thoughtworks.gauge.language.psi.SpecStep) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) CompletionResultSet(com.intellij.codeInsight.completion.CompletionResultSet) PsiTreeUtil(com.intellij.psi.util.PsiTreeUtil) List(java.util.List) CompletionProvider(com.intellij.codeInsight.completion.CompletionProvider) PsiFile(com.intellij.psi.PsiFile) SpecStaticArg(com.thoughtworks.gauge.language.psi.SpecStaticArg) NotNull(org.jetbrains.annotations.NotNull) SpecStep(com.thoughtworks.gauge.language.psi.SpecStep) SpecStaticArg(com.thoughtworks.gauge.language.psi.SpecStaticArg) HashSet(java.util.HashSet)

Example 4 with SpecStep

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

the class SpecInspectionProviderTest method testGetElementReturnsStep.

@Test
public void testGetElementReturnsStep() throws Exception {
    SpecStep step = mock(SpecStep.class);
    PsiElement element = new SpecInspectionProvider().getElement(step);
    assertEquals(step, element);
}
Also used : SpecStep(com.thoughtworks.gauge.language.psi.SpecStep) PsiElement(com.intellij.psi.PsiElement) LeafPsiElement(com.intellij.psi.impl.source.tree.LeafPsiElement) Test(org.junit.Test)

Aggregations

SpecStep (com.thoughtworks.gauge.language.psi.SpecStep)4 PlainPrefixMatcher (com.intellij.codeInsight.completion.PlainPrefixMatcher)2 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)2 PsiFile (com.intellij.psi.PsiFile)2 SpecDetail (com.thoughtworks.gauge.language.psi.SpecDetail)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 CompletionParameters (com.intellij.codeInsight.completion.CompletionParameters)1 CompletionProvider (com.intellij.codeInsight.completion.CompletionProvider)1 CompletionResultSet (com.intellij.codeInsight.completion.CompletionResultSet)1 PsiElement (com.intellij.psi.PsiElement)1 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)1 PsiTreeUtil (com.intellij.psi.util.PsiTreeUtil)1 ProcessingContext (com.intellij.util.ProcessingContext)1 StepCompletionContributor.getPrefix (com.thoughtworks.gauge.autocomplete.StepCompletionContributor.getPrefix)1 ModuleHelper (com.thoughtworks.gauge.helper.ModuleHelper)1 SpecScenario (com.thoughtworks.gauge.language.psi.SpecScenario)1 SpecStaticArg (com.thoughtworks.gauge.language.psi.SpecStaticArg)1 HashSet (java.util.HashSet)1 List (java.util.List)1