0
我正在嘗試編寫一個SonarQube JavaScript自定義規則。該規則應該看到一個for循環不是空的(即for塊體中有多於0個語句)。如何訪問SonarQube自定義規則中的後代節點?
我已經延長了DoubleDispatchVisitorCheck類,並覆蓋了visitForStatement方法。在該方法中,我不確定如何確定for語句有多少個後代。
@Override
public void visitForStatement(ForStatementTree tree) {
StatementTree statement = tree.statement();
// How to see tree or statement descendants?
super.visitForStatement(tree);
}
的best documentation I've located沒有深入下去如何遍歷比在樹上的一個節點多。
+1這是非常有益的。我還想添加一個鏈接到sonar-javascript源代碼作爲更具體的代碼示例的源代碼: https://github.com/SonarSource/sonar-javascript – gabrielfreiberg