diff --git a/platform/lang-api/src/com/intellij/codeInsight/hints/InlayParameterHintsProvider.kt b/platform/lang-api/src/com/intellij/codeInsight/hints/InlayParameterHintsProvider.kt index 707b025ca444..26cf5386ef2a 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/hints/InlayParameterHintsProvider.kt +++ b/platform/lang-api/src/com/intellij/codeInsight/hints/InlayParameterHintsProvider.kt @@ -20,13 +20,17 @@ import com.intellij.lang.Language import com.intellij.lang.LanguageExtension -object InlayParameterHintsExtension: LanguageExtension("com.intellij.codeInsight.parameterNameHints") +object InlayParameterHintsExtension : LanguageExtension("com.intellij.codeInsight.parameterNameHints") -class InlayInfo(val text: String, val offset: Int, val isShowOnlyIfExistedBefore: Boolean) { - - constructor(text: String, offset: Int): this(text, offset, false) - +class InlayInfo(val text: String, + val offset: Int, + val isShowOnlyIfExistedBefore: Boolean, + val isFilterByBlacklist: Boolean) { + + constructor(text: String, offset: Int, isShowOnlyIfExistedBefore: Boolean) : this(text, offset, isShowOnlyIfExistedBefore, true) + constructor(text: String, offset: Int) : this(text, offset, false, true) + override fun equals(other: Any?): Boolean { if (this === other) return true if (other?.javaClass != javaClass) return false @@ -54,7 +58,7 @@ sealed class HintInfo { * @language in case you want to put this method into blacklist of another language */ open class MethodInfo(val fullyQualifiedName: String, val paramNames: List, val language: Language?) : HintInfo() { - constructor(fullyQualifiedName: String, paramNames: List): this(fullyQualifiedName, paramNames, null) + constructor(fullyQualifiedName: String, paramNames: List) : this(fullyQualifiedName, paramNames, null) open fun getMethodName(): String { val start = fullyQualifiedName.lastIndexOf('.') + 1 @@ -63,15 +67,15 @@ sealed class HintInfo { } open class OptionInfo(protected val option: Option) : HintInfo() { - + open fun disable() = alternate() open fun enable() = alternate() - + private fun alternate() { val current = option.get() option.set(!current) } - + open val optionName = option.name fun isOptionEnabled(): Boolean = option.isEnabled() diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hints/ParameterHintsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/hints/ParameterHintsPass.java index 754a68efa532..70f911dab9cd 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hints/ParameterHintsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hints/ParameterHintsPass.java @@ -31,6 +31,7 @@ import gnu.trove.TIntObjectHashMap; import org.jetbrains.annotations.NotNull; import java.util.List; +import java.util.stream.Stream; import static com.intellij.codeInsight.hints.ParameterHintsPassFactory.putCurrentPsiModificationStamp; @@ -71,18 +72,24 @@ public class ParameterHintsPass extends EditorBoundHighlightingPass { List hints = provider.getParameterHints(element); if (hints.isEmpty()) return; HintInfo info = provider.getHintInfo(element); - if (info == null || myHintInfoFilter.showHint(info)) { - hints.forEach((hint) -> { - String presentation = provider.getInlayPresentation(hint.getText()); - int offset = hint.getOffset(); - if (hint.isShowOnlyIfExistedBefore()) { - myShowOnlyIfExistedBeforeHints.put(offset, presentation); - } - else { - myHints.put(offset, presentation); - } - }); + + boolean showHints = info == null || info instanceof HintInfo.OptionInfo || myHintInfoFilter.showHint(info); + + Stream inlays = hints.stream(); + if (!showHints) { + inlays = inlays.filter((inlayInfo -> !inlayInfo.isFilterByBlacklist())); } + + inlays.forEach((hint) -> { + String presentation = provider.getInlayPresentation(hint.getText()); + int offset = hint.getOffset(); + if (hint.isShowOnlyIfExistedBefore()) { + myShowOnlyIfExistedBeforeHints.put(offset, presentation); + } + else { + myHints.put(offset, presentation); + } + }); } @Override