use of com.goide.quickfix.GoRenameToBlankQuickFix in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoUnusedFunctionInspection method buildGoVisitor.
@NotNull
@Override
protected GoVisitor buildGoVisitor(@NotNull ProblemsHolder holder, @NotNull LocalInspectionToolSession session) {
return new GoVisitor() {
@Override
public void visitFunctionDeclaration(@NotNull GoFunctionDeclaration o) {
if (o.isBlank())
return;
GoFile file = o.getContainingFile();
String name = o.getName();
if (!canRun(name))
return;
if (GoConstants.MAIN.equals(file.getPackageName()) && GoConstants.MAIN.equals(name))
return;
if (GoConstants.INIT.equals(name))
return;
if (GoTestFinder.isTestFile(file) && GoTestFunctionType.fromName(name) != null)
return;
if (ReferencesSearch.search(o, o.getUseScope()).findFirst() == null) {
PsiElement id = o.getIdentifier();
TextRange range = TextRange.from(id.getStartOffsetInParent(), id.getTextLength());
holder.registerProblem(o, "Unused function <code>#ref</code> #loc", ProblemHighlightType.LIKE_UNUSED_SYMBOL, range, new GoDeleteQuickFix("Delete function", GoFunctionDeclaration.class), new GoRenameToBlankQuickFix(o));
}
}
};
}
use of com.goide.quickfix.GoRenameToBlankQuickFix 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));
}
}
};
}
Aggregations