support for returns@ so that it displays the same as @return
diff --git a/plugins/org.eclipse.dltk.javascript.ui/src/org/eclipse/dltk/javascript/scriptdoc/JavaDoc2HTMLTextReader.java b/plugins/org.eclipse.dltk.javascript.ui/src/org/eclipse/dltk/javascript/scriptdoc/JavaDoc2HTMLTextReader.java
index e418df3..13e9692 100644
--- a/plugins/org.eclipse.dltk.javascript.ui/src/org/eclipse/dltk/javascript/scriptdoc/JavaDoc2HTMLTextReader.java
+++ b/plugins/org.eclipse.dltk.javascript.ui/src/org/eclipse/dltk/javascript/scriptdoc/JavaDoc2HTMLTextReader.java
@@ -18,7 +18,6 @@
import org.eclipse.dltk.internal.ui.text.SubstitutionTextReader;
import org.eclipse.dltk.utils.TextUtils;
-
public class JavaDoc2HTMLTextReader extends SubstitutionTextReader {
/*
@@ -27,111 +26,117 @@
public static final String TAG_AUTHOR = "@author"; //$NON-NLS-1$
/**
- * Standard inline doc tag name (value {@value}).
+ * Standard inline doc tag name (value {@value} ).
* <p>
* Note that this tag first appeared in J2SE 5.
* </p>
+ *
* @since 3.1
*/
public static final String TAG_CODE = "@code"; //$NON-NLS-1$
/**
- * Standard doc tag name (value {@value}).
+ * Standard doc tag name (value {@value} ).
*/
public static final String TAG_DEPRECATED = "@deprecated"; //$NON-NLS-1$
/**
- * Standard inline doc tag name (value {@value}).
+ * Standard inline doc tag name (value {@value} ).
*/
public static final String TAG_DOCROOT = "@docRoot"; //$NON-NLS-1$
/**
- * Standard doc tag name (value {@value}).
+ * Standard doc tag name (value {@value} ).
*/
public static final String TAG_EXCEPTION = "@exception"; //$NON-NLS-1$
/**
- * Standard inline doc tag name (value {@value}).
+ * Standard inline doc tag name (value {@value} ).
*/
public static final String TAG_INHERITDOC = "@inheritDoc"; //$NON-NLS-1$
/**
- * Standard inline doc tag name (value {@value}).
+ * Standard inline doc tag name (value {@value} ).
*/
public static final String TAG_LINK = "@link"; //$NON-NLS-1$
/**
- * Standard inline doc tag name (value {@value}).
+ * Standard inline doc tag name (value {@value} ).
*/
public static final String TAG_LINKPLAIN = "@linkplain"; //$NON-NLS-1$
/**
- * Standard inline doc tag name (value {@value}).
+ * Standard inline doc tag name (value {@value} ).
* <p>
* Note that this tag first appeared in J2SE 5.
* </p>
+ *
* @since 3.1
*/
public static final String TAG_LITERAL = "@literal"; //$NON-NLS-1$
/**
- * Standard doc tag name (value {@value}).
+ * Standard doc tag name (value {@value} ).
*/
public static final String TAG_PARAM = "@param"; //$NON-NLS-1$
/**
- * Standard doc tag name (value {@value}).
+ * Standard doc tag name (value {@value} ).
*/
public static final String TAG_RETURN = "@return"; //$NON-NLS-1$
/**
- * Standard doc tag name (value {@value}).
+ * Standard doc tag name (value {@value} ).
+ */
+ public static final String TAG_RETURNS = "@returns"; //$NON-NLS-1$
+
+ /**
+ * Standard doc tag name (value {@value} ).
*/
public static final String TAG_SEE = "@see"; //$NON-NLS-1$
/**
- * Standard doc tag name (value {@value}).
+ * Standard doc tag name (value {@value} ).
*/
public static final String TAG_SERIAL = "@serial"; //$NON-NLS-1$
/**
- * Standard doc tag name (value {@value}).
+ * Standard doc tag name (value {@value} ).
*/
- public static final String TAG_SERIALDATA= "@serialData"; //$NON-NLS-1$
+ public static final String TAG_SERIALDATA = "@serialData"; //$NON-NLS-1$
/**
- * Standard doc tag name (value {@value}).
+ * Standard doc tag name (value {@value} ).
*/
- public static final String TAG_SERIALFIELD= "@serialField"; //$NON-NLS-1$
+ public static final String TAG_SERIALFIELD = "@serialField"; //$NON-NLS-1$
/**
- * Standard doc tag name (value {@value}).
+ * Standard doc tag name (value {@value} ).
*/
public static final String TAG_SINCE = "@since"; //$NON-NLS-1$
/**
- * Standard doc tag name (value {@value}).
+ * Standard doc tag name (value {@value} ).
*/
public static final String TAG_THROWS = "@throws"; //$NON-NLS-1$
/**
- * Standard inline doc tag name (value {@value}).
+ * Standard inline doc tag name (value {@value} ).
*/
- public static final String TAG_VALUE= "@value"; //$NON-NLS-1$
+ public static final String TAG_VALUE = "@value"; //$NON-NLS-1$
/**
- * Standard doc tag name (value {@value}).
+ * Standard doc tag name (value {@value} ).
*/
public static final String TAG_VERSION = "@version"; //$NON-NLS-1$
-
static private class Pair {
String fTag;
String fContent;
Pair(String tag, String content) {
- fTag= tag;
- fContent= content;
+ fTag = tag;
+ fContent = content;
}
}
@@ -149,30 +154,32 @@
}
private int getTag(StringBuffer buffer) throws IOException {
- int c= nextChar();
+ int c = nextChar();
while (c == '.' || c != -1 && Character.isLetter((char) c)) {
buffer.append((char) c);
- c= nextChar();
+ c = nextChar();
}
return c;
}
- private int getContent(StringBuffer buffer, char stopChar) throws IOException {
- int c= nextChar();
+ private int getContent(StringBuffer buffer, char stopChar)
+ throws IOException {
+ int c = nextChar();
while (c != -1 && c != stopChar) {
buffer.append((char) c);
- c= nextChar();
+ c = nextChar();
}
return c;
}
private int getContentUntilNextTag(StringBuffer buffer) throws IOException {
- int c= nextChar();
- boolean blockStartRead= false;
+ int c = nextChar();
+ boolean blockStartRead = false;
while (c != -1) {
if (c == '@') {
- int index= buffer.length();
- while (--index >= 0 && Character.isWhitespace(buffer.charAt(index))) {
+ int index = buffer.length();
+ while (--index >= 0
+ && Character.isWhitespace(buffer.charAt(index))) {
switch (buffer.charAt(index)) {
case '\n':
case '\r':
@@ -183,38 +190,39 @@
}
}
}
- if (blockStartRead) {
- buffer.append(processBlockTag());
- blockStartRead= false;
- } else {
- buffer.append((char) c);
- }
+ if (blockStartRead) {
+ buffer.append(processBlockTag());
+ blockStartRead = false;
+ } else {
+ buffer.append((char) c);
+ }
- c= nextChar();
- blockStartRead= c == '{';
+ c = nextChar();
+ blockStartRead = c == '{';
}
return c;
}
private String substituteQualification(String qualification) {
- String result= qualification.replace('#', '.');
+ String result = qualification.replace('#', '.');
if (result.startsWith(".")) { //$NON-NLS-1$
- result= result.substring(1);
+ result = result.substring(1);
}
return result;
}
- private void printDefinitions(StringBuffer buffer, List list, boolean firstword) {
- Iterator e= list.iterator();
+ private void printDefinitions(StringBuffer buffer, List list,
+ boolean firstword) {
+ Iterator e = list.iterator();
while (e.hasNext()) {
- String s= (String) e.next();
+ String s = (String) e.next();
buffer.append("<dd>"); //$NON-NLS-1$
if (!firstword)
buffer.append(s);
else {
buffer.append("<b>"); //$NON-NLS-1$
- int i= getParamEndOffset(s);
+ int i = getParamEndOffset(s);
if (i <= s.length()) {
buffer.append(TextUtils.escapeHTML(s.substring(0, i)));
buffer.append("</b>"); //$NON-NLS-1$
@@ -228,8 +236,8 @@
}
private int getParamEndOffset(String s) {
- int i= 0;
- final int length= s.length();
+ int i = 0;
+ final int length = s.length();
// \s*
while (i < length && Character.isWhitespace(s.charAt(i)))
++i;
@@ -251,8 +259,9 @@
return i;
}
- private void print(StringBuffer buffer, String tag, List elements, boolean firstword) {
- if ( !elements.isEmpty()) {
+ private void print(StringBuffer buffer, String tag, List elements,
+ boolean firstword) {
+ if (!elements.isEmpty()) {
buffer.append("<dt>"); //$NON-NLS-1$
buffer.append(tag);
buffer.append("</dt>"); //$NON-NLS-1$
@@ -261,7 +270,7 @@
}
private void print(StringBuffer buffer, String tag, String content) {
- if (content != null) {
+ if (content != null) {
buffer.append("<dt>"); //$NON-NLS-1$
buffer.append(tag);
buffer.append("</dt>"); //$NON-NLS-1$
@@ -272,10 +281,10 @@
}
private void printRest(StringBuffer buffer) {
- if ( !fRest.isEmpty()) {
- Iterator e= fRest.iterator();
+ if (!fRest.isEmpty()) {
+ Iterator e = fRest.iterator();
while (e.hasNext()) {
- Pair p= (Pair) e.next();
+ Pair p = (Pair) e.next();
buffer.append("<dt>"); //$NON-NLS-1$
if (p.fTag != null)
buffer.append(p.fTag);
@@ -289,14 +298,21 @@
}
private String printSimpleTag() {
- StringBuffer buffer= new StringBuffer();
+ StringBuffer buffer = new StringBuffer();
buffer.append("<dl>"); //$NON-NLS-1$
- print(buffer, JavaDocMessages.JavaDoc2HTMLTextReader_see_section, fSees, false);
- print(buffer, JavaDocMessages.JavaDoc2HTMLTextReader_parameters_section, fParameters, true);
- print(buffer, JavaDocMessages.JavaDoc2HTMLTextReader_returns_section, fReturn);
- print(buffer, JavaDocMessages.JavaDoc2HTMLTextReader_throws_section, fExceptions, false);
- print(buffer, JavaDocMessages.JavaDoc2HTMLTextReader_author_section, fAuthors, false);
- print(buffer, JavaDocMessages.JavaDoc2HTMLTextReader_since_section, fSince, false);
+ print(buffer, JavaDocMessages.JavaDoc2HTMLTextReader_see_section,
+ fSees, false);
+ print(buffer,
+ JavaDocMessages.JavaDoc2HTMLTextReader_parameters_section,
+ fParameters, true);
+ print(buffer, JavaDocMessages.JavaDoc2HTMLTextReader_returns_section,
+ fReturn);
+ print(buffer, JavaDocMessages.JavaDoc2HTMLTextReader_throws_section,
+ fExceptions, false);
+ print(buffer, JavaDocMessages.JavaDoc2HTMLTextReader_author_section,
+ fAuthors, false);
+ print(buffer, JavaDocMessages.JavaDoc2HTMLTextReader_since_section,
+ fSince, false);
printRest(buffer);
buffer.append("</dl>"); //$NON-NLS-1$
@@ -305,21 +321,21 @@
private void handleTag(String tag, String tagContent) {
- tagContent= tagContent.trim();
+ tagContent = tagContent.trim();
if (TAG_PARAM.equals(tag))
fParameters.add(tagContent);
- else if (TAG_RETURN.equals(tag))
- fReturn= tagContent;
- else if (TAG_EXCEPTION.equals(tag))
+ else if (TAG_RETURN.equals(tag) || TAG_RETURNS.equals(tag))
+ fReturn = tagContent;
+ else if (TAG_EXCEPTION.equals(tag))
fExceptions.add(tagContent);
- else if (TAG_THROWS.equals(tag))
+ else if (TAG_THROWS.equals(tag))
fExceptions.add(tagContent);
- else if (TAG_AUTHOR.equals(tag))
+ else if (TAG_AUTHOR.equals(tag))
fAuthors.add(substituteQualification(tagContent));
- else if (TAG_SEE.equals(tag))
+ else if (TAG_SEE.equals(tag))
fSees.add(substituteQualification(tagContent));
- else if (TAG_SINCE.equals(tag))
+ else if (TAG_SINCE.equals(tag))
fSince.add(substituteQualification(tagContent));
else if (tagContent != null)
fRest.add(new Pair(tag, tagContent));
@@ -330,25 +346,25 @@
*/
private String processSimpleTag() throws IOException {
- fParameters= new ArrayList();
- fExceptions= new ArrayList();
- fAuthors= new ArrayList();
- fSees= new ArrayList();
- fSince= new ArrayList();
- fRest= new ArrayList();
+ fParameters = new ArrayList();
+ fExceptions = new ArrayList();
+ fAuthors = new ArrayList();
+ fSees = new ArrayList();
+ fSince = new ArrayList();
+ fRest = new ArrayList();
- StringBuffer buffer= new StringBuffer();
- int c= '@';
+ StringBuffer buffer = new StringBuffer();
+ int c = '@';
while (c != -1) {
buffer.setLength(0);
buffer.append((char) c);
- c= getTag(buffer);
- String tag= buffer.toString();
+ c = getTag(buffer);
+ String tag = buffer.toString();
buffer.setLength(0);
if (c != -1) {
- c= getContentUntilNextTag(buffer);
+ c = getContentUntilNextTag(buffer);
}
handleTag(tag, buffer.toString());
@@ -361,43 +377,43 @@
if (TAG_LINK.equals(tag) || TAG_LINKPLAIN.equals(tag)) {
- char[] contentChars= tagContent.toCharArray();
- boolean inParentheses= false;
- int labelStart= 0;
+ char[] contentChars = tagContent.toCharArray();
+ boolean inParentheses = false;
+ int labelStart = 0;
- for (int i= 0; i < contentChars.length; i++) {
- char nextChar= contentChars[i];
+ for (int i = 0; i < contentChars.length; i++) {
+ char nextChar = contentChars[i];
// tagContent always has a leading space
if (i == 0 && Character.isWhitespace(nextChar)) {
- labelStart= 1;
+ labelStart = 1;
continue;
}
if (nextChar == '(') {
- inParentheses= true;
+ inParentheses = true;
continue;
}
if (nextChar == ')') {
- inParentheses= false;
+ inParentheses = false;
continue;
}
// Stop at first whitespace that is not in parentheses
if (!inParentheses && Character.isWhitespace(nextChar)) {
- labelStart= i+1;
+ labelStart = i + 1;
break;
}
}
if (TAG_LINK.equals(tag))
- return "<code>" + substituteQualification(tagContent.substring(labelStart)) + "</code>"; //$NON-NLS-1$//$NON-NLS-2$
+ return "<code>" + substituteQualification(tagContent.substring(labelStart)) + "</code>"; //$NON-NLS-1$//$NON-NLS-2$
else
return substituteQualification(tagContent.substring(labelStart));
-
+
} else if (TAG_LITERAL.equals(tag)) {
return printLiteral(tagContent);
-
+
} else if (TAG_CODE.equals(tag)) {
return "<code>" + printLiteral(tagContent) + "</code>"; //$NON-NLS-1$//$NON-NLS-2$
}
@@ -407,10 +423,10 @@
}
private String printLiteral(String tagContent) {
- int contentStart= 0;
- for (int i= 0; i < tagContent.length(); i++) {
- if (! Character.isWhitespace(tagContent.charAt(i))) {
- contentStart= i;
+ int contentStart = 0;
+ for (int i = 0; i < tagContent.length(); i++) {
+ if (!Character.isWhitespace(tagContent.charAt(i))) {
+ contentStart = i;
break;
}
}
@@ -422,28 +438,28 @@
*/
private String processBlockTag() throws IOException {
- int c= nextChar();
+ int c = nextChar();
if (c != '@') {
- StringBuffer buffer= new StringBuffer();
+ StringBuffer buffer = new StringBuffer();
buffer.append('{');
buffer.append((char) c);
return buffer.toString();
}
- StringBuffer buffer= new StringBuffer();
+ StringBuffer buffer = new StringBuffer();
if (c != -1) {
buffer.setLength(0);
buffer.append((char) c);
- c= getTag(buffer);
- String tag= buffer.toString();
+ c = getTag(buffer);
+ String tag = buffer.toString();
buffer.setLength(0);
if (c != -1 && c != '}') {
buffer.append((char) c);
- c= getContent(buffer, '}');
+ c = getContent(buffer, '}');
}
return printBlockTag(tag, buffer.toString());