Search in sources :

Example 1 with FunctionUtil

use of com.intellij.util.FunctionUtil in project intellij-community by JetBrains.

the class TestsPattern method createSearchingForTestsTask.

@Override
public SearchForTestsTask createSearchingForTestsTask() {
    final JUnitConfiguration.Data data = getConfiguration().getPersistentData();
    final Project project = getConfiguration().getProject();
    final Set<String> classNames = new LinkedHashSet<>();
    for (String className : data.getPatterns()) {
        final PsiClass psiClass = getTestClass(project, className);
        if (psiClass != null && JUnitUtil.isTestClass(psiClass)) {
            classNames.add(className);
        }
    }
    if (classNames.size() == data.getPatterns().size()) {
        return new SearchForTestsTask(project, myServerSocket) {

            @Override
            protected void search() throws ExecutionException {
                final Function<String, String> nameFunction = StringUtil.isEmpty(data.METHOD_NAME) ? FunctionUtil.<String>id() : (Function<String, String>) className -> className;
                addClassesListToJavaParameters(classNames, nameFunction, "", false, getJavaParameters());
            }

            @Override
            protected void onFound() {
            }
        };
    }
    return super.createSearchingForTestsTask();
}
Also used : LinkedHashSet(java.util.LinkedHashSet) RuntimeConfigurationException(com.intellij.execution.configurations.RuntimeConfigurationException) ExecutionException(com.intellij.execution.ExecutionException) StringUtil(com.intellij.openapi.util.text.StringUtil) RefactoringElementListener(com.intellij.refactoring.listeners.RefactoringElementListener) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) Set(java.util.Set) JavaExecutionUtil(com.intellij.execution.JavaExecutionUtil) Nullable(org.jetbrains.annotations.Nullable) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) RefactoringElementListenerComposite(com.intellij.refactoring.listeners.RefactoringElementListenerComposite) Function(com.intellij.util.Function) SearchForTestsTask(com.intellij.execution.testframework.SearchForTestsTask) Project(com.intellij.openapi.project.Project) com.intellij.psi(com.intellij.psi) FunctionUtil(com.intellij.util.FunctionUtil) CantRunException(com.intellij.execution.CantRunException) RuntimeConfigurationWarning(com.intellij.execution.configurations.RuntimeConfigurationWarning) Module(com.intellij.openapi.module.Module) LinkedHashSet(java.util.LinkedHashSet) Project(com.intellij.openapi.project.Project) SearchForTestsTask(com.intellij.execution.testframework.SearchForTestsTask)

Aggregations

CantRunException (com.intellij.execution.CantRunException)1 ExecutionException (com.intellij.execution.ExecutionException)1 JavaExecutionUtil (com.intellij.execution.JavaExecutionUtil)1 RuntimeConfigurationException (com.intellij.execution.configurations.RuntimeConfigurationException)1 RuntimeConfigurationWarning (com.intellij.execution.configurations.RuntimeConfigurationWarning)1 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)1 SearchForTestsTask (com.intellij.execution.testframework.SearchForTestsTask)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 com.intellij.psi (com.intellij.psi)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 RefactoringElementListener (com.intellij.refactoring.listeners.RefactoringElementListener)1 RefactoringElementListenerComposite (com.intellij.refactoring.listeners.RefactoringElementListenerComposite)1 Function (com.intellij.util.Function)1 FunctionUtil (com.intellij.util.FunctionUtil)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 Nullable (org.jetbrains.annotations.Nullable)1