handler.runExecuteAction(console, true);
}
@Override
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
Editor editor = e.getData(DataKeys.EDITOR);
if (editor == null) {
presentation.setEnabled(false);
return;
}
Project project = editor.getProject();
if (project == null) {
presentation.setEnabled(false);
return;
}
Document document = editor.getDocument();
PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
if (psiFile == null || !(psiFile instanceof HaskellFile)) {
presentation.setEnabled(false);
return;
}
VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile == null || virtualFile instanceof LightVirtualFile) {
presentation.setEnabled(false);
return;
}
String filePath = virtualFile.getPath();
if (filePath == null) {
presentation.setEnabled(false);
return;
}
HaskellConsoleProcessHandler handler = findRunningHaskellConsole(project);
if (handler == null) {
presentation.setEnabled(false);
return;
}
LanguageConsoleImpl console = handler.getLanguageConsole();
if (!(console instanceof HaskellConsole)) {
presentation.setEnabled(false);
return;
}
presentation.setEnabled(true);
}