Search in sources :

Example 11 with Text

use of org.eclipse.n4js.jsdoc.dom.Text 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 12 with Text

use of org.eclipse.n4js.jsdoc.dom.Text 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)

Example 13 with Text

use of org.eclipse.n4js.jsdoc.dom.Text in project n4js by eclipse.

the class DocletParserTest method testJSDocParsing.

@SuppressWarnings("javadoc")
@Test
public void testJSDocParsing() {
    String in = "/** This is the description.\n * @stubLineTagTitle \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("This is the description.", descr.getText());
    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)

Example 14 with Text

use of org.eclipse.n4js.jsdoc.dom.Text in project n4js by eclipse.

the class DocletParserTest method testTrailingDescriptionIsIgnored.

@SuppressWarnings("javadoc")
@Test
public void testTrailingDescriptionIsIgnored() {
    String in = "/** This is the description.\n * @stubLineTagTitle \n * Trailing description.\n */";
    AbstractLineTagDefinition tag = new StubLineTagDefinition("stubLineTagTitle");
    DocletParser docletParser = new DocletParser(new TagDictionary<>(Arrays.asList(tag)), new TagDictionary<AbstractInlineTagDefinition>());
    Doclet doclet = docletParser.parse(in);
    assertEquals(1, doclet.getContents().size());
    assertEquals(1, doclet.getContents().size());
    Text descr = (Text) doclet.getContents().get(0);
    assertEquals("This is the description.", descr.getText());
    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)

Example 15 with Text

use of org.eclipse.n4js.jsdoc.dom.Text in project n4js by eclipse.

the class InlineTagTest method testSimpleLineTag.

@SuppressWarnings("javadoc")
@Test
public void testSimpleLineTag() {
    String in = "/** Some Description {@inline me} some other text. \n */";
    AbstractInlineTagDefinition tag = new StubInlineTagDefinition("inline");
    DocletParser docletParser = new DocletParser(new TagDictionary<AbstractLineTagDefinition>(), new TagDictionary<>(Arrays.asList(tag)));
    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("Some Description ", descriptionText1.getText());
    assertEquals(" some other text.", descriptionText2.getText());
    TagValue inlineDescription = descriptionInlineTag.getValueByKey(StubInlineTagDefinition.PARAM_VALUE);
    Text tValue = (Text) inlineDescription.getContents().get(0);
    assertEquals(" me", tValue.getText());
}
Also used : Composite(org.eclipse.n4js.jsdoc.dom.Composite) Text(org.eclipse.n4js.jsdoc.dom.Text) ContentNode(org.eclipse.n4js.jsdoc.dom.ContentNode) InlineTag(org.eclipse.n4js.jsdoc.dom.InlineTag) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) DocletParser(org.eclipse.n4js.jsdoc.DocletParser) TagValue(org.eclipse.n4js.jsdoc.dom.TagValue) Test(org.junit.Test)

Aggregations

Text (org.eclipse.n4js.jsdoc.dom.Text)22 Doclet (org.eclipse.n4js.jsdoc.dom.Doclet)14 Test (org.junit.Test)14 LineTag (org.eclipse.n4js.jsdoc.dom.LineTag)7 AbstractInlineTagDefinition (org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition)7 DocletParser (org.eclipse.n4js.jsdoc.DocletParser)6 ContentNode (org.eclipse.n4js.jsdoc.dom.ContentNode)6 TagValue (org.eclipse.n4js.jsdoc.dom.TagValue)6 InlineTag (org.eclipse.n4js.jsdoc.dom.InlineTag)4 AbstractLineTagDefinition (org.eclipse.n4js.jsdoc.tags.AbstractLineTagDefinition)4 Composite (org.eclipse.n4js.jsdoc.dom.Composite)3 Tag (org.eclipse.n4js.jsdoc.dom.Tag)3 JSDocToken (org.eclipse.n4js.jsdoc.JSDocToken)2 N4JSDocletParser (org.eclipse.n4js.jsdoc.N4JSDocletParser)2