Make rule a RuleChain

This commit is contained in:
Gwilym Kuiper
2020-04-03 15:18:22 +01:00
parent 58185fce2f
commit e94db8bf22

View File

@@ -26,6 +26,10 @@ public class FieldDeclarationsShouldBeAtStartRule extends AbstractApexRule {
.thenComparing(ApexNode::getBeginColumn); .thenComparing(ApexNode::getBeginColumn);
public static final String STATIC_INITIALIZER_METHOD_NAME = "<clinit>"; public static final String STATIC_INITIALIZER_METHOD_NAME = "<clinit>";
public FieldDeclarationsShouldBeAtStartRule() {
addRuleChainVisit(ASTUserClass.class);
}
@Override @Override
public Object visit(ASTUserClass node, Object data) { public Object visit(ASTUserClass node, Object data) {
// Unfortunately the parser re-orders the AST to put field declarations before method declarations // Unfortunately the parser re-orders the AST to put field declarations before method declarations
@@ -46,7 +50,7 @@ public class FieldDeclarationsShouldBeAtStartRule extends AbstractApexRule {
if (!firstNonFieldDeclaration.isPresent()) { if (!firstNonFieldDeclaration.isPresent()) {
// there is nothing except field declaration, so that has to come first // there is nothing except field declaration, so that has to come first
return super.visit(node, data); return data;
} }
for (ASTField field : fields) { for (ASTField field : fields) {
@@ -55,7 +59,7 @@ public class FieldDeclarationsShouldBeAtStartRule extends AbstractApexRule {
} }
} }
return super.visit(node, data); return data;
} }
private List<ApexNode<?>> getMethodNodes(ASTUserClass node) { private List<ApexNode<?>> getMethodNodes(ASTUserClass node) {