aboutsummaryrefslogtreecommitdiffstats
path: root/queries/cpp/locals.scm
blob: 69d2f2c26475c49a79556b089a5ff33e1faab8d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
;; Class / struct defintions
(class_specifier) @scope
(struct_specifier) @scope

(reference_declarator
  (identifier) @definition.var)

(struct_specifier
  name: (type_identifier) @definition.type) 

(struct_specifier
  name: (scoped_type_identifier
          name: (type_identifier) @definition.type))

(class_specifier
  name: (type_identifier) @definition.type) 

(class_specifier
  name: (scoped_type_identifier
          name: (type_identifier) @definition.type))

(alias_declaration
  name: (type_identifier) @definition.type)

;template <typename T>
(type_parameter_declaration
  (type_identifier) @definition.type)
     
;; Namespaces
(namespace_definition 
  name: (identifier) @definition.namespace
  body: (_) @scope)

((namespace_identifier) @reference
                        (set! reference.kind "namespace"))

;; Function defintions
(template_function
  name: (identifier) @definition.function) @scope

(template_method
  name: (field_identifier) @definition.method) @scope

(template_function
  name: (scoped_identifier
    name: (identifier) @definition.function)) @scope

(function_declarator
  declarator: (scoped_identifier
                name: (type_identifier) @definition.function)) @scope

(field_declaration
        declarator: (function_declarator
                       (field_identifier) @definition.method))

(lambda_expression) @scope

;; Control structures
(try_statement
  body: (_) @scope)

(catch_clause) @scope

(destructor_name
  name: (_) @constructor)