use of com.goide.quickfix.GoRenameQuickFix in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoReceiverNamesInspection method buildGoVisitor.
@NotNull
@Override
protected GoVisitor buildGoVisitor(@NotNull ProblemsHolder holder, @NotNull LocalInspectionToolSession session) {
return new GoVisitor() {
@Override
public void visitReceiver(@NotNull GoReceiver o) {
if (genericNamesSet.contains(o.getName())) {
PsiElement identifier = o.getIdentifier();
if (identifier == null)
return;
holder.registerProblem(identifier, "Receiver has generic name", new GoRenameQuickFix(o));
}
}
};
}
use of com.goide.quickfix.GoRenameQuickFix in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoReservedWordUsedAsNameInspection method registerProblem.
private static void registerProblem(@NotNull ProblemsHolder holder, @NotNull GoNamedElement element, @NotNull GoNamedElement builtinElement) {
PsiElement identifier = element.getIdentifier();
if (identifier == null)
return;
String elementDescription = ElementDescriptionUtil.getElementDescription(element, UsageViewTypeLocation.INSTANCE);
String builtinElementDescription = ElementDescriptionUtil.getElementDescription(builtinElement, UsageViewTypeLocation.INSTANCE);
String message = StringUtil.capitalize(elementDescription) + " <code>#ref</code> collides with builtin " + builtinElementDescription;
holder.registerProblem(identifier, message, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new GoRenameQuickFix(element));
}
use of com.goide.quickfix.GoRenameQuickFix in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoUnusedImportInspection method checkFile.
@Override
protected void checkFile(@NotNull GoFile file, @NotNull ProblemsHolder problemsHolder) {
MultiMap<String, GoImportSpec> importMap = file.getImportMap();
for (PsiElement importIdentifier : GoImportOptimizer.findRedundantImportIdentifiers(importMap)) {
problemsHolder.registerProblem(importIdentifier, "Redundant alias", ProblemHighlightType.LIKE_UNUSED_SYMBOL, OPTIMIZE_QUICK_FIX);
}
Set<GoImportSpec> duplicatedEntries = GoImportOptimizer.findDuplicatedEntries(importMap);
for (GoImportSpec duplicatedImportSpec : duplicatedEntries) {
problemsHolder.registerProblem(duplicatedImportSpec, "Redeclared import", ProblemHighlightType.GENERIC_ERROR, OPTIMIZE_QUICK_FIX);
}
for (Map.Entry<String, Collection<GoImportSpec>> specs : importMap.entrySet()) {
Iterator<GoImportSpec> imports = specs.getValue().iterator();
GoImportSpec originalImport = imports.next();
if (originalImport.isDot() || originalImport.isForSideEffects()) {
continue;
}
while (imports.hasNext()) {
GoImportSpec redeclaredImport = imports.next();
if (!duplicatedEntries.contains(redeclaredImport)) {
LocalQuickFix[] quickFixes = FindManager.getInstance(redeclaredImport.getProject()).canFindUsages(redeclaredImport) ? new LocalQuickFix[] { new GoRenameQuickFix(redeclaredImport) } : LocalQuickFix.EMPTY_ARRAY;
problemsHolder.registerProblem(redeclaredImport, "Redeclared import", ProblemHighlightType.GENERIC_ERROR, quickFixes);
}
}
}
if (importMap.containsKey(".")) {
if (!problemsHolder.isOnTheFly() || ApplicationManager.getApplication().isUnitTestMode())
resolveAllReferences(file);
}
MultiMap<String, GoImportSpec> unusedImportsMap = GoImportOptimizer.filterUnusedImports(file, importMap);
Set<GoImportSpec> unusedImportSpecs = ContainerUtil.newHashSet(unusedImportsMap.values());
for (PsiElement importEntry : unusedImportSpecs) {
GoImportSpec spec = GoImportOptimizer.getImportSpec(importEntry);
if (spec != null && spec.getImportString().resolve() != null) {
problemsHolder.registerProblem(spec, "Unused import", ProblemHighlightType.GENERIC_ERROR, OPTIMIZE_QUICK_FIX, IMPORT_FOR_SIDE_EFFECTS_QUICK_FIX);
}
}
}
use of com.goide.quickfix.GoRenameQuickFix in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoImportUsedAsNameInspection method registerProblem.
private static void registerProblem(@NotNull ProblemsHolder holder, @NotNull GoNamedElement element) {
PsiElement identifier = element.getIdentifier();
if (identifier != null) {
String elementDescription = ElementDescriptionUtil.getElementDescription(element, UsageViewTypeLocation.INSTANCE);
String message = StringUtil.capitalize(elementDescription) + " <code>#ref</code> collides with imported package name #loc";
holder.registerProblem(identifier, message, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new GoRenameQuickFix(element));
}
}
Aggregations