tree-sitter-analyzer 0.6.2__py3-none-any.whl → 0.8.0__py3-none-any.whl
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.
Potentially problematic release.
This version of tree-sitter-analyzer might be problematic. Click here for more details.
- tree_sitter_analyzer/__init__.py +132 -132
- tree_sitter_analyzer/__main__.py +11 -11
- tree_sitter_analyzer/api.py +533 -533
- tree_sitter_analyzer/cli/__init__.py +39 -39
- tree_sitter_analyzer/cli/__main__.py +12 -12
- tree_sitter_analyzer/cli/commands/__init__.py +26 -26
- tree_sitter_analyzer/cli/commands/advanced_command.py +88 -88
- tree_sitter_analyzer/cli/commands/base_command.py +160 -160
- tree_sitter_analyzer/cli/commands/default_command.py +18 -18
- tree_sitter_analyzer/cli/commands/partial_read_command.py +141 -141
- tree_sitter_analyzer/cli/commands/query_command.py +81 -81
- tree_sitter_analyzer/cli/commands/structure_command.py +138 -138
- tree_sitter_analyzer/cli/commands/summary_command.py +101 -101
- tree_sitter_analyzer/cli/commands/table_command.py +235 -235
- tree_sitter_analyzer/cli/info_commands.py +121 -121
- tree_sitter_analyzer/cli_main.py +297 -297
- tree_sitter_analyzer/core/__init__.py +15 -15
- tree_sitter_analyzer/core/analysis_engine.py +555 -555
- tree_sitter_analyzer/core/cache_service.py +320 -320
- tree_sitter_analyzer/core/engine.py +566 -566
- tree_sitter_analyzer/core/parser.py +293 -293
- tree_sitter_analyzer/encoding_utils.py +459 -459
- tree_sitter_analyzer/exceptions.py +406 -337
- tree_sitter_analyzer/file_handler.py +210 -210
- tree_sitter_analyzer/formatters/__init__.py +1 -1
- tree_sitter_analyzer/formatters/base_formatter.py +167 -167
- tree_sitter_analyzer/formatters/formatter_factory.py +78 -78
- tree_sitter_analyzer/interfaces/__init__.py +9 -9
- tree_sitter_analyzer/interfaces/cli.py +528 -528
- tree_sitter_analyzer/interfaces/cli_adapter.py +343 -343
- tree_sitter_analyzer/interfaces/mcp_adapter.py +206 -206
- tree_sitter_analyzer/interfaces/mcp_server.py +425 -405
- tree_sitter_analyzer/languages/__init__.py +10 -10
- tree_sitter_analyzer/languages/javascript_plugin.py +446 -446
- tree_sitter_analyzer/languages/python_plugin.py +755 -755
- tree_sitter_analyzer/mcp/__init__.py +31 -31
- tree_sitter_analyzer/mcp/resources/__init__.py +44 -44
- tree_sitter_analyzer/mcp/resources/code_file_resource.py +209 -209
- tree_sitter_analyzer/mcp/server.py +346 -333
- tree_sitter_analyzer/mcp/tools/__init__.py +30 -30
- tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +654 -654
- tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py +247 -247
- tree_sitter_analyzer/mcp/tools/base_tool.py +54 -54
- tree_sitter_analyzer/mcp/tools/read_partial_tool.py +300 -300
- tree_sitter_analyzer/mcp/tools/table_format_tool.py +362 -362
- tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py +543 -543
- tree_sitter_analyzer/mcp/utils/__init__.py +107 -107
- tree_sitter_analyzer/mcp/utils/error_handler.py +549 -549
- tree_sitter_analyzer/output_manager.py +253 -253
- tree_sitter_analyzer/plugins/__init__.py +280 -280
- tree_sitter_analyzer/plugins/base.py +529 -529
- tree_sitter_analyzer/plugins/manager.py +379 -379
- tree_sitter_analyzer/queries/__init__.py +26 -26
- tree_sitter_analyzer/queries/java.py +391 -391
- tree_sitter_analyzer/queries/javascript.py +148 -148
- tree_sitter_analyzer/queries/python.py +285 -285
- tree_sitter_analyzer/queries/typescript.py +229 -229
- tree_sitter_analyzer/query_loader.py +257 -257
- tree_sitter_analyzer/security/__init__.py +22 -0
- tree_sitter_analyzer/security/boundary_manager.py +237 -0
- tree_sitter_analyzer/security/regex_checker.py +292 -0
- tree_sitter_analyzer/security/validator.py +224 -0
- tree_sitter_analyzer/table_formatter.py +652 -473
- tree_sitter_analyzer/utils.py +277 -277
- {tree_sitter_analyzer-0.6.2.dist-info → tree_sitter_analyzer-0.8.0.dist-info}/METADATA +4 -1
- tree_sitter_analyzer-0.8.0.dist-info/RECORD +76 -0
- tree_sitter_analyzer-0.6.2.dist-info/RECORD +0 -72
- {tree_sitter_analyzer-0.6.2.dist-info → tree_sitter_analyzer-0.8.0.dist-info}/WHEEL +0 -0
- {tree_sitter_analyzer-0.6.2.dist-info → tree_sitter_analyzer-0.8.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,229 +1,229 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
TypeScript Tree-sitter queries for code analysis.
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
# Function declarations and expressions
|
|
7
|
-
FUNCTIONS = """
|
|
8
|
-
(function_declaration
|
|
9
|
-
name: (identifier) @function.name
|
|
10
|
-
parameters: (formal_parameters) @function.params
|
|
11
|
-
return_type: (type_annotation)? @function.return_type
|
|
12
|
-
body: (statement_block) @function.body) @function.declaration
|
|
13
|
-
|
|
14
|
-
(function_expression
|
|
15
|
-
name: (identifier)? @function.name
|
|
16
|
-
parameters: (formal_parameters) @function.params
|
|
17
|
-
return_type: (type_annotation)? @function.return_type
|
|
18
|
-
body: (statement_block) @function.body) @function.expression
|
|
19
|
-
|
|
20
|
-
(arrow_function
|
|
21
|
-
parameters: (_) @function.params
|
|
22
|
-
return_type: (type_annotation)? @function.return_type
|
|
23
|
-
body: (_) @function.body) @function.arrow
|
|
24
|
-
|
|
25
|
-
(method_definition
|
|
26
|
-
name: (_) @function.name
|
|
27
|
-
parameters: (formal_parameters) @function.params
|
|
28
|
-
return_type: (type_annotation)? @function.return_type
|
|
29
|
-
body: (statement_block) @function.body) @method.definition
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
# Class declarations
|
|
33
|
-
CLASSES = """
|
|
34
|
-
(class_declaration
|
|
35
|
-
name: (type_identifier) @class.name
|
|
36
|
-
type_parameters: (type_parameters)? @class.generics
|
|
37
|
-
superclass: (class_heritage)? @class.superclass
|
|
38
|
-
body: (class_body) @class.body) @class.declaration
|
|
39
|
-
|
|
40
|
-
(abstract_class_declaration
|
|
41
|
-
name: (type_identifier) @class.name
|
|
42
|
-
type_parameters: (type_parameters)? @class.generics
|
|
43
|
-
superclass: (class_heritage)? @class.superclass
|
|
44
|
-
body: (class_body) @class.body) @class.abstract
|
|
45
|
-
"""
|
|
46
|
-
|
|
47
|
-
# Interface declarations
|
|
48
|
-
INTERFACES = """
|
|
49
|
-
(interface_declaration
|
|
50
|
-
name: (type_identifier) @interface.name
|
|
51
|
-
type_parameters: (type_parameters)? @interface.generics
|
|
52
|
-
body: (object_type) @interface.body) @interface.declaration
|
|
53
|
-
"""
|
|
54
|
-
|
|
55
|
-
# Type aliases
|
|
56
|
-
TYPE_ALIASES = """
|
|
57
|
-
(type_alias_declaration
|
|
58
|
-
name: (type_identifier) @type.name
|
|
59
|
-
type_parameters: (type_parameters)? @type.generics
|
|
60
|
-
value: (_) @type.value) @type.alias
|
|
61
|
-
"""
|
|
62
|
-
|
|
63
|
-
# Enum declarations
|
|
64
|
-
ENUMS = """
|
|
65
|
-
(enum_declaration
|
|
66
|
-
name: (identifier) @enum.name
|
|
67
|
-
body: (enum_body) @enum.body) @enum.declaration
|
|
68
|
-
"""
|
|
69
|
-
|
|
70
|
-
# Variable declarations with types
|
|
71
|
-
VARIABLES = """
|
|
72
|
-
(variable_declaration
|
|
73
|
-
(variable_declarator
|
|
74
|
-
name: (identifier) @variable.name
|
|
75
|
-
type: (type_annotation)? @variable.type
|
|
76
|
-
value: (_)? @variable.value)) @variable.declaration
|
|
77
|
-
|
|
78
|
-
(lexical_declaration
|
|
79
|
-
(variable_declarator
|
|
80
|
-
name: (identifier) @variable.name
|
|
81
|
-
type: (type_annotation)? @variable.type
|
|
82
|
-
value: (_)? @variable.value)) @variable.lexical
|
|
83
|
-
"""
|
|
84
|
-
|
|
85
|
-
# Import and export statements
|
|
86
|
-
IMPORTS = """
|
|
87
|
-
(import_statement
|
|
88
|
-
source: (string) @import.source) @import.statement
|
|
89
|
-
|
|
90
|
-
(import_statement
|
|
91
|
-
(import_clause
|
|
92
|
-
(named_imports
|
|
93
|
-
(import_specifier
|
|
94
|
-
name: (identifier) @import.name
|
|
95
|
-
alias: (identifier)? @import.alias))) @import.named
|
|
96
|
-
|
|
97
|
-
(import_statement
|
|
98
|
-
(import_clause
|
|
99
|
-
(import_default_specifier
|
|
100
|
-
(identifier) @import.default))) @import.default
|
|
101
|
-
|
|
102
|
-
(import_statement
|
|
103
|
-
(import_clause
|
|
104
|
-
(namespace_import
|
|
105
|
-
(identifier) @import.namespace))) @import.namespace
|
|
106
|
-
|
|
107
|
-
(type_import
|
|
108
|
-
(import_clause
|
|
109
|
-
(named_imports
|
|
110
|
-
(import_specifier
|
|
111
|
-
name: (identifier) @import.type.name
|
|
112
|
-
alias: (identifier)? @import.type.alias)))) @import.type
|
|
113
|
-
"""
|
|
114
|
-
|
|
115
|
-
EXPORTS = """
|
|
116
|
-
(export_statement
|
|
117
|
-
declaration: (_) @export.declaration) @export.statement
|
|
118
|
-
|
|
119
|
-
(export_statement
|
|
120
|
-
(export_clause
|
|
121
|
-
(export_specifier
|
|
122
|
-
name: (identifier) @export.name
|
|
123
|
-
alias: (identifier)? @export.alias))) @export.named
|
|
124
|
-
"""
|
|
125
|
-
|
|
126
|
-
# Decorators (TypeScript specific)
|
|
127
|
-
DECORATORS = """
|
|
128
|
-
(decorator
|
|
129
|
-
(identifier) @decorator.name) @decorator.simple
|
|
130
|
-
|
|
131
|
-
(decorator
|
|
132
|
-
(call_expression
|
|
133
|
-
function: (identifier) @decorator.name
|
|
134
|
-
arguments: (arguments) @decorator.args)) @decorator.call
|
|
135
|
-
|
|
136
|
-
(decorator
|
|
137
|
-
(member_expression
|
|
138
|
-
object: (identifier) @decorator.object
|
|
139
|
-
property: (property_identifier) @decorator.name)) @decorator.member
|
|
140
|
-
"""
|
|
141
|
-
|
|
142
|
-
# Generic type parameters
|
|
143
|
-
GENERICS = """
|
|
144
|
-
(type_parameters
|
|
145
|
-
(type_parameter
|
|
146
|
-
name: (type_identifier) @generic.name
|
|
147
|
-
constraint: (type_annotation)? @generic.constraint
|
|
148
|
-
default: (type_annotation)? @generic.default)) @generic.parameter
|
|
149
|
-
"""
|
|
150
|
-
|
|
151
|
-
# Property signatures and method signatures
|
|
152
|
-
SIGNATURES = """
|
|
153
|
-
(property_signature
|
|
154
|
-
name: (_) @property.name
|
|
155
|
-
type: (type_annotation) @property.type) @property.signature
|
|
156
|
-
|
|
157
|
-
(method_signature
|
|
158
|
-
name: (_) @method.name
|
|
159
|
-
parameters: (formal_parameters) @method.params
|
|
160
|
-
return_type: (type_annotation)? @method.return_type) @method.signature
|
|
161
|
-
|
|
162
|
-
(construct_signature
|
|
163
|
-
parameters: (formal_parameters) @constructor.params
|
|
164
|
-
return_type: (type_annotation)? @constructor.return_type) @constructor.signature
|
|
165
|
-
"""
|
|
166
|
-
|
|
167
|
-
# Comments
|
|
168
|
-
COMMENTS = """
|
|
169
|
-
(comment) @comment
|
|
170
|
-
"""
|
|
171
|
-
|
|
172
|
-
# All queries combined
|
|
173
|
-
ALL_QUERIES = {
|
|
174
|
-
"functions": {
|
|
175
|
-
"query": FUNCTIONS,
|
|
176
|
-
"description": "Search all function declarations, expressions, and methods with type annotations",
|
|
177
|
-
},
|
|
178
|
-
"classes": {
|
|
179
|
-
"query": CLASSES,
|
|
180
|
-
"description": "Search all class declarations including abstract classes",
|
|
181
|
-
},
|
|
182
|
-
"interfaces": {
|
|
183
|
-
"query": INTERFACES,
|
|
184
|
-
"description": "Search all interface declarations",
|
|
185
|
-
},
|
|
186
|
-
"type_aliases": {
|
|
187
|
-
"query": TYPE_ALIASES,
|
|
188
|
-
"description": "Search all type alias declarations",
|
|
189
|
-
},
|
|
190
|
-
"enums": {"query": ENUMS, "description": "Search all enum declarations"},
|
|
191
|
-
"variables": {
|
|
192
|
-
"query": VARIABLES,
|
|
193
|
-
"description": "Search all variable declarations with type annotations",
|
|
194
|
-
},
|
|
195
|
-
"imports": {
|
|
196
|
-
"query": IMPORTS,
|
|
197
|
-
"description": "Search all import statements including type imports",
|
|
198
|
-
},
|
|
199
|
-
"exports": {"query": EXPORTS, "description": "Search all export statements"},
|
|
200
|
-
"decorators": {"query": DECORATORS, "description": "Search all decorators"},
|
|
201
|
-
"generics": {
|
|
202
|
-
"query": GENERICS,
|
|
203
|
-
"description": "Search all generic type parameters",
|
|
204
|
-
},
|
|
205
|
-
"signatures": {
|
|
206
|
-
"query": SIGNATURES,
|
|
207
|
-
"description": "Search property signatures, method signatures, and constructor signatures",
|
|
208
|
-
},
|
|
209
|
-
"comments": {"query": COMMENTS, "description": "Search all comments"},
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
def get_query(name: str) -> str:
|
|
214
|
-
"""Get a specific query by name."""
|
|
215
|
-
if name in ALL_QUERIES:
|
|
216
|
-
return ALL_QUERIES[name]["query"]
|
|
217
|
-
raise ValueError(
|
|
218
|
-
f"Query '{name}' not found. Available queries: {list(ALL_QUERIES.keys())}"
|
|
219
|
-
)
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
def get_all_queries() -> dict:
|
|
223
|
-
"""Get all available queries."""
|
|
224
|
-
return ALL_QUERIES
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
def list_queries() -> list:
|
|
228
|
-
"""List all available query names."""
|
|
229
|
-
return list(ALL_QUERIES.keys())
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
TypeScript Tree-sitter queries for code analysis.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# Function declarations and expressions
|
|
7
|
+
FUNCTIONS = """
|
|
8
|
+
(function_declaration
|
|
9
|
+
name: (identifier) @function.name
|
|
10
|
+
parameters: (formal_parameters) @function.params
|
|
11
|
+
return_type: (type_annotation)? @function.return_type
|
|
12
|
+
body: (statement_block) @function.body) @function.declaration
|
|
13
|
+
|
|
14
|
+
(function_expression
|
|
15
|
+
name: (identifier)? @function.name
|
|
16
|
+
parameters: (formal_parameters) @function.params
|
|
17
|
+
return_type: (type_annotation)? @function.return_type
|
|
18
|
+
body: (statement_block) @function.body) @function.expression
|
|
19
|
+
|
|
20
|
+
(arrow_function
|
|
21
|
+
parameters: (_) @function.params
|
|
22
|
+
return_type: (type_annotation)? @function.return_type
|
|
23
|
+
body: (_) @function.body) @function.arrow
|
|
24
|
+
|
|
25
|
+
(method_definition
|
|
26
|
+
name: (_) @function.name
|
|
27
|
+
parameters: (formal_parameters) @function.params
|
|
28
|
+
return_type: (type_annotation)? @function.return_type
|
|
29
|
+
body: (statement_block) @function.body) @method.definition
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
# Class declarations
|
|
33
|
+
CLASSES = """
|
|
34
|
+
(class_declaration
|
|
35
|
+
name: (type_identifier) @class.name
|
|
36
|
+
type_parameters: (type_parameters)? @class.generics
|
|
37
|
+
superclass: (class_heritage)? @class.superclass
|
|
38
|
+
body: (class_body) @class.body) @class.declaration
|
|
39
|
+
|
|
40
|
+
(abstract_class_declaration
|
|
41
|
+
name: (type_identifier) @class.name
|
|
42
|
+
type_parameters: (type_parameters)? @class.generics
|
|
43
|
+
superclass: (class_heritage)? @class.superclass
|
|
44
|
+
body: (class_body) @class.body) @class.abstract
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
# Interface declarations
|
|
48
|
+
INTERFACES = """
|
|
49
|
+
(interface_declaration
|
|
50
|
+
name: (type_identifier) @interface.name
|
|
51
|
+
type_parameters: (type_parameters)? @interface.generics
|
|
52
|
+
body: (object_type) @interface.body) @interface.declaration
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
# Type aliases
|
|
56
|
+
TYPE_ALIASES = """
|
|
57
|
+
(type_alias_declaration
|
|
58
|
+
name: (type_identifier) @type.name
|
|
59
|
+
type_parameters: (type_parameters)? @type.generics
|
|
60
|
+
value: (_) @type.value) @type.alias
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
# Enum declarations
|
|
64
|
+
ENUMS = """
|
|
65
|
+
(enum_declaration
|
|
66
|
+
name: (identifier) @enum.name
|
|
67
|
+
body: (enum_body) @enum.body) @enum.declaration
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
# Variable declarations with types
|
|
71
|
+
VARIABLES = """
|
|
72
|
+
(variable_declaration
|
|
73
|
+
(variable_declarator
|
|
74
|
+
name: (identifier) @variable.name
|
|
75
|
+
type: (type_annotation)? @variable.type
|
|
76
|
+
value: (_)? @variable.value)) @variable.declaration
|
|
77
|
+
|
|
78
|
+
(lexical_declaration
|
|
79
|
+
(variable_declarator
|
|
80
|
+
name: (identifier) @variable.name
|
|
81
|
+
type: (type_annotation)? @variable.type
|
|
82
|
+
value: (_)? @variable.value)) @variable.lexical
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
# Import and export statements
|
|
86
|
+
IMPORTS = """
|
|
87
|
+
(import_statement
|
|
88
|
+
source: (string) @import.source) @import.statement
|
|
89
|
+
|
|
90
|
+
(import_statement
|
|
91
|
+
(import_clause
|
|
92
|
+
(named_imports
|
|
93
|
+
(import_specifier
|
|
94
|
+
name: (identifier) @import.name
|
|
95
|
+
alias: (identifier)? @import.alias))) @import.named
|
|
96
|
+
|
|
97
|
+
(import_statement
|
|
98
|
+
(import_clause
|
|
99
|
+
(import_default_specifier
|
|
100
|
+
(identifier) @import.default))) @import.default
|
|
101
|
+
|
|
102
|
+
(import_statement
|
|
103
|
+
(import_clause
|
|
104
|
+
(namespace_import
|
|
105
|
+
(identifier) @import.namespace))) @import.namespace
|
|
106
|
+
|
|
107
|
+
(type_import
|
|
108
|
+
(import_clause
|
|
109
|
+
(named_imports
|
|
110
|
+
(import_specifier
|
|
111
|
+
name: (identifier) @import.type.name
|
|
112
|
+
alias: (identifier)? @import.type.alias)))) @import.type
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
EXPORTS = """
|
|
116
|
+
(export_statement
|
|
117
|
+
declaration: (_) @export.declaration) @export.statement
|
|
118
|
+
|
|
119
|
+
(export_statement
|
|
120
|
+
(export_clause
|
|
121
|
+
(export_specifier
|
|
122
|
+
name: (identifier) @export.name
|
|
123
|
+
alias: (identifier)? @export.alias))) @export.named
|
|
124
|
+
"""
|
|
125
|
+
|
|
126
|
+
# Decorators (TypeScript specific)
|
|
127
|
+
DECORATORS = """
|
|
128
|
+
(decorator
|
|
129
|
+
(identifier) @decorator.name) @decorator.simple
|
|
130
|
+
|
|
131
|
+
(decorator
|
|
132
|
+
(call_expression
|
|
133
|
+
function: (identifier) @decorator.name
|
|
134
|
+
arguments: (arguments) @decorator.args)) @decorator.call
|
|
135
|
+
|
|
136
|
+
(decorator
|
|
137
|
+
(member_expression
|
|
138
|
+
object: (identifier) @decorator.object
|
|
139
|
+
property: (property_identifier) @decorator.name)) @decorator.member
|
|
140
|
+
"""
|
|
141
|
+
|
|
142
|
+
# Generic type parameters
|
|
143
|
+
GENERICS = """
|
|
144
|
+
(type_parameters
|
|
145
|
+
(type_parameter
|
|
146
|
+
name: (type_identifier) @generic.name
|
|
147
|
+
constraint: (type_annotation)? @generic.constraint
|
|
148
|
+
default: (type_annotation)? @generic.default)) @generic.parameter
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
# Property signatures and method signatures
|
|
152
|
+
SIGNATURES = """
|
|
153
|
+
(property_signature
|
|
154
|
+
name: (_) @property.name
|
|
155
|
+
type: (type_annotation) @property.type) @property.signature
|
|
156
|
+
|
|
157
|
+
(method_signature
|
|
158
|
+
name: (_) @method.name
|
|
159
|
+
parameters: (formal_parameters) @method.params
|
|
160
|
+
return_type: (type_annotation)? @method.return_type) @method.signature
|
|
161
|
+
|
|
162
|
+
(construct_signature
|
|
163
|
+
parameters: (formal_parameters) @constructor.params
|
|
164
|
+
return_type: (type_annotation)? @constructor.return_type) @constructor.signature
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
# Comments
|
|
168
|
+
COMMENTS = """
|
|
169
|
+
(comment) @comment
|
|
170
|
+
"""
|
|
171
|
+
|
|
172
|
+
# All queries combined
|
|
173
|
+
ALL_QUERIES = {
|
|
174
|
+
"functions": {
|
|
175
|
+
"query": FUNCTIONS,
|
|
176
|
+
"description": "Search all function declarations, expressions, and methods with type annotations",
|
|
177
|
+
},
|
|
178
|
+
"classes": {
|
|
179
|
+
"query": CLASSES,
|
|
180
|
+
"description": "Search all class declarations including abstract classes",
|
|
181
|
+
},
|
|
182
|
+
"interfaces": {
|
|
183
|
+
"query": INTERFACES,
|
|
184
|
+
"description": "Search all interface declarations",
|
|
185
|
+
},
|
|
186
|
+
"type_aliases": {
|
|
187
|
+
"query": TYPE_ALIASES,
|
|
188
|
+
"description": "Search all type alias declarations",
|
|
189
|
+
},
|
|
190
|
+
"enums": {"query": ENUMS, "description": "Search all enum declarations"},
|
|
191
|
+
"variables": {
|
|
192
|
+
"query": VARIABLES,
|
|
193
|
+
"description": "Search all variable declarations with type annotations",
|
|
194
|
+
},
|
|
195
|
+
"imports": {
|
|
196
|
+
"query": IMPORTS,
|
|
197
|
+
"description": "Search all import statements including type imports",
|
|
198
|
+
},
|
|
199
|
+
"exports": {"query": EXPORTS, "description": "Search all export statements"},
|
|
200
|
+
"decorators": {"query": DECORATORS, "description": "Search all decorators"},
|
|
201
|
+
"generics": {
|
|
202
|
+
"query": GENERICS,
|
|
203
|
+
"description": "Search all generic type parameters",
|
|
204
|
+
},
|
|
205
|
+
"signatures": {
|
|
206
|
+
"query": SIGNATURES,
|
|
207
|
+
"description": "Search property signatures, method signatures, and constructor signatures",
|
|
208
|
+
},
|
|
209
|
+
"comments": {"query": COMMENTS, "description": "Search all comments"},
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def get_query(name: str) -> str:
|
|
214
|
+
"""Get a specific query by name."""
|
|
215
|
+
if name in ALL_QUERIES:
|
|
216
|
+
return ALL_QUERIES[name]["query"]
|
|
217
|
+
raise ValueError(
|
|
218
|
+
f"Query '{name}' not found. Available queries: {list(ALL_QUERIES.keys())}"
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def get_all_queries() -> dict:
|
|
223
|
+
"""Get all available queries."""
|
|
224
|
+
return ALL_QUERIES
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def list_queries() -> list:
|
|
228
|
+
"""List all available query names."""
|
|
229
|
+
return list(ALL_QUERIES.keys())
|