From 78aa878e1e320afff58b7a6fc2956d2fe87d83c7 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 9 Dec 2013 19:04:55 +0400 Subject: [PATCH] IDEA-117883 make <--tooltip end--> logic work in Inspections View; provide additional tooltip bounds --- .../impl/DaemonTooltipRendererProvider.java | 18 ++---------------- .../intellij/codeInspection/ui/Browser.java | 2 +- .../ui/DefaultInspectionToolPresentation.java | 19 +++++++++++++++++++ .../inspectionDescriptions/CanBeFinal.html | 1 + .../inspectionDescriptions/Dependency.html | 1 + .../inspectionDescriptions/EmptyMethod.html | 5 +++-- .../src/inspectionDescriptions/JavaDoc.html | 1 + .../Local_CustomHtmlAttributes.html | 1 + .../Local_CustomHtmlTags.html | 1 + .../Local_NotRequiredHtmlAttributes.html | 1 + .../inspectionDescriptions/UNUSED_SYMBOL.html | 1 + .../UnusedDeclaration.html | 1 + .../inspectionDescriptions/WeakerAccess.html | 1 + 13 files changed, 34 insertions(+), 19 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java index c37adbf42774..4451797b3b26 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java @@ -24,6 +24,7 @@ import com.intellij.codeInsight.daemon.impl.actions.ShowErrorDescriptionAction; import com.intellij.codeInsight.hint.LineTooltipRenderer; import com.intellij.codeInsight.hint.TooltipLinkHandlerEP; import com.intellij.codeInsight.hint.TooltipRenderer; +import com.intellij.codeInspection.ui.DefaultInspectionToolPresentation; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.ex.ErrorStripTooltipRendererProvider; import com.intellij.openapi.editor.impl.TrafficTooltipRenderer; @@ -42,8 +43,6 @@ import javax.swing.*; import java.util.Collection; import java.util.Comparator; import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; public class DaemonTooltipRendererProvider implements ErrorStripTooltipRendererProvider { @NonNls private static final String END_MARKER = ""; @@ -143,20 +142,7 @@ public class DaemonTooltipRendererProvider implements ErrorStripTooltipRendererP if (ref != null) { String description = TooltipLinkHandlerEP.getDescription(ref, editor); if (description != null) { - description = UIUtil.getHtmlBody(description); - final int descriptionEnd = description.indexOf(""); - if (descriptionEnd < 0) { - final Pattern pattern = Pattern.compile(".*Use.*(the (panel|checkbox|checkboxes|field|button|controls).*below).*", Pattern.DOTALL); - final Matcher matcher = pattern.matcher(description); - int startFindIdx = 0; - while (matcher.find(startFindIdx)) { - final int end = matcher.end(1); - startFindIdx = end; - description = description.substring(0, matcher.start(1)) + " inspection settings " + description.substring(end); - } - } else { - description = description.substring(0, descriptionEnd); - } + description = DefaultInspectionToolPresentation.stripUIRefsFromInspectionDescription(UIUtil.getHtmlBody(description)); text += UIUtil.getHtmlBody(problem).replace(DaemonBundle.message("inspection.extended.description"), DaemonBundle.message("inspection.collapse.description")) + END_MARKER + "

" + description + BORDER_LINE; diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java index 2dc1cf0b1b4c..9db2d9e1afdf 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java @@ -450,7 +450,7 @@ class Browser extends JPanel { if (description == null) { description = underConstruction; } - page.append(UIUtil.getHtmlBody(description)); + page.append(DefaultInspectionToolPresentation.stripUIRefsFromInspectionDescription(UIUtil.getHtmlBody(description))); page.append(""); myHTMLViewer.setText(XmlStringUtil.wrapInHtml(page)); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java index 212489bda65f..fe7c3ab22b81 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java @@ -51,6 +51,8 @@ import org.jetbrains.annotations.Nullable; import javax.swing.tree.DefaultTreeModel; import java.io.*; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class DefaultInspectionToolPresentation implements ProblemDescriptionsProcessor, InspectionToolPresentation { @NotNull private final InspectionToolWrapper myToolWrapper; @@ -91,6 +93,23 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro return FileStatus.NOT_CHANGED; } + public static String stripUIRefsFromInspectionDescription(String description) { + final int descriptionEnd = description.indexOf(""); + if (descriptionEnd < 0) { + final Pattern pattern = Pattern.compile(".*Use.*(the (panel|checkbox|checkboxes|field|button|controls).*below).*", Pattern.DOTALL); + final Matcher matcher = pattern.matcher(description); + int startFindIdx = 0; + while (matcher.find(startFindIdx)) { + final int end = matcher.end(1); + startFindIdx = end; + description = description.substring(0, matcher.start(1)) + " inspection settings " + description.substring(end); + } + } else { + description = description.substring(0, descriptionEnd); + } + return description; + } + protected HighlightSeverity getSeverity(@NotNull RefElement element) { final PsiElement psiElement = element.getPointer().getContainingFile(); if (psiElement != null) { diff --git a/resources-en/src/inspectionDescriptions/CanBeFinal.html b/resources-en/src/inspectionDescriptions/CanBeFinal.html index d293049398f2..8caa55327e0b 100644 --- a/resources-en/src/inspectionDescriptions/CanBeFinal.html +++ b/resources-en/src/inspectionDescriptions/CanBeFinal.html @@ -2,6 +2,7 @@ This inspection reports all fields, methods or classes, found in the specified inspection scope, that may have a final modifier added to their declarations.

+ Use check boxes in the inspection options below, to define which declarations are to be reported.
diff --git a/resources-en/src/inspectionDescriptions/Dependency.html b/resources-en/src/inspectionDescriptions/Dependency.html index 387aeea22871..706c0e1b317b 100644 --- a/resources-en/src/inspectionDescriptions/Dependency.html +++ b/resources-en/src/inspectionDescriptions/Dependency.html @@ -2,6 +2,7 @@ This inspection detects violations of rules specified for dependency validation.

+ Use the "Configure dependency rules" button below to customize validation rules.
diff --git a/resources-en/src/inspectionDescriptions/EmptyMethod.html b/resources-en/src/inspectionDescriptions/EmptyMethod.html index a8077ffd129e..636fa4e5ee7d 100644 --- a/resources-en/src/inspectionDescriptions/EmptyMethod.html +++ b/resources-en/src/inspectionDescriptions/EmptyMethod.html @@ -8,8 +8,9 @@ Note that a method containing only the super()
This inspection is automatically suppressed for methods annotated with special annotations, -for example, EJB annotations javax.ejb.Init and javax.ejb.Remove. Additional annotations -can be configured below. +for example, EJB annotations javax.ejb.Init and javax.ejb.Remove. + +Additional annotations can be configured below. diff --git a/resources-en/src/inspectionDescriptions/JavaDoc.html b/resources-en/src/inspectionDescriptions/JavaDoc.html index e042b7d9dde1..e364c436d411 100644 --- a/resources-en/src/inspectionDescriptions/JavaDoc.html +++ b/resources-en/src/inspectionDescriptions/JavaDoc.html @@ -5,6 +5,7 @@  - required tag is missing
 - invalid or incomplete tag
 - javadoc description is missing or incomplete

+ Use tabs and corresponding inspection options below, to define visibility scope where javadoc is required, as well as the required javadoc tags for classes, methods, fields and inner classes. diff --git a/resources-en/src/inspectionDescriptions/Local_CustomHtmlAttributes.html b/resources-en/src/inspectionDescriptions/Local_CustomHtmlAttributes.html index df86302fb8d6..42b845bcf17b 100644 --- a/resources-en/src/inspectionDescriptions/Local_CustomHtmlAttributes.html +++ b/resources-en/src/inspectionDescriptions/Local_CustomHtmlAttributes.html @@ -2,6 +2,7 @@ Shows custom html attributes in html or jsp.

+ Use options below to add attributes to known custom attributes list.
\ No newline at end of file diff --git a/resources-en/src/inspectionDescriptions/Local_CustomHtmlTags.html b/resources-en/src/inspectionDescriptions/Local_CustomHtmlTags.html index ebe99cedde9d..595cdf33abaa 100644 --- a/resources-en/src/inspectionDescriptions/Local_CustomHtmlTags.html +++ b/resources-en/src/inspectionDescriptions/Local_CustomHtmlTags.html @@ -2,6 +2,7 @@ Shows custom html tags in html or jsp.

+ Use options below to add tags to known custom tags list.
\ No newline at end of file diff --git a/resources-en/src/inspectionDescriptions/Local_NotRequiredHtmlAttributes.html b/resources-en/src/inspectionDescriptions/Local_NotRequiredHtmlAttributes.html index 0637e65f8f23..4b4b6b4cd524 100644 --- a/resources-en/src/inspectionDescriptions/Local_NotRequiredHtmlAttributes.html +++ b/resources-en/src/inspectionDescriptions/Local_NotRequiredHtmlAttributes.html @@ -2,6 +2,7 @@ Shows not required html attributes in html or jsp.

+ Use options below to add attributes to not required attributes list.
\ No newline at end of file diff --git a/resources-en/src/inspectionDescriptions/UNUSED_SYMBOL.html b/resources-en/src/inspectionDescriptions/UNUSED_SYMBOL.html index 6197860721e9..b6a8b50dfed5 100644 --- a/resources-en/src/inspectionDescriptions/UNUSED_SYMBOL.html +++ b/resources-en/src/inspectionDescriptions/UNUSED_SYMBOL.html @@ -4,6 +4,7 @@ Detects local variables and private members that are declared but not used, never accessed for reading or not initialized in a class.
Can ignore members that are annotated in a special way, for example, by EJB annotation javax.ejb.EJB. + Additional annotations can be configured below.
The Report unused parameters in non-private method setting is used to diff --git a/resources-en/src/inspectionDescriptions/UnusedDeclaration.html b/resources-en/src/inspectionDescriptions/UnusedDeclaration.html index f2204d0bddab..07da616e05da 100644 --- a/resources-en/src/inspectionDescriptions/UnusedDeclaration.html +++ b/resources-en/src/inspectionDescriptions/UnusedDeclaration.html @@ -2,6 +2,7 @@ This inspection reports classes, methods or fields in the specified inspection scope that are not used or not reachable from entry points.

+ Use check boxes in the inspection options below, to specify what should be automatically assumed entry points. You will also have a possibility to add entry points manually when inspection results are ready.
diff --git a/resources-en/src/inspectionDescriptions/WeakerAccess.html b/resources-en/src/inspectionDescriptions/WeakerAccess.html index 55b124db84e6..190d36091402 100644 --- a/resources-en/src/inspectionDescriptions/WeakerAccess.html +++ b/resources-en/src/inspectionDescriptions/WeakerAccess.html @@ -2,6 +2,7 @@ This inspection reports all fields, methods or classes, found in the specified inspection scope, that may have their access modifier narrowed down.

+ Use check boxes in the inspection options below, to define rules for the modifier change suggestions.