Search in sources :

Example 31 with GoFile

use of com.goide.psi.GoFile in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoDeleteImportQuickFix method applyFix.

@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
    PsiElement element = PsiTreeUtil.getNonStrictParentOfType(descriptor.getPsiElement(), GoImportSpec.class);
    PsiFile file = element != null ? element.getContainingFile() : null;
    if (!(file instanceof GoFile))
        return;
    WriteCommandAction.runWriteCommandAction(project, () -> ((GoFile) file).deleteImport((GoImportSpec) element));
}
Also used : GoFile(com.goide.psi.GoFile) GoImportSpec(com.goide.psi.GoImportSpec) PsiFile(com.intellij.psi.PsiFile) PsiElement(com.intellij.psi.PsiElement)

Aggregations

GoFile (com.goide.psi.GoFile)31 PsiFile (com.intellij.psi.PsiFile)20 PsiElement (com.intellij.psi.PsiElement)12 Project (com.intellij.openapi.project.Project)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 PsiDirectory (com.intellij.psi.PsiDirectory)8 Module (com.intellij.openapi.module.Module)6 NotNull (org.jetbrains.annotations.NotNull)6 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)4 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)4 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)4 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)4 WorkspaceLanguageSettings (com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings)4 WorkspacePathResolverImpl (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl)4 Nullable (javax.annotation.Nullable)4 Test (org.junit.Test)4 GoPackageClause (com.goide.psi.GoPackageClause)3 Nullable (org.jetbrains.annotations.Nullable)3 GoFunctionDeclaration (com.goide.psi.GoFunctionDeclaration)2 GoFunctionOrMethodDeclaration (com.goide.psi.GoFunctionOrMethodDeclaration)2