Skip to content

Commit 9961e24

Browse files
committed
another read fix
1 parent f16b435 commit 9961e24

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

java-execution-impl/src/main/java/com/intellij/java/execution/impl/application/AbstractApplicationConfigurationProducer.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,21 @@ private void setupConfiguration(T configuration, PsiClass aClass, ConfigurationC
8282
}
8383

8484
@Nullable
85-
private static PsiMethod findMain(PsiElement element) {
86-
PsiMethod method;
87-
while ((method = PsiTreeUtil.getParentOfType(element, PsiMethod.class)) != null) {
88-
if (PsiMethodUtil.isMainMethod(method)) {
89-
return method;
90-
}
91-
else {
92-
element = method.getParent();
85+
private static PsiMethod findMain(final PsiElement element) {
86+
return ReadAction.compute(() -> {
87+
PsiElement target = element;
88+
89+
PsiMethod method;
90+
while ((method = PsiTreeUtil.getParentOfType(target, PsiMethod.class)) != null) {
91+
if (PsiMethodUtil.isMainMethod(method)) {
92+
return method;
93+
}
94+
else {
95+
target = method.getParent();
96+
}
9397
}
94-
}
95-
return null;
98+
return null;
99+
});
96100
}
97101

98102
@Override

0 commit comments

Comments
 (0)