mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
no need in URLs? during description composition (IDEA-119992)
This commit is contained in:
@@ -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 {
|
||||
|
||||
+8
-16
@@ -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();
|
||||
|
||||
@@ -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("<a HREF=\"");
|
||||
try {
|
||||
if (myExporter == null){
|
||||
//noinspection HardCodedStringLiteral
|
||||
anchor.append(new URL(vFile.getUrl() + "#descr:" + i));
|
||||
}
|
||||
else {
|
||||
anchor.append(myExporter.getURL(refElement));
|
||||
}
|
||||
if (myExporter == null){
|
||||
//noinspection HardCodedStringLiteral
|
||||
anchor.append(appendURL(vFile, "descr:" + i));
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
LOG.error(e);
|
||||
else {
|
||||
anchor.append(myExporter.getURL(refElement));
|
||||
}
|
||||
|
||||
anchor.append("\">");
|
||||
@@ -197,14 +190,9 @@ public class DescriptorComposer extends HTMLComposerImpl {
|
||||
if (myExporter == null) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
lineAnchor.append("<a HREF=\"");
|
||||
try {
|
||||
int offset = doc.getLineStartOffset(lineNumber - 1);
|
||||
offset = CharArrayUtil.shiftForward(doc.getCharsSequence(), offset, " \t");
|
||||
lineAnchor.append(new URL(vFile.getUrl() + "#" + offset));
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
int offset = doc.getLineStartOffset(lineNumber - 1);
|
||||
offset = CharArrayUtil.shiftForward(doc.getCharsSequence(), offset, " \t");
|
||||
lineAnchor.append(appendURL(vFile, String.valueOf(offset)));
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user