Search in sources :

Example 1 with GoLabelDefinition

use of com.goide.psi.GoLabelDefinition 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));
            }
        }
    };
}
Also used : GoLabelDefinition(com.goide.psi.GoLabelDefinition) GoRenameToBlankQuickFix(com.goide.quickfix.GoRenameToBlankQuickFix) NotNull(org.jetbrains.annotations.NotNull) GoVisitor(com.goide.psi.GoVisitor) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

GoLabelDefinition (com.goide.psi.GoLabelDefinition)1 GoVisitor (com.goide.psi.GoVisitor)1 GoRenameToBlankQuickFix (com.goide.quickfix.GoRenameToBlankQuickFix)1 NotNull (org.jetbrains.annotations.NotNull)1