@@ -14,6 +14,58 @@ fn default_indentation_spaces() -> u32 {
1414 INDENTATION_LEVEL_DEFAULT
1515}
1616
17+ pub struct MethodOutputBreakRule {
18+ pub enabled : bool
19+ }
20+
21+ pub struct MethodOutputBreakArgs {
22+ pub before_arrow_range : ZeroRange ,
23+ pub arrow_range : ZeroRange ,
24+ pub after_arrow_range : ZeroRange ,
25+ }
26+
27+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
28+ pub struct MethodOutputBreakOptions {
29+ }
30+
31+ impl Rule for MethodOutputBreakRule {
32+ fn name ( ) -> & ' static str {
33+ "method_output_break"
34+ }
35+ fn description ( ) -> & ' static str {
36+ "Break long method declarations with output parameters before the arrow."
37+ }
38+ fn get_rule_type ( ) -> RuleType {
39+ RuleType :: LL5
40+ }
41+ }
42+
43+ impl MethodOutputBreakArgs {
44+ pub fn from_method ( node : & MethodContent ) -> Option < MethodOutputBreakArgs > {
45+ let Some ( returns) = & node. returns else { return None ; } ;
46+ Some ( MethodOutputBreakArgs {
47+ before_arrow_range : node. rparen . range ( ) ,
48+ arrow_range : returns. 0 . range ( ) ,
49+ after_arrow_range : returns. 1 . range ( ) ,
50+ } )
51+ }
52+ }
53+
54+ impl MethodOutputBreakRule {
55+ pub fn check ( & self , args : Option < MethodOutputBreakArgs > , acc : & mut Vec < DMLStyleError > ) {
56+ if !self . enabled { return ; }
57+ let Some ( args) = args else { return ; } ;
58+ if args. before_arrow_range . row_end . 0 == args. after_arrow_range . row_start . 0 {
59+ // If all parts are on the same line, we don't need to check it.
60+ return ;
61+ }
62+ // If the arrow and the return type are not on the same line, report an error.
63+ if args. arrow_range . row_start . 0 != args. after_arrow_range . row_start . 0 {
64+ acc. push ( self . create_err ( args. arrow_range ) ) ;
65+ }
66+ }
67+ }
68+
1769pub struct FuncCallBreakOnOpenParenRule {
1870 pub enabled : bool ,
1971 indentation_spaces : u32
0 commit comments