Search in sources :

Example 1 with SpecStepImpl

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

the class ReferenceSearchHelperTest method testShouldFindReferencesIfGaugeModule.

@Test
public void testShouldFindReferencesIfGaugeModule() throws Exception {
    SpecStepImpl element = mock(SpecStepImpl.class);
    when(element.getProject()).thenReturn(project);
    ReferencesSearch.SearchParameters searchParameters = new ReferencesSearch.SearchParameters(element, scope, true);
    when(moduleHelper.isGaugeModule(element)).thenReturn(true);
    when(scope.getDisplayName()).thenReturn("Other Scope");
    ReferenceSearchHelper referenceSearchHelper = new ReferenceSearchHelper(moduleHelper);
    referenceSearchHelper.shouldFindReferences(searchParameters, searchParameters.getElementToSearch());
    verify(scope, times(1)).getDisplayName();
}
Also used : SpecStepImpl(com.thoughtworks.gauge.language.psi.impl.SpecStepImpl) ReferencesSearch(com.intellij.psi.search.searches.ReferencesSearch) Test(org.junit.Test)

Example 2 with SpecStepImpl

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

the class ReferenceSearchHelperTest method testShouldNotFindReferencesIfNotGaugeModule.

@Test
public void testShouldNotFindReferencesIfNotGaugeModule() throws Exception {
    SpecStepImpl element = mock(SpecStepImpl.class);
    when(element.getProject()).thenReturn(project);
    ReferencesSearch.SearchParameters searchParameters = new ReferencesSearch.SearchParameters(element, scope, true);
    when(moduleHelper.isGaugeModule(element)).thenReturn(false);
    ReferenceSearchHelper referenceSearchHelper = new ReferenceSearchHelper(moduleHelper);
    boolean shouldFindReferences = referenceSearchHelper.shouldFindReferences(searchParameters, searchParameters.getElementToSearch());
    assertFalse("Should find reference for non Gauge Module(Expected: false, Actual: true)", shouldFindReferences);
    verify(scope, never()).getDisplayName();
}
Also used : SpecStepImpl(com.thoughtworks.gauge.language.psi.impl.SpecStepImpl) ReferencesSearch(com.intellij.psi.search.searches.ReferencesSearch) Test(org.junit.Test)

Example 3 with SpecStepImpl

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

the class ReferenceSearchHelperTest method testShouldFindReferencesOfGaugeElement.

@Test
public void testShouldFindReferencesOfGaugeElement() throws Exception {
    SpecStepImpl element = mock(SpecStepImpl.class);
    when(element.getProject()).thenReturn(project);
    ReferencesSearch.SearchParameters searchParameters = new ReferencesSearch.SearchParameters(element, GlobalSearchScope.allScope(project), true);
    when(moduleHelper.isGaugeModule(element)).thenReturn(true);
    boolean shouldFindReferences = new ReferenceSearchHelper(moduleHelper).shouldFindReferences(searchParameters, searchParameters.getElementToSearch());
    assertTrue("Should find reference for SpecStep(Expected: true, Actual: false)", shouldFindReferences);
}
Also used : SpecStepImpl(com.thoughtworks.gauge.language.psi.impl.SpecStepImpl) ReferencesSearch(com.intellij.psi.search.searches.ReferencesSearch) Test(org.junit.Test)

Example 4 with SpecStepImpl

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

the class ConceptReference method resolve.

@Nullable
@Override
public PsiElement resolve() {
    SpecStepImpl step = new SpecStepImpl(this.myElement.getNode());
    step.setConcept(true);
    return StepUtil.findStepImpl(step, moduleForPsiElement(this.myElement));
}
Also used : SpecStepImpl(com.thoughtworks.gauge.language.psi.impl.SpecStepImpl) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with SpecStepImpl

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

the class SpecStepsBuilder method build.

public List<PsiElement> build() {
    List<PsiElement> specSteps = getPsiElements(SpecStepImpl.class);
    Integer count = 0;
    for (PsiElement element : specSteps) {
        SpecStepImpl specStep = (SpecStepImpl) element;
        if (specStep.getInlineTable() != null && TextToTableMap.get(specStep.getInlineTable().getText().trim()) == null) {
            tableMap.put("table" + (++count).toString(), specStep.getInlineTable().getText().trim());
            TextToTableMap.put(specStep.getInlineTable().getText().trim(), "table" + (count).toString());
        }
    }
    return specSteps;
}
Also used : SpecStepImpl(com.thoughtworks.gauge.language.psi.impl.SpecStepImpl) PsiElement(com.intellij.psi.PsiElement)

Aggregations

SpecStepImpl (com.thoughtworks.gauge.language.psi.impl.SpecStepImpl)9 Test (org.junit.Test)7 ReferencesSearch (com.intellij.psi.search.searches.ReferencesSearch)4 Annotation (com.intellij.lang.annotation.Annotation)1 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)1 Module (com.intellij.openapi.module.Module)1 TextRange (com.intellij.openapi.util.TextRange)1 PsiElement (com.intellij.psi.PsiElement)1 StepValue (com.thoughtworks.gauge.StepValue)1 Nullable (org.jetbrains.annotations.Nullable)1