use of com.puppycrawl.tools.checkstyle.api.DetailAST in project checkstyle by checkstyle.
the class JavadocMethodCheck method checkParamTags.
/**
* Checks a set of tags for matching parameters.
*
* @param tags the tags to check
* @param parent the node which takes the parameters
* @param reportExpectedTags whether we should report if do not find
* expected tag
*/
private void checkParamTags(final List<JavadocTag> tags, final DetailAST parent, boolean reportExpectedTags) {
final List<DetailAST> params = getParameters(parent);
final List<DetailAST> typeParams = CheckUtils.getTypeParameters(parent);
// Loop over the tags, checking to see they exist in the params.
final ListIterator<JavadocTag> tagIt = tags.listIterator();
while (tagIt.hasNext()) {
final JavadocTag tag = tagIt.next();
if (!tag.isParamTag()) {
continue;
}
tagIt.remove();
final String arg1 = tag.getFirstArg();
boolean found = removeMatchingParam(params, arg1);
if (CommonUtils.startsWithChar(arg1, '<') && CommonUtils.endsWithChar(arg1, '>')) {
found = searchMatchingTypeParameter(typeParams, arg1.substring(1, arg1.length() - 1));
}
// Handle extra JavadocTag
if (!found) {
log(tag.getLineNo(), tag.getColumnNo(), MSG_UNUSED_TAG, "@param", arg1);
}
}
// the user has chosen to suppress these problems
if (!allowMissingParamTags && reportExpectedTags) {
for (DetailAST param : params) {
log(param, MSG_EXPECTED_TAG, JavadocTagInfo.PARAM.getText(), param.getText());
}
for (DetailAST typeParam : typeParams) {
log(typeParam, MSG_EXPECTED_TAG, JavadocTagInfo.PARAM.getText(), "<" + typeParam.findFirstToken(TokenTypes.IDENT).getText() + ">");
}
}
}
use of com.puppycrawl.tools.checkstyle.api.DetailAST in project checkstyle by checkstyle.
the class AbstractExpressionHandler method findSubtreeLines.
/**
* Find the set of lines for a given subtree.
*
* @param lines the set of lines to add to
* @param tree the subtree to examine
* @param allowNesting whether or not to allow nested subtrees
*/
protected final void findSubtreeLines(LineSet lines, DetailAST tree, boolean allowNesting) {
if (!indentCheck.getHandlerFactory().isHandledType(tree.getType())) {
final int lineNum = tree.getLineNo();
final Integer colNum = lines.getStartColumn(lineNum);
final int thisLineColumn = expandedTabsColumnNo(tree);
if (colNum == null || thisLineColumn < colNum) {
lines.addLineAndCol(lineNum, thisLineColumn);
}
// check children
for (DetailAST node = tree.getFirstChild(); node != null; node = node.getNextSibling()) {
findSubtreeLines(lines, node, allowNesting);
}
}
}
use of com.puppycrawl.tools.checkstyle.api.DetailAST in project checkstyle by checkstyle.
the class ArrayInitHandler method getIndentImpl.
@Override
protected IndentLevel getIndentImpl() {
final DetailAST parentAST = getMainAst().getParent();
final int type = parentAST.getType();
if (type == TokenTypes.LITERAL_NEW || type == TokenTypes.ASSIGN) {
// note: assumes new or assignment is line to align with
return new IndentLevel(getLineStart(parentAST));
} else {
// at this point getParent() is instance of BlockParentHandler
return ((BlockParentHandler) getParent()).getChildrenExpectedIndent();
}
}
use of com.puppycrawl.tools.checkstyle.api.DetailAST in project checkstyle by checkstyle.
the class BlockParentHandler method checkNonListChild.
/**
* Check the indentation level of a child that is not a list of statements.
*/
private void checkNonListChild() {
final DetailAST nonList = getNonListChild();
if (nonList != null) {
final IndentLevel expected = new IndentLevel(getIndent(), getBasicOffset());
checkExpressionSubtree(nonList, expected, false, false);
}
}
use of com.puppycrawl.tools.checkstyle.api.DetailAST in project checkstyle by checkstyle.
the class BlockParentHandler method checkLeftCurly.
/**
* Check the indentation of the left curly brace.
*/
protected void checkLeftCurly() {
// the lcurly can either be at the correct indentation, or nested
// with a previous expression
final DetailAST lcurly = getLeftCurly();
final int lcurlyPos = expandedTabsColumnNo(lcurly);
if (!curlyIndent().isAcceptable(lcurlyPos) && isOnStartOfLine(lcurly)) {
logError(lcurly, "lcurly", lcurlyPos, curlyIndent());
}
}
Aggregations