@Override
public void update(AnActionEvent e) {
Editor editor = PlatformDataKeys.EDITOR.getData(e.getDataContext());
PsiFile psiFile = LangDataKeys.PSI_FILE.getData(e.getDataContext());
Language language = psiFile == null ? null : psiFile.getLanguage();
LivePreviewLanguage livePreviewLanguage = language instanceof LivePreviewLanguage? (LivePreviewLanguage)language : null;
Editor grammarEditor = livePreviewLanguage == null? null : getGrammarEditor(psiFile.getProject(), livePreviewLanguage);
boolean enabled = editor != null && grammarEditor != null;
if (enabled) {
boolean running = editor.getUserData(GRAMMAR_UPDATE_RUNNING) != null;