Skip to content

Commit

Permalink
Merge pull request #5180 from jherkel/netbeans-1309
Browse files Browse the repository at this point in the history
[NETBEANS-1309] add support for @summary javadoc tag
  • Loading branch information
mbien authored Jan 5, 2023
2 parents d859340 + bef7a93 commit b7ba5d6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
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

0 comments on commit b7ba5d6

Please sign in to comment.