diff --git a/java/java-impl/src/com/intellij/codeInsight/hints/JavaHintUtils.kt b/java/java-impl/src/com/intellij/codeInsight/hints/JavaHintUtils.kt index 3d2a61e80ab1..65c1952a0bea 100644 --- a/java/java-impl/src/com/intellij/codeInsight/hints/JavaHintUtils.kt +++ b/java/java-impl/src/com/intellij/codeInsight/hints/JavaHintUtils.kt @@ -25,8 +25,6 @@ import com.intellij.psi.util.TypeConversionUtil object JavaInlayHintsProvider { - var isDebug = false - fun createHints(callExpression: PsiCallExpression): Set { val resolveResult = callExpression.resolveMethodGenerics() val hints = createHintsForResolvedMethod(callExpression, resolveResult) @@ -181,8 +179,8 @@ object JavaInlayHintsProvider { else -> false } - if (isDebug) { - println("${callArgument.text} : ${callArgument.javaClass} : isShowHint->$isShowHint") + if (ParameterHintsPassFactory.isDebug()) { + println("${System.nanoTime()}: ${callArgument.text} : ${callArgument.javaClass} : isShowHint->$isShowHint") } return isShowHint diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/inlays/InlayParameterHintsTest.kt b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/inlays/InlayParameterHintsTest.kt index 74f38053cb7e..7a813df4bbb6 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/inlays/InlayParameterHintsTest.kt +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/inlays/InlayParameterHintsTest.kt @@ -17,6 +17,7 @@ package com.intellij.codeInsight.daemon.inlays import com.intellij.codeInsight.daemon.impl.ParameterHintsPresentationManager import com.intellij.codeInsight.hints.InlayInfo +import com.intellij.codeInsight.hints.ParameterHintsPassFactory import com.intellij.codeInsight.hints.settings.ParameterNameHintsSettings import com.intellij.openapi.command.WriteCommandAction import com.intellij.openapi.editor.Document @@ -87,6 +88,11 @@ abstract class InlayParameterHintsTest : LightCodeInsightFixtureTestCase() { myFixture.doHighlighting() val editor = myFixture.editor val allInlays = editor.inlayModel.getInlineElementsInRange(0, editor.document.textLength) + + if (ParameterHintsPassFactory.isDebug()) { + println("${System.nanoTime()}: [HintTests] inlays extracted") + } + val hintManager = ParameterHintsPresentationManager.getInstance() return allInlays .filter { hintManager.isParameterHint(it) } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/inlays/JavaParameterNameHintsTest.kt b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/inlays/JavaParameterNameHintsTest.kt index c0e777b8af87..6e399ba0f8e5 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/inlays/JavaParameterNameHintsTest.kt +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/inlays/JavaParameterNameHintsTest.kt @@ -15,7 +15,7 @@ */ package com.intellij.codeInsight.daemon.inlays -import com.intellij.codeInsight.hints.JavaInlayHintsProvider +import com.intellij.codeInsight.hints.ParameterHintsPassFactory import com.intellij.codeInsight.hints.settings.ParameterNameHintsSettings import com.intellij.lang.java.JavaLanguage @@ -573,7 +573,7 @@ class Key { fun `test poly and binary expressions`() { try { - JavaInlayHintsProvider.isDebug = true + ParameterHintsPassFactory.setDebug(true) check(""" class Test { void test() { @@ -589,7 +589,7 @@ class Test { """) } finally { - JavaInlayHintsProvider.isDebug = false + ParameterHintsPassFactory.setDebug(false) } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hints/ParameterHintsPassFactory.java b/platform/lang-impl/src/com/intellij/codeInsight/hints/ParameterHintsPassFactory.java index 01fd4e930861..b1c04e80ba51 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hints/ParameterHintsPassFactory.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hints/ParameterHintsPassFactory.java @@ -43,6 +43,7 @@ import com.intellij.util.containers.HashSet; import gnu.trove.TIntObjectHashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; import java.util.*; import java.util.stream.Collectors; @@ -50,6 +51,18 @@ import java.util.stream.Collectors; public class ParameterHintsPassFactory extends AbstractProjectComponent implements TextEditorHighlightingPassFactory { private static final Key REPEATED_PASS = Key.create("RepeatedParameterHintsPass"); + private static boolean isDebug = false; + + @TestOnly + public static void setDebug(boolean value) { + isDebug = value; + } + + @TestOnly + public static boolean isDebug() { + return isDebug; + } + public ParameterHintsPassFactory(Project project, TextEditorHighlightingPassRegistrar registrar) { super(project); registrar.registerTextEditorHighlightingPass(this, null, null, false, -1); @@ -91,7 +104,15 @@ public class ParameterHintsPassFactory extends AbstractProjectComponent implemen .filter((e) -> e != null) .collect(Collectors.toList()); + if (isDebug) { + System.out.println(System.nanoTime() + ": [HintsPass] Traversing started"); + } + SyntaxTraverser.psiTraverser(myFile).forEach(element -> process(element, provider, matchers)); + + if (isDebug) { + System.out.println(System.nanoTime() + ": [HintsPass] Traversing ended"); + } } private static Set getBlackList(Language language) {