|
7 | 7 | //! bundled with it so they move together when reordered. |
8 | 8 |
|
9 | 9 | use crate::node_kind::GDScriptNodeKind; |
| 10 | +use crate::shared_utils::should_annotation_be_inline; |
10 | 11 | use tree_sitter::Node; |
11 | 12 |
|
12 | 13 | #[derive(Debug, Clone)] |
@@ -187,10 +188,10 @@ pub fn build_reorder_plan<'a>(parent: Node<'a>, content: &'a str) -> ReorderPlan |
187 | 188 | } else { |
188 | 189 | is_child_attached_to_declaration[child_index] = true; |
189 | 190 | if let Some(annotation_identifier) = get_annotation_identifier(child, content) { |
190 | | - if is_inline_export_annotation(annotation_identifier) { |
191 | | - visited_annotations.has_export_annotation = true; |
192 | | - } else if annotation_identifier == "onready" { |
| 191 | + if annotation_identifier == "onready" { |
193 | 192 | visited_annotations.has_onready_annotation = true; |
| 193 | + } else if should_annotation_be_inline(annotation_identifier) { |
| 194 | + visited_annotations.has_export_annotation = true; |
194 | 195 | } |
195 | 196 | } |
196 | 197 | } |
@@ -528,10 +529,10 @@ fn classify_variable<'a>( |
528 | 529 | let Some(annotation_name) = get_annotation_identifier(annotation, content) else { |
529 | 530 | continue; |
530 | 531 | }; |
531 | | - if is_inline_export_annotation(annotation_name) { |
532 | | - has_export_annotation = true; |
533 | | - } else if annotation_name == "onready" { |
| 532 | + if annotation_name == "onready" { |
534 | 533 | has_onready_annotation = true; |
| 534 | + } else if should_annotation_be_inline(annotation_name) { |
| 535 | + has_export_annotation = true; |
535 | 536 | } |
536 | 537 | } |
537 | 538 | } |
@@ -563,16 +564,6 @@ fn get_annotation_identifier<'a>(annotation: Node<'a>, content: &'a str) -> Opti |
563 | 564 | None |
564 | 565 | } |
565 | 566 |
|
566 | | -/// Returns true when an annotation exports the variable it annotates. The |
567 | | -/// `@export_group` and `@export_subgroup` annotations only mark groups of |
568 | | -/// following properties and must not make an unannotated variable look |
569 | | -/// exported. |
570 | | -fn is_inline_export_annotation(annotation_name: &str) -> bool { |
571 | | - annotation_name.starts_with("export") |
572 | | - && annotation_name != "export_group" |
573 | | - && annotation_name != "export_subgroup" |
574 | | -} |
575 | | - |
576 | 567 | /// Extract the "name" field child from a declaration node. |
577 | 568 | fn extract_name<'a>(node: Node<'a>, content: &'a str) -> Option<&'a str> { |
578 | 569 | let count = node.child_count(); |
|
0 commit comments