Skip to content

Commit

Permalink
[kotlin] Exclude parameter names excluded by java inlay param hints p…
Browse files Browse the repository at this point in the history
…rovider

#KTIJ-28679
#KTIJ-32872
#IJPL-166464

GitOrigin-RevId: 4736d42fdb1a5c24a5bb437b25664b3f206e4bd0
  • Loading branch information
vladimirdolzhenko authored and intellij-monorepo-bot committed Feb 1, 2025
1 parent 63d3f41 commit c358ab7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// 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.InlayParameterHintsExtension
import com.intellij.codeInsight.hints.declarative.*
import com.intellij.codeInsight.hints.filtering.Matcher
import com.intellij.codeInsight.hints.filtering.MatcherConstructor
import com.intellij.lang.java.JavaLanguage
import com.intellij.openapi.util.registry.Registry
import com.intellij.psi.PsiComment
import com.intellij.psi.PsiElement
Expand All @@ -28,8 +30,8 @@ import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
import org.jetbrains.kotlin.psi.psiUtil.startOffset

class KtParameterHintsProvider : AbstractKtInlayHintsProvider() {
private val excludeListMatchers: List<Matcher> =
listOf(
private val excludeListMatchers: List<Matcher> by lazy {
(listOf(
"*listOf", "*setOf", "*arrayOf", "*ListOf", "*SetOf", "*ArrayOf", "*assert*(*)", "*mapOf", "*MapOf",
"kotlin.require*(*)", "kotlin.check*(*)", "*contains*(value)", "*containsKey(key)", "kotlin.lazyOf(value)",
"*SequenceBuilder.resume(value)", "*SequenceBuilder.yield(value)",
Expand All @@ -51,7 +53,9 @@ class KtParameterHintsProvider : AbstractKtInlayHintsProvider() {
"org.gradle.kotlin.dsl.project(path,configuration)",
"org.gradle.api.provider.Property.set(value)",
"org.gradle.api.plugins.ObjectConfigurationAction.plugin(pluginId)",
).mapNotNull { MatcherConstructor.createMatcher(it) }
) + InlayParameterHintsExtension.forLanguage(JavaLanguage.INSTANCE).defaultBlackList)
.mapNotNull { MatcherConstructor.createMatcher(it) }
}

override fun collectFromElement(
element: PsiElement,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ fun foo() {
require(true)
requireNotNull(true)
check(true)
// blacklisted from java
buildList {
add("a")
}
println("Kodee")
}

0 comments on commit c358ab7

Please sign in to comment.