Search in sources :

Example 1 with Doclet

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

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

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

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

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

the class LineTagTest method testSimpleLineTag.

@SuppressWarnings("javadoc")
@Test
public void testSimpleLineTag() {
    String in = "/** foo.\n * @stubLineTagTitle \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);
    assertEquals("stubLineTagTitle", lineTag.getTitle().getTitle());
}
Also used : LineTag(org.eclipse.n4js.jsdoc.dom.LineTag) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) DocletParser(org.eclipse.n4js.jsdoc.DocletParser) Test(org.junit.Test)

Aggregations

Doclet (org.eclipse.n4js.jsdoc.dom.Doclet)28 Test (org.junit.Test)21 LineTag (org.eclipse.n4js.jsdoc.dom.LineTag)14 Text (org.eclipse.n4js.jsdoc.dom.Text)14 DocletParser (org.eclipse.n4js.jsdoc.DocletParser)11 AbstractInlineTagDefinition (org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition)11 ContentNode (org.eclipse.n4js.jsdoc.dom.ContentNode)8 AbstractLineTagDefinition (org.eclipse.n4js.jsdoc.tags.AbstractLineTagDefinition)8 TagValue (org.eclipse.n4js.jsdoc.dom.TagValue)6 N4JSDocletParser (org.eclipse.n4js.jsdoc.N4JSDocletParser)5 FullMemberReference (org.eclipse.n4js.jsdoc.dom.FullMemberReference)4 Composite (org.eclipse.n4js.jsdoc.dom.Composite)3 InlineTag (org.eclipse.n4js.jsdoc.dom.InlineTag)3 ArrayList (java.util.ArrayList)2 EObject (org.eclipse.emf.ecore.EObject)2 TMember (org.eclipse.n4js.ts.types.TMember)2 Optional (java.util.Optional)1 EcoreUtil (org.eclipse.emf.ecore.util.EcoreUtil)1 ITextViewer (org.eclipse.jface.text.ITextViewer)1 CompletionProposal (org.eclipse.jface.text.contentassist.CompletionProposal)1