Skip to content

Commit 342efbc

Browse files
committed
Add config option for enabling/disabling indexing
1 parent 691bf81 commit 342efbc

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public data class CompilerConfiguration(
2323
val jvm: JVMConfiguration = JVMConfiguration()
2424
)
2525

26+
public data class IndexingConfiguration(
27+
/** Whether an index of global symbols should be built in the background. */
28+
var enabled: Boolean = true
29+
)
30+
2631
public data class ExternalSourcesConfiguration(
2732
/** Whether kls-URIs should be sent to the client to describe classes in JARs. */
2833
var useKlsScheme: Boolean = false,
@@ -34,5 +39,6 @@ public data class Configuration(
3439
val compiler: CompilerConfiguration = CompilerConfiguration(),
3540
val completion: CompletionConfiguration = CompletionConfiguration(),
3641
val linting: LintingConfiguration = LintingConfiguration(),
42+
var indexing: IndexingConfiguration = IndexingConfiguration(),
3743
val externalSources: ExternalSourcesConfiguration = ExternalSourcesConfiguration()
3844
)

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ class KotlinWorkspaceService(
123123
}
124124
}
125125

126+
// Update indexing options
127+
get("indexing")?.asJsonObject?.apply {
128+
val indexing = config.indexing
129+
get("enabled")?.asBoolean?.let {
130+
indexing.enabled = it
131+
sp.indexEnabled = it
132+
}
133+
}
134+
126135
// Update options about external sources e.g. JAR files, decompilers, etc
127136
get("externalSources")?.asJsonObject?.apply {
128137
val externalSources = config.externalSources

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class SourcePath(
3131
private val indexAsync = AsyncExecutor()
3232

3333
val index = SymbolIndex()
34+
var indexEnabled = true
3435
var beforeCompileCallback: () -> Unit = {}
3536

3637
private inner class SourceFile(
@@ -201,7 +202,7 @@ class SourcePath(
201202
}
202203

203204
// Only index normal files, not build files
204-
if (kind == CompilationKind.DEFAULT) {
205+
if (indexEnabled && kind == CompilationKind.DEFAULT) {
205206
updateIndexAsync(container)
206207
}
207208

@@ -222,8 +223,8 @@ class SourcePath(
222223
* Updates the symbol index asynchronously.
223224
*/
224225
private fun updateIndexAsync(container: ComponentProvider) = indexAsync.execute {
225-
// val module = container.getService(ModuleDescriptor::class.java)
226-
// index.update(module)
226+
val module = container.getService(ModuleDescriptor::class.java)
227+
index.update(module)
227228
}
228229

229230
/**

0 commit comments

Comments
 (0)