3
변수 이름의 철자가 다른 경우 (대소 문자가 아님)에 대한 표준이 있습니다. 예를 들어,이 불법 :이 지원하는 Checkstyle 확장을 작성하려고하지만,하고Checkstyle : 변수 이름에 액세스 하시겠습니까?
int INDEX = 0;
int index = 0;
ast.getText()
대신 실제 변수 이름의 "variable_def"를 반환합니다. 어떻게해야합니까? 감사.
package check;
import java.util.ArrayList;
import com.puppycrawl.tools.checkstyle.api.Check;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.FullIdent;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
public class VariableSpelling extends Check {
private ArrayList<String> variables = new ArrayList<String>();
public int[] getDefaultTokens() {
return new int[] { TokenTypes.VARIABLE_DEF };
}
/**
* This method is called when a node is found
*/
public void visitToken(DetailAST ast) {
String var = ast.getText();
}
}
코드를 솔루션으로 업데이트 해 주시겠습니까? 비슷한 문제에 직면하고 있습니다.이 CheckStyle을 처음 접했을 때 변경 사항을 어디에서 볼 수 있는지 알아 보는 것이 도움이 될 것입니다 ... –