Search in sources :

Example 1 with JSDocCharScanner

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

the class TagTitleTokenizerTest method test.

@SuppressWarnings("javadoc")
@Test
public void test() {
    TagTitleTokenizer tokenizer = new TagTitleTokenizer();
    assertEquals(new JSDocToken("Test", 1, 4), tokenizer.nextToken(new JSDocCharScanner("@Test Hello World")));
    assertEquals(new JSDocToken("Test", 1, 4), tokenizer.nextToken(new JSDocCharScanner("@Test\nHello World")));
    assertEquals(new JSDocToken("Test", 1, 4), tokenizer.nextToken(new JSDocCharScanner("@Test\n * Hello World")));
    assertNull(tokenizer.nextToken(new JSDocCharScanner("@ Hello World")));
    assertNull(tokenizer.nextToken(new JSDocCharScanner("Test Hello World")));
    assertNull(tokenizer.nextToken(new JSDocCharScanner("Test @Hello World")));
}
Also used : JSDocCharScanner(org.eclipse.n4js.jsdoc.JSDocCharScanner) JSDocToken(org.eclipse.n4js.jsdoc.JSDocToken) Test(org.junit.Test)

Example 2 with JSDocCharScanner

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

the class RegionTokenizerTest method testSimple.

@SuppressWarnings("javadoc")
@Test
public void testSimple() {
    RegionTokenizer rt = new RegionTokenizer("{", "}", true, '\\', false, false);
    JSDocCharScanner scanner = new JSDocCharScanner("{simple}");
    assertEquals("simple", rt.nextToken(scanner).token);
    scanner = new JSDocCharScanner("{simple} and more");
    assertEquals("simple", rt.nextToken(scanner).token);
    // ws are not skipped!
    scanner = new JSDocCharScanner(" {simple} and more");
    assertNull(rt.nextToken(scanner));
    scanner = new JSDocCharScanner("{simple and more");
    assertNull(rt.nextToken(scanner));
    scanner = new JSDocCharScanner("simple} and more");
    assertNull(rt.nextToken(scanner));
    scanner = new JSDocCharScanner("x {simple} and more");
    assertNull(rt.nextToken(scanner));
}
Also used : JSDocCharScanner(org.eclipse.n4js.jsdoc.JSDocCharScanner) Test(org.junit.Test)

Example 3 with JSDocCharScanner

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

the class RegionTokenizerTest method testSimpleIncludeTags.

@SuppressWarnings("javadoc")
@Test
public void testSimpleIncludeTags() {
    RegionTokenizer rt = new RegionTokenizer("{", "}", true, '\\', true, false);
    JSDocCharScanner scanner = new JSDocCharScanner("{simple}");
    assertEquals("{simple}", rt.nextToken(scanner).token);
    scanner = new JSDocCharScanner("{simple} and more");
    assertEquals("{simple}", rt.nextToken(scanner).token);
}
Also used : JSDocCharScanner(org.eclipse.n4js.jsdoc.JSDocCharScanner) Test(org.junit.Test)

Example 4 with JSDocCharScanner

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

the class TextTokenizerTest method testLinebreak.

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

Example 5 with JSDocCharScanner

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

the class TextTokenizerTest method testEmpty.

@SuppressWarnings("javadoc")
@Test
public void testEmpty() {
    TextTokenizer TEXT = TextTokenizer.INSTANCE;
    assertEquals(new JSDocToken("\n", 1, 1), TEXT.nextToken(new JSDocCharScanner("x\n cont", 1)));
    assertNull(TEXT.nextToken(new JSDocCharScanner("x*/", 1)));
}
Also used : JSDocCharScanner(org.eclipse.n4js.jsdoc.JSDocCharScanner) JSDocToken(org.eclipse.n4js.jsdoc.JSDocToken) Test(org.junit.Test)

Aggregations

JSDocCharScanner (org.eclipse.n4js.jsdoc.JSDocCharScanner)12 Test (org.junit.Test)11 JSDocToken (org.eclipse.n4js.jsdoc.JSDocToken)4 ArrayList (java.util.ArrayList)1 Optional (java.util.Optional)1 EcoreUtil (org.eclipse.emf.ecore.util.EcoreUtil)1 ITextViewer (org.eclipse.jface.text.ITextViewer)1 CompletionProposal (org.eclipse.jface.text.contentassist.CompletionProposal)1 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)1 ITagDefinition (org.eclipse.n4js.jsdoc.ITagDefinition)1 ScannerState (org.eclipse.n4js.jsdoc.JSDocCharScanner.ScannerState)1 JSDocCompletionHint (org.eclipse.n4js.jsdoc.JSDocCompletionHint)1 MODULESPEC (org.eclipse.n4js.jsdoc.JSDocCompletionHint.CompletionKind.MODULESPEC)1 NOCOMPLETION (org.eclipse.n4js.jsdoc.JSDocCompletionHint.CompletionKind.NOCOMPLETION)1 JSDocletUtils (org.eclipse.n4js.jsdoc.JSDocletUtils)1 N4JSDocletParser (org.eclipse.n4js.jsdoc.N4JSDocletParser)1 Doclet (org.eclipse.n4js.jsdoc.dom.Doclet)1 FullMemberReference (org.eclipse.n4js.jsdoc.dom.FullMemberReference)1 Tag (org.eclipse.n4js.jsdoc.dom.Tag)1 LineTagWithFullElementReference (org.eclipse.n4js.jsdoc.tags.LineTagWithFullElementReference)1