Search in sources :

Example 6 with JSDocToken

use of org.eclipse.n4js.jsdoc.JSDocToken in project n4js by eclipse.

the class TextTokenizerTest method test.

@SuppressWarnings("javadoc")
@Test
public void test() {
    TextTokenizer TEXT = TextTokenizer.INSTANCE;
    assertEquals(new JSDocToken("Hello World", 0, 10), TEXT.nextToken(new JSDocCharScanner("Hello World")));
    assertEquals(new JSDocToken("Hello World", 7, 17), TEXT.nextToken(new JSDocCharScanner("/**\n * Hello World")));
    assertEquals(new JSDocToken("Hello World", 7, 17), TEXT.nextToken(new JSDocCharScanner("/**\n * Hello World", 7)));
    assertEquals(new JSDocToken("Hello World", 7, 17), TEXT.nextToken(new JSDocCharScanner("/**\n * Hello World */", 7)));
    assertEquals(new JSDocToken("Hello World ", 7, 18), TEXT.nextToken(new JSDocCharScanner("/**\n * Hello World {@code sample} */")));
}
Also used : JSDocCharScanner(org.eclipse.n4js.jsdoc.JSDocCharScanner) JSDocToken(org.eclipse.n4js.jsdoc.JSDocToken) Test(org.junit.Test)

Example 7 with JSDocToken

use of org.eclipse.n4js.jsdoc.JSDocToken in project n4js by eclipse.

the class StubLineTagWithRegionDefinition method parse.

@Override
public Tag parse(TagTitle title, JSDocCharScanner scanner, DescriptionParser descriptionParser) {
    Tag paramTag = createLineTag(title);
    scanner.skipWS();
    JSDocToken region = InlineTagTokenizer.INSTANCE.nextToken(scanner);
    if (region != null) {
        addValue(paramTag, REGION, region);
    }
    // silent ignore no region
    scanner.skipWS();
    // expect no tags in descritpion
    TagDictionary<AbstractInlineTagDefinition> dictionary = new TagDictionary<>();
    ContentNode description = descriptionParser.parse(scanner, dictionary);
    if (description != null) {
        addValue(paramTag, DESCR, description);
    }
    return paramTag;
}
Also used : TagDictionary(org.eclipse.n4js.jsdoc.TagDictionary) Tag(org.eclipse.n4js.jsdoc.dom.Tag) JSDocToken(org.eclipse.n4js.jsdoc.JSDocToken) ContentNode(org.eclipse.n4js.jsdoc.dom.ContentNode)

Example 8 with JSDocToken

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

JSDocToken (org.eclipse.n4js.jsdoc.JSDocToken)8 JSDocCharScanner (org.eclipse.n4js.jsdoc.JSDocCharScanner)4 Test (org.junit.Test)4 Tag (org.eclipse.n4js.jsdoc.dom.Tag)3 Text (org.eclipse.n4js.jsdoc.dom.Text)2 TagDictionary (org.eclipse.n4js.jsdoc.TagDictionary)1 ContentNode (org.eclipse.n4js.jsdoc.dom.ContentNode)1 InlineTag (org.eclipse.n4js.jsdoc.dom.InlineTag)1