scope_engine/language/
cpp.rs1use super::{LanguageAdapter, LanguageQueries};
2use tree_sitter::Language;
3
4pub struct CppAdapter;
5
6impl CppAdapter {
7 #[must_use]
8 pub const fn new() -> Self {
9 Self
10 }
11}
12
13impl Default for CppAdapter {
14 fn default() -> Self {
15 Self::new()
16 }
17}
18
19impl LanguageAdapter for CppAdapter {
20 fn language_name(&self) -> &'static str {
21 "cpp"
22 }
23 fn extensions(&self) -> &[&'static str] {
24 &["cpp", "cxx", "cc", "hpp", "hxx", "hh"]
25 }
26 fn language(&self) -> Language {
27 tree_sitter_cpp::LANGUAGE.into()
28 }
29 fn queries(&self) -> LanguageQueries {
30 LanguageQueries {
31 definitions: r"
32 (function_definition declarator: (function_declarator declarator: (identifier) @name)) @def
33 (class_specifier name: (type_identifier) @name) @def
34 (struct_specifier name: (type_identifier) @name) @def
35 (declaration declarator: (init_declarator declarator: (identifier) @name)) @def
36 ",
37 references: r"
38 (call_expression function: (identifier) @ref) @call
39 (call_expression function: (field_identifier) @ref) @call
40 (type_identifier) @ref
41 ",
42 }
43 }
44}