Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge00 #607

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/src/main/kotlin/org/javacs/kt/CompilerClassPath.kt
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class CompilerClassPath(

override fun close() {
compiler.close()
async.shutdown(true)
outputDirectory.delete()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class KotlinLanguageServer(
override fun close() {
textDocumentService.close()
classPath.close()
sourcePath.close()
tempDirectory.close()
async.shutdown(awaitTermination = true)
}
Expand Down
7 changes: 6 additions & 1 deletion server/src/main/kotlin/org/javacs/kt/SourcePath.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,7 +26,7 @@ class SourcePath(
private val contentProvider: URIContentProvider,
private val indexingConfig: IndexingConfiguration,
private val databaseService: DatabaseService
) {
): Closeable {
private val files = mutableMapOf<URI, SourceFile>()
private val parseDataWriteLock = ReentrantLock()

Expand Down Expand Up @@ -354,4 +355,8 @@ class SourcePath(
files.values
.filter { includeHidden || !it.isTemporary }
.map { it.apply { parseIfChanged() }.parsed!! }

override fun close() {
indexAsync.shutdown(true)
}
}
17 changes: 9 additions & 8 deletions server/src/main/kotlin/org/javacs/kt/completion/Completions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
// }
Comment on lines +187 to +195
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to correctly reference getters/setters from Java, per Kotlin's automatic renaming


if (KotlinBuiltIns.isDeprecated(d)) {
result.tags = listOf(CompletionItemTag.Deprecated)
Expand Down
Loading