Package com.puppycrawl.tools.checkstyle.api

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


     *
     * @return the right curly brace expression
     */
    protected DetailAST getRCurly()
    {
        final DetailAST slist = getMainAst().findFirstToken(TokenTypes.SLIST);
        if (slist == null) {
            return null;
        }

        return slist.findFirstToken(TokenTypes.RCURLY);
    }
View Full Code Here


     */
    protected void checkLCurly()
    {
        // the lcurly can either be at the correct indentation, or nested
        // with a previous expression
        final DetailAST lcurly = getLCurly();
        final int lcurlyPos = expandedTabsColumnNo(lcurly);

        if ((lcurly == null)
            || curlyLevel().accept(lcurlyPos)
            || !startsLine(lcurly))
View Full Code Here

     */
    protected void checkRCurly()
    {
        // the rcurly can either be at the correct indentation, or
        // on the same line as the lcurly
        final DetailAST lcurly = getLCurly();
        final DetailAST rcurly = getRCurly();
        final int rcurlyPos = expandedTabsColumnNo(rcurly);

        if ((rcurly == null)
            || curlyLevel().accept(rcurlyPos)
            || (!rcurlyMustStart() && !startsLine(rcurly))
View Full Code Here

     * Check the indentation level of a child that is not a list of statements.
     */
    private void checkNonlistChild()
    {
        // TODO: look for SEMI and check for it here?
        final DetailAST nonlist = getNonlistChild();
        if (nonlist == null) {
            return;
        }

        final IndentLevel expected =
View Full Code Here

        checkRParen(getLParen(), getRParen());
        if (hasCurlys()) {
            checkLCurly();
            checkRCurly();
        }
        final DetailAST listChild = getListChild();
        if (listChild != null) {
            // NOTE: switch statements usually don't have curlys
            if (!hasCurlys() || !areOnSameLine(getLCurly(), getRCurly())) {
                checkChildren(listChild,
                              getCheckedChildren(),
View Full Code Here

    {
        if (inIgnoreList(aAST)) {
            return;
        }

        final DetailAST constantDefAST = findContainingConstantDef(aAST);

        if (constantDefAST == null) {
            reportMagicNumber(aAST);
        }
        else {
            DetailAST ast = aAST.getParent();
            while (ast != constantDefAST) {
                final int type = ast.getType();
                if (Arrays.binarySearch(ALLOWED_PATH_TOKENTYPES, type) < 0) {
                    reportMagicNumber(aAST);
                    break;
                }

                ast = ast.getParent();
            }
        }
    }
View Full Code Here

    public void visitToken(DetailAST aAst)
    {
        super.visitToken(aAst); // Will check the name against the format.

        if (!mAllowClassName) {
            final DetailAST method =
                aAst.findFirstToken(TokenTypes.IDENT);
            //in all cases this will be the classDef type except anon inner
            //with anon inner classes this will be the Literal_New keyword
            final DetailAST classDefOrNew = aAst.getParent().getParent();
            final DetailAST classIdent =
                classDefOrNew.findFirstToken(TokenTypes.IDENT);
            // Following logic is to handle when a classIdent can not be
            // found. This is when you have a Literal_New keyword followed
            // a DOT, which is when you have:
            // new Outclass.InnerInterface(x) { ... }
            // Such a rare case, will not have the logic to handle parsing
            // down the tree looking for the first ident.
            if ((null != classIdent)
                && method.getText().equals(classIdent.getText()))
            {
                log(method.getLineNo(), method.getColumnNo(),
                    "method.name.equals.class.name", method.getText());
            }
        }
View Full Code Here

    @Override
    public void visitToken(DetailAST aAST)
    {
        // don't flag interfaces
        final DetailAST container = aAST.getParent().getParent();
        if (container.getType() == TokenTypes.INTERFACE_DEF) {
            return;
        }

        if (aAST.getType() == TokenTypes.LITERAL_CATCH) {
            visitCatch(aAST);
View Full Code Here

    }

    @Override
    protected final boolean mustCheckName(DetailAST aAST)
    {
        DetailAST location =
            aAST.getParent().getParent();

        if (location.getType() == TokenTypes.MODIFIERS) {
            location = location.getParent();
        }

        return location.getType() == this.mLocation;
    }
View Full Code Here

        if (!aMethod.branchContains(TokenTypes.PARAMETER_DEF)) {
            return;
        }

        // ignore abstract method
        final DetailAST modifiers =
            aMethod.findFirstToken(TokenTypes.MODIFIERS);
        if (modifiers.branchContains(TokenTypes.ABSTRACT)) {
            return;
        }

        // we can now be sure that there is at least one parameter
        final DetailAST parameters =
            aMethod.findFirstToken(TokenTypes.PARAMETERS);
        DetailAST child = (DetailAST) parameters.getFirstChild();
        while (child != null) {
            // childs are PARAMETER_DEF and COMMA
            if (child.getType() == TokenTypes.PARAMETER_DEF) {
                checkParam(child);
            }
            child = (DetailAST) child.getNextSibling();
        }
    }
View Full Code Here

TOP

Related Classes of com.puppycrawl.tools.checkstyle.api.DetailAST

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.