Package com.puppycrawl.tools.checkstyle.api

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


  protected void processFiltered(File aFile, List<String> aLines) {
    // check if already checked and passed the file
    final String fileName = aFile.getPath();

    try {
      final FileContents contents = new FileContents(fileName, aLines
          .toArray(new String[aLines.size()]));
      final DetailAST rootAST = TreeWalker.parse(contents);
      walk(rootAST, contents);
    } catch (final RecognitionException re) {
      Utils.getExceptionLogger()
View Full Code Here


    }
  }

  private String getSince(DetailAST ast) {
    String since = classSince;
    final FileContents contents = getFileContents();
    final TextBlock javadoc = contents.getJavadocBefore(ast.getLineNo());
    if (null != javadoc) {
      for (String line : javadoc.getText()) {
        int index = line.indexOf("@since");
        if (index >= 0) {
          since = line.substring(index + 6).trim();
View Full Code Here

            endLine = (mCharacters.get(mMatcher.end() - 1))[0].
                    intValue();
            endColumn = (mCharacters.get(mMatcher.end() - 1))[1].
                    intValue();
            if (mIgnoreComments) {
                final FileContents theFileContents = getFileContents();
                ignore = theFileContents.hasIntersectionWithComment(startLine,
                    startColumn, endLine, endColumn);
            }
            if (!ignore) {
                mMatchCount++;
                if (mIllegalPattern || (mCheckForDuplicates
View Full Code Here

                openingBrace.findFirstToken(TokenTypes.RCURLY);
            int length =
                closingBrace.getLineNo() - openingBrace.getLineNo() + 1;

            if (!mCountEmpty) {
                final FileContents contents = getFileContents();
                final int lastLine = closingBrace.getLineNo();
                for (int i = openingBrace.getLineNo() - 1; i < lastLine; i++) {
                    if (contents.lineIsBlank(i) || contents.lineIsComment(i)) {
                        length--;
                    }
                }
            }
            if (length > mMax) {
View Full Code Here

    }

    @Override
    public void visitToken(DetailAST aAST)
    {
        final FileContents contents = getFileContents();
        final int lineNo = aAST.getLineNo();
        final TextBlock cmt =
            contents.getJavadocBefore(lineNo);
        if (cmt == null) {
            log(lineNo, "type.missingTag", mTag);
        }
        else {
            checkTag(lineNo, cmt.getText(), mTag, mTagRE, mTagFormatRE,
View Full Code Here

    @Override
    public void visitToken(DetailAST aAST)
    {
        if (shouldCheck(aAST)) {
            final FileContents contents = getFileContents();
            final int lineNo = aAST.getLineNo();
            final TextBlock cmt = contents.getJavadocBefore(lineNo);
            if (cmt == null) {
                log(lineNo, "javadoc.missing");
            }
            else if (ScopeUtils.isOuterMostType(aAST)) {
                // don't check author/version for inner classes
View Full Code Here

    @Override
    public void visitToken(DetailAST aAST)
    {
        if (shouldCheck(aAST)) {
            final FileContents contents = getFileContents();
            final TextBlock cmt =
                contents.getJavadocBefore(aAST.getLineNo());

            if (cmt == null) {
                log(aAST, "javadoc.missing");
            }
        }
View Full Code Here

            return true;        // A special event.
        }

        // Lazy update. If the first event for the current file, update file
        // contents and tag suppressions
        final FileContents currentContents = FileContentsHolder.getContents();
        if (currentContents == null) {
            // we have no contents, so we can not filter.
            // TODO: perhaps we should notify user somehow?
            return true;
        }
View Full Code Here

     * sorts the list.
     */
    private void tagSuppressions()
    {
        mTags.clear();
        final FileContents contents = getFileContents();
        if (mCheckCPP) {
            tagSuppressions(contents.getCppComments().values());
        }
        if (mCheckC) {
            final Collection<List<TextBlock>> cComments = contents
                    .getCComments().values();
            for (List<TextBlock> element : cComments) {
                tagSuppressions(element);
            }
        }
View Full Code Here

    }

    @Override
    public void beginTree(DetailAST aRootAST)
    {
        final FileContents contents = getFileContents();
        checkCppComments(contents);
        checkBadComments(contents);
    }
View Full Code Here

TOP

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

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.