From 587da28340aca8635132d8fd361c62acb843aeb8 Mon Sep 17 00:00:00 2001 From: Piotr Tomiak Date: Thu, 7 Mar 2024 16:50:28 +0100 Subject: [PATCH] IJPL-787 JBHtmlPane: add support for rendering
- no need to override
behavior in tooltips GitOrigin-RevId: c1284dade5c328b235a926def092e28fd5ace43f --- .../java/codeInsight/JavaDocumentationTest.kt | 10 ++++---- .../com/intellij/ide/IdeTooltipManager.java | 24 ++----------------- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/JavaDocumentationTest.kt b/java/java-tests/testSrc/com/intellij/java/codeInsight/JavaDocumentationTest.kt index c43d1e6bd3c9..278cd0eb15d0 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/JavaDocumentationTest.kt +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/JavaDocumentationTest.kt @@ -289,11 +289,11 @@ class JavaDocumentationTest : LightJavaCodeInsightFixtureTestCase() { val actual = JavaExternalDocumentationTest.getDocumentationText(myFixture.project, input) - val expected = "
Candidates for method call s.regionMatches() are:
" + + val expected = "

Candidates for method call s.regionMatches() are:
" + "
" + "  boolean regionMatches(int, String, int, int)
" + "  boolean regionMatches(boolean, int, String, int, int)
" + - "

" + "

" TestCase.assertEquals(expected, actual) } @@ -309,11 +309,11 @@ class JavaDocumentationTest : LightJavaCodeInsightFixtureTestCase() { val documentationManager = DocumentationManager.getInstance(myFixture.project) JavaExternalDocumentationTest.getDocumentationText(myFixture.project, input) { component -> - val expected = "
Candidates for method call s.regionMatches() are:
" + + val expected = "

Candidates for method call s.regionMatches() are:
" + "
" + "  boolean regionMatches(int, String, int, int)
" + "  boolean regionMatches(boolean, int, String, int, int)
" + - "

" + "

" assertEquals(expected, component.decoratedText) documentationManager.navigateByLink(component, null, "psi_element://java.lang.String#regionMatches(int, java.lang.String, int, int)") @@ -326,7 +326,7 @@ class JavaDocumentationTest : LightJavaCodeInsightFixtureTestCase() { // Here we check that the covering module (SDK in this case) is rendered in decorated info assertTrue( - component.decoratedText.contains("
 < java 1.7 >
")) + component.decoratedText.contains("
 < java 1.7 >
")) return@getDocumentationText null } } diff --git a/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java b/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java index 70b441d22ae4..cc8c5a5ba6f8 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java @@ -29,7 +29,6 @@ import com.intellij.ui.components.JBHtmlPane; import com.intellij.ui.components.JBHtmlPaneConfiguration; import com.intellij.ui.components.JBHtmlPaneStyleConfiguration; import com.intellij.ui.components.panels.Wrapper; -import com.intellij.ui.scale.JBUIScale; import com.intellij.util.Alarm; import com.intellij.util.messages.SimpleMessageBusConnection; import com.intellij.util.ui.*; @@ -39,14 +38,9 @@ import org.jetbrains.annotations.*; import javax.swing.*; import javax.swing.border.Border; -import javax.swing.text.AbstractDocument; -import javax.swing.text.AttributeSet; -import javax.swing.text.StyleConstants; -import javax.swing.text.html.HTML; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.MouseEvent; -import java.lang.reflect.Field; import java.util.Collections; // Android team doesn't want to use new mockito for now, so, class cannot be final @@ -722,22 +716,8 @@ public class IdeTooltipManager implements Disposable { JBHtmlPaneConfiguration paneConfiguration = new JBHtmlPaneConfiguration( Collections.emptyMap(), url -> null, icon -> null, color -> StyleSheetUtil.loadStyleSheet("pre {white-space: pre-wrap;} code, pre {overflow-wrap: anywhere;}"), - null, Collections.singletonList( - (elem, view) -> { - AttributeSet attrs = elem.getAttributes(); - if (attrs.getAttribute(AbstractDocument.ElementNameAttribute) == null && - attrs.getAttribute(StyleConstants.NameAttribute) == HTML.Tag.HR) { - try { - Field field = view.getClass().getDeclaredField("size"); - field.setAccessible(true); - field.set(view, JBUIScale.scale(1)); - } - catch (Exception ignored) { - } - } - return view; - } - )); + null, Collections.emptyList() + ); Ref prefSizeWasComputed = new Ref<>(false);