mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-07 22:09:38 +07:00
[kotlin] Do not show parameter inlay hints for default names for functional types without explicit names
#KTIJ-30438 #KTIJ-30439 Fixed GitOrigin-RevId: 3cb11ecaf9ea5faaee1d642b563b80d212e2d9a0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7c0cd2f2b3
commit
3e9d784cfb
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.k2.codeinsight.hints
|
||||
|
||||
import com.intellij.codeInsight.hints.declarative.HintColorKind
|
||||
import com.intellij.codeInsight.hints.declarative.InlayActionData
|
||||
import com.intellij.codeInsight.hints.declarative.InlayTreeSink
|
||||
import com.intellij.codeInsight.hints.declarative.InlineInlayPosition
|
||||
@@ -17,6 +18,7 @@ import org.jetbrains.kotlin.analysis.api.analyze
|
||||
import org.jetbrains.kotlin.analysis.api.resolution.singleFunctionCallOrNull
|
||||
import org.jetbrains.kotlin.analysis.api.resolution.symbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaFunctionSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaValueParameterSymbol
|
||||
import org.jetbrains.kotlin.idea.codeinsights.impl.base.ArgumentNameCommentInfo
|
||||
import org.jetbrains.kotlin.idea.codeinsights.impl.base.isExpectedArgumentNameComment
|
||||
@@ -104,6 +106,10 @@ class KtParameterHintsProvider : AbstractKtInlayHintsProvider() {
|
||||
arguments: MutableList<KtValueArgument>,
|
||||
sink: InlayTreeSink
|
||||
) {
|
||||
// TODO: KTIJ-30439 it should respect parameter names when KT-65846 is fixed
|
||||
if ((this as? KaNamedFunctionSymbol)?.isBuiltinFunctionInvoke == true) {
|
||||
return
|
||||
}
|
||||
for ((index, symbol) in valueParameters.withIndex()) {
|
||||
if (index >= arguments.size) break
|
||||
val argument = arguments[index]
|
||||
@@ -120,7 +126,7 @@ class KtParameterHintsProvider : AbstractKtInlayHintsProvider() {
|
||||
if (argument.isArgumentNamed(symbol)) continue
|
||||
|
||||
name.takeUnless(Name::isSpecial)?.asString()?.let { stringName ->
|
||||
sink.addPresentation(InlineInlayPosition(argument.startOffset, true), hasBackground = true) {
|
||||
sink.addPresentation(InlineInlayPosition(argument.startOffset, true), hintColorKind = HintColorKind.Default) {
|
||||
if (symbol.isVararg) text(Typography.ellipsis.toString())
|
||||
text(stringName,
|
||||
symbol.psi?.createSmartPointer()?.let {
|
||||
|
||||
@@ -35,6 +35,11 @@ public class KtParameterHintsProviderTestGenerated extends AbstractKtParameterHi
|
||||
runTest("../../idea/tests/testData/codeInsight/hints/arguments/blacklisted.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionalTypes.kt")
|
||||
public void testFunctionalTypes() throws Exception {
|
||||
runTest("../../idea/tests/testData/codeInsight/hints/arguments/functionalTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaParameters.kt")
|
||||
public void testJavaParameters() throws Exception {
|
||||
runTest("../../idea/tests/testData/codeInsight/hints/arguments/javaParameters.kt");
|
||||
|
||||
@@ -35,6 +35,11 @@ public class KotlinArgumentsHintsProviderTestGenerated extends AbstractKotlinArg
|
||||
runTest("testData/codeInsight/hints/arguments/blacklisted.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionalTypes.kt")
|
||||
public void testFunctionalTypes() throws Exception {
|
||||
runTest("testData/codeInsight/hints/arguments/functionalTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaParameters.kt")
|
||||
public void testJavaParameters() throws Exception {
|
||||
runTest("testData/codeInsight/hints/arguments/javaParameters.kt");
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fun test(action: (String) -> Unit) {
|
||||
action("hello")
|
||||
}
|
||||
|
||||
fun test2(action: (name: String) -> Unit) {
|
||||
// TODO: should be enabled when KTIJ-30438 is fixed
|
||||
// action(<# name|: #>"hello")
|
||||
}
|
||||
Reference in New Issue
Block a user