[kotlin] Do not show a parameter inlay hint when parameter has the same prefix as parameter name

#KTIJ-32872

GitOrigin-RevId: 0e2031d47e3ce3a2f0519a73adf4964f814861bb
This commit is contained in:
Vladimir Dolzhenko
2025-01-31 17:31:48 +00:00
committed by intellij-monorepo-bot
parent bd4b175d97
commit c46cf087d1
2 changed files with 13 additions and 3 deletions
@@ -141,8 +141,11 @@ class KtParameterHintsProvider : AbstractKtInlayHintsProvider() {
val symbolName = symbol.name.asString()
if (argumentText == symbolName) return true
// avoid cases like "`value =` myValue"
if (symbolName.length > 1 && argumentText.endsWith(symbolName[0].uppercaseChar() + symbolName.substring(1))) return true
if (symbolName.length > 1) {
val name = symbolName[0].uppercaseChar() + symbolName.substring(1)
// avoid cases like "`type = Type(...)`" and "`value =` myValue"
if (argumentText.startsWith(name) || argumentText.endsWith(name)) return true
}
// avoid cases like "/* value = */ value"
var sibling: PsiElement? = this.prevSibling
@@ -17,4 +17,11 @@ fun m() {
simpleFun2(name)
simpleFun2(myName)
simpleFun2(/*<# [namedParameters.kt:125]name| = #>*/n)
}
}
class Buzz(val name: String)
fun buzzyFun(buzz: Buzz) {
buzzyFun(Buzz(name))
buzzyFun(Buzz(/*<# [namedParameters.kt:546]name| = #>*/"me"))
}