mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
junit 5: detect attached junit by jupiter api
This commit is contained in:
@@ -29,30 +29,33 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Date: 2/20/12
|
||||
*/
|
||||
public class LocationUtil {
|
||||
public static boolean isJarAttached(@NotNull Location location, @NotNull final PsiPackage aPackage, final String fqn) {
|
||||
return isJarAttached(location, fqn, aPackage.getDirectories());
|
||||
public static boolean isJarAttached(@NotNull Location location, @NotNull final PsiPackage aPackage, final String... fqn) {
|
||||
return isJarAttached(location, aPackage.getDirectories(), fqn);
|
||||
}
|
||||
|
||||
public static boolean isJarAttached(@NotNull Location location,
|
||||
final String fqn,
|
||||
final PsiDirectory[] directories) {
|
||||
final PsiDirectory[] directories,
|
||||
final String... fqns) {
|
||||
final JavaPsiFacade facade = JavaPsiFacade.getInstance(location.getProject());
|
||||
boolean testngJarFound = false;
|
||||
final Module locationModule = location.getModule();
|
||||
if (locationModule != null) {
|
||||
testngJarFound = facade.findClass(fqn, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(locationModule, true)) != null;
|
||||
for (String fqn : fqns) {
|
||||
if (facade.findClass(fqn, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(locationModule, true)) != null) return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (PsiDirectory directory : directories) {
|
||||
final Module module = ModuleUtilCore.findModuleForFile(directory.getVirtualFile(), location.getProject());
|
||||
if (module != null) {
|
||||
if (facade.findClass(fqn, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, true)) != null) {
|
||||
testngJarFound = true;
|
||||
break;
|
||||
GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, true);
|
||||
for (String fqn : fqns) {
|
||||
if (facade.findClass(fqn, scope) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return testngJarFound;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user