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