Package com.asakusafw.utils.java.internal.parser.javadoc.ir

Examples of com.asakusafw.utils.java.internal.parser.javadoc.ir.JavadocToken


        String text = load("synopsis.doc.txt");
        DefaultJavadocScanner scanner = DefaultJavadocScanner.newInstance(text);
        int index = 0;
        while (true) {
            assertEquals(index, scanner.getIndex());
            JavadocToken t = scanner.nextToken();
            if (t.getKind() == EOF) {
                break;
            }
            index++;
        }
        assertEquals(index, scanner.getIndex());
View Full Code Here


     */
    @Test
    public void testSetLocationToken() {
        {
            IrDocElement elem = new IrDocText("text");
            JavadocToken start = new JavadocToken(JavadocTokenKind.IDENTIFIER, "id", 10);
            JavadocToken stop = new JavadocToken(JavadocTokenKind.IDENTIFIER, "id", 20);
            JavadocBlockParserUtil.setLocation(elem, start, stop);
            assertEquals(10, elem.getLocation().getStartPosition());
            assertEquals(12, elem.getLocation().getLength());
        }
        {
            IrDocElement elem = new IrDocText("text");
            JavadocToken start = new JavadocToken(JavadocTokenKind.IDENTIFIER, "id", 10);
            JavadocBlockParserUtil.setLocation(elem, start, start);
            assertEquals(10, elem.getLocation().getStartPosition());
            assertEquals(2, elem.getLocation().getLength());
        }
    }
View Full Code Here

        return blocks;
    }

    private static JavadocBlockInfo fetchStandAloneBlock(JavadocScanner scanner, List<JavadocToken> tokens) {
        JavadocToken first = scanner.lookahead(0);
        JavadocTokenKind kind = first.getKind();
        if (kind == JavadocTokenKind.EOF) {
            return null;
        }
        if (kind != JavadocTokenKind.AT) {
            throw new AssertionError(MessageFormat.format(
                "AT <-> {0}({1})@{2}", //$NON-NLS-1$
                first,
                first.getKind(),
                first.getLocation()));
        }

        scanner.consume(1);

        // タグ名を解析
        int tagCount = JavadocBlockParserUtil.countWhileTagName(scanner, 0);
        List<JavadocToken> tagNames = new ArrayList<JavadocToken>(tagCount);
        for (int i = 0; i < tagCount; i++) {
            tagNames.add(scanner.nextToken());
        }
        String tagName = JavadocBlockParserUtil.buildString(tagNames);

        // 本体を解析
        int bodyStart = scanner.getIndex();
        int count = JavadocScannerUtil.countUntilBlockEnd(scanner, 0);

        // 情報として作成
        int success = scanner.lookahead(count).getStartPosition();
        DefaultJavadocScanner bs = new DefaultJavadocScanner(
            new ArrayList<JavadocToken>(tokens.subList(bodyStart, bodyStart + count)),
            success);
        int init = first.getStartPosition();
        IrLocation location = new IrLocation(init, success - init);
        JavadocBlockInfo info = new JavadocBlockInfo(tagName, bs, location);
        scanner.consume(count);

        return info;
View Full Code Here

            int count = JavadocScannerUtil.countUntilBlockEnd(scanner, offset);
            int success = scanner.lookahead(offset + count).getStartPosition();
            DefaultJavadocScanner bs = new DefaultJavadocScanner(
                new ArrayList<JavadocToken>(tokens.subList(start + offset, start + offset + count)),
                success);
            JavadocToken first = scanner.lookahead(offset);
            int init = first.getStartPosition();
            IrLocation location = new IrLocation(init, success - init);
            JavadocBlockInfo info = new JavadocBlockInfo(null, bs, location);
            scanner.consume(offset + count);
            return info;
        }
View Full Code Here

        if (count < 0) {
            throw new IllegalArgumentException();
        }
        List<JavadocToken> tokens = new ArrayList<JavadocToken>(count);
        for (int i = 0; i < count; i++) {
            JavadocToken token = scanner.lookahead(start + i);
            if (token.getKind() == JavadocTokenKind.EOF) {
                break;
            }
            tokens.add(token);
        }
        return tokens;
View Full Code Here

     */
    public static int countUntilCommentEnd(
            JavadocScanner scanner,
            boolean returnMinusIfMissing,
            int start) {
        JavadocToken token = scanner.lookahead(start);
        if (token.getKind() == JavadocTokenKind.EOF) {
            return (returnMinusIfMissing ? -1 : 0);
        }
        int offset = 1;
        boolean sawAster = (token.getKind() == JavadocTokenKind.ASTERISK);
        while (true) {
            JavadocToken la = scanner.lookahead(start + offset);
            JavadocTokenKind kind = la.getKind();
            if (kind == JavadocTokenKind.EOF) {
                return (returnMinusIfMissing ? -1 : offset);
            } else if (sawAster && kind == JavadocTokenKind.SLASH) {
                offset--;
                return offset;
View Full Code Here

            JavadocScanner scanner,
            int start,
            boolean breakOnFound) {
        int offset = 0;
        while (true) {
            JavadocToken token = scanner.lookahead(start + offset);
            JavadocTokenKind kind = token.getKind();
            if (
                    kind == JavadocTokenKind.EOF
                    || kinds.contains(kind) == breakOnFound) {
                return offset;
            } else {
View Full Code Here

     */
    public static int countUntilNextPrintable(JavadocScanner scanner, int start) {
        int offset = 0;
        while (true) {
            offset += countWhile(S_WHITE_SPACES, scanner, start + offset);
            JavadocToken token = scanner.lookahead(start + offset);
            JavadocTokenKind kind = token.getKind();
            if (kind == JavadocTokenKind.EOF) {
                return offset;
            } else if (kind != JavadocTokenKind.LINE_BREAK) {
                return offset;
            }
View Full Code Here

     * @return 開始オフセットから次の行頭までのトークンが連続する個数
     */
    public static int countUntilNextLineStart(JavadocScanner scanner, int start) {
        int offset = 0;
        offset += countUntil(S_LINE_BREAK, scanner, start + offset);
        JavadocToken token = scanner.lookahead(start + offset);
        if (token.getKind() == JavadocTokenKind.EOF) {
            return offset;
        } else {
            offset++;
        }
        offset += countWhile(S_WHITE_SPACES, scanner, start + offset);
View Full Code Here

        while (true) {
            offset += JavadocScannerUtil.countUntil(S_TEXT_DELIM, scanner,
                offset);
            JavadocTokenKind kind = scanner.lookahead(offset).getKind();
            if (kind == LEFT_BRACE) {
                JavadocToken la = scanner.lookahead(offset + 1);
                if (la.getKind() == JavadocTokenKind.AT) {
                    break;
                }
                offset++;
            } else {
                break;
View Full Code Here

TOP

Related Classes of com.asakusafw.utils.java.internal.parser.javadoc.ir.JavadocToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.