From 604e270a732532e04297deca624ff235e1c53962 Mon Sep 17 00:00:00 2001 From: Andrei Klunnyi Date: Wed, 8 Jul 2020 19:39:26 +0200 Subject: [PATCH] KT-32368 Rework Inline hints settings // preview text --- .../hints/KotlinInlayParameterHintsProvider.kt | 13 +++++++++++++ .../hints/KotlinLambdasHintsProvider.kt | 13 +++++++++++++ .../hints/KotlinReferencesTypeHintsProvider.kt | 18 ++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinInlayParameterHintsProvider.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinInlayParameterHintsProvider.kt index d99bff37c6a..740b9407b37 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinInlayParameterHintsProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinInlayParameterHintsProvider.kt @@ -28,6 +28,19 @@ class KotlinInlayParameterHintsProvider : InlayParameterHintsProvider { "*SequenceBuilder.resume(value)", "*SequenceBuilder.yield(value)" ) + override fun getSettingsPreview(): String { + return """ + fun callsAnotherFun() { + anotherFunction(1, 2) + } + + fun anotherFunction(a: Int = 10, b: Int = 5): Int { + val sum = a + b + return sum * 2 + } + """.trimIndent() + } + override fun getHintInfo(element: PsiElement): HintInfo? { if (!(HintType.PARAMETER_HINT.isApplicable(element))) return null val parent: PsiElement = (element as? KtValueArgumentList)?.parent ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinLambdasHintsProvider.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinLambdasHintsProvider.kt index 0ab0e0f5398..8b9b5c9fe72 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinLambdasHintsProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinLambdasHintsProvider.kt @@ -83,4 +83,17 @@ class KotlinLambdasHintsProvider : KotlinAbstractHintsProvider + i + 10 + i + 20 + } + + fun someFun() { + GlobalScope.launch { + // someSuspendingFun() + } + } + """.trimIndent() } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinReferencesTypeHintsProvider.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinReferencesTypeHintsProvider.kt index 86d20412a86..53ec870ade0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinReferencesTypeHintsProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinReferencesTypeHintsProvider.kt @@ -66,4 +66,22 @@ class KotlinReferencesTypeHintsProvider : KotlinAbstractHintsProvider false } } + + override val previewText: String? = """ + val property = listOf(1, 2, 3).filter { num -> num % 2 == 0 } + + fun someFun(arg: Int) = print(arg) + + fun anotherFun(a: Int = 10, b: Int = 5): Int { + val variable = a + b + return variable * 2 + } + + fun yetAnotherFun() { + Stream.of(1, 2, 3) + .map { i -> i + 12 } + .filter { i -> i % 2 == 0 } + .collect(Collectors.toList()) + } + """.trimIndent() } \ No newline at end of file