Skip to content

Commit

Permalink
fix: Parse the project in path correctly (#708)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdneo authored May 20, 2019
1 parent 9c4c5f2 commit 7ff7a32
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static Set<IJavaProject> parseProjects(String uriStr) {
return Collections.emptySet();
}
return Arrays.stream(ProjectUtils.getJavaProjects())
.filter(p -> belongToProject(parentPath, p.getProject()))
.filter(p -> isProjectBelongToPath(p.getProject(), parentPath))
.collect(Collectors.toSet());
}

Expand Down Expand Up @@ -135,7 +135,23 @@ public static boolean isTest(IClasspathEntry entry) {
return entry.isTest();
}

public static boolean belongToProject(IPath testPath, IProject project) {
public static boolean isProjectBelongToPath(IProject project, IPath path) {
// Check for visible project
if (project.getLocation() != null && path.isPrefixOf(project.getLocation())) {
return true;
}


// Check for invisible project
final IPath linkedLocation = project.getFolder(WORKSPACE_LINK).getLocation();
if (linkedLocation != null && path.isPrefixOf(linkedLocation)) {
return true;
}

return false;
}

public static boolean isPathBelongToProject(IPath testPath, IProject project) {
// Check if the path belongs to visible project
if (project.getLocation() != null && project.getLocation().isPrefixOf(testPath)) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static String[] resolveRuntimeClassPath(List<Object> arguments) throws Co
while (iterator.hasNext()) {
final IJavaProject javaProject = iterator.next();
final IProject project = javaProject.getProject();
if (ProjectTestUtils.belongToProject(testPath, project)) {
if (ProjectTestUtils.isPathBelongToProject(testPath, project)) {
projectsToTest.add(javaProject);
iterator.remove();
}
Expand Down

0 comments on commit 7ff7a32

Please sign in to comment.