tree_sitter_language_pack 1.16.1 → 1.16.2

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.
@@ -1,5 +1,5 @@
1
1
  // This file is auto-generated by alef. DO NOT EDIT.
2
- // alef:hash:0610241288e9ecf0ceaa96d28faf641497d9b61129e67415390e25481287f308
2
+ // alef:hash:c3615d7c5390fb2f911fcfde880fe0b9856216e28c6b830e42ce58db41dc60f1
3
3
  // Re-generate with: alef generate
4
4
  #![allow(dead_code, unused_imports, unused_variables)]
5
5
  #![allow(
@@ -99,14 +99,24 @@ impl ByteRange {
99
99
  let (kwargs_opt,) = args.optional;
100
100
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
101
101
  Ok(Self {
102
- start: kwargs
103
- .get(ruby.to_symbol("start"))
104
- .and_then(|v| usize::try_convert(v).ok())
105
- .unwrap_or_default(),
106
- end: kwargs
107
- .get(ruby.to_symbol("end"))
108
- .and_then(|v| usize::try_convert(v).ok())
109
- .unwrap_or_default(),
102
+ start: match kwargs.get(ruby.to_symbol("start")) {
103
+ Some(v) => usize::try_convert(v).map_err(|e| {
104
+ magnus::Error::new(
105
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
106
+ format!("invalid value for `start`: {}", e),
107
+ )
108
+ })?,
109
+ None => Default::default(),
110
+ },
111
+ end: match kwargs.get(ruby.to_symbol("end")) {
112
+ Some(v) => usize::try_convert(v).map_err(|e| {
113
+ magnus::Error::new(
114
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
115
+ format!("invalid value for `end`: {}", e),
116
+ )
117
+ })?,
118
+ None => Default::default(),
119
+ },
110
120
  })
111
121
  }
112
122
 
@@ -175,42 +185,87 @@ impl ChunkContext {
175
185
  let (kwargs_opt,) = args.optional;
176
186
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
177
187
  Ok(Self {
178
- language: kwargs
179
- .get(ruby.to_symbol("language"))
180
- .and_then(|v| String::try_convert(v).ok())
181
- .unwrap_or_default(),
182
- chunk_index: kwargs
183
- .get(ruby.to_symbol("chunk_index"))
184
- .and_then(|v| usize::try_convert(v).ok())
185
- .unwrap_or_default(),
186
- total_chunks: kwargs
187
- .get(ruby.to_symbol("total_chunks"))
188
- .and_then(|v| usize::try_convert(v).ok())
189
- .unwrap_or_default(),
190
- node_types: kwargs
191
- .get(ruby.to_symbol("node_types"))
192
- .and_then(|v| <Vec<String>>::try_convert(v).ok())
193
- .unwrap_or_default(),
194
- context_path: kwargs
195
- .get(ruby.to_symbol("context_path"))
196
- .and_then(|v| <Vec<String>>::try_convert(v).ok())
197
- .unwrap_or_default(),
198
- symbols_defined: kwargs
199
- .get(ruby.to_symbol("symbols_defined"))
200
- .and_then(|v| <Vec<String>>::try_convert(v).ok())
201
- .unwrap_or_default(),
202
- comments: kwargs
203
- .get(ruby.to_symbol("comments"))
204
- .and_then(|v| <Vec<CommentInfo>>::try_convert(v).ok())
205
- .unwrap_or_default(),
206
- docstrings: kwargs
207
- .get(ruby.to_symbol("docstrings"))
208
- .and_then(|v| <Vec<DocstringInfo>>::try_convert(v).ok())
209
- .unwrap_or_default(),
210
- has_error_nodes: kwargs
211
- .get(ruby.to_symbol("has_error_nodes"))
212
- .and_then(|v| bool::try_convert(v).ok())
213
- .unwrap_or_default(),
188
+ language: match kwargs.get(ruby.to_symbol("language")) {
189
+ Some(v) => String::try_convert(v).map_err(|e| {
190
+ magnus::Error::new(
191
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
192
+ format!("invalid value for `language`: {}", e),
193
+ )
194
+ })?,
195
+ None => Default::default(),
196
+ },
197
+ chunk_index: match kwargs.get(ruby.to_symbol("chunk_index")) {
198
+ Some(v) => usize::try_convert(v).map_err(|e| {
199
+ magnus::Error::new(
200
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
201
+ format!("invalid value for `chunk_index`: {}", e),
202
+ )
203
+ })?,
204
+ None => Default::default(),
205
+ },
206
+ total_chunks: match kwargs.get(ruby.to_symbol("total_chunks")) {
207
+ Some(v) => usize::try_convert(v).map_err(|e| {
208
+ magnus::Error::new(
209
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
210
+ format!("invalid value for `total_chunks`: {}", e),
211
+ )
212
+ })?,
213
+ None => Default::default(),
214
+ },
215
+ node_types: match kwargs.get(ruby.to_symbol("node_types")) {
216
+ Some(v) => <Vec<String>>::try_convert(v).map_err(|e| {
217
+ magnus::Error::new(
218
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
219
+ format!("invalid value for `node_types`: {}", e),
220
+ )
221
+ })?,
222
+ None => Default::default(),
223
+ },
224
+ context_path: match kwargs.get(ruby.to_symbol("context_path")) {
225
+ Some(v) => <Vec<String>>::try_convert(v).map_err(|e| {
226
+ magnus::Error::new(
227
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
228
+ format!("invalid value for `context_path`: {}", e),
229
+ )
230
+ })?,
231
+ None => Default::default(),
232
+ },
233
+ symbols_defined: match kwargs.get(ruby.to_symbol("symbols_defined")) {
234
+ Some(v) => <Vec<String>>::try_convert(v).map_err(|e| {
235
+ magnus::Error::new(
236
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
237
+ format!("invalid value for `symbols_defined`: {}", e),
238
+ )
239
+ })?,
240
+ None => Default::default(),
241
+ },
242
+ comments: match kwargs.get(ruby.to_symbol("comments")) {
243
+ Some(v) => <Vec<CommentInfo>>::try_convert(v).map_err(|e| {
244
+ magnus::Error::new(
245
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
246
+ format!("invalid value for `comments`: {}", e),
247
+ )
248
+ })?,
249
+ None => Default::default(),
250
+ },
251
+ docstrings: match kwargs.get(ruby.to_symbol("docstrings")) {
252
+ Some(v) => <Vec<DocstringInfo>>::try_convert(v).map_err(|e| {
253
+ magnus::Error::new(
254
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
255
+ format!("invalid value for `docstrings`: {}", e),
256
+ )
257
+ })?,
258
+ None => Default::default(),
259
+ },
260
+ has_error_nodes: match kwargs.get(ruby.to_symbol("has_error_nodes")) {
261
+ Some(v) => bool::try_convert(v).map_err(|e| {
262
+ magnus::Error::new(
263
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
264
+ format!("invalid value for `has_error_nodes`: {}", e),
265
+ )
266
+ })?,
267
+ None => Default::default(),
268
+ },
214
269
  })
215
270
  }
216
271
 
@@ -304,30 +359,60 @@ impl CodeChunk {
304
359
  let (kwargs_opt,) = args.optional;
305
360
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
306
361
  Ok(Self {
307
- content: kwargs
308
- .get(ruby.to_symbol("content"))
309
- .and_then(|v| String::try_convert(v).ok())
310
- .unwrap_or_default(),
311
- start_byte: kwargs
312
- .get(ruby.to_symbol("start_byte"))
313
- .and_then(|v| usize::try_convert(v).ok())
314
- .unwrap_or_default(),
315
- end_byte: kwargs
316
- .get(ruby.to_symbol("end_byte"))
317
- .and_then(|v| usize::try_convert(v).ok())
318
- .unwrap_or_default(),
319
- start_line: kwargs
320
- .get(ruby.to_symbol("start_line"))
321
- .and_then(|v| usize::try_convert(v).ok())
322
- .unwrap_or_default(),
323
- end_line: kwargs
324
- .get(ruby.to_symbol("end_line"))
325
- .and_then(|v| usize::try_convert(v).ok())
326
- .unwrap_or_default(),
327
- metadata: kwargs
328
- .get(ruby.to_symbol("metadata"))
329
- .and_then(|v| ChunkContext::try_convert(v).ok())
330
- .unwrap_or_default(),
362
+ content: match kwargs.get(ruby.to_symbol("content")) {
363
+ Some(v) => String::try_convert(v).map_err(|e| {
364
+ magnus::Error::new(
365
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
366
+ format!("invalid value for `content`: {}", e),
367
+ )
368
+ })?,
369
+ None => Default::default(),
370
+ },
371
+ start_byte: match kwargs.get(ruby.to_symbol("start_byte")) {
372
+ Some(v) => usize::try_convert(v).map_err(|e| {
373
+ magnus::Error::new(
374
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
375
+ format!("invalid value for `start_byte`: {}", e),
376
+ )
377
+ })?,
378
+ None => Default::default(),
379
+ },
380
+ end_byte: match kwargs.get(ruby.to_symbol("end_byte")) {
381
+ Some(v) => usize::try_convert(v).map_err(|e| {
382
+ magnus::Error::new(
383
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
384
+ format!("invalid value for `end_byte`: {}", e),
385
+ )
386
+ })?,
387
+ None => Default::default(),
388
+ },
389
+ start_line: match kwargs.get(ruby.to_symbol("start_line")) {
390
+ Some(v) => usize::try_convert(v).map_err(|e| {
391
+ magnus::Error::new(
392
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
393
+ format!("invalid value for `start_line`: {}", e),
394
+ )
395
+ })?,
396
+ None => Default::default(),
397
+ },
398
+ end_line: match kwargs.get(ruby.to_symbol("end_line")) {
399
+ Some(v) => usize::try_convert(v).map_err(|e| {
400
+ magnus::Error::new(
401
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
402
+ format!("invalid value for `end_line`: {}", e),
403
+ )
404
+ })?,
405
+ None => Default::default(),
406
+ },
407
+ metadata: match kwargs.get(ruby.to_symbol("metadata")) {
408
+ Some(v) => ChunkContext::try_convert(v).map_err(|e| {
409
+ magnus::Error::new(
410
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
411
+ format!("invalid value for `metadata`: {}", e),
412
+ )
413
+ })?,
414
+ None => Default::default(),
415
+ },
331
416
  })
332
417
  }
333
418
 
@@ -412,21 +497,42 @@ impl CommentInfo {
412
497
  let (kwargs_opt,) = args.optional;
413
498
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
414
499
  Ok(Self {
415
- text: kwargs
416
- .get(ruby.to_symbol("text"))
417
- .and_then(|v| String::try_convert(v).ok())
418
- .unwrap_or_default(),
419
- kind: kwargs
420
- .get(ruby.to_symbol("kind"))
421
- .and_then(|v| CommentKind::try_convert(v).ok())
422
- .unwrap_or(CommentKind::Line),
423
- span: kwargs
424
- .get(ruby.to_symbol("span"))
425
- .and_then(|v| Span::try_convert(v).ok())
426
- .unwrap_or_default(),
427
- associated_node: kwargs
428
- .get(ruby.to_symbol("associated_node"))
429
- .and_then(|v| String::try_convert(v).ok()),
500
+ text: match kwargs.get(ruby.to_symbol("text")) {
501
+ Some(v) => String::try_convert(v).map_err(|e| {
502
+ magnus::Error::new(
503
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
504
+ format!("invalid value for `text`: {}", e),
505
+ )
506
+ })?,
507
+ None => Default::default(),
508
+ },
509
+ kind: match kwargs.get(ruby.to_symbol("kind")) {
510
+ Some(v) => CommentKind::try_convert(v).map_err(|e| {
511
+ magnus::Error::new(
512
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
513
+ format!("invalid value for `kind`: {}", e),
514
+ )
515
+ })?,
516
+ None => CommentKind::Line,
517
+ },
518
+ span: match kwargs.get(ruby.to_symbol("span")) {
519
+ Some(v) => Span::try_convert(v).map_err(|e| {
520
+ magnus::Error::new(
521
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
522
+ format!("invalid value for `span`: {}", e),
523
+ )
524
+ })?,
525
+ None => Default::default(),
526
+ },
527
+ associated_node: match kwargs.get(ruby.to_symbol("associated_node")) {
528
+ Some(v) => Some(String::try_convert(v).map_err(|e| {
529
+ magnus::Error::new(
530
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
531
+ format!("invalid value for `associated_node`: {}", e),
532
+ )
533
+ })?),
534
+ None => None,
535
+ },
430
536
  })
431
537
  }
432
538
 
@@ -497,18 +603,33 @@ impl DataAttribute {
497
603
  let (kwargs_opt,) = args.optional;
498
604
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
499
605
  Ok(Self {
500
- name: kwargs
501
- .get(ruby.to_symbol("name"))
502
- .and_then(|v| String::try_convert(v).ok())
503
- .unwrap_or_default(),
504
- value: kwargs
505
- .get(ruby.to_symbol("value"))
506
- .and_then(|v| String::try_convert(v).ok())
507
- .unwrap_or_default(),
508
- span: kwargs
509
- .get(ruby.to_symbol("span"))
510
- .and_then(|v| Span::try_convert(v).ok())
511
- .unwrap_or_default(),
606
+ name: match kwargs.get(ruby.to_symbol("name")) {
607
+ Some(v) => String::try_convert(v).map_err(|e| {
608
+ magnus::Error::new(
609
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
610
+ format!("invalid value for `name`: {}", e),
611
+ )
612
+ })?,
613
+ None => Default::default(),
614
+ },
615
+ value: match kwargs.get(ruby.to_symbol("value")) {
616
+ Some(v) => String::try_convert(v).map_err(|e| {
617
+ magnus::Error::new(
618
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
619
+ format!("invalid value for `value`: {}", e),
620
+ )
621
+ })?,
622
+ None => Default::default(),
623
+ },
624
+ span: match kwargs.get(ruby.to_symbol("span")) {
625
+ Some(v) => Span::try_convert(v).map_err(|e| {
626
+ magnus::Error::new(
627
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
628
+ format!("invalid value for `span`: {}", e),
629
+ )
630
+ })?,
631
+ None => Default::default(),
632
+ },
512
633
  })
513
634
  }
514
635
 
@@ -586,28 +707,60 @@ impl DataNode {
586
707
  let (kwargs_opt,) = args.optional;
587
708
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
588
709
  Ok(Self {
589
- kind: kwargs
590
- .get(ruby.to_symbol("kind"))
591
- .and_then(|v| DataNodeKind::try_convert(v).ok())
592
- .unwrap_or(DataNodeKind::KeyValue),
593
- key: kwargs
594
- .get(ruby.to_symbol("key"))
595
- .and_then(|v| String::try_convert(v).ok()),
596
- value: kwargs
597
- .get(ruby.to_symbol("value"))
598
- .and_then(|v| String::try_convert(v).ok()),
599
- attributes: kwargs
600
- .get(ruby.to_symbol("attributes"))
601
- .and_then(|v| <Vec<DataAttribute>>::try_convert(v).ok())
602
- .unwrap_or_default(),
603
- children: kwargs
604
- .get(ruby.to_symbol("children"))
605
- .and_then(|v| <Vec<DataNode>>::try_convert(v).ok())
606
- .unwrap_or_default(),
607
- span: kwargs
608
- .get(ruby.to_symbol("span"))
609
- .and_then(|v| Span::try_convert(v).ok())
610
- .unwrap_or_default(),
710
+ kind: match kwargs.get(ruby.to_symbol("kind")) {
711
+ Some(v) => DataNodeKind::try_convert(v).map_err(|e| {
712
+ magnus::Error::new(
713
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
714
+ format!("invalid value for `kind`: {}", e),
715
+ )
716
+ })?,
717
+ None => DataNodeKind::KeyValue,
718
+ },
719
+ key: match kwargs.get(ruby.to_symbol("key")) {
720
+ Some(v) => Some(String::try_convert(v).map_err(|e| {
721
+ magnus::Error::new(
722
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
723
+ format!("invalid value for `key`: {}", e),
724
+ )
725
+ })?),
726
+ None => None,
727
+ },
728
+ value: match kwargs.get(ruby.to_symbol("value")) {
729
+ Some(v) => Some(String::try_convert(v).map_err(|e| {
730
+ magnus::Error::new(
731
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
732
+ format!("invalid value for `value`: {}", e),
733
+ )
734
+ })?),
735
+ None => None,
736
+ },
737
+ attributes: match kwargs.get(ruby.to_symbol("attributes")) {
738
+ Some(v) => <Vec<DataAttribute>>::try_convert(v).map_err(|e| {
739
+ magnus::Error::new(
740
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
741
+ format!("invalid value for `attributes`: {}", e),
742
+ )
743
+ })?,
744
+ None => Default::default(),
745
+ },
746
+ children: match kwargs.get(ruby.to_symbol("children")) {
747
+ Some(v) => <Vec<DataNode>>::try_convert(v).map_err(|e| {
748
+ magnus::Error::new(
749
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
750
+ format!("invalid value for `children`: {}", e),
751
+ )
752
+ })?,
753
+ None => Default::default(),
754
+ },
755
+ span: match kwargs.get(ruby.to_symbol("span")) {
756
+ Some(v) => Span::try_convert(v).map_err(|e| {
757
+ magnus::Error::new(
758
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
759
+ format!("invalid value for `span`: {}", e),
760
+ )
761
+ })?,
762
+ None => Default::default(),
763
+ },
611
764
  })
612
765
  }
613
766
 
@@ -686,18 +839,33 @@ impl Diagnostic {
686
839
  let (kwargs_opt,) = args.optional;
687
840
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
688
841
  Ok(Self {
689
- message: kwargs
690
- .get(ruby.to_symbol("message"))
691
- .and_then(|v| String::try_convert(v).ok())
692
- .unwrap_or_default(),
693
- severity: kwargs
694
- .get(ruby.to_symbol("severity"))
695
- .and_then(|v| DiagnosticSeverity::try_convert(v).ok())
696
- .unwrap_or(DiagnosticSeverity::Error),
697
- span: kwargs
698
- .get(ruby.to_symbol("span"))
699
- .and_then(|v| Span::try_convert(v).ok())
700
- .unwrap_or_default(),
842
+ message: match kwargs.get(ruby.to_symbol("message")) {
843
+ Some(v) => String::try_convert(v).map_err(|e| {
844
+ magnus::Error::new(
845
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
846
+ format!("invalid value for `message`: {}", e),
847
+ )
848
+ })?,
849
+ None => Default::default(),
850
+ },
851
+ severity: match kwargs.get(ruby.to_symbol("severity")) {
852
+ Some(v) => DiagnosticSeverity::try_convert(v).map_err(|e| {
853
+ magnus::Error::new(
854
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
855
+ format!("invalid value for `severity`: {}", e),
856
+ )
857
+ })?,
858
+ None => DiagnosticSeverity::Error,
859
+ },
860
+ span: match kwargs.get(ruby.to_symbol("span")) {
861
+ Some(v) => Span::try_convert(v).map_err(|e| {
862
+ magnus::Error::new(
863
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
864
+ format!("invalid value for `span`: {}", e),
865
+ )
866
+ })?,
867
+ None => Default::default(),
868
+ },
701
869
  })
702
870
  }
703
871
 
@@ -764,17 +932,33 @@ impl DocSection {
764
932
  let (kwargs_opt,) = args.optional;
765
933
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
766
934
  Ok(Self {
767
- kind: kwargs
768
- .get(ruby.to_symbol("kind"))
769
- .and_then(|v| String::try_convert(v).ok())
770
- .unwrap_or_default(),
771
- name: kwargs
772
- .get(ruby.to_symbol("name"))
773
- .and_then(|v| String::try_convert(v).ok()),
774
- description: kwargs
775
- .get(ruby.to_symbol("description"))
776
- .and_then(|v| String::try_convert(v).ok())
777
- .unwrap_or_default(),
935
+ kind: match kwargs.get(ruby.to_symbol("kind")) {
936
+ Some(v) => String::try_convert(v).map_err(|e| {
937
+ magnus::Error::new(
938
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
939
+ format!("invalid value for `kind`: {}", e),
940
+ )
941
+ })?,
942
+ None => Default::default(),
943
+ },
944
+ name: match kwargs.get(ruby.to_symbol("name")) {
945
+ Some(v) => Some(String::try_convert(v).map_err(|e| {
946
+ magnus::Error::new(
947
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
948
+ format!("invalid value for `name`: {}", e),
949
+ )
950
+ })?),
951
+ None => None,
952
+ },
953
+ description: match kwargs.get(ruby.to_symbol("description")) {
954
+ Some(v) => String::try_convert(v).map_err(|e| {
955
+ magnus::Error::new(
956
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
957
+ format!("invalid value for `description`: {}", e),
958
+ )
959
+ })?,
960
+ None => Default::default(),
961
+ },
778
962
  })
779
963
  }
780
964
 
@@ -851,25 +1035,51 @@ impl DocstringInfo {
851
1035
  let (kwargs_opt,) = args.optional;
852
1036
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
853
1037
  Ok(Self {
854
- text: kwargs
855
- .get(ruby.to_symbol("text"))
856
- .and_then(|v| String::try_convert(v).ok())
857
- .unwrap_or_default(),
858
- format: kwargs
859
- .get(ruby.to_symbol("format"))
860
- .and_then(|v| DocstringFormat::try_convert(v).ok())
861
- .unwrap_or(DocstringFormat::PythonTripleQuote),
862
- span: kwargs
863
- .get(ruby.to_symbol("span"))
864
- .and_then(|v| Span::try_convert(v).ok())
865
- .unwrap_or_default(),
866
- associated_item: kwargs
867
- .get(ruby.to_symbol("associated_item"))
868
- .and_then(|v| String::try_convert(v).ok()),
869
- parsed_sections: kwargs
870
- .get(ruby.to_symbol("parsed_sections"))
871
- .and_then(|v| <Vec<DocSection>>::try_convert(v).ok())
872
- .unwrap_or_default(),
1038
+ text: match kwargs.get(ruby.to_symbol("text")) {
1039
+ Some(v) => String::try_convert(v).map_err(|e| {
1040
+ magnus::Error::new(
1041
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1042
+ format!("invalid value for `text`: {}", e),
1043
+ )
1044
+ })?,
1045
+ None => Default::default(),
1046
+ },
1047
+ format: match kwargs.get(ruby.to_symbol("format")) {
1048
+ Some(v) => DocstringFormat::try_convert(v).map_err(|e| {
1049
+ magnus::Error::new(
1050
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1051
+ format!("invalid value for `format`: {}", e),
1052
+ )
1053
+ })?,
1054
+ None => DocstringFormat::PythonTripleQuote,
1055
+ },
1056
+ span: match kwargs.get(ruby.to_symbol("span")) {
1057
+ Some(v) => Span::try_convert(v).map_err(|e| {
1058
+ magnus::Error::new(
1059
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1060
+ format!("invalid value for `span`: {}", e),
1061
+ )
1062
+ })?,
1063
+ None => Default::default(),
1064
+ },
1065
+ associated_item: match kwargs.get(ruby.to_symbol("associated_item")) {
1066
+ Some(v) => Some(String::try_convert(v).map_err(|e| {
1067
+ magnus::Error::new(
1068
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1069
+ format!("invalid value for `associated_item`: {}", e),
1070
+ )
1071
+ })?),
1072
+ None => None,
1073
+ },
1074
+ parsed_sections: match kwargs.get(ruby.to_symbol("parsed_sections")) {
1075
+ Some(v) => <Vec<DocSection>>::try_convert(v).map_err(|e| {
1076
+ magnus::Error::new(
1077
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1078
+ format!("invalid value for `parsed_sections`: {}", e),
1079
+ )
1080
+ })?,
1081
+ None => Default::default(),
1082
+ },
873
1083
  })
874
1084
  }
875
1085
 
@@ -901,8 +1111,10 @@ pub struct DownloadManager {
901
1111
  inner: Arc<tree_sitter_language_pack::DownloadManager>,
902
1112
  }
903
1113
 
1114
+ #[cfg(feature = "download")]
904
1115
  unsafe impl IntoValueFromNative for DownloadManager {}
905
1116
 
1117
+ #[cfg(feature = "download")]
906
1118
  impl magnus::TryConvert for DownloadManager {
907
1119
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
908
1120
  let r: &DownloadManager = magnus::TryConvert::try_convert(val)?;
@@ -910,6 +1122,7 @@ impl magnus::TryConvert for DownloadManager {
910
1122
  }
911
1123
  }
912
1124
 
1125
+ #[cfg(feature = "download")]
913
1126
  unsafe impl TryConvertOwned for DownloadManager {}
914
1127
 
915
1128
  #[cfg(feature = "download")]
@@ -989,18 +1202,33 @@ impl ExportInfo {
989
1202
  let (kwargs_opt,) = args.optional;
990
1203
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
991
1204
  Ok(Self {
992
- name: kwargs
993
- .get(ruby.to_symbol("name"))
994
- .and_then(|v| String::try_convert(v).ok())
995
- .unwrap_or_default(),
996
- kind: kwargs
997
- .get(ruby.to_symbol("kind"))
998
- .and_then(|v| ExportKind::try_convert(v).ok())
999
- .unwrap_or(ExportKind::Named),
1000
- span: kwargs
1001
- .get(ruby.to_symbol("span"))
1002
- .and_then(|v| Span::try_convert(v).ok())
1003
- .unwrap_or_default(),
1205
+ name: match kwargs.get(ruby.to_symbol("name")) {
1206
+ Some(v) => String::try_convert(v).map_err(|e| {
1207
+ magnus::Error::new(
1208
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1209
+ format!("invalid value for `name`: {}", e),
1210
+ )
1211
+ })?,
1212
+ None => Default::default(),
1213
+ },
1214
+ kind: match kwargs.get(ruby.to_symbol("kind")) {
1215
+ Some(v) => ExportKind::try_convert(v).map_err(|e| {
1216
+ magnus::Error::new(
1217
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1218
+ format!("invalid value for `kind`: {}", e),
1219
+ )
1220
+ })?,
1221
+ None => ExportKind::Named,
1222
+ },
1223
+ span: match kwargs.get(ruby.to_symbol("span")) {
1224
+ Some(v) => Span::try_convert(v).map_err(|e| {
1225
+ magnus::Error::new(
1226
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1227
+ format!("invalid value for `span`: {}", e),
1228
+ )
1229
+ })?,
1230
+ None => Default::default(),
1231
+ },
1004
1232
  })
1005
1233
  }
1006
1234
 
@@ -1072,38 +1300,78 @@ impl FileMetrics {
1072
1300
  let (kwargs_opt,) = args.optional;
1073
1301
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
1074
1302
  Ok(Self {
1075
- total_lines: kwargs
1076
- .get(ruby.to_symbol("total_lines"))
1077
- .and_then(|v| usize::try_convert(v).ok())
1078
- .unwrap_or_default(),
1079
- code_lines: kwargs
1080
- .get(ruby.to_symbol("code_lines"))
1081
- .and_then(|v| usize::try_convert(v).ok())
1082
- .unwrap_or_default(),
1083
- comment_lines: kwargs
1084
- .get(ruby.to_symbol("comment_lines"))
1085
- .and_then(|v| usize::try_convert(v).ok())
1086
- .unwrap_or_default(),
1087
- blank_lines: kwargs
1088
- .get(ruby.to_symbol("blank_lines"))
1089
- .and_then(|v| usize::try_convert(v).ok())
1090
- .unwrap_or_default(),
1091
- total_bytes: kwargs
1092
- .get(ruby.to_symbol("total_bytes"))
1093
- .and_then(|v| usize::try_convert(v).ok())
1094
- .unwrap_or_default(),
1095
- node_count: kwargs
1096
- .get(ruby.to_symbol("node_count"))
1097
- .and_then(|v| usize::try_convert(v).ok())
1098
- .unwrap_or_default(),
1099
- error_count: kwargs
1100
- .get(ruby.to_symbol("error_count"))
1101
- .and_then(|v| usize::try_convert(v).ok())
1102
- .unwrap_or_default(),
1103
- max_depth: kwargs
1104
- .get(ruby.to_symbol("max_depth"))
1105
- .and_then(|v| usize::try_convert(v).ok())
1106
- .unwrap_or_default(),
1303
+ total_lines: match kwargs.get(ruby.to_symbol("total_lines")) {
1304
+ Some(v) => usize::try_convert(v).map_err(|e| {
1305
+ magnus::Error::new(
1306
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1307
+ format!("invalid value for `total_lines`: {}", e),
1308
+ )
1309
+ })?,
1310
+ None => Default::default(),
1311
+ },
1312
+ code_lines: match kwargs.get(ruby.to_symbol("code_lines")) {
1313
+ Some(v) => usize::try_convert(v).map_err(|e| {
1314
+ magnus::Error::new(
1315
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1316
+ format!("invalid value for `code_lines`: {}", e),
1317
+ )
1318
+ })?,
1319
+ None => Default::default(),
1320
+ },
1321
+ comment_lines: match kwargs.get(ruby.to_symbol("comment_lines")) {
1322
+ Some(v) => usize::try_convert(v).map_err(|e| {
1323
+ magnus::Error::new(
1324
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1325
+ format!("invalid value for `comment_lines`: {}", e),
1326
+ )
1327
+ })?,
1328
+ None => Default::default(),
1329
+ },
1330
+ blank_lines: match kwargs.get(ruby.to_symbol("blank_lines")) {
1331
+ Some(v) => usize::try_convert(v).map_err(|e| {
1332
+ magnus::Error::new(
1333
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1334
+ format!("invalid value for `blank_lines`: {}", e),
1335
+ )
1336
+ })?,
1337
+ None => Default::default(),
1338
+ },
1339
+ total_bytes: match kwargs.get(ruby.to_symbol("total_bytes")) {
1340
+ Some(v) => usize::try_convert(v).map_err(|e| {
1341
+ magnus::Error::new(
1342
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1343
+ format!("invalid value for `total_bytes`: {}", e),
1344
+ )
1345
+ })?,
1346
+ None => Default::default(),
1347
+ },
1348
+ node_count: match kwargs.get(ruby.to_symbol("node_count")) {
1349
+ Some(v) => usize::try_convert(v).map_err(|e| {
1350
+ magnus::Error::new(
1351
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1352
+ format!("invalid value for `node_count`: {}", e),
1353
+ )
1354
+ })?,
1355
+ None => Default::default(),
1356
+ },
1357
+ error_count: match kwargs.get(ruby.to_symbol("error_count")) {
1358
+ Some(v) => usize::try_convert(v).map_err(|e| {
1359
+ magnus::Error::new(
1360
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1361
+ format!("invalid value for `error_count`: {}", e),
1362
+ )
1363
+ })?,
1364
+ None => Default::default(),
1365
+ },
1366
+ max_depth: match kwargs.get(ruby.to_symbol("max_depth")) {
1367
+ Some(v) => usize::try_convert(v).map_err(|e| {
1368
+ magnus::Error::new(
1369
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1370
+ format!("invalid value for `max_depth`: {}", e),
1371
+ )
1372
+ })?,
1373
+ None => Default::default(),
1374
+ },
1107
1375
  })
1108
1376
  }
1109
1377
 
@@ -1200,25 +1468,51 @@ impl ImportInfo {
1200
1468
  let (kwargs_opt,) = args.optional;
1201
1469
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
1202
1470
  Ok(Self {
1203
- source: kwargs
1204
- .get(ruby.to_symbol("source"))
1205
- .and_then(|v| String::try_convert(v).ok())
1206
- .unwrap_or_default(),
1207
- items: kwargs
1208
- .get(ruby.to_symbol("items"))
1209
- .and_then(|v| <Vec<String>>::try_convert(v).ok())
1210
- .unwrap_or_default(),
1211
- alias: kwargs
1212
- .get(ruby.to_symbol("alias"))
1213
- .and_then(|v| String::try_convert(v).ok()),
1214
- is_wildcard: kwargs
1215
- .get(ruby.to_symbol("is_wildcard"))
1216
- .and_then(|v| bool::try_convert(v).ok())
1217
- .unwrap_or_default(),
1218
- span: kwargs
1219
- .get(ruby.to_symbol("span"))
1220
- .and_then(|v| Span::try_convert(v).ok())
1221
- .unwrap_or_default(),
1471
+ source: match kwargs.get(ruby.to_symbol("source")) {
1472
+ Some(v) => String::try_convert(v).map_err(|e| {
1473
+ magnus::Error::new(
1474
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1475
+ format!("invalid value for `source`: {}", e),
1476
+ )
1477
+ })?,
1478
+ None => Default::default(),
1479
+ },
1480
+ items: match kwargs.get(ruby.to_symbol("items")) {
1481
+ Some(v) => <Vec<String>>::try_convert(v).map_err(|e| {
1482
+ magnus::Error::new(
1483
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1484
+ format!("invalid value for `items`: {}", e),
1485
+ )
1486
+ })?,
1487
+ None => Default::default(),
1488
+ },
1489
+ alias: match kwargs.get(ruby.to_symbol("alias")) {
1490
+ Some(v) => Some(String::try_convert(v).map_err(|e| {
1491
+ magnus::Error::new(
1492
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1493
+ format!("invalid value for `alias`: {}", e),
1494
+ )
1495
+ })?),
1496
+ None => None,
1497
+ },
1498
+ is_wildcard: match kwargs.get(ruby.to_symbol("is_wildcard")) {
1499
+ Some(v) => bool::try_convert(v).map_err(|e| {
1500
+ magnus::Error::new(
1501
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1502
+ format!("invalid value for `is_wildcard`: {}", e),
1503
+ )
1504
+ })?,
1505
+ None => Default::default(),
1506
+ },
1507
+ span: match kwargs.get(ruby.to_symbol("span")) {
1508
+ Some(v) => Span::try_convert(v).map_err(|e| {
1509
+ magnus::Error::new(
1510
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1511
+ format!("invalid value for `span`: {}", e),
1512
+ )
1513
+ })?,
1514
+ None => Default::default(),
1515
+ },
1222
1516
  })
1223
1517
  }
1224
1518
 
@@ -1481,15 +1775,33 @@ impl PackConfig {
1481
1775
  let (kwargs_opt,) = args.optional;
1482
1776
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
1483
1777
  Ok(Self {
1484
- cache_dir: kwargs
1485
- .get(ruby.to_symbol("cache_dir"))
1486
- .and_then(|v| String::try_convert(v).ok()),
1487
- languages: kwargs
1488
- .get(ruby.to_symbol("languages"))
1489
- .and_then(|v| <Vec<String>>::try_convert(v).ok()),
1490
- groups: kwargs
1491
- .get(ruby.to_symbol("groups"))
1492
- .and_then(|v| <Vec<String>>::try_convert(v).ok()),
1778
+ cache_dir: match kwargs.get(ruby.to_symbol("cache_dir")) {
1779
+ Some(v) => Some(String::try_convert(v).map_err(|e| {
1780
+ magnus::Error::new(
1781
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1782
+ format!("invalid value for `cache_dir`: {}", e),
1783
+ )
1784
+ })?),
1785
+ None => None,
1786
+ },
1787
+ languages: match kwargs.get(ruby.to_symbol("languages")) {
1788
+ Some(v) => Some(<Vec<String>>::try_convert(v).map_err(|e| {
1789
+ magnus::Error::new(
1790
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1791
+ format!("invalid value for `languages`: {}", e),
1792
+ )
1793
+ })?),
1794
+ None => None,
1795
+ },
1796
+ groups: match kwargs.get(ruby.to_symbol("groups")) {
1797
+ Some(v) => Some(<Vec<String>>::try_convert(v).map_err(|e| {
1798
+ magnus::Error::new(
1799
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1800
+ format!("invalid value for `groups`: {}", e),
1801
+ )
1802
+ })?),
1803
+ None => None,
1804
+ },
1493
1805
  })
1494
1806
  }
1495
1807
 
@@ -1606,14 +1918,24 @@ impl Point {
1606
1918
  let (kwargs_opt,) = args.optional;
1607
1919
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
1608
1920
  Ok(Self {
1609
- row: kwargs
1610
- .get(ruby.to_symbol("row"))
1611
- .and_then(|v| usize::try_convert(v).ok())
1612
- .unwrap_or_default(),
1613
- column: kwargs
1614
- .get(ruby.to_symbol("column"))
1615
- .and_then(|v| usize::try_convert(v).ok())
1616
- .unwrap_or_default(),
1921
+ row: match kwargs.get(ruby.to_symbol("row")) {
1922
+ Some(v) => usize::try_convert(v).map_err(|e| {
1923
+ magnus::Error::new(
1924
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1925
+ format!("invalid value for `row`: {}", e),
1926
+ )
1927
+ })?,
1928
+ None => Default::default(),
1929
+ },
1930
+ column: match kwargs.get(ruby.to_symbol("column")) {
1931
+ Some(v) => usize::try_convert(v).map_err(|e| {
1932
+ magnus::Error::new(
1933
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1934
+ format!("invalid value for `column`: {}", e),
1935
+ )
1936
+ })?,
1937
+ None => Default::default(),
1938
+ },
1617
1939
  })
1618
1940
  }
1619
1941
 
@@ -1693,51 +2015,114 @@ impl ProcessConfig {
1693
2015
  let (kwargs_opt,) = args.optional;
1694
2016
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
1695
2017
  Ok(Self {
1696
- language: kwargs
1697
- .get(ruby.to_symbol("language"))
1698
- .and_then(|v| String::try_convert(v).ok())
1699
- .unwrap_or("".to_string()),
1700
- structure: kwargs
1701
- .get(ruby.to_symbol("structure"))
1702
- .and_then(|v| bool::try_convert(v).ok())
1703
- .unwrap_or(true),
1704
- imports: kwargs
1705
- .get(ruby.to_symbol("imports"))
1706
- .and_then(|v| bool::try_convert(v).ok())
1707
- .unwrap_or(true),
1708
- exports: kwargs
1709
- .get(ruby.to_symbol("exports"))
1710
- .and_then(|v| bool::try_convert(v).ok())
1711
- .unwrap_or(true),
1712
- comments: kwargs
1713
- .get(ruby.to_symbol("comments"))
1714
- .and_then(|v| bool::try_convert(v).ok())
1715
- .unwrap_or(false),
1716
- docstrings: kwargs
1717
- .get(ruby.to_symbol("docstrings"))
1718
- .and_then(|v| bool::try_convert(v).ok())
1719
- .unwrap_or(false),
1720
- symbols: kwargs
1721
- .get(ruby.to_symbol("symbols"))
1722
- .and_then(|v| bool::try_convert(v).ok())
1723
- .unwrap_or(false),
1724
- diagnostics: kwargs
1725
- .get(ruby.to_symbol("diagnostics"))
1726
- .and_then(|v| bool::try_convert(v).ok())
1727
- .unwrap_or(false),
1728
- chunk_max_size: kwargs
1729
- .get(ruby.to_symbol("chunk_max_size"))
1730
- .and_then(|v| usize::try_convert(v).ok()),
1731
- data_extraction: kwargs
1732
- .get(ruby.to_symbol("data_extraction"))
1733
- .and_then(|v| bool::try_convert(v).ok())
1734
- .unwrap_or(false),
1735
- max_source_bytes: kwargs
1736
- .get(ruby.to_symbol("max_source_bytes"))
1737
- .and_then(|v| usize::try_convert(v).ok()),
1738
- parse_timeout_ms: kwargs
1739
- .get(ruby.to_symbol("parse_timeout_ms"))
1740
- .and_then(|v| u64::try_convert(v).ok()),
2018
+ language: match kwargs.get(ruby.to_symbol("language")) {
2019
+ Some(v) => String::try_convert(v).map_err(|e| {
2020
+ magnus::Error::new(
2021
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2022
+ format!("invalid value for `language`: {}", e),
2023
+ )
2024
+ })?,
2025
+ None => "".to_string(),
2026
+ },
2027
+ structure: match kwargs.get(ruby.to_symbol("structure")) {
2028
+ Some(v) => bool::try_convert(v).map_err(|e| {
2029
+ magnus::Error::new(
2030
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2031
+ format!("invalid value for `structure`: {}", e),
2032
+ )
2033
+ })?,
2034
+ None => true,
2035
+ },
2036
+ imports: match kwargs.get(ruby.to_symbol("imports")) {
2037
+ Some(v) => bool::try_convert(v).map_err(|e| {
2038
+ magnus::Error::new(
2039
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2040
+ format!("invalid value for `imports`: {}", e),
2041
+ )
2042
+ })?,
2043
+ None => true,
2044
+ },
2045
+ exports: match kwargs.get(ruby.to_symbol("exports")) {
2046
+ Some(v) => bool::try_convert(v).map_err(|e| {
2047
+ magnus::Error::new(
2048
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2049
+ format!("invalid value for `exports`: {}", e),
2050
+ )
2051
+ })?,
2052
+ None => true,
2053
+ },
2054
+ comments: match kwargs.get(ruby.to_symbol("comments")) {
2055
+ Some(v) => bool::try_convert(v).map_err(|e| {
2056
+ magnus::Error::new(
2057
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2058
+ format!("invalid value for `comments`: {}", e),
2059
+ )
2060
+ })?,
2061
+ None => false,
2062
+ },
2063
+ docstrings: match kwargs.get(ruby.to_symbol("docstrings")) {
2064
+ Some(v) => bool::try_convert(v).map_err(|e| {
2065
+ magnus::Error::new(
2066
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2067
+ format!("invalid value for `docstrings`: {}", e),
2068
+ )
2069
+ })?,
2070
+ None => false,
2071
+ },
2072
+ symbols: match kwargs.get(ruby.to_symbol("symbols")) {
2073
+ Some(v) => bool::try_convert(v).map_err(|e| {
2074
+ magnus::Error::new(
2075
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2076
+ format!("invalid value for `symbols`: {}", e),
2077
+ )
2078
+ })?,
2079
+ None => false,
2080
+ },
2081
+ diagnostics: match kwargs.get(ruby.to_symbol("diagnostics")) {
2082
+ Some(v) => bool::try_convert(v).map_err(|e| {
2083
+ magnus::Error::new(
2084
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2085
+ format!("invalid value for `diagnostics`: {}", e),
2086
+ )
2087
+ })?,
2088
+ None => false,
2089
+ },
2090
+ chunk_max_size: match kwargs.get(ruby.to_symbol("chunk_max_size")) {
2091
+ Some(v) => Some(usize::try_convert(v).map_err(|e| {
2092
+ magnus::Error::new(
2093
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2094
+ format!("invalid value for `chunk_max_size`: {}", e),
2095
+ )
2096
+ })?),
2097
+ None => None,
2098
+ },
2099
+ data_extraction: match kwargs.get(ruby.to_symbol("data_extraction")) {
2100
+ Some(v) => bool::try_convert(v).map_err(|e| {
2101
+ magnus::Error::new(
2102
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2103
+ format!("invalid value for `data_extraction`: {}", e),
2104
+ )
2105
+ })?,
2106
+ None => false,
2107
+ },
2108
+ max_source_bytes: match kwargs.get(ruby.to_symbol("max_source_bytes")) {
2109
+ Some(v) => Some(usize::try_convert(v).map_err(|e| {
2110
+ magnus::Error::new(
2111
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2112
+ format!("invalid value for `max_source_bytes`: {}", e),
2113
+ )
2114
+ })?),
2115
+ None => None,
2116
+ },
2117
+ parse_timeout_ms: match kwargs.get(ruby.to_symbol("parse_timeout_ms")) {
2118
+ Some(v) => Some(u64::try_convert(v).map_err(|e| {
2119
+ magnus::Error::new(
2120
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2121
+ format!("invalid value for `parse_timeout_ms`: {}", e),
2122
+ )
2123
+ })?),
2124
+ None => None,
2125
+ },
1741
2126
  })
1742
2127
  }
1743
2128
 
@@ -2086,49 +2471,105 @@ impl ProcessResult {
2086
2471
  let (kwargs_opt,) = args.optional;
2087
2472
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
2088
2473
  Ok(Self {
2089
- language: kwargs
2090
- .get(ruby.to_symbol("language"))
2091
- .and_then(|v| String::try_convert(v).ok())
2092
- .unwrap_or_default(),
2093
- metrics: kwargs
2094
- .get(ruby.to_symbol("metrics"))
2095
- .and_then(|v| FileMetrics::try_convert(v).ok())
2096
- .unwrap_or_default(),
2097
- structure: kwargs
2098
- .get(ruby.to_symbol("structure"))
2099
- .and_then(|v| <Vec<StructureItem>>::try_convert(v).ok())
2100
- .unwrap_or_default(),
2101
- imports: kwargs
2102
- .get(ruby.to_symbol("imports"))
2103
- .and_then(|v| <Vec<ImportInfo>>::try_convert(v).ok())
2104
- .unwrap_or_default(),
2105
- exports: kwargs
2106
- .get(ruby.to_symbol("exports"))
2107
- .and_then(|v| <Vec<ExportInfo>>::try_convert(v).ok())
2108
- .unwrap_or_default(),
2109
- comments: kwargs
2110
- .get(ruby.to_symbol("comments"))
2111
- .and_then(|v| <Vec<CommentInfo>>::try_convert(v).ok())
2112
- .unwrap_or_default(),
2113
- docstrings: kwargs
2114
- .get(ruby.to_symbol("docstrings"))
2115
- .and_then(|v| <Vec<DocstringInfo>>::try_convert(v).ok())
2116
- .unwrap_or_default(),
2117
- symbols: kwargs
2118
- .get(ruby.to_symbol("symbols"))
2119
- .and_then(|v| <Vec<SymbolInfo>>::try_convert(v).ok())
2120
- .unwrap_or_default(),
2121
- diagnostics: kwargs
2122
- .get(ruby.to_symbol("diagnostics"))
2123
- .and_then(|v| <Vec<Diagnostic>>::try_convert(v).ok())
2124
- .unwrap_or_default(),
2125
- chunks: kwargs
2126
- .get(ruby.to_symbol("chunks"))
2127
- .and_then(|v| <Vec<CodeChunk>>::try_convert(v).ok())
2128
- .unwrap_or_default(),
2129
- data: kwargs
2130
- .get(ruby.to_symbol("data"))
2131
- .and_then(|v| DataNode::try_convert(v).ok()),
2474
+ language: match kwargs.get(ruby.to_symbol("language")) {
2475
+ Some(v) => String::try_convert(v).map_err(|e| {
2476
+ magnus::Error::new(
2477
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2478
+ format!("invalid value for `language`: {}", e),
2479
+ )
2480
+ })?,
2481
+ None => Default::default(),
2482
+ },
2483
+ metrics: match kwargs.get(ruby.to_symbol("metrics")) {
2484
+ Some(v) => FileMetrics::try_convert(v).map_err(|e| {
2485
+ magnus::Error::new(
2486
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2487
+ format!("invalid value for `metrics`: {}", e),
2488
+ )
2489
+ })?,
2490
+ None => Default::default(),
2491
+ },
2492
+ structure: match kwargs.get(ruby.to_symbol("structure")) {
2493
+ Some(v) => <Vec<StructureItem>>::try_convert(v).map_err(|e| {
2494
+ magnus::Error::new(
2495
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2496
+ format!("invalid value for `structure`: {}", e),
2497
+ )
2498
+ })?,
2499
+ None => Default::default(),
2500
+ },
2501
+ imports: match kwargs.get(ruby.to_symbol("imports")) {
2502
+ Some(v) => <Vec<ImportInfo>>::try_convert(v).map_err(|e| {
2503
+ magnus::Error::new(
2504
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2505
+ format!("invalid value for `imports`: {}", e),
2506
+ )
2507
+ })?,
2508
+ None => Default::default(),
2509
+ },
2510
+ exports: match kwargs.get(ruby.to_symbol("exports")) {
2511
+ Some(v) => <Vec<ExportInfo>>::try_convert(v).map_err(|e| {
2512
+ magnus::Error::new(
2513
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2514
+ format!("invalid value for `exports`: {}", e),
2515
+ )
2516
+ })?,
2517
+ None => Default::default(),
2518
+ },
2519
+ comments: match kwargs.get(ruby.to_symbol("comments")) {
2520
+ Some(v) => <Vec<CommentInfo>>::try_convert(v).map_err(|e| {
2521
+ magnus::Error::new(
2522
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2523
+ format!("invalid value for `comments`: {}", e),
2524
+ )
2525
+ })?,
2526
+ None => Default::default(),
2527
+ },
2528
+ docstrings: match kwargs.get(ruby.to_symbol("docstrings")) {
2529
+ Some(v) => <Vec<DocstringInfo>>::try_convert(v).map_err(|e| {
2530
+ magnus::Error::new(
2531
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2532
+ format!("invalid value for `docstrings`: {}", e),
2533
+ )
2534
+ })?,
2535
+ None => Default::default(),
2536
+ },
2537
+ symbols: match kwargs.get(ruby.to_symbol("symbols")) {
2538
+ Some(v) => <Vec<SymbolInfo>>::try_convert(v).map_err(|e| {
2539
+ magnus::Error::new(
2540
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2541
+ format!("invalid value for `symbols`: {}", e),
2542
+ )
2543
+ })?,
2544
+ None => Default::default(),
2545
+ },
2546
+ diagnostics: match kwargs.get(ruby.to_symbol("diagnostics")) {
2547
+ Some(v) => <Vec<Diagnostic>>::try_convert(v).map_err(|e| {
2548
+ magnus::Error::new(
2549
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2550
+ format!("invalid value for `diagnostics`: {}", e),
2551
+ )
2552
+ })?,
2553
+ None => Default::default(),
2554
+ },
2555
+ chunks: match kwargs.get(ruby.to_symbol("chunks")) {
2556
+ Some(v) => <Vec<CodeChunk>>::try_convert(v).map_err(|e| {
2557
+ magnus::Error::new(
2558
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2559
+ format!("invalid value for `chunks`: {}", e),
2560
+ )
2561
+ })?,
2562
+ None => Default::default(),
2563
+ },
2564
+ data: match kwargs.get(ruby.to_symbol("data")) {
2565
+ Some(v) => Some(DataNode::try_convert(v).map_err(|e| {
2566
+ magnus::Error::new(
2567
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2568
+ format!("invalid value for `data`: {}", e),
2569
+ )
2570
+ })?),
2571
+ None => None,
2572
+ },
2132
2573
  })
2133
2574
  }
2134
2575
 
@@ -2230,30 +2671,60 @@ impl Span {
2230
2671
  let (kwargs_opt,) = args.optional;
2231
2672
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
2232
2673
  Ok(Self {
2233
- start_byte: kwargs
2234
- .get(ruby.to_symbol("start_byte"))
2235
- .and_then(|v| usize::try_convert(v).ok())
2236
- .unwrap_or_default(),
2237
- end_byte: kwargs
2238
- .get(ruby.to_symbol("end_byte"))
2239
- .and_then(|v| usize::try_convert(v).ok())
2240
- .unwrap_or_default(),
2241
- start_line: kwargs
2242
- .get(ruby.to_symbol("start_line"))
2243
- .and_then(|v| usize::try_convert(v).ok())
2244
- .unwrap_or_default(),
2245
- start_column: kwargs
2246
- .get(ruby.to_symbol("start_column"))
2247
- .and_then(|v| usize::try_convert(v).ok())
2248
- .unwrap_or_default(),
2249
- end_line: kwargs
2250
- .get(ruby.to_symbol("end_line"))
2251
- .and_then(|v| usize::try_convert(v).ok())
2252
- .unwrap_or_default(),
2253
- end_column: kwargs
2254
- .get(ruby.to_symbol("end_column"))
2255
- .and_then(|v| usize::try_convert(v).ok())
2256
- .unwrap_or_default(),
2674
+ start_byte: match kwargs.get(ruby.to_symbol("start_byte")) {
2675
+ Some(v) => usize::try_convert(v).map_err(|e| {
2676
+ magnus::Error::new(
2677
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2678
+ format!("invalid value for `start_byte`: {}", e),
2679
+ )
2680
+ })?,
2681
+ None => Default::default(),
2682
+ },
2683
+ end_byte: match kwargs.get(ruby.to_symbol("end_byte")) {
2684
+ Some(v) => usize::try_convert(v).map_err(|e| {
2685
+ magnus::Error::new(
2686
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2687
+ format!("invalid value for `end_byte`: {}", e),
2688
+ )
2689
+ })?,
2690
+ None => Default::default(),
2691
+ },
2692
+ start_line: match kwargs.get(ruby.to_symbol("start_line")) {
2693
+ Some(v) => usize::try_convert(v).map_err(|e| {
2694
+ magnus::Error::new(
2695
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2696
+ format!("invalid value for `start_line`: {}", e),
2697
+ )
2698
+ })?,
2699
+ None => Default::default(),
2700
+ },
2701
+ start_column: match kwargs.get(ruby.to_symbol("start_column")) {
2702
+ Some(v) => usize::try_convert(v).map_err(|e| {
2703
+ magnus::Error::new(
2704
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2705
+ format!("invalid value for `start_column`: {}", e),
2706
+ )
2707
+ })?,
2708
+ None => Default::default(),
2709
+ },
2710
+ end_line: match kwargs.get(ruby.to_symbol("end_line")) {
2711
+ Some(v) => usize::try_convert(v).map_err(|e| {
2712
+ magnus::Error::new(
2713
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2714
+ format!("invalid value for `end_line`: {}", e),
2715
+ )
2716
+ })?,
2717
+ None => Default::default(),
2718
+ },
2719
+ end_column: match kwargs.get(ruby.to_symbol("end_column")) {
2720
+ Some(v) => usize::try_convert(v).map_err(|e| {
2721
+ magnus::Error::new(
2722
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2723
+ format!("invalid value for `end_column`: {}", e),
2724
+ )
2725
+ })?,
2726
+ None => Default::default(),
2727
+ },
2257
2728
  })
2258
2729
  }
2259
2730
 
@@ -2346,37 +2817,87 @@ impl StructureItem {
2346
2817
  let (kwargs_opt,) = args.optional;
2347
2818
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
2348
2819
  Ok(Self {
2349
- kind: kwargs
2350
- .get(ruby.to_symbol("kind"))
2351
- .and_then(|v| StructureKind::try_convert(v).ok())
2352
- .unwrap_or(StructureKind::Function),
2353
- name: kwargs
2354
- .get(ruby.to_symbol("name"))
2355
- .and_then(|v| String::try_convert(v).ok()),
2356
- visibility: kwargs
2357
- .get(ruby.to_symbol("visibility"))
2358
- .and_then(|v| String::try_convert(v).ok()),
2359
- span: kwargs
2360
- .get(ruby.to_symbol("span"))
2361
- .and_then(|v| Span::try_convert(v).ok())
2362
- .unwrap_or_default(),
2363
- children: kwargs
2364
- .get(ruby.to_symbol("children"))
2365
- .and_then(|v| <Vec<StructureItem>>::try_convert(v).ok())
2366
- .unwrap_or_default(),
2367
- decorators: kwargs
2368
- .get(ruby.to_symbol("decorators"))
2369
- .and_then(|v| <Vec<String>>::try_convert(v).ok())
2370
- .unwrap_or_default(),
2371
- doc_comment: kwargs
2372
- .get(ruby.to_symbol("doc_comment"))
2373
- .and_then(|v| String::try_convert(v).ok()),
2374
- signature: kwargs
2375
- .get(ruby.to_symbol("signature"))
2376
- .and_then(|v| String::try_convert(v).ok()),
2377
- body_span: kwargs
2378
- .get(ruby.to_symbol("body_span"))
2379
- .and_then(|v| Span::try_convert(v).ok()),
2820
+ kind: match kwargs.get(ruby.to_symbol("kind")) {
2821
+ Some(v) => StructureKind::try_convert(v).map_err(|e| {
2822
+ magnus::Error::new(
2823
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2824
+ format!("invalid value for `kind`: {}", e),
2825
+ )
2826
+ })?,
2827
+ None => StructureKind::Function,
2828
+ },
2829
+ name: match kwargs.get(ruby.to_symbol("name")) {
2830
+ Some(v) => Some(String::try_convert(v).map_err(|e| {
2831
+ magnus::Error::new(
2832
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2833
+ format!("invalid value for `name`: {}", e),
2834
+ )
2835
+ })?),
2836
+ None => None,
2837
+ },
2838
+ visibility: match kwargs.get(ruby.to_symbol("visibility")) {
2839
+ Some(v) => Some(String::try_convert(v).map_err(|e| {
2840
+ magnus::Error::new(
2841
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2842
+ format!("invalid value for `visibility`: {}", e),
2843
+ )
2844
+ })?),
2845
+ None => None,
2846
+ },
2847
+ span: match kwargs.get(ruby.to_symbol("span")) {
2848
+ Some(v) => Span::try_convert(v).map_err(|e| {
2849
+ magnus::Error::new(
2850
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2851
+ format!("invalid value for `span`: {}", e),
2852
+ )
2853
+ })?,
2854
+ None => Default::default(),
2855
+ },
2856
+ children: match kwargs.get(ruby.to_symbol("children")) {
2857
+ Some(v) => <Vec<StructureItem>>::try_convert(v).map_err(|e| {
2858
+ magnus::Error::new(
2859
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2860
+ format!("invalid value for `children`: {}", e),
2861
+ )
2862
+ })?,
2863
+ None => Default::default(),
2864
+ },
2865
+ decorators: match kwargs.get(ruby.to_symbol("decorators")) {
2866
+ Some(v) => <Vec<String>>::try_convert(v).map_err(|e| {
2867
+ magnus::Error::new(
2868
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2869
+ format!("invalid value for `decorators`: {}", e),
2870
+ )
2871
+ })?,
2872
+ None => Default::default(),
2873
+ },
2874
+ doc_comment: match kwargs.get(ruby.to_symbol("doc_comment")) {
2875
+ Some(v) => Some(String::try_convert(v).map_err(|e| {
2876
+ magnus::Error::new(
2877
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2878
+ format!("invalid value for `doc_comment`: {}", e),
2879
+ )
2880
+ })?),
2881
+ None => None,
2882
+ },
2883
+ signature: match kwargs.get(ruby.to_symbol("signature")) {
2884
+ Some(v) => Some(String::try_convert(v).map_err(|e| {
2885
+ magnus::Error::new(
2886
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2887
+ format!("invalid value for `signature`: {}", e),
2888
+ )
2889
+ })?),
2890
+ None => None,
2891
+ },
2892
+ body_span: match kwargs.get(ruby.to_symbol("body_span")) {
2893
+ Some(v) => Some(Span::try_convert(v).map_err(|e| {
2894
+ magnus::Error::new(
2895
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
2896
+ format!("invalid value for `body_span`: {}", e),
2897
+ )
2898
+ })?),
2899
+ None => None,
2900
+ },
2380
2901
  })
2381
2902
  }
2382
2903
 
@@ -2477,24 +2998,51 @@ impl SymbolInfo {
2477
2998
  let (kwargs_opt,) = args.optional;
2478
2999
  let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
2479
3000
  Ok(Self {
2480
- name: kwargs
2481
- .get(ruby.to_symbol("name"))
2482
- .and_then(|v| String::try_convert(v).ok())
2483
- .unwrap_or_default(),
2484
- kind: kwargs
2485
- .get(ruby.to_symbol("kind"))
2486
- .and_then(|v| SymbolKind::try_convert(v).ok())
2487
- .unwrap_or(SymbolKind::Variable),
2488
- span: kwargs
2489
- .get(ruby.to_symbol("span"))
2490
- .and_then(|v| Span::try_convert(v).ok())
2491
- .unwrap_or_default(),
2492
- type_annotation: kwargs
2493
- .get(ruby.to_symbol("type_annotation"))
2494
- .and_then(|v| String::try_convert(v).ok()),
2495
- doc: kwargs
2496
- .get(ruby.to_symbol("doc"))
2497
- .and_then(|v| String::try_convert(v).ok()),
3001
+ name: match kwargs.get(ruby.to_symbol("name")) {
3002
+ Some(v) => String::try_convert(v).map_err(|e| {
3003
+ magnus::Error::new(
3004
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
3005
+ format!("invalid value for `name`: {}", e),
3006
+ )
3007
+ })?,
3008
+ None => Default::default(),
3009
+ },
3010
+ kind: match kwargs.get(ruby.to_symbol("kind")) {
3011
+ Some(v) => SymbolKind::try_convert(v).map_err(|e| {
3012
+ magnus::Error::new(
3013
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
3014
+ format!("invalid value for `kind`: {}", e),
3015
+ )
3016
+ })?,
3017
+ None => SymbolKind::Variable,
3018
+ },
3019
+ span: match kwargs.get(ruby.to_symbol("span")) {
3020
+ Some(v) => Span::try_convert(v).map_err(|e| {
3021
+ magnus::Error::new(
3022
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
3023
+ format!("invalid value for `span`: {}", e),
3024
+ )
3025
+ })?,
3026
+ None => Default::default(),
3027
+ },
3028
+ type_annotation: match kwargs.get(ruby.to_symbol("type_annotation")) {
3029
+ Some(v) => Some(String::try_convert(v).map_err(|e| {
3030
+ magnus::Error::new(
3031
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
3032
+ format!("invalid value for `type_annotation`: {}", e),
3033
+ )
3034
+ })?),
3035
+ None => None,
3036
+ },
3037
+ doc: match kwargs.get(ruby.to_symbol("doc")) {
3038
+ Some(v) => Some(String::try_convert(v).map_err(|e| {
3039
+ magnus::Error::new(
3040
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
3041
+ format!("invalid value for `doc`: {}", e),
3042
+ )
3043
+ })?),
3044
+ None => None,
3045
+ },
2498
3046
  })
2499
3047
  }
2500
3048
 
@@ -4054,13 +4602,16 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
4054
4602
 
4055
4603
  let class = module.define_class("DownloadManager", ruby.class_object())?;
4056
4604
 
4605
+ #[cfg(feature = "download")]
4057
4606
  class.define_method("installed_languages", method!(DownloadManager::installed_languages, 0))?;
4058
4607
 
4608
+ #[cfg(feature = "download")]
4059
4609
  class.define_method(
4060
4610
  "download_all_best_effort",
4061
4611
  method!(DownloadManager::download_all_best_effort, 0),
4062
4612
  )?;
4063
4613
 
4614
+ #[cfg(feature = "download")]
4064
4615
  class.define_method("clean_cache", method!(DownloadManager::clean_cache, 0))?;
4065
4616
 
4066
4617
  let class = module.define_class("ExportInfo", ruby.class_object())?;