Skip to content

Commit 12edb62

Browse files
committed
Log more verbosely about exclusions
1 parent 70dfeb4 commit 12edb62

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

server/src/main/kotlin/org/javacs/kt/KotlinTextDocumentService.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ class KotlinTextDocumentService(
8080

8181
private fun recover(uriString: String, position: Position, recompile: Recompile): Pair<CompiledFile, Int>? {
8282
val uri = parseURI(uriString)
83-
if (!sf.isIncluded(uri)) return null
83+
if (!sf.isIncluded(uri)) {
84+
LOG.warn("URI is excluded, therefore cannot be recovered: $uri")
85+
return null
86+
}
8487
val content = sp.content(uri)
8588
val offset = offset(content, position.line, position.character)
8689
val shouldRecompile = when (recompile) {

server/src/main/kotlin/org/javacs/kt/SourceFiles.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ class SourceFiles(
154154
}
155155

156156
fun addWorkspaceRoot(root: Path) {
157+
LOG.info("Searching $root using exclusions: ${exclusions.excludedPatterns}")
157158
val addSources = findSourceFiles(root)
158159

159160
logAdded(addSources, root)

shared/src/main/kotlin/org/javacs/kt/SourceExclusions.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ class SourceExclusions(
1313
private val workspaceRoots: Collection<Path>,
1414
private val scriptsConfig: ScriptsConfiguration
1515
) {
16-
private val excludedPatterns = (listOf(
16+
val excludedPatterns = (listOf(
1717
".*", "bazel-*", "bin", "build", "node_modules", "target"
1818
) + when {
1919
!scriptsConfig.enabled -> listOf("*.kts")
2020
!scriptsConfig.buildScriptsEnabled -> listOf("*.gradle.kts")
2121
else -> emptyList()
2222
})
23+
24+
private val exclusionMatchers = excludedPatterns
2325
.map { FileSystems.getDefault().getPathMatcher("glob:$it") }
2426

2527
/** Finds all non-excluded files recursively. */
@@ -35,10 +37,10 @@ class SourceExclusions(
3537

3638
/** Tests whether the given path is not excluded. */
3739
fun isPathIncluded(file: Path): Boolean = workspaceRoots.any { file.startsWith(it) }
38-
&& excludedPatterns.none { pattern ->
40+
&& exclusionMatchers.none { matcher ->
3941
workspaceRoots
4042
.mapNotNull { if (file.startsWith(it)) it.relativize(file) else null }
4143
.flatMap { it } // Extract path segments
42-
.any(pattern::matches)
44+
.any(matcher::matches)
4345
}
4446
}

0 commit comments

Comments
 (0)