use of com.goide.psi.GoVisitor in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoUnusedLabelInspection method buildGoVisitor.
@NotNull
@Override
protected GoVisitor buildGoVisitor(@NotNull ProblemsHolder holder, @NotNull LocalInspectionToolSession session) {
return new GoVisitor() {
@Override
public void visitLabelDefinition(@NotNull GoLabelDefinition o) {
super.visitLabelDefinition(o);
if (o.isBlank())
return;
if (ReferencesSearch.search(o, o.getUseScope()).findFirst() == null) {
String name = o.getName();
holder.registerProblem(o, "Unused label <code>#ref</code> #loc", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new GoRenameToBlankQuickFix(o), new GoDeleteLabelStatementQuickFix(name));
}
}
};
}
use of com.goide.psi.GoVisitor in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoRangeIterationOnIllegalTypeInspection method buildGoVisitor.
@NotNull
@Override
protected GoVisitor buildGoVisitor(@NotNull ProblemsHolder holder, @NotNull LocalInspectionToolSession session) {
return new GoVisitor() {
@Override
public void visitRangeClause(@NotNull GoRangeClause o) {
super.visitRangeClause(o);
GoExpression expression = o.getRangeExpression();
GoType type = expression != null ? expression.getGoType(null) : null;
if (type != null && !GoTypeUtil.isIterable(type)) {
holder.registerProblem(expression, "Cannot range over data (type " + GoPsiImplUtil.getText(type) + ")", ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
}
};
}
Aggregations