Package com.puppycrawl.tools.checkstyle.api

Examples of com.puppycrawl.tools.checkstyle.api.DetailAST.findFirstToken()


                .findFirstToken(TokenTypes.EXTENDS_CLAUSE);

        if (extendsClause != null) {
            final DetailAST dot = extendsClause.findFirstToken(TokenTypes.DOT);
            if (dot != null) {
                result = dot.findFirstToken(TokenTypes.IDENT).getText();
            }
            else {
                result = extendsClause.findFirstToken(TokenTypes.IDENT)
                        .getText();
            }
View Full Code Here


    {
        DetailAST parameters =
            aMethodNode.findFirstToken(TokenTypes.PARAMETERS);
        boolean result = false;
        if (parameters.getChildCount(TokenTypes.PARAMETER_DEF) == 1) {
            parameters = parameters.findFirstToken(TokenTypes.PARAMETER_DEF);
            parameters = parameters.findFirstToken(TokenTypes.TYPE);
            parameters = parameters.getFirstChild();
            result = aParameterText.equals(parameters.getText());
        }
        return result;
View Full Code Here

        DetailAST parameters =
            aMethodNode.findFirstToken(TokenTypes.PARAMETERS);
        boolean result = false;
        if (parameters.getChildCount(TokenTypes.PARAMETER_DEF) == 1) {
            parameters = parameters.findFirstToken(TokenTypes.PARAMETER_DEF);
            parameters = parameters.findFirstToken(TokenTypes.TYPE);
            parameters = parameters.getFirstChild();
            result = aParameterText.equals(parameters.getText());
        }
        return result;
    }
View Full Code Here

    {
        if (mChecking && aAST.getParent().getType() == TokenTypes.OBJBLOCK) {
            final DetailAST modifiersAST =
                aAST.findFirstToken(TokenTypes.MODIFIERS);

            if (!(modifiersAST.findFirstToken(TokenTypes.FINAL) != null)) {
                log(aAST.getLineNo(),  aAST.getColumnNo(), "mutable.exception",
                        aAST.findFirstToken(TokenTypes.IDENT).getText());
            }
        }
    }
View Full Code Here

        final DetailAST slist = getMainAst().findFirstToken(TokenTypes.SLIST);
        if (slist == null) {
            return null;
        }

        return slist.findFirstToken(TokenTypes.RCURLY);
    }

    /**
     * Check the indentation of the left curly brace.
     */
 
View Full Code Here

    private boolean checkTry(final DetailAST aAST, boolean aUseBreak,
                             boolean aUseContinue)
    {
        final DetailAST finalStmt = aAST.getLastChild();
        if (finalStmt.getType() == TokenTypes.LITERAL_FINALLY) {
            return isTerminated(finalStmt.findFirstToken(TokenTypes.SLIST),
                                aUseBreak, aUseContinue);
        }

        boolean isTerminated = isTerminated((DetailAST) aAST.getFirstChild(),
                                            aUseBreak, aUseContinue);
View Full Code Here

             child != null;
             child = (DetailAST) child.getNextSibling())
        {
            if (child.getType() == TokenTypes.TYPE_PARAMETER) {
                DetailAST param = child;
                String alias = param.findFirstToken(TokenTypes.IDENT).getText();
                DetailAST bounds =
                    param.findFirstToken(TokenTypes.TYPE_UPPER_BOUNDS);
                if (bounds != null) {
                    FullIdent name = FullIdent.createFullIdentBelow(bounds);
                    ClassInfo ci =
View Full Code Here

        boolean followsEmptyForIterator = false;
        final DetailAST parent = aAST.getParent();
        //Only traditional for statements are examined, not for-each statements
        if ((parent != null)
            && (parent.getType() == TokenTypes.LITERAL_FOR)
            && (parent.findFirstToken(TokenTypes.FOR_EACH_CLAUSE) == null))
        {
            final DetailAST forIterator =
                parent.findFirstToken(TokenTypes.FOR_ITERATOR);
            followsEmptyForIterator = (forIterator.getChildCount() == 0)
                && (aAST == forIterator.getNextSibling());
View Full Code Here

        boolean preceedsEmptyForInintializer = false;
        final DetailAST parent = aAST.getParent();
        //Only traditional for statements are examined, not for-each statements
        if ((parent != null)
            && (parent.getType() == TokenTypes.LITERAL_FOR)
            && (parent.findFirstToken(TokenTypes.FOR_EACH_CLAUSE) == null))
        {
            final DetailAST forIterator =
                    parent.findFirstToken(TokenTypes.FOR_INIT);
            preceedsEmptyForInintializer = (forIterator.getChildCount() == 0)
                    && (aAST == forIterator.getPreviousSibling());
View Full Code Here

            if (tag.getArg1().startsWith("<") && tag.getArg1().endsWith(">")) {
                // Loop looking for matching type param
                Iterator typeParamsIt = typeParams.iterator();
                while (typeParamsIt.hasNext()) {
                    final DetailAST typeParam = (DetailAST) typeParamsIt.next();
                    if (typeParam.findFirstToken(TokenTypes.IDENT).getText()
                        .equals(tag.getArg1().substring(
                            1, tag.getArg1().length() - 1)))
                    {
                        found = true;
                        typeParamsIt.remove();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.