|
3 | 3 | use log::error; |
4 | 4 |
|
5 | 5 | use crate::lint::rules::indentation::IndentEmptyLoopArgs; |
| 6 | +use crate::lint::rules::spacing::SpReservedArgs; |
6 | 7 | use crate::span::Range; |
7 | 8 | use crate::analysis::parsing::lexer::TokenKind; |
8 | 9 | use crate::analysis::parsing::statement; |
@@ -145,9 +146,9 @@ impl TreeElement for CompoundContent { |
145 | 146 | create_subs!(&self.lbrace, &self.statements, &self.rbrace) |
146 | 147 | } |
147 | 148 | fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, aux: AuxParams) { |
148 | | - rules.sp_brace.check(acc, SpBracesArgs::from_compound(self)); |
149 | | - rules.indent_code_block.check(acc, IndentCodeBlockArgs::from_compound_content(self, aux.depth)); |
150 | | - rules.indent_closing_brace.check(acc, IndentClosingBraceArgs::from_compound_content(self, aux.depth)); |
| 149 | + rules.sp_brace.check(SpBracesArgs::from_compound(self), acc); |
| 150 | + rules.indent_code_block.check(IndentCodeBlockArgs::from_compound_content(self, aux.depth), acc); |
| 151 | + rules.indent_closing_brace.check(IndentClosingBraceArgs::from_compound_content(self, aux.depth), acc); |
151 | 152 | } |
152 | 153 | fn should_increment_depth(&self) -> bool { |
153 | 154 | true |
@@ -203,7 +204,7 @@ impl TreeElement for VariableDeclContent { |
203 | 204 | self.decls.ensure_named() |
204 | 205 | } |
205 | 206 | fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) { |
206 | | - rules.sp_punct.check(acc, SpPunctArgs::from_variable_decl(self)); |
| 207 | + rules.sp_punct.check(SpPunctArgs::from_variable_decl(self), acc); |
207 | 208 | } |
208 | 209 | } |
209 | 210 |
|
@@ -435,8 +436,9 @@ impl TreeElement for IfContent { |
435 | 436 | &self.elsebranch) |
436 | 437 | } |
437 | 438 | fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) { |
438 | | - rules.nsp_inparen.check(acc, NspInparenArgs::from_if(self)); |
439 | | - rules.indent_paren_expr.check(acc, IndentParenExprArgs::from_if(self)); |
| 439 | + rules.nsp_inparen.check(NspInparenArgs::from_if(self), acc); |
| 440 | + rules.indent_paren_expr.check(IndentParenExprArgs::from_if(self), acc); |
| 441 | + rules.sp_reserved.check(SpReservedArgs::from_if(self), acc); |
440 | 442 | } |
441 | 443 | } |
442 | 444 |
|
@@ -548,8 +550,9 @@ impl TreeElement for WhileContent { |
548 | 550 | &self.statement) |
549 | 551 | } |
550 | 552 | fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, aux: AuxParams) { |
551 | | - rules.indent_paren_expr.check(acc, IndentParenExprArgs::from_while(self)); |
552 | | - rules.indent_empty_loop.check(acc, IndentEmptyLoopArgs::from_while_content(self, aux.depth)); |
| 553 | + rules.indent_paren_expr.check(IndentParenExprArgs::from_while(self), acc); |
| 554 | + rules.indent_empty_loop.check(IndentEmptyLoopArgs::from_while_content(self, aux.depth), acc); |
| 555 | + rules.sp_reserved.check(SpReservedArgs::from_while(self), acc); |
553 | 556 | } |
554 | 557 | } |
555 | 558 |
|
@@ -599,7 +602,7 @@ impl TreeElement for DoContent { |
599 | 602 | &self.semi) |
600 | 603 | } |
601 | 604 | fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) { |
602 | | - rules.indent_paren_expr.check(acc, IndentParenExprArgs::from_do_while(self)); |
| 605 | + rules.indent_paren_expr.check(IndentParenExprArgs::from_do_while(self), acc); |
603 | 606 | } |
604 | 607 | } |
605 | 608 |
|
@@ -864,8 +867,9 @@ impl TreeElement for ForContent { |
864 | 867 | &self.statement) |
865 | 868 | } |
866 | 869 | fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, aux: AuxParams) { |
867 | | - rules.indent_paren_expr.check(acc, IndentParenExprArgs::from_for(self)); |
868 | | - rules.indent_empty_loop.check(acc, IndentEmptyLoopArgs::from_for_content(self, aux.depth)); |
| 870 | + rules.indent_paren_expr.check(IndentParenExprArgs::from_for(self), acc); |
| 871 | + rules.indent_empty_loop.check(IndentEmptyLoopArgs::from_for_content(self, aux.depth), acc); |
| 872 | + rules.sp_reserved.check(SpReservedArgs::from_for(self), acc); |
869 | 873 | } |
870 | 874 | } |
871 | 875 |
|
@@ -1024,7 +1028,7 @@ impl TreeElement for SwitchCase { |
1024 | 1028 | } |
1025 | 1029 | } |
1026 | 1030 | fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, aux: AuxParams) { |
1027 | | - rules.indent_switch_case.check(acc, IndentSwitchCaseArgs::from_switch_case(self, aux.depth)); |
| 1031 | + rules.indent_switch_case.check(IndentSwitchCaseArgs::from_switch_case(self, aux.depth), acc); |
1028 | 1032 | } |
1029 | 1033 | fn should_increment_depth(&self) -> bool { |
1030 | 1034 | matches!(self, SwitchCase::Statement(statement) |
@@ -1114,8 +1118,8 @@ impl TreeElement for SwitchContent { |
1114 | 1118 | fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, |
1115 | 1119 | rules: &CurrentRules, aux: AuxParams) |
1116 | 1120 | { |
1117 | | - rules.indent_closing_brace.check(acc, IndentClosingBraceArgs::from_switch_content(self, aux.depth)); |
1118 | | - rules.indent_paren_expr.check(acc, IndentParenExprArgs::from_switch(self)); |
| 1121 | + rules.indent_closing_brace.check(IndentClosingBraceArgs::from_switch_content(self, aux.depth), acc); |
| 1122 | + rules.indent_paren_expr.check(IndentParenExprArgs::from_switch(self), acc); |
1119 | 1123 | } |
1120 | 1124 | } |
1121 | 1125 |
|
@@ -1285,6 +1289,9 @@ impl TreeElement for AfterContent { |
1285 | 1289 | &self.callexpression, |
1286 | 1290 | &self.semi) |
1287 | 1291 | } |
| 1292 | + fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) { |
| 1293 | + rules.sp_reserved.check(SpReservedArgs::from_after_content(self), acc); |
| 1294 | + } |
1288 | 1295 | } |
1289 | 1296 |
|
1290 | 1297 | impl Parse<StatementContent> for AfterContent { |
@@ -1611,7 +1618,7 @@ impl TreeElement for ForeachContent { |
1611 | 1618 | &self.statement) |
1612 | 1619 | } |
1613 | 1620 | fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) { |
1614 | | - rules.indent_paren_expr.check(acc, IndentParenExprArgs::from_foreach(self)); |
| 1621 | + rules.indent_paren_expr.check(IndentParenExprArgs::from_foreach(self), acc); |
1615 | 1622 | } |
1616 | 1623 | } |
1617 | 1624 |
|
@@ -1750,7 +1757,7 @@ impl TreeElement for ExpressionStmtContent { |
1750 | 1757 | create_subs!(&self.expression, &self.semi) |
1751 | 1758 | } |
1752 | 1759 | fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) { |
1753 | | - rules.sp_punct.check(acc, SpPunctArgs::from_expression_stmt(self)); |
| 1760 | + rules.sp_punct.check(SpPunctArgs::from_expression_stmt(self), acc); |
1754 | 1761 | } |
1755 | 1762 | } |
1756 | 1763 |
|
|
0 commit comments