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