From f3bc48e8885cbd9bbda61614840c7aa9a1445c64 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 14 Apr 2014 16:48:13 +0200 Subject: [PATCH] no need in URLs? during description composition (IDEA-119992) --- .../codeInspection/ex/HTMLComposerImpl.java | 5 ++- .../reference/RefElementImpl.java | 24 +++++--------- .../codeInspection/ex/DescriptorComposer.java | 32 +++++++------------ 3 files changed, 21 insertions(+), 40 deletions(-) diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/HTMLComposerImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/HTMLComposerImpl.java index 978aab633602..c8a8361b020b 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/HTMLComposerImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/HTMLComposerImpl.java @@ -43,7 +43,6 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.net.URL; import java.util.HashMap; import java.util.Map; @@ -178,9 +177,9 @@ public abstract class HTMLComposerImpl extends HTMLComposer { @Override public void appendElementReference(final StringBuffer buf, RefElement refElement, String linkText, @NonNls String frameName) { if (myExporter == null) { - final URL url = ((RefElementImpl)refElement).getURL(); + final String url = ((RefElementImpl)refElement).getURL(); if (url != null) { - appendElementReference(buf, url.toString(), linkText, frameName); + appendElementReference(buf, url, linkText, frameName); } } else { diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java index 066bf033c019..7e1cee27d1da 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java @@ -42,8 +42,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.net.MalformedURLException; -import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -245,20 +243,14 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement } @Nullable - public URL getURL() { - try { - final PsiElement element = getElement(); - if (element == null) return null; - final PsiFile containingFile = element.getContainingFile(); - if (containingFile == null) return null; - final VirtualFile virtualFile = containingFile.getVirtualFile(); - if (virtualFile == null) return null; - return new URL(virtualFile.getUrl() + "#" + element.getTextOffset()); - } catch (MalformedURLException e) { - LOG.error(e); - } - - return null; + public String getURL() { + final PsiElement element = getElement(); + if (element == null || !element.isPhysical()) return null; + final PsiFile containingFile = element.getContainingFile(); + if (containingFile == null) return null; + final VirtualFile virtualFile = containingFile.getVirtualFile(); + if (virtualFile == null) return null; + return virtualFile.getUrl() + "#" + element.getTextOffset(); } protected abstract void initialize(); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorComposer.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorComposer.java index 9069f4cae0e2..f7c8a4c99529 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorComposer.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorComposer.java @@ -31,8 +31,6 @@ import com.intellij.util.text.CharArrayUtil; import com.intellij.xml.util.XmlStringUtil; import org.jetbrains.annotations.NotNull; -import java.net.MalformedURLException; -import java.net.URL; import java.util.ArrayList; import java.util.List; @@ -158,17 +156,12 @@ public class DescriptorComposer extends HTMLComposerImpl { //noinspection HardCodedStringLiteral anchor.append(""); @@ -197,14 +190,9 @@ public class DescriptorComposer extends HTMLComposerImpl { if (myExporter == null) { //noinspection HardCodedStringLiteral lineAnchor.append(""); } lineAnchor.append(Integer.toString(lineNumber)); @@ -222,5 +210,7 @@ public class DescriptorComposer extends HTMLComposerImpl { composeAdditionalDescription(buf, refElement); } - + private static String appendURL(VirtualFile vFile, String anchor) { + return vFile.getUrl() + "#" + anchor; + } }