Skip to content

Commit b387834

Browse files
make sure subdirectories are correctly added to search scopes (#145)
Signed-off-by: Pranav Gaikwad <pgaikwad@redhat.com>
1 parent 8f942d2 commit b387834

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/SampleDelegateCommandHandler.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,20 @@ private static List<SymbolInformation> search(String projectName, ArrayList<Stri
235235
IPath includedIPath = Path.fromOSString(includedPath);
236236
if (includedIPath.isAbsolute()) {
237237
includedIPath = includedIPath.makeRelativeTo(workspaceDirectoryLocation.iterator().next());
238-
// we need to remove the /src/java from the path
238+
// when the java project is in a sub-directory, we need to cut everything
239+
// until the first occurrence of "src".
240+
if (!includedIPath.segment(0).equals("src")) {
241+
int srcSegmentIdx = -1;
242+
for (int i = 0; i < includedIPath.segmentCount(); i += 1) {
243+
if (includedIPath.segment(i).equals("src")) {
244+
srcSegmentIdx = i;
245+
}
246+
}
247+
if (srcSegmentIdx != -1) {
248+
includedIPath = includedIPath.removeFirstSegments(srcSegmentIdx);
249+
}
250+
}
251+
// we need to remove the /src/main/java from the path
239252
if (includedIPath.segment(0).equals("src")) {
240253
includedIPath = includedIPath.removeFirstSegments(1);
241254
}

0 commit comments

Comments
 (0)