From 08bd0596577ab9b2a836f3201241bc2a610ee912 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 3 Jul 2012 12:08:26 +0200 Subject: [PATCH] IDEA-87740 Property key quick definition tooltip: escape XML --- .../PropertiesDocumentationProvider.java | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/plugins/properties/src/com/intellij/lang/properties/PropertiesDocumentationProvider.java b/plugins/properties/src/com/intellij/lang/properties/PropertiesDocumentationProvider.java index d1853fce045b..c7060b7dc22f 100644 --- a/plugins/properties/src/com/intellij/lang/properties/PropertiesDocumentationProvider.java +++ b/plugins/properties/src/com/intellij/lang/properties/PropertiesDocumentationProvider.java @@ -27,6 +27,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.ui.GuiUtils; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.awt.*; @@ -35,16 +36,25 @@ public class PropertiesDocumentationProvider extends AbstractDocumentationProvid @Nullable public String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) { if (element instanceof IProperty) { - @NonNls String info = "\n\"" + ((IProperty)element).getValue() + "\""; - PsiFile file = element.getContainingFile(); - if (file != null) { - info += " [" + file.getName() + "]"; - } - return info; + return "\"" + renderPropertyValue((IProperty)element) + "\"" + getLocationString(element); } return null; } + private static String getLocationString(PsiElement element) { + PsiFile file = element.getContainingFile(); + return file != null ? " [" + file.getName() + "]" : ""; + } + + @NotNull + private static String renderPropertyValue(IProperty prop) { + String raw = prop.getValue(); + if (raw == null) { + return "empty"; + } + return StringUtil.escapeXml(raw); + } + public String generateDoc(final PsiElement element, final PsiElement originalElement) { if (element instanceof IProperty) { IProperty property = (IProperty)element; @@ -63,11 +73,8 @@ public class PropertiesDocumentationProvider extends AbstractDocumentationProvid info += ""; } } - info += "\n" + property.getName() + "=\"" + ((IProperty)element).getValue() + "\""; - PsiFile file = element.getContainingFile(); - if (file != null) { - info += " [" + file.getName() + "]"; - } + info += "\n" + property.getName() + "=\"" + renderPropertyValue(((IProperty)element)) + "\""; + info += getLocationString(element); return info; } return null;