Search in sources :

Example 1 with GoDeleteConstDefinitionQuickFix

use of com.goide.quickfix.GoDeleteConstDefinitionQuickFix in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoUnusedConstInspection method buildGoVisitor.

@NotNull
@Override
protected GoVisitor buildGoVisitor(@NotNull ProblemsHolder holder, @NotNull LocalInspectionToolSession session) {
    return new GoVisitor() {

        @Override
        public void visitConstDefinition(@NotNull GoConstDefinition o) {
            if (o.isBlank())
                return;
            if (ReferencesSearch.search(o, o.getUseScope()).findFirst() == null) {
                String constName = o.getName();
                holder.registerProblem(o, "Unused constant <code>#ref</code> #loc", ProblemHighlightType.LIKE_UNUSED_SYMBOL, new GoDeleteConstDefinitionQuickFix(constName));
            }
        }
    };
}
Also used : GoDeleteConstDefinitionQuickFix(com.goide.quickfix.GoDeleteConstDefinitionQuickFix) GoConstDefinition(com.goide.psi.GoConstDefinition) NotNull(org.jetbrains.annotations.NotNull) GoVisitor(com.goide.psi.GoVisitor) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

GoConstDefinition (com.goide.psi.GoConstDefinition)1 GoVisitor (com.goide.psi.GoVisitor)1 GoDeleteConstDefinitionQuickFix (com.goide.quickfix.GoDeleteConstDefinitionQuickFix)1 NotNull (org.jetbrains.annotations.NotNull)1