From a1a5498497d2f74cc09f41c7c2deadb81e90dca8 Mon Sep 17 00:00:00 2001 From: xiaobo Date: Wed, 27 Apr 2022 09:49:48 +0800 Subject: [PATCH 1/2] fix bug on closing Executor Thread Pool --- server/src/main/kotlin/org/javacs/kt/CompilerClassPath.kt | 1 + .../src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt | 1 + server/src/main/kotlin/org/javacs/kt/SourcePath.kt | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/server/src/main/kotlin/org/javacs/kt/CompilerClassPath.kt b/server/src/main/kotlin/org/javacs/kt/CompilerClassPath.kt index 23fe1356e..1ac6d399e 100644 --- a/server/src/main/kotlin/org/javacs/kt/CompilerClassPath.kt +++ b/server/src/main/kotlin/org/javacs/kt/CompilerClassPath.kt @@ -141,6 +141,7 @@ class CompilerClassPath(private val config: CompilerConfiguration) : Closeable { 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 7f2017359..497cd8a85 100644 --- a/server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt +++ b/server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt @@ -152,6 +152,7 @@ class KotlinLanguageServer : LanguageServer, LanguageClientAware, Closeable { 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 150696195..ebfc8ae82 100644 --- a/server/src/main/kotlin/org/javacs/kt/SourcePath.kt +++ b/server/src/main/kotlin/org/javacs/kt/SourcePath.kt @@ -13,6 +13,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 @@ -23,7 +24,7 @@ class SourcePath( private val cp: CompilerClassPath, private val contentProvider: URIContentProvider, private val indexingConfig: IndexingConfiguration -) { +): Closeable { private val files = mutableMapOf() private val parseDataWriteLock = ReentrantLock() @@ -352,4 +353,8 @@ class SourcePath( files.values .filter { includeHidden || !it.isTemporary } .map { it.apply { parseIfChanged() }.parsed!! } + + override fun close() { + indexAsync.shutdown(true) + } } From c757c703739d71a1360ee1aeb26f55ca8adb3223 Mon Sep 17 00:00:00 2001 From: naturali Date: Thu, 2 Jun 2022 17:17:53 +0800 Subject: [PATCH 2/2] disable a suspicious code block that extracts get/set functions --- .../org/javacs/kt/completion/Completions.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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 aefe4cbfe..726f2d0f6 100644 --- a/server/src/main/kotlin/org/javacs/kt/completion/Completions.kt +++ b/server/src/main/kotlin/org/javacs/kt/completion/Completions.kt @@ -181,14 +181,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)