Skip to content

Commit

Permalink
Tries to fix ui-test
Browse files Browse the repository at this point in the history
  • Loading branch information
fvclaus committed Sep 28, 2023
1 parent 1938151 commit ead44c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.core.internal.utils.FileUtil;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
Expand Down Expand Up @@ -578,17 +579,20 @@ private static Object[] findJarDirectoryChildren(JarEntryDirectory directory, St

public static IProject getProject(String projectUri) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IContainer[] containers = root.findContainersForLocationURI(JDTUtils.toURI(projectUri));

if (containers.length == 0) {
return null;
}
URI uri = JDTUtils.toURI(projectUri);
IContainer[] containers = root.findContainersForLocationURI(uri);

Optional<IContainer> maybeProject = Arrays.stream(containers).filter(container -> container instanceof IProject).findFirst();
if (maybeProject.isPresent()) {
return (IProject) maybeProject.get();
} else {
String invisibleProjectName = ProjectUtils.getWorkspaceInvisibleProjectName(FileUtil.toPath(uri).removeTrailingSeparator());
IProject invisibleProject = root.getProject(invisibleProjectName);
if (!invisibleProject.exists()) {
throw new IllegalArgumentException(projectUri + " is neither a Java nor an invisible project.");
}
return invisibleProject;
}
return null;
}

public static IJavaProject getJavaProject(String projectUri) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,9 @@ public static List<MainClassInfo> getMainClasses(List<Object> arguments, IProgre
}
for (PackageNode project : projectList) {
IJavaProject javaProject = PackageCommand.getJavaProject(project.getUri());
if (javaProject != null) {
for (IPackageFragmentRoot packageFragmentRoot : javaProject.getAllPackageFragmentRoots()) {
if (!packageFragmentRoot.isArchive()) {
searchRoots.add(packageFragmentRoot);
}
for (IPackageFragmentRoot packageFragmentRoot : javaProject.getAllPackageFragmentRoots()) {
if (!packageFragmentRoot.isArchive()) {
searchRoots.add(packageFragmentRoot);
}
}
}
Expand Down

0 comments on commit ead44c0

Please sign in to comment.