Skip to content

Commit

Permalink
Support {@systemProperty <name>} tag
Browse files Browse the repository at this point in the history
  • Loading branch information
matozoid committed Feb 19, 2019
1 parent 1fe3bfe commit 60b6410
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
Expand Up @@ -33,7 +33,9 @@

import static com.github.javaparser.StaticJavaParser.parse;
import static com.github.javaparser.StaticJavaParser.parseJavadoc;
import static com.github.javaparser.javadoc.description.JavadocInlineTag.Type.*;
import static com.github.javaparser.utils.Utils.EOL;
import static java.util.stream.Collectors.toList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand Down Expand Up @@ -88,13 +90,30 @@ void descriptionAndBlockTagsAreRetrievable() {
void inlineTagsAreParsable() {
String docText =
"Returns the {@link TOFilename}s of all files that existed during the requested" + EOL +
"{@link TOVersion}." + EOL +
"{@link TOVersion}. Set {@systemProperty JAVA_HOME} correctly." + EOL +
"" + EOL +
"@param versionID the id of the {@link TOVersion}." + EOL +
"@return the filenames" + EOL +
"@throws InvalidIDException if the {@link IPersistence} doesn't recognize the given versionID." + EOL;
String javadoc = parseJavadoc(docText).toText();
assertTrue(javadoc.contains("{@link TOVersion}"));
Javadoc javadoc = parseJavadoc(docText);

List<JavadocInlineTag> inlineTags = javadoc.getDescription().getElements().stream()
.filter(element -> element instanceof JavadocInlineTag)
.map(element -> (JavadocInlineTag) element)
.collect(toList());

assertEquals("link", inlineTags.get(0).getName());
assertEquals(" TOFilename", inlineTags.get(0).getContent());
assertEquals(LINK, inlineTags.get(0).getType());
assertEquals("link", inlineTags.get(1).getName());
assertEquals(" TOVersion", inlineTags.get(1).getContent());
assertEquals(LINK, inlineTags.get(1).getType());
assertEquals("systemProperty", inlineTags.get(2).getName());
assertEquals(" JAVA_HOME", inlineTags.get(2).getContent());
assertEquals(SYSTEM_PROPERTY, inlineTags.get(2).getType());

String javadocText = javadoc.toText();
assertTrue(javadocText.contains("{@link TOVersion}"));
}

@Test
Expand Down Expand Up @@ -131,7 +150,7 @@ void descriptionModificationWorks() {

assertEquals(0, description.getElements().size());

JavadocDescriptionElement inlineTag = new JavadocInlineTag("inheritDoc", JavadocInlineTag.Type.INHERIT_DOC, "");
JavadocDescriptionElement inlineTag = new JavadocInlineTag("inheritDoc", INHERIT_DOC, "");
assertTrue(description.addElement(inlineTag));

assertEquals(1, description.getElements().size());
Expand All @@ -147,7 +166,7 @@ void issue1533() {
List<JavadocDescriptionElement> elements = compilationUnit.getType(0).getJavadoc().get().getDescription().getElements();
assertEquals(3, elements.size());
assertEquals(new JavadocSnippet("hallo "), elements.get(0));
assertEquals(new JavadocInlineTag("link", JavadocInlineTag.Type.LINK, " Foo"), elements.get(1));
assertEquals(new JavadocInlineTag("link", LINK, " Foo"), elements.get(1));
assertEquals(new JavadocSnippet(" welt"), elements.get(2));
}
}
Expand Up @@ -57,6 +57,7 @@ public enum Type {
LINKPLAIN,
LITERAL,
VALUE,
SYSTEM_PROPERTY,
UNKNOWN;

Type() {
Expand Down

0 comments on commit 60b6410

Please sign in to comment.