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));
}
}
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);
}
}
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);
}
}
}
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);
}
}
}
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());
}
}