mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] Do not insert inlay hints when argument variable named is the same as parameter name
#KTIJ-29008 GitOrigin-RevId: 8eb7783713a77d1bccdb06e5c22564c3995c1900
This commit is contained in:
committed by
intellij-monorepo-bot
parent
baafb50e56
commit
0c59c0441d
+5
@@ -99,10 +99,15 @@ class KtParameterHintsProvider : AbstractKtInlayHintsProvider() {
|
||||
val argument = arguments[index]
|
||||
val symbolName = symbol.name
|
||||
val name: Name = symbolName
|
||||
// do not put inlay hints for a named argument
|
||||
if (argument.isNamed()) {
|
||||
// it is possible to place named argument in a wrong position when there is some default value
|
||||
// after which you have to name rest arguments and no reason to proceed further
|
||||
if (argument.getArgumentName()?.asName != name) break
|
||||
continue
|
||||
}
|
||||
// avoid cases like "`value:` value"
|
||||
if (argument.text == name.asString()) continue
|
||||
|
||||
name.takeUnless(Name::isSpecial)?.asString()?.let { stringName ->
|
||||
sink.addPresentation(InlineInlayPosition(argument.startOffset, true), hasBackground = true) {
|
||||
|
||||
+15
-4
@@ -1,6 +1,17 @@
|
||||
fun foo(index: Int, firstName: String = "John", lastName: String = "Smith") {
|
||||
|
||||
}
|
||||
fun foo(index: Int, firstName: String = "John", lastName: String = "Smith") {}
|
||||
fun simpleFun1(name: String){}
|
||||
fun simpleFun2(name: String){}
|
||||
fun simpleFun2(name: String, value: Int){}
|
||||
|
||||
val f = foo(/*<# [namedParameters.kt:8]index|: #>*/0, lastName = "Johnson")
|
||||
val f2 = foo(/*<# [namedParameters.kt:8]index|: #>*/0, firstName = "Joe", /*<# [namedParameters.kt:48]lastName|: #>*/"Johnson")
|
||||
val f2 = foo(/*<# [namedParameters.kt:8]index|: #>*/0, firstName = "Joe", /*<# [namedParameters.kt:48]lastName|: #>*/"Johnson")
|
||||
fun m() {
|
||||
val name = "name"
|
||||
val n = "name"
|
||||
simpleFun0()
|
||||
simpleFun1(/*<# [namedParameters.kt:94]name|: #>*/"name")
|
||||
simpleFun1(name)
|
||||
simpleFun1(/*<# [namedParameters.kt:94]name|: #>*/n)
|
||||
simpleFun2(name)
|
||||
simpleFun2(/*<# [namedParameters.kt:125]name|: #>*/n)
|
||||
}
|
||||
@@ -1,6 +1,17 @@
|
||||
fun foo(index: Int, firstName: String = "John", lastName: String = "Smith") {
|
||||
|
||||
}
|
||||
fun foo(index: Int, firstName: String = "John", lastName: String = "Smith") {}
|
||||
fun simpleFun1(name: String){}
|
||||
fun simpleFun2(name: String){}
|
||||
fun simpleFun2(name: String, value: Int){}
|
||||
|
||||
val f = foo(<hint text="index:"/>0, lastName = "Johnson")
|
||||
val f2 = foo(<hint text="index:"/>0, firstName = "Joe", <hint text="lastName:"/>"Johnson")
|
||||
val f2 = foo(<hint text="index:"/>0, firstName = "Joe", <hint text="lastName:"/>"Johnson")
|
||||
fun m() {
|
||||
val name = "name"
|
||||
val n = "name"
|
||||
simpleFun0()
|
||||
simpleFun1(<hint text="name:"/>"name")
|
||||
simpleFun1(name)
|
||||
simpleFun1(n)
|
||||
simpleFun2(name)
|
||||
simpleFun2(n)
|
||||
}
|
||||
Reference in New Issue
Block a user