@@ -16,18 +16,18 @@ def __init__(self, style: BlankLinesStyle, stop_after: Optional[Tree] = None):
1616 self ._stop_after = stop_after
1717 self ._stop = False
1818
19- def visit_compilation_unit (self , compilation_unit : CompilationUnit , p : P ) -> J :
20- if not compilation_unit .prefix .comments :
21- compilation_unit = compilation_unit .replace (prefix = Space .EMPTY )
22- return super ().visit_compilation_unit (compilation_unit , p )
19+ def visit_compilation_unit (self , cu : CompilationUnit , p : P ) -> J :
20+ if not cu .prefix .comments :
21+ cu = cu .replace (prefix = Space .EMPTY )
22+ return super ().visit_compilation_unit (cu , p )
2323
24- def visit_statement (self , statement : Statement , p : P ) -> J :
25- statement = super ().visit_statement (statement , p )
24+ def visit_statement (self , stmt : Statement , p : P ) -> J :
25+ stmt = super ().visit_statement (stmt , p )
2626
2727 parent_cursor = self .cursor .parent_tree_cursor ()
2828 top_level = isinstance (parent_cursor .value , CompilationUnit )
2929
30- if isinstance (statement , (Import , MultiImport )):
30+ if isinstance (stmt , (Import , MultiImport )):
3131 parent_cursor .put_message ('prev_import' , True )
3232 prev_import = False
3333 else :
@@ -36,35 +36,35 @@ def visit_statement(self, statement: Statement, p: P) -> J:
3636 parent_cursor .put_message ('prev_import' , False )
3737
3838 if top_level :
39- if statement == cast (CompilationUnit , parent_cursor .value ).statements [0 ]:
40- statement = statement .replace (prefix = statement .prefix .replace (whitespace = '' ))
39+ if stmt == cast (CompilationUnit , parent_cursor .value ).statements [0 ]:
40+ stmt = stmt .replace (prefix = stmt .prefix .replace (whitespace = '' ))
4141 else :
42- min_lines = max (self ._style .minimum .around_top_level_classes_functions if isinstance (statement , (ClassDeclaration , MethodDeclaration )) else 0 ,
42+ min_lines = max (self ._style .minimum .around_top_level_classes_functions if isinstance (stmt , (ClassDeclaration , MethodDeclaration )) else 0 ,
4343 self ._style .minimum .after_top_level_imports if prev_import else 0 )
44- statement = _adjusted_lines_for_tree (statement , min_lines , self ._style .keep_maximum .in_declarations )
44+ stmt = _adjusted_lines_for_tree (stmt , min_lines , self ._style .keep_maximum .in_declarations )
4545 else :
4646 in_block = isinstance (parent_cursor .value , Block )
4747 in_class = in_block and isinstance (parent_cursor .parent_tree_cursor ().value , ClassDeclaration )
4848 min_lines = 0
4949 if in_class :
50- is_first = cast (Block , parent_cursor .value ).statements [0 ] is statement
51- if not is_first and isinstance (statement , MethodDeclaration ):
50+ is_first = cast (Block , parent_cursor .value ).statements [0 ] is stmt
51+ if not is_first and isinstance (stmt , MethodDeclaration ):
5252 min_lines = max (min_lines , self ._style .minimum .around_method )
53- elif not is_first and isinstance (statement , ClassDeclaration ):
53+ elif not is_first and isinstance (stmt , ClassDeclaration ):
5454 min_lines = max (min_lines , self ._style .minimum .around_class )
55- elif is_first and isinstance (statement , MethodDeclaration ):
55+ elif is_first and isinstance (stmt , MethodDeclaration ):
5656 min_lines = max (min_lines , self ._style .minimum .before_first_method )
5757
5858 # This seems to correspond to how IntelliJ interprets this configuration
5959 max_lines = self ._style .keep_maximum .in_declarations if \
60- isinstance (statement , (ClassDeclaration , MethodDeclaration )) else \
60+ isinstance (stmt , (ClassDeclaration , MethodDeclaration )) else \
6161 self ._style .keep_maximum .in_code
6262
6363 if prev_import :
6464 min_lines = max (min_lines , self ._style .minimum .after_local_imports )
6565
66- statement = _adjusted_lines_for_tree (statement , min_lines , max_lines )
67- return statement
66+ stmt = _adjusted_lines_for_tree (stmt , min_lines , max_lines )
67+ return stmt
6868
6969 def post_visit (self , tree : T , p : P ) -> Optional [T ]:
7070 if self ._stop_after and tree == self ._stop_after :
0 commit comments