Bug 546320 - Need to handle the newly added tags appropriately in
the Javadoc view
Change-Id: Icf87c5d67c9226e3825373b2e8265922b2368243
Signed-off-by: Vikas Chandra <Vikas.Chandra@in.ibm.com>
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocMessages.java
index 0ebc557..858685d 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocMessages.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -38,6 +38,11 @@
public static String JavaDoc2HTMLTextReader_since_section;
public static String JavaDoc2HTMLTextReader_specified_by_section;
public static String JavaDoc2HTMLTextReader_version_section;
+ public static String JavaDoc2HTMLTextReader_api_note;
+ public static String JavaDoc2HTMLTextReader_impl_spec;
+ public static String JavaDoc2HTMLTextReader_impl_note;
+ public static String JavaDoc2HTMLTextReader_uses;
+ public static String JavaDoc2HTMLTextReader_provides;
public static String JavadocContentAccess2_getproperty_message;
public static String JavadocContentAccess2_setproperty_message;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocMessages.properties
index 3d528ee..df3cf7e 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocMessages.properties
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2014 IBM Corporation and others.
+# Copyright (c) 2000, 2019 IBM Corporation and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
@@ -24,5 +24,10 @@
JavaDoc2HTMLTextReader_since_section=Since:
JavaDoc2HTMLTextReader_specified_by_section=Specified by:
JavaDoc2HTMLTextReader_version_section=Version:
+JavaDoc2HTMLTextReader_api_note=API Note:
+JavaDoc2HTMLTextReader_impl_spec=Impl Spec:
+JavaDoc2HTMLTextReader_impl_note=Impl Note:
+JavaDoc2HTMLTextReader_uses=Uses:
+JavaDoc2HTMLTextReader_provides=Provides:
JavadocContentAccess2_getproperty_message=<p>Gets the value of the property {0}.</p><dl><dt>Property Description:</dt><dd>{1}</dd></dl>
JavadocContentAccess2_setproperty_message=<p>Sets the value of the property {0}.</p><dl><dt>Property Description:</dt><dd>{1}</dd></dl>
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java
index 0847ee5..2f9ae62 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java
@@ -946,6 +946,12 @@
List<TagElement> sees= new ArrayList<>();
List<TagElement> since= new ArrayList<>();
List<TagElement> rest= new ArrayList<>();
+ List<TagElement> apinote= new ArrayList<>(1);
+ List<TagElement> implspec= new ArrayList<>(1);
+ List<TagElement> implnote= new ArrayList<>(1);
+ List<TagElement> uses= new ArrayList<>(1);
+ List<TagElement> provides= new ArrayList<>(1);
+ List<TagElement> hidden= new ArrayList<>(1);
List<TagElement> tags= fJavadoc.tags();
for (Iterator<TagElement> iter= tags.iterator(); iter.hasNext(); ) {
@@ -1015,6 +1021,18 @@
} else if (TagElement.TAG_DEPRECATED.equals(tagName)) {
if (deprecatedTag == null)
deprecatedTag= tag; // the Javadoc tool only shows the first deprecated tag
+ } else if (TagElement.TAG_API_NOTE.equals(tagName)) {
+ apinote.add(tag);
+ } else if (TagElement.TAG_IMPL_SPEC.equals(tagName)) {
+ implspec.add(tag);
+ } else if (TagElement.TAG_IMPL_NOTE.equals(tagName)) {
+ implnote.add(tag);
+ } else if (TagElement.TAG_USES.equals(tagName)) {
+ uses.add(tag);
+ } else if (TagElement.TAG_PROVIDES.equals(tagName)) {
+ provides.add(tag);
+ } else if (TagElement.TAG_HIDDEN.equals(tagName)) {
+ hidden.add(tag);
} else {
rest.add(tag);
}
@@ -1050,7 +1068,9 @@
boolean hasExceptions= exceptions.size() > 0 || hasInheritedExceptions;
if (hasParameters || hasTypeParameters || hasReturnTag || hasExceptions
- || versions.size() > 0 || authors.size() > 0 || since.size() > 0 || sees.size() > 0 || rest.size() > 0
+ || versions.size() > 0 || authors.size() > 0 || since.size() > 0 || sees.size() > 0 ||
+ apinote.size() > 0 || implnote.size() > 0 || implspec.size() > 0 || uses.size() > 0 ||
+ provides.size() > 0 || hidden.size() > 0 || rest.size() > 0
|| (fBuf.length() > 0 && (parameterDescriptions.length > 0 || exceptionDescriptions.length > 0))
) {
handleSuperMethodReferences();
@@ -1063,6 +1083,14 @@
handleBlockTags(JavaDocMessages.JavaDoc2HTMLTextReader_version_section, versions);
handleBlockTags(JavaDocMessages.JavaDoc2HTMLTextReader_author_section, authors);
handleBlockTags(JavaDocMessages.JavaDoc2HTMLTextReader_see_section, sees);
+ handleBlockTags(JavaDocMessages.JavaDoc2HTMLTextReader_api_note, apinote);
+ handleBlockTags(JavaDocMessages.JavaDoc2HTMLTextReader_impl_spec, implspec);
+ handleBlockTags(JavaDocMessages.JavaDoc2HTMLTextReader_impl_note, implnote);
+ handleBlockTags(JavaDocMessages.JavaDoc2HTMLTextReader_uses, uses);
+ handleBlockTags(JavaDocMessages.JavaDoc2HTMLTextReader_provides, provides);
+ if (hidden.size() > 0) {
+ handleBlockTagsHidden();
+ }
handleBlockTags(rest);
fBuf.append(BLOCK_TAG_END);
@@ -1071,6 +1099,16 @@
}
}
+ private void handleBlockTagsHidden() {
+ String replaceAll= fBuf.toString().replaceAll(BLOCK_TAG_START, "<dl hidden>"); //$NON-NLS-1$
+ replaceAll= replaceAll.replaceAll(BlOCK_TAG_TITLE_START, "<dt hidden>"); //$NON-NLS-1$
+ replaceAll= replaceAll.replaceAll(BlOCK_TAG_ENTRY_START, "<dd hidden>"); //$NON-NLS-1$
+ // For tags like deprecated
+ replaceAll= replaceAll.replaceAll(PARAM_NAME_START, "<b hidden>"); //$NON-NLS-1$
+ fBuf.setLength(0);
+ fBuf.append(replaceAll);
+ }
+
private void handleDeprecatedTag(TagElement tag) {
fBuf.append("<p><b>"); //$NON-NLS-1$
fBuf.append(JavaDocMessages.JavaDoc2HTMLTextReader_deprecated_section);
@@ -1454,7 +1492,6 @@
private void handleInlineTagElement(TagElement node) {
String name= node.getTagName();
-
if (TagElement.TAG_VALUE.equals(name) && handleValueTag(node))
return;
@@ -1462,14 +1499,20 @@
boolean isLinkplain= TagElement.TAG_LINKPLAIN.equals(name);
boolean isCode= TagElement.TAG_CODE.equals(name);
boolean isLiteral= TagElement.TAG_LITERAL.equals(name);
+ boolean isSummary = TagElement.TAG_SUMMARY.equals(name);
+ boolean isIndex = TagElement.TAG_INDEX.equals(name);
- if (isLiteral || isCode)
+ if (isLiteral || isCode || isSummary || isIndex)
fLiteralContent++;
if (isLink || isCode)
fBuf.append("<code>"); //$NON-NLS-1$
if (isLink || isLinkplain)
handleLink(node.fragments());
+ else if (isSummary)
+ handleSummary(node.fragments());
+ else if (isIndex)
+ handleIndex(node.fragments());
else if (isCode || isLiteral)
handleContentElements(node.fragments(), true);
else if (handleInheritDoc(node)) {
@@ -1872,6 +1915,30 @@
}
}
+ private void handleSummary(List<? extends ASTNode> fragments) {
+ int fs= fragments.size();
+ if (fs > 0) {
+ Object first= fragments.get(0);
+ if (first instanceof TextElement) {
+ TextElement memberRef= (TextElement) first;
+ fBuf.append(BlOCK_TAG_TITLE_START + "Summary: " + memberRef.getText() + BlOCK_TAG_TITLE_END); //$NON-NLS-1$
+ return;
+ }
+ }
+ }
+
+ private void handleIndex(List<? extends ASTNode> fragments) {
+ int fs= fragments.size();
+ if (fs > 0) {
+ Object first= fragments.get(0);
+ if (first instanceof TextElement) {
+ TextElement memberRef= (TextElement) first;
+ fBuf.append( memberRef.getText() );
+ return;
+ }
+ }
+ }
+
private void handleLink(List<? extends ASTNode> fragments) {
//TODO: Javadoc shortens type names to minimal length according to context
int fs= fragments.size();