use of org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition in project n4js by eclipse.
the class DocletParserTest method testParserResumesAfterUnkonwLineTag.
@SuppressWarnings("javadoc")
@Test
public void testParserResumesAfterUnkonwLineTag() {
String in = "/** \n * @unkonwLineTag \n * @stubLineTagTitle1 \n * @stubLineTagTitle2 \n */";
AbstractLineTagDefinition tag0 = new StubLineTagDefinition("stubLineTagTitle0");
AbstractLineTagDefinition tag1 = new StubLineTagDefinition("stubLineTagTitle1");
AbstractLineTagDefinition tag2 = new StubLineTagDefinition("stubLineTagTitle2");
DocletParser docletParser = new DocletParser(new TagDictionary<>(Arrays.asList(tag0, tag1, tag2)), new TagDictionary<AbstractInlineTagDefinition>());
Doclet doclet = docletParser.parse(in);
EList<LineTag> lineTags = doclet.getLineTags();
assertEquals(2, lineTags.size());
// assuming that list is as parsing order
LineTag lineTag1 = lineTags.get(0);
assertEquals("stubLineTagTitle1", lineTag1.getTitle().getTitle());
LineTag lineTag2 = lineTags.get(1);
assertEquals("stubLineTagTitle2", lineTag2.getTitle().getTitle());
}
use of org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition in project n4js by eclipse.
the class DocletParserTest method testJSDocParsing.
@SuppressWarnings("javadoc")
@Test
public void testJSDocParsing() {
String in = "/** This is the description.\n * @stubLineTagTitle \n */";
AbstractLineTagDefinition tag = new StubLineTagDefinition("stubLineTagTitle");
DocletParser docletParser = new DocletParser(new TagDictionary<>(Arrays.asList(tag)), new TagDictionary<AbstractInlineTagDefinition>());
Doclet doclet = docletParser.parse(in);
Text descr = (Text) doclet.getContents().get(0);
assertEquals("This is the description.", descr.getText());
LineTag lineTag = doclet.getLineTags().get(0);
assertEquals("stubLineTagTitle", lineTag.getTitle().getTitle());
}
use of org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition in project n4js by eclipse.
the class DocletParserTest method testTrailingDescriptionIsIgnored.
@SuppressWarnings("javadoc")
@Test
public void testTrailingDescriptionIsIgnored() {
String in = "/** This is the description.\n * @stubLineTagTitle \n * Trailing description.\n */";
AbstractLineTagDefinition tag = new StubLineTagDefinition("stubLineTagTitle");
DocletParser docletParser = new DocletParser(new TagDictionary<>(Arrays.asList(tag)), new TagDictionary<AbstractInlineTagDefinition>());
Doclet doclet = docletParser.parse(in);
assertEquals(1, doclet.getContents().size());
assertEquals(1, doclet.getContents().size());
Text descr = (Text) doclet.getContents().get(0);
assertEquals("This is the description.", descr.getText());
LineTag lineTag = doclet.getLineTags().get(0);
assertEquals("stubLineTagTitle", lineTag.getTitle().getTitle());
}
use of org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition 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;
}
use of org.eclipse.n4js.jsdoc.tags.AbstractInlineTagDefinition 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());
}
Aggregations