use of com.goide.codeInsight.imports.GoGetPackageFix in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoImportReference method getQuickFixes.
@Override
public LocalQuickFix[] getQuickFixes() {
if (GoPackageUtil.isBuiltinPackage(resolve())) {
return new LocalQuickFix[] { new GoDeleteImportQuickFix() };
}
List<LocalQuickFix> result = ContainerUtil.newArrayList();
FileReferenceSet fileReferenceSet = getFileReferenceSet();
if (fileReferenceSet instanceof GoImportReferenceSet && !((GoImportReferenceSet) fileReferenceSet).isRelativeImport() && !fileReferenceSet.isAbsolutePathReference()) {
result.add(new GoGetPackageFix(fileReferenceSet.getPathString()));
}
String fileNameToCreate = getFileNameToCreate();
for (PsiFileSystemItem context : getContexts()) {
if (context instanceof PsiDirectory) {
try {
((PsiDirectory) context).checkCreateSubdirectory(fileNameToCreate);
String targetPath = context.getVirtualFile().getPath();
result.add(new CreateFileFix(true, fileNameToCreate, (PsiDirectory) context) {
@NotNull
@Override
public String getText() {
return "Create Directory " + fileNameToCreate + " at " + targetPath;
}
});
} catch (IncorrectOperationException ignore) {
}
}
}
return result.toArray(new LocalQuickFix[result.size()]);
}
Aggregations