mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-117883 make <--tooltip end--> logic work in Inspections View; provide additional tooltip bounds
This commit is contained in:
+2
-16
@@ -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 = "<!-- 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("<!-- tooltip end -->");
|
||||
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 + "<p>" + description + BORDER_LINE;
|
||||
|
||||
@@ -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("</td></tr></table>");
|
||||
myHTMLViewer.setText(XmlStringUtil.wrapInHtml(page));
|
||||
|
||||
+19
@@ -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("<!-- tooltip end -->");
|
||||
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) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<body>
|
||||
<font face="verdana" size="-1">This inspection reports all fields, methods or classes, found in the specified inspection
|
||||
scope, that may have a <b><font color="#000080">final</font></b> modifier added to their declarations.<br><br>
|
||||
<!-- tooltip end -->
|
||||
Use check boxes in the inspection options below, to define which declarations are to be reported.</font>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<body>
|
||||
<font face="verdana" size="-1">
|
||||
This inspection detects violations of rules specified for dependency validation.<br><br>
|
||||
<!-- tooltip end -->
|
||||
Use the "Configure dependency rules" button below to customize validation rules.
|
||||
</font>
|
||||
</body>
|
||||
|
||||
@@ -8,8 +8,9 @@ Note that a method containing only the <b><font color="#000080">super()</font></
|
||||
call and passing its own parameter is also considered empty.
|
||||
<br><br>
|
||||
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.
|
||||
<!-- tooltip end -->
|
||||
Additional annotations can be configured below.
|
||||
</font>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
- required tag is missing<br>
|
||||
- invalid or incomplete tag<br>
|
||||
- javadoc description is missing or incomplete<br><br>
|
||||
<!-- tooltip end -->
|
||||
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.</font>
|
||||
</body>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<body>
|
||||
<font face="verdana" size="-1">Shows custom html attributes in html or jsp.<br>
|
||||
<br>
|
||||
<!-- tooltip end -->
|
||||
Use options below to add attributes to known custom attributes list.</font>
|
||||
</body>
|
||||
</html>
|
||||
@@ -2,6 +2,7 @@
|
||||
<body>
|
||||
<font face="verdana" size="-1">Shows custom html tags in html or jsp.<br>
|
||||
<br>
|
||||
<!-- tooltip end -->
|
||||
Use options below to add tags to known custom tags list.</font>
|
||||
</body>
|
||||
</html>
|
||||
@@ -2,6 +2,7 @@
|
||||
<body>
|
||||
<font face="verdana" size="-1">Shows not required html attributes in html or jsp.<br>
|
||||
<br>
|
||||
<!-- tooltip end -->
|
||||
Use options below to add attributes to not required attributes list.</font>
|
||||
</body>
|
||||
</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.
|
||||
<br>Can ignore members that are annotated in a special way, for example, by EJB annotation javax.ejb.EJB.
|
||||
<!-- tooltip end -->
|
||||
Additional annotations can be configured below.
|
||||
<br>
|
||||
The <b>Report unused parameters in non-private method</b> setting is used to
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<body>
|
||||
<font face="verdana" size="-1">This inspection reports classes, methods or fields in the specified inspection scope that
|
||||
are not used or not reachable from entry points.<br><br>
|
||||
<!-- tooltip end -->
|
||||
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.</font>
|
||||
</body>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<body>
|
||||
<font face="verdana" size="-1">This inspection reports all fields, methods or classes, found in the specified inspection
|
||||
scope, that may have their access modifier narrowed down.<br><br>
|
||||
<!-- tooltip end -->
|
||||
Use check boxes in the inspection options below, to define rules for the modifier change suggestions.</font>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user