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