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 {
93 object_field: &'static str,
94 method_field: &'static str,
95 },
96 FirstChild,
100}
101
102pub enum ClassNameField {
104 Simple(&'static str),
106 TypeSpec {
108 spec_kind: &'static str,
109 field: &'static str,
110 },
111 ImplType(&'static str),
113}
114
115pub struct AssignmentRule {
117 pub node_kind: &'static str,
118 pub strategy: AssignmentStrategy,
119}
120
121pub enum AssignmentStrategy {
123 LeftRight,
125 Declarators,
127 PatternBased,
129 ShortVar,
131 VarSpec,
133}
134
135pub struct ParamRule {
137 pub node_kind: &'static str,
138 pub name_field: ParamNameField,
139 pub type_field: &'static str,
140 pub skip_names: &'static [&'static str],
141}
142
143pub enum ParamNameField {
145 Simple(&'static str),
147 WithFallback(&'static str),
149 RustPattern,
151}
152
153pub struct MemberAccess {
155 pub node_kind: &'static str,
156 pub object_field: &'static str,
157 pub property_field: &'static str,
158}
159
160pub enum InitStrategy {
162 ConstructorBody {
164 class_nodes: &'static [&'static str],
165 init_names: &'static [&'static str],
166 init_node_kind: &'static str,
167 self_keyword: &'static str,
168 access_kind: &'static str,
169 obj_field: &'static str,
170 prop_field: &'static str,
171 },
172 StructFields {
174 struct_nodes: &'static [&'static str],
175 },
176 None,
178}
179
180pub type ImportExtractorFn = fn(
182 node: tree_sitter::Node,
183 file_path: &str,
184 source: &[u8],
185 symbol_table: &HashMap<String, Vec<String>>,
186 entity_map: &HashMap<String, EntityInfo>,
187 import_table: &mut HashMap<(String, String), String>,
188 scopes: &mut Vec<crate::parser::scope_resolve::Scope>,
189);
190
191pub struct ImportRule {
193 pub node_kind: &'static str,
194 pub extractor: ImportExtractorFn,
195}
196
197#[cfg(feature = "lang-typescript")]
198fn get_typescript() -> Option<Language> {
199 Some(tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into())
200}
201
202#[cfg(feature = "lang-typescript")]
203fn get_tsx() -> Option<Language> {
204 Some(tree_sitter_typescript::LANGUAGE_TSX.into())
205}
206
207#[cfg(feature = "lang-javascript")]
208fn get_javascript() -> Option<Language> {
209 Some(tree_sitter_javascript::LANGUAGE.into())
210}
211
212#[cfg(feature = "lang-python")]
213fn get_python() -> Option<Language> {
214 Some(tree_sitter_python::LANGUAGE.into())
215}
216
217#[cfg(feature = "lang-go")]
218fn get_go() -> Option<Language> {
219 Some(tree_sitter_go::LANGUAGE.into())
220}
221
222#[cfg(feature = "lang-rust")]
223fn get_rust() -> Option<Language> {
224 Some(tree_sitter_rust::LANGUAGE.into())
225}
226
227#[cfg(feature = "lang-java")]
228fn get_java() -> Option<Language> {
229 Some(tree_sitter_java::LANGUAGE.into())
230}
231
232#[cfg(feature = "lang-c")]
233fn get_c() -> Option<Language> {
234 Some(tree_sitter_c::LANGUAGE.into())
235}
236
237#[cfg(feature = "lang-cpp")]
238fn get_cpp() -> Option<Language> {
239 Some(tree_sitter_cpp::LANGUAGE.into())
240}
241
242#[cfg(feature = "lang-ruby")]
243fn get_ruby() -> Option<Language> {
244 Some(tree_sitter_ruby::LANGUAGE.into())
245}
246
247#[cfg(feature = "lang-csharp")]
248fn get_csharp() -> Option<Language> {
249 Some(tree_sitter_c_sharp::LANGUAGE.into())
250}
251
252#[cfg(feature = "lang-php")]
253fn get_php() -> Option<Language> {
254 Some(tree_sitter_php::LANGUAGE_PHP.into())
255}
256
257#[cfg(feature = "lang-fortran")]
258fn get_fortran() -> Option<Language> {
259 Some(tree_sitter_fortran::LANGUAGE.into())
260}
261
262#[cfg(feature = "lang-swift")]
263fn get_swift() -> Option<Language> {
264 Some(tree_sitter_swift::LANGUAGE.into())
265}
266
267#[cfg(feature = "lang-elixir")]
268fn get_elixir() -> Option<Language> {
269 Some(tree_sitter_elixir::LANGUAGE.into())
270}
271
272#[cfg(feature = "lang-bash")]
273fn get_bash() -> Option<Language> {
274 Some(tree_sitter_bash::LANGUAGE.into())
275}
276
277#[cfg(feature = "lang-hcl")]
278fn get_hcl() -> Option<Language> {
279 Some(tree_sitter_hcl::LANGUAGE.into())
280}
281
282#[cfg(feature = "lang-kotlin")]
283fn get_kotlin() -> Option<Language> {
284 Some(tree_sitter_kotlin_ng::LANGUAGE.into())
285}
286
287#[cfg(feature = "lang-xml")]
288fn get_xml() -> Option<Language> {
289 Some(tree_sitter_xml::LANGUAGE_XML.into())
290}
291
292#[cfg(feature = "lang-dart")]
293fn get_dart() -> Option<Language> {
294 Some(tree_sitter_dart::LANGUAGE.into())
295}
296
297#[cfg(feature = "lang-perl")]
298fn get_perl() -> Option<Language> {
299 Some(tree_sitter_perl_next::LANGUAGE.into())
300}
301
302#[cfg(feature = "lang-ocaml")]
303fn get_ocaml() -> Option<Language> {
304 Some(tree_sitter_ocaml::LANGUAGE_OCAML.into())
305}
306
307#[cfg(feature = "lang-ocaml")]
308fn get_ocaml_interface() -> Option<Language> {
309 Some(tree_sitter_ocaml::LANGUAGE_OCAML_INTERFACE.into())
310}
311
312#[cfg(feature = "lang-scala")]
313fn get_scala() -> Option<Language> {
314 Some(tree_sitter_scala::LANGUAGE.into())
315}
316
317#[cfg(feature = "lang-zig")]
318fn get_zig() -> Option<Language> {
319 Some(tree_sitter_zig::LANGUAGE.into())
320}
321
322#[cfg(feature = "lang-nix")]
323fn get_nix() -> Option<Language> {
324 Some(tree_sitter_nix::LANGUAGE.into())
325}
326
327#[cfg(feature = "lang-haskell")]
328fn get_haskell() -> Option<Language> {
329 Some(tree_sitter_haskell::LANGUAGE.into())
330}
331
332const JS_TS_SUPPRESSED_NESTED: &[SuppressedNestedEntity] = &[
336 SuppressedNestedEntity {
337 parent_entity_node_type: "function_declaration",
338 child_entity_node_type: "lexical_declaration",
339 },
340 SuppressedNestedEntity {
341 parent_entity_node_type: "function_declaration",
342 child_entity_node_type: "variable_declaration",
343 },
344 SuppressedNestedEntity {
345 parent_entity_node_type: "generator_function_declaration",
346 child_entity_node_type: "lexical_declaration",
347 },
348 SuppressedNestedEntity {
349 parent_entity_node_type: "generator_function_declaration",
350 child_entity_node_type: "variable_declaration",
351 },
352 SuppressedNestedEntity {
353 parent_entity_node_type: "method_definition",
354 child_entity_node_type: "lexical_declaration",
355 },
356 SuppressedNestedEntity {
357 parent_entity_node_type: "method_definition",
358 child_entity_node_type: "variable_declaration",
359 },
360 SuppressedNestedEntity {
364 parent_entity_node_type: "arrow_function",
365 child_entity_node_type: "lexical_declaration",
366 },
367 SuppressedNestedEntity {
368 parent_entity_node_type: "arrow_function",
369 child_entity_node_type: "variable_declaration",
370 },
371 SuppressedNestedEntity {
372 parent_entity_node_type: "function_expression",
373 child_entity_node_type: "lexical_declaration",
374 },
375 SuppressedNestedEntity {
376 parent_entity_node_type: "function_expression",
377 child_entity_node_type: "variable_declaration",
378 },
379 SuppressedNestedEntity {
380 parent_entity_node_type: "generator_function",
381 child_entity_node_type: "lexical_declaration",
382 },
383 SuppressedNestedEntity {
384 parent_entity_node_type: "generator_function",
385 child_entity_node_type: "variable_declaration",
386 },
387];
388
389const JS_TS_SCOPE_BOUNDARIES: &[&str] = &[
390 "arrow_function",
391 "function_expression",
392 "generator_function",
393];
394
395const C_SUPPRESSED_NESTED: &[SuppressedNestedEntity] = &[SuppressedNestedEntity {
399 parent_entity_node_type: "function_definition",
400 child_entity_node_type: "declaration",
401}];
402
403const CPP_SUPPRESSED_NESTED: &[SuppressedNestedEntity] = &[
407 SuppressedNestedEntity {
408 parent_entity_node_type: "function_definition",
409 child_entity_node_type: "declaration",
410 },
411 SuppressedNestedEntity {
412 parent_entity_node_type: "lambda_expression",
413 child_entity_node_type: "declaration",
414 },
415];
416
417const CPP_SCOPE_BOUNDARIES: &[&str] = &["lambda_expression"];
418
419const SWIFT_SUPPRESSED_NESTED: &[SuppressedNestedEntity] = &[
420 SuppressedNestedEntity {
421 parent_entity_node_type: "function_declaration",
422 child_entity_node_type: "property_declaration",
423 },
424 SuppressedNestedEntity {
425 parent_entity_node_type: "init_declaration",
426 child_entity_node_type: "property_declaration",
427 },
428 SuppressedNestedEntity {
429 parent_entity_node_type: "deinit_declaration",
430 child_entity_node_type: "property_declaration",
431 },
432 SuppressedNestedEntity {
433 parent_entity_node_type: "subscript_declaration",
434 child_entity_node_type: "property_declaration",
435 },
436 SuppressedNestedEntity {
437 parent_entity_node_type: "property_declaration",
438 child_entity_node_type: "property_declaration",
439 },
440];
441
442#[cfg(feature = "lang-typescript")]
443static TYPESCRIPT_CONFIG: LanguageConfig = LanguageConfig {
444 id: "typescript",
445 extensions: &[".ts", ".mts", ".cts"],
446 entity_node_types: &[
447 "function_declaration",
448 "generator_function_declaration",
449 "function_signature",
450 "class_declaration",
451 "abstract_class_declaration",
452 "interface_declaration",
453 "type_alias_declaration",
454 "enum_declaration",
455 "internal_module",
456 "module",
457 "export_statement",
458 "lexical_declaration",
459 "variable_declaration",
460 "method_definition",
461 "abstract_method_signature",
462 "public_field_definition",
463 "function_signature",
464 "method_signature",
465 "property_signature",
466 ],
467 container_node_types: &[
468 "class_body",
469 "interface_body",
470 "enum_body",
471 "statement_block",
472 ],
473 call_entity_identifiers: &[],
474 suppressed_nested_entities: JS_TS_SUPPRESSED_NESTED,
475 scope_boundary_types: JS_TS_SCOPE_BOUNDARIES,
476 get_language: get_typescript,
477 scope_resolve: Some(&TS_SCOPE_CONFIG),
478};
479
480#[cfg(feature = "lang-typescript")]
481static TSX_CONFIG: LanguageConfig = LanguageConfig {
482 id: "tsx",
483 extensions: &[".tsx"],
484 entity_node_types: &[
485 "function_declaration",
486 "generator_function_declaration",
487 "function_signature",
488 "class_declaration",
489 "abstract_class_declaration",
490 "interface_declaration",
491 "type_alias_declaration",
492 "enum_declaration",
493 "internal_module",
494 "module",
495 "export_statement",
496 "lexical_declaration",
497 "variable_declaration",
498 "method_definition",
499 "abstract_method_signature",
500 "public_field_definition",
501 "function_signature",
502 "method_signature",
503 "property_signature",
504 ],
505 container_node_types: &[
506 "class_body",
507 "interface_body",
508 "enum_body",
509 "statement_block",
510 ],
511 call_entity_identifiers: &[],
512 suppressed_nested_entities: JS_TS_SUPPRESSED_NESTED,
513 scope_boundary_types: JS_TS_SCOPE_BOUNDARIES,
514 get_language: get_tsx,
515 scope_resolve: Some(&TS_SCOPE_CONFIG),
516};
517
518#[cfg(feature = "lang-javascript")]
519static JAVASCRIPT_CONFIG: LanguageConfig = LanguageConfig {
520 id: "javascript",
521 extensions: &[".js", ".jsx", ".mjs", ".cjs", ".es6"],
522 entity_node_types: &[
523 "function_declaration",
524 "generator_function_declaration",
525 "class_declaration",
526 "export_statement",
527 "lexical_declaration",
528 "variable_declaration",
529 "method_definition",
530 "field_definition",
531 ],
532 container_node_types: &["class_body", "statement_block"],
533 call_entity_identifiers: &[],
534 suppressed_nested_entities: JS_TS_SUPPRESSED_NESTED,
535 scope_boundary_types: JS_TS_SCOPE_BOUNDARIES,
536 get_language: get_javascript,
537 scope_resolve: Some(&TS_SCOPE_CONFIG),
538};
539
540#[cfg(feature = "lang-python")]
541static PYTHON_CONFIG: LanguageConfig = LanguageConfig {
542 id: "python",
543 extensions: &[".py", ".pyi"],
544 entity_node_types: &[
545 "function_definition",
546 "class_definition",
547 "decorated_definition",
548 ],
549 container_node_types: &["block"],
550 call_entity_identifiers: &[],
551 suppressed_nested_entities: &[],
552 scope_boundary_types: &[],
553 get_language: get_python,
554 scope_resolve: Some(&PYTHON_SCOPE_CONFIG),
555};
556
557#[cfg(feature = "lang-go")]
558static GO_CONFIG: LanguageConfig = LanguageConfig {
559 id: "go",
560 extensions: &[".go"],
561 entity_node_types: &[
562 "function_declaration",
563 "method_declaration",
564 "type_declaration",
565 "var_declaration",
566 "const_declaration",
567 ],
568 container_node_types: &["block"],
569 call_entity_identifiers: &[],
570 suppressed_nested_entities: &[],
571 scope_boundary_types: &[],
572 get_language: get_go,
573 scope_resolve: Some(&GO_SCOPE_CONFIG),
574};
575
576#[cfg(feature = "lang-rust")]
577static RUST_CONFIG: LanguageConfig = LanguageConfig {
578 id: "rust",
579 extensions: &[".rs"],
580 entity_node_types: &[
581 "function_item",
582 "struct_item",
583 "enum_item",
584 "impl_item",
585 "trait_item",
586 "mod_item",
587 "const_item",
588 "static_item",
589 "type_item",
590 "macro_definition",
591 ],
592 container_node_types: &["declaration_list", "block"],
593 call_entity_identifiers: &[],
594 suppressed_nested_entities: &[],
595 scope_boundary_types: &[],
596 get_language: get_rust,
597 scope_resolve: Some(&RUST_SCOPE_CONFIG),
598};
599
600#[cfg(feature = "lang-java")]
601static JAVA_CONFIG: LanguageConfig = LanguageConfig {
602 id: "java",
603 extensions: &[".java"],
604 entity_node_types: &[
605 "class_declaration",
606 "method_declaration",
607 "interface_declaration",
608 "enum_declaration",
609 "record_declaration",
610 "field_declaration",
611 "constructor_declaration",
612 "annotation_type_declaration",
613 ],
614 container_node_types: &[
615 "class_body",
616 "interface_body",
617 "enum_body",
618 "record_body",
619 "block",
620 ],
621 call_entity_identifiers: &[],
622 suppressed_nested_entities: &[],
623 scope_boundary_types: &[],
624 get_language: get_java,
625 scope_resolve: Some(&JAVA_SCOPE_CONFIG),
626};
627
628#[cfg(feature = "lang-c")]
629static C_CONFIG: LanguageConfig = LanguageConfig {
630 id: "c",
631 extensions: &[".c", ".h"],
632 entity_node_types: &[
633 "function_definition",
634 "struct_specifier",
635 "enum_specifier",
636 "union_specifier",
637 "type_definition",
638 "declaration",
639 ],
640 container_node_types: &["compound_statement"],
641 call_entity_identifiers: &[],
642 suppressed_nested_entities: C_SUPPRESSED_NESTED,
643 scope_boundary_types: &[],
644 get_language: get_c,
645 scope_resolve: None,
646};
647
648#[cfg(feature = "lang-cpp")]
649static CPP_CONFIG: LanguageConfig = LanguageConfig {
650 id: "cpp",
651 extensions: &[".cpp", ".cc", ".cxx", ".hpp", ".hh", ".hxx"],
652 entity_node_types: &[
653 "function_definition",
654 "class_specifier",
655 "struct_specifier",
656 "enum_specifier",
657 "namespace_definition",
658 "template_declaration",
659 "declaration",
660 "type_definition",
661 ],
662 container_node_types: &[
663 "field_declaration_list",
664 "declaration_list",
665 "compound_statement",
666 ],
667 call_entity_identifiers: &[],
668 suppressed_nested_entities: CPP_SUPPRESSED_NESTED,
669 scope_boundary_types: CPP_SCOPE_BOUNDARIES,
670 get_language: get_cpp,
671 scope_resolve: Some(&CPP_SCOPE_CONFIG),
672};
673
674#[cfg(feature = "lang-ruby")]
675static RUBY_CONFIG: LanguageConfig = LanguageConfig {
676 id: "ruby",
677 extensions: &[".rb"],
678 entity_node_types: &["method", "singleton_method", "class", "module"],
679 container_node_types: &["body_statement"],
680 call_entity_identifiers: &[],
681 suppressed_nested_entities: &[],
682 scope_boundary_types: &[],
683 get_language: get_ruby,
684 scope_resolve: Some(&RUBY_SCOPE_CONFIG),
685};
686
687#[cfg(feature = "lang-csharp")]
688static CSHARP_CONFIG: LanguageConfig = LanguageConfig {
689 id: "csharp",
690 extensions: &[".cs"],
691 entity_node_types: &[
692 "method_declaration",
693 "class_declaration",
694 "interface_declaration",
695 "enum_declaration",
696 "struct_declaration",
697 "record_declaration",
698 "record_struct_declaration",
699 "namespace_declaration",
700 "property_declaration",
701 "constructor_declaration",
702 "field_declaration",
703 ],
704 container_node_types: &["declaration_list", "record_body", "block"],
705 call_entity_identifiers: &[],
706 suppressed_nested_entities: &[],
707 scope_boundary_types: &[],
708 get_language: get_csharp,
709 scope_resolve: Some(&CSHARP_SCOPE_CONFIG),
710};
711
712#[cfg(feature = "lang-php")]
713static PHP_CONFIG: LanguageConfig = LanguageConfig {
714 id: "php",
715 extensions: &[".php", ".inc", ".phtml", ".module"],
716 entity_node_types: &[
717 "function_definition",
718 "class_declaration",
719 "method_declaration",
720 "interface_declaration",
721 "trait_declaration",
722 "enum_declaration",
723 "namespace_definition",
724 ],
725 container_node_types: &[
726 "declaration_list",
727 "enum_declaration_list",
728 "compound_statement",
729 ],
730 call_entity_identifiers: &[],
731 suppressed_nested_entities: &[],
732 scope_boundary_types: &[],
733 get_language: get_php,
734 scope_resolve: Some(&PHP_SCOPE_CONFIG),
735};
736
737#[cfg(feature = "lang-fortran")]
738static FORTRAN_CONFIG: LanguageConfig = LanguageConfig {
739 id: "fortran",
740 extensions: &[".f90", ".f95", ".f03", ".f08", ".f", ".for"],
741 entity_node_types: &[
742 "function",
743 "subroutine",
744 "module",
745 "program",
746 "interface",
747 "type_declaration",
748 ],
749 container_node_types: &["module", "program", "internal_procedures"],
750 call_entity_identifiers: &[],
751 suppressed_nested_entities: &[],
752 scope_boundary_types: &[],
753 get_language: get_fortran,
754 scope_resolve: None,
755};
756
757#[cfg(feature = "lang-swift")]
758static SWIFT_CONFIG: LanguageConfig = LanguageConfig {
759 id: "swift",
760 extensions: &[".swift"],
761 entity_node_types: &[
762 "function_declaration",
763 "class_declaration",
764 "protocol_declaration",
765 "struct_declaration",
766 "enum_declaration",
767 "init_declaration",
768 "deinit_declaration",
769 "subscript_declaration",
770 "typealias_declaration",
771 "property_declaration",
772 "operator_declaration",
773 "associatedtype_declaration",
774 ],
775 container_node_types: &[
776 "class_body",
777 "protocol_body",
778 "enum_class_body",
779 "struct_body",
780 "function_body",
781 "computed_property",
782 ],
783 call_entity_identifiers: &[],
784 suppressed_nested_entities: SWIFT_SUPPRESSED_NESTED,
785 scope_boundary_types: &[],
786 get_language: get_swift,
787 scope_resolve: Some(&SWIFT_SCOPE_CONFIG),
788};
789
790#[cfg(feature = "lang-elixir")]
791static ELIXIR_CONFIG: LanguageConfig = LanguageConfig {
792 id: "elixir",
793 extensions: &[".ex", ".exs"],
794 entity_node_types: &[],
795 container_node_types: &["do_block"],
796 call_entity_identifiers: &[
797 "defmodule",
798 "def",
799 "defp",
800 "defmacro",
801 "defmacrop",
802 "defguard",
803 "defguardp",
804 "defprotocol",
805 "defimpl",
806 "defstruct",
807 "defexception",
808 "defdelegate",
809 ],
810 suppressed_nested_entities: &[],
811 scope_boundary_types: &[],
812 get_language: get_elixir,
813 scope_resolve: None,
814};
815
816#[cfg(feature = "lang-bash")]
817static BASH_CONFIG: LanguageConfig = LanguageConfig {
818 id: "bash",
819 extensions: &[".sh"],
820 entity_node_types: &["function_definition"],
821 container_node_types: &["compound_statement"],
822 call_entity_identifiers: &[],
823 suppressed_nested_entities: &[],
824 scope_boundary_types: &[],
825 get_language: get_bash,
826 scope_resolve: Some(&BASH_SCOPE_CONFIG),
827};
828
829#[cfg(feature = "lang-hcl")]
830static HCL_CONFIG: LanguageConfig = LanguageConfig {
831 id: "hcl",
832 extensions: &[".hcl", ".tf", ".tfvars"],
833 entity_node_types: &["block", "attribute"],
834 container_node_types: &["body"],
835 call_entity_identifiers: &[],
836 suppressed_nested_entities: &[SuppressedNestedEntity {
837 parent_entity_node_type: "block",
838 child_entity_node_type: "attribute",
839 }],
840 scope_boundary_types: &[],
841 get_language: get_hcl,
842 scope_resolve: None,
843};
844
845#[cfg(feature = "lang-kotlin")]
846static KOTLIN_CONFIG: LanguageConfig = LanguageConfig {
847 id: "kotlin",
848 extensions: &[".kt", ".kts"],
849 entity_node_types: &[
850 "function_declaration",
851 "class_declaration",
852 "object_declaration",
853 "property_declaration",
854 "companion_object",
855 "secondary_constructor",
856 "type_alias",
857 ],
858 container_node_types: &["class_body", "enum_class_body"],
859 call_entity_identifiers: &[],
860 suppressed_nested_entities: &[],
861 scope_boundary_types: &[],
862 get_language: get_kotlin,
863 scope_resolve: Some(&KOTLIN_SCOPE_CONFIG),
864};
865
866#[cfg(feature = "lang-xml")]
867static XML_CONFIG: LanguageConfig = LanguageConfig {
868 id: "xml",
869 extensions: &[
870 ".xml", ".plist", ".svg", ".xhtml", ".csproj", ".fsproj", ".vbproj", ".props", ".targets",
871 ".nuspec", ".resx", ".xaml", ".axml",
872 ],
873 entity_node_types: &["element"],
874 container_node_types: &["content"],
875 call_entity_identifiers: &[],
876 suppressed_nested_entities: &[],
877 scope_boundary_types: &[],
878 get_language: get_xml,
879 scope_resolve: None,
880};
881
882#[cfg(feature = "lang-dart")]
883static DART_CONFIG: LanguageConfig = LanguageConfig {
884 id: "dart",
885 extensions: &[".dart"],
886 entity_node_types: &[
887 "class_declaration",
888 "mixin_declaration",
889 "extension_declaration",
890 "extension_type_declaration",
891 "enum_declaration",
892 "type_alias",
893 "class_member",
894 "function_signature",
895 "getter_signature",
896 "setter_signature",
897 ],
898 container_node_types: &["class_body", "enum_body", "extension_body"],
899 call_entity_identifiers: &[],
900 suppressed_nested_entities: &[],
901 scope_boundary_types: &[],
902 get_language: get_dart,
903 scope_resolve: Some(&DART_SCOPE_CONFIG),
904};
905
906#[cfg(feature = "lang-perl")]
907static PERL_CONFIG: LanguageConfig = LanguageConfig {
908 id: "perl",
909 extensions: &[".pl", ".pm", ".t"],
910 entity_node_types: &["subroutine_declaration_statement", "package_statement"],
911 container_node_types: &["block"],
912 call_entity_identifiers: &[],
913 suppressed_nested_entities: &[],
914 scope_boundary_types: &[],
915 get_language: get_perl,
916 scope_resolve: None,
917};
918
919#[cfg(feature = "lang-ocaml")]
920static OCAML_CONFIG: LanguageConfig = LanguageConfig {
921 id: "ocaml",
922 extensions: &[".ml"],
923 entity_node_types: &[
924 "value_definition",
925 "module_definition",
926 "module_type_definition",
927 "type_definition",
928 "exception_definition",
929 "class_definition",
930 "class_type_definition",
931 "external",
932 ],
933 container_node_types: &["structure", "module_binding"],
934 call_entity_identifiers: &[],
935 suppressed_nested_entities: &[],
936 scope_boundary_types: &[],
937 get_language: get_ocaml,
938 scope_resolve: None,
939};
940
941#[cfg(feature = "lang-ocaml")]
942static OCAML_INTERFACE_CONFIG: LanguageConfig = LanguageConfig {
943 id: "ocaml_interface",
944 extensions: &[".mli"],
945 entity_node_types: &[
946 "value_specification",
947 "module_definition",
948 "module_type_definition",
949 "type_definition",
950 "exception_definition",
951 "class_definition",
952 "class_type_definition",
953 "external",
954 ],
955 container_node_types: &["signature", "module_binding"],
956 call_entity_identifiers: &[],
957 suppressed_nested_entities: &[],
958 scope_boundary_types: &[],
959 get_language: get_ocaml_interface,
960 scope_resolve: None,
961};
962
963#[cfg(feature = "lang-scala")]
964static SCALA_CONFIG: LanguageConfig = LanguageConfig {
965 id: "scala",
966 extensions: &[".scala", ".sc", ".sbt", ".kojo", ".mill"],
967 entity_node_types: &[
968 "class_definition",
969 "object_definition",
970 "trait_definition",
971 "enum_definition",
972 "function_definition",
973 "function_declaration",
974 "val_definition",
975 "given_definition",
976 "extension_definition",
977 "type_definition",
978 "package_object",
979 ],
980 container_node_types: &["template_body", "enum_body", "with_template_body"],
981 call_entity_identifiers: &[],
982 suppressed_nested_entities: &[],
983 scope_boundary_types: &[],
984 get_language: get_scala,
985 scope_resolve: Some(&SCALA_SCOPE_CONFIG),
986};
987
988#[cfg(feature = "lang-zig")]
989static ZIG_CONFIG: LanguageConfig = LanguageConfig {
990 id: "zig",
991 extensions: &[".zig"],
992 entity_node_types: &[
993 "function_declaration",
994 "test_declaration",
995 "variable_declaration",
996 ],
997 container_node_types: &["block"],
998 call_entity_identifiers: &[],
999 suppressed_nested_entities: &[SuppressedNestedEntity {
1000 parent_entity_node_type: "function_declaration",
1001 child_entity_node_type: "variable_declaration",
1002 }],
1003 scope_boundary_types: &[],
1004 get_language: get_zig,
1005 scope_resolve: Some(&ZIG_SCOPE_CONFIG),
1006};
1007
1008#[cfg(feature = "lang-nix")]
1009static NIX_CONFIG: LanguageConfig = LanguageConfig {
1010 id: "nix",
1011 extensions: &[".nix"],
1012 entity_node_types: &["binding", "inherit", "inherit_from"],
1013 container_node_types: &["binding_set"],
1014 call_entity_identifiers: &[],
1015 suppressed_nested_entities: &[],
1016 scope_boundary_types: &[],
1017 get_language: get_nix,
1018 scope_resolve: None,
1019};
1020
1021#[cfg(feature = "lang-haskell")]
1022static HASKELL_CONFIG: LanguageConfig = LanguageConfig {
1023 id: "haskell",
1024 extensions: &[".hs"],
1025 entity_node_types: &[
1026 "function", "signature", "data_type", "newtype", "class", "instance", "type_synomym", "foreign_import", "foreign_export", "pattern_synonym", "type_family", "data_family", "fixity", ],
1040 container_node_types: &["declarations", "class_body", "instance_body"],
1041 call_entity_identifiers: &[],
1042 suppressed_nested_entities: &[],
1043 scope_boundary_types: &["function"],
1044 get_language: get_haskell,
1045 scope_resolve: None,
1046};
1047
1048static PYTHON_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1051 class_scope_nodes: &["class_definition"],
1052 impl_scope_nodes: &[],
1053 function_scope_nodes: &["function_definition"],
1054 class_name_field: ClassNameField::Simple("name"),
1055
1056 assignment_rules: &[
1057 AssignmentRule {
1058 node_kind: "assignment",
1059 strategy: AssignmentStrategy::LeftRight,
1060 },
1061 AssignmentRule {
1062 node_kind: "expression_statement",
1063 strategy: AssignmentStrategy::LeftRight,
1064 },
1065 ],
1066 assignment_recurse_into: &["block"],
1067
1068 param_rules: &[
1069 ParamRule {
1070 node_kind: "typed_parameter",
1071 name_field: ParamNameField::WithFallback("name"),
1072 type_field: "type",
1073 skip_names: &["self", "cls"],
1074 },
1075 ParamRule {
1076 node_kind: "typed_default_parameter",
1077 name_field: ParamNameField::WithFallback("name"),
1078 type_field: "type",
1079 skip_names: &["self", "cls"],
1080 },
1081 ],
1082
1083 return_type_field: None,
1084
1085 call_nodes: &["call"],
1086 call_style: CallNodeStyle::FunctionField("function"),
1087 new_expr_nodes: &[],
1088 new_expr_type_field: "constructor",
1089 composite_literal_nodes: &[],
1090 member_access: &[MemberAccess {
1091 node_kind: "attribute",
1092 object_field: "object",
1093 property_field: "attribute",
1094 }],
1095 scoped_call_nodes: &[],
1096
1097 self_keywords: &["self", "cls"],
1098
1099 init_strategy: InitStrategy::ConstructorBody {
1100 class_nodes: &["class_definition"],
1101 init_names: &["__init__"],
1102 init_node_kind: "function_definition",
1103 self_keyword: "self",
1104 access_kind: "attribute",
1105 obj_field: "object",
1106 prop_field: "attribute",
1107 },
1108
1109 import_extractor: None, external_method: false,
1111
1112 builtins: &[
1113 "print",
1114 "len",
1115 "range",
1116 "str",
1117 "int",
1118 "float",
1119 "bool",
1120 "list",
1121 "dict",
1122 "set",
1123 "tuple",
1124 "type",
1125 "super",
1126 "isinstance",
1127 "issubclass",
1128 "getattr",
1129 "setattr",
1130 "hasattr",
1131 "delattr",
1132 "open",
1133 "input",
1134 "map",
1135 "filter",
1136 "zip",
1137 "enumerate",
1138 "sorted",
1139 "reversed",
1140 "min",
1141 "max",
1142 "sum",
1143 "any",
1144 "all",
1145 "abs",
1146 "round",
1147 "format",
1148 "repr",
1149 "id",
1150 "hash",
1151 "ValueError",
1152 "TypeError",
1153 "KeyError",
1154 "RuntimeError",
1155 "Exception",
1156 "StopIteration",
1157 ],
1158};
1159
1160static TS_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1161 class_scope_nodes: &["class_declaration", "abstract_class_declaration"],
1162 impl_scope_nodes: &[],
1163 function_scope_nodes: &[
1164 "function_declaration",
1165 "method_definition",
1166 "arrow_function",
1167 ],
1168 class_name_field: ClassNameField::Simple("name"),
1169
1170 assignment_rules: &[
1171 AssignmentRule {
1172 node_kind: "lexical_declaration",
1173 strategy: AssignmentStrategy::Declarators,
1174 },
1175 AssignmentRule {
1176 node_kind: "variable_declaration",
1177 strategy: AssignmentStrategy::Declarators,
1178 },
1179 AssignmentRule {
1180 node_kind: "expression_statement",
1181 strategy: AssignmentStrategy::LeftRight,
1182 },
1183 ],
1184 assignment_recurse_into: &["statement_block"],
1185
1186 param_rules: &[
1187 ParamRule {
1188 node_kind: "required_parameter",
1189 name_field: ParamNameField::WithFallback("pattern"),
1190 type_field: "type",
1191 skip_names: &["this"],
1192 },
1193 ParamRule {
1194 node_kind: "optional_parameter",
1195 name_field: ParamNameField::WithFallback("pattern"),
1196 type_field: "type",
1197 skip_names: &["this"],
1198 },
1199 ],
1200
1201 return_type_field: Some("return_type"),
1202
1203 call_nodes: &["call_expression"],
1204 call_style: CallNodeStyle::FunctionField("function"),
1205 new_expr_nodes: &["new_expression"],
1206 new_expr_type_field: "constructor",
1207 composite_literal_nodes: &[],
1208 member_access: &[MemberAccess {
1209 node_kind: "member_expression",
1210 object_field: "object",
1211 property_field: "property",
1212 }],
1213 scoped_call_nodes: &[],
1214
1215 self_keywords: &["this"],
1216
1217 init_strategy: InitStrategy::ConstructorBody {
1218 class_nodes: &["class_declaration", "abstract_class_declaration"],
1219 init_names: &["constructor"],
1220 init_node_kind: "method_definition",
1221 self_keyword: "this",
1222 access_kind: "member_expression",
1223 obj_field: "object",
1224 prop_field: "property",
1225 },
1226
1227 import_extractor: None,
1228 external_method: false,
1229
1230 builtins: &[
1231 "console",
1232 "parseInt",
1233 "parseFloat",
1234 "isNaN",
1235 "isFinite",
1236 "setTimeout",
1237 "setInterval",
1238 "clearTimeout",
1239 "clearInterval",
1240 "Promise",
1241 "Array",
1242 "Object",
1243 "Map",
1244 "Set",
1245 "WeakMap",
1246 "WeakSet",
1247 "JSON",
1248 "Math",
1249 "Date",
1250 "RegExp",
1251 "Error",
1252 "TypeError",
1253 "RangeError",
1254 "Symbol",
1255 "Proxy",
1256 "Reflect",
1257 "String",
1258 "Number",
1259 "Boolean",
1260 "BigInt",
1261 "require",
1262 "module",
1263 "exports",
1264 "process",
1265 "Buffer",
1266 "global",
1267 "window",
1268 "document",
1269 "fetch",
1270 "Response",
1271 "Request",
1272 "Headers",
1273 "URL",
1274 "undefined",
1275 "encodeURIComponent",
1276 "decodeURIComponent",
1277 "encodeURI",
1278 "decodeURI",
1279 "AbortController",
1280 "TextEncoder",
1281 "TextDecoder",
1282 "Uint8Array",
1283 "Int8Array",
1284 "Float32Array",
1285 "ArrayBuffer",
1286 "DataView",
1287 "ReadableStream",
1288 "WritableStream",
1289 "Blob",
1290 "File",
1291 "FormData",
1292 "URLSearchParams",
1293 "Event",
1294 "EventTarget",
1295 "CustomEvent",
1296 "queueMicrotask",
1297 "structuredClone",
1298 "atob",
1299 "btoa",
1300 "crypto",
1301 "performance",
1302 "navigator",
1303 ],
1304};
1305
1306static RUST_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1307 class_scope_nodes: &["struct_item"],
1308 impl_scope_nodes: &["impl_item"],
1309 function_scope_nodes: &["function_item"],
1310 class_name_field: ClassNameField::Simple("name"),
1311
1312 assignment_rules: &[AssignmentRule {
1313 node_kind: "let_declaration",
1314 strategy: AssignmentStrategy::PatternBased,
1315 }],
1316 assignment_recurse_into: &["block", "expression_statement"],
1317
1318 param_rules: &[ParamRule {
1319 node_kind: "parameter",
1320 name_field: ParamNameField::RustPattern,
1321 type_field: "type",
1322 skip_names: &["self"],
1323 }],
1324
1325 return_type_field: Some("return_type"),
1326
1327 call_nodes: &["call_expression"],
1328 call_style: CallNodeStyle::FunctionField("function"),
1329 new_expr_nodes: &[],
1330 new_expr_type_field: "constructor",
1331 composite_literal_nodes: &[],
1332 member_access: &[MemberAccess {
1333 node_kind: "field_expression",
1334 object_field: "value",
1335 property_field: "field",
1336 }],
1337 scoped_call_nodes: &["scoped_identifier"],
1338
1339 self_keywords: &["self"],
1340
1341 init_strategy: InitStrategy::StructFields {
1342 struct_nodes: &["struct_item"],
1343 },
1344
1345 import_extractor: None,
1346 external_method: false,
1347
1348 builtins: &[
1349 "println",
1350 "eprintln",
1351 "print",
1352 "eprint",
1353 "dbg",
1354 "format",
1355 "write",
1356 "writeln",
1357 "vec",
1358 "panic",
1359 "todo",
1360 "unimplemented",
1361 "unreachable",
1362 "assert",
1363 "assert_eq",
1364 "assert_ne",
1365 "debug_assert",
1366 "Some",
1367 "None",
1368 "Ok",
1369 "Err",
1370 "Box",
1371 "Vec",
1372 "String",
1373 "HashMap",
1374 "HashSet",
1375 "Arc",
1376 "Rc",
1377 "Mutex",
1378 "RwLock",
1379 "Cell",
1380 "RefCell",
1381 "Option",
1382 "Result",
1383 "Iterator",
1384 "IntoIterator",
1385 "Clone",
1386 "Copy",
1387 "Debug",
1388 "Display",
1389 "Default",
1390 "From",
1391 "Into",
1392 "TryFrom",
1393 "TryInto",
1394 "Send",
1395 "Sync",
1396 "Sized",
1397 "Unpin",
1398 "cfg",
1399 "derive",
1400 "include",
1401 "env",
1402 ],
1403};
1404
1405static GO_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1406 class_scope_nodes: &["type_declaration"],
1407 impl_scope_nodes: &[],
1408 function_scope_nodes: &["function_declaration", "method_declaration"],
1409 class_name_field: ClassNameField::TypeSpec {
1410 spec_kind: "type_spec",
1411 field: "name",
1412 },
1413
1414 assignment_rules: &[
1415 AssignmentRule {
1416 node_kind: "short_var_declaration",
1417 strategy: AssignmentStrategy::ShortVar,
1418 },
1419 AssignmentRule {
1420 node_kind: "var_declaration",
1421 strategy: AssignmentStrategy::VarSpec,
1422 },
1423 ],
1424 assignment_recurse_into: &["block"],
1425
1426 param_rules: &[ParamRule {
1427 node_kind: "parameter_declaration",
1428 name_field: ParamNameField::Simple("name"),
1429 type_field: "type",
1430 skip_names: &[],
1431 }],
1432
1433 return_type_field: Some("result"),
1434
1435 call_nodes: &["call_expression"],
1436 call_style: CallNodeStyle::FunctionField("function"),
1437 new_expr_nodes: &[],
1438 new_expr_type_field: "constructor",
1439 composite_literal_nodes: &["composite_literal"],
1440 member_access: &[MemberAccess {
1441 node_kind: "selector_expression",
1442 object_field: "operand",
1443 property_field: "field",
1444 }],
1445 scoped_call_nodes: &[],
1446
1447 self_keywords: &[],
1448
1449 init_strategy: InitStrategy::StructFields {
1450 struct_nodes: &["type_declaration"],
1451 },
1452
1453 import_extractor: None,
1454 external_method: true,
1455
1456 builtins: &[
1457 "fmt",
1458 "log",
1459 "os",
1460 "io",
1461 "strings",
1462 "strconv",
1463 "bytes",
1464 "make",
1465 "len",
1466 "cap",
1467 "append",
1468 "copy",
1469 "delete",
1470 "close",
1471 "panic",
1472 "recover",
1473 "new",
1474 "print",
1475 "println",
1476 "error",
1477 "string",
1478 "int",
1479 "int8",
1480 "int16",
1481 "int32",
1482 "int64",
1483 "uint",
1484 "uint8",
1485 "uint16",
1486 "uint32",
1487 "uint64",
1488 "float32",
1489 "float64",
1490 "complex64",
1491 "complex128",
1492 "bool",
1493 "byte",
1494 "rune",
1495 "uintptr",
1496 "Println",
1497 "Printf",
1498 "Sprintf",
1499 "Fprintf",
1500 "Errorf",
1501 ],
1502};
1503
1504static JAVA_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1507 class_scope_nodes: &[
1508 "class_declaration",
1509 "interface_declaration",
1510 "enum_declaration",
1511 ],
1512 impl_scope_nodes: &[],
1513 function_scope_nodes: &["method_declaration", "constructor_declaration"],
1514 class_name_field: ClassNameField::Simple("name"),
1515
1516 assignment_rules: &[
1517 AssignmentRule {
1518 node_kind: "local_variable_declaration",
1519 strategy: AssignmentStrategy::Declarators,
1520 },
1521 AssignmentRule {
1522 node_kind: "expression_statement",
1523 strategy: AssignmentStrategy::LeftRight,
1524 },
1525 ],
1526 assignment_recurse_into: &["block"],
1527
1528 param_rules: &[ParamRule {
1529 node_kind: "formal_parameter",
1530 name_field: ParamNameField::Simple("name"),
1531 type_field: "type",
1532 skip_names: &[],
1533 }],
1534
1535 return_type_field: Some("type"),
1536
1537 call_nodes: &["method_invocation"],
1538 call_style: CallNodeStyle::DirectMethod {
1539 object_field: "object",
1540 method_field: "name",
1541 },
1542 new_expr_nodes: &["object_creation_expression"],
1543 new_expr_type_field: "type",
1544 composite_literal_nodes: &[],
1545 member_access: &[MemberAccess {
1546 node_kind: "method_invocation",
1547 object_field: "object",
1548 property_field: "name",
1549 }],
1550 scoped_call_nodes: &[],
1551
1552 self_keywords: &["this"],
1553
1554 init_strategy: InitStrategy::None,
1555 import_extractor: None,
1556 external_method: false,
1557
1558 builtins: &[
1559 "System",
1560 "String",
1561 "Integer",
1562 "Long",
1563 "Double",
1564 "Float",
1565 "Boolean",
1566 "Object",
1567 "Class",
1568 "Math",
1569 "Collections",
1570 "Arrays",
1571 "List",
1572 "Map",
1573 "Set",
1574 "ArrayList",
1575 "HashMap",
1576 "HashSet",
1577 "Optional",
1578 "Stream",
1579 "Exception",
1580 "RuntimeException",
1581 "NullPointerException",
1582 "println",
1583 "printf",
1584 "format",
1585 ],
1586};
1587
1588static CSHARP_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1589 class_scope_nodes: &[
1590 "class_declaration",
1591 "interface_declaration",
1592 "struct_declaration",
1593 "enum_declaration",
1594 ],
1595 impl_scope_nodes: &[],
1596 function_scope_nodes: &["method_declaration", "constructor_declaration"],
1597 class_name_field: ClassNameField::Simple("name"),
1598
1599 assignment_rules: &[
1600 AssignmentRule {
1601 node_kind: "local_declaration_statement",
1602 strategy: AssignmentStrategy::Declarators,
1603 },
1604 AssignmentRule {
1605 node_kind: "expression_statement",
1606 strategy: AssignmentStrategy::LeftRight,
1607 },
1608 ],
1609 assignment_recurse_into: &["block"],
1610
1611 param_rules: &[ParamRule {
1612 node_kind: "parameter",
1613 name_field: ParamNameField::Simple("name"),
1614 type_field: "type",
1615 skip_names: &[],
1616 }],
1617
1618 return_type_field: Some("type"),
1619
1620 call_nodes: &["invocation_expression"],
1621 call_style: CallNodeStyle::FunctionField("function"),
1622 new_expr_nodes: &["object_creation_expression"],
1623 new_expr_type_field: "type",
1624 composite_literal_nodes: &[],
1625 member_access: &[MemberAccess {
1626 node_kind: "member_access_expression",
1627 object_field: "expression",
1628 property_field: "name",
1629 }],
1630 scoped_call_nodes: &[],
1631
1632 self_keywords: &["this"],
1633
1634 init_strategy: InitStrategy::None,
1635 import_extractor: None,
1636 external_method: false,
1637
1638 builtins: &[
1639 "Console",
1640 "String",
1641 "Int32",
1642 "Int64",
1643 "Double",
1644 "Boolean",
1645 "Object",
1646 "Math",
1647 "List",
1648 "Dictionary",
1649 "HashSet",
1650 "Task",
1651 "Async",
1652 "Exception",
1653 "ArgumentException",
1654 "WriteLine",
1655 "ReadLine",
1656 "ToString",
1657 "Equals",
1658 ],
1659};
1660
1661static CPP_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1662 class_scope_nodes: &["class_specifier", "struct_specifier"],
1663 impl_scope_nodes: &[],
1664 function_scope_nodes: &["function_definition"],
1665 class_name_field: ClassNameField::Simple("name"),
1666
1667 assignment_rules: &[
1668 AssignmentRule {
1669 node_kind: "declaration",
1670 strategy: AssignmentStrategy::Declarators,
1671 },
1672 AssignmentRule {
1673 node_kind: "expression_statement",
1674 strategy: AssignmentStrategy::LeftRight,
1675 },
1676 ],
1677 assignment_recurse_into: &["compound_statement"],
1678
1679 param_rules: &[ParamRule {
1680 node_kind: "parameter_declaration",
1681 name_field: ParamNameField::Simple("declarator"),
1682 type_field: "type",
1683 skip_names: &[],
1684 }],
1685
1686 return_type_field: Some("type"),
1687
1688 call_nodes: &["call_expression"],
1689 call_style: CallNodeStyle::FunctionField("function"),
1690 new_expr_nodes: &["new_expression"],
1691 new_expr_type_field: "type",
1692 composite_literal_nodes: &[],
1693 member_access: &[MemberAccess {
1694 node_kind: "field_expression",
1695 object_field: "argument",
1696 property_field: "field",
1697 }],
1698 scoped_call_nodes: &["qualified_identifier"],
1699
1700 self_keywords: &["this"],
1701
1702 init_strategy: InitStrategy::StructFields {
1703 struct_nodes: &["class_specifier", "struct_specifier"],
1704 },
1705 import_extractor: None,
1706 external_method: false,
1707
1708 builtins: &[
1709 "std",
1710 "cout",
1711 "cin",
1712 "endl",
1713 "printf",
1714 "scanf",
1715 "malloc",
1716 "free",
1717 "string",
1718 "vector",
1719 "map",
1720 "set",
1721 "pair",
1722 "make_pair",
1723 "shared_ptr",
1724 "unique_ptr",
1725 "make_shared",
1726 "make_unique",
1727 "nullptr",
1728 "size_t",
1729 "int",
1730 "char",
1731 "double",
1732 "float",
1733 "bool",
1734 ],
1735};
1736
1737static RUBY_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1738 class_scope_nodes: &["class", "module"],
1739 impl_scope_nodes: &[],
1740 function_scope_nodes: &["method", "singleton_method"],
1741 class_name_field: ClassNameField::Simple("name"),
1742
1743 assignment_rules: &[AssignmentRule {
1744 node_kind: "assignment",
1745 strategy: AssignmentStrategy::LeftRight,
1746 }],
1747 assignment_recurse_into: &["body_statement"],
1748
1749 param_rules: &[],
1750
1751 return_type_field: None,
1752
1753 call_nodes: &["call"],
1754 call_style: CallNodeStyle::DirectMethod {
1755 object_field: "receiver",
1756 method_field: "method",
1757 },
1758 new_expr_nodes: &[],
1759 new_expr_type_field: "constructor",
1760 composite_literal_nodes: &[],
1761 member_access: &[MemberAccess {
1762 node_kind: "call",
1763 object_field: "receiver",
1764 property_field: "method",
1765 }],
1766 scoped_call_nodes: &["scope_resolution"],
1767
1768 self_keywords: &["self"],
1769
1770 init_strategy: InitStrategy::None,
1771 import_extractor: None,
1772 external_method: false,
1773
1774 builtins: &[
1775 "puts",
1776 "print",
1777 "p",
1778 "require",
1779 "require_relative",
1780 "include",
1781 "extend",
1782 "attr_accessor",
1783 "attr_reader",
1784 "attr_writer",
1785 "raise",
1786 "rescue",
1787 "yield",
1788 "block_given?",
1789 "Array",
1790 "Hash",
1791 "String",
1792 "Integer",
1793 "Float",
1794 "Symbol",
1795 "nil",
1796 "true",
1797 "false",
1798 ],
1799};
1800
1801static KOTLIN_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1802 class_scope_nodes: &[
1803 "class_declaration",
1804 "object_declaration",
1805 "companion_object",
1806 ],
1807 impl_scope_nodes: &[],
1808 function_scope_nodes: &["function_declaration", "secondary_constructor"],
1809 class_name_field: ClassNameField::Simple("name"),
1810
1811 assignment_rules: &[AssignmentRule {
1812 node_kind: "property_declaration",
1813 strategy: AssignmentStrategy::Declarators,
1814 }],
1815 assignment_recurse_into: &["statements", "block", "function_body"],
1816
1817 param_rules: &[ParamRule {
1818 node_kind: "parameter",
1819 name_field: ParamNameField::Simple("name"),
1820 type_field: "type",
1821 skip_names: &[],
1822 }],
1823
1824 return_type_field: Some("type"),
1825
1826 call_nodes: &["call_expression"],
1827 call_style: CallNodeStyle::FirstChild,
1828 new_expr_nodes: &[],
1829 new_expr_type_field: "constructor",
1830 composite_literal_nodes: &[],
1831 member_access: &[MemberAccess {
1832 node_kind: "navigation_expression",
1833 object_field: "expression",
1834 property_field: "navigation_suffix",
1835 }],
1836 scoped_call_nodes: &[],
1837
1838 self_keywords: &["this"],
1839
1840 init_strategy: InitStrategy::ConstructorBody {
1841 class_nodes: &["class_declaration"],
1842 init_names: &["init"],
1843 init_node_kind: "anonymous_initializer",
1844 self_keyword: "this",
1845 access_kind: "navigation_expression",
1846 obj_field: "expression",
1847 prop_field: "navigation_suffix",
1848 },
1849 import_extractor: None,
1850 external_method: false,
1851
1852 builtins: &[
1853 "println",
1854 "print",
1855 "listOf",
1856 "mapOf",
1857 "setOf",
1858 "arrayOf",
1859 "mutableListOf",
1860 "mutableMapOf",
1861 "mutableSetOf",
1862 "String",
1863 "Int",
1864 "Long",
1865 "Double",
1866 "Float",
1867 "Boolean",
1868 "Any",
1869 "Unit",
1870 "Nothing",
1871 "Pair",
1872 "Triple",
1873 "require",
1874 "check",
1875 "error",
1876 "TODO",
1877 "emptyList",
1878 "emptyMap",
1879 "emptySet",
1880 "lazy",
1881 "run",
1882 "let",
1883 "also",
1884 "apply",
1885 "with",
1886 "takeIf",
1887 "takeUnless",
1888 "Throwable",
1889 "Exception",
1890 "RuntimeException",
1891 "IllegalArgumentException",
1892 "IllegalStateException",
1893 "UnsupportedOperationException",
1894 "Regex",
1895 "Sequence",
1896 "Iterable",
1897 "Iterator",
1898 "coroutineScope",
1899 "launch",
1900 "async",
1901 "withContext",
1902 "runBlocking",
1903 "Flow",
1904 "StateFlow",
1905 "SharedFlow",
1906 "Dispatchers",
1907 "Job",
1908 "SupervisorJob",
1909 "CoroutineScope",
1910 "suspend",
1911 "Channel",
1912 ],
1913};
1914
1915static PHP_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1916 class_scope_nodes: &[
1917 "class_declaration",
1918 "interface_declaration",
1919 "trait_declaration",
1920 ],
1921 impl_scope_nodes: &[],
1922 function_scope_nodes: &["function_definition", "method_declaration"],
1923 class_name_field: ClassNameField::Simple("name"),
1924
1925 assignment_rules: &[AssignmentRule {
1926 node_kind: "expression_statement",
1927 strategy: AssignmentStrategy::LeftRight,
1928 }],
1929 assignment_recurse_into: &["compound_statement"],
1930
1931 param_rules: &[ParamRule {
1932 node_kind: "simple_parameter",
1933 name_field: ParamNameField::Simple("name"),
1934 type_field: "type",
1935 skip_names: &[],
1936 }],
1937
1938 return_type_field: Some("return_type"),
1939
1940 call_nodes: &["function_call_expression", "member_call_expression"],
1941 call_style: CallNodeStyle::FunctionField("function"),
1942 new_expr_nodes: &["object_creation_expression"],
1943 new_expr_type_field: "type",
1944 composite_literal_nodes: &[],
1945 member_access: &[MemberAccess {
1946 node_kind: "member_call_expression",
1947 object_field: "object",
1948 property_field: "name",
1949 }],
1950 scoped_call_nodes: &["scoped_call_expression"],
1951
1952 self_keywords: &["$this"],
1953
1954 init_strategy: InitStrategy::None,
1955 import_extractor: None,
1956 external_method: false,
1957
1958 builtins: &[
1959 "echo",
1960 "print",
1961 "var_dump",
1962 "print_r",
1963 "isset",
1964 "unset",
1965 "empty",
1966 "array",
1967 "count",
1968 "strlen",
1969 "substr",
1970 "strpos",
1971 "is_null",
1972 "is_array",
1973 "is_string",
1974 "is_int",
1975 "Exception",
1976 "RuntimeException",
1977 "InvalidArgumentException",
1978 ],
1979};
1980
1981static SWIFT_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
1982 class_scope_nodes: &[
1983 "class_declaration",
1984 "protocol_declaration",
1985 "struct_declaration",
1986 "enum_declaration",
1987 ],
1988 impl_scope_nodes: &["extension_declaration"],
1989 function_scope_nodes: &[
1990 "function_declaration",
1991 "init_declaration",
1992 "deinit_declaration",
1993 "subscript_declaration",
1994 "property_declaration",
1995 ],
1996 class_name_field: ClassNameField::Simple("name"),
1997
1998 assignment_rules: &[AssignmentRule {
1999 node_kind: "property_declaration",
2000 strategy: AssignmentStrategy::Declarators,
2001 }],
2002 assignment_recurse_into: &[
2003 "function_body",
2004 "computed_property",
2005 "code_block",
2006 "statements",
2007 "if_statement",
2008 "guard_statement",
2009 "for_statement",
2010 "while_statement",
2011 "repeat_while_statement",
2012 "switch_statement",
2013 ],
2014
2015 param_rules: &[ParamRule {
2016 node_kind: "parameter",
2017 name_field: ParamNameField::Simple("name"),
2018 type_field: "type",
2019 skip_names: &[],
2020 }],
2021
2022 return_type_field: Some("return_type"),
2023
2024 call_nodes: &["call_expression"],
2025 call_style: CallNodeStyle::FirstChild,
2026 new_expr_nodes: &[],
2027 new_expr_type_field: "constructor",
2028 composite_literal_nodes: &[],
2029 member_access: &[MemberAccess {
2030 node_kind: "navigation_expression",
2031 object_field: "target",
2032 property_field: "suffix",
2033 }],
2034 scoped_call_nodes: &[],
2035
2036 self_keywords: &["self"],
2037
2038 init_strategy: InitStrategy::ConstructorBody {
2039 class_nodes: &["class_declaration", "struct_declaration"],
2040 init_names: &["init"],
2041 init_node_kind: "init_declaration",
2042 self_keyword: "self",
2043 access_kind: "navigation_expression",
2044 obj_field: "target",
2045 prop_field: "suffix",
2046 },
2047 import_extractor: None,
2048 external_method: false,
2049
2050 builtins: &[
2051 "print",
2052 "debugPrint",
2053 "fatalError",
2054 "precondition",
2055 "assert",
2056 "String",
2057 "Int",
2058 "Double",
2059 "Float",
2060 "Bool",
2061 "Array",
2062 "Dictionary",
2063 "Set",
2064 "Optional",
2065 "Result",
2066 "Error",
2067 "NSError",
2068 "nil",
2069 "Any",
2070 "AnyObject",
2071 "Void",
2072 "Never",
2073 "Data",
2074 "URL",
2075 "URLRequest",
2076 "URLSession",
2077 "Codable",
2078 "Hashable",
2079 "Equatable",
2080 "Comparable",
2081 "Identifiable",
2082 "Task",
2083 "MainActor",
2084 "Sendable",
2085 "min",
2086 "max",
2087 "abs",
2088 "zip",
2089 "stride",
2090 "type",
2091 "DispatchQueue",
2092 "NotificationCenter",
2093 "UserDefaults",
2094 "NSObject",
2095 "Bundle",
2096 "FileManager",
2097 "true",
2098 "false",
2099 ],
2100};
2101
2102static SCALA_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
2103 class_scope_nodes: &["class_definition", "object_definition", "trait_definition"],
2104 impl_scope_nodes: &[],
2105 function_scope_nodes: &["function_definition", "function_declaration"],
2106 class_name_field: ClassNameField::Simple("name"),
2107
2108 assignment_rules: &[AssignmentRule {
2109 node_kind: "val_definition",
2110 strategy: AssignmentStrategy::Declarators,
2111 }],
2112 assignment_recurse_into: &["template_body"],
2113
2114 param_rules: &[ParamRule {
2115 node_kind: "parameter",
2116 name_field: ParamNameField::Simple("name"),
2117 type_field: "type",
2118 skip_names: &[],
2119 }],
2120
2121 return_type_field: Some("return_type"),
2122
2123 call_nodes: &["call_expression"],
2124 call_style: CallNodeStyle::FunctionField("function"),
2125 new_expr_nodes: &[],
2126 new_expr_type_field: "constructor",
2127 composite_literal_nodes: &[],
2128 member_access: &[MemberAccess {
2129 node_kind: "field_expression",
2130 object_field: "value",
2131 property_field: "field",
2132 }],
2133 scoped_call_nodes: &[],
2134
2135 self_keywords: &["this"],
2136
2137 init_strategy: InitStrategy::None,
2138 import_extractor: None,
2139 external_method: false,
2140
2141 builtins: &[
2142 "println", "print", "require", "assert", "String", "Int", "Long", "Double", "Float",
2143 "Boolean", "List", "Map", "Set", "Seq", "Vector", "Option", "Some", "None", "Future",
2144 "Try", "Either", "Left", "Right",
2145 ],
2146};
2147
2148static DART_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
2151 class_scope_nodes: &["class_declaration", "mixin_declaration", "enum_declaration"],
2152 impl_scope_nodes: &[],
2153 function_scope_nodes: &["function_signature", "method_signature"],
2154 class_name_field: ClassNameField::Simple("name"),
2155
2156 assignment_rules: &[],
2157 assignment_recurse_into: &[],
2158
2159 param_rules: &[ParamRule {
2160 node_kind: "formal_parameter",
2161 name_field: ParamNameField::Simple("name"),
2162 type_field: "type",
2163 skip_names: &[],
2164 }],
2165
2166 return_type_field: None,
2167
2168 call_nodes: &["function_expression_body"],
2169 call_style: CallNodeStyle::FunctionField("function"),
2170 new_expr_nodes: &[],
2171 new_expr_type_field: "constructor",
2172 composite_literal_nodes: &[],
2173 member_access: &[],
2174 scoped_call_nodes: &[],
2175
2176 self_keywords: &["this"],
2177
2178 init_strategy: InitStrategy::None,
2179 import_extractor: None,
2180 external_method: false,
2181
2182 builtins: &[
2183 "print",
2184 "debugPrint",
2185 "String",
2186 "int",
2187 "double",
2188 "bool",
2189 "List",
2190 "Map",
2191 "Set",
2192 "Future",
2193 "Stream",
2194 ],
2195};
2196
2197static ZIG_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
2198 class_scope_nodes: &[],
2199 impl_scope_nodes: &[],
2200 function_scope_nodes: &["function_declaration", "test_declaration"],
2201 class_name_field: ClassNameField::Simple("name"),
2202
2203 assignment_rules: &[],
2204 assignment_recurse_into: &[],
2205
2206 param_rules: &[],
2207
2208 return_type_field: None,
2209
2210 call_nodes: &["call_expression"],
2211 call_style: CallNodeStyle::FunctionField("function"),
2212 new_expr_nodes: &[],
2213 new_expr_type_field: "constructor",
2214 composite_literal_nodes: &[],
2215 member_access: &[MemberAccess {
2216 node_kind: "field_expression",
2217 object_field: "object",
2218 property_field: "field",
2219 }],
2220 scoped_call_nodes: &[],
2221
2222 self_keywords: &[],
2223
2224 init_strategy: InitStrategy::None,
2225 import_extractor: None,
2226 external_method: false,
2227
2228 builtins: &[
2229 "std",
2230 "print",
2231 "debug",
2232 "assert",
2233 "expect",
2234 "allocator",
2235 "mem",
2236 "testing",
2237 ],
2238};
2239
2240static BASH_SCOPE_CONFIG: ScopeResolveConfig = ScopeResolveConfig {
2241 class_scope_nodes: &[],
2242 impl_scope_nodes: &[],
2243 function_scope_nodes: &["function_definition"],
2244 class_name_field: ClassNameField::Simple("name"),
2245
2246 assignment_rules: &[],
2247 assignment_recurse_into: &[],
2248
2249 param_rules: &[],
2250
2251 return_type_field: None,
2252
2253 call_nodes: &["command"],
2254 call_style: CallNodeStyle::FunctionField("name"),
2255 new_expr_nodes: &[],
2256 new_expr_type_field: "constructor",
2257 composite_literal_nodes: &[],
2258 member_access: &[],
2259 scoped_call_nodes: &[],
2260
2261 self_keywords: &[],
2262
2263 init_strategy: InitStrategy::None,
2264 import_extractor: None,
2265 external_method: false,
2266
2267 builtins: &[
2268 "echo", "printf", "cd", "ls", "cat", "grep", "sed", "awk", "if", "then", "else", "fi",
2269 "for", "while", "do", "done", "exit", "return", "export", "source", "eval",
2270 ],
2271};
2272
2273macro_rules! all_configs {
2274 () => {{
2275 &[
2276 #[cfg(feature = "lang-typescript")]
2277 &TYPESCRIPT_CONFIG,
2278 #[cfg(feature = "lang-typescript")]
2279 &TSX_CONFIG,
2280 #[cfg(feature = "lang-javascript")]
2281 &JAVASCRIPT_CONFIG,
2282 #[cfg(feature = "lang-python")]
2283 &PYTHON_CONFIG,
2284 #[cfg(feature = "lang-go")]
2285 &GO_CONFIG,
2286 #[cfg(feature = "lang-rust")]
2287 &RUST_CONFIG,
2288 #[cfg(feature = "lang-java")]
2289 &JAVA_CONFIG,
2290 #[cfg(feature = "lang-c")]
2291 &C_CONFIG,
2292 #[cfg(feature = "lang-cpp")]
2293 &CPP_CONFIG,
2294 #[cfg(feature = "lang-ruby")]
2295 &RUBY_CONFIG,
2296 #[cfg(feature = "lang-csharp")]
2297 &CSHARP_CONFIG,
2298 #[cfg(feature = "lang-php")]
2299 &PHP_CONFIG,
2300 #[cfg(feature = "lang-fortran")]
2301 &FORTRAN_CONFIG,
2302 #[cfg(feature = "lang-swift")]
2303 &SWIFT_CONFIG,
2304 #[cfg(feature = "lang-elixir")]
2305 &ELIXIR_CONFIG,
2306 #[cfg(feature = "lang-bash")]
2307 &BASH_CONFIG,
2308 #[cfg(feature = "lang-hcl")]
2309 &HCL_CONFIG,
2310 #[cfg(feature = "lang-kotlin")]
2311 &KOTLIN_CONFIG,
2312 #[cfg(feature = "lang-xml")]
2313 &XML_CONFIG,
2314 #[cfg(feature = "lang-dart")]
2315 &DART_CONFIG,
2316 #[cfg(feature = "lang-perl")]
2317 &PERL_CONFIG,
2318 #[cfg(feature = "lang-ocaml")]
2319 &OCAML_CONFIG,
2320 #[cfg(feature = "lang-ocaml")]
2321 &OCAML_INTERFACE_CONFIG,
2322 #[cfg(feature = "lang-scala")]
2323 &SCALA_CONFIG,
2324 #[cfg(feature = "lang-zig")]
2325 &ZIG_CONFIG,
2326 #[cfg(feature = "lang-nix")]
2327 &NIX_CONFIG,
2328 #[cfg(feature = "lang-haskell")]
2329 &HASKELL_CONFIG,
2330 ]
2331 }};
2332}
2333
2334static ALL_CONFIGS: &[&LanguageConfig] = all_configs!();
2335
2336pub fn get_language_config(extension: &str) -> Option<&'static LanguageConfig> {
2337 ALL_CONFIGS
2338 .iter()
2339 .find(|c| c.extensions.contains(&extension))
2340 .copied()
2341}
2342
2343pub fn get_all_code_extensions() -> &'static [&'static str] {
2344 static EXTENSIONS: std::sync::LazyLock<Vec<&'static str>> = std::sync::LazyLock::new(|| {
2347 ALL_CONFIGS
2348 .iter()
2349 .flat_map(|c| c.extensions.iter().copied())
2350 .collect()
2351 });
2352 &EXTENSIONS
2353}