perchai-cli 2.4.116 → 2.4.118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -1
- package/bin/perch +12 -2
- package/dist/perch.mjs +2841 -1933
- package/dist/tree-sitter/NOTICE.md +264 -0
- package/dist/tree-sitter/manifest.json +134 -0
- package/dist/tree-sitter/queries/csharp.scm +64 -0
- package/dist/tree-sitter/queries/go.scm +77 -0
- package/dist/tree-sitter/queries/java.scm +57 -0
- package/dist/tree-sitter/queries/javascript.scm +152 -0
- package/dist/tree-sitter/queries/php.scm +85 -0
- package/dist/tree-sitter/queries/python.scm +51 -0
- package/dist/tree-sitter/queries/ruby.scm +101 -0
- package/dist/tree-sitter/queries/rust.scm +103 -0
- package/dist/tree-sitter/queries/tsx.scm +210 -0
- package/dist/tree-sitter/queries/typescript.scm +208 -0
- package/dist/tree-sitter/tree-sitter-csharp.wasm +0 -0
- package/dist/tree-sitter/tree-sitter-go.wasm +0 -0
- package/dist/tree-sitter/tree-sitter-java.wasm +0 -0
- package/dist/tree-sitter/tree-sitter-javascript.wasm +0 -0
- package/dist/tree-sitter/tree-sitter-php.wasm +0 -0
- package/dist/tree-sitter/tree-sitter-python.wasm +0 -0
- package/dist/tree-sitter/tree-sitter-ruby.wasm +0 -0
- package/dist/tree-sitter/tree-sitter-rust.wasm +0 -0
- package/dist/tree-sitter/tree-sitter-tsx.wasm +0 -0
- package/dist/tree-sitter/tree-sitter-typescript.wasm +0 -0
- package/dist/tree-sitter/web-tree-sitter.wasm +0 -0
- package/package.json +3 -2
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
; ---------------------------------------------------------------------------
|
|
2
|
+
; From tree-sitter-javascript 0.25.0, queries/tags.scm, with one Perch change:
|
|
3
|
+
; an object literal's members (pairs and method shorthand) are properties,
|
|
4
|
+
; not functions or methods, so the map does not list them as definitions
|
|
5
|
+
; of their own (methods count only in a class body).
|
|
6
|
+
; https://github.com/tree-sitter/tree-sitter-javascript
|
|
7
|
+
;
|
|
8
|
+
; The MIT License (MIT)
|
|
9
|
+
;
|
|
10
|
+
; Copyright (c) 2014 Max Brunsfeld
|
|
11
|
+
;
|
|
12
|
+
; Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
; of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
; in the Software without restriction, including without limitation the rights
|
|
15
|
+
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
; copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
; furnished to do so, subject to the following conditions:
|
|
18
|
+
;
|
|
19
|
+
; The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
; copies or substantial portions of the Software.
|
|
21
|
+
;
|
|
22
|
+
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
; SOFTWARE.
|
|
29
|
+
; ---------------------------------------------------------------------------
|
|
30
|
+
|
|
31
|
+
(class_body
|
|
32
|
+
(comment)* @doc
|
|
33
|
+
.
|
|
34
|
+
(method_definition
|
|
35
|
+
name: (property_identifier) @name) @definition.method
|
|
36
|
+
(#not-eq? @name "constructor")
|
|
37
|
+
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
38
|
+
(#select-adjacent! @doc @definition.method)
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
(object
|
|
42
|
+
(method_definition
|
|
43
|
+
name: (property_identifier) @name) @definition.property)
|
|
44
|
+
|
|
45
|
+
(
|
|
46
|
+
(comment)* @doc
|
|
47
|
+
.
|
|
48
|
+
[
|
|
49
|
+
(class
|
|
50
|
+
name: (_) @name)
|
|
51
|
+
(class_declaration
|
|
52
|
+
name: (_) @name)
|
|
53
|
+
] @definition.class
|
|
54
|
+
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
55
|
+
(#select-adjacent! @doc @definition.class)
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
(
|
|
59
|
+
(comment)* @doc
|
|
60
|
+
.
|
|
61
|
+
[
|
|
62
|
+
(function_expression
|
|
63
|
+
name: (identifier) @name)
|
|
64
|
+
(function_declaration
|
|
65
|
+
name: (identifier) @name)
|
|
66
|
+
(generator_function
|
|
67
|
+
name: (identifier) @name)
|
|
68
|
+
(generator_function_declaration
|
|
69
|
+
name: (identifier) @name)
|
|
70
|
+
] @definition.function
|
|
71
|
+
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
72
|
+
(#select-adjacent! @doc @definition.function)
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
(
|
|
76
|
+
(comment)* @doc
|
|
77
|
+
.
|
|
78
|
+
(lexical_declaration
|
|
79
|
+
(variable_declarator
|
|
80
|
+
name: (identifier) @name
|
|
81
|
+
value: [(arrow_function) (function_expression)]) @definition.function)
|
|
82
|
+
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
83
|
+
(#select-adjacent! @doc @definition.function)
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
(
|
|
87
|
+
(comment)* @doc
|
|
88
|
+
.
|
|
89
|
+
(variable_declaration
|
|
90
|
+
(variable_declarator
|
|
91
|
+
name: (identifier) @name
|
|
92
|
+
value: [(arrow_function) (function_expression)]) @definition.function)
|
|
93
|
+
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
94
|
+
(#select-adjacent! @doc @definition.function)
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
(assignment_expression
|
|
98
|
+
left: [
|
|
99
|
+
(identifier) @name
|
|
100
|
+
(member_expression
|
|
101
|
+
property: (property_identifier) @name)
|
|
102
|
+
]
|
|
103
|
+
right: [(arrow_function) (function_expression)]
|
|
104
|
+
) @definition.function
|
|
105
|
+
|
|
106
|
+
(pair
|
|
107
|
+
key: (property_identifier) @name
|
|
108
|
+
value: [(arrow_function) (function_expression)]) @definition.property
|
|
109
|
+
|
|
110
|
+
(
|
|
111
|
+
(call_expression
|
|
112
|
+
function: (identifier) @name) @reference.call
|
|
113
|
+
(#not-match? @name "^(require)$")
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
(call_expression
|
|
117
|
+
function: (member_expression
|
|
118
|
+
property: (property_identifier) @name)
|
|
119
|
+
arguments: (_) @reference.call)
|
|
120
|
+
|
|
121
|
+
(new_expression
|
|
122
|
+
constructor: (_) @name) @reference.class
|
|
123
|
+
|
|
124
|
+
(export_statement value: (assignment_expression left: (identifier) @name right: ([
|
|
125
|
+
(number)
|
|
126
|
+
(string)
|
|
127
|
+
(identifier)
|
|
128
|
+
(undefined)
|
|
129
|
+
(null)
|
|
130
|
+
(new_expression)
|
|
131
|
+
(binary_expression)
|
|
132
|
+
(call_expression)
|
|
133
|
+
]))) @definition.constant
|
|
134
|
+
|
|
135
|
+
; ---------------------------------------------------------------------------
|
|
136
|
+
; Perch additions (MIT): module imports (@import), exported constants and
|
|
137
|
+
; types, and a few more definitions and references.
|
|
138
|
+
; ---------------------------------------------------------------------------
|
|
139
|
+
(import_statement source: (string (string_fragment) @import))
|
|
140
|
+
(export_statement source: (string (string_fragment) @import))
|
|
141
|
+
((call_expression
|
|
142
|
+
function: (identifier) @_require
|
|
143
|
+
arguments: (arguments . (string (string_fragment) @import)))
|
|
144
|
+
(#eq? @_require "require"))
|
|
145
|
+
(call_expression
|
|
146
|
+
function: (import)
|
|
147
|
+
arguments: (arguments . (string (string_fragment) @import)))
|
|
148
|
+
(export_statement
|
|
149
|
+
declaration: (lexical_declaration
|
|
150
|
+
(variable_declarator name: (identifier) @name) @definition.constant))
|
|
151
|
+
(jsx_opening_element name: (identifier) @name) @reference.class
|
|
152
|
+
(jsx_self_closing_element name: (identifier) @name) @reference.class
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
; ---------------------------------------------------------------------------
|
|
2
|
+
; From tree-sitter-php 0.24.2, queries/tags.scm, unchanged.
|
|
3
|
+
; https://github.com/tree-sitter/tree-sitter-php
|
|
4
|
+
;
|
|
5
|
+
; The MIT License (MIT)
|
|
6
|
+
;
|
|
7
|
+
; Copyright (c) 2017 Josh Vera, GitHub
|
|
8
|
+
; Copyright (c) 2019 Max Brunsfeld, Amaan Qureshi, Christian Frøystad, Caleb White
|
|
9
|
+
;
|
|
10
|
+
; Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
; of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
; in the Software without restriction, including without limitation the rights
|
|
13
|
+
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
; copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
; furnished to do so, subject to the following conditions:
|
|
16
|
+
;
|
|
17
|
+
; The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
; copies or substantial portions of the Software.
|
|
19
|
+
;
|
|
20
|
+
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
; SOFTWARE.
|
|
27
|
+
; ---------------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
(namespace_definition
|
|
30
|
+
name: (namespace_name) @name) @definition.module
|
|
31
|
+
|
|
32
|
+
(interface_declaration
|
|
33
|
+
name: (name) @name) @definition.interface
|
|
34
|
+
|
|
35
|
+
(trait_declaration
|
|
36
|
+
name: (name) @name) @definition.interface
|
|
37
|
+
|
|
38
|
+
(class_declaration
|
|
39
|
+
name: (name) @name) @definition.class
|
|
40
|
+
|
|
41
|
+
(class_interface_clause [(name) (qualified_name)] @name) @reference.implementation
|
|
42
|
+
|
|
43
|
+
(property_declaration
|
|
44
|
+
(property_element (variable_name (name) @name))) @definition.field
|
|
45
|
+
|
|
46
|
+
(function_definition
|
|
47
|
+
name: (name) @name) @definition.function
|
|
48
|
+
|
|
49
|
+
(method_declaration
|
|
50
|
+
name: (name) @name) @definition.function
|
|
51
|
+
|
|
52
|
+
(object_creation_expression
|
|
53
|
+
[
|
|
54
|
+
(qualified_name (name) @name)
|
|
55
|
+
(variable_name (name) @name)
|
|
56
|
+
]) @reference.class
|
|
57
|
+
|
|
58
|
+
(function_call_expression
|
|
59
|
+
function: [
|
|
60
|
+
(qualified_name (name) @name)
|
|
61
|
+
(variable_name (name)) @name
|
|
62
|
+
]) @reference.call
|
|
63
|
+
|
|
64
|
+
(scoped_call_expression
|
|
65
|
+
name: (name) @name) @reference.call
|
|
66
|
+
|
|
67
|
+
(member_call_expression
|
|
68
|
+
name: (name) @name) @reference.call
|
|
69
|
+
|
|
70
|
+
; ---------------------------------------------------------------------------
|
|
71
|
+
; Perch additions (MIT): module imports (@import), exported constants and
|
|
72
|
+
; types, and a few more definitions and references.
|
|
73
|
+
; ---------------------------------------------------------------------------
|
|
74
|
+
(namespace_use_clause (qualified_name) @import)
|
|
75
|
+
(namespace_use_clause (name) @import)
|
|
76
|
+
(require_expression (_) @import)
|
|
77
|
+
(require_once_expression (_) @import)
|
|
78
|
+
(include_expression (_) @import)
|
|
79
|
+
(include_once_expression (_) @import)
|
|
80
|
+
(const_declaration (const_element (name) @name)) @definition.constant
|
|
81
|
+
(enum_declaration name: (name) @name) @definition.enum
|
|
82
|
+
(method_declaration name: (name) @name) @definition.method
|
|
83
|
+
(function_call_expression function: (name) @name) @reference.call
|
|
84
|
+
(object_creation_expression (name) @name) @reference.class
|
|
85
|
+
(named_type (name) @name) @reference.type
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
; ---------------------------------------------------------------------------
|
|
2
|
+
; From tree-sitter-python 0.25.0, queries/tags.scm, unchanged.
|
|
3
|
+
; https://github.com/tree-sitter/tree-sitter-python
|
|
4
|
+
;
|
|
5
|
+
; The MIT License (MIT)
|
|
6
|
+
;
|
|
7
|
+
; Copyright (c) 2016 Max Brunsfeld
|
|
8
|
+
;
|
|
9
|
+
; Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
; of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
; in the Software without restriction, including without limitation the rights
|
|
12
|
+
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
; copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
; furnished to do so, subject to the following conditions:
|
|
15
|
+
;
|
|
16
|
+
; The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
; copies or substantial portions of the Software.
|
|
18
|
+
;
|
|
19
|
+
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
; SOFTWARE.
|
|
26
|
+
; ---------------------------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
(module (expression_statement (assignment left: (identifier) @name) @definition.constant))
|
|
29
|
+
|
|
30
|
+
(class_definition
|
|
31
|
+
name: (identifier) @name) @definition.class
|
|
32
|
+
|
|
33
|
+
(function_definition
|
|
34
|
+
name: (identifier) @name) @definition.function
|
|
35
|
+
|
|
36
|
+
(call
|
|
37
|
+
function: [
|
|
38
|
+
(identifier) @name
|
|
39
|
+
(attribute
|
|
40
|
+
attribute: (identifier) @name)
|
|
41
|
+
]) @reference.call
|
|
42
|
+
|
|
43
|
+
; ---------------------------------------------------------------------------
|
|
44
|
+
; Perch additions (MIT): module imports (@import), exported constants and
|
|
45
|
+
; types, and a few more definitions and references.
|
|
46
|
+
; ---------------------------------------------------------------------------
|
|
47
|
+
(import_statement name: (dotted_name) @import)
|
|
48
|
+
(import_statement name: (aliased_import name: (dotted_name) @import))
|
|
49
|
+
(import_from_statement module_name: (_) @import)
|
|
50
|
+
(module (decorated_definition definition: (class_definition name: (identifier) @name) @definition.class))
|
|
51
|
+
(module (decorated_definition definition: (function_definition name: (identifier) @name) @definition.function))
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
; ---------------------------------------------------------------------------
|
|
2
|
+
; From tree-sitter-ruby 0.23.1, queries/tags.scm, unchanged.
|
|
3
|
+
; https://github.com/tree-sitter/tree-sitter-ruby
|
|
4
|
+
;
|
|
5
|
+
; The MIT License (MIT)
|
|
6
|
+
;
|
|
7
|
+
; Copyright (c) 2016 Rob Rix
|
|
8
|
+
;
|
|
9
|
+
; Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
; of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
; in the Software without restriction, including without limitation the rights
|
|
12
|
+
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
; copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
; furnished to do so, subject to the following conditions:
|
|
15
|
+
;
|
|
16
|
+
; The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
; copies or substantial portions of the Software.
|
|
18
|
+
;
|
|
19
|
+
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
; SOFTWARE.
|
|
26
|
+
; ---------------------------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
; Method definitions
|
|
29
|
+
|
|
30
|
+
(
|
|
31
|
+
(comment)* @doc
|
|
32
|
+
.
|
|
33
|
+
[
|
|
34
|
+
(method
|
|
35
|
+
name: (_) @name) @definition.method
|
|
36
|
+
(singleton_method
|
|
37
|
+
name: (_) @name) @definition.method
|
|
38
|
+
]
|
|
39
|
+
(#strip! @doc "^#\\s*")
|
|
40
|
+
(#select-adjacent! @doc @definition.method)
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
(alias
|
|
44
|
+
name: (_) @name) @definition.method
|
|
45
|
+
|
|
46
|
+
(setter
|
|
47
|
+
(identifier) @ignore)
|
|
48
|
+
|
|
49
|
+
; Class definitions
|
|
50
|
+
|
|
51
|
+
(
|
|
52
|
+
(comment)* @doc
|
|
53
|
+
.
|
|
54
|
+
[
|
|
55
|
+
(class
|
|
56
|
+
name: [
|
|
57
|
+
(constant) @name
|
|
58
|
+
(scope_resolution
|
|
59
|
+
name: (_) @name)
|
|
60
|
+
]) @definition.class
|
|
61
|
+
(singleton_class
|
|
62
|
+
value: [
|
|
63
|
+
(constant) @name
|
|
64
|
+
(scope_resolution
|
|
65
|
+
name: (_) @name)
|
|
66
|
+
]) @definition.class
|
|
67
|
+
]
|
|
68
|
+
(#strip! @doc "^#\\s*")
|
|
69
|
+
(#select-adjacent! @doc @definition.class)
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
; Module definitions
|
|
73
|
+
|
|
74
|
+
(
|
|
75
|
+
(module
|
|
76
|
+
name: [
|
|
77
|
+
(constant) @name
|
|
78
|
+
(scope_resolution
|
|
79
|
+
name: (_) @name)
|
|
80
|
+
]) @definition.module
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
; Calls
|
|
84
|
+
|
|
85
|
+
(call method: (identifier) @name) @reference.call
|
|
86
|
+
|
|
87
|
+
(
|
|
88
|
+
[(identifier) (constant)] @name @reference.call
|
|
89
|
+
(#is-not? local)
|
|
90
|
+
(#not-match? @name "^(lambda|load|require|require_relative|__FILE__|__LINE__)$")
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
; ---------------------------------------------------------------------------
|
|
94
|
+
; Perch additions (MIT): module imports (@import), exported constants and
|
|
95
|
+
; types, and a few more definitions and references.
|
|
96
|
+
; ---------------------------------------------------------------------------
|
|
97
|
+
((call
|
|
98
|
+
method: (identifier) @_require
|
|
99
|
+
arguments: (argument_list . (string (string_content) @import)))
|
|
100
|
+
(#match? @_require "^require(_relative)?$"))
|
|
101
|
+
(assignment left: (constant) @name) @definition.constant
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
; ---------------------------------------------------------------------------
|
|
2
|
+
; From tree-sitter-rust 0.24.0, queries/tags.scm, unchanged.
|
|
3
|
+
; https://github.com/tree-sitter/tree-sitter-rust
|
|
4
|
+
;
|
|
5
|
+
; The MIT License (MIT)
|
|
6
|
+
;
|
|
7
|
+
; Copyright (c) 2017 Maxim Sokolov
|
|
8
|
+
;
|
|
9
|
+
; Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
; of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
; in the Software without restriction, including without limitation the rights
|
|
12
|
+
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
; copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
; furnished to do so, subject to the following conditions:
|
|
15
|
+
;
|
|
16
|
+
; The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
; copies or substantial portions of the Software.
|
|
18
|
+
;
|
|
19
|
+
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
; SOFTWARE.
|
|
26
|
+
; ---------------------------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
; ADT definitions
|
|
29
|
+
|
|
30
|
+
(struct_item
|
|
31
|
+
name: (type_identifier) @name) @definition.class
|
|
32
|
+
|
|
33
|
+
(enum_item
|
|
34
|
+
name: (type_identifier) @name) @definition.class
|
|
35
|
+
|
|
36
|
+
(union_item
|
|
37
|
+
name: (type_identifier) @name) @definition.class
|
|
38
|
+
|
|
39
|
+
; type aliases
|
|
40
|
+
|
|
41
|
+
(type_item
|
|
42
|
+
name: (type_identifier) @name) @definition.class
|
|
43
|
+
|
|
44
|
+
; method definitions
|
|
45
|
+
|
|
46
|
+
(declaration_list
|
|
47
|
+
(function_item
|
|
48
|
+
name: (identifier) @name) @definition.method)
|
|
49
|
+
|
|
50
|
+
; function definitions
|
|
51
|
+
|
|
52
|
+
(function_item
|
|
53
|
+
name: (identifier) @name) @definition.function
|
|
54
|
+
|
|
55
|
+
; trait definitions
|
|
56
|
+
(trait_item
|
|
57
|
+
name: (type_identifier) @name) @definition.interface
|
|
58
|
+
|
|
59
|
+
; module definitions
|
|
60
|
+
(mod_item
|
|
61
|
+
name: (identifier) @name) @definition.module
|
|
62
|
+
|
|
63
|
+
; macro definitions
|
|
64
|
+
|
|
65
|
+
(macro_definition
|
|
66
|
+
name: (identifier) @name) @definition.macro
|
|
67
|
+
|
|
68
|
+
; references
|
|
69
|
+
|
|
70
|
+
(call_expression
|
|
71
|
+
function: (identifier) @name) @reference.call
|
|
72
|
+
|
|
73
|
+
(call_expression
|
|
74
|
+
function: (field_expression
|
|
75
|
+
field: (field_identifier) @name)) @reference.call
|
|
76
|
+
|
|
77
|
+
(macro_invocation
|
|
78
|
+
macro: (identifier) @name) @reference.call
|
|
79
|
+
|
|
80
|
+
; implementations
|
|
81
|
+
|
|
82
|
+
(impl_item
|
|
83
|
+
trait: (type_identifier) @name) @reference.implementation
|
|
84
|
+
|
|
85
|
+
(impl_item
|
|
86
|
+
type: (type_identifier) @name
|
|
87
|
+
!trait) @reference.implementation
|
|
88
|
+
|
|
89
|
+
; ---------------------------------------------------------------------------
|
|
90
|
+
; Perch additions (MIT): module imports (@import), exported constants and
|
|
91
|
+
; types, and a few more definitions and references.
|
|
92
|
+
; ---------------------------------------------------------------------------
|
|
93
|
+
(use_declaration argument: (_) @import)
|
|
94
|
+
(mod_item name: (identifier) @import !body)
|
|
95
|
+
(const_item name: (identifier) @name) @definition.constant
|
|
96
|
+
(static_item name: (identifier) @name) @definition.constant
|
|
97
|
+
(type_item name: (type_identifier) @name) @definition.type
|
|
98
|
+
(call_expression function: (scoped_identifier name: (identifier) @name)) @reference.call
|
|
99
|
+
(scoped_identifier path: (identifier) @name) @reference.type
|
|
100
|
+
(field_declaration type: (type_identifier) @name) @reference.type
|
|
101
|
+
(parameter type: (type_identifier) @name) @reference.type
|
|
102
|
+
(function_item return_type: (type_identifier) @name) @reference.type
|
|
103
|
+
(struct_expression name: (type_identifier) @name) @reference.class
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
; ---------------------------------------------------------------------------
|
|
2
|
+
; From tree-sitter-javascript 0.25.0, queries/tags.scm, with one Perch change:
|
|
3
|
+
; an object literal's members (pairs and method shorthand) are properties,
|
|
4
|
+
; not functions or methods, so the map does not list them as definitions
|
|
5
|
+
; of their own (methods count only in a class body).
|
|
6
|
+
; https://github.com/tree-sitter/tree-sitter-javascript
|
|
7
|
+
;
|
|
8
|
+
; The MIT License (MIT)
|
|
9
|
+
;
|
|
10
|
+
; Copyright (c) 2014 Max Brunsfeld
|
|
11
|
+
;
|
|
12
|
+
; Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
; of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
; in the Software without restriction, including without limitation the rights
|
|
15
|
+
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
; copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
; furnished to do so, subject to the following conditions:
|
|
18
|
+
;
|
|
19
|
+
; The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
; copies or substantial portions of the Software.
|
|
21
|
+
;
|
|
22
|
+
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
; SOFTWARE.
|
|
29
|
+
; ---------------------------------------------------------------------------
|
|
30
|
+
|
|
31
|
+
(class_body
|
|
32
|
+
(comment)* @doc
|
|
33
|
+
.
|
|
34
|
+
(method_definition
|
|
35
|
+
name: (property_identifier) @name) @definition.method
|
|
36
|
+
(#not-eq? @name "constructor")
|
|
37
|
+
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
38
|
+
(#select-adjacent! @doc @definition.method)
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
(object
|
|
42
|
+
(method_definition
|
|
43
|
+
name: (property_identifier) @name) @definition.property)
|
|
44
|
+
|
|
45
|
+
(
|
|
46
|
+
(comment)* @doc
|
|
47
|
+
.
|
|
48
|
+
[
|
|
49
|
+
(class
|
|
50
|
+
name: (_) @name)
|
|
51
|
+
(class_declaration
|
|
52
|
+
name: (_) @name)
|
|
53
|
+
] @definition.class
|
|
54
|
+
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
55
|
+
(#select-adjacent! @doc @definition.class)
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
(
|
|
59
|
+
(comment)* @doc
|
|
60
|
+
.
|
|
61
|
+
[
|
|
62
|
+
(function_expression
|
|
63
|
+
name: (identifier) @name)
|
|
64
|
+
(function_declaration
|
|
65
|
+
name: (identifier) @name)
|
|
66
|
+
(generator_function
|
|
67
|
+
name: (identifier) @name)
|
|
68
|
+
(generator_function_declaration
|
|
69
|
+
name: (identifier) @name)
|
|
70
|
+
] @definition.function
|
|
71
|
+
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
72
|
+
(#select-adjacent! @doc @definition.function)
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
(
|
|
76
|
+
(comment)* @doc
|
|
77
|
+
.
|
|
78
|
+
(lexical_declaration
|
|
79
|
+
(variable_declarator
|
|
80
|
+
name: (identifier) @name
|
|
81
|
+
value: [(arrow_function) (function_expression)]) @definition.function)
|
|
82
|
+
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
83
|
+
(#select-adjacent! @doc @definition.function)
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
(
|
|
87
|
+
(comment)* @doc
|
|
88
|
+
.
|
|
89
|
+
(variable_declaration
|
|
90
|
+
(variable_declarator
|
|
91
|
+
name: (identifier) @name
|
|
92
|
+
value: [(arrow_function) (function_expression)]) @definition.function)
|
|
93
|
+
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
94
|
+
(#select-adjacent! @doc @definition.function)
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
(assignment_expression
|
|
98
|
+
left: [
|
|
99
|
+
(identifier) @name
|
|
100
|
+
(member_expression
|
|
101
|
+
property: (property_identifier) @name)
|
|
102
|
+
]
|
|
103
|
+
right: [(arrow_function) (function_expression)]
|
|
104
|
+
) @definition.function
|
|
105
|
+
|
|
106
|
+
(pair
|
|
107
|
+
key: (property_identifier) @name
|
|
108
|
+
value: [(arrow_function) (function_expression)]) @definition.property
|
|
109
|
+
|
|
110
|
+
(
|
|
111
|
+
(call_expression
|
|
112
|
+
function: (identifier) @name) @reference.call
|
|
113
|
+
(#not-match? @name "^(require)$")
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
(call_expression
|
|
117
|
+
function: (member_expression
|
|
118
|
+
property: (property_identifier) @name)
|
|
119
|
+
arguments: (_) @reference.call)
|
|
120
|
+
|
|
121
|
+
(new_expression
|
|
122
|
+
constructor: (_) @name) @reference.class
|
|
123
|
+
|
|
124
|
+
(export_statement value: (assignment_expression left: (identifier) @name right: ([
|
|
125
|
+
(number)
|
|
126
|
+
(string)
|
|
127
|
+
(identifier)
|
|
128
|
+
(undefined)
|
|
129
|
+
(null)
|
|
130
|
+
(new_expression)
|
|
131
|
+
(binary_expression)
|
|
132
|
+
(call_expression)
|
|
133
|
+
]))) @definition.constant
|
|
134
|
+
|
|
135
|
+
; ---------------------------------------------------------------------------
|
|
136
|
+
; From tree-sitter-typescript 0.23.2, queries/tags.scm, unchanged.
|
|
137
|
+
; https://github.com/tree-sitter/tree-sitter-typescript
|
|
138
|
+
;
|
|
139
|
+
; The MIT License (MIT)
|
|
140
|
+
;
|
|
141
|
+
; Copyright (c) 2017 Max Brunsfeld
|
|
142
|
+
;
|
|
143
|
+
; Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
144
|
+
; of this software and associated documentation files (the "Software"), to deal
|
|
145
|
+
; in the Software without restriction, including without limitation the rights
|
|
146
|
+
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
147
|
+
; copies of the Software, and to permit persons to whom the Software is
|
|
148
|
+
; furnished to do so, subject to the following conditions:
|
|
149
|
+
;
|
|
150
|
+
; The above copyright notice and this permission notice shall be included in all
|
|
151
|
+
; copies or substantial portions of the Software.
|
|
152
|
+
;
|
|
153
|
+
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
154
|
+
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
155
|
+
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
156
|
+
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
157
|
+
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
158
|
+
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
159
|
+
; SOFTWARE.
|
|
160
|
+
; ---------------------------------------------------------------------------
|
|
161
|
+
|
|
162
|
+
(function_signature
|
|
163
|
+
name: (identifier) @name) @definition.function
|
|
164
|
+
|
|
165
|
+
(method_signature
|
|
166
|
+
name: (property_identifier) @name) @definition.method
|
|
167
|
+
|
|
168
|
+
(abstract_method_signature
|
|
169
|
+
name: (property_identifier) @name) @definition.method
|
|
170
|
+
|
|
171
|
+
(abstract_class_declaration
|
|
172
|
+
name: (type_identifier) @name) @definition.class
|
|
173
|
+
|
|
174
|
+
(module
|
|
175
|
+
name: (identifier) @name) @definition.module
|
|
176
|
+
|
|
177
|
+
(interface_declaration
|
|
178
|
+
name: (type_identifier) @name) @definition.interface
|
|
179
|
+
|
|
180
|
+
(type_annotation
|
|
181
|
+
(type_identifier) @name) @reference.type
|
|
182
|
+
|
|
183
|
+
(new_expression
|
|
184
|
+
constructor: (identifier) @name) @reference.class
|
|
185
|
+
|
|
186
|
+
; ---------------------------------------------------------------------------
|
|
187
|
+
; Perch additions (MIT): module imports (@import), exported constants and
|
|
188
|
+
; types, and a few more definitions and references.
|
|
189
|
+
; ---------------------------------------------------------------------------
|
|
190
|
+
(import_statement source: (string (string_fragment) @import))
|
|
191
|
+
(export_statement source: (string (string_fragment) @import))
|
|
192
|
+
((call_expression
|
|
193
|
+
function: (identifier) @_require
|
|
194
|
+
arguments: (arguments . (string (string_fragment) @import)))
|
|
195
|
+
(#eq? @_require "require"))
|
|
196
|
+
(call_expression
|
|
197
|
+
function: (import)
|
|
198
|
+
arguments: (arguments . (string (string_fragment) @import)))
|
|
199
|
+
(export_statement
|
|
200
|
+
declaration: (lexical_declaration
|
|
201
|
+
(variable_declarator name: (identifier) @name) @definition.constant))
|
|
202
|
+
(jsx_opening_element name: (identifier) @name) @reference.class
|
|
203
|
+
(jsx_self_closing_element name: (identifier) @name) @reference.class
|
|
204
|
+
|
|
205
|
+
(type_alias_declaration name: (type_identifier) @name) @definition.type
|
|
206
|
+
(enum_declaration name: (identifier) @name) @definition.enum
|
|
207
|
+
(generic_type name: (type_identifier) @name) @reference.type
|
|
208
|
+
(type_arguments (type_identifier) @name) @reference.type
|
|
209
|
+
(extends_type_clause (type_identifier) @name) @reference.type
|
|
210
|
+
(implements_clause (type_identifier) @name) @reference.implementation
|