use of org.jetbrains.plugins.cucumber.steps.AbstractStepDefinition in project intellij-plugins by JetBrains.
the class CucumberStepInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
return new GherkinElementVisitor() {
@Override
public void visitStep(GherkinStep step) {
super.visitStep(step);
final PsiElement parent = step.getParent();
if (parent instanceof GherkinStepsHolder) {
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) {
CucumberCreateStepFix createStepFix = null;
CucumberCreateAllStepsFix createAllStepsFix = null;
if (CucumberStepsIndex.getInstance(step.getProject()).getExtensionCount() > 0) {
createStepFix = new CucumberCreateStepFix();
createAllStepsFix = new CucumberCreateAllStepsFix();
}
holder.registerProblem(reference.getElement(), reference.getRangeInElement(), CucumberBundle.message("cucumber.inspection.undefined.step.msg.name") + " #loc #ref", createStepFix, createAllStepsFix);
}
}
}
};
}
use of org.jetbrains.plugins.cucumber.steps.AbstractStepDefinition 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);
}
}
Aggregations