Skip to content

Commit 9b09e22

Browse files
authored
Merge pull request #1692 from adamwojs/issue_1675
Fixed #1675: "AWT events are not allowed inside write action" exception while creating dialog window for resolving arguments ambiguity
2 parents 62e1ea8 + 9710ebf commit 9b09e22

File tree

7 files changed

+44
-3
lines changed

7 files changed

+44
-3
lines changed

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/ServiceActionUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ public static void fixServiceArgument(@NotNull Project project, @NotNull List<St
474474
}
475475
}
476476

477-
callback.insert(items);
477+
ApplicationManager.getApplication().runWriteAction(() -> callback.insert(items));
478478

479479
return;
480480
}

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/generator/ServiceArgumentGenerateAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull Ps
7878

7979
@Override
8080
public boolean startInWriteAction() {
81-
return true;
81+
return false;
8282
}
8383
};
8484
}

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/quickfix/AddServiceXmlArgumentLocalQuickFix.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,8 @@ public void applyFix(final @NotNull Project project, @NotNull ProblemDescriptor
4444
ServiceActionUtil.fixServiceArgument(args, (XmlTag) parent);
4545
}
4646

47+
@Override
48+
public boolean startInWriteAction() {
49+
return false;
50+
}
4751
}

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/ui/ServiceArgumentSelectionDialog.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package fr.adrienbrault.idea.symfony2plugin.action.ui;
22

3+
import com.intellij.openapi.application.ApplicationManager;
34
import com.intellij.openapi.project.Project;
45
import com.intellij.openapi.ui.ComboBox;
56
import com.intellij.ui.ToolbarDecorator;
@@ -55,7 +56,7 @@ public void init() {
5556
items.add(serviceParameter.getCurrentService());
5657
}
5758

58-
callback.onOk(items);
59+
ApplicationManager.getApplication().runWriteAction(() -> callback.onOk(items));
5960

6061
dispose();
6162
});

src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/php/XmlServiceArgumentIntention.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,8 @@ public String getText() {
8989
return "Symfony: Add Arguments";
9090
}
9191

92+
@Override
93+
public boolean startInWriteAction() {
94+
return false;
95+
}
9296
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package fr.adrienbrault.idea.symfony2plugin.tests.action.quickfix;
2+
3+
import fr.adrienbrault.idea.symfony2plugin.action.quickfix.AddServiceXmlArgumentLocalQuickFix;
4+
import fr.adrienbrault.idea.symfony2plugin.tests.SymfonyLightCodeInsightFixtureTestCase;
5+
6+
import java.util.ArrayList;
7+
8+
public class AddServiceXmlArgumentLocalQuickFixTest extends SymfonyLightCodeInsightFixtureTestCase {
9+
10+
public void testStartInWriteAction() {
11+
var quickfix = new AddServiceXmlArgumentLocalQuickFix(new ArrayList<>());
12+
13+
// Prevents "AWT events are not allowed inside write action" exception
14+
// while creating dialog window for resolving arguments ambiguity
15+
assertFalse(quickfix.startInWriteAction());
16+
}
17+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package fr.adrienbrault.idea.symfony2plugin.tests.intentions.php;
2+
3+
import fr.adrienbrault.idea.symfony2plugin.intentions.php.XmlServiceArgumentIntention;
4+
import fr.adrienbrault.idea.symfony2plugin.tests.SymfonyLightCodeInsightFixtureTestCase;
5+
6+
public class XmlServiceArgumentIntentionTest extends SymfonyLightCodeInsightFixtureTestCase {
7+
8+
public void testIntentionStartInReadThread() {
9+
var intention = new XmlServiceArgumentIntention();
10+
11+
// Prevents "AWT events are not allowed inside write action" exception
12+
// while creating dialog window for resolving arguments ambiguity
13+
assertFalse(intention.startInWriteAction());
14+
}
15+
}

0 commit comments

Comments
 (0)