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

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


        int offset = 0;
        offset += JavadocScannerUtil.countUntilNextPrintable(scanner, offset);

        // 先頭の "{"
        JavadocToken head = scanner.lookahead(offset);
        if (head.getKind() != LEFT_BRACE) {
            return null;
        }

        // タグ開始文字 "@"
        offset++;
        JavadocToken at = scanner.lookahead(offset);
        if (at.getKind() != AT) {
            return null;
        }

        // タグ名
        offset++;
        int nameCount = countWhileTagName(scanner, offset);
        String tagName = buildString(JavadocScannerUtil.lookaheadTokens(
            scanner, offset, nameCount));

        offset += nameCount;

        // 末端の検出
        int blockEnd = JavadocScannerUtil.countUntil(S_INLINE_BLOCK_DELIM,
            scanner,
            offset);

        JavadocToken token = scanner.lookahead(offset + blockEnd);
        JavadocTokenKind kind = token.getKind();

        // 次のブロックの開始を検出すると、このブロックは長さ0になる
        if (kind == LEFT_BRACE) {
            blockEnd = 0;
        }

        boolean legalBlock = (kind == JavadocTokenKind.RIGHT_BRACE);
        JavadocToken tail = scanner.lookahead(offset + blockEnd);

        int startIndex = scanner.getIndex() + offset;
        int stopIndex = startIndex + blockEnd;

        int startPos = head.getStartPosition();
        int endPos = tail.getStartPosition();
        if (legalBlock) {
            endPos += tail.getText().length();
        }

        IrLocation blockLocation = new IrLocation(startPos, endPos - startPos);
        DefaultJavadocScanner blockScanner = new DefaultJavadocScanner(
            new ArrayList<JavadocToken>(scanner.getTokens().subList(startIndex,
View Full Code Here


        if (consumeIfMatch(stream, LEFT_PAREN) == null) {
            stream.rewind();
            return null;
        }

        JavadocToken delim;
        List<IrDocMethodParameter> parameters;
        IrDocMethodParameter first = fetchMethodParameter(stream);
        if (first == null) {
            delim = consumeIfMatch(stream, RIGHT_PAREN);
            if (delim == null) {
                stream.rewind();
                return null;
            }
            parameters = Collections.emptyList();
        } else {
            parameters = new ArrayList<IrDocMethodParameter>();
            parameters.add(first);
            while (true) {
                delim = stream.nextToken();
                if (delim.getKind() == RIGHT_PAREN) {
                    break;
                } else if (delim.getKind() == COMMA) {
                    IrDocMethodParameter p = fetchMethodParameter(stream);
                    if (p == null) {
                        stream.rewind();
                        return null;
                    }
                    parameters.add(p);
                } else {
                    stream.rewind();
                    return null;
                }
            }
        }
        stream.discard();

        IrDocMethod elem = new IrDocMethod();
        elem.setDeclaringType(field.getDeclaringType());
        elem.setName(field.getName());
        elem.setParameters(parameters);
        setLocation(elem, field.getLocation(), delim.getLocation());
        return elem;
    }
View Full Code Here

                    || (stream.lookahead(1).getKind() != DOT)) {
                stream.rewind();
                return null;
            }
            stream.nextToken();
            JavadocToken lastDot = stream.nextToken();
            delim = lastDot.getLocation();
            varargs = true;
        } else {
            varargs = false;
        }
View Full Code Here

    private static IrDocField fetchField(JavadocTokenStream stream) {
        stream.mark();

        IrDocNamedType decl = fetchNamedType(stream);

        JavadocToken sharp = consumeIfMatch(stream, SHARP);
        if (sharp == null) {
            stream.rewind();
            return null;
        }

        IrDocSimpleName name = fetchSimpleName(stream);
        if (name == null) {
            stream.rewind();
            return null;
        }

        IrDocField elem = new IrDocField();
        elem.setDeclaringType(decl);
        elem.setName(name);
        setLocation(elem, decl == null ? sharp.getLocation() : decl
            .getLocation(), name.getLocation());

        return elem;
    }
View Full Code Here

            stream.mark();
            if (consumeIfMatch(stream, JavadocTokenKind.LEFT_BRACKET) == null) {
                stream.rewind();
                break;
            }
            JavadocToken stop = consumeIfMatch(stream,
                JavadocTokenKind.RIGHT_BRACKET);
            if (stop == null) {
                stream.rewind();
                break;
            } else {
                stream.discard();
                IrDocArrayType t = new IrDocArrayType(elem);
                setLocation(t, elem.getLocation(), stop.getLocation());
                elem = t;
            }
        }
        stream.discard();
        return elem;
View Full Code Here

        }
        return name;
    }

    private static IrDocBasicType fetchBasicType(JavadocTokenStream stream) {
        JavadocToken token = stream.peek();
        if (token.getKind() == JavadocTokenKind.IDENTIFIER) {
            if (BASIC_TYPE_NAMES.containsKey(token.getText())) {
                stream.nextToken();
                IrBasicTypeKind k = BASIC_TYPE_NAMES.get(token.getText());
                IrDocBasicType elem = new IrDocBasicType(k);
                setLocation(elem, token, token);
                return elem;
            }
        }
View Full Code Here

        }
        return null;
    }

    private static IrDocSimpleName fetchSimpleName(JavadocTokenStream stream) {
        JavadocToken token = consumeIfMatch(stream, JavadocTokenKind.IDENTIFIER);
        if (token != null) {
            IrDocSimpleName name = new IrDocSimpleName(token.getText());
            setLocation(name, token, token);
            return name;
        } else {
            return null;
        }
View Full Code Here

        return set.contains(kind);
    }

    private static JavadocToken consumeIfMatch(JavadocTokenStream stream,
            JavadocTokenKind kind) {
        JavadocToken token = stream.peek();
        if (token.getKind() == kind) {
            return stream.nextToken();
        }
        return null;
    }
View Full Code Here

        if (tokens.isEmpty()) {
            return null;
        }
        String text = buildString(tokens);
        IrDocText elem = new IrDocText(text);
        JavadocToken start = tokens.get(0);
        JavadocToken stop = tokens.get(tokens.size() - 1);
        setLocation(elem, start, stop);
        return elem;
    }
View Full Code Here

                return Collections.emptyList();
            }
        }
        List<JavadocToken> tokens = new ArrayList<JavadocToken>(rest);
        for (int i = 0; i < rest; i++) {
            JavadocToken t = scanner.nextToken();
            if (t.getKind() == JavadocTokenKind.EOF) {
                break;
            }
            tokens.add(t);
        }
        if (trimTail) {
            int lastWs = tokens.size();
            while (lastWs >= 0) {
                JavadocToken t = tokens.get(lastWs - 1);
                if (t.getKind() != WHITE_SPACES) {
                    break;
                }
                lastWs--;
            }
            if (lastWs != tokens.size()) {
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.