@@ -575,40 +575,7 @@ impl GdTree {
575575 continue ;
576576 }
577577
578- // Function annotations are always placed on a new line after formatting
579- if child_grammar_name == "function_definition" {
580- let function = & self . nodes [ child_id] ;
581-
582- if function. children . is_empty ( ) {
583- continue ;
584- }
585-
586- let Some ( annotations_id) = function. children . get ( 0 ) . cloned ( ) else {
587- continue ;
588- } ;
589- let annotations = & mut self . nodes [ annotations_id] ;
590-
591- // We check if this function has any annotations as first child
592- if annotations. grammar_name != "annotations" {
593- // If the first child is not annotations, then this function doesn't have any
594- continue ;
595- }
596-
597- // Annotations are children of the (annotations) node, so we need to flatten them
598- let flatten_annotations = annotations. children . drain ( ..) . collect :: < Vec < _ > > ( ) ;
599-
600- // Annotations node is now an orphan
601- // We could remove it from nodes, but it's too much trouble, just pretend it's not there
602- self . nodes [ child_id] . children . remove ( 0 ) ;
603-
604- let new_parent = & mut self . nodes [ parent_id] ;
605- // Insert annotations before the function
606- // Iterating in reverse because nodes will push other nodes down in the tree,
607- // so the first annotation needs to be inserted last
608- for annotation_id in flatten_annotations. into_iter ( ) . rev ( ) {
609- new_parent. children . insert ( index, annotation_id) ;
610- }
611- } else if child_grammar_name == "variable_statement" {
578+ if child_grammar_name == "variable_statement" {
612579 // We move @onready and @export annotations on the same line as the variable after formatting,
613580 // that means we need to move these annotations to be children of the variable_statement node
614581 // We move from the current index back to 0, searching for any annotations
0 commit comments