diff --git a/src/main/java/io/kusionstack/kcl/action/FormatDirectoryAction.java b/src/main/java/io/kusionstack/kcl/action/FormatDirectoryAction.java deleted file mode 100644 index c8d4cce..0000000 --- a/src/main/java/io/kusionstack/kcl/action/FormatDirectoryAction.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * KusionStack. Copyright (c) 2020-2020 All Rights Reserved. - */ -package io.kusionstack.kcl.action; - -import com.intellij.openapi.actionSystem.ActionUpdateThread; -import io.kusionstack.kcl.util.KCLBinaryUtil; -import io.kusionstack.kcl.util.KCLFmtCommand; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.project.DumbAwareAction; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VfsUtil; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; - -/** - * @author amyxia - * @version FormatDirectoryAction: FormatDirectoryAction.java, v 0.1 2020年12月03日 2:48 下午 amyxia Exp $ - */ -public class FormatDirectoryAction extends DumbAwareAction { - @Override - public void update(@NotNull AnActionEvent e) { - // Using the event, evaluate the context, and enable or disable the action. - // the action button is visible only when the current focused item is a file directory - VirtualFile vf = e.getData(CommonDataKeys.VIRTUAL_FILE); - e.getPresentation().setVisible((vf != null && vf.isDirectory())); - // the action button is enabled only when kcl is installed - e.getPresentation().setEnabled(KCLBinaryUtil.KCLInstalled()); - } - - @Override - public void actionPerformed(@NotNull AnActionEvent e) { - Project project = e.getProject(); - assert project != null; - // save all documents before formatting - FileDocumentManager.getInstance().saveAllDocuments(); - // do kcl fmt - VirtualFile file = e.getRequiredData(CommonDataKeys.VIRTUAL_FILE); - KCLFmtCommand.execute(file, true); - VfsUtil.markDirtyAndRefresh(true, true, true, file); - } - - @Override - public @NotNull ActionUpdateThread getActionUpdateThread(){ - return ActionUpdateThread.BGT; - } -} \ No newline at end of file diff --git a/src/main/java/io/kusionstack/kcl/action/FormatSingleFileAction.java b/src/main/java/io/kusionstack/kcl/action/FormatSingleFileAction.java deleted file mode 100644 index 8b5971a..0000000 --- a/src/main/java/io/kusionstack/kcl/action/FormatSingleFileAction.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * KusionStack. Copyright (c) 2020-2020 All Rights Reserved. - */ -package io.kusionstack.kcl.action; - -import com.intellij.openapi.actionSystem.ActionUpdateThread; -import io.kusionstack.kcl.KCLFileType; -import io.kusionstack.kcl.util.KCLBinaryUtil; -import io.kusionstack.kcl.util.KCLFmtCommand; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VfsUtil; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; - -import com.intellij.openapi.diagnostic.Logger; - -/** - * @author amyxia - * @version FormatSingleFileAction: FormatSingleFileAction.java, v 0.1 2020年11月04日 10:00 下午 amyxia Exp $ - */ -public class FormatSingleFileAction extends AnAction { - @Override - public void update(@NotNull AnActionEvent e) { - // Using the event, evaluate the context, and enable or disable the action. - // the action button is visible only when the current file is a kcl file - VirtualFile vf = e.getData(CommonDataKeys.VIRTUAL_FILE); - e.getPresentation().setVisible(true); - // the action button is enabled only when kcl is installed - e.getPresentation().setEnabled(KCLBinaryUtil.KCLInstalled()); - } - - @Override - public void actionPerformed(@NotNull AnActionEvent event) { - Project project = event.getProject(); - assert project != null; - VirtualFile file = event.getRequiredData(CommonDataKeys.VIRTUAL_FILE); - Document document = FileDocumentManager.getInstance().getDocument(file); - if (document != null) { - FileDocumentManager.getInstance().saveDocument(document); - } else { - FileDocumentManager.getInstance().saveAllDocuments(); - } - // execute kcl --fmt command to get formatted content - KCLFmtCommand.execute(file, false); - VfsUtil.markDirtyAndRefresh(true, true, true, file); - } - - public boolean isKCLFile(VirtualFile virtualFile) { - if (virtualFile != null) { - return (virtualFile.getFileType() instanceof KCLFileType); - } - return false; - } - - @Override - public @NotNull ActionUpdateThread getActionUpdateThread(){ - return ActionUpdateThread.BGT; - } -} \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 1dd4ff8..4f172a4 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -66,10 +66,6 @@ - - - -