@Override public void update(AnActionEvent e) { final Presentation presentation = e.getPresentation(); presentation.setVisible(false); final DataContext dataContext = e.getDataContext(); final Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project != null) { final RunConfiguration configuration = RunConfiguration.DATA_KEY.getData(dataContext); if (isPatternBasedConfiguration(configuration)) { final AbstractTestProxy testProxy = AbstractTestProxy.DATA_KEY.getData(dataContext); if (testProxy != null) { final Location location = testProxy.getLocation( project, ((T) configuration).getConfigurationModule().getSearchScope()); if (location != null) { final PsiElement psiElement = location.getPsiElement(); if (psiElement instanceof PsiClass && getPattern((T) configuration) .contains(((PsiClass) psiElement).getQualifiedName())) { presentation.setVisible(true); } } } } } }
@Override public void actionPerformed(AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final Project project = CommonDataKeys.PROJECT.getData(dataContext); LOG.assertTrue(project != null); final T configuration = (T) RunConfiguration.DATA_KEY.getData(dataContext); LOG.assertTrue(configuration != null); final GlobalSearchScope searchScope = configuration.getConfigurationModule().getSearchScope(); final AbstractTestProxy testProxy = AbstractTestProxy.DATA_KEY.getData(dataContext); LOG.assertTrue(testProxy != null); final String qualifiedName = ((PsiClass) testProxy.getLocation(project, searchScope).getPsiElement()).getQualifiedName(); getPattern(configuration).remove(qualifiedName); }
protected void addJUnit4Parameter(final JUnitConfiguration.Data data, Project project) { for (AbstractTestProxy failedTest : myFailedTests) { Location location = failedTest.getLocation(project); if (!(location instanceof MethodLocation)) continue; if (JUnitUtil.isJUnit4TestClass(((MethodLocation) location).getContainingClass())) { myJavaParameters.getProgramParametersList().add(JUnitStarter.JUNIT4_PARAMETER); return; } PsiMethod method = ((MethodLocation) location).getPsiElement(); if (JUnitUtil.isTestAnnotated(method)) { myJavaParameters.getProgramParametersList().add(JUnitStarter.JUNIT4_PARAMETER); return; } } }
protected void initialize() throws ExecutionException { defaultInitialize(); final JUnitConfiguration.Data data = myConfiguration.getPersistentData(); RunConfigurationModule module = myConfiguration.getConfigurationModule(); final Project project = module.getProject(); addJUnit4Parameter(data, project); final ExecutionException[] exception = new ExecutionException[1]; ApplicationManager.getApplication() .runReadAction( new Runnable() { public void run() { try { myConfiguration.configureClasspath(myJavaParameters); } catch (CantRunException e) { exception[0] = e; } } }); if (exception[0] != null) throw exception[0]; final LinkedHashMap<PsiMethod, TestInfo> methods = new LinkedHashMap<PsiMethod, TestInfo>(); for (AbstractTestProxy failedTest : myFailedTests) { Location location = failedTest.getLocation(project); if (!(location instanceof MethodLocation)) continue; PsiElement psiElement = location.getPsiElement(); LOG.assertTrue(psiElement instanceof PsiMethod); PsiMethod method = (PsiMethod) psiElement; methods.put(method, ((TestProxy) failedTest).getInfo()); } addClassesListToJavaParameters( methods.keySet(), new Function<PsiElement, String>() { public String fun(PsiElement element) { if (element instanceof PsiMethod) { final PsiMethod method = (PsiMethod) element; final TestInfo testInfo = methods.get(method); return JavaExecutionUtil.getRuntimeQualifiedName( ((MethodLocation) testInfo.getLocation(project)).getContainingClass()) + "," + testInfo.getName(); } return null; } }, data.getPackageName(), true, false); }