Skip to content

Commit 68667ae

Browse files
committed
fix: relativize source root path before applying exclusion filter
excludeSourceRoot matched patterns against the full absolute path, so projects stored under a directory containing "src/test/resources" (e.g. test fixtures in src/test/resources/) had their source roots wronglyexcluded, producing an empty symbol table. Fix by relativizing the source root against the project root before pattern matching, so only path segments within the target project are considered.
1 parent dbd9ac7 commit 68667ae

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/main/java/com/ibm/cldk/SymbolTable.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,9 +1162,10 @@ private static String resolveType(Type type) {
11621162
Paths.get("src", "it", "resources").toString(),
11631163
Paths.get("src", "xdocs-examples").toString()
11641164
};
1165-
private static boolean excludeSourceRoot(Path sourceRoot) {
1165+
private static boolean excludeSourceRoot(Path sourceRoot, Path projectRootPath) {
1166+
Path relativeSourceRoot = projectRootPath.toAbsolutePath().relativize(sourceRoot.toAbsolutePath());
11661167
for (String excludedSrcRoot : EXCLUDED_SOURCE_ROOTS) {
1167-
if (Pattern.compile(excludedSrcRoot).matcher(sourceRoot.toString()).find()) {
1168+
if (Pattern.compile(excludedSrcRoot).matcher(relativeSourceRoot.toString()).find()) {
11681169
return true;
11691170
}
11701171
}
@@ -1202,7 +1203,7 @@ public static Pair<Map<String, JavaCompilationUnit>, Map<String, List<Problem>>>
12021203
Map<String, JavaCompilationUnit> symbolTable = new LinkedHashMap<>();
12031204
Map<String, List<Problem>> parseProblems = new HashMap<>();
12041205
for (SourceRoot sourceRoot : projectRoot.getSourceRoots()) {
1205-
if (excludeSourceRoot(sourceRoot.getRoot())) {
1206+
if (excludeSourceRoot(sourceRoot.getRoot(), projectRootPath)) {
12061207
continue;
12071208
}
12081209
sourceRoot.setParserConfiguration(config);

0 commit comments

Comments
 (0)