'Problems' view in 'Project Structure': fixed escaping of error messages (IDEA-151029)

This commit is contained in:
nik
2016-02-02 11:10:25 +03:00
parent 1dae45eab9
commit db3ea89d4f
5 changed files with 16 additions and 7 deletions
@@ -167,14 +167,15 @@ public class ErrorPaneConfigurable extends JPanel implements Configurable, Dispo
description = problemDescription.getDescription();
if (description == null) {
ProjectStructureElement place = problemDescription.getPlace().getContainingElement();
description = place.getTypeName() + " <a href='http://navigate/" + i + "'>" + place.getPresentableName() + "</a>: " + problemDescription.getMessage(false);
description = place.getTypeName() + " <a href='http://navigate/" + i + "'>" + XmlStringUtil.convertToHtmlContent(place.getPresentableName())
+ "</a>: " + XmlStringUtil.convertToHtmlContent(problemDescription.getMessage(false));
}
else {
description = XmlStringUtil.stripHtml(description);
description = XmlStringUtil.convertToHtmlContent(description);
}
}
else {
description = XmlStringUtil.stripHtml(error.getDescription());
description = XmlStringUtil.convertToHtmlContent(error.getDescription());
}
if (error.canBeFixed()) {
description += " <a href='http://fix/" + i + "'>[Fix]</a>";
@@ -155,7 +155,7 @@ public class LibraryProjectStructureElement extends ProjectStructureElement {
final List<ConfigurationErrorQuickFix> fixes = Arrays.asList(new AddLibraryToDependenciesFix(), new RemoveLibraryFix(), new RemoveAllUnusedLibrariesFix());
final String name = StringUtil.escapeXml(myLibrary.getName());
String libraryName = "<a href='http://library/" + name + "'>" + name + "</a>";
return new ProjectStructureProblemDescription("Library " + libraryName + " is not used", null, createPlace(),
return new ProjectStructureProblemDescription(XmlStringUtil.wrapInHtml("Library " + libraryName + " is not used"), null, createPlace(),
ProjectStructureProblemType.unused("unused-library"), ProjectStructureProblemDescription.ProblemLevel.PROJECT,
fixes, false);
}
@@ -10,7 +10,6 @@ import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.ui.configuration.ModuleEditor;
import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
@@ -65,7 +64,7 @@ public class ModuleProjectStructureElement extends ProjectStructureElement {
}
}
else {
problemsHolder.registerProblem(ProjectBundle.message("project.roots.library.problem.message", StringUtil.escapeXml(entry.getPresentableName())), null,
problemsHolder.registerProblem(ProjectBundle.message("project.roots.library.problem.message", entry.getPresentableName()), null,
ProjectStructureProblemType.error("invalid-module-dependency"), createPlace(entry),
null);
}
@@ -39,7 +39,7 @@ public class ProjectStructureProblemsHolderImpl implements ProjectStructureProbl
if (myProblemDescriptions != null) {
int problems = 0;
for (ProjectStructureProblemDescription problemDescription : myProblemDescriptions) {
buf.append(XmlStringUtil.escapeString(problemDescription.getMessage(false))).append("<br>");
buf.append(XmlStringUtil.convertToHtmlContent(problemDescription.getMessage(false))).append("<br>");
problems++;
if (problems >= 10 && myProblemDescriptions.size() > 12) {
buf.append(myProblemDescriptions.size() - problems).append(" more problems...<br>");
@@ -130,4 +130,13 @@ public class XmlStringUtil {
toolTip = StringUtil.trimEnd(toolTip, BODY_END);
return toolTip;
}
/**
* Converts {@code text} to a string which can be used inside an HTML document: if it's already an HTML text the root html/body tags will
* be stripped, if it's a plain text special characters will be escaped
*/
@NotNull
public static String convertToHtmlContent(@NotNull String text) {
return isWrappedInHtml(text) ? stripHtml(text) : escapeString(text);
}
}