tree-sitter-analyzer 0.2.0__py3-none-any.whl → 0.4.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 +134 -121
- tree_sitter_analyzer/__main__.py +11 -12
- tree_sitter_analyzer/api.py +533 -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 +235 -233
- tree_sitter_analyzer/cli/info_commands.py +120 -121
- tree_sitter_analyzer/cli_main.py +278 -276
- tree_sitter_analyzer/core/__init__.py +15 -20
- tree_sitter_analyzer/core/analysis_engine.py +555 -574
- tree_sitter_analyzer/core/cache_service.py +320 -330
- tree_sitter_analyzer/core/engine.py +559 -560
- tree_sitter_analyzer/core/parser.py +293 -288
- tree_sitter_analyzer/core/query.py +502 -502
- tree_sitter_analyzer/encoding_utils.py +456 -460
- tree_sitter_analyzer/exceptions.py +337 -340
- tree_sitter_analyzer/file_handler.py +210 -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 +291 -270
- tree_sitter_analyzer/formatters/python_formatter.py +259 -235
- tree_sitter_analyzer/interfaces/__init__.py +9 -10
- tree_sitter_analyzer/interfaces/cli.py +528 -557
- tree_sitter_analyzer/interfaces/cli_adapter.py +343 -319
- tree_sitter_analyzer/interfaces/mcp_adapter.py +206 -170
- tree_sitter_analyzer/interfaces/mcp_server.py +405 -416
- tree_sitter_analyzer/java_analyzer.py +187 -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 +1174 -1113
- tree_sitter_analyzer/{plugins → languages}/javascript_plugin.py +446 -439
- tree_sitter_analyzer/languages/python_plugin.py +747 -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 +209 -213
- tree_sitter_analyzer/mcp/resources/project_stats_resource.py +555 -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 +654 -557
- tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py +247 -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 +107 -106
- tree_sitter_analyzer/mcp/utils/error_handler.py +549 -549
- tree_sitter_analyzer/models.py +470 -481
- tree_sitter_analyzer/output_manager.py +255 -264
- tree_sitter_analyzer/plugins/__init__.py +280 -334
- tree_sitter_analyzer/plugins/base.py +496 -446
- tree_sitter_analyzer/plugins/manager.py +379 -355
- 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 +257 -260
- tree_sitter_analyzer/table_formatter.py +471 -448
- tree_sitter_analyzer/utils.py +277 -277
- {tree_sitter_analyzer-0.2.0.dist-info → tree_sitter_analyzer-0.4.0.dist-info}/METADATA +23 -8
- tree_sitter_analyzer-0.4.0.dist-info/RECORD +73 -0
- {tree_sitter_analyzer-0.2.0.dist-info → tree_sitter_analyzer-0.4.0.dist-info}/entry_points.txt +2 -1
- tree_sitter_analyzer/plugins/java_plugin.py +0 -625
- tree_sitter_analyzer/plugins/plugin_loader.py +0 -83
- tree_sitter_analyzer/plugins/python_plugin.py +0 -598
- tree_sitter_analyzer/plugins/registry.py +0 -366
- tree_sitter_analyzer-0.2.0.dist-info/RECORD +0 -77
- {tree_sitter_analyzer-0.2.0.dist-info → tree_sitter_analyzer-0.4.0.dist-info}/WHEEL +0 -0
|
@@ -1,394 +1,391 @@
|
|
|
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
|
-
(field_declaration
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
(import_declaration
|
|
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
|
-
|
|
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
|
-
name: (identifier) @
|
|
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
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
"
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
"
|
|
266
|
-
"
|
|
267
|
-
"
|
|
268
|
-
"
|
|
269
|
-
"
|
|
270
|
-
"
|
|
271
|
-
"
|
|
272
|
-
"
|
|
273
|
-
"
|
|
274
|
-
"
|
|
275
|
-
"
|
|
276
|
-
"
|
|
277
|
-
"
|
|
278
|
-
"
|
|
279
|
-
"
|
|
280
|
-
"
|
|
281
|
-
"
|
|
282
|
-
"
|
|
283
|
-
"
|
|
284
|
-
|
|
285
|
-
"
|
|
286
|
-
"
|
|
287
|
-
|
|
288
|
-
"
|
|
289
|
-
"
|
|
290
|
-
"
|
|
291
|
-
"
|
|
292
|
-
"
|
|
293
|
-
"
|
|
294
|
-
"
|
|
295
|
-
"
|
|
296
|
-
"
|
|
297
|
-
"
|
|
298
|
-
"
|
|
299
|
-
"
|
|
300
|
-
"
|
|
301
|
-
"
|
|
302
|
-
"
|
|
303
|
-
"
|
|
304
|
-
"
|
|
305
|
-
"
|
|
306
|
-
"
|
|
307
|
-
"
|
|
308
|
-
"
|
|
309
|
-
"
|
|
310
|
-
"
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
ALL_QUERIES = {}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
クエリ名のリスト
|
|
393
|
-
"""
|
|
394
|
-
return list(JAVA_QUERIES.keys())
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Java Language Queries
|
|
4
|
+
|
|
5
|
+
Tree-sitter queries specific to Java language constructs.
|
|
6
|
+
Covers classes, methods, annotations, imports, and other Java-specific elements.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Java専用クエリライブラリ
|
|
10
|
+
JAVA_QUERIES: dict[str, str] = {
|
|
11
|
+
# --- 基本構造 ---
|
|
12
|
+
"class": """
|
|
13
|
+
(class_declaration) @class
|
|
14
|
+
""",
|
|
15
|
+
"interface": """
|
|
16
|
+
(interface_declaration) @interface
|
|
17
|
+
""",
|
|
18
|
+
"enum": """
|
|
19
|
+
(enum_declaration) @enum
|
|
20
|
+
""",
|
|
21
|
+
"annotation_type": """
|
|
22
|
+
(annotation_type_declaration) @annotation_type
|
|
23
|
+
""",
|
|
24
|
+
# --- メソッドと構築子 ---
|
|
25
|
+
"method": """
|
|
26
|
+
(method_declaration) @method
|
|
27
|
+
""",
|
|
28
|
+
"constructor": """
|
|
29
|
+
(constructor_declaration) @constructor
|
|
30
|
+
""",
|
|
31
|
+
"abstract_method": """
|
|
32
|
+
(method_declaration
|
|
33
|
+
(modifiers) @mod
|
|
34
|
+
(#match? @mod "abstract")) @abstract_method
|
|
35
|
+
""",
|
|
36
|
+
# --- フィールドと変数 ---
|
|
37
|
+
"field": """
|
|
38
|
+
(field_declaration) @field
|
|
39
|
+
""",
|
|
40
|
+
"static_field": """
|
|
41
|
+
(field_declaration
|
|
42
|
+
(modifiers) @mod
|
|
43
|
+
(#match? @mod "static")) @static_field
|
|
44
|
+
""",
|
|
45
|
+
"final_field": """
|
|
46
|
+
(field_declaration
|
|
47
|
+
(modifiers) @mod
|
|
48
|
+
(#match? @mod "final")) @final_field
|
|
49
|
+
""",
|
|
50
|
+
# --- インポートとパッケージ ---
|
|
51
|
+
"import": """
|
|
52
|
+
(import_declaration) @import
|
|
53
|
+
""",
|
|
54
|
+
"static_import": """
|
|
55
|
+
(import_declaration
|
|
56
|
+
"static") @static_import
|
|
57
|
+
""",
|
|
58
|
+
"package": """
|
|
59
|
+
(package_declaration) @package
|
|
60
|
+
""",
|
|
61
|
+
# --- アノテーション ---
|
|
62
|
+
"annotation": """
|
|
63
|
+
(annotation) @annotation
|
|
64
|
+
""",
|
|
65
|
+
"marker_annotation": """
|
|
66
|
+
(marker_annotation) @marker_annotation
|
|
67
|
+
""",
|
|
68
|
+
"annotation_with_params": """
|
|
69
|
+
(annotation
|
|
70
|
+
(annotation_argument_list)) @annotation_with_params
|
|
71
|
+
""",
|
|
72
|
+
# --- Java特有のコンストラクト ---
|
|
73
|
+
"lambda": """
|
|
74
|
+
(lambda_expression) @lambda
|
|
75
|
+
""",
|
|
76
|
+
"try_catch": """
|
|
77
|
+
(try_statement) @try_catch
|
|
78
|
+
""",
|
|
79
|
+
"synchronized_block": """
|
|
80
|
+
(synchronized_statement) @synchronized_block
|
|
81
|
+
""",
|
|
82
|
+
"generic_type": """
|
|
83
|
+
(generic_type) @generic_type
|
|
84
|
+
""",
|
|
85
|
+
# --- 名前のみ抽出 ---
|
|
86
|
+
"class_name": """
|
|
87
|
+
(class_declaration
|
|
88
|
+
name: (identifier) @class_name)
|
|
89
|
+
""",
|
|
90
|
+
"method_name": """
|
|
91
|
+
(method_declaration
|
|
92
|
+
name: (identifier) @method_name)
|
|
93
|
+
""",
|
|
94
|
+
"field_name": """
|
|
95
|
+
(field_declaration
|
|
96
|
+
declarator: (variable_declarator
|
|
97
|
+
name: (identifier) @field_name))
|
|
98
|
+
""",
|
|
99
|
+
# --- 詳細付きクエリ ---
|
|
100
|
+
"class_with_body": """
|
|
101
|
+
(class_declaration
|
|
102
|
+
name: (identifier) @name
|
|
103
|
+
body: (class_body) @body) @class_with_body
|
|
104
|
+
""",
|
|
105
|
+
"method_with_body": """
|
|
106
|
+
(method_declaration
|
|
107
|
+
name: (identifier) @name
|
|
108
|
+
body: (block) @body) @method_with_body
|
|
109
|
+
""",
|
|
110
|
+
"method_with_annotations": """
|
|
111
|
+
(method_declaration
|
|
112
|
+
(modifiers (annotation) @annotation)*
|
|
113
|
+
name: (identifier) @name) @method_with_annotations
|
|
114
|
+
""",
|
|
115
|
+
# --- 継承関係 ---
|
|
116
|
+
"extends_clause": """
|
|
117
|
+
(class_declaration
|
|
118
|
+
(superclass) @extends_clause)
|
|
119
|
+
""",
|
|
120
|
+
"implements_clause": """
|
|
121
|
+
(class_declaration
|
|
122
|
+
(super_interfaces) @implements_clause)
|
|
123
|
+
""",
|
|
124
|
+
# --- 修飾子別 ---
|
|
125
|
+
"public_methods": """
|
|
126
|
+
(method_declaration
|
|
127
|
+
(modifiers) @mod
|
|
128
|
+
(#match? @mod "public")
|
|
129
|
+
name: (identifier) @name) @public_methods
|
|
130
|
+
""",
|
|
131
|
+
"private_methods": """
|
|
132
|
+
(method_declaration
|
|
133
|
+
(modifiers) @mod
|
|
134
|
+
(#match? @mod "private")
|
|
135
|
+
name: (identifier) @name) @private_methods
|
|
136
|
+
""",
|
|
137
|
+
"static_methods": """
|
|
138
|
+
(method_declaration
|
|
139
|
+
(modifiers) @mod
|
|
140
|
+
(#match? @mod "static")
|
|
141
|
+
name: (identifier) @name) @static_methods
|
|
142
|
+
""",
|
|
143
|
+
# --- Spring Framework アノテーション ---
|
|
144
|
+
"spring_controller": """
|
|
145
|
+
(class_declaration
|
|
146
|
+
(modifiers (annotation
|
|
147
|
+
name: (identifier) @annotation_name
|
|
148
|
+
(#match? @annotation_name "Controller|RestController")))
|
|
149
|
+
name: (identifier) @controller_name) @spring_controller
|
|
150
|
+
""",
|
|
151
|
+
"spring_service": """
|
|
152
|
+
(class_declaration
|
|
153
|
+
(modifiers (annotation
|
|
154
|
+
name: (identifier) @annotation_name
|
|
155
|
+
(#match? @annotation_name "Service")))
|
|
156
|
+
name: (identifier) @service_name) @spring_service
|
|
157
|
+
""",
|
|
158
|
+
"spring_repository": """
|
|
159
|
+
(class_declaration
|
|
160
|
+
(modifiers (annotation
|
|
161
|
+
name: (identifier) @annotation_name
|
|
162
|
+
(#match? @annotation_name "Repository")))
|
|
163
|
+
name: (identifier) @repository_name) @spring_repository
|
|
164
|
+
""",
|
|
165
|
+
# --- JPA アノテーション ---
|
|
166
|
+
"jpa_entity": """
|
|
167
|
+
(class_declaration
|
|
168
|
+
(modifiers (annotation
|
|
169
|
+
name: (identifier) @annotation_name
|
|
170
|
+
(#match? @annotation_name "Entity")))
|
|
171
|
+
name: (identifier) @entity_name) @jpa_entity
|
|
172
|
+
""",
|
|
173
|
+
"jpa_id_field": """
|
|
174
|
+
(field_declaration
|
|
175
|
+
(modifiers (annotation
|
|
176
|
+
name: (identifier) @annotation_name
|
|
177
|
+
(#match? @annotation_name "Id")))
|
|
178
|
+
declarator: (variable_declarator
|
|
179
|
+
name: (identifier) @field_name)) @jpa_id_field
|
|
180
|
+
""",
|
|
181
|
+
# --- 構造情報抽出用クエリ ---
|
|
182
|
+
"javadoc_comment": """
|
|
183
|
+
(block_comment) @javadoc_comment
|
|
184
|
+
(#match? @javadoc_comment "^/\\*\\*")
|
|
185
|
+
""",
|
|
186
|
+
"class_with_javadoc": """
|
|
187
|
+
(class_declaration
|
|
188
|
+
name: (identifier) @class_name
|
|
189
|
+
body: (class_body) @class_body) @class_with_javadoc
|
|
190
|
+
""",
|
|
191
|
+
"method_with_javadoc": """
|
|
192
|
+
(method_declaration
|
|
193
|
+
name: (identifier) @method_name
|
|
194
|
+
parameters: (formal_parameters) @parameters
|
|
195
|
+
body: (block) @method_body) @method_with_javadoc
|
|
196
|
+
""",
|
|
197
|
+
"field_with_javadoc": """
|
|
198
|
+
(field_declaration
|
|
199
|
+
type: (_) @field_type
|
|
200
|
+
declarator: (variable_declarator
|
|
201
|
+
name: (identifier) @field_name)) @field_with_javadoc
|
|
202
|
+
""",
|
|
203
|
+
"method_parameters_detailed": """
|
|
204
|
+
(method_declaration
|
|
205
|
+
name: (identifier) @method_name
|
|
206
|
+
parameters: (formal_parameters
|
|
207
|
+
(formal_parameter
|
|
208
|
+
type: (_) @param_type
|
|
209
|
+
name: (identifier) @param_name)*) @parameters) @method_parameters_detailed
|
|
210
|
+
""",
|
|
211
|
+
"class_inheritance_detailed": """
|
|
212
|
+
(class_declaration
|
|
213
|
+
name: (identifier) @class_name
|
|
214
|
+
(superclass
|
|
215
|
+
(type_identifier) @extends_class)?
|
|
216
|
+
(super_interfaces
|
|
217
|
+
(interface_type_list
|
|
218
|
+
(type_identifier) @implements_interface)*)?
|
|
219
|
+
body: (class_body) @class_body) @class_inheritance_detailed
|
|
220
|
+
""",
|
|
221
|
+
"annotation_detailed": """
|
|
222
|
+
(annotation
|
|
223
|
+
name: (identifier) @annotation_name
|
|
224
|
+
(annotation_argument_list
|
|
225
|
+
(element_value_pair
|
|
226
|
+
key: (identifier) @param_key
|
|
227
|
+
value: (_) @param_value)*)?
|
|
228
|
+
) @annotation_detailed
|
|
229
|
+
""",
|
|
230
|
+
"import_detailed": """
|
|
231
|
+
(import_declaration
|
|
232
|
+
"static"? @static_modifier
|
|
233
|
+
(scoped_identifier) @import_path) @import_detailed
|
|
234
|
+
""",
|
|
235
|
+
"package_detailed": """
|
|
236
|
+
(package_declaration
|
|
237
|
+
(scoped_identifier) @package_name) @package_detailed
|
|
238
|
+
""",
|
|
239
|
+
"constructor_detailed": """
|
|
240
|
+
(constructor_declaration
|
|
241
|
+
name: (identifier) @constructor_name
|
|
242
|
+
parameters: (formal_parameters) @parameters
|
|
243
|
+
body: (constructor_body) @constructor_body) @constructor_detailed
|
|
244
|
+
""",
|
|
245
|
+
"enum_constant": """
|
|
246
|
+
(enum_declaration
|
|
247
|
+
body: (enum_body
|
|
248
|
+
(enum_constant
|
|
249
|
+
name: (identifier) @constant_name)*)) @enum_constant
|
|
250
|
+
""",
|
|
251
|
+
"interface_method": """
|
|
252
|
+
(interface_declaration
|
|
253
|
+
body: (interface_body
|
|
254
|
+
(method_declaration
|
|
255
|
+
name: (identifier) @method_name
|
|
256
|
+
parameters: (formal_parameters) @parameters)*)) @interface_method
|
|
257
|
+
""",
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
# クエリの説明
|
|
261
|
+
JAVA_QUERY_DESCRIPTIONS: dict[str, str] = {
|
|
262
|
+
"class": "Javaクラス宣言を抽出",
|
|
263
|
+
"interface": "Javaインターフェース宣言を抽出",
|
|
264
|
+
"enum": "Java列挙型宣言を抽出",
|
|
265
|
+
"annotation_type": "Javaアノテーション型宣言を抽出",
|
|
266
|
+
"method": "Javaメソッド宣言を抽出",
|
|
267
|
+
"constructor": "Javaコンストラクタ宣言を抽出",
|
|
268
|
+
"field": "Javaフィールド宣言を抽出",
|
|
269
|
+
"import": "Javaインポート文を抽出",
|
|
270
|
+
"package": "Javaパッケージ宣言を抽出",
|
|
271
|
+
"annotation": "Javaアノテーションを抽出",
|
|
272
|
+
"lambda": "Javaラムダ式を抽出",
|
|
273
|
+
"try_catch": "Java try-catch文を抽出",
|
|
274
|
+
"class_name": "クラス名のみを抽出",
|
|
275
|
+
"method_name": "メソッド名のみを抽出",
|
|
276
|
+
"field_name": "フィールド名のみを抽出",
|
|
277
|
+
"class_with_body": "クラス宣言と本体を抽出",
|
|
278
|
+
"method_with_body": "メソッド宣言と本体を抽出",
|
|
279
|
+
"extends_clause": "クラスの継承句を抽出",
|
|
280
|
+
"implements_clause": "クラスの実装句を抽出",
|
|
281
|
+
"public_methods": "publicメソッドを抽出",
|
|
282
|
+
"private_methods": "privateメソッドを抽出",
|
|
283
|
+
"static_methods": "staticメソッドを抽出",
|
|
284
|
+
# 構造情報抽出用クエリの説明
|
|
285
|
+
"javadoc_comment": "JavaDocコメントを抽出",
|
|
286
|
+
"class_with_javadoc": "JavaDoc付きクラスを抽出",
|
|
287
|
+
"method_with_javadoc": "JavaDoc付きメソッドを抽出",
|
|
288
|
+
"field_with_javadoc": "JavaDoc付きフィールドを抽出",
|
|
289
|
+
"method_parameters_detailed": "メソッドパラメータの詳細情報を抽出",
|
|
290
|
+
"class_inheritance_detailed": "クラスの継承関係詳細を抽出",
|
|
291
|
+
"annotation_detailed": "アノテーションの詳細情報を抽出",
|
|
292
|
+
"import_detailed": "インポート文の詳細情報を抽出",
|
|
293
|
+
"package_detailed": "パッケージ宣言の詳細情報を抽出",
|
|
294
|
+
"constructor_detailed": "コンストラクタの詳細情報を抽出",
|
|
295
|
+
"enum_constant": "列挙型定数を抽出",
|
|
296
|
+
"interface_method": "インターフェースメソッドを抽出",
|
|
297
|
+
"spring_controller": "Spring Controllerクラスを抽出",
|
|
298
|
+
"spring_service": "Spring Serviceクラスを抽出",
|
|
299
|
+
"spring_repository": "Spring Repositoryクラスを抽出",
|
|
300
|
+
"jpa_entity": "JPA Entityクラスを抽出",
|
|
301
|
+
"abstract_method": "抽象メソッドを抽出",
|
|
302
|
+
"static_field": "静的フィールドを抽出",
|
|
303
|
+
"final_field": "finalフィールドを抽出",
|
|
304
|
+
"static_import": "静的インポート文を抽出",
|
|
305
|
+
"marker_annotation": "マーカーアノテーションを抽出",
|
|
306
|
+
"annotation_with_params": "パラメータ付きアノテーションを抽出",
|
|
307
|
+
"synchronized_block": "synchronized文を抽出",
|
|
308
|
+
"generic_type": "ジェネリック型を抽出",
|
|
309
|
+
"method_with_annotations": "アノテーション付きメソッドを抽出",
|
|
310
|
+
"jpa_id_field": "JPA IDフィールドを抽出",
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def get_java_query(name: str) -> str:
|
|
315
|
+
"""
|
|
316
|
+
指定されたJavaクエリを取得
|
|
317
|
+
|
|
318
|
+
Args:
|
|
319
|
+
name: クエリ名
|
|
320
|
+
|
|
321
|
+
Returns:
|
|
322
|
+
クエリ文字列
|
|
323
|
+
|
|
324
|
+
Raises:
|
|
325
|
+
ValueError: クエリが見つからない場合
|
|
326
|
+
"""
|
|
327
|
+
if name not in JAVA_QUERIES:
|
|
328
|
+
available = list(JAVA_QUERIES.keys())
|
|
329
|
+
raise ValueError(f"Javaクエリ '{name}' は存在しません。利用可能: {available}")
|
|
330
|
+
|
|
331
|
+
return JAVA_QUERIES[name]
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
def get_java_query_description(name: str) -> str:
|
|
335
|
+
"""
|
|
336
|
+
指定されたJavaクエリの説明を取得
|
|
337
|
+
|
|
338
|
+
Args:
|
|
339
|
+
name: クエリ名
|
|
340
|
+
|
|
341
|
+
Returns:
|
|
342
|
+
クエリの説明
|
|
343
|
+
"""
|
|
344
|
+
return JAVA_QUERY_DESCRIPTIONS.get(name, "説明なし")
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
# Convert to ALL_QUERIES format for dynamic loader compatibility
|
|
348
|
+
ALL_QUERIES = {}
|
|
349
|
+
for query_name, query_string in JAVA_QUERIES.items():
|
|
350
|
+
description = JAVA_QUERY_DESCRIPTIONS.get(query_name, "説明なし")
|
|
351
|
+
ALL_QUERIES[query_name] = {"query": query_string, "description": description}
|
|
352
|
+
|
|
353
|
+
# Add common query aliases for cross-language compatibility
|
|
354
|
+
ALL_QUERIES["functions"] = {
|
|
355
|
+
"query": JAVA_QUERIES["method"],
|
|
356
|
+
"description": "すべての関数/メソッド宣言を検索(methodのエイリアス)",
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
ALL_QUERIES["classes"] = {
|
|
360
|
+
"query": JAVA_QUERIES["class"],
|
|
361
|
+
"description": "すべてのクラス宣言を検索(classのエイリアス)",
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
def get_query(name: str) -> str:
|
|
366
|
+
"""Get a specific query by name."""
|
|
367
|
+
if name in ALL_QUERIES:
|
|
368
|
+
return ALL_QUERIES[name]["query"]
|
|
369
|
+
raise ValueError(
|
|
370
|
+
f"Query '{name}' not found. Available queries: {list(ALL_QUERIES.keys())}"
|
|
371
|
+
)
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
def get_all_queries() -> dict:
|
|
375
|
+
"""Get all available queries."""
|
|
376
|
+
return ALL_QUERIES
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def list_queries() -> list:
|
|
380
|
+
"""List all available query names."""
|
|
381
|
+
return list(ALL_QUERIES.keys())
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
def get_available_java_queries() -> list[str]:
|
|
385
|
+
"""
|
|
386
|
+
利用可能なJavaクエリ一覧を取得
|
|
387
|
+
|
|
388
|
+
Returns:
|
|
389
|
+
クエリ名のリスト
|
|
390
|
+
"""
|
|
391
|
+
return list(JAVA_QUERIES.keys())
|