Search in sources :

Example 1 with TagValue

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

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

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

the class LineTagTest method testLineTagDescr.

@SuppressWarnings("javadoc")
@Test
public void testLineTagDescr() {
    String in = "/** foo." + "\n * @stubLineTagTitle  tag description. " + "\n */";
    AbstractLineTagDefinition tag = new StubLineTagWithRegionDefinition("stubLineTagTitle");
    DocletParser docletParser = new DocletParser(new TagDictionary<>(Arrays.asList(tag)), new TagDictionary<AbstractInlineTagDefinition>());
    Doclet doclet = docletParser.parse(in);
    LineTag lineTag = doclet.getLineTags().get(0);
    TagValue vDescription = lineTag.getValueByKey(StubLineTagWithRegionDefinition.DESCR);
    Text tabDescription = (Text) vDescription.getContents().get(0);
    String deString = tabDescription.getText();
    assertEquals("tag description. ", deString);
}
Also used : LineTag(org.eclipse.n4js.jsdoc.dom.LineTag) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) DocletParser(org.eclipse.n4js.jsdoc.DocletParser) Text(org.eclipse.n4js.jsdoc.dom.Text) TagValue(org.eclipse.n4js.jsdoc.dom.TagValue) Test(org.junit.Test)

Example 4 with TagValue

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

the class LineTagTest method testLineTagWithRegionAndDescr.

@SuppressWarnings("javadoc")
@Test
public void testLineTagWithRegionAndDescr() {
    String in = "/** foo.\n * @stubLineTagTitle {@region value} tag description. \n */";
    AbstractLineTagDefinition tag = new StubLineTagWithRegionDefinition("stubLineTagTitle");
    DocletParser docletParser = new DocletParser(new TagDictionary<>(Arrays.asList(tag)), new TagDictionary<AbstractInlineTagDefinition>());
    Doclet doclet = docletParser.parse(in);
    LineTag lineTag = doclet.getLineTags().get(0);
    TagValue region = lineTag.getValueByKey(StubLineTagWithRegionDefinition.REGION);
    Text strcturedText = (Text) region.getContents().get(0);
    assertEquals("@region value", strcturedText.getText());
    TagValue vDescription = lineTag.getValueByKey(StubLineTagWithRegionDefinition.DESCR);
    Text tabDescription = (Text) vDescription.getContents().get(0);
    String deString = tabDescription.getText();
    assertEquals("tag description. ", deString);
}
Also used : LineTag(org.eclipse.n4js.jsdoc.dom.LineTag) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) DocletParser(org.eclipse.n4js.jsdoc.DocletParser) Text(org.eclipse.n4js.jsdoc.dom.Text) TagValue(org.eclipse.n4js.jsdoc.dom.TagValue) Test(org.junit.Test)

Example 5 with TagValue

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

the class AbstractBaseTagDefinition method addValue.

/**
 * Creates {@link TagValue} that will hold provided contents. It will be stored in provided {@link Tag} values under
 * provided key.
 *
 * @param tag
 *            To which we add value
 * @param key
 *            That will associated with the value
 * @param contents
 *            That will be added as value
 * @return Created {@link TagValue} or null
 */
protected TagValue addValue(Tag tag, String key, Collection<? extends ContentNode> contents) {
    TagValue tagValue = DOM.createTagValue();
    tagValue.setKey(key);
    tagValue.setBegin(JSDocUtils.getBegin(contents));
    tagValue.setEnd(JSDocUtils.getEnd(contents));
    tagValue.getContents().addAll(contents);
    tag.getValues().add(tagValue);
    return tagValue;
}
Also used : TagValue(org.eclipse.n4js.jsdoc.dom.TagValue)

Aggregations

TagValue (org.eclipse.n4js.jsdoc.dom.TagValue)9 Doclet (org.eclipse.n4js.jsdoc.dom.Doclet)6 Text (org.eclipse.n4js.jsdoc.dom.Text)6 Test (org.junit.Test)6 DocletParser (org.eclipse.n4js.jsdoc.DocletParser)4 Composite (org.eclipse.n4js.jsdoc.dom.Composite)3 ContentNode (org.eclipse.n4js.jsdoc.dom.ContentNode)3 InlineTag (org.eclipse.n4js.jsdoc.dom.InlineTag)3 LineTag (org.eclipse.n4js.jsdoc.dom.LineTag)3 AbstractInlineTagDefinition (org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition)2