Search in sources :

Example 1 with TagTitle

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

the class InlineTagImpl method basicSetTitle.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetTitle(TagTitle newTitle, NotificationChain msgs) {
    TagTitle oldTitle = title;
    title = newTitle;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DomPackage.INLINE_TAG__TITLE, oldTitle, newTitle);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) TagTitle(org.eclipse.n4js.jsdoc.dom.TagTitle)

Example 2 with TagTitle

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

the class DocletParser method parse.

/**
 * @param commentString
 *            Input string that will be parsed. Multiline comment expected.
 * @return Instance of Doclet (not null, but may have no contents).
 */
public Doclet parse(String commentString) {
    JSDocCharScanner scanner = new JSDocCharScanner(commentString);
    // parse main description
    Doclet doclet = parseMainDescription(scanner);
    TagTitleTokenizer tagTitleTokenizer = new TagTitleTokenizer();
    JSDocToken token;
    // TODO error handling
    while (null != (token = tagTitleTokenizer.nextToken(scanner))) {
        ITagDefinition tagDefinition = lineTagDictionary.getDefinition(token.token);
        int lineTagEnd = scanner.findLineTagEnd();
        scanner.fence(lineTagEnd);
        if (tagDefinition != null) {
            TagTitle tagTitle = createTagTitle(token, tagDefinition);
            LineTag tag = (LineTag) tagDefinition.parse(tagTitle, scanner, descriptionParser);
            tag.setRange(token.start, scanner.offset());
            doclet.getLineTags().add(tag);
        }
        scanner.unfence();
        scanner.setNextOffset(lineTagEnd);
    }
    doclet.setEnd(scanner.offset());
    return doclet;
}
Also used : TagTitleTokenizer(org.eclipse.n4js.jsdoc.tokenizers.TagTitleTokenizer) LineTag(org.eclipse.n4js.jsdoc.dom.LineTag) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) TagTitle(org.eclipse.n4js.jsdoc.dom.TagTitle)

Example 3 with TagTitle

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

the class DescriptionParser method parseRegion.

/**
 * Method used to parse Region encountered in text. Expects {@link JSDocCharScanner#nextNonWS()} to be beginning of
 * region. It will use provided {@link TagDictionary} to recognize parse region. If no tags will mach parsed region,
 * null is returned. If region is maching one of {@link InlineTag} definitions it will return result of parsing
 * region with given tag.
 *
 * @param scanner
 *            JSDocCharScanner with offset_ before region
 * @param inlineTagsDictinary
 *            Dictionary of tags used to parse given region
 * @return Returns instance of Tag if parsed successfully, null otherwise.
 */
Tag parseRegion(JSDocCharScanner scanner, TagDictionary<AbstractInlineTagDefinition> inlineTagsDictinary) {
    ScannerState stateBeforeRegion = scanner.saveState();
    char _char = scanner.nextNonWS();
    // unsafe if region is marked by more than one char
    if (!regionStart(_char)) {
        return null;
    }
    scanner.skipWS();
    JSDocToken tokenTitle = TagTitleTokenizer.INSTANCE.nextToken(scanner);
    if (tokenTitle != null) {
        ITagDefinition iTagDefinition = inlineTagsDictinary.getDefinition(tokenTitle.token);
        if (iTagDefinition != null) {
            TagTitle tagTitle = createTagTitle(tokenTitle, iTagDefinition);
            AbstractInlineTagDefinition tagDefinition = (AbstractInlineTagDefinition) iTagDefinition;
            // although start of the region will be parsed twice (e.g. tag
            // title) it allows given tag implementation to decide what to
            // do with whole region, also might be important for nested
            // regions detection.
            scanner.restoreState(stateBeforeRegion);
            InlineTag tag = (InlineTag) tagDefinition.parse(tagTitle, scanner);
            tag.setRange(tokenTitle.start, scanner.offset());
            return tag;
        } else {
            System.err.println("silent ignore of unrecognized InlineTag {" + tokenTitle.token + "}");
            return null;
        }
    }
    return null;
}
Also used : InlineTag(org.eclipse.n4js.jsdoc.dom.InlineTag) AbstractInlineTagDefinition(org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition) TagTitle(org.eclipse.n4js.jsdoc.dom.TagTitle) ScannerState(org.eclipse.n4js.jsdoc.JSDocCharScanner.ScannerState)

Example 4 with TagTitle

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

the class TagImpl method basicSetTitle.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetTitle(TagTitle newTitle, NotificationChain msgs) {
    TagTitle oldTitle = title;
    title = newTitle;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DomPackage.TAG__TITLE, oldTitle, newTitle);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) TagTitle(org.eclipse.n4js.jsdoc.dom.TagTitle)

Example 5 with TagTitle

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

the class AbstractJSDocParser method createTagTitle.

/**
 * Creates tag title with actual and canonical title.
 */
protected TagTitle createTagTitle(JSDocToken token, ITagDefinition tagDefinition) {
    TagTitle tagTitle = DomFactory.eINSTANCE.createTagTitle();
    tagTitle.setTitle(tagDefinition.getTitle());
    tagTitle.setActualTitle(token.token);
    tagTitle.setBegin(token.start);
    tagTitle.setEnd(token.end);
    return tagTitle;
}
Also used : TagTitle(org.eclipse.n4js.jsdoc.dom.TagTitle)

Aggregations

TagTitle (org.eclipse.n4js.jsdoc.dom.TagTitle)5 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 ScannerState (org.eclipse.n4js.jsdoc.JSDocCharScanner.ScannerState)1 Doclet (org.eclipse.n4js.jsdoc.dom.Doclet)1 InlineTag (org.eclipse.n4js.jsdoc.dom.InlineTag)1 LineTag (org.eclipse.n4js.jsdoc.dom.LineTag)1 AbstractInlineTagDefinition (org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition)1 TagTitleTokenizer (org.eclipse.n4js.jsdoc.tokenizers.TagTitleTokenizer)1