use of com.goide.quickfix.GoMultiplePackagesQuickFix in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoMultiplePackagesInspection method checkFile.
@Override
protected void checkFile(@NotNull GoFile file, @NotNull ProblemsHolder problemsHolder) {
if (((ScratchFileType) ScratchFileType.INSTANCE).isMyFileType(file.getVirtualFile()))
return;
GoPackageClause packageClause = file.getPackage();
if (packageClause != null) {
String packageName = file.getPackageName();
if (packageName == null || packageName.equals(GoConstants.DOCUMENTATION))
return;
PsiDirectory dir = file.getContainingDirectory();
Collection<String> packages = GoPackageUtil.getAllPackagesInDirectory(dir, null, true);
packages.remove(GoConstants.DOCUMENTATION);
if (packages.size() > 1) {
Collection<LocalQuickFix> fixes = ContainerUtil.newArrayList();
if (problemsHolder.isOnTheFly()) {
fixes.add(new GoMultiplePackagesQuickFix(packageClause, packageName, packages, true));
} else {
for (String name : packages) {
fixes.add(new GoMultiplePackagesQuickFix(packageClause, name, packages, false));
}
}
problemsHolder.registerProblem(packageClause, "Multiple packages in directory", fixes.toArray(new LocalQuickFix[fixes.size()]));
}
}
}
Aggregations