rubydex 0.1.0.beta11 → 0.1.0.beta13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +23 -23
  3. data/README.md +125 -125
  4. data/THIRD_PARTY_LICENSES.html +2018 -945
  5. data/exe/rdx +47 -47
  6. data/ext/rubydex/declaration.c +453 -388
  7. data/ext/rubydex/declaration.h +23 -23
  8. data/ext/rubydex/definition.c +284 -197
  9. data/ext/rubydex/definition.h +28 -28
  10. data/ext/rubydex/diagnostic.c +6 -6
  11. data/ext/rubydex/diagnostic.h +11 -11
  12. data/ext/rubydex/document.c +97 -98
  13. data/ext/rubydex/document.h +10 -10
  14. data/ext/rubydex/extconf.rb +146 -127
  15. data/ext/rubydex/graph.c +701 -512
  16. data/ext/rubydex/graph.h +10 -10
  17. data/ext/rubydex/handle.h +44 -44
  18. data/ext/rubydex/location.c +22 -22
  19. data/ext/rubydex/location.h +15 -15
  20. data/ext/rubydex/reference.c +123 -104
  21. data/ext/rubydex/reference.h +15 -16
  22. data/ext/rubydex/rubydex.c +22 -22
  23. data/ext/rubydex/utils.c +108 -86
  24. data/ext/rubydex/utils.h +34 -28
  25. data/lib/rubydex/comment.rb +17 -17
  26. data/lib/rubydex/declaration.rb +11 -0
  27. data/lib/rubydex/diagnostic.rb +21 -21
  28. data/lib/rubydex/failures.rb +15 -15
  29. data/lib/rubydex/graph.rb +98 -92
  30. data/lib/rubydex/keyword.rb +17 -0
  31. data/lib/rubydex/keyword_parameter.rb +13 -0
  32. data/lib/rubydex/location.rb +90 -90
  33. data/lib/rubydex/mixin.rb +22 -0
  34. data/lib/rubydex/version.rb +5 -5
  35. data/lib/rubydex.rb +24 -20
  36. data/rbi/rubydex.rbi +425 -310
  37. data/rust/Cargo.lock +1851 -1851
  38. data/rust/Cargo.toml +29 -29
  39. data/rust/about.toml +10 -10
  40. data/rust/{about.hbs → about_templates/about.hbs} +81 -78
  41. data/rust/about_templates/mingw_licenses.hbs +1071 -0
  42. data/rust/rubydex/Cargo.toml +42 -42
  43. data/rust/rubydex/src/compile_assertions.rs +13 -13
  44. data/rust/rubydex/src/diagnostic.rs +110 -109
  45. data/rust/rubydex/src/errors.rs +28 -28
  46. data/rust/rubydex/src/indexing/local_graph.rs +224 -224
  47. data/rust/rubydex/src/indexing/rbs_indexer.rs +1551 -1554
  48. data/rust/rubydex/src/indexing/ruby_indexer.rs +2329 -6753
  49. data/rust/rubydex/src/indexing/ruby_indexer_tests.rs +4962 -0
  50. data/rust/rubydex/src/indexing.rs +210 -210
  51. data/rust/rubydex/src/integrity.rs +279 -278
  52. data/rust/rubydex/src/job_queue.rs +199 -205
  53. data/rust/rubydex/src/lib.rs +17 -17
  54. data/rust/rubydex/src/listing.rs +371 -272
  55. data/rust/rubydex/src/main.rs +160 -160
  56. data/rust/rubydex/src/model/built_in.rs +83 -0
  57. data/rust/rubydex/src/model/comment.rs +24 -24
  58. data/rust/rubydex/src/model/declaration.rs +679 -588
  59. data/rust/rubydex/src/model/definitions.rs +1682 -1602
  60. data/rust/rubydex/src/model/document.rs +222 -252
  61. data/rust/rubydex/src/model/encoding.rs +22 -22
  62. data/rust/rubydex/src/model/graph.rs +3782 -3556
  63. data/rust/rubydex/src/model/id.rs +110 -110
  64. data/rust/rubydex/src/model/identity_maps.rs +58 -58
  65. data/rust/rubydex/src/model/ids.rs +60 -38
  66. data/rust/rubydex/src/model/keywords.rs +256 -256
  67. data/rust/rubydex/src/model/name.rs +298 -298
  68. data/rust/rubydex/src/model/references.rs +111 -111
  69. data/rust/rubydex/src/model/string_ref.rs +50 -50
  70. data/rust/rubydex/src/model/visibility.rs +41 -41
  71. data/rust/rubydex/src/model.rs +15 -14
  72. data/rust/rubydex/src/offset.rs +147 -147
  73. data/rust/rubydex/src/position.rs +6 -6
  74. data/rust/rubydex/src/query.rs +1841 -1700
  75. data/rust/rubydex/src/resolution.rs +1852 -5895
  76. data/rust/rubydex/src/resolution_tests.rs +4701 -0
  77. data/rust/rubydex/src/stats/memory.rs +71 -71
  78. data/rust/rubydex/src/stats/orphan_report.rs +264 -263
  79. data/rust/rubydex/src/stats/timer.rs +127 -127
  80. data/rust/rubydex/src/stats.rs +11 -11
  81. data/rust/rubydex/src/test_utils/context.rs +226 -226
  82. data/rust/rubydex/src/test_utils/graph_test.rs +730 -679
  83. data/rust/rubydex/src/test_utils/local_graph_test.rs +602 -602
  84. data/rust/rubydex/src/test_utils.rs +52 -52
  85. data/rust/rubydex/src/visualization/dot.rs +192 -176
  86. data/rust/rubydex/src/visualization.rs +6 -6
  87. data/rust/rubydex/tests/cli.rs +185 -167
  88. data/rust/rubydex-mcp/Cargo.toml +28 -28
  89. data/rust/rubydex-mcp/src/main.rs +48 -48
  90. data/rust/rubydex-mcp/src/server.rs +1145 -1145
  91. data/rust/rubydex-mcp/src/tools.rs +49 -49
  92. data/rust/rubydex-mcp/tests/mcp.rs +302 -302
  93. data/rust/rubydex-sys/Cargo.toml +20 -20
  94. data/rust/rubydex-sys/build.rs +14 -14
  95. data/rust/rubydex-sys/cbindgen.toml +12 -12
  96. data/rust/rubydex-sys/src/declaration_api.rs +485 -469
  97. data/rust/rubydex-sys/src/definition_api.rs +443 -352
  98. data/rust/rubydex-sys/src/diagnostic_api.rs +99 -99
  99. data/rust/rubydex-sys/src/document_api.rs +85 -54
  100. data/rust/rubydex-sys/src/graph_api.rs +1017 -700
  101. data/rust/rubydex-sys/src/lib.rs +79 -9
  102. data/rust/rubydex-sys/src/location_api.rs +79 -79
  103. data/rust/rubydex-sys/src/name_api.rs +187 -135
  104. data/rust/rubydex-sys/src/reference_api.rs +267 -195
  105. data/rust/rubydex-sys/src/utils.rs +70 -70
  106. data/rust/rustfmt.toml +2 -2
  107. metadata +16 -9
  108. data/lib/rubydex/librubydex_sys.so +0 -0
@@ -1,252 +1,222 @@
1
- use std::path::PathBuf;
2
-
3
- use line_index::LineIndex;
4
- use url::Url;
5
-
6
- use crate::diagnostic::Diagnostic;
7
- use crate::model::identity_maps::IdentityHashMap;
8
- use crate::model::ids::{DefinitionId, ReferenceId};
9
-
10
- // Represents a document currently loaded into memory. Identified by its unique URI, it holds the edges to all
11
- // definitions and references discovered in it
12
- #[derive(Debug)]
13
- pub struct Document {
14
- uri: String,
15
- line_index: LineIndex,
16
- definition_ids: Vec<DefinitionId>,
17
- method_reference_ids: Vec<ReferenceId>,
18
- constant_reference_ids: Vec<ReferenceId>,
19
- diagnostics: Vec<Diagnostic>,
20
- definition_diagnostics: IdentityHashMap<DefinitionId, Vec<Diagnostic>>,
21
- reference_diagnostics: IdentityHashMap<ReferenceId, Vec<Diagnostic>>,
22
- }
23
-
24
- impl Document {
25
- #[must_use]
26
- pub fn new(uri: String, source: &str) -> Self {
27
- Self {
28
- uri,
29
- line_index: LineIndex::new(source),
30
- definition_ids: Vec::new(),
31
- method_reference_ids: Vec::new(),
32
- constant_reference_ids: Vec::new(),
33
- diagnostics: Vec::new(),
34
- definition_diagnostics: IdentityHashMap::default(),
35
- reference_diagnostics: IdentityHashMap::default(),
36
- }
37
- }
38
-
39
- #[must_use]
40
- pub fn uri(&self) -> &str {
41
- &self.uri
42
- }
43
-
44
- #[must_use]
45
- pub fn line_index(&self) -> &LineIndex {
46
- &self.line_index
47
- }
48
-
49
- #[must_use]
50
- pub fn definitions(&self) -> &[DefinitionId] {
51
- &self.definition_ids
52
- }
53
-
54
- pub fn add_definition(&mut self, definition_id: DefinitionId) {
55
- debug_assert!(
56
- !self.definition_ids.contains(&definition_id),
57
- "Cannot add the same exact definition to a document twice. Duplicate definition IDs"
58
- );
59
-
60
- self.definition_ids.push(definition_id);
61
- }
62
-
63
- #[must_use]
64
- pub fn method_references(&self) -> &[ReferenceId] {
65
- &self.method_reference_ids
66
- }
67
-
68
- pub fn add_method_reference(&mut self, reference_id: ReferenceId) {
69
- self.method_reference_ids.push(reference_id);
70
- }
71
-
72
- #[must_use]
73
- pub fn constant_references(&self) -> &[ReferenceId] {
74
- &self.constant_reference_ids
75
- }
76
-
77
- pub fn add_constant_reference(&mut self, reference_id: ReferenceId) {
78
- self.constant_reference_ids.push(reference_id);
79
- }
80
-
81
- #[must_use]
82
- pub fn diagnostics(&self) -> &[Diagnostic] {
83
- &self.diagnostics
84
- }
85
-
86
- pub fn add_diagnostic(&mut self, diagnostic: Diagnostic) {
87
- self.diagnostics.push(diagnostic);
88
- }
89
-
90
- #[must_use]
91
- pub fn diagnostics_for_definition(&self, id: DefinitionId) -> &[Diagnostic] {
92
- self.definition_diagnostics.get(&id).map_or(&[], Vec::as_slice)
93
- }
94
-
95
- pub fn add_diagnostic_for_definition(&mut self, id: DefinitionId, diagnostic: Diagnostic) {
96
- self.definition_diagnostics.entry(id).or_default().push(diagnostic);
97
- }
98
-
99
- #[must_use]
100
- pub fn diagnostics_for_reference(&self, id: ReferenceId) -> &[Diagnostic] {
101
- self.reference_diagnostics.get(&id).map_or(&[], Vec::as_slice)
102
- }
103
-
104
- pub fn add_diagnostic_for_reference(&mut self, id: ReferenceId, diagnostic: Diagnostic) {
105
- self.reference_diagnostics.entry(id).or_default().push(diagnostic);
106
- }
107
-
108
- pub fn all_diagnostics(&self) -> impl Iterator<Item = &Diagnostic> {
109
- self.diagnostics
110
- .iter()
111
- .chain(self.definition_diagnostics.values().flatten())
112
- .chain(self.reference_diagnostics.values().flatten())
113
- }
114
-
115
- /// Computes the require path for this document given load paths.
116
- ///
117
- /// Returns `None` if:
118
- /// - URI is not `file://` scheme
119
- /// - URI doesn't end with `.rb`
120
- /// - File path doesn't match any load path
121
- /// - `Url::to_file_path()` fails
122
- ///
123
- /// # Panics
124
- ///
125
- /// Panics if load path entries exceed u16.
126
- #[must_use]
127
- pub fn require_path(&self, load_paths: &[PathBuf]) -> Option<(String, u16)> {
128
- let url = Url::parse(&self.uri).ok()?;
129
- if url.scheme() != "file" {
130
- return None;
131
- }
132
-
133
- let file_path = url.to_file_path().ok()?;
134
- if file_path.extension().is_none_or(|ext| ext != "rb") {
135
- return None;
136
- }
137
-
138
- for (load_path_index, load_path) in load_paths.iter().enumerate() {
139
- if let Ok(relative) = file_path.strip_prefix(load_path) {
140
- let file_path = relative
141
- .components()
142
- .filter_map(|c| c.as_os_str().to_str())
143
- .collect::<Vec<_>>()
144
- .join("/");
145
-
146
- let require_path = file_path.trim_end_matches(".rb").to_string();
147
- return Some((
148
- require_path,
149
- load_path_index.try_into().expect("Load path entries exceed u16"),
150
- ));
151
- }
152
- }
153
- None
154
- }
155
- }
156
-
157
- #[cfg(test)]
158
- mod tests {
159
- use std::str::FromStr;
160
-
161
- use super::*;
162
-
163
- fn test_root() -> PathBuf {
164
- let root = if cfg!(windows) { "C:\\" } else { "/" };
165
- PathBuf::from_str(root).unwrap()
166
- }
167
-
168
- #[test]
169
- #[should_panic(expected = "Cannot add the same exact definition to a document twice. Duplicate definition IDs")]
170
- fn inserting_duplicate_definitions() {
171
- let mut document = Document::new("file:///foo.rb".to_string(), "class Foo; end");
172
- let def_id = DefinitionId::new(123);
173
-
174
- document.add_definition(def_id);
175
- document.add_definition(def_id);
176
-
177
- assert_eq!(document.definitions().len(), 1);
178
- }
179
-
180
- #[test]
181
- fn tracking_references() {
182
- let mut document = Document::new("file:///foo.rb".to_string(), "class Foo; end");
183
- let method_ref = ReferenceId::new(1);
184
- let constant_ref = ReferenceId::new(2);
185
-
186
- document.add_method_reference(method_ref);
187
- document.add_constant_reference(constant_ref);
188
-
189
- assert_eq!(document.method_references(), &[method_ref]);
190
- assert_eq!(document.constant_references(), &[constant_ref]);
191
- }
192
-
193
- #[test]
194
- fn require_path() {
195
- let root = test_root();
196
- let path = root.join("lib").join("foo").join("bar.rb");
197
- let uri = Url::from_file_path(path).unwrap().to_string();
198
- let load_paths = [root.join("lib")];
199
-
200
- let document = Document::new(uri, "");
201
- assert_eq!(Some(("foo/bar".to_string(), 0)), document.require_path(&load_paths));
202
- }
203
-
204
- #[test]
205
- fn require_path_first_load_path_wins() {
206
- let root = test_root();
207
- let path = root.join("a").join("b").join("foo.rb");
208
- let uri = Url::from_file_path(path).unwrap().to_string();
209
- let load_path_a = root.join("a");
210
- let load_path_ab = root.join("a").join("b");
211
- let load_paths = [load_path_a, load_path_ab];
212
-
213
- let document = Document::new(uri, "");
214
- assert_eq!(Some(("b/foo".to_string(), 0)), document.require_path(&load_paths));
215
- }
216
-
217
- #[test]
218
- fn require_path_returns_none() {
219
- let root = test_root();
220
- let load_paths = [root.join("lib")];
221
-
222
- // non-file URI
223
- let document = Document::new("untitled:Untitled-1".to_string(), "");
224
- assert!(document.require_path(&load_paths).is_none());
225
-
226
- // non-.rb extension
227
- let path = root.join("lib").join("foo.so");
228
- let uri = Url::from_file_path(path).unwrap().to_string();
229
- let document = Document::new(uri, "");
230
- assert!(document.require_path(&load_paths).is_none());
231
-
232
- // /libfoo is not under /lib - should not match due to partial directory name
233
- let path = root.join("libfoo").join("bar.rb");
234
- let uri = Url::from_file_path(path).unwrap().to_string();
235
- let document = Document::new(uri, "");
236
- assert!(document.require_path(&load_paths).is_none());
237
- }
238
-
239
- #[test]
240
- fn require_path_with_spaces() {
241
- let root = test_root();
242
- let path = root.join("lib").join("space foo").join("bar.rb");
243
- let uri = Url::from_file_path(path).unwrap().to_string();
244
- let load_paths = [root.join("lib")];
245
-
246
- let document = Document::new(uri, "");
247
- assert_eq!(
248
- Some(("space foo/bar".to_string(), 0)),
249
- document.require_path(&load_paths)
250
- );
251
- }
252
- }
1
+ use std::path::PathBuf;
2
+
3
+ use line_index::LineIndex;
4
+ use url::Url;
5
+
6
+ use crate::diagnostic::Diagnostic;
7
+ use crate::model::ids::{ConstantReferenceId, DefinitionId, MethodReferenceId};
8
+
9
+ // Represents a document currently loaded into memory. Identified by its unique URI, it holds the edges to all
10
+ // definitions and references discovered in it
11
+ #[derive(Debug)]
12
+ pub struct Document {
13
+ uri: String,
14
+ line_index: LineIndex,
15
+ definition_ids: Vec<DefinitionId>,
16
+ method_reference_ids: Vec<MethodReferenceId>,
17
+ constant_reference_ids: Vec<ConstantReferenceId>,
18
+ diagnostics: Vec<Diagnostic>,
19
+ }
20
+
21
+ impl Document {
22
+ #[must_use]
23
+ pub fn new(uri: String, source: &str) -> Self {
24
+ Self {
25
+ uri,
26
+ line_index: LineIndex::new(source),
27
+ definition_ids: Vec::new(),
28
+ method_reference_ids: Vec::new(),
29
+ constant_reference_ids: Vec::new(),
30
+ diagnostics: Vec::new(),
31
+ }
32
+ }
33
+
34
+ #[must_use]
35
+ pub fn uri(&self) -> &str {
36
+ &self.uri
37
+ }
38
+
39
+ #[must_use]
40
+ pub fn line_index(&self) -> &LineIndex {
41
+ &self.line_index
42
+ }
43
+
44
+ #[must_use]
45
+ pub fn definitions(&self) -> &[DefinitionId] {
46
+ &self.definition_ids
47
+ }
48
+
49
+ pub fn add_definition(&mut self, definition_id: DefinitionId) {
50
+ debug_assert!(
51
+ !self.definition_ids.contains(&definition_id),
52
+ "Cannot add the same exact definition to a document twice. Duplicate definition IDs"
53
+ );
54
+
55
+ self.definition_ids.push(definition_id);
56
+ }
57
+
58
+ #[must_use]
59
+ pub fn method_references(&self) -> &[MethodReferenceId] {
60
+ &self.method_reference_ids
61
+ }
62
+
63
+ pub fn add_method_reference(&mut self, reference_id: MethodReferenceId) {
64
+ self.method_reference_ids.push(reference_id);
65
+ }
66
+
67
+ #[must_use]
68
+ pub fn constant_references(&self) -> &[ConstantReferenceId] {
69
+ &self.constant_reference_ids
70
+ }
71
+
72
+ pub fn add_constant_reference(&mut self, reference_id: ConstantReferenceId) {
73
+ self.constant_reference_ids.push(reference_id);
74
+ }
75
+
76
+ #[must_use]
77
+ pub fn diagnostics(&self) -> &[Diagnostic] {
78
+ &self.diagnostics
79
+ }
80
+
81
+ pub fn add_diagnostic(&mut self, diagnostic: Diagnostic) {
82
+ self.diagnostics.push(diagnostic);
83
+ }
84
+
85
+ /// Computes the require path for this document given load paths.
86
+ ///
87
+ /// Returns `None` if:
88
+ /// - URI is not `file://` scheme
89
+ /// - URI doesn't end with `.rb`
90
+ /// - File path doesn't match any load path
91
+ /// - `Url::to_file_path()` fails
92
+ ///
93
+ /// # Panics
94
+ ///
95
+ /// Panics if load path entries exceed u16.
96
+ #[must_use]
97
+ pub fn require_path(&self, load_paths: &[PathBuf]) -> Option<(String, u16)> {
98
+ let url = Url::parse(&self.uri).ok()?;
99
+ if url.scheme() != "file" {
100
+ return None;
101
+ }
102
+
103
+ let file_path = url.to_file_path().ok()?;
104
+ if file_path.extension().is_none_or(|ext| ext != "rb") {
105
+ return None;
106
+ }
107
+
108
+ for (load_path_index, load_path) in load_paths.iter().enumerate() {
109
+ if let Ok(relative) = file_path.strip_prefix(load_path) {
110
+ let file_path = relative
111
+ .components()
112
+ .filter_map(|c| c.as_os_str().to_str())
113
+ .collect::<Vec<_>>()
114
+ .join("/");
115
+
116
+ let require_path = file_path.trim_end_matches(".rb").to_string();
117
+ return Some((
118
+ require_path,
119
+ load_path_index.try_into().expect("Load path entries exceed u16"),
120
+ ));
121
+ }
122
+ }
123
+ None
124
+ }
125
+ }
126
+
127
+ #[cfg(test)]
128
+ mod tests {
129
+ use std::str::FromStr;
130
+
131
+ use super::*;
132
+
133
+ fn test_root() -> PathBuf {
134
+ let root = if cfg!(windows) { "C:\\" } else { "/" };
135
+ PathBuf::from_str(root).unwrap()
136
+ }
137
+
138
+ #[test]
139
+ #[should_panic(expected = "Cannot add the same exact definition to a document twice. Duplicate definition IDs")]
140
+ fn inserting_duplicate_definitions() {
141
+ let mut document = Document::new("file:///foo.rb".to_string(), "class Foo; end");
142
+ let def_id = DefinitionId::new(123);
143
+
144
+ document.add_definition(def_id);
145
+ document.add_definition(def_id);
146
+
147
+ assert_eq!(document.definitions().len(), 1);
148
+ }
149
+
150
+ #[test]
151
+ fn tracking_references() {
152
+ let mut document = Document::new("file:///foo.rb".to_string(), "class Foo; end");
153
+ let method_ref = MethodReferenceId::new(1);
154
+ let constant_ref = ConstantReferenceId::new(2);
155
+
156
+ document.add_method_reference(method_ref);
157
+ document.add_constant_reference(constant_ref);
158
+
159
+ assert_eq!(document.method_references(), &[method_ref]);
160
+ assert_eq!(document.constant_references(), &[constant_ref]);
161
+ }
162
+
163
+ #[test]
164
+ fn require_path() {
165
+ let root = test_root();
166
+ let path = root.join("lib").join("foo").join("bar.rb");
167
+ let uri = Url::from_file_path(path).unwrap().to_string();
168
+ let load_paths = [root.join("lib")];
169
+
170
+ let document = Document::new(uri, "");
171
+ assert_eq!(Some(("foo/bar".to_string(), 0)), document.require_path(&load_paths));
172
+ }
173
+
174
+ #[test]
175
+ fn require_path_first_load_path_wins() {
176
+ let root = test_root();
177
+ let path = root.join("a").join("b").join("foo.rb");
178
+ let uri = Url::from_file_path(path).unwrap().to_string();
179
+ let load_path_a = root.join("a");
180
+ let load_path_ab = root.join("a").join("b");
181
+ let load_paths = [load_path_a, load_path_ab];
182
+
183
+ let document = Document::new(uri, "");
184
+ assert_eq!(Some(("b/foo".to_string(), 0)), document.require_path(&load_paths));
185
+ }
186
+
187
+ #[test]
188
+ fn require_path_returns_none() {
189
+ let root = test_root();
190
+ let load_paths = [root.join("lib")];
191
+
192
+ // non-file URI
193
+ let document = Document::new("untitled:Untitled-1".to_string(), "");
194
+ assert!(document.require_path(&load_paths).is_none());
195
+
196
+ // non-.rb extension
197
+ let path = root.join("lib").join("foo.so");
198
+ let uri = Url::from_file_path(path).unwrap().to_string();
199
+ let document = Document::new(uri, "");
200
+ assert!(document.require_path(&load_paths).is_none());
201
+
202
+ // /libfoo is not under /lib - should not match due to partial directory name
203
+ let path = root.join("libfoo").join("bar.rb");
204
+ let uri = Url::from_file_path(path).unwrap().to_string();
205
+ let document = Document::new(uri, "");
206
+ assert!(document.require_path(&load_paths).is_none());
207
+ }
208
+
209
+ #[test]
210
+ fn require_path_with_spaces() {
211
+ let root = test_root();
212
+ let path = root.join("lib").join("space foo").join("bar.rb");
213
+ let uri = Url::from_file_path(path).unwrap().to_string();
214
+ let load_paths = [root.join("lib")];
215
+
216
+ let document = Document::new(uri, "");
217
+ assert_eq!(
218
+ Some(("space foo/bar".to_string(), 0)),
219
+ document.require_path(&load_paths)
220
+ );
221
+ }
222
+ }
@@ -1,22 +1,22 @@
1
- use line_index::WideEncoding;
2
-
3
- #[derive(Default, Debug)]
4
- pub enum Encoding {
5
- #[default]
6
- Utf8,
7
- Utf16,
8
- Utf32,
9
- }
10
-
11
- impl Encoding {
12
- /// Transform the LSP selected encoding into the expected `WideEncoding` for converting code units with the
13
- /// `line_index` crate
14
- #[must_use]
15
- pub fn to_wide(&self) -> Option<WideEncoding> {
16
- match self {
17
- Encoding::Utf8 => None,
18
- Encoding::Utf16 => Some(WideEncoding::Utf16),
19
- Encoding::Utf32 => Some(WideEncoding::Utf32),
20
- }
21
- }
22
- }
1
+ use line_index::WideEncoding;
2
+
3
+ #[derive(Default, Debug)]
4
+ pub enum Encoding {
5
+ #[default]
6
+ Utf8,
7
+ Utf16,
8
+ Utf32,
9
+ }
10
+
11
+ impl Encoding {
12
+ /// Transform the LSP selected encoding into the expected `WideEncoding` for converting code units with the
13
+ /// `line_index` crate
14
+ #[must_use]
15
+ pub fn to_wide(&self) -> Option<WideEncoding> {
16
+ match self {
17
+ Encoding::Utf8 => None,
18
+ Encoding::Utf16 => Some(WideEncoding::Utf16),
19
+ Encoding::Utf32 => Some(WideEncoding::Utf32),
20
+ }
21
+ }
22
+ }