提交 9d6c634c 编写于 作者: J jjg

8012174: {@literal} and {@code} should use \"new\" Taglet, not old.

Reviewed-by: darcy
上级 24d71a5d
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
package com.sun.tools.doclets.formats.html; package com.sun.tools.doclets.formats.html;
import com.sun.javadoc.*; import com.sun.javadoc.*;
import com.sun.tools.doclets.formats.html.markup.HtmlAttr;
import com.sun.tools.doclets.formats.html.markup.HtmlTag;
import com.sun.tools.doclets.formats.html.markup.HtmlTree;
import com.sun.tools.doclets.formats.html.markup.StringContent;
import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder; import com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder;
import com.sun.tools.doclets.internal.toolkit.taglets.*; import com.sun.tools.doclets.internal.toolkit.taglets.*;
...@@ -62,6 +66,14 @@ public class TagletWriterImpl extends TagletWriter { ...@@ -62,6 +66,14 @@ public class TagletWriterImpl extends TagletWriter {
return new TagletOutputImpl(""); return new TagletOutputImpl("");
} }
/**
* {@inheritDoc}
*/
protected TagletOutput codeTagOutput(Tag tag) {
Content result = HtmlTree.CODE(new StringContent(tag.text()));
return new TagletOutputImpl(result.toString());
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
...@@ -118,6 +130,23 @@ public class TagletWriterImpl extends TagletWriter { ...@@ -118,6 +130,23 @@ public class TagletWriterImpl extends TagletWriter {
return new TagletOutputImpl(output.toString()); return new TagletOutputImpl(output.toString());
} }
/**
* {@inheritDoc}
*/
protected TagletOutput expertTagOutput(Tag tag) {
HtmlTree result = new HtmlTree(HtmlTag.SUB, new StringContent(tag.text()));
result.addAttr(HtmlAttr.ID, "expert");
return new TagletOutputImpl(result.toString());
}
/**
* {@inheritDoc}
*/
protected TagletOutput literalTagOutput(Tag tag) {
Content result = new StringContent(tag.text());
return new TagletOutputImpl(result.toString());
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
......
/* /*
* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -75,6 +75,7 @@ public enum HtmlTag { ...@@ -75,6 +75,7 @@ public enum HtmlTag {
SMALL(BlockType.INLINE, EndTag.END), SMALL(BlockType.INLINE, EndTag.END),
SPAN(BlockType.INLINE, EndTag.END), SPAN(BlockType.INLINE, EndTag.END),
STRONG(BlockType.INLINE, EndTag.END), STRONG(BlockType.INLINE, EndTag.END),
SUB(BlockType.INLINE, EndTag.END),
TABLE, TABLE,
TBODY, TBODY,
TD, TD,
......
/* /*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,7 +26,6 @@ package com.sun.tools.doclets.internal.toolkit.taglets; ...@@ -26,7 +26,6 @@ package com.sun.tools.doclets.internal.toolkit.taglets;
import java.util.Map; import java.util.Map;
import com.sun.javadoc.Tag; import com.sun.javadoc.Tag;
import com.sun.tools.doclets.Taglet;
/** /**
* An inline Taglet used to denote literal code fragments. * An inline Taglet used to denote literal code fragments.
...@@ -49,23 +48,23 @@ import com.sun.tools.doclets.Taglet; ...@@ -49,23 +48,23 @@ import com.sun.tools.doclets.Taglet;
* @since 1.5 * @since 1.5
*/ */
public class CodeTaglet extends LiteralTaglet { public class CodeTaglet extends BaseInlineTaglet {
private static final String NAME = "code"; private static final String NAME = "code";
public static void register(Map<String, Taglet> map) { public static void register(Map<String, Taglet> map) {
map.remove(NAME); map.remove(NAME);
map.put(NAME, new CodeTaglet()); map.put(NAME, new CodeTaglet());
} }
public String getName() { public String getName() {
return NAME; return NAME;
} }
/* /**
* Wraps @literal's result in a <code> element. * {@inheritDoc}
*/ */
public String toString(Tag tag) { public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
return "<code>" + super.toString(tag) + "</code>"; return writer.codeTagOutput(tag);
} }
} }
...@@ -27,7 +27,6 @@ package com.sun.tools.doclets.internal.toolkit.taglets; ...@@ -27,7 +27,6 @@ package com.sun.tools.doclets.internal.toolkit.taglets;
import java.util.Map; import java.util.Map;
import com.sun.tools.doclets.Taglet;
import com.sun.javadoc.Tag; import com.sun.javadoc.Tag;
/** /**
...@@ -39,11 +38,9 @@ import com.sun.javadoc.Tag; ...@@ -39,11 +38,9 @@ import com.sun.javadoc.Tag;
* deletion without notice.</b> * deletion without notice.</b>
* *
*/ */
public class ExpertTaglet implements Taglet { public class ExpertTaglet extends BaseTaglet {
private static final String NAME = "expert"; private static final String NAME = "expert";
private static final String START_TAG = "<sub id=\"expert\">";
private static final String END_TAG = "</sub>";
/** /**
* {@inheritDoc} * {@inheritDoc}
...@@ -85,22 +82,10 @@ public class ExpertTaglet implements Taglet { ...@@ -85,22 +82,10 @@ public class ExpertTaglet implements Taglet {
map.put(NAME, new ExpertTaglet()); map.put(NAME, new ExpertTaglet());
} }
public String toString(Tag tag) { /**
return (tag.text() == null || tag.text().length() == 0) ? null : * {@inheritDoc}
START_TAG + LiteralTaglet.textToString(tag.text()) + END_TAG; */
} public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
return writer.expertTagOutput(tag);
public String toString(Tag[] tags) {
if (tags == null || tags.length == 0) return null;
StringBuffer sb = new StringBuffer(START_TAG);
for(Tag t:tags) {
sb.append(LiteralTaglet.textToString(t.text()));
}
sb.append(END_TAG);
return sb.toString();
} }
} }
/* /*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,8 +25,9 @@ ...@@ -25,8 +25,9 @@
package com.sun.tools.doclets.internal.toolkit.taglets; package com.sun.tools.doclets.internal.toolkit.taglets;
import java.util.Map; import java.util.Map;
import com.sun.javadoc.Doc;
import com.sun.javadoc.Tag; import com.sun.javadoc.Tag;
import com.sun.tools.doclets.Taglet;
/** /**
...@@ -47,60 +48,23 @@ import com.sun.tools.doclets.Taglet; ...@@ -47,60 +48,23 @@ import com.sun.tools.doclets.Taglet;
* @since 1.5 * @since 1.5
*/ */
public class LiteralTaglet implements Taglet { public class LiteralTaglet extends BaseInlineTaglet {
private static final String NAME = "literal"; private static final String NAME = "literal";
public static void register(Map<String,Taglet> map) { public static void register(Map<String, Taglet> map) {
map.remove(NAME); map.remove(NAME);
map.put(NAME, new LiteralTaglet()); map.put(NAME, new LiteralTaglet());
} }
public String getName() { public String getName() {
return NAME; return NAME;
} }
public String toString(Tag tag) { /**
return textToString(tag.text()); * {@inheritDoc}
}
public String toString(Tag[] tags) { return null; }
public boolean inField() { return false; }
public boolean inConstructor() { return false; }
public boolean inMethod() { return false; }
public boolean inOverview() { return false; }
public boolean inPackage() { return false; }
public boolean inType() { return false; }
public boolean isInlineTag() { return true; }
/*
* Replace occurrences of the following characters: < > &
*/ */
protected static String textToString(String text) { public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
StringBuilder buf = new StringBuilder(); return writer.literalTagOutput(tag);
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
switch (c) {
case '<':
buf.append("&lt;");
break;
case '>':
buf.append("&gt;");
break;
case '&':
buf.append("&amp;");
break;
default:
buf.append(c);
}
}
return buf.toString();
} }
} }
...@@ -659,10 +659,8 @@ public class TagletManager { ...@@ -659,10 +659,8 @@ public class TagletManager {
customTags.put((temp = new DocRootTaglet()).getName(), temp); customTags.put((temp = new DocRootTaglet()).getName(), temp);
customTags.put((temp = new InheritDocTaglet()).getName(), temp); customTags.put((temp = new InheritDocTaglet()).getName(), temp);
customTags.put((temp = new ValueTaglet()).getName(), temp); customTags.put((temp = new ValueTaglet()).getName(), temp);
customTags.put((temp = new LegacyTaglet(new LiteralTaglet())).getName(), customTags.put((temp = new LiteralTaglet()).getName(), temp);
temp); customTags.put((temp = new CodeTaglet()).getName(), temp);
customTags.put((temp = new LegacyTaglet(new CodeTaglet())).getName(),
temp);
//Keep track of the names of standard tags for error //Keep track of the names of standard tags for error
//checking purposes. //checking purposes.
...@@ -705,7 +703,7 @@ public class TagletManager { ...@@ -705,7 +703,7 @@ public class TagletManager {
SimpleTaglet.FIELD + SimpleTaglet.METHOD)).getName(), temp); SimpleTaglet.FIELD + SimpleTaglet.METHOD)).getName(), temp);
customTags.put((temp = new SimpleTaglet("treatAsPrivate", null, customTags.put((temp = new SimpleTaglet("treatAsPrivate", null,
SimpleTaglet.FIELD + SimpleTaglet.METHOD + SimpleTaglet.TYPE)).getName(), temp); SimpleTaglet.FIELD + SimpleTaglet.METHOD + SimpleTaglet.TYPE)).getName(), temp);
customTags.put((temp = new LegacyTaglet(new ExpertTaglet())).getName(), temp); customTags.put((temp = new ExpertTaglet()).getName(), temp);
standardTags.add("propertyGetter"); standardTags.add("propertyGetter");
standardTags.add("propertySetter"); standardTags.add("propertySetter");
......
...@@ -53,10 +53,18 @@ public abstract class TagletWriter { ...@@ -53,10 +53,18 @@ public abstract class TagletWriter {
} }
/** /**
* @return an instance of the output object. * @return an instance of an output object.
*/ */
public abstract TagletOutput getOutputInstance(); public abstract TagletOutput getOutputInstance();
/**
* Return the output for a {@code...} tag.
*
* @param tag the tag.
* @return the output of the taglet.
*/
protected abstract TagletOutput codeTagOutput(Tag tag);
/** /**
* Returns the output for the DocRoot inline tag. * Returns the output for the DocRoot inline tag.
* @return the output for the DocRoot inline tag. * @return the output for the DocRoot inline tag.
...@@ -71,6 +79,23 @@ public abstract class TagletWriter { ...@@ -71,6 +79,23 @@ public abstract class TagletWriter {
*/ */
protected abstract TagletOutput deprecatedTagOutput(Doc doc); protected abstract TagletOutput deprecatedTagOutput(Doc doc);
/**
* Return the output for a {@expert...} tag.
*
* @param tag the tag.
* @return the output of the taglet.
*/
// TODO: remove this taglet
protected abstract TagletOutput expertTagOutput(Tag tag);
/**
* Return the output for a {@literal...} tag.
*
* @param tag the tag.
* @return the output of the taglet.
*/
protected abstract TagletOutput literalTagOutput(Tag tag);
/** /**
* Returns {@link MessageRetriever} for output purposes. * Returns {@link MessageRetriever} for output purposes.
* *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册