use of org.jetbrains.plugins.cucumber.psi.GherkinElementVisitor in project intellij-plugins by JetBrains.
the class CucumberExamplesColonInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new GherkinElementVisitor() {
@Override
public void visitExamplesBlock(GherkinExamplesBlockImpl block) {
final PsiElement examples = block.getFirstChild();
assert examples != null;
final PsiElement next = examples.getNextSibling();
final String text = next != null ? next.getText() : null;
if (text == null || !text.contains(":")) {
holder.registerProblem(examples, new TextRange(0, examples.getTextRange().getEndOffset() - examples.getTextOffset()), CucumberBundle.message("inspection.missed.colon.example.name"), new CucumberAddExamplesColonFix());
}
}
};
}
use of org.jetbrains.plugins.cucumber.psi.GherkinElementVisitor in project intellij-plugins by JetBrains.
the class CucumberMissedExamplesInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
return new GherkinElementVisitor() {
@Override
public void visitScenarioOutline(GherkinScenarioOutline outline) {
super.visitScenarioOutline(outline);
final GherkinExamplesBlockImpl block = PsiTreeUtil.getChildOfType(outline, GherkinExamplesBlockImpl.class);
if (block == null) {
ASTNode[] keyword = outline.getNode().getChildren(GherkinTokenTypes.KEYWORDS);
if (keyword.length > 0) {
holder.registerProblem(outline, keyword[0].getTextRange().shiftRight(-outline.getTextOffset()), CucumberBundle.message("inspection.missed.example.msg.name"), new CucumberCreateExamplesSectionFix());
}
}
}
};
}
use of org.jetbrains.plugins.cucumber.psi.GherkinElementVisitor 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);
}
}
}
};
}
Aggregations