Spacing (@Nullable Block parent, @Nullable Block child1, @Nullable Block child2) { if (!(parent instanceof ASTBlock) || !(child1 instanceof ASTBlock) || !(child2 instanceof ASTBlock)) { return null; } for (SpacingRule rule : myRules) { if (rule.matches((ASTBlock)parent, (ASTBlock)child1, (ASTBlock) child2)) { return rule.createSpacing(parent.getTextRange()); } } return null; }