Search in sources :

Example 1 with TextBlock

use of com.puppycrawl.tools.checkstyle.api.TextBlock in project checkstyle by checkstyle.

the class UnusedImportsCheck method collectReferencesFromJavadoc.

/**
     * Collects references made in Javadoc comments.
     * @param ast node to inspect for Javadoc
     */
private void collectReferencesFromJavadoc(DetailAST ast) {
    final FileContents contents = getFileContents();
    final int lineNo = ast.getLineNo();
    final TextBlock textBlock = contents.getJavadocBefore(lineNo);
    if (textBlock != null) {
        referenced.addAll(collectReferencesFromJavadoc(textBlock));
    }
}
Also used : FileContents(com.puppycrawl.tools.checkstyle.api.FileContents) TextBlock(com.puppycrawl.tools.checkstyle.api.TextBlock)

Example 2 with TextBlock

use of com.puppycrawl.tools.checkstyle.api.TextBlock in project checkstyle by checkstyle.

the class JavadocStyleCheck method visitToken.

@Override
public void visitToken(DetailAST ast) {
    if (shouldCheck(ast)) {
        final FileContents contents = getFileContents();
        // Need to start searching for the comment before the annotations
        // that may exist. Even if annotations are not defined on the
        // package, the ANNOTATIONS AST is defined.
        final TextBlock textBlock = contents.getJavadocBefore(ast.getFirstChild().getLineNo());
        checkComment(ast, textBlock);
    }
}
Also used : FileContents(com.puppycrawl.tools.checkstyle.api.FileContents) TextBlock(com.puppycrawl.tools.checkstyle.api.TextBlock)

Example 3 with TextBlock

use of com.puppycrawl.tools.checkstyle.api.TextBlock in project checkstyle by checkstyle.

the class JavadocTypeCheck method visitToken.

@Override
public void visitToken(DetailAST ast) {
    if (shouldCheck(ast)) {
        final FileContents contents = getFileContents();
        final int lineNo = ast.getLineNo();
        final TextBlock textBlock = contents.getJavadocBefore(lineNo);
        if (textBlock == null) {
            log(lineNo, MSG_JAVADOC_MISSING);
        } else {
            final List<JavadocTag> tags = getJavadocTags(textBlock);
            if (ScopeUtils.isOuterMostType(ast)) {
                // don't check author/version for inner classes
                checkTag(lineNo, tags, JavadocTagInfo.AUTHOR.getName(), authorFormat);
                checkTag(lineNo, tags, JavadocTagInfo.VERSION.getName(), versionFormat);
            }
            final List<String> typeParamNames = CheckUtils.getTypeParameterNames(ast);
            if (!allowMissingParamTags) {
                //Check type parameters that should exist, do
                for (final String typeParamName : typeParamNames) {
                    checkTypeParamTag(lineNo, tags, typeParamName);
                }
            }
            checkUnusedTypeParamTags(tags, typeParamNames);
        }
    }
}
Also used : FileContents(com.puppycrawl.tools.checkstyle.api.FileContents) TextBlock(com.puppycrawl.tools.checkstyle.api.TextBlock)

Example 4 with TextBlock

use of com.puppycrawl.tools.checkstyle.api.TextBlock in project checkstyle by checkstyle.

the class JavadocVariableCheck method visitToken.

@Override
public void visitToken(DetailAST ast) {
    if (shouldCheck(ast)) {
        final FileContents contents = getFileContents();
        final TextBlock textBlock = contents.getJavadocBefore(ast.getLineNo());
        if (textBlock == null) {
            log(ast, MSG_JAVADOC_MISSING);
        }
    }
}
Also used : FileContents(com.puppycrawl.tools.checkstyle.api.FileContents) TextBlock(com.puppycrawl.tools.checkstyle.api.TextBlock)

Example 5 with TextBlock

use of com.puppycrawl.tools.checkstyle.api.TextBlock in project checkstyle by checkstyle.

the class WriteTagCheck method visitToken.

@Override
public void visitToken(DetailAST ast) {
    final FileContents contents = getFileContents();
    final int lineNo = ast.getLineNo();
    final TextBlock cmt = contents.getJavadocBefore(lineNo);
    if (cmt == null) {
        log(lineNo, MSG_MISSING_TAG, tag);
    } else {
        checkTag(lineNo, cmt.getText());
    }
}
Also used : FileContents(com.puppycrawl.tools.checkstyle.api.FileContents) TextBlock(com.puppycrawl.tools.checkstyle.api.TextBlock)

Aggregations

TextBlock (com.puppycrawl.tools.checkstyle.api.TextBlock)12 FileContents (com.puppycrawl.tools.checkstyle.api.FileContents)6 DetailAST (com.puppycrawl.tools.checkstyle.api.DetailAST)1 Scope (com.puppycrawl.tools.checkstyle.api.Scope)1 HashSet (java.util.HashSet)1 List (java.util.List)1