[lsp] use completion from https://github.com/darthorimar/rekot for now until we have a proper document commit

GitOrigin-RevId: 83b1f74d7b907a1670e6d4e8ce309e076f90aaa9
This commit is contained in:
Ilya Kirillov
2025-05-14 18:49:23 +00:00
committed by intellij-monorepo-bot
parent ccaaa440ae
commit fde19b5fb7
2 changed files with 41 additions and 2 deletions
@@ -306,6 +306,36 @@ class KtSymbolFromIndexProvider(
resolveExtensionScopeWithTopLevelDeclarations.callables(nameFilter)
.filterNot { it.isExtension }
/**
* Returns top-level callables, including extensions.
*/
context(KaSession)
@OptIn(KaExperimentalApi::class)
fun getTopLevelCallableSymbolsByNameFilterIncludingExtensions(
nameFilter: (Name) -> Boolean,
scope: GlobalSearchScope = analysisScope,
psiFilter: (KtCallableDeclaration) -> Boolean = { true }
): Sequence<KaCallableSymbol> = sequenceOf(
KotlinTopLevelFunctionFqnNameIndex,
KotlinTopLevelPropertyFqnNameIndex,
).flatMap { helper ->
val results = mutableListOf<KtCallableDeclaration>()
val processor = cancelableCollectFilterProcessor(results) { declaration: KtCallableDeclaration ->
declaration.isAcceptable(psiFilter)
}
helper.processAllElements(
project = project,
scope = scope,
filter = { nameFilter(getShortName(it)) },
processor = processor,
)
results
}.map { it.symbol }
.filterIsInstance<KaCallableSymbol>() +
resolveExtensionScopeWithTopLevelDeclarations.callables(nameFilter)
context(KaSession)
@OptIn(KaExperimentalApi::class)
fun getExtensionCallableSymbolsByName(
@@ -3,6 +3,7 @@
package org.jetbrains.kotlin.idea.completion.lookups
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.kotlin.analysis.api.KaExperimentalApi
import org.jetbrains.kotlin.analysis.api.KaSession
import org.jetbrains.kotlin.analysis.api.signatures.KaCallableSignature
@@ -18,14 +19,22 @@ import org.jetbrains.kotlin.idea.completion.lookups.CompletionShortNamesRenderer
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.renderer.render
internal object TailTextProvider {
@ApiStatus.Internal
object TailTextProvider {
context(KaSession)
fun getTailText(
signature: KaCallableSignature<*>,
): String = buildString {
): String {
// use unsubstituted type when rendering receiver type of extension
val symbol = signature.symbol
return getTailText(symbol)
}
context(KaSession)
fun getTailText(
symbol: KaCallableSymbol,
): String = buildString {
symbol.receiverType?.let { renderReceiverType(it) }
symbol.getContainerPresentation(isFunctionalVariableCall = false)?.let { append(it) }