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