Skip to content

Commit

Permalink
Better handle javadoc with extra tags. Fixes eclipse-jdtls#611
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Bricon <[email protected]>
  • Loading branch information
fbricon committed Apr 4, 2018
1 parent 7be84e8 commit 3a73faa
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,7 @@ private void handleBlockTags(String title, List<TagElement> tags) {
fBuf.append(BlOCK_TAG_ENTRY_END);
fBuf.append(BLOCK_TAG_END);
}
fBuf.append(BlOCK_TAG_ENTRY_END);
}

private void handleReturnTag(TagElement tag, CharSequence returnDescription) {
Expand All @@ -1827,11 +1828,15 @@ private void handleBlockTags(List<TagElement> tags) {
for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext();) {
TagElement tag = iter.next();
handleBlockTagTitle(tag.getTagName());
fBuf.append(BlOCK_TAG_ENTRY_START);
fBuf.append(BLOCK_TAG_START);
handleContentElements(tag.fragments());
List fragments = tag.fragments();
if (!fragments.isEmpty()) {
fBuf.append(BLOCK_TAG_START);
fBuf.append(BlOCK_TAG_ENTRY_START);
handleContentElements(fragments);
fBuf.append(BlOCK_TAG_ENTRY_END);
fBuf.append(BLOCK_TAG_END);
}
fBuf.append(BlOCK_TAG_ENTRY_END);
fBuf.append(BLOCK_TAG_END);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,42 @@ public void testHoverWhenLinkDoesNotExist() throws Exception {
assertMatches("This link doesnt work LinkToSomethingNotFound", content);
}

/**
* @param cu
* @return
*/

@Test
public void testHoverJavadocWithExtraTags() throws Exception {
IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
StringBuilder buf = new StringBuilder();
//@formatter:off
buf.append("package test1;\n");
buf.append("/**\n" +
" * Some text.\n" +
" *\n" +
" * @uses java.sql.Driver\n" +
" *\n" +
" * @moduleGraph\n" +
" * @since 9\n" +
" */\n");
buf.append("public class Meh {}\n");
//@formatter:on
ICompilationUnit cu = pack1.createCompilationUnit("Meh.java", buf.toString(), false, null);
Hover hover = getHover(cu, 9, 15);
assertNotNull(hover);
assertEquals(2, hover.getContents().size());

//@formatter:off
String expectedJavadoc = "Some text.\n" +
"\n" +
" * **Since:**\n" +
" \n" +
" * 9\n" +
" * **@uses**\n" +
" \n" +
" * java.sql.Driver\n" +
" * **@moduleGraph**";
//@formatter:on
assertEquals("Unexpected hover ", expectedJavadoc, hover.getContents().get(1).getLeft());
}

private String getTitleHover(ICompilationUnit cu, int line, int character) {
// when
Hover hover = getHover(cu, line, character);
Expand Down

0 comments on commit 3a73faa

Please sign in to comment.