我想寫一個自定義檢查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
請對不起我的英文不好