Skip to content

Commit

Permalink
fix: Don't run actions in ActionUpdateThread.OLD_EDT (fixes #696)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjansen committed Sep 11, 2024
1 parent 5eb7906 commit 7e47e4d
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.antlr.intellij.plugin.actions;

import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.diagnostic.Logger;
Expand All @@ -8,6 +9,7 @@
import com.intellij.openapi.vfs.VirtualFile;
import org.antlr.intellij.plugin.configdialogs.ConfigANTLRPerGrammar;
import org.antlr.v4.Tool;
import org.jetbrains.annotations.NotNull;

public class ConfigureANTLRAction extends AnAction implements DumbAware {
public static final Logger LOG = Logger.getInstance("ConfigureANTLRAction");
Expand All @@ -17,6 +19,11 @@ public void update(AnActionEvent e) {
MyActionUtils.selectedFileIsGrammar(e);
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}

@Override
public void actionPerformed(AnActionEvent e) {
if ( e.getProject()==null ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public void update(@NotNull AnActionEvent e) {
presentation.setEnabled(true);
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
PsiElement el = MyActionUtils.getSelectedPsiElement(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.antlr.intellij.plugin.actions;

import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.LangDataKeys;
Expand Down Expand Up @@ -27,6 +28,7 @@
import org.antlr.v4.runtime.tree.pattern.ParseTreeMatch;
import org.antlr.v4.runtime.tree.pattern.ParseTreePattern;
import org.antlr.v4.runtime.tree.xpath.XPath;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -54,6 +56,11 @@ public void update(AnActionEvent e) {
}
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}

@Override
public void actionPerformed(AnActionEvent e) {
LOG.info("actionPerformed GenerateLexerRulesForLiteralsAction");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
Expand All @@ -17,6 +18,7 @@
import com.intellij.psi.PsiDocumentManager;
import org.antlr.intellij.plugin.configdialogs.ANTLRv4GrammarPropertiesStore;
import org.antlr.intellij.plugin.parsing.RunANTLROnGrammarFile;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.util.HashSet;
Expand All @@ -33,6 +35,11 @@ public void update(AnActionEvent e) {
MyActionUtils.selectedFileIsGrammar(e);
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}

@Override
public void actionPerformed(final AnActionEvent e) {
Project project = e.getData(PlatformDataKeys.PROJECT);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.antlr.intellij.plugin.actions;

import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.LangDataKeys;
Expand All @@ -22,6 +23,7 @@
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.TerminalNode;
import org.antlr.v4.runtime.tree.Trees;
import org.jetbrains.annotations.NotNull;

import java.util.List;

Expand All @@ -31,6 +33,11 @@ public void update(AnActionEvent e) {
MyActionUtils.showOnlyIfSelectionIsRule(e, "Inline and Remove Rule %s");
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}

@Override
public void actionPerformed(AnActionEvent e) {
PsiElement el = MyActionUtils.getSelectedPsiElement(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.antlr.intellij.plugin.actions;

import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.LangDataKeys;
Expand All @@ -17,6 +18,7 @@
import com.intellij.psi.PsiFile;
import org.antlr.intellij.plugin.ANTLRv4PluginController;
import org.antlr.intellij.plugin.psi.ParserRuleRefNode;
import org.jetbrains.annotations.NotNull;

import java.awt.*;
import java.awt.event.InputEvent;
Expand Down Expand Up @@ -81,6 +83,11 @@ public void update(AnActionEvent e) {
}
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.EDT;
}

@Override
public void actionPerformed(final AnActionEvent e) {
if ( e.getProject()==null ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.antlr.intellij.plugin.actions;

import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.LangDataKeys;
Expand All @@ -21,6 +22,7 @@
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.TerminalNode;
import org.jetbrains.annotations.NotNull;

import java.util.List;

Expand All @@ -33,6 +35,11 @@ public void update(AnActionEvent e) {
MyActionUtils.showOnlyIfSelectionIsRule(e, "Dup to Make %s Refs Unique");
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}

@Override
public void actionPerformed(AnActionEvent e) {
PsiElement el = MyActionUtils.getSelectedPsiElement(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.antlr.intellij.plugin.preview;

import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import org.antlr.intellij.plugin.ANTLRv4PluginController;
Expand All @@ -25,6 +26,11 @@ public void update(@NotNull AnActionEvent e) {
e.getPresentation().setEnabled(enabled);
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.EDT;
}

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final ANTLRv4PluginController controller = ANTLRv4PluginController.getInstance(e.getProject());
Expand Down

0 comments on commit 7e47e4d

Please sign in to comment.