mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
test-runner: non-null scope guarantee for AbstractTestProxy.getLocation
This commit is contained in:
+6
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,11 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 24-Dec-2008
|
||||
*/
|
||||
package com.intellij.execution.actions;
|
||||
|
||||
import com.intellij.execution.testframework.Filter;
|
||||
@@ -29,16 +24,19 @@ import com.intellij.openapi.ui.ComponentContainer;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author anna
|
||||
* @since 24-Dec-2008
|
||||
*/
|
||||
public class JavaRerunFailedTestsAction extends AbstractRerunFailedTestsAction {
|
||||
public JavaRerunFailedTestsAction(@NotNull ComponentContainer componentContainer, @NotNull TestConsoleProperties consoleProperties) {
|
||||
super(componentContainer);
|
||||
|
||||
init(consoleProperties);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Filter getFilter(Project project, GlobalSearchScope searchScope) {
|
||||
protected Filter getFilter(@NotNull Project project, @NotNull GlobalSearchScope searchScope) {
|
||||
return super.getFilter(project, searchScope).and(JavaAwareFilter.METHOD(project, searchScope));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,11 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 20-Feb-2008
|
||||
*/
|
||||
package com.intellij.execution.testframework;
|
||||
|
||||
import com.intellij.execution.Location;
|
||||
@@ -26,18 +21,22 @@ import com.intellij.execution.junit2.info.MethodLocation;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author anna
|
||||
* @since 20-Feb-2008
|
||||
*/
|
||||
public class JavaAwareFilter {
|
||||
private JavaAwareFilter() {
|
||||
}
|
||||
private JavaAwareFilter() { }
|
||||
|
||||
public static Filter METHOD(final Project project, final GlobalSearchScope searchScope) {
|
||||
public static Filter METHOD(@NotNull final Project project, @NotNull final GlobalSearchScope searchScope) {
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean shouldAccept(final AbstractTestProxy test) {
|
||||
final Location location = test.getLocation(project, searchScope);
|
||||
if (location instanceof MethodLocation) return true;
|
||||
if (location instanceof PsiLocation && location.getPsiElement() instanceof PsiMethod) return true;
|
||||
return false;
|
||||
Location location = test.getLocation(project, searchScope);
|
||||
return location instanceof MethodLocation ||
|
||||
location instanceof PsiLocation && location.getPsiElement() instanceof PsiMethod;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+9
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,7 +19,7 @@ import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.JavaExecutionUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiClass;
|
||||
@@ -53,12 +53,15 @@ public class JavaRunConfigurationModule extends RunConfigurationModule {
|
||||
return JavaExecutionUtil.findMainClass(getProject(), qualifiedName, getSearchScope());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public GlobalSearchScope getSearchScope() {
|
||||
final Module module = getModule();
|
||||
Module module = getModule();
|
||||
if (module != null) {
|
||||
return myClassesInLibraries ? module.getModuleRuntimeScope(true) : GlobalSearchScope.moduleWithDependenciesScope(module);
|
||||
}
|
||||
return myClassesInLibraries ? GlobalSearchScope.allScope(getProject()) : GlobalSearchScope.projectScope(getProject());
|
||||
else {
|
||||
return myClassesInLibraries ? GlobalSearchScope.allScope(getProject()) : GlobalSearchScope.projectScope(getProject());
|
||||
}
|
||||
}
|
||||
|
||||
public static Collection<Module> getModulesForClass(@NotNull final Project project, final String className) {
|
||||
@@ -68,7 +71,7 @@ public class JavaRunConfigurationModule extends RunConfigurationModule {
|
||||
|
||||
final Set<Module> modules = new THashSet<Module>();
|
||||
for (PsiClass aClass : possibleClasses) {
|
||||
Module module = ModuleUtil.findModuleForPsiElement(aClass);
|
||||
Module module = ModuleUtilCore.findModuleForPsiElement(aClass);
|
||||
if (module != null) {
|
||||
modules.add(module);
|
||||
}
|
||||
@@ -79,7 +82,7 @@ public class JavaRunConfigurationModule extends RunConfigurationModule {
|
||||
else {
|
||||
final Set<Module> result = new HashSet<Module>();
|
||||
for (Module module : modules) {
|
||||
ModuleUtil.collectModulesDependsOn(module, result);
|
||||
ModuleUtilCore.collectModulesDependsOn(module, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user