我想写一个自定义检查Checkstyle 8.1。我成功安装并配置Gradle Checkstyle并写入我的支票草图。但是,当我尝试运行我的支票 - 我有错误Android checkstyle - 调试自定义检查
Execution failed for task ':app:checkstyle'.
> Unable to process files: FILE1, FILE2 ...
这里是我的校验码
package com.lsurvila.checkstyle;
import com.puppycrawl.tools.checkstyle.api.*;
import javax.xml.ws.LogicalMessage;
public class LinesAfterClassJavadocCheck extends AbstractCheck
{
private static final int DEFAULT_MAX = 30;
private int max = DEFAULT_MAX;
/**
* Returns the default token a check is interested in. Only used if the
* configuration for a check does not define the tokens.
*
* @return the default tokens
* @see TokenTypes
*/
@Override
public int[] getDefaultTokens() {
return new int[]{TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF};
}
/**
* The configurable token set.
* Used to protect Checks against malicious users who specify an
* unacceptable token set in the configuration file.
* The default implementation returns the check's default tokens.
*
* @return the token set this check is designed for.
* @see TokenTypes
*/
@Override
public int[] getAcceptableTokens() {
return new int[0];
}
/**
* The tokens that this check must be registered for.
*
* @return the token set this must be registered for.
* @see TokenTypes
*/
@Override
public int[] getRequiredTokens() {
return new int[0];
}
@Override
public void visitToken(DetailAST ast)
{
//throw new IllegalArgumentException("SUKA BLEAT");
DetailAST objBlock1 = ast.findFirstToken(TokenTypes.LITERAL_CLASS);
if (objBlock1 == null) {
log(ast.getLineNo(), "PIDOR");
//System.out.print("PIDOR");
}
String a = getLine(objBlock1.getLineNo()-1);
log(1,a);
//System.out.print(a);
if (a.isEmpty()) {
log(ast.getLineNo(), "PIDOR1");
}
/*DetailAST objBlock2 = ast.findFirstToken(TokenTypes.MODIFIERS).findFirstToken(TokenTypes.BLOCK_COMMENT_BEGIN);
if (objBlock2 == null) {
log(ast.getLineNo(), "PIDOR1");
//System.out.print("PIDOR");
}*/
/*DetailAST objBlock2 = ast.findFirstToken(TokenTypes.LITERAL_CLASS);
DetailAST objBlock3 = objBlock1.findFirstToken(TokenTypes.MODIFIERS).findFirstToken(TokenTypes.BLOCK_COMMENT_BEGIN).findFirstToken(TokenTypes.BLOCK_COMMENT_END);
if (objBlock3.getLine()+2 != objBlock2.getLine()) {
log(ast.getLineNo(), "PIDOR");
}*/
}
}
我发现log()方法产生这种例外。我没有找到另一种方法来查看我的代码中发生了什么 - 即使System.out.print()也不显示任何内容。我怎样才能运行调试器附加到我的自定义检查?由于在编译应用程序之前我的检查已经开始,所以情况很复杂。
这里是screenshoot如何检查摆在我的应用程序的项目: enter image description here
请对不起我的英文不好