diff --git a/server/src/main/kotlin/org/javacs/kt/CompilerClassPath.kt b/server/src/main/kotlin/org/javacs/kt/CompilerClassPath.kt index 794377454..6865ee8d8 100644 --- a/server/src/main/kotlin/org/javacs/kt/CompilerClassPath.kt +++ b/server/src/main/kotlin/org/javacs/kt/CompilerClassPath.kt @@ -170,6 +170,7 @@ class CompilerClassPath( override fun close() { compiler.close() + async.shutdown(true) outputDirectory.delete() } } diff --git a/server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt b/server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt index e8da0ff99..d58d51134 100644 --- a/server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt +++ b/server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt @@ -162,6 +162,7 @@ class KotlinLanguageServer( override fun close() { textDocumentService.close() classPath.close() + sourcePath.close() tempDirectory.close() async.shutdown(awaitTermination = true) } diff --git a/server/src/main/kotlin/org/javacs/kt/SourcePath.kt b/server/src/main/kotlin/org/javacs/kt/SourcePath.kt index dff7e0d7e..afafbf34f 100644 --- a/server/src/main/kotlin/org/javacs/kt/SourcePath.kt +++ b/server/src/main/kotlin/org/javacs/kt/SourcePath.kt @@ -14,6 +14,7 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.CompositeBindingContext import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter +import java.io.Closeable import kotlin.concurrent.withLock import java.nio.file.Path import java.nio.file.Paths @@ -25,7 +26,7 @@ class SourcePath( private val contentProvider: URIContentProvider, private val indexingConfig: IndexingConfiguration, private val databaseService: DatabaseService -) { +): Closeable { private val files = mutableMapOf() private val parseDataWriteLock = ReentrantLock() @@ -354,4 +355,8 @@ class SourcePath( files.values .filter { includeHidden || !it.isTemporary } .map { it.apply { parseIfChanged() }.parsed!! } + + override fun close() { + indexAsync.shutdown(true) + } } diff --git a/server/src/main/kotlin/org/javacs/kt/completion/Completions.kt b/server/src/main/kotlin/org/javacs/kt/completion/Completions.kt index 509f1e6b8..4bd37caf2 100644 --- a/server/src/main/kotlin/org/javacs/kt/completion/Completions.kt +++ b/server/src/main/kotlin/org/javacs/kt/completion/Completions.kt @@ -184,14 +184,15 @@ private fun completionItem(d: DeclarationDescriptor, surroundingElement: KtEleme result.label = methodSignature.find(result.detail)?.groupValues?.get(1) ?: result.label - if (isNotStaticJavaMethod(d) && (isGetter(d) || isSetter(d))) { - val name = extractPropertyName(d) - - result.detail += " (from ${result.label})" - result.label = name - result.insertText = name - result.filterText = name - } + // TODO: @xiaobo; sceptical about this code block, it might mistakenly extract function names +// if (isNotStaticJavaMethod(d) && (isGetter(d) || isSetter(d))) { +// val name = extractPropertyName(d) +// +// result.detail += " (from ${result.label})" +// result.label = name +// result.insertText = name +// result.filterText = name +// } if (KotlinBuiltIns.isDeprecated(d)) { result.tags = listOf(CompletionItemTag.Deprecated)