verter_core 0.0.1-alpha.1

Vue 3 SFC compiler - transforms Vue Single File Components to render functions with TypeScript support
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
//! Vue SFC script parsing module.
//!
//! This module provides parsing for Vue Single File Component script blocks,
//! supporting both Options API (`<script>`) and Script Setup (`<script setup>`).
//!
//! # Example
//!
//! ```ignore
//! use verter_core::syntax::plugins::analysis::plugins::script::{
//!     parse_script, ScriptMode, ScriptParseResult,
//! };
//!
//! let result = parse_script(program, ScriptMode::Setup, base_offset, source);
//! ```

// This module is WIP - allow dead code for now
#![allow(dead_code)]
#![allow(unused_imports)]

pub mod macros;
pub mod options;
pub mod resolve_type;
pub mod setup;
pub mod shared;
pub mod types;
pub mod usage;

use oxc_ast::ast::Program;

pub use macros::{
    detect_macro_kind, is_define_component, MacroArrayArg, MacroDeclarator, MacroObjectArg,
    MacroProperty, MacroTypeParams, ScriptMacro, VueMacroKind,
};
pub use resolve_type::{
    build_type_context, format_runtime_types, resolve_type_elements_with_ctx,
    resolve_type_elements_with_ctx_ref, DiagnosticLocation, ResolutionDiagnostic,
    ResolutionDiagnosticKind, ResolvedEmit, RuntimeType, TypeResolutionContext,
};
pub use shared::ScriptParseContext;
pub use types::*;
pub use usage::{
    detect_vue_api_call,
    // Template usage types
    BindingRefContext,
    BindingRefInfo,
    // Sync context tracking (getCurrentInstance safety)
    CallSiteContext,
    ComponentUsageInfo,
    // Loop & render performance tracking
    ConditionLikelihood,
    EmitCallUsage,
    EmitEventName,
    FileUsageFlags,
    InjectUsage,
    IterableType,
    LifecycleHook,
    LifecycleUsage,
    LoopChildren,
    LoopInfo,
    ProvideKey,
    ProvideKeyKind,
    ProvideUsage,
    ReactiveKind,
    ReactiveStateUsage,
    RenderPatternWarning,
    SlotDefinitionInfo,
    SlotName,
    SlotUsageInfo,
    StaticConditionValue,
    SyncContextUsage,
    TemplateMetrics,
    TemplateRefAttrUsage,
    TemplateUsageCollector,
    TemplateUtilUsage,
    UsageCollector,
    VueApiCategory,
    VueApiKind,
    WarningSeverity,
    WatcherUsage,
};

use options::{process_options_statements, OptionsContext};
use setup::{process_setup_statements, SetupContext};
use shared::{try_process_export, try_process_import};

/// Parse a Vue SFC script block.
///
/// This is the main entry point for script parsing. It walks the already-parsed
/// OXC Program AST and extracts relevant information based on the script mode.
///
/// # Arguments
///
/// * `program` - The OXC-parsed program AST
/// * `mode` - The script mode (Options or Setup)
/// * `base_offset` - The byte offset where the script content starts in the SFC file
/// * `source` - The source text of the script content
///
/// # Returns
///
/// A `ScriptParseResult` containing all extracted items, async status, and errors.
pub fn parse_script<'a>(
    program: &Program<'a>,
    mode: ScriptMode,
    base_offset: u32,
    source: &'a str,
) -> ScriptParseResult<'a> {
    let ctx = ScriptParseContext::new(base_offset, source.as_bytes());
    let mut items = Vec::new();
    let mut errors = Vec::new();
    let mut is_async = false;

    // First pass: collect imports and exports (shared across modes)
    for stmt in &program.body {
        if let Some(import_item) = try_process_import(stmt, &ctx) {
            items.push(import_item);
        }
        if let Some(export_item) = try_process_export(stmt, &ctx) {
            items.push(export_item);
        }
    }

    // Second pass: mode-specific processing
    match mode {
        ScriptMode::Setup => {
            let mut setup_ctx = SetupContext::new();
            process_setup_statements(&program.body, &ctx, &mut setup_ctx, &mut items, &mut errors);
            is_async = setup_ctx.is_async;
        }
        ScriptMode::Options => {
            let mut options_ctx = OptionsContext::new();
            process_options_statements(
                &program.body,
                &ctx,
                &mut options_ctx,
                &mut items,
                &mut errors,
                &mut is_async,
            );
        }
    }

    ScriptParseResult {
        is_async,
        items,
        errors,
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use oxc_allocator::Allocator;
    use oxc_parser::Parser;
    use oxc_span::SourceType;

    #[test]
    fn test_parse_setup_with_import() {
        let source = r#"import { ref } from 'vue';
const count = ref(0);"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let result = parse_script(&ret.program, ScriptMode::Setup, 0, source);

        // Should have import + declaration
        let imports: Vec<_> = result
            .items
            .iter()
            .filter(|i| matches!(i, ScriptItem::Import(_)))
            .collect();
        let decls: Vec<_> = result
            .items
            .iter()
            .filter(|i| matches!(i, ScriptItem::Declaration(_)))
            .collect();

        assert_eq!(imports.len(), 1);
        assert_eq!(decls.len(), 1);
    }

    #[test]
    fn test_parse_setup_with_macro() {
        let source = r#"const props = defineProps<{ msg: string }>();"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let result = parse_script(&ret.program, ScriptMode::Setup, 0, source);

        let macros: Vec<_> = result
            .items
            .iter()
            .filter(|i| matches!(i, ScriptItem::Macro(_)))
            .collect();

        assert_eq!(macros.len(), 1);
        if let ScriptItem::Macro(m) = macros[0] {
            assert_eq!(m.kind(), VueMacroKind::DefineProps);
            assert!(matches!(
                m,
                ScriptMacro::DefineProps {
                    type_params: Some(_),
                    ..
                }
            ));
        }
    }

    #[test]
    fn test_parse_setup_with_async() {
        let source = r#"const data = await fetch('/api');"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let result = parse_script(&ret.program, ScriptMode::Setup, 0, source);

        assert!(result.is_async);
        let async_items: Vec<_> = result
            .items
            .iter()
            .filter(|i| matches!(i, ScriptItem::Async(_)))
            .collect();
        assert!(!async_items.is_empty());
    }

    #[test]
    fn test_parse_setup_with_top_level_await_expression() {
        // Test top-level await as an expression statement
        let source = r#"await Promise.resolve();"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let result = parse_script(&ret.program, ScriptMode::Setup, 0, source);

        assert!(
            result.is_async,
            "is_async should be true for top-level await"
        );
        let async_items: Vec<_> = result
            .items
            .iter()
            .filter(|i| matches!(i, ScriptItem::Async(_)))
            .collect();
        assert_eq!(
            async_items.len(),
            1,
            "Should have exactly one ScriptAsync item"
        );
    }

    #[test]
    fn test_parse_setup_with_multiple_awaits() {
        let source = r#"
const a = await fetch('/api/a');
const b = await fetch('/api/b');
await processResults(a, b);
"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let result = parse_script(&ret.program, ScriptMode::Setup, 0, source);

        assert!(result.is_async);
        let async_items: Vec<_> = result
            .items
            .iter()
            .filter(|i| matches!(i, ScriptItem::Async(_)))
            .collect();
        assert_eq!(
            async_items.len(),
            3,
            "Should detect all three await expressions"
        );
    }

    #[test]
    fn test_parse_setup_with_await_using() {
        // await using is ES2024 syntax for async disposal
        let source = r#"await using resource = getAsyncResource();"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let result = parse_script(&ret.program, ScriptMode::Setup, 0, source);

        assert!(result.is_async, "is_async should be true for await using");
        let async_items: Vec<_> = result
            .items
            .iter()
            .filter(|i| matches!(i, ScriptItem::Async(_)))
            .collect();
        assert!(
            !async_items.is_empty(),
            "Should have ScriptAsync item for await using"
        );
    }

    #[test]
    fn test_parse_setup_with_for_await_of() {
        let source = r#"
for await (const item of asyncIterable) {
    console.log(item);
}
"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let result = parse_script(&ret.program, ScriptMode::Setup, 0, source);

        assert!(
            result.is_async,
            "is_async should be true for for await...of"
        );
        let async_items: Vec<_> = result
            .items
            .iter()
            .filter(|i| matches!(i, ScriptItem::Async(_)))
            .collect();
        assert!(
            !async_items.is_empty(),
            "Should have ScriptAsync item for for await...of"
        );
    }

    #[test]
    fn test_parse_setup_with_nested_await() {
        // Await nested in call expression arguments
        let source = r#"process(await fetch('/api'));"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let result = parse_script(&ret.program, ScriptMode::Setup, 0, source);

        assert!(result.is_async, "is_async should be true for nested await");
        let async_items: Vec<_> = result
            .items
            .iter()
            .filter(|i| matches!(i, ScriptItem::Async(_)))
            .collect();
        assert!(
            !async_items.is_empty(),
            "Should detect await in call argument"
        );
    }

    #[test]
    fn test_parse_setup_with_await_in_binary_expression() {
        let source = r#"const result = (await fetchA()) + (await fetchB());"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let result = parse_script(&ret.program, ScriptMode::Setup, 0, source);

        assert!(result.is_async);
        let async_items: Vec<_> = result
            .items
            .iter()
            .filter(|i| matches!(i, ScriptItem::Async(_)))
            .collect();
        assert_eq!(
            async_items.len(),
            2,
            "Should detect both awaits in binary expression"
        );
    }

    #[test]
    fn test_parse_setup_with_await_in_conditional() {
        let source = r#"const result = condition ? await fetchA() : await fetchB();"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let result = parse_script(&ret.program, ScriptMode::Setup, 0, source);

        assert!(result.is_async);
        let async_items: Vec<_> = result
            .items
            .iter()
            .filter(|i| matches!(i, ScriptItem::Async(_)))
            .collect();
        assert_eq!(
            async_items.len(),
            2,
            "Should detect both awaits in conditional expression"
        );
    }

    #[test]
    fn test_parse_setup_await_inside_async_function_not_counted() {
        // Await inside an async function should NOT make the script setup async
        // Only top-level awaits should count
        let source = r#"
async function fetchData() {
    return await fetch('/api');
}
const handler = async () => {
    await something();
};
"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let result = parse_script(&ret.program, ScriptMode::Setup, 0, source);

        assert!(
            !result.is_async,
            "Awaits inside async functions should not make script setup async"
        );
        let async_items: Vec<_> = result
            .items
            .iter()
            .filter(|i| matches!(i, ScriptItem::Async(_)))
            .collect();
        assert!(
            async_items.is_empty(),
            "Should not have ScriptAsync items for nested async functions"
        );
    }

    #[test]
    fn test_parse_setup_async_span_is_correct() {
        let source = r#"await fetch('/api');"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let result = parse_script(&ret.program, ScriptMode::Setup, 50, source);

        let async_items: Vec<_> = result
            .items
            .iter()
            .filter_map(|i| {
                if let ScriptItem::Async(a) = i {
                    Some(a)
                } else {
                    None
                }
            })
            .collect();

        assert_eq!(async_items.len(), 1);
        // Span should be adjusted by base_offset (50)
        assert!(
            async_items[0].span.start >= 50,
            "Span should be adjusted by base_offset"
        );
        assert!(async_items[0].span.end > async_items[0].span.start);
    }

    #[test]
    fn test_parse_setup_with_await_in_if_condition() {
        let source = r#"
if (await checkCondition()) {
    doSomething();
}
"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let result = parse_script(&ret.program, ScriptMode::Setup, 0, source);

        assert!(
            result.is_async,
            "is_async should be true for await in if condition"
        );
        let async_items: Vec<_> = result
            .items
            .iter()
            .filter(|i| matches!(i, ScriptItem::Async(_)))
            .collect();
        assert!(
            !async_items.is_empty(),
            "Should detect await in if condition"
        );
    }

    #[test]
    fn test_parse_setup_real_world_async_script() {
        // This is the exact script from the user's Vue SFC
        let source = r#"import { ref } from "vue";

const foo = ref("");

await Promise.resolve();

async () => {
  await Promise.resolve();
};

let a = {};"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let result = parse_script(&ret.program, ScriptMode::Setup, 0, source);

        // Should detect the top-level await, but NOT the one inside the async arrow function
        assert!(
            result.is_async,
            "is_async should be true - there's a top-level await"
        );

        let async_items: Vec<_> = result
            .items
            .iter()
            .filter_map(|i| {
                if let ScriptItem::Async(a) = i {
                    Some(a)
                } else {
                    None
                }
            })
            .collect();

        // Should have exactly 1 async item (the top-level await Promise.resolve())
        // The await inside async () => {} should NOT be counted
        assert_eq!(
            async_items.len(),
            1,
            "Should have exactly 1 ScriptAsync item for top-level await"
        );

        // Verify the span points to the correct location
        let await_text =
            &source[async_items[0].span.start as usize..async_items[0].span.end as usize];
        println!("Detected async span text: '{}'", await_text);
        assert!(await_text.contains("await"), "Span should contain 'await'");
    }

    #[test]
    fn test_parse_options_with_define_component() {
        let source = r#"import { defineComponent } from 'vue';
export default defineComponent({
    setup() {
        return {};
    }
});"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let result = parse_script(&ret.program, ScriptMode::Options, 0, source);

        let default_exports: Vec<_> = result
            .items
            .iter()
            .filter_map(|i| {
                if let ScriptItem::DefaultExport(e) = i {
                    Some(e)
                } else {
                    None
                }
            })
            .collect();

        assert_eq!(default_exports.len(), 1);
        assert_eq!(
            default_exports[0].export_type,
            DefaultExportType::DefineComponent
        );
        assert!(default_exports[0].setup_body_span.is_some());
    }

    #[test]
    fn test_parse_options_plain_object() {
        let source = r#"export default {
    setup() {
        return {};
    }
};"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let result = parse_script(&ret.program, ScriptMode::Options, 0, source);

        let default_exports: Vec<_> = result
            .items
            .iter()
            .filter_map(|i| {
                if let ScriptItem::DefaultExport(e) = i {
                    Some(e)
                } else {
                    None
                }
            })
            .collect();

        assert_eq!(default_exports.len(), 1);
        assert_eq!(default_exports[0].export_type, DefaultExportType::Object);
    }

    #[test]
    fn test_detect_macro_kind() {
        assert_eq!(
            detect_macro_kind(b"defineProps"),
            Some(VueMacroKind::DefineProps)
        );
        assert_eq!(
            detect_macro_kind(b"defineEmits"),
            Some(VueMacroKind::DefineEmits)
        );
        assert_eq!(
            detect_macro_kind(b"withDefaults"),
            Some(VueMacroKind::WithDefaults)
        );
        assert_eq!(detect_macro_kind(b"ref"), None);
    }

    #[test]
    fn test_offset_adjustment() {
        let source = r#"const x = 1;"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        // Simulate script starting at offset 100 in the SFC file
        let result = parse_script(&ret.program, ScriptMode::Setup, 100, source);

        // Check that spans are adjusted
        let decls: Vec<_> = result
            .items
            .iter()
            .filter_map(|i| {
                if let ScriptItem::Declaration(d) = i {
                    Some(d)
                } else {
                    None
                }
            })
            .collect();

        assert_eq!(decls.len(), 1);
        // The span should start at 100 (base_offset) + 6 (position of 'x')
        assert!(decls[0].span.start >= 100);
    }

    #[test]
    fn test_get_current_instance_detection() {
        assert_eq!(
            detect_vue_api_call(b"getCurrentInstance"),
            Some(VueApiKind::GetCurrentInstance)
        );
        // Category should be InstanceAccess
        assert_eq!(
            VueApiKind::GetCurrentInstance.category(),
            VueApiCategory::InstanceAccess
        );
        // Should require sync context
        assert!(VueApiKind::GetCurrentInstance.requires_sync_context());
    }

    #[test]
    fn test_get_current_instance_before_await() {
        use setup::check_expression_for_usage;
        use shared::ScriptParseContext;
        use usage::{CallSiteContext, UsageCollector};

        let source = r#"const instance = getCurrentInstance();"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let ctx = ScriptParseContext::new(0, source.as_bytes());
        let mut collector = UsageCollector::new(source.as_bytes());

        // Process the variable declaration
        for stmt in &ret.program.body {
            if let oxc_ast::ast::Statement::VariableDeclaration(var_decl) = stmt {
                for declarator in &var_decl.declarations {
                    if let Some(init) = &declarator.init {
                        let binding_span =
                            if let oxc_ast::ast::BindingPattern::BindingIdentifier(id) =
                                &declarator.id
                            {
                                Some(crate::common::Span::new(id.span.start, id.span.end))
                            } else {
                                None
                            };
                        check_expression_for_usage(init, &ctx, &mut collector, binding_span);
                    }
                }
            }
        }

        // Should have detected getCurrentInstance
        assert_eq!(collector.sync_context_usages.len(), 1);
        let usage = &collector.sync_context_usages[0];
        assert_eq!(usage.kind, VueApiKind::GetCurrentInstance);
        // Should be before await (no await in this source)
        assert_eq!(usage.context, CallSiteContext::BeforeAwait);
        assert!(usage.is_safe());
    }

    #[test]
    fn test_get_current_instance_after_await() {
        use setup::check_expression_for_usage;
        use shared::ScriptParseContext;
        use usage::{CallSiteContext, UsageCollector};

        // getCurrentInstance after an await
        let source = r#"
const data = await fetch('/api');
const instance = getCurrentInstance();
"#;
        let allocator = Allocator::default();
        let source_type = SourceType::tsx();
        let ret = Parser::new(&allocator, source, source_type).parse();

        let ctx = ScriptParseContext::new(0, source.as_bytes());
        let mut collector = UsageCollector::new(source.as_bytes());

        // Process all statements
        for stmt in &ret.program.body {
            match stmt {
                oxc_ast::ast::Statement::VariableDeclaration(var_decl) => {
                    for declarator in &var_decl.declarations {
                        if let Some(init) = &declarator.init {
                            let binding_span =
                                if let oxc_ast::ast::BindingPattern::BindingIdentifier(id) =
                                    &declarator.id
                                {
                                    Some(crate::common::Span::new(id.span.start, id.span.end))
                                } else {
                                    None
                                };
                            check_expression_for_usage(init, &ctx, &mut collector, binding_span);
                        }
                    }
                }
                oxc_ast::ast::Statement::ExpressionStatement(expr) => {
                    check_expression_for_usage(&expr.expression, &ctx, &mut collector, None);
                }
                _ => {}
            }
        }

        // Should have detected getCurrentInstance
        assert_eq!(
            collector.sync_context_usages.len(),
            1,
            "Should have one getCurrentInstance call"
        );
        let usage = &collector.sync_context_usages[0];
        assert_eq!(usage.kind, VueApiKind::GetCurrentInstance);
        // Should be after await
        assert_eq!(usage.context, CallSiteContext::AfterAwait);
        assert!(usage.is_potentially_unsafe());
        // Should have the preceding await span
        assert!(usage.preceding_await_span.is_some());
    }
}