1use std::collections::HashMap;
2
3use tree_sitter::Language;
4
5use crate::parser::graph::EntityInfo;
6
7pub struct SuppressedNestedEntity {
8 pub parent_entity_node_type: &'static str,
9 pub child_entity_node_type: &'static str,
10}
11
12#[allow(dead_code)]
13pub struct LanguageConfig {
14 pub id: &'static str,
15 pub extensions: &'static [&'static str],
16 pub entity_node_types: &'static [&'static str],
17 pub container_node_types: &'static [&'static str],
18 pub call_entity_identifiers: &'static [&'static str],
19 pub suppressed_nested_entities: &'static [SuppressedNestedEntity],
20 pub scope_boundary_types: &'static [&'static str],
24 pub get_language: fn() -> Option<Language>,
25 pub scope_resolve: Option<&'static ScopeResolveConfig>,
26}
27
28pub struct ScopeResolveConfig {
33 pub class_scope_nodes: &'static [&'static str],
35 pub impl_scope_nodes: &'static [&'static str],
37 pub function_scope_nodes: &'static [&'static str],
39 pub class_name_field: ClassNameField,
41
42 pub assignment_rules: &'static [AssignmentRule],
44 pub assignment_recurse_into: &'static [&'static str],
46
47 pub param_rules: &'static [ParamRule],
49
50 pub return_type_field: Option<&'static str>,
52
53 pub call_nodes: &'static [&'static str],
55 pub call_style: CallNodeStyle,
58 pub new_expr_nodes: &'static [&'static str],
60 pub new_expr_type_field: &'static str,
62 pub composite_literal_nodes: &'static [&'static str],
64 pub member_access: &'static [MemberAccess],
66 pub scoped_call_nodes: &'static [&'static str],
68
69 pub self_keywords: &'static [&'static str],
71
72 pub init_strategy: InitStrategy,
74
75 pub import_extractor: Option<ImportExtractorFn>,
77
78 pub external_method: bool,
80
81 pub builtins: &'static [&'static str],
83}
84
85pub enum CallNodeStyle {
87 FunctionField(&'static str),
90 DirectMethod { object_field: &'static str, method_field: &'static str },
93}
94
95pub enum ClassNameField {
97 Simple(&'static str),
99 TypeSpec { spec_kind: &'static str, field: &'static str },
101 ImplType(&'static str),
103}
104
105pub struct AssignmentRule {
107 pub node_kind: &'static str,
108 pub strategy: AssignmentStrategy,
109}
110
111pub enum AssignmentStrategy {
113 LeftRight,
115 Declarators,
117 PatternBased,
119 ShortVar,
121 VarSpec,
123}
124
125pub struct ParamRule {
127 pub node_kind: &'static str,
128 pub name_field: ParamNameField,
129 pub type_field: &'static str,
130 pub skip_names: &'static [&'static str],
131}
132
133pub enum ParamNameField {
135 Simple(&'static str),
137 WithFallback(&'static str),
139 RustPattern,
141}
142
143pub struct MemberAccess {
145 pub node_kind: &'static str,
146 pub object_field: &'static str,
147 pub property_field: &'static str,
148}
149
150pub enum InitStrategy {
152 ConstructorBody {
154 class_nodes: &'static [&'static str],
155 init_names: &'static [&'static str],
156 init_node_kind: &'static str,
157 self_keyword: &'static str,
158 access_kind: &'static str,
159 obj_field: &'static str,
160 prop_field: &'static str,
161 },
162 StructFields {
164 struct_nodes: &'static [&'static str],
165 },
166 None,
168}
169
170pub type ImportExtractorFn = fn(
172 node: tree_sitter::Node,
173 file_path: &str,
174 source: &[u8],
175 symbol_table: &HashMap<String, Vec<String>>,
176 entity_map: &HashMap<String, EntityInfo>,
177 import_table: &mut HashMap<(String, String), String>,
178 scopes: &mut Vec<crate::parser::scope_resolve::Scope>,
179);
180
181pub struct ImportRule {
183 pub node_kind: &'static str,
184 pub extractor: ImportExtractorFn,
185}
186
187fn get_typescript() -> Option<Language> {
188 Some(tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into())
189}
190
191fn get_tsx() -> Option<Language> {
192 Some(tree_sitter_typescript::LANGUAGE_TSX.into())
193}
194
195fn get_javascript() -> Option<Language> {
196 Some(tree_sitter_javascript::LANGUAGE.into())
197}
198
199fn get_python() -> Option<Language> {
200 Some(tree_sitter_python::LANGUAGE.into())
201}
202
203fn get_go() -> Option<Language> {
204 Some(tree_sitter_go::LANGUAGE.into())
205}
206
207fn get_rust() -> Option<Language> {
208 Some(tree_sitter_rust::LANGUAGE.into())
209}
210
211fn get_java() -> Option<Language> {
212 Some(tree_sitter_java::LANGUAGE.into())
213}
214
215fn get_c() -> Option<Language> {
216 Some(tree_sitter_c::LANGUAGE.into())
217}
218
219fn get_cpp() -> Option<Language> {
220 Some(tree_sitter_cpp::LANGUAGE.into())
221}
222
223fn get_ruby() -> Option<Language> {
224 Some(tree_sitter_ruby::LANGUAGE.into())
225}
226
227fn get_csharp() -> Option<Language> {
228 Some(tree_sitter_c_sharp::LANGUAGE.into())
229}
230
231fn get_php() -> Option<Language> {
232 Some(tree_sitter_php::LANGUAGE_PHP.into())
233}
234
235fn get_fortran() -> Option<Language> {
236 Some(tree_sitter_fortran::LANGUAGE.into())
237}
238
239fn get_swift() -> Option<Language> {
240 Some(tree_sitter_swift::LANGUAGE.into())
241}
242
243fn get_elixir() -> Option<Language> {
244 Some(tree_sitter_elixir::LANGUAGE.into())
245}
246
247fn get_bash() -> Option<Language> {
248 Some(tree_sitter_bash::LANGUAGE.into())
249}
250
251fn get_hcl() -> Option<Language> {
252 Some(tree_sitter_hcl::LANGUAGE.into())
253}
254
255fn get_kotlin() -> Option<Language> {
256 Some(tree_sitter_kotlin_ng::LANGUAGE.into())
257}
258
259fn get_xml() -> Option<Language> {
260 Some(tree_sitter_xml::LANGUAGE_XML.into())
261}
262
263fn get_dart() -> Option<Language> {
264 Some(tree_sitter_dart::LANGUAGE.into())
265}
266
267fn get_perl() -> Option<Language> {
268 Some(tree_sitter_perl_next::LANGUAGE.into())
269}
270
271fn get_ocaml() -> Option<Language> {
272 Some(tree_sitter_ocaml::LANGUAGE_OCAML.into())
273}
274
275fn get_ocaml_interface() -> Option<Language> {
276 Some(tree_sitter_ocaml::LANGUAGE_OCAML_INTERFACE.into())
277}
278
279fn get_scala() -> Option<Language> {
280 Some(tree_sitter_scala::LANGUAGE.into())
281}
282
283fn get_zig() -> Option<Language> {
284 Some(tree_sitter_zig::LANGUAGE.into())
285}
286
287fn get_nix() -> Option<Language> {
288 Some(tree_sitter_nix::LANGUAGE.into())
289}
290
291const JS_TS_SUPPRESSED_NESTED: &[SuppressedNestedEntity] = &[
295 SuppressedNestedEntity {
296 parent_entity_node_type: "function_declaration",
297 child_entity_node_type: "lexical_declaration",
298 },
299 SuppressedNestedEntity {
300 parent_entity_node_type: "function_declaration",
301 child_entity_node_type: "variable_declaration",
302 },
303 SuppressedNestedEntity {
304 parent_entity_node_type: "generator_function_declaration",
305 child_entity_node_type: "lexical_declaration",
306 },
307 SuppressedNestedEntity {
308 parent_entity_node_type: "generator_function_declaration",
309 child_entity_node_type: "variable_declaration",
310 },
311 SuppressedNestedEntity {
312 parent_entity_node_type: "method_definition",
313 child_entity_node_type: "lexical_declaration",
314 },
315 SuppressedNestedEntity {
316 parent_entity_node_type: "method_definition",
317 child_entity_node_type: "variable_declaration",
318 },
319 SuppressedNestedEntity {
323 parent_entity_node_type: "arrow_function",
324 child_entity_node_type: "lexical_declaration",
325 },
326 SuppressedNestedEntity {
327 parent_entity_node_type: "arrow_function",
328 child_entity_node_type: "variable_declaration",
329 },
330 SuppressedNestedEntity {
331 parent_entity_node_type: "function_expression",
332 child_entity_node_type: "lexical_declaration",
333 },
334 SuppressedNestedEntity {
335 parent_entity_node_type: "function_expression",
336 child_entity_node_type: "variable_declaration",
337 },
338 SuppressedNestedEntity {
339 parent_entity_node_type: "generator_function",
340 child_entity_node_type: "lexical_declaration",
341 },
342 SuppressedNestedEntity {
343 parent_entity_node_type: "generator_function",
344 child_entity_node_type: "variable_declaration",
345 },
346];
347
348const JS_TS_SCOPE_BOUNDARIES: &[&str] = &[
349 "arrow_function",
350 "function_expression",
351 "generator_function",
352];
353
354static TYPESCRIPT_CONFIG: LanguageConfig = LanguageConfig {
355 id: "typescript",
356 extensions: &[".ts", ".mts", ".cts"],
357 entity_node_types: &[
358 "function_declaration",
359 "generator_function_declaration",
360 "class_declaration",
361 "interface_declaration",
362 "type_alias_declaration",
363 "enum_declaration",
364 "export_statement",
365 "lexical_declaration",
366 "variable_declaration",
367 "method_definition",
368 "public_field_definition",
369 ],
370 container_node_types: &["class_body", "interface_body", "enum_body", "statement_block"],
371 call_entity_identifiers: &[],
372 suppressed_nested_entities: JS_TS_SUPPRESSED_NESTED,
373 scope_boundary_types: JS_TS_SCOPE_BOUNDARIES,
374 get_language: get_typescript,
375 scope_resolve: Some(&TS_SCOPE_CONFIG),
376};
377
378static TSX_CONFIG: LanguageConfig = LanguageConfig {
379 id: "tsx",
380 extensions: &[".tsx"],
381 entity_node_types: &[
382 "function_declaration",
383 "generator_function_declaration",
384 "class_declaration",
385 "interface_declaration",
386 "type_alias_declaration",
387 "enum_declaration",
388 "export_statement",
389 "lexical_declaration",
390 "variable_declaration",
391 "method_definition",
392 "public_field_definition",
393 ],
394 container_node_types: &["class_body", "interface_body", "enum_body", "statement_block"],
395 call_entity_identifiers: &[],
396 suppressed_nested_entities: JS_TS_SUPPRESSED_NESTED,
397 scope_boundary_types: JS_TS_SCOPE_BOUNDARIES,
398 get_language: get_tsx,
399 scope_resolve: Some(&TS_SCOPE_CONFIG),
400};
401
402static JAVASCRIPT_CONFIG: LanguageConfig = LanguageConfig {
403 id: "javascript",
404 extensions: &[".js", ".jsx", ".mjs", ".cjs", ".es6"],
405 entity_node_types: &[
406 "function_declaration",
407 "generator_function_declaration",
408 "class_declaration",
409 "export_statement",
410 "lexical_declaration",
411 "variable_declaration",
412 "method_definition",
413 "field_definition",
414 ],
415 container_node_types: &["class_body", "statement_block"],
416 call_entity_identifiers: &[],
417 suppressed_nested_entities: JS_TS_SUPPRESSED_NESTED,
418 scope_boundary_types: JS_TS_SCOPE_BOUNDARIES,
419 get_language: get_javascript,
420 scope_resolve: Some(&TS_SCOPE_CONFIG),
421};
422
423static PYTHON_CONFIG: LanguageConfig = LanguageConfig {
424 id: "python",
425 extensions: &[".py", ".pyi"],
426 entity_node_types: &[
427 "function_definition",
428 "class_definition",
429 "decorated_definition",
430 ],
431 container_node_types: &["block"],
432 call_entity_identifiers: &[],
433 suppressed_nested_entities: &[],
434 scope_boundary_types: &[],
435 get_language: get_python,
436 scope_resolve: Some(&PYTHON_SCOPE_CONFIG),
437};
438
439static GO_CONFIG: LanguageConfig = LanguageConfig {
440 id: "go",
441 extensions: &[".go"],
442 entity_node_types: &[
443 "function_declaration",
444 "method_declaration",
445 "type_declaration",
446 "var_declaration",
447 "const_declaration",
448 ],
449 container_node_types: &["block"],
450 call_entity_identifiers: &[],
451 suppressed_nested_entities: &[],
452 scope_boundary_types: &[],
453 get_language: get_go,
454 scope_resolve: Some(&GO_SCOPE_CONFIG),
455};
456
457static RUST_CONFIG: LanguageConfig = LanguageConfig {
458 id: "rust",
459 extensions: &[".rs"],
460 entity_node_types: &[
461 "function_item",
462 "struct_item",
463 "enum_item",
464 "impl_item",
465 "trait_item",
466 "mod_item",
467 "const_item",
468 "static_item",
469 "type_item",
470 "macro_definition",
471 ],
472 container_node_types: &["declaration_list", "block"],
473 call_entity_identifiers: &[],
474 suppressed_nested_entities: &[],
475 scope_boundary_types: &[],
476 get_language: get_rust,
477 scope_resolve: Some(&RUST_SCOPE_CONFIG),
478};
479
480static JAVA_CONFIG: LanguageConfig = LanguageConfig {
481 id: "java",
482 extensions: &[".java"],
483 entity_node_types: &[
484 "class_declaration",
485 "method_declaration",
486 "interface_declaration",
487 "enum_declaration",
488 "field_declaration",
489 "constructor_declaration",
490 "annotation_type_declaration",
491 ],
492 container_node_types: &["class_body", "interface_body", "enum_body", "block"],
493 call_entity_identifiers: &[],
494 suppressed_nested_entities: &[],
495 scope_boundary_types: &[],
496 get_language: get_java,
497 scope_resolve: Some(&JAVA_SCOPE_CONFIG),
498};
499
500static C_CONFIG: LanguageConfig = LanguageConfig {
501 id: "c",
502 extensions: &[".c", ".h"],
503 entity_node_types: &[
504 "function_definition",
505 "struct_specifier",
506 "enum_specifier",
507 "union_specifier",
508 "type_definition",
509 "declaration",
510 ],
511 container_node_types: &["compound_statement"],
512 call_entity_identifiers: &[],
513 suppressed_nested_entities: &[],
514 scope_boundary_types: &[],
515 get_language: get_c,
516 scope_resolve: None,
517};
518
519static CPP_CONFIG: LanguageConfig = LanguageConfig {
520 id: "cpp",
521 extensions: &[".cpp", ".cc", ".cxx", ".hpp", ".hh", ".hxx"],
522 entity_node_types: &[
523 "function_definition",
524 "class_specifier",
525 "struct_specifier",
526 "enum_specifier",
527 "namespace_definition",
528 "template_declaration",
529 "declaration",
530 "type_definition",
531 ],
532 container_node_types: &["field_declaration_list", "declaration_list", "compound_statement"],
533 call_entity_identifiers: &[],
534 suppressed_nested_entities: &[],
535 scope_boundary_types: &[],
536 get_language: get_cpp,
537 scope_resolve: Some(&CPP_SCOPE_CONFIG),
538};
539
540static RUBY_CONFIG: LanguageConfig = LanguageConfig {
541 id: "ruby",
542 extensions: &[".rb"],
543 entity_node_types: &[
544 "method",
545 "singleton_method",
546 "class",
547 "module",
548 ],
549 container_node_types: &["body_statement"],
550 call_entity_identifiers: &[],
551 suppressed_nested_entities: &[],
552 scope_boundary_types: &[],
553 get_language: get_ruby,
554 scope_resolve: Some(&RUBY_SCOPE_CONFIG),
555};
556
557static CSHARP_CONFIG: LanguageConfig = LanguageConfig {
558 id: "csharp",
559 extensions: &[".cs"],
560 entity_node_types: &[
561 "method_declaration",
562 "class_declaration",
563 "interface_declaration",
564 "enum_declaration",
565 "struct_declaration",
566 "namespace_declaration",
567 "property_declaration",
568 "constructor_declaration",
569 "field_declaration",
570 ],
571 container_node_types: &["declaration_list", "block"],
572 call_entity_identifiers: &[],
573 suppressed_nested_entities: &[],
574 scope_boundary_types: &[],
575 get_language: get_csharp,
576 scope_resolve: Some(&CSHARP_SCOPE_CONFIG),
577};
578
579static PHP_CONFIG: LanguageConfig = LanguageConfig {
580 id: "php",
581 extensions: &[".php", ".inc", ".phtml", ".module"],
582 entity_node_types: &[
583 "function_definition",
584 "class_declaration",
585 "method_declaration",
586 "interface_declaration",
587 "trait_declaration",
588 "enum_declaration",
589 "namespace_definition",
590 ],
591 container_node_types: &["declaration_list", "enum_declaration_list", "compound_statement"],
592 call_entity_identifiers: &[],
593 suppressed_nested_entities: &[],
594 scope_boundary_types: &[],
595 get_language: get_php,
596 scope_resolve: Some(&PHP_SCOPE_CONFIG),
597};
598
599static FORTRAN_CONFIG: LanguageConfig = LanguageConfig {
600 id: "fortran",
601 extensions: &[".f90", ".f95", ".f03", ".f08", ".f", ".for"],
602 entity_node_types: &[
603 "function",
604 "subroutine",
605 "module",
606 "program",
607 "interface",
608 "type_declaration",
609 ],
610 container_node_types: &["module", "program", "internal_procedures"],
611 call_entity_identifiers: &[],
612 suppressed_nested_entities: &[],
613 scope_boundary_types: &[],
614 get_language: get_fortran,
615 scope_resolve: None,
616};
617
618static SWIFT_CONFIG: LanguageConfig = LanguageConfig {
619 id: "swift",
620 extensions: &[".swift"],
621 entity_node_types: &[
622 "function_declaration",
623 "class_declaration",
624 "protocol_declaration",
625 "init_declaration",
626 "deinit_declaration",
627 "subscript_declaration",
628 "typealias_declaration",
629 "property_declaration",
630 "operator_declaration",
631 "associatedtype_declaration",
632 ],
633 container_node_types: &["class_body", "protocol_body", "enum_class_body", "function_body"],
634 call_entity_identifiers: &[],
635 suppressed_nested_entities: &[],
636 scope_boundary_types: &[],
637 get_language: get_swift,
638 scope_resolve: Some(&SWIFT_SCOPE_CONFIG),
639};
640
641static ELIXIR_CONFIG: LanguageConfig = LanguageConfig {
642 id: "elixir",
643 extensions: &[".ex", ".exs"],
644 entity_node_types: &[],
645 container_node_types: &["do_block"],
646 call_entity_identifiers: &[
647 "defmodule", "def", "defp", "defmacro", "defmacrop",
648 "defguard", "defguardp", "defprotocol", "defimpl",
649 "defstruct", "defexception", "defdelegate",
650 ],
651 suppressed_nested_entities: &[],
652 scope_boundary_types: &[],
653 get_language: get_elixir,
654 scope_resolve: None,
655};
656
657static BASH_CONFIG: LanguageConfig = LanguageConfig {
658 id: "bash",
659 extensions: &[".sh"],
660 entity_node_types: &["function_definition"],
661 container_node_types: &["compound_statement"],
662 call_entity_identifiers: &[],
663 suppressed_nested_entities: &[],
664 scope_boundary_types: &[],
665 get_language: get_bash,
666 scope_resolve: Some(&BASH_SCOPE_CONFIG),
667};
668
669static HCL_CONFIG: LanguageConfig = LanguageConfig {
670 id: "hcl",
671 extensions: &[".hcl", ".tf", ".tfvars"],
672 entity_node_types: &["block", "attribute"],
673 container_node_types: &["body"],
674 call_entity_identifiers: &[],
675 suppressed_nested_entities: &[SuppressedNestedEntity {
676 parent_entity_node_type: "block",
677 child_entity_node_type: "attribute",
678 }],
679 scope_boundary_types: &[],
680 get_language: get_hcl,
681 scope_resolve: None,
682};
683
684static KOTLIN_CONFIG: LanguageConfig = LanguageConfig {
685 id: "kotlin",
686 extensions: &[".kt", ".kts"],
687 entity_node_types: &[
688 "function_declaration",
689 "class_declaration",
690 "object_declaration",
691 "property_declaration",
692 "companion_object",
693 "secondary_constructor",
694 "type_alias",
695 ],
696 container_node_types: &["class_body", "enum_class_body"],
697 call_entity_identifiers: &[],
698 suppressed_nested_entities: &[],
699 scope_boundary_types: &[],
700 get_language: get_kotlin,
701 scope_resolve: Some(&KOTLIN_SCOPE_CONFIG),
702};
703
704static XML_CONFIG: LanguageConfig = LanguageConfig {
705 id: "xml",
706 extensions: &[".xml", ".plist", ".svg", ".xhtml", ".csproj", ".fsproj", ".vbproj", ".props", ".targets", ".nuspec", ".resx", ".xaml", ".axml"],
707 entity_node_types: &["element"],
708 container_node_types: &["content"],
709 call_entity_identifiers: &[],
710 suppressed_nested_entities: &[],
711 scope_boundary_types: &[],
712 get_language: get_xml,
713 scope_resolve: None,
714};
715
716static DART_CONFIG: LanguageConfig = LanguageConfig {
717 id: "dart",
718 extensions: &[".dart"],
719 entity_node_types: &[
720 "class_declaration",
721 "mixin_declaration",
722 "extension_declaration",
723 "extension_type_declaration",
724 "enum_declaration",
725 "type_alias",
726 "class_member",
727 "function_signature",
728 "getter_signature",
729 "setter_signature",
730 ],
731 container_node_types: &["class_body", "enum_body", "extension_body"],
732 call_entity_identifiers: &[],
733 suppressed_nested_entities: &[],
734 scope_boundary_types: &[],
735 get_language: get_dart,
736 scope_resolve: Some(&DART_SCOPE_CONFIG),
737};
738
739static PERL_CONFIG: LanguageConfig = LanguageConfig {
740 id: "perl",
741 extensions: &[".pl", ".pm", ".t"],
742 entity_node_types: &[
743 "subroutine_declaration_statement",
744 "package_statement",
745 ],
746 container_node_types: &["block"],
747 call_entity_identifiers: &[],
748 suppressed_nested_entities: &[],
749 scope_boundary_types: &[],
750 get_language: get_perl,
751 scope_resolve: None,
752};
753
754static OCAML_CONFIG: LanguageConfig = LanguageConfig {
755 id: "ocaml",
756 extensions: &[".ml"],
757 entity_node_types: &[
758 "value_definition",
759 "module_definition",
760 "module_type_definition",
761 "type_definition",
762 "exception_definition",
763 "class_definition",
764 "class_type_definition",
765 "external",
766 ],
767 container_node_types: &["structure", "module_binding"],
768 call_entity_identifiers: &[],
769 suppressed_nested_entities: &[],
770 scope_boundary_types: &[],
771 get_language: get_ocaml,
772 scope_resolve: None,
773};
774
775static OCAML_INTERFACE_CONFIG: LanguageConfig = LanguageConfig {
776 id: "ocaml_interface",
777 extensions: &[".mli"],
778 entity_node_types: &[
779 "value_specification",
780 "module_definition",
781 "module_type_definition",
782 "type_definition",
783 "exception_definition",
784 "class_definition",
785 "class_type_definition",
786 "external",
787 ],
788 container_node_types: &["signature", "module_binding"],
789 call_entity_identifiers: &[],
790 suppressed_nested_entities: &[],
791 scope_boundary_types: &[],
792 get_language: get_ocaml_interface,
793 scope_resolve: None,
794};
795
796static SCALA_CONFIG: LanguageConfig = LanguageConfig {
797 id: "scala",
798 extensions: &[".scala", ".sc", ".sbt", ".kojo", ".mill"],
799 entity_node_types: &[
800 "class_definition",
801 "object_definition",
802 "trait_definition",
803 "enum_definition",
804 "function_definition",
805 "function_declaration",
806 "val_definition",
807 "given_definition",
808 "extension_definition",
809 "type_definition",
810 "package_object",
811 ],
812 container_node_types: &["template_body", "enum_body", "with_template_body"],
813 call_entity_identifiers: &[],
814 suppressed_nested_entities: &[],
815 scope_boundary_types: &[],
816 get_language: get_scala,
817 scope_resolve: Some(&SCALA_SCOPE_CONFIG),
818};
819
820static ZIG_CONFIG: LanguageConfig = LanguageConfig {
821 id: "zig",
822 extensions: &[".zig"],
823 entity_node_types: &[
824 "function_declaration",
825 "test_declaration",
826 "variable_declaration",
827 ],
828 container_node_types: &["block"],
829 call_entity_identifiers: &[],
830 suppressed_nested_entities: &[
831 SuppressedNestedEntity {
832 parent_entity_node_type: "function_declaration",
833 child_entity_node_type: "variable_declaration",
834 },
835 ],
836 scope_boundary_types: &[],
837 get_language: get_zig,
838 scope_resolve: Some(&ZIG_SCOPE_CONFIG),
839};
840
841static NIX_CONFIG: LanguageConfig = LanguageConfig {
842 id: "nix",
843 extensions: &[".nix"],
844 entity_node_types: &["binding", "inherit", "inherit_from"],
845 container_node_types: &["binding_set"],
846 call_entity_identifiers: &[],
847 suppressed_nested_entities: &[],
848 scope_boundary_types: &[],
849 get_language: get_nix,
850 scope_resolve: None,
851};
852
853static PYTHON_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
856 class_scope_nodes: &["class_definition"],
857 impl_scope_nodes: &[],
858 function_scope_nodes: &["function_definition"],
859 class_name_field: ClassNameField::Simple("name"),
860
861 assignment_rules: &[
862 AssignmentRule { node_kind: "assignment", strategy: AssignmentStrategy::LeftRight },
863 AssignmentRule { node_kind: "expression_statement", strategy: AssignmentStrategy::LeftRight },
864 ],
865 assignment_recurse_into: &["block"],
866
867 param_rules: &[
868 ParamRule { node_kind: "typed_parameter", name_field: ParamNameField::WithFallback("name"), type_field: "type", skip_names: &["self", "cls"] },
869 ParamRule { node_kind: "typed_default_parameter", name_field: ParamNameField::WithFallback("name"), type_field: "type", skip_names: &["self", "cls"] },
870 ],
871
872 return_type_field: None,
873
874 call_nodes: &["call"],
875 call_style: CallNodeStyle::FunctionField("function"),
876 new_expr_nodes: &[],
877 new_expr_type_field: "constructor",
878 composite_literal_nodes: &[],
879 member_access: &[MemberAccess { node_kind: "attribute", object_field: "object", property_field: "attribute" }],
880 scoped_call_nodes: &[],
881
882 self_keywords: &["self", "cls"],
883
884 init_strategy: InitStrategy::ConstructorBody {
885 class_nodes: &["class_definition"],
886 init_names: &["__init__"],
887 init_node_kind: "function_definition",
888 self_keyword: "self",
889 access_kind: "attribute",
890 obj_field: "object",
891 prop_field: "attribute",
892 },
893
894 import_extractor: None, external_method: false,
896
897 builtins: &[
898 "print", "len", "range", "str", "int", "float", "bool",
899 "list", "dict", "set", "tuple", "type", "super",
900 "isinstance", "issubclass", "getattr", "setattr",
901 "hasattr", "delattr", "open", "input", "map",
902 "filter", "zip", "enumerate", "sorted", "reversed",
903 "min", "max", "sum", "any", "all", "abs",
904 "round", "format", "repr", "id", "hash",
905 "ValueError", "TypeError", "KeyError", "RuntimeError",
906 "Exception", "StopIteration",
907 ],
908};
909
910static TS_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
911 class_scope_nodes: &["class_declaration"],
912 impl_scope_nodes: &[],
913 function_scope_nodes: &["function_declaration", "method_definition"],
914 class_name_field: ClassNameField::Simple("name"),
915
916 assignment_rules: &[
917 AssignmentRule { node_kind: "lexical_declaration", strategy: AssignmentStrategy::Declarators },
918 AssignmentRule { node_kind: "variable_declaration", strategy: AssignmentStrategy::Declarators },
919 AssignmentRule { node_kind: "expression_statement", strategy: AssignmentStrategy::LeftRight },
920 ],
921 assignment_recurse_into: &["statement_block"],
922
923 param_rules: &[
924 ParamRule { node_kind: "required_parameter", name_field: ParamNameField::WithFallback("pattern"), type_field: "type", skip_names: &["this"] },
925 ParamRule { node_kind: "optional_parameter", name_field: ParamNameField::WithFallback("pattern"), type_field: "type", skip_names: &["this"] },
926 ],
927
928 return_type_field: Some("return_type"),
929
930 call_nodes: &["call_expression"],
931 call_style: CallNodeStyle::FunctionField("function"),
932 new_expr_nodes: &["new_expression"],
933 new_expr_type_field: "constructor",
934 composite_literal_nodes: &[],
935 member_access: &[MemberAccess { node_kind: "member_expression", object_field: "object", property_field: "property" }],
936 scoped_call_nodes: &[],
937
938 self_keywords: &["this"],
939
940 init_strategy: InitStrategy::ConstructorBody {
941 class_nodes: &["class_declaration"],
942 init_names: &["constructor"],
943 init_node_kind: "method_definition",
944 self_keyword: "this",
945 access_kind: "member_expression",
946 obj_field: "object",
947 prop_field: "property",
948 },
949
950 import_extractor: None,
951 external_method: false,
952
953 builtins: &[
954 "console", "parseInt", "parseFloat", "isNaN", "isFinite",
955 "setTimeout", "setInterval", "clearTimeout", "clearInterval",
956 "Promise", "Array", "Object", "Map", "Set", "WeakMap", "WeakSet",
957 "JSON", "Math", "Date", "RegExp", "Error", "TypeError",
958 "RangeError", "Symbol", "Proxy", "Reflect",
959 "String", "Number", "Boolean", "BigInt",
960 "require", "module", "exports", "process",
961 "Buffer", "global", "window", "document",
962 "fetch", "Response", "Request", "Headers", "URL",
963 ],
964};
965
966static RUST_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
967 class_scope_nodes: &["struct_item"],
968 impl_scope_nodes: &["impl_item"],
969 function_scope_nodes: &["function_item"],
970 class_name_field: ClassNameField::Simple("name"),
971
972 assignment_rules: &[
973 AssignmentRule { node_kind: "let_declaration", strategy: AssignmentStrategy::PatternBased },
974 ],
975 assignment_recurse_into: &["block", "expression_statement"],
976
977 param_rules: &[
978 ParamRule { node_kind: "parameter", name_field: ParamNameField::RustPattern, type_field: "type", skip_names: &["self"] },
979 ],
980
981 return_type_field: Some("return_type"),
982
983 call_nodes: &["call_expression"],
984 call_style: CallNodeStyle::FunctionField("function"),
985 new_expr_nodes: &[],
986 new_expr_type_field: "constructor",
987 composite_literal_nodes: &[],
988 member_access: &[MemberAccess { node_kind: "field_expression", object_field: "value", property_field: "field" }],
989 scoped_call_nodes: &["scoped_identifier"],
990
991 self_keywords: &["self"],
992
993 init_strategy: InitStrategy::StructFields {
994 struct_nodes: &["struct_item"],
995 },
996
997 import_extractor: None,
998 external_method: false,
999
1000 builtins: &[
1001 "println", "eprintln", "print", "eprint", "dbg",
1002 "format", "write", "writeln",
1003 "vec", "panic", "todo", "unimplemented", "unreachable",
1004 "assert", "assert_eq", "assert_ne", "debug_assert",
1005 "Some", "None", "Ok", "Err",
1006 "Box", "Vec", "String", "HashMap", "HashSet",
1007 "Arc", "Rc", "Mutex", "RwLock", "Cell", "RefCell",
1008 "Option", "Result", "Iterator", "IntoIterator",
1009 "Clone", "Copy", "Debug", "Display", "Default",
1010 "From", "Into", "TryFrom", "TryInto",
1011 "Send", "Sync", "Sized", "Unpin",
1012 "cfg", "derive", "include", "env",
1013 ],
1014};
1015
1016static GO_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1017 class_scope_nodes: &["type_declaration"],
1018 impl_scope_nodes: &[],
1019 function_scope_nodes: &["function_declaration", "method_declaration"],
1020 class_name_field: ClassNameField::TypeSpec { spec_kind: "type_spec", field: "name" },
1021
1022 assignment_rules: &[
1023 AssignmentRule { node_kind: "short_var_declaration", strategy: AssignmentStrategy::ShortVar },
1024 AssignmentRule { node_kind: "var_declaration", strategy: AssignmentStrategy::VarSpec },
1025 ],
1026 assignment_recurse_into: &["block"],
1027
1028 param_rules: &[
1029 ParamRule { node_kind: "parameter_declaration", name_field: ParamNameField::Simple("name"), type_field: "type", skip_names: &[] },
1030 ],
1031
1032 return_type_field: Some("result"),
1033
1034 call_nodes: &["call_expression"],
1035 call_style: CallNodeStyle::FunctionField("function"),
1036 new_expr_nodes: &[],
1037 new_expr_type_field: "constructor",
1038 composite_literal_nodes: &["composite_literal"],
1039 member_access: &[MemberAccess { node_kind: "selector_expression", object_field: "operand", property_field: "field" }],
1040 scoped_call_nodes: &[],
1041
1042 self_keywords: &[],
1043
1044 init_strategy: InitStrategy::StructFields {
1045 struct_nodes: &["type_declaration"],
1046 },
1047
1048 import_extractor: None,
1049 external_method: true,
1050
1051 builtins: &[
1052 "fmt", "log", "os", "io", "strings", "strconv", "bytes",
1053 "make", "len", "cap", "append", "copy", "delete", "close",
1054 "panic", "recover", "new", "print", "println",
1055 "error", "string", "int", "int8", "int16", "int32", "int64",
1056 "uint", "uint8", "uint16", "uint32", "uint64",
1057 "float32", "float64", "complex64", "complex128",
1058 "bool", "byte", "rune", "uintptr",
1059 "Println", "Printf", "Sprintf", "Fprintf", "Errorf",
1060 ],
1061};
1062
1063static JAVA_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1066 class_scope_nodes: &["class_declaration", "interface_declaration", "enum_declaration"],
1067 impl_scope_nodes: &[],
1068 function_scope_nodes: &["method_declaration", "constructor_declaration"],
1069 class_name_field: ClassNameField::Simple("name"),
1070
1071 assignment_rules: &[
1072 AssignmentRule { node_kind: "local_variable_declaration", strategy: AssignmentStrategy::Declarators },
1073 AssignmentRule { node_kind: "expression_statement", strategy: AssignmentStrategy::LeftRight },
1074 ],
1075 assignment_recurse_into: &["block"],
1076
1077 param_rules: &[
1078 ParamRule { node_kind: "formal_parameter", name_field: ParamNameField::Simple("name"), type_field: "type", skip_names: &[] },
1079 ],
1080
1081 return_type_field: Some("type"),
1082
1083 call_nodes: &["method_invocation"],
1084 call_style: CallNodeStyle::DirectMethod { object_field: "object", method_field: "name" },
1085 new_expr_nodes: &["object_creation_expression"],
1086 new_expr_type_field: "type",
1087 composite_literal_nodes: &[],
1088 member_access: &[MemberAccess { node_kind: "method_invocation", object_field: "object", property_field: "name" }],
1089 scoped_call_nodes: &[],
1090
1091 self_keywords: &["this"],
1092
1093 init_strategy: InitStrategy::None,
1094 import_extractor: None,
1095 external_method: false,
1096
1097 builtins: &[
1098 "System", "String", "Integer", "Long", "Double", "Float", "Boolean",
1099 "Object", "Class", "Math", "Collections", "Arrays", "List", "Map", "Set",
1100 "ArrayList", "HashMap", "HashSet", "Optional", "Stream",
1101 "Exception", "RuntimeException", "NullPointerException",
1102 "println", "printf", "format",
1103 ],
1104};
1105
1106static CSHARP_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1107 class_scope_nodes: &["class_declaration", "interface_declaration", "struct_declaration", "enum_declaration"],
1108 impl_scope_nodes: &[],
1109 function_scope_nodes: &["method_declaration", "constructor_declaration"],
1110 class_name_field: ClassNameField::Simple("name"),
1111
1112 assignment_rules: &[
1113 AssignmentRule { node_kind: "local_declaration_statement", strategy: AssignmentStrategy::Declarators },
1114 AssignmentRule { node_kind: "expression_statement", strategy: AssignmentStrategy::LeftRight },
1115 ],
1116 assignment_recurse_into: &["block"],
1117
1118 param_rules: &[
1119 ParamRule { node_kind: "parameter", name_field: ParamNameField::Simple("name"), type_field: "type", skip_names: &[] },
1120 ],
1121
1122 return_type_field: Some("type"),
1123
1124 call_nodes: &["invocation_expression"],
1125 call_style: CallNodeStyle::FunctionField("function"),
1126 new_expr_nodes: &["object_creation_expression"],
1127 new_expr_type_field: "type",
1128 composite_literal_nodes: &[],
1129 member_access: &[MemberAccess { node_kind: "member_access_expression", object_field: "expression", property_field: "name" }],
1130 scoped_call_nodes: &[],
1131
1132 self_keywords: &["this"],
1133
1134 init_strategy: InitStrategy::None,
1135 import_extractor: None,
1136 external_method: false,
1137
1138 builtins: &[
1139 "Console", "String", "Int32", "Int64", "Double", "Boolean",
1140 "Object", "Math", "List", "Dictionary", "HashSet",
1141 "Task", "Async", "Exception", "ArgumentException",
1142 "WriteLine", "ReadLine", "ToString", "Equals",
1143 ],
1144};
1145
1146static CPP_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1147 class_scope_nodes: &["class_specifier", "struct_specifier"],
1148 impl_scope_nodes: &[],
1149 function_scope_nodes: &["function_definition"],
1150 class_name_field: ClassNameField::Simple("name"),
1151
1152 assignment_rules: &[
1153 AssignmentRule { node_kind: "declaration", strategy: AssignmentStrategy::Declarators },
1154 AssignmentRule { node_kind: "expression_statement", strategy: AssignmentStrategy::LeftRight },
1155 ],
1156 assignment_recurse_into: &["compound_statement"],
1157
1158 param_rules: &[
1159 ParamRule { node_kind: "parameter_declaration", name_field: ParamNameField::Simple("declarator"), type_field: "type", skip_names: &[] },
1160 ],
1161
1162 return_type_field: Some("type"),
1163
1164 call_nodes: &["call_expression"],
1165 call_style: CallNodeStyle::FunctionField("function"),
1166 new_expr_nodes: &["new_expression"],
1167 new_expr_type_field: "type",
1168 composite_literal_nodes: &[],
1169 member_access: &[
1170 MemberAccess { node_kind: "field_expression", object_field: "argument", property_field: "field" },
1171 ],
1172 scoped_call_nodes: &["qualified_identifier"],
1173
1174 self_keywords: &["this"],
1175
1176 init_strategy: InitStrategy::StructFields {
1177 struct_nodes: &["class_specifier", "struct_specifier"],
1178 },
1179 import_extractor: None,
1180 external_method: false,
1181
1182 builtins: &[
1183 "std", "cout", "cin", "endl", "printf", "scanf", "malloc", "free",
1184 "string", "vector", "map", "set", "pair", "make_pair",
1185 "shared_ptr", "unique_ptr", "make_shared", "make_unique",
1186 "nullptr", "size_t", "int", "char", "double", "float", "bool",
1187 ],
1188};
1189
1190static RUBY_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1191 class_scope_nodes: &["class", "module"],
1192 impl_scope_nodes: &[],
1193 function_scope_nodes: &["method", "singleton_method"],
1194 class_name_field: ClassNameField::Simple("name"),
1195
1196 assignment_rules: &[
1197 AssignmentRule { node_kind: "assignment", strategy: AssignmentStrategy::LeftRight },
1198 ],
1199 assignment_recurse_into: &["body_statement"],
1200
1201 param_rules: &[],
1202
1203 return_type_field: None,
1204
1205 call_nodes: &["call"],
1206 call_style: CallNodeStyle::DirectMethod { object_field: "receiver", method_field: "method" },
1207 new_expr_nodes: &[],
1208 new_expr_type_field: "constructor",
1209 composite_literal_nodes: &[],
1210 member_access: &[MemberAccess { node_kind: "call", object_field: "receiver", property_field: "method" }],
1211 scoped_call_nodes: &["scope_resolution"],
1212
1213 self_keywords: &["self"],
1214
1215 init_strategy: InitStrategy::None,
1216 import_extractor: None,
1217 external_method: false,
1218
1219 builtins: &[
1220 "puts", "print", "p", "require", "require_relative", "include", "extend",
1221 "attr_accessor", "attr_reader", "attr_writer",
1222 "raise", "rescue", "yield", "block_given?",
1223 "Array", "Hash", "String", "Integer", "Float", "Symbol",
1224 "nil", "true", "false",
1225 ],
1226};
1227
1228static KOTLIN_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1229 class_scope_nodes: &["class_declaration", "object_declaration"],
1230 impl_scope_nodes: &[],
1231 function_scope_nodes: &["function_declaration", "secondary_constructor"],
1232 class_name_field: ClassNameField::Simple("name"),
1233
1234 assignment_rules: &[
1235 AssignmentRule { node_kind: "property_declaration", strategy: AssignmentStrategy::Declarators },
1236 ],
1237 assignment_recurse_into: &["statements"],
1238
1239 param_rules: &[
1240 ParamRule { node_kind: "parameter", name_field: ParamNameField::Simple("name"), type_field: "type", skip_names: &[] },
1241 ],
1242
1243 return_type_field: Some("type"),
1244
1245 call_nodes: &["call_expression"],
1246 call_style: CallNodeStyle::FunctionField("function"),
1247 new_expr_nodes: &[],
1248 new_expr_type_field: "constructor",
1249 composite_literal_nodes: &[],
1250 member_access: &[MemberAccess { node_kind: "navigation_expression", object_field: "expression", property_field: "navigation_suffix" }],
1251 scoped_call_nodes: &[],
1252
1253 self_keywords: &["this"],
1254
1255 init_strategy: InitStrategy::None,
1256 import_extractor: None,
1257 external_method: false,
1258
1259 builtins: &[
1260 "println", "print", "listOf", "mapOf", "setOf", "arrayOf",
1261 "mutableListOf", "mutableMapOf", "mutableSetOf",
1262 "String", "Int", "Long", "Double", "Float", "Boolean",
1263 "Any", "Unit", "Nothing", "Pair", "Triple",
1264 "require", "check", "error", "TODO",
1265 ],
1266};
1267
1268static PHP_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1269 class_scope_nodes: &["class_declaration", "interface_declaration", "trait_declaration"],
1270 impl_scope_nodes: &[],
1271 function_scope_nodes: &["function_definition", "method_declaration"],
1272 class_name_field: ClassNameField::Simple("name"),
1273
1274 assignment_rules: &[
1275 AssignmentRule { node_kind: "expression_statement", strategy: AssignmentStrategy::LeftRight },
1276 ],
1277 assignment_recurse_into: &["compound_statement"],
1278
1279 param_rules: &[
1280 ParamRule { node_kind: "simple_parameter", name_field: ParamNameField::Simple("name"), type_field: "type", skip_names: &[] },
1281 ],
1282
1283 return_type_field: Some("return_type"),
1284
1285 call_nodes: &["function_call_expression", "member_call_expression"],
1286 call_style: CallNodeStyle::FunctionField("function"),
1287 new_expr_nodes: &["object_creation_expression"],
1288 new_expr_type_field: "type",
1289 composite_literal_nodes: &[],
1290 member_access: &[MemberAccess { node_kind: "member_call_expression", object_field: "object", property_field: "name" }],
1291 scoped_call_nodes: &["scoped_call_expression"],
1292
1293 self_keywords: &["$this"],
1294
1295 init_strategy: InitStrategy::None,
1296 import_extractor: None,
1297 external_method: false,
1298
1299 builtins: &[
1300 "echo", "print", "var_dump", "print_r", "isset", "unset", "empty",
1301 "array", "count", "strlen", "substr", "strpos",
1302 "is_null", "is_array", "is_string", "is_int",
1303 "Exception", "RuntimeException", "InvalidArgumentException",
1304 ],
1305};
1306
1307static SWIFT_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1308 class_scope_nodes: &["class_declaration", "protocol_declaration"],
1309 impl_scope_nodes: &[],
1310 function_scope_nodes: &["function_declaration", "init_declaration"],
1311 class_name_field: ClassNameField::Simple("name"),
1312
1313 assignment_rules: &[
1314 AssignmentRule { node_kind: "property_declaration", strategy: AssignmentStrategy::Declarators },
1315 ],
1316 assignment_recurse_into: &["function_body"],
1317
1318 param_rules: &[
1319 ParamRule { node_kind: "parameter", name_field: ParamNameField::Simple("name"), type_field: "type", skip_names: &[] },
1320 ],
1321
1322 return_type_field: Some("return_type"),
1323
1324 call_nodes: &["call_expression"],
1325 call_style: CallNodeStyle::FunctionField("function"),
1326 new_expr_nodes: &[],
1327 new_expr_type_field: "constructor",
1328 composite_literal_nodes: &[],
1329 member_access: &[MemberAccess { node_kind: "navigation_expression", object_field: "target", property_field: "suffix" }],
1330 scoped_call_nodes: &[],
1331
1332 self_keywords: &["self"],
1333
1334 init_strategy: InitStrategy::None,
1335 import_extractor: None,
1336 external_method: false,
1337
1338 builtins: &[
1339 "print", "debugPrint", "fatalError", "precondition", "assert",
1340 "String", "Int", "Double", "Float", "Bool", "Array", "Dictionary", "Set",
1341 "Optional", "Result", "Error", "NSError",
1342 ],
1343};
1344
1345static SCALA_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1346 class_scope_nodes: &["class_definition", "object_definition", "trait_definition"],
1347 impl_scope_nodes: &[],
1348 function_scope_nodes: &["function_definition", "function_declaration"],
1349 class_name_field: ClassNameField::Simple("name"),
1350
1351 assignment_rules: &[
1352 AssignmentRule { node_kind: "val_definition", strategy: AssignmentStrategy::Declarators },
1353 ],
1354 assignment_recurse_into: &["template_body"],
1355
1356 param_rules: &[
1357 ParamRule { node_kind: "parameter", name_field: ParamNameField::Simple("name"), type_field: "type", skip_names: &[] },
1358 ],
1359
1360 return_type_field: Some("return_type"),
1361
1362 call_nodes: &["call_expression"],
1363 call_style: CallNodeStyle::FunctionField("function"),
1364 new_expr_nodes: &[],
1365 new_expr_type_field: "constructor",
1366 composite_literal_nodes: &[],
1367 member_access: &[MemberAccess { node_kind: "field_expression", object_field: "value", property_field: "field" }],
1368 scoped_call_nodes: &[],
1369
1370 self_keywords: &["this"],
1371
1372 init_strategy: InitStrategy::None,
1373 import_extractor: None,
1374 external_method: false,
1375
1376 builtins: &[
1377 "println", "print", "require", "assert",
1378 "String", "Int", "Long", "Double", "Float", "Boolean",
1379 "List", "Map", "Set", "Seq", "Vector", "Option", "Some", "None",
1380 "Future", "Try", "Either", "Left", "Right",
1381 ],
1382};
1383
1384static DART_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1387 class_scope_nodes: &["class_declaration", "mixin_declaration", "enum_declaration"],
1388 impl_scope_nodes: &[],
1389 function_scope_nodes: &["function_signature", "method_signature"],
1390 class_name_field: ClassNameField::Simple("name"),
1391
1392 assignment_rules: &[],
1393 assignment_recurse_into: &[],
1394
1395 param_rules: &[
1396 ParamRule { node_kind: "formal_parameter", name_field: ParamNameField::Simple("name"), type_field: "type", skip_names: &[] },
1397 ],
1398
1399 return_type_field: None,
1400
1401 call_nodes: &["function_expression_body"],
1402 call_style: CallNodeStyle::FunctionField("function"),
1403 new_expr_nodes: &[],
1404 new_expr_type_field: "constructor",
1405 composite_literal_nodes: &[],
1406 member_access: &[],
1407 scoped_call_nodes: &[],
1408
1409 self_keywords: &["this"],
1410
1411 init_strategy: InitStrategy::None,
1412 import_extractor: None,
1413 external_method: false,
1414
1415 builtins: &[
1416 "print", "debugPrint", "String", "int", "double", "bool",
1417 "List", "Map", "Set", "Future", "Stream",
1418 ],
1419};
1420
1421static ZIG_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1422 class_scope_nodes: &[],
1423 impl_scope_nodes: &[],
1424 function_scope_nodes: &["function_declaration", "test_declaration"],
1425 class_name_field: ClassNameField::Simple("name"),
1426
1427 assignment_rules: &[],
1428 assignment_recurse_into: &[],
1429
1430 param_rules: &[],
1431
1432 return_type_field: None,
1433
1434 call_nodes: &["call_expression"],
1435 call_style: CallNodeStyle::FunctionField("function"),
1436 new_expr_nodes: &[],
1437 new_expr_type_field: "constructor",
1438 composite_literal_nodes: &[],
1439 member_access: &[MemberAccess { node_kind: "field_expression", object_field: "object", property_field: "field" }],
1440 scoped_call_nodes: &[],
1441
1442 self_keywords: &[],
1443
1444 init_strategy: InitStrategy::None,
1445 import_extractor: None,
1446 external_method: false,
1447
1448 builtins: &[
1449 "std", "print", "debug", "assert", "expect",
1450 "allocator", "mem", "testing",
1451 ],
1452};
1453
1454static BASH_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1455 class_scope_nodes: &[],
1456 impl_scope_nodes: &[],
1457 function_scope_nodes: &["function_definition"],
1458 class_name_field: ClassNameField::Simple("name"),
1459
1460 assignment_rules: &[],
1461 assignment_recurse_into: &[],
1462
1463 param_rules: &[],
1464
1465 return_type_field: None,
1466
1467 call_nodes: &["command"],
1468 call_style: CallNodeStyle::FunctionField("name"),
1469 new_expr_nodes: &[],
1470 new_expr_type_field: "constructor",
1471 composite_literal_nodes: &[],
1472 member_access: &[],
1473 scoped_call_nodes: &[],
1474
1475 self_keywords: &[],
1476
1477 init_strategy: InitStrategy::None,
1478 import_extractor: None,
1479 external_method: false,
1480
1481 builtins: &[
1482 "echo", "printf", "cd", "ls", "cat", "grep", "sed", "awk",
1483 "if", "then", "else", "fi", "for", "while", "do", "done",
1484 "exit", "return", "export", "source", "eval",
1485 ],
1486};
1487
1488static ALL_CONFIGS: &[&LanguageConfig] = &[
1489 &TYPESCRIPT_CONFIG,
1490 &TSX_CONFIG,
1491 &JAVASCRIPT_CONFIG,
1492 &PYTHON_CONFIG,
1493 &GO_CONFIG,
1494 &RUST_CONFIG,
1495 &JAVA_CONFIG,
1496 &C_CONFIG,
1497 &CPP_CONFIG,
1498 &RUBY_CONFIG,
1499 &CSHARP_CONFIG,
1500 &PHP_CONFIG,
1501 &FORTRAN_CONFIG,
1502 &SWIFT_CONFIG,
1503 &ELIXIR_CONFIG,
1504 &BASH_CONFIG,
1505 &HCL_CONFIG,
1506 &KOTLIN_CONFIG,
1507 &XML_CONFIG,
1508 &DART_CONFIG,
1509 &PERL_CONFIG,
1510 &OCAML_CONFIG,
1511 &OCAML_INTERFACE_CONFIG,
1512 &SCALA_CONFIG,
1513 &ZIG_CONFIG,
1514 &NIX_CONFIG,
1515];
1516
1517pub fn get_language_config(extension: &str) -> Option<&'static LanguageConfig> {
1518 ALL_CONFIGS
1519 .iter()
1520 .find(|c| c.extensions.contains(&extension))
1521 .copied()
1522}
1523
1524pub fn get_all_code_extensions() -> &'static [&'static str] {
1525 static EXTENSIONS: std::sync::LazyLock<Vec<&'static str>> = std::sync::LazyLock::new(|| {
1528 ALL_CONFIGS.iter().flat_map(|c| c.extensions.iter().copied()).collect()
1529 });
1530 &EXTENSIONS
1531}