Search in sources :

Example 1 with ContentNode

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

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

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

the class DocletDescriptionParserTest method testSimpleDescription.

@SuppressWarnings("javadoc")
@Test
public void testSimpleDescription() {
    String in = "/** This is the description.\n */";
    DocletParser docletParser = new DocletParser(null, null);
    Doclet doclet = docletParser.parse(in);
    EList<ContentNode> contents = doclet.getContents();
    ContentNode node = contents.get(0);
    Text descriptionText = (Text) node;
    assertEquals("This is the description.", descriptionText.getText());
}
Also used : Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) Text(org.eclipse.n4js.jsdoc.dom.Text) ContentNode(org.eclipse.n4js.jsdoc.dom.ContentNode) Test(org.junit.Test)

Example 4 with ContentNode

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

the class LineTagWithFullMemberReferenceTest method test_fullRef_simpleName.

@SuppressWarnings("javadoc")
@Test
public void test_fullRef_simpleName() {
    String in = "/** foo." + "\n * @testee n4/model/collections/DataSet.DataSet.each" + "\n */";
    AbstractLineTagDefinition tagDef = new LineTagWithFullMemberReference("testee");
    DocletParser docletParser = new DocletParser(new TagDictionary<>(Arrays.asList(tagDef)), new TagDictionary<AbstractInlineTagDefinition>());
    Doclet doclet = docletParser.parse(in);
    LineTag lineTag = doclet.getLineTags().get(0);
    EList<ContentNode> contents = lineTag.getValueByKey(LineTagWithFullElementReference.REF).getContents();
    FullMemberReference ref = (FullMemberReference) contents.get(0);
    assertEquals("n4/model/collections/DataSet", ref.getModuleName());
    assertEquals("DataSet", ref.getTypeName());
    assertEquals("each", ref.getMemberName());
}
Also used : LineTag(org.eclipse.n4js.jsdoc.dom.LineTag) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) DocletParser(org.eclipse.n4js.jsdoc.DocletParser) ContentNode(org.eclipse.n4js.jsdoc.dom.ContentNode) FullMemberReference(org.eclipse.n4js.jsdoc.dom.FullMemberReference) Test(org.junit.Test)

Example 5 with ContentNode

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

ContentNode (org.eclipse.n4js.jsdoc.dom.ContentNode)11 Doclet (org.eclipse.n4js.jsdoc.dom.Doclet)8 Test (org.junit.Test)7 Text (org.eclipse.n4js.jsdoc.dom.Text)6 DocletParser (org.eclipse.n4js.jsdoc.DocletParser)3 Composite (org.eclipse.n4js.jsdoc.dom.Composite)3 InlineTag (org.eclipse.n4js.jsdoc.dom.InlineTag)3 LineTag (org.eclipse.n4js.jsdoc.dom.LineTag)3 Tag (org.eclipse.n4js.jsdoc.dom.Tag)3 TagValue (org.eclipse.n4js.jsdoc.dom.TagValue)3 AbstractInlineTagDefinition (org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition)3 FullMemberReference (org.eclipse.n4js.jsdoc.dom.FullMemberReference)2 JSDocToken (org.eclipse.n4js.jsdoc.JSDocToken)1 TagDictionary (org.eclipse.n4js.jsdoc.TagDictionary)1