-
Notifications
You must be signed in to change notification settings - Fork 244
Fix compatibility issues + bugs #556
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,6 +108,8 @@ class KotlinLanguageServer( | |
| serverCapabilities.renameProvider = Either.forRight(RenameOptions(false)) | ||
| } | ||
|
|
||
| config.workspace.symbolResolveSupport = clientHasWorkspaceSymbolResolveSupport(clientCapabilities) | ||
|
|
||
| @Suppress("DEPRECATION") | ||
| val folders = params.workspaceFolders?.takeIf { it.isNotEmpty() } | ||
| ?: params.rootUri?.let(::WorkspaceFolder)?.let(::listOf) | ||
|
|
@@ -141,6 +143,11 @@ class KotlinLanguageServer( | |
| InitializeResult(serverCapabilities, serverInfo) | ||
| } | ||
|
|
||
| private fun clientHasWorkspaceSymbolResolveSupport(clientCapabilities: ClientCapabilities) = | ||
| clientCapabilities?.workspace?.symbol?.resolveSupport?.properties?.let { properties -> | ||
| if (properties.size > 0) SymbolResolveSupport(true, properties) else null | ||
| } ?: SymbolResolveSupport(false, emptyList()) | ||
|
||
|
|
||
| private fun connectLoggingBackend() { | ||
| val backend: (LogMessage) -> Unit = { | ||
| client.logMessage(MessageParams().apply { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |||||
| package org.javacs.kt.symbols | ||||||
|
|
||||||
| import com.intellij.psi.PsiElement | ||||||
| import org.eclipse.lsp4j.Location | ||||||
| import org.eclipse.lsp4j.SymbolInformation | ||||||
| import org.eclipse.lsp4j.SymbolKind | ||||||
| import org.eclipse.lsp4j.DocumentSymbol | ||||||
|
|
@@ -11,9 +12,9 @@ import org.eclipse.lsp4j.WorkspaceSymbolLocation | |||||
| import org.eclipse.lsp4j.jsonrpc.messages.Either | ||||||
| import org.javacs.kt.SourcePath | ||||||
| import org.javacs.kt.position.range | ||||||
| import org.javacs.kt.position.toURIString | ||||||
| import org.javacs.kt.util.containsCharactersInOrder | ||||||
| import org.javacs.kt.util.preOrderTraversal | ||||||
| import org.javacs.kt.util.toPath | ||||||
| import org.jetbrains.kotlin.psi.* | ||||||
| import org.jetbrains.kotlin.psi.psiUtil.parents | ||||||
|
|
||||||
|
|
@@ -33,10 +34,10 @@ private fun doDocumentSymbols(element: PsiElement): List<DocumentSymbol> { | |||||
| } ?: children | ||||||
| } | ||||||
|
|
||||||
| fun workspaceSymbols(query: String, sp: SourcePath): List<WorkspaceSymbol> = | ||||||
| fun workspaceSymbols(locationRequired: Boolean, query: String, sp: SourcePath): List<WorkspaceSymbol> = | ||||||
|
||||||
| doWorkspaceSymbols(sp) | ||||||
| .filter { containsCharactersInOrder(it.name!!, query, false) } | ||||||
| .mapNotNull(::workspaceSymbol) | ||||||
| .mapNotNull(workspaceSymbol(locationRequired)) | ||||||
| .toList() | ||||||
|
|
||||||
| private fun doWorkspaceSymbols(sp: SourcePath): Sequence<KtNamedDeclaration> = | ||||||
|
|
@@ -56,10 +57,28 @@ private fun pickImportantElements(node: PsiElement, includeLocals: Boolean): KtN | |||||
| else -> null | ||||||
| } | ||||||
|
|
||||||
| private fun workspaceSymbol(d: KtNamedDeclaration): WorkspaceSymbol? { | ||||||
| val name = d.name ?: return null | ||||||
| private fun workspaceSymbol(locationRequired: Boolean): (KtNamedDeclaration) -> WorkspaceSymbol? { | ||||||
|
||||||
| private fun workspaceSymbol(locationRequired: Boolean): (KtNamedDeclaration) -> WorkspaceSymbol? { | |
| private fun workspaceSymbol(declaration: KtNamedDeclaration, locationRequired: Boolean): WorkspaceSymbol? { |
This would keep the naming pattern more consistent too (most singular thing-named functions also return the thing in question and not a function).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Configuration classes are intended to map (1-to-1) to the user-provided configuration. I'm not sure how I feel about adding a special case for a value derived from the client capabilities. IMO it would probably be better to just pass the client capabilities to
KotlinWorkspaceServicedirectly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no problem, I change it to pass the client capabilities into the KotlinWorkspaceService