Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NETBEANS-1309] add support for @summary javadoc tag #5180

Merged
merged 1 commit into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,23 @@ public void testSnippet2() throws Exception {

performCompletionTest(code, "end:");
}

public void testSummaryCompletionForMethod() throws Exception {
String code =
"package p;\n" +
"class Clazz {\n" +
" /**\n" +
" * {@sum|\n" +
" */\n" +
" void method(int p1, int p2) {\n" +
" }\n" +
" Clazz() {\n" +
" }\n" +
"}\n";
performCompletionTest(code, "@summary:");
}



private static String stripHTML(String from) {
StringBuilder result = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ private static class Pretty extends ErrorAwareTreePathScanner<Boolean, Void> {
private static final String JDOC_THROWS_TAG = "@throws"; //NOI18N
private static final String JDOC_VALUE_TAG = "@value"; //NOI18N
private static final String JDOC_SNIPPET_TAG = "@snippet"; //NOI18N
private static final String JDOC_SUMMARY_TAG = "@summary"; //NOI18N
private static final String ERROR = "<error>"; //NOI18N

private final String fText;
Expand Down Expand Up @@ -4835,6 +4836,7 @@ private void reformatComment() {
|| JDOC_DOCROOT_TAG.equalsIgnoreCase(tokenText)
|| JDOC_INHERITDOC_TAG.equalsIgnoreCase(tokenText)
|| JDOC_VALUE_TAG.equalsIgnoreCase(tokenText)
|| JDOC_SUMMARY_TAG.equalsIgnoreCase(tokenText)
|| JDOC_LITERAL_TAG.equalsIgnoreCase(tokenText)) {
insideTag = true;
addMark(Pair.of(currWSOffset >= 0 ? currWSOffset : javadocTokens.offset() - offset, 5), marks, state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.sun.source.doctree.DeprecatedTree;
import com.sun.source.doctree.DocCommentTree;
import com.sun.source.doctree.DocTree;
import static com.sun.source.doctree.DocTree.Kind.SUMMARY;
import com.sun.source.doctree.EndElementTree;
import com.sun.source.doctree.EntityTree;
import com.sun.source.doctree.InheritDocTree;
Expand All @@ -37,6 +38,7 @@
import com.sun.source.doctree.SinceTree;
import com.sun.source.doctree.SnippetTree;
import com.sun.source.doctree.StartElementTree;
import com.sun.source.doctree.SummaryTree;
import com.sun.source.doctree.TextTree;
import com.sun.source.doctree.ThrowsTree;
import com.sun.source.doctree.UnknownBlockTagTree;
Expand Down Expand Up @@ -1060,8 +1062,8 @@ public Void visitInheritDoc(InheritDocTree node, Void p) {
}
sb.append(inlineTags(unTag.getContent(), path, doc, info.getDocTrees(), null));
break;
}
break;
}
break;
}
}

Expand Down Expand Up @@ -1325,6 +1327,11 @@ private StringBuilder inlineTags(List<? extends DocTree> tags, TreePath docPath,
snippetCount++;
processDocSnippet(sb, (SnippetTree)tag, snippetCount,docPath, doc, trees);
break;
case SUMMARY:
SummaryTree summaryTag = (SummaryTree)tag;
List<? extends DocTree> summary = summaryTag.getSummary();
sb.append(inlineTags(summary, docPath, doc, trees, null));
break;
}
}
return sb;
Expand Down