Search in sources :

Example 6 with CucumberStepReference

use of org.jetbrains.plugins.cucumber.steps.reference.CucumberStepReference in project intellij-plugins by JetBrains.

the class GherkinAnnotatorVisitor method visitStep.

@Override
public void visitStep(GherkinStep step) {
    final PsiReference[] references = step.getReferences();
    if (references.length != 1 || !(references[0] instanceof CucumberStepReference))
        return;
    CucumberStepReference reference = (CucumberStepReference) references[0];
    final AbstractStepDefinition definition = reference.resolveToDefinition();
    if (definition != null) {
        final List<TextRange> parameterRanges = GherkinPsiUtil.buildParameterRanges(step, definition, reference.getRangeInElement().getStartOffset());
        if (parameterRanges == null)
            return;
        for (TextRange range : parameterRanges) {
            if (range.getLength() > 0) {
                highlight(step, range, GherkinHighlighter.REGEXP_PARAMETER);
            }
        }
        highlightOutlineParams(step, reference);
    }
}
Also used : CucumberStepReference(org.jetbrains.plugins.cucumber.steps.reference.CucumberStepReference) AbstractStepDefinition(org.jetbrains.plugins.cucumber.steps.AbstractStepDefinition) PsiReference(com.intellij.psi.PsiReference) TextRange(com.intellij.openapi.util.TextRange)

Aggregations

CucumberStepReference (org.jetbrains.plugins.cucumber.steps.reference.CucumberStepReference)6 AbstractStepDefinition (org.jetbrains.plugins.cucumber.steps.AbstractStepDefinition)5 PsiElement (com.intellij.psi.PsiElement)4 PsiReference (com.intellij.psi.PsiReference)4 GherkinStep (org.jetbrains.plugins.cucumber.psi.GherkinStep)4 GherkinStepsHolder (org.jetbrains.plugins.cucumber.psi.GherkinStepsHolder)3 TextRange (com.intellij.openapi.util.TextRange)2 NotNull (org.jetbrains.annotations.NotNull)2 ASTNode (com.intellij.lang.ASTNode)1 PsiFile (com.intellij.psi.PsiFile)1 ResolveResult (com.intellij.psi.ResolveResult)1 UsageInfo (com.intellij.usageView.UsageInfo)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Pattern (java.util.regex.Pattern)1 GherkinElementVisitor (org.jetbrains.plugins.cucumber.psi.GherkinElementVisitor)1 GherkinFeature (org.jetbrains.plugins.cucumber.psi.GherkinFeature)1 GherkinFile (org.jetbrains.plugins.cucumber.psi.GherkinFile)1