Examples of DetailAST


Examples of com.puppycrawl.tools.checkstyle.api.DetailAST

    }

    @Override
    public IndentLevel suggestedChildLevel(ExpressionHandler aChild)
    {
        final DetailAST assign = getMainAst();
        final DetailAST child = aChild.getMainAst();

        if (child == assign.getFirstChild()) {
            // left side of assignment should have the same
            // indentation as "assignment"
            return getLevel();
View Full Code Here

Examples of com.puppycrawl.tools.checkstyle.api.DetailAST

        case TokenTypes.LITERAL_DO :
        case TokenTypes.LITERAL_WHILE :
        case TokenTypes.LITERAL_IF :
        case TokenTypes.LITERAL_ELSE :
            //don't count if or loop conditions
            final DetailAST prevSibling = aAST.getPreviousSibling();
            countable = (prevSibling == null)
                || (TokenTypes.LPAREN != prevSibling.getType());
            break;
        default :
            countable = false;
            break;
        }
View Full Code Here

Examples of com.puppycrawl.tools.checkstyle.api.DetailAST

    @Override
    public void visitToken(DetailAST aAST)
    {
        if (aAST.getChildCount() == 0) {
            //empty for initializer. test pad before semi.
            final DetailAST semi = (DetailAST) aAST.getNextSibling();
            final int semiLineIdx = semi.getLineNo() - 1;
            final String line = getLines()[semiLineIdx];
            final int before = semi.getColumnNo() - 1;
            //don't check if semi at beginning of line
            if (!Utils.whitespaceBefore(before, line)) {
                final PadOption option = getAbstractOption();
                if ((PadOption.NOSPACE == option)
                    && (Character.isWhitespace(line.charAt(before))))
                {
                    log(semi.getLineNo(), before, "ws.preceded", ";");
                }
                else if ((PadOption.SPACE == option)
                         && !Character.isWhitespace(line.charAt(before)))
                {
                    log(semi.getLineNo(), before, "ws.notPreceded", ";");
                }
            }
        }
    }
View Full Code Here

Examples of com.puppycrawl.tools.checkstyle.api.DetailAST

     * @param aAST a given node.
     * @return whether we should check a given node.
     */
    private boolean shouldCheck(final DetailAST aAST)
    {
        final DetailAST mods = aAST.findFirstToken(TokenTypes.MODIFIERS);
        final Scope declaredScope = ScopeUtils.getScopeFromMods(mods);
        final Scope scope =
            ScopeUtils.inInterfaceOrAnnotationBlock(aAST)
                ? Scope.PUBLIC : declaredScope;
        final Scope surroundingScope = ScopeUtils.getSurroundingScope(aAST);
View Full Code Here

Examples of com.puppycrawl.tools.checkstyle.api.DetailAST

     * @return new instance.
     */
    ExpressionHandler createMethodCallHandler(IndentationCheck aIndentCheck,
        DetailAST aAst, ExpressionHandler aParent)
    {
        DetailAST ast = (DetailAST) aAst.getFirstChild();
        while ((ast != null) && (ast.getType() == TokenTypes.DOT)) {
            ast = (DetailAST) ast.getFirstChild();
        }
        if ((ast != null) && isHandledType(ast.getType())) {
            aParent = getHandler(aIndentCheck, ast, aParent);
            mCreatedHandlers.put(ast, aParent);
        }
        return new MethodCallHandler(aIndentCheck, aAst, aParent);
    }
View Full Code Here

Examples of com.puppycrawl.tools.checkstyle.api.DetailAST

    {
        if (aAST.getType() != TokenTypes.LITERAL_SUPER) {
            return false;
        }
        // dot operator?
        DetailAST parent = aAST.getParent();
        if ((parent == null) || (parent.getType() != TokenTypes.DOT)) {
            return false;
        }

        // same name of method
        AST sibling = aAST.getNextSibling();
        // ignore type parameters
        if ((sibling != null)
            && (sibling.getType() == TokenTypes.TYPE_ARGUMENTS))
        {
            sibling = sibling.getNextSibling();
        }
        if ((sibling == null) || (sibling.getType() != TokenTypes.IDENT)) {
            return false;
        }
        final String name = sibling.getText();
        if (!getMethodName().equals(name)) {
            return false;
        }

        // 0 parameters?
        final DetailAST args = (DetailAST) parent.getNextSibling();
        if ((args == null) || (args.getType() != TokenTypes.ELIST)) {
            return false;
        }
        if (args.getChildCount() != 0) {
            return false;
        }

        // in an overriding method for this check?
        while (parent != null) {
View Full Code Here

Examples of com.puppycrawl.tools.checkstyle.api.DetailAST

        //                 ^           ^
        //      ws reqd ---+           +--- whitespace NOT required
        //
        if (0 <= before) {
            // Detect if the first case
            final DetailAST parent = aAST.getParent();
            final DetailAST grandparent = parent.getParent();
            if ((TokenTypes.TYPE_PARAMETERS == parent.getType())
                && ((TokenTypes.CTOR_DEF == grandparent.getType())
                    || (TokenTypes.METHOD_DEF == grandparent.getType())))
            {
                // Require whitespace
                if (!Character.isWhitespace(line.charAt(before))) {
                    log(aAST.getLineNo(), before, "ws.notPreceded", "<");
                }
View Full Code Here

Examples of com.puppycrawl.tools.checkstyle.api.DetailAST

    {
        if (isOverridingMethod(aAST)) {
            final MethodNode methodNode =
                mMethodStack.removeLast();
            if (!methodNode.getCallsSuper()) {
                final DetailAST methodAST = methodNode.getMethod();
                final DetailAST nameAST =
                    methodAST.findFirstToken(TokenTypes.IDENT);
                log(nameAST.getLineNo(), nameAST.getColumnNo(),
                    "missing.super.call", nameAST.getText());
            }
        }
    }
View Full Code Here

Examples of com.puppycrawl.tools.checkstyle.api.DetailAST

    }

    @Override
    public void visitToken(DetailAST aAST)
    {
        DetailAST targetAST = aAST;
        if (targetAST.getType() == TokenTypes.TYPECAST) {
            targetAST = targetAST.findFirstToken(TokenTypes.RPAREN);
        }
        final String line = getLines()[aAST.getLineNo() - 1];
        final int after =
            targetAST.getColumnNo() + targetAST.getText().length();

        if ((after >= line.length())
            || Character.isWhitespace(line.charAt(after)))
        {
            boolean flag = !mAllowLineBreaks;
            for (int i = after + 1; !flag && (i < line.length()); i++) {
                if (!Character.isWhitespace(line.charAt(i))) {
                    flag = true;
                }
            }
            if (flag) {
                log(targetAST.getLineNo(), after,
                    "ws.followed", targetAST.getText());
            }
        }
    }
View Full Code Here

Examples of com.puppycrawl.tools.checkstyle.api.DetailAST

        if ((aAST.getType() != TokenTypes.METHOD_DEF)
            || ScopeUtils.inInterfaceOrAnnotationBlock(aAST))
        {
            return false;
        }
        final DetailAST nameAST = aAST.findFirstToken(TokenTypes.IDENT);
        final String name = nameAST.getText();
        if (!getMethodName().equals(name)) {
            return false;
        }
        final DetailAST params = aAST.findFirstToken(TokenTypes.PARAMETERS);
        return (params.getChildCount() == 0);
    }
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.