|
| 1 | +/// A byte and character range in the source buffer. |
| 2 | +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] |
| 3 | +pub struct LocationRange { |
| 4 | + pub start_char: u32, |
| 5 | + pub start_byte: u32, |
| 6 | + pub end_char: u32, |
| 7 | + pub end_byte: u32, |
| 8 | +} |
| 9 | + |
| 10 | +impl LocationRange { |
| 11 | + #[must_use] |
| 12 | + pub fn new(start_char: u32, start_byte: u32, end_char: u32, end_byte: u32) -> Self { |
| 13 | + Self { |
| 14 | + start_char, |
| 15 | + start_byte, |
| 16 | + end_char, |
| 17 | + end_byte, |
| 18 | + } |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +/// ```rbs |
| 23 | +/// foo |
| 24 | +/// ^^^ name |
| 25 | +/// |
| 26 | +/// foo[bar, baz] |
| 27 | +/// ^^^ name |
| 28 | +/// ^^^^^^^^^^ args |
| 29 | +/// ``` |
| 30 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 31 | +pub struct AliasLocation { |
| 32 | + pub range: LocationRange, |
| 33 | + pub name_range: LocationRange, |
| 34 | + pub args_range: Option<LocationRange>, |
| 35 | +} |
| 36 | + |
| 37 | +/// ```rbs |
| 38 | +/// Foo |
| 39 | +/// ^^^ name |
| 40 | +/// |
| 41 | +/// Foo[Bar, Baz] |
| 42 | +/// ^^^ name |
| 43 | +/// ^^^^^^^^^^ args |
| 44 | +/// ``` |
| 45 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 46 | +pub struct ClassInstanceLocation { |
| 47 | + pub range: LocationRange, |
| 48 | + pub name_range: LocationRange, |
| 49 | + pub args_range: Option<LocationRange>, |
| 50 | +} |
| 51 | + |
| 52 | +/// ```rbs |
| 53 | +/// singleton(::Foo) |
| 54 | +/// ^^^^^ name |
| 55 | +/// ``` |
| 56 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 57 | +pub struct ClassSingletonLocation { |
| 58 | + pub range: LocationRange, |
| 59 | + pub name_range: LocationRange, |
| 60 | + pub args_range: Option<LocationRange>, |
| 61 | +} |
| 62 | + |
| 63 | +/// ```rbs |
| 64 | +/// String name |
| 65 | +/// ^^^^ name |
| 66 | +/// ``` |
| 67 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 68 | +pub struct FunctionParamLocation { |
| 69 | + pub range: LocationRange, |
| 70 | + pub name_range: Option<LocationRange>, |
| 71 | +} |
| 72 | + |
| 73 | +/// ```rbs |
| 74 | +/// _Foo |
| 75 | +/// ^^^^ name |
| 76 | +/// |
| 77 | +/// _Foo[Bar, Baz] |
| 78 | +/// ^^^^ name |
| 79 | +/// ^^^^^^^^^^ args |
| 80 | +/// ``` |
| 81 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 82 | +pub struct InterfaceLocation { |
| 83 | + pub range: LocationRange, |
| 84 | + pub name_range: LocationRange, |
| 85 | + pub args_range: Option<LocationRange>, |
| 86 | +} |
| 87 | + |
| 88 | +/// ```rbs |
| 89 | +/// () -> void |
| 90 | +/// ^^^^^^^^^^ type |
| 91 | +/// |
| 92 | +/// [A] () { () -> A } -> A |
| 93 | +/// ^^^ type_params |
| 94 | +/// ^^^^^^^^^^^^^^^^^^^ type |
| 95 | +/// ``` |
| 96 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 97 | +pub struct MethodTypeLocation { |
| 98 | + pub range: LocationRange, |
| 99 | + pub type_range: LocationRange, |
| 100 | + pub type_params_range: Option<LocationRange>, |
| 101 | +} |
| 102 | + |
| 103 | +/// ```rbs |
| 104 | +/// Key |
| 105 | +/// ^^^ name |
| 106 | +/// |
| 107 | +/// unchecked out Elem < _ToJson > bot = untyped |
| 108 | +/// ^^^^^^^^^ unchecked |
| 109 | +/// ^^^ variance |
| 110 | +/// ^^^^ name |
| 111 | +/// ^^^^^^^^^ upper_bound |
| 112 | +/// ^^^^^ lower_bound |
| 113 | +/// ^^^^^^^^ default |
| 114 | +/// ``` |
| 115 | +#[derive(Clone, Debug, Eq, PartialEq, Hash)] |
| 116 | +pub struct TypeParamLocation { |
| 117 | + pub range: LocationRange, |
| 118 | + pub name_range: LocationRange, |
| 119 | + pub variance_range: Option<LocationRange>, |
| 120 | + pub unchecked_range: Option<LocationRange>, |
| 121 | + pub upper_bound_range: Option<LocationRange>, |
| 122 | + pub lower_bound_range: Option<LocationRange>, |
| 123 | + pub default_range: Option<LocationRange>, |
| 124 | +} |
0 commit comments