Search in sources :

Example 1 with AbstractInlineTagDefinition

use of org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition in project n4js by eclipse.

the class DocletDescriptionParserTest method testParserResumesAfterUnkownInlineTag.

@SuppressWarnings("javadoc")
@Test
public void testParserResumesAfterUnkownInlineTag() {
    String in = "/** This is the description with {@unkonwnInlineTag parsed as text} ... text in between... {@inline tag description} ..and finish description. \n */";
    AbstractInlineTagDefinition inlineTag = new StubInlineTagDefinition("inline");
    DocletParser docletParser = new DocletParser(null, new TagDictionary<>(Arrays.asList(inlineTag)));
    Doclet doclet = docletParser.parse(in);
    EList<ContentNode> contents = doclet.getContents();
    Composite composite = (Composite) contents.get(0);
    ContentNode node0 = composite.getContents().get(0);
    ContentNode node1 = composite.getContents().get(1);
    ContentNode node2 = composite.getContents().get(2);
    Text descriptionText1 = (Text) node0;
    InlineTag descriptionInlineTag = (InlineTag) node1;
    Text descriptionText2 = (Text) node2;
    assertEquals("This is the description with {@unkonwnInlineTag parsed as text} ... text in between... ", descriptionText1.getText());
    assertEquals(" ..and finish description.", descriptionText2.getText());
    TagValue inlineDescription = descriptionInlineTag.getValueByKey(StubInlineTagDefinition.PARAM_VALUE);
    Text tValue = (Text) inlineDescription.getContents().get(0);
    assertEquals(" tag description", tValue.getText());
}
Also used : InlineTag(org.eclipse.n4js.jsdoc.dom.InlineTag) Composite(org.eclipse.n4js.jsdoc.dom.Composite) AbstractInlineTagDefinition(org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) Text(org.eclipse.n4js.jsdoc.dom.Text) TagValue(org.eclipse.n4js.jsdoc.dom.TagValue) ContentNode(org.eclipse.n4js.jsdoc.dom.ContentNode) Test(org.junit.Test)

Example 2 with AbstractInlineTagDefinition

use of org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition in project n4js by eclipse.

the class DocletDescriptionParserTest method testDescriptionWithInline.

@SuppressWarnings("javadoc")
@Test
public void testDescriptionWithInline() {
    String in = "/** This is the description with {@inline tag description} ..and finish description. \n */";
    AbstractInlineTagDefinition inlineTag = new StubInlineTagDefinition("inline");
    DocletParser docletParser = new DocletParser(null, new TagDictionary<>(Arrays.asList(inlineTag)));
    Doclet doclet = docletParser.parse(in);
    EList<ContentNode> contents = doclet.getContents();
    Composite composite = (Composite) contents.get(0);
    ContentNode node0 = composite.getContents().get(0);
    ContentNode node1 = composite.getContents().get(1);
    ContentNode node2 = composite.getContents().get(2);
    Text descriptionText1 = (Text) node0;
    InlineTag descriptionInlineTag = (InlineTag) node1;
    Text descriptionText2 = (Text) node2;
    assertEquals("This is the description with ", descriptionText1.getText());
    assertEquals(" ..and finish description.", descriptionText2.getText());
    TagValue inlineDescription = descriptionInlineTag.getValueByKey(StubInlineTagDefinition.PARAM_VALUE);
    Text tValue = (Text) inlineDescription.getContents().get(0);
    assertEquals(" tag description", tValue.getText());
}
Also used : InlineTag(org.eclipse.n4js.jsdoc.dom.InlineTag) Composite(org.eclipse.n4js.jsdoc.dom.Composite) AbstractInlineTagDefinition(org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) Text(org.eclipse.n4js.jsdoc.dom.Text) TagValue(org.eclipse.n4js.jsdoc.dom.TagValue) ContentNode(org.eclipse.n4js.jsdoc.dom.ContentNode) Test(org.junit.Test)

Example 3 with AbstractInlineTagDefinition

use of org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition in project n4js by eclipse.

the class DocletParserTest method testJSDocParsingWithManyLineTags.

@SuppressWarnings("javadoc")
@Test
public void testJSDocParsingWithManyLineTags() {
    String in = "/** \n * @stubLineTagTitle0 \n * @stubLineTagTitle1 \n * @stubLineTagTitle2 \n */";
    AbstractLineTagDefinition tag0 = new StubLineTagDefinition("stubLineTagTitle0");
    AbstractLineTagDefinition tag1 = new StubLineTagDefinition("stubLineTagTitle1");
    AbstractLineTagDefinition tag2 = new StubLineTagDefinition("stubLineTagTitle2");
    DocletParser docletParser = new DocletParser(new TagDictionary<>(Arrays.asList(tag0, tag1, tag2)), new TagDictionary<AbstractInlineTagDefinition>());
    Doclet doclet = docletParser.parse(in);
    EList<LineTag> lineTags = doclet.getLineTags();
    assertEquals(3, lineTags.size());
    // assuming that list is as parsing order
    LineTag lineTag0 = lineTags.get(0);
    assertEquals("stubLineTagTitle0", lineTag0.getTitle().getTitle());
    LineTag lineTag1 = lineTags.get(1);
    assertEquals("stubLineTagTitle1", lineTag1.getTitle().getTitle());
    LineTag lineTag2 = lineTags.get(2);
    assertEquals("stubLineTagTitle2", lineTag2.getTitle().getTitle());
}
Also used : LineTag(org.eclipse.n4js.jsdoc.dom.LineTag) AbstractLineTagDefinition(org.eclipse.n4js.jsdoc.tags.AbstractLineTagDefinition) AbstractInlineTagDefinition(org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) Test(org.junit.Test)

Example 4 with AbstractInlineTagDefinition

use of org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition in project n4js by eclipse.

the class DocletParserTest method testJSDocParsingWithoutLineTags.

@SuppressWarnings("javadoc")
@Test
public void testJSDocParsingWithoutLineTags() {
    String in = "/** Just free text.\n */";
    AbstractLineTagDefinition tag = new StubLineTagDefinition("stubLineTagTitle");
    DocletParser docletParser = new DocletParser(new TagDictionary<>(Arrays.asList(tag)), new TagDictionary<AbstractInlineTagDefinition>());
    Doclet doclet = docletParser.parse(in);
    Text descr = (Text) doclet.getContents().get(0);
    assertEquals("Just free text.", descr.getText());
}
Also used : AbstractLineTagDefinition(org.eclipse.n4js.jsdoc.tags.AbstractLineTagDefinition) AbstractInlineTagDefinition(org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) Text(org.eclipse.n4js.jsdoc.dom.Text) Test(org.junit.Test)

Example 5 with AbstractInlineTagDefinition

use of org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition in project n4js by eclipse.

the class DocletParserTest method testTrailingDescriptionAndAllThatFollowsIsIgnored.

@SuppressWarnings("javadoc")
@Test
public void testTrailingDescriptionAndAllThatFollowsIsIgnored() {
    String in = "/** This is the description." + "\n * @stubLineTagTitle " + "\n * Trailing description." + "\n * @stubLineTagTitle2 " + "\n */";
    AbstractLineTagDefinition tag = new StubLineTagDefinition("stubLineTagTitle");
    AbstractLineTagDefinition tag2 = new StubLineTagDefinition("stubLineTagTitle2");
    DocletParser docletParser = new DocletParser(new TagDictionary<>(Arrays.asList(tag, tag2)), new TagDictionary<AbstractInlineTagDefinition>());
    Doclet doclet = docletParser.parse(in);
    assertEquals(1, doclet.getContents().size());
    Text descr = (Text) doclet.getContents().get(0);
    assertEquals("This is the description.", descr.getText());
    assertEquals(2, doclet.getLineTags().size());
    LineTag lineTag = doclet.getLineTags().get(0);
    assertEquals("stubLineTagTitle", lineTag.getTitle().getTitle());
}
Also used : LineTag(org.eclipse.n4js.jsdoc.dom.LineTag) AbstractLineTagDefinition(org.eclipse.n4js.jsdoc.tags.AbstractLineTagDefinition) AbstractInlineTagDefinition(org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) Text(org.eclipse.n4js.jsdoc.dom.Text) Test(org.junit.Test)

Aggregations

AbstractInlineTagDefinition (org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition)12 Doclet (org.eclipse.n4js.jsdoc.dom.Doclet)11 Test (org.junit.Test)11 AbstractLineTagDefinition (org.eclipse.n4js.jsdoc.tags.AbstractLineTagDefinition)8 Text (org.eclipse.n4js.jsdoc.dom.Text)7 LineTag (org.eclipse.n4js.jsdoc.dom.LineTag)6 ContentNode (org.eclipse.n4js.jsdoc.dom.ContentNode)3 InlineTag (org.eclipse.n4js.jsdoc.dom.InlineTag)3 Composite (org.eclipse.n4js.jsdoc.dom.Composite)2 TagValue (org.eclipse.n4js.jsdoc.dom.TagValue)2 ScannerState (org.eclipse.n4js.jsdoc.JSDocCharScanner.ScannerState)1 TagTitle (org.eclipse.n4js.jsdoc.dom.TagTitle)1