Search in sources :

Example 16 with Text

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

the class StubInlineTagDefinition method convertToText.

/**
 * Converts the given token to a DOM text element.
 */
@Override
protected Text convertToText(JSDocToken descr) {
    Text text = DOM.createText();
    text.setText(descr.token);
    text.setBegin(descr.start);
    text.setEnd(descr.end);
    return text;
}
Also used : Text(org.eclipse.n4js.jsdoc.dom.Text)

Example 17 with Text

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

the class DescriptionParser method saveTextTokens.

private void saveTextTokens(ComposedContent description, int start, int end, StringBuilder strb) {
    Text text = DomFactory.eINSTANCE.createText();
    JSDocToken token = new JSDocToken(strb.toString(), start, end);
    text.setText(token.token);
    text.setBegin(token.start);
    text.setEnd(token.end);
    description.getContents().add(text);
}
Also used : Text(org.eclipse.n4js.jsdoc.dom.Text)

Example 18 with Text

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

the class DocletDescriptionParserTest method testDescriptionWithUnknownInlineTag.

@SuppressWarnings("javadoc")
@Test
public void testDescriptionWithUnknownInlineTag() {
    String in = "/** This is the description with {@unkonwnInlineTag parsed as text} ..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();
    Text descr = (Text) contents.get(0);
    assertEquals("This is the description with {@unkonwnInlineTag parsed as text} ..and finish description.", descr.getText());
}
Also used : AbstractInlineTagDefinition(org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition) 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 19 with Text

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

the class LineTagTest method testLineTagWithRegion.

@SuppressWarnings("javadoc")
@Test
public void testLineTagWithRegion() {
    String in = "/** foo.\n * @stubLineTagTitle {@region value} \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());
}
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 20 with Text

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

the class StubInlineTagDefinition method parse.

@Override
public Tag parse(TagTitle title, JSDocCharScanner scanner) {
    Tag paramTag = createInlineTag(title);
    scanner.skipWS();
    JSDocToken description = InlineTagTokenizer.INSTANCE.nextToken(scanner);
    if (description != null) {
        String raw = convertToText(description).getText();
        int titleOff = raw.indexOf(title.getTitle());
        int titleLen = title.getTitle().length();
        int fix = titleOff + titleLen;
        raw = raw.substring(fix);
        Text text = DOM.createText();
        text.setText(raw);
        text.setBegin(description.start + fix);
        text.setEnd(description.end);
        addValue(paramTag, PARAM_VALUE, text);
    }
    return paramTag;
}
Also used : Text(org.eclipse.n4js.jsdoc.dom.Text) Tag(org.eclipse.n4js.jsdoc.dom.Tag) JSDocToken(org.eclipse.n4js.jsdoc.JSDocToken)

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