Skip to content

Commit 756fc4e

Browse files
authored
Merge pull request #151 from codellm-devkit/fix/exclude-source-root-relative-path
fix: relativize source root path before applying exclusion filter
2 parents dbd9ac7 + 68667ae commit 756fc4e

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)