From b688be4d49c76925b9a9ff0cd8c852f30ba5c8ac Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Sat, 4 Apr 2015 14:10:17 +0200 Subject: [PATCH] read action during search in background --- .../ui/actions/RerunFailedTestsAction.java | 51 +++++++++++-------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/plugins/testng/src/com/theoryinpractice/testng/ui/actions/RerunFailedTestsAction.java b/plugins/testng/src/com/theoryinpractice/testng/ui/actions/RerunFailedTestsAction.java index 0c6eea9af3e8..d07fd8962872 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/ui/actions/RerunFailedTestsAction.java +++ b/plugins/testng/src/com/theoryinpractice/testng/ui/actions/RerunFailedTestsAction.java @@ -70,27 +70,38 @@ public class RerunFailedTestsAction extends JavaRerunFailedTestsAction { final GlobalSearchScope scope = config.getConfigurationModule().getSearchScope(); final Project project = config.getProject(); - for (AbstractTestProxy proxy : failedTests) { - final Location location = proxy.getLocation(project, scope); - if (location != null) { - final PsiElement element = location.getPsiElement(); - if (element instanceof PsiMethod && element.isValid()) { - final PsiMethod psiMethod = (PsiMethod)element; - PsiClass psiClass = psiMethod.getContainingClass(); - if (psiClass != null && psiClass.hasModifierProperty(PsiModifier.ABSTRACT)) { - final AbstractTestProxy parent = proxy.getParent(); - final PsiElement elt = parent != null ? parent.getLocation(project, scope).getPsiElement() : null; - if (elt instanceof PsiClass) { - psiClass = (PsiClass)elt; - } - } - Collection psiMethods = classes.get(psiClass); - if (psiMethods == null) { - psiMethods = new ArrayList(); - classes.put(psiClass, psiMethods); - } - psiMethods.add(psiMethod); + for (final AbstractTestProxy proxy : failedTests) { + ApplicationManager.getApplication().runReadAction(new Runnable() { + public void run() { + includeFailedTestWithDependencies(classes, scope, project, proxy); } + }); + } + } + + private void includeFailedTestWithDependencies(Map> classes, + GlobalSearchScope scope, + Project project, + AbstractTestProxy proxy) { + final Location location = proxy.getLocation(project, scope); + if (location != null) { + final PsiElement element = location.getPsiElement(); + if (element instanceof PsiMethod && element.isValid()) { + final PsiMethod psiMethod = (PsiMethod)element; + PsiClass psiClass = psiMethod.getContainingClass(); + if (psiClass != null && psiClass.hasModifierProperty(PsiModifier.ABSTRACT)) { + final AbstractTestProxy parent = proxy.getParent(); + final PsiElement elt = parent != null ? parent.getLocation(project, scope).getPsiElement() : null; + if (elt instanceof PsiClass) { + psiClass = (PsiClass)elt; + } + } + Collection psiMethods = classes.get(psiClass); + if (psiMethods == null) { + psiMethods = new ArrayList(); + classes.put(psiClass, psiMethods); + } + psiMethods.add(psiMethod); } } }