tree-sitter-analyzer 0.2.0__py3-none-any.whl → 0.3.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 +133 -121
- tree_sitter_analyzer/__main__.py +11 -12
- tree_sitter_analyzer/api.py +531 -539
- tree_sitter_analyzer/cli/__init__.py +39 -39
- tree_sitter_analyzer/cli/__main__.py +12 -13
- tree_sitter_analyzer/cli/commands/__init__.py +26 -27
- tree_sitter_analyzer/cli/commands/advanced_command.py +88 -88
- tree_sitter_analyzer/cli/commands/base_command.py +160 -155
- tree_sitter_analyzer/cli/commands/default_command.py +18 -19
- tree_sitter_analyzer/cli/commands/partial_read_command.py +141 -133
- tree_sitter_analyzer/cli/commands/query_command.py +81 -82
- tree_sitter_analyzer/cli/commands/structure_command.py +138 -121
- tree_sitter_analyzer/cli/commands/summary_command.py +101 -93
- tree_sitter_analyzer/cli/commands/table_command.py +232 -233
- tree_sitter_analyzer/cli/info_commands.py +120 -121
- tree_sitter_analyzer/cli_main.py +277 -276
- tree_sitter_analyzer/core/__init__.py +15 -20
- tree_sitter_analyzer/core/analysis_engine.py +591 -574
- tree_sitter_analyzer/core/cache_service.py +320 -330
- tree_sitter_analyzer/core/engine.py +557 -560
- tree_sitter_analyzer/core/parser.py +293 -288
- tree_sitter_analyzer/core/query.py +494 -502
- tree_sitter_analyzer/encoding_utils.py +458 -460
- tree_sitter_analyzer/exceptions.py +337 -340
- tree_sitter_analyzer/file_handler.py +217 -222
- tree_sitter_analyzer/formatters/__init__.py +1 -1
- tree_sitter_analyzer/formatters/base_formatter.py +167 -168
- tree_sitter_analyzer/formatters/formatter_factory.py +78 -74
- tree_sitter_analyzer/formatters/java_formatter.py +287 -270
- tree_sitter_analyzer/formatters/python_formatter.py +255 -235
- tree_sitter_analyzer/interfaces/__init__.py +9 -10
- tree_sitter_analyzer/interfaces/cli.py +528 -557
- tree_sitter_analyzer/interfaces/cli_adapter.py +322 -319
- tree_sitter_analyzer/interfaces/mcp_adapter.py +180 -170
- tree_sitter_analyzer/interfaces/mcp_server.py +405 -416
- tree_sitter_analyzer/java_analyzer.py +218 -219
- tree_sitter_analyzer/language_detector.py +398 -400
- tree_sitter_analyzer/language_loader.py +224 -228
- tree_sitter_analyzer/languages/__init__.py +10 -11
- tree_sitter_analyzer/languages/java_plugin.py +1129 -1113
- tree_sitter_analyzer/languages/python_plugin.py +737 -712
- tree_sitter_analyzer/mcp/__init__.py +31 -32
- tree_sitter_analyzer/mcp/resources/__init__.py +44 -47
- tree_sitter_analyzer/mcp/resources/code_file_resource.py +212 -213
- tree_sitter_analyzer/mcp/resources/project_stats_resource.py +560 -550
- tree_sitter_analyzer/mcp/server.py +333 -345
- tree_sitter_analyzer/mcp/tools/__init__.py +30 -31
- tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +621 -557
- tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py +242 -245
- tree_sitter_analyzer/mcp/tools/base_tool.py +54 -55
- tree_sitter_analyzer/mcp/tools/read_partial_tool.py +300 -302
- tree_sitter_analyzer/mcp/tools/table_format_tool.py +362 -359
- tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py +543 -476
- tree_sitter_analyzer/mcp/utils/__init__.py +105 -106
- tree_sitter_analyzer/mcp/utils/error_handler.py +549 -549
- tree_sitter_analyzer/models.py +470 -481
- tree_sitter_analyzer/output_manager.py +261 -264
- tree_sitter_analyzer/plugins/__init__.py +333 -334
- tree_sitter_analyzer/plugins/base.py +477 -446
- tree_sitter_analyzer/plugins/java_plugin.py +608 -625
- tree_sitter_analyzer/plugins/javascript_plugin.py +446 -439
- tree_sitter_analyzer/plugins/manager.py +362 -355
- tree_sitter_analyzer/plugins/plugin_loader.py +85 -83
- tree_sitter_analyzer/plugins/python_plugin.py +606 -598
- tree_sitter_analyzer/plugins/registry.py +374 -366
- tree_sitter_analyzer/queries/__init__.py +26 -27
- tree_sitter_analyzer/queries/java.py +391 -394
- tree_sitter_analyzer/queries/javascript.py +148 -149
- tree_sitter_analyzer/queries/python.py +285 -286
- tree_sitter_analyzer/queries/typescript.py +229 -230
- tree_sitter_analyzer/query_loader.py +254 -260
- tree_sitter_analyzer/table_formatter.py +468 -448
- tree_sitter_analyzer/utils.py +277 -277
- {tree_sitter_analyzer-0.2.0.dist-info → tree_sitter_analyzer-0.3.0.dist-info}/METADATA +21 -6
- tree_sitter_analyzer-0.3.0.dist-info/RECORD +77 -0
- tree_sitter_analyzer-0.2.0.dist-info/RECORD +0 -77
- {tree_sitter_analyzer-0.2.0.dist-info → tree_sitter_analyzer-0.3.0.dist-info}/WHEEL +0 -0
- {tree_sitter_analyzer-0.2.0.dist-info → tree_sitter_analyzer-0.3.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,230 +1,229 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
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
|
-
(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
(decorator
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
"
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
"
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
"
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
"
|
|
189
|
-
|
|
190
|
-
},
|
|
191
|
-
"
|
|
192
|
-
|
|
193
|
-
"
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
"
|
|
198
|
-
|
|
199
|
-
},
|
|
200
|
-
"
|
|
201
|
-
"
|
|
202
|
-
|
|
203
|
-
"
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
"
|
|
208
|
-
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
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": "型アノテーション付きのすべての関数宣言、式、メソッドを検索",
|
|
177
|
+
},
|
|
178
|
+
"classes": {
|
|
179
|
+
"query": CLASSES,
|
|
180
|
+
"description": "抽象クラスを含むすべてのクラス宣言を検索",
|
|
181
|
+
},
|
|
182
|
+
"interfaces": {
|
|
183
|
+
"query": INTERFACES,
|
|
184
|
+
"description": "すべてのインターフェース宣言を検索",
|
|
185
|
+
},
|
|
186
|
+
"type_aliases": {
|
|
187
|
+
"query": TYPE_ALIASES,
|
|
188
|
+
"description": "すべての型エイリアス宣言を検索",
|
|
189
|
+
},
|
|
190
|
+
"enums": {"query": ENUMS, "description": "すべての列挙型宣言を検索"},
|
|
191
|
+
"variables": {
|
|
192
|
+
"query": VARIABLES,
|
|
193
|
+
"description": "型アノテーション付きのすべての変数宣言を検索",
|
|
194
|
+
},
|
|
195
|
+
"imports": {
|
|
196
|
+
"query": IMPORTS,
|
|
197
|
+
"description": "型インポートを含むすべてのインポート文を検索",
|
|
198
|
+
},
|
|
199
|
+
"exports": {"query": EXPORTS, "description": "すべてのエクスポート文を検索"},
|
|
200
|
+
"decorators": {"query": DECORATORS, "description": "すべてのデコレータを検索"},
|
|
201
|
+
"generics": {
|
|
202
|
+
"query": GENERICS,
|
|
203
|
+
"description": "すべてのジェネリック型パラメータを検索",
|
|
204
|
+
},
|
|
205
|
+
"signatures": {
|
|
206
|
+
"query": SIGNATURES,
|
|
207
|
+
"description": "プロパティシグネチャ、メソッドシグネチャ、コンストラクタシグネチャを検索",
|
|
208
|
+
},
|
|
209
|
+
"comments": {"query": COMMENTS, "description": "すべてのコメントを検索"},
|
|
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())
|