Skip to main content

swls_core/feature/
hover.rs

1use bevy_ecs::{
2    component::Component,
3    schedule::{IntoScheduleConfigs, Schedule, ScheduleLabel},
4    world::World,
5};
6
7pub use crate::{
8    systems::{
9        get_current_prefix, hover_class, hover_excluded_property, hover_prefix, hover_property,
10        hover_types, infer_types,
11    },
12    util::triple::get_current_triple,
13};
14
15/// [`Component`] indicating that the current document is handling a Hover request.
16#[derive(Component, Debug, Default)]
17pub struct HoverRequest(pub Vec<String>, pub Option<crate::lsp_types::Range>);
18
19/// [`ScheduleLabel`] related to the Hover schedule
20#[derive(ScheduleLabel, Clone, Eq, PartialEq, Debug, Hash)]
21pub struct Label;
22
23pub fn setup_schedule(world: &mut World) {
24    let mut hover = Schedule::new(Label);
25    hover.add_systems((
26        infer_types,
27        get_current_triple,
28        // Runs after the triple lookup and drops its (wrong) result when the
29        // cursor is on a prefix declaration, so the triple-based hovers below
30        // no-op and `hover_prefix` describes the namespace instead.
31        get_current_prefix.after(get_current_triple),
32        hover_prefix.after(get_current_prefix),
33        hover_types
34            .before(hover_class)
35            .before(hover_property)
36            .after(get_current_prefix)
37            .after(infer_types),
38        hover_class.after(get_current_prefix),
39        hover_property.after(get_current_prefix),
40        hover_excluded_property.after(get_current_prefix),
41    ));
42    world.add_schedule(hover);
43}