Package com.puppycrawl.tools.checkstyle.api

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


    }

    @Override
    protected final boolean mustCheckName(DetailAST aAST)
    {
        final DetailAST modifiersAST =
            aAST.findFirstToken(TokenTypes.MODIFIERS);
        final boolean isStatic = (modifiersAST != null)
            && modifiersAST.branchContains(TokenTypes.LITERAL_STATIC);

        return (!isStatic && !ScopeUtils.inInterfaceOrAnnotationBlock(aAST)
            && !ScopeUtils.isLocalVariableDef(aAST))
            && (modifiersAST != null)
            && shouldCheckInScope(modifiersAST);
View Full Code Here


    {
    }

    public Object getChild(Object parent, int index)
    {
        final DetailAST ast = (DetailAST) parent;
        int i = 0;
        AST child = ast.getFirstChild();
        while (i < index) {
            child = child.getNextSibling();
            i++;
        }
        return child;
View Full Code Here

        try {
            getMessageDispatcher().fireFileStarted(fileName);
            final String[] lines = Utils.getLines(fileName, getCharset());
            final FileContents contents = new FileContents(fileName, lines);
            final DetailAST rootAST = TreeWalker.parse(contents);
            walk(rootAST, contents);
        }
        catch (final FileNotFoundException fnfe) {
            Utils.getExceptionLogger()
                .debug("FileNotFoundException occured.", fnfe);
View Full Code Here

     * @param aAST the token of the method/constructor
     * @return the scope of the method/constructor
     */
    private Scope calculateScope(final DetailAST aAST)
    {
        final DetailAST mods = aAST.findFirstToken(TokenTypes.MODIFIERS);
        final Scope declaredScope = ScopeUtils.getScopeFromMods(mods);
        return ScopeUtils.inInterfaceOrAnnotationBlock(aAST) ? Scope.PUBLIC
                : declaredScope;
    }
View Full Code Here

        return child;
    }

    public int getChildCount(Object parent)
    {
        final DetailAST ast = (DetailAST) parent;
        return ast.getChildCount();
    }
View Full Code Here

            return;
        }

        notifyVisit(aAST);

        final DetailAST child = (DetailAST) aAST.getFirstChild();
        if (child != null) {
            processRec(child);
        }

        notifyLeave(aAST);

        final DetailAST sibling = (DetailAST) aAST.getNextSibling();
        if (sibling != null) {
            processRec(sibling);
        }
    }
View Full Code Here

     * @param aAST the method node.
     * @return the list of parameter nodes for aAST.
     */
    private List<DetailAST> getParameters(DetailAST aAST)
    {
        final DetailAST params = aAST.findFirstToken(TokenTypes.PARAMETERS);
        final List<DetailAST> retVal = Lists.newArrayList();

        DetailAST child = (DetailAST) params.getFirstChild();
        while (child != null) {
            if (child.getType() == TokenTypes.PARAMETER_DEF) {
                final DetailAST ident = child.findFirstToken(TokenTypes.IDENT);
                retVal.add(ident);
            }
            child = (DetailAST) child.getNextSibling();
        }
        return retVal;
View Full Code Here

     * Uses iterative algorithm.
     * @param aRoot the root of tree for process
     */
    private void processIter(DetailAST aRoot)
    {
        DetailAST curNode = aRoot;
        while (curNode != null) {
            notifyVisit(curNode);
            DetailAST toVisit = (DetailAST) curNode.getFirstChild();
            while ((curNode != null) && (toVisit == null)) {
                notifyLeave(curNode);
                toVisit = (DetailAST) curNode.getNextSibling();
                if (toVisit == null) {
                    curNode = curNode.getParent();
View Full Code Here

     * @return the list of exception nodes for aAST.
     */
    private List<ExceptionInfo> getThrows(DetailAST aAST)
    {
        final List<ExceptionInfo> retVal = Lists.newArrayList();
        final DetailAST throwsAST = aAST
                .findFirstToken(TokenTypes.LITERAL_THROWS);
        if (throwsAST != null) {
            DetailAST child = (DetailAST) throwsAST.getFirstChild();
            while (child != null) {
                if ((child.getType() == TokenTypes.IDENT)
                        || (child.getType() == TokenTypes.DOT))
                {
                    final FullIdent fi = FullIdent.createFullIdent(child);
                    final ExceptionInfo ei = new ExceptionInfo(new Token(fi),
                            getCurrentClassName());
                    retVal.add(ei);
                }
                child = (DetailAST) child.getNextSibling();
            }
        }
        return retVal;
    }
View Full Code Here

            boolean found = false;

            // Loop looking for matching param
            final Iterator<DetailAST> paramIt = params.iterator();
            while (paramIt.hasNext()) {
                final DetailAST param = paramIt.next();
                if (param.getText().equals(tag.getArg1())) {
                    found = true;
                    paramIt.remove();
                    break;
                }
            }

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

            }

            // Handle extra JavadocTag
            if (!found) {
                log(tag.getLineNo(), tag.getColumnNo(), "javadoc.unusedTag",
                        "@param", tag.getArg1());
            }
        }

        // Now dump out all type parameters/parameters without tags :- unless
        // the user has chosen to suppress these problems
        if (!mAllowMissingParamTags && aReportExpectedTags) {
            for (DetailAST param : params) {
                log(param, "javadoc.expectedTag", "@param", param.getText());
            }

            for (DetailAST typeParam : typeParams) {
                log(typeParam, "javadoc.expectedTag", "@param", "<"
                        + typeParam.findFirstToken(TokenTypes.IDENT).getText()
                        + ">");
            }
        }
    }
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.