Search in sources :

Example 21 with Text

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

the class AbstractInlineTagDefinition method convertToText.

/**
 * Convenience method.
 */
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 22 with Text

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

the class LineTagWithSimpleTextDefinition method parse.

/**
 * Parses section content and set it as {@link #VALUE}.
 */
@Override
public Tag parse(TagTitle title, JSDocCharScanner scanner, DescriptionParser descriptionParser) {
    ContentNode node = descriptionParser.parse(scanner, TagDictionary.emptyDict());
    if (!(node instanceof Text)) {
        // warning: node may now be null! (e.g. in case of a tag without content)
        String asText = node != null ? JSDocSerializer.toJSDocString(node) : "";
        if (asText.isEmpty()) {
            node = null;
        } else {
            Text text = DomFactory.eINSTANCE.createText();
            text.setText(asText);
            if (node == null) {
                text.setRange(scanner.nextOffset(), scanner.nextOffset());
            } else {
                text.setRange(node.getBegin(), node.getEnd());
            }
            node = text;
        }
    } else {
        Text text = (Text) node;
        if (text.getText().isEmpty()) {
            node = null;
        }
    }
    Tag tag = createLineTag(title);
    if (node != null) {
        addValue(tag, VALUE, node);
    }
    return tag;
}
Also used : Text(org.eclipse.n4js.jsdoc.dom.Text) LineTag(org.eclipse.n4js.jsdoc.dom.LineTag) Tag(org.eclipse.n4js.jsdoc.dom.Tag) ContentNode(org.eclipse.n4js.jsdoc.dom.ContentNode)

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