diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/inlays/ToggleInlineHintsActionTest.kt b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/inlays/ToggleInlineHintsActionTest.kt deleted file mode 100644 index 50ce949d23c2..000000000000 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/inlays/ToggleInlineHintsActionTest.kt +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.java.codeInsight.daemon.inlays - -import com.intellij.codeInsight.hints.isPossibleHintNearOffset -import com.intellij.openapi.editor.ex.EditorSettingsExternalizable -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase -import org.assertj.core.api.Assertions.assertThat - -class ToggleInlineHintsActionTest : LightCodeInsightFixtureTestCase() { - - private var before: Boolean = false - - override fun setUp() { - super.setUp() - before = EditorSettingsExternalizable.getInstance().isShowParameterNameHints - EditorSettingsExternalizable.getInstance().isShowParameterNameHints = false - } - - override fun tearDown() { - EditorSettingsExternalizable.getInstance().isShowParameterNameHints = before - super.tearDown() - } - - fun `test is enabled near method with possible hints`() { - myFixture.configureByText("A.java", """" -class Test { - Test(int time) {} - void initialize(int loadTime) {} - static void s_test() { - Test test = new Test(10); - test.initialize(10000); - } -} -""") - - val file = myFixture.file - val caretModel = myFixture.editor.caretModel - - assertThat(caretModel.caretCount).isEqualTo(4) - - editor.caretModel.allCarets.forEach { - val hintCanBeAtCaret = isPossibleHintNearOffset(file, it.offset) - assertThat(hintCanBeAtCaret).isTrue() - } - } - - fun `test is disabled in random places`() { - myFixture.configureByText("A.java", """" -class Test { - static void s_test() { - int a = 2; - List list = null; - } -} -""") - - val file = myFixture.file - val caretModel = myFixture.editor.caretModel - - assertThat(caretModel.caretCount).isEqualTo(3) - - editor.caretModel.allCarets.forEach { - val hintCanBeAtCaret = isPossibleHintNearOffset(file, it.offset) - assertThat(hintCanBeAtCaret).isFalse() - } - } - -} \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hints/PopupActions.kt b/platform/lang-impl/src/com/intellij/codeInsight/hints/PopupActions.kt index 0b991940a4a9..7cb1774d4b63 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hints/PopupActions.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/hints/PopupActions.kt @@ -29,7 +29,6 @@ import com.intellij.lang.Language import com.intellij.notification.Notification import com.intellij.notification.NotificationListener import com.intellij.notification.NotificationType -import com.intellij.openapi.actionSystem.ActionPlaces import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.CommonDataKeys @@ -275,22 +274,6 @@ class ToggleInlineHintsAction : AnAction() { val isHintsShownNow = EditorSettingsExternalizable.getInstance().isShowParameterNameHints e.presentation.text = if (isHintsShownNow) disableText else enableText e.presentation.isEnabledAndVisible = true - - if (isInMainEditorPopup(e)) { - val file = CommonDataKeys.PSI_FILE.getData(e.dataContext) ?: return - val editor = CommonDataKeys.EDITOR.getData(e.dataContext) ?: return - val caretOffset = editor.caretModel.offset - e.presentation.isEnabledAndVisible = !isHintsShownNow && isPossibleHintNearOffset(file, caretOffset) - } - } - - private fun isInMainEditorPopup(e: AnActionEvent): Boolean { - if (e.place != ActionPlaces.EDITOR_POPUP) return false - - val editor = CommonDataKeys.EDITOR.getData(e.dataContext) ?: return false - val offset = editor.caretModel.offset - - return !editor.inlayModel.hasInlineElementAt(offset) } override fun actionPerformed(e: AnActionEvent) { @@ -349,21 +332,6 @@ fun PsiElement.isOwnsInlayInEditor(editor: Editor): Boolean { return !editor.inlayModel.getInlineElementsInRange(start, textRange.endOffset).isEmpty() } -fun isPossibleHintNearOffset(file: PsiFile, offset: Int): Boolean { - val hintProvider = InlayParameterHintsExtension.forLanguage(file.language) ?: return false - - var element = file.findElementAt(offset) - for (i in 0..3) { - if (element == null) return false - - val hints = hintProvider.getParameterHints(element) - if (hints.isNotEmpty()) return true - element = element.parent - } - - return false -} - fun MethodInfo.toPattern() = this.fullyQualifiedName + '(' + this.paramNames.joinToString(",") + ')' diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml index 9071d8e57bc3..4f71957ddfce 100644 --- a/platform/platform-resources/src/idea/LangActions.xml +++ b/platform/platform-resources/src/idea/LangActions.xml @@ -304,7 +304,6 @@ -