Search in sources :

Example 11 with ContentNode

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

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