tree-sitter-analyzer 0.4.0__py3-none-any.whl → 0.6.1__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 +1 -3
- tree_sitter_analyzer/__main__.py +2 -2
- tree_sitter_analyzer/cli/commands/default_command.py +1 -1
- tree_sitter_analyzer/cli/commands/query_command.py +5 -5
- tree_sitter_analyzer/cli/commands/table_command.py +3 -3
- tree_sitter_analyzer/cli/info_commands.py +14 -13
- tree_sitter_analyzer/cli_main.py +49 -30
- tree_sitter_analyzer/core/analysis_engine.py +21 -21
- tree_sitter_analyzer/core/cache_service.py +31 -31
- tree_sitter_analyzer/core/query.py +502 -502
- tree_sitter_analyzer/encoding_utils.py +5 -2
- tree_sitter_analyzer/file_handler.py +3 -3
- tree_sitter_analyzer/formatters/base_formatter.py +18 -18
- tree_sitter_analyzer/formatters/formatter_factory.py +15 -15
- tree_sitter_analyzer/formatters/java_formatter.py +291 -291
- tree_sitter_analyzer/formatters/python_formatter.py +259 -259
- tree_sitter_analyzer/interfaces/cli_adapter.py +32 -32
- tree_sitter_analyzer/interfaces/mcp_adapter.py +2 -2
- tree_sitter_analyzer/language_detector.py +398 -398
- tree_sitter_analyzer/language_loader.py +224 -224
- tree_sitter_analyzer/languages/java_plugin.py +1174 -1174
- tree_sitter_analyzer/languages/python_plugin.py +10 -2
- tree_sitter_analyzer/mcp/resources/project_stats_resource.py +555 -555
- tree_sitter_analyzer/models.py +470 -470
- tree_sitter_analyzer/output_manager.py +8 -10
- tree_sitter_analyzer/plugins/base.py +33 -0
- tree_sitter_analyzer/queries/java.py +78 -78
- tree_sitter_analyzer/queries/javascript.py +7 -7
- tree_sitter_analyzer/queries/python.py +18 -18
- tree_sitter_analyzer/queries/typescript.py +12 -12
- tree_sitter_analyzer/query_loader.py +13 -13
- tree_sitter_analyzer/table_formatter.py +20 -18
- tree_sitter_analyzer/utils.py +1 -1
- {tree_sitter_analyzer-0.4.0.dist-info → tree_sitter_analyzer-0.6.1.dist-info}/METADATA +10 -10
- {tree_sitter_analyzer-0.4.0.dist-info → tree_sitter_analyzer-0.6.1.dist-info}/RECORD +37 -38
- tree_sitter_analyzer/java_analyzer.py +0 -187
- {tree_sitter_analyzer-0.4.0.dist-info → tree_sitter_analyzer-0.6.1.dist-info}/WHEEL +0 -0
- {tree_sitter_analyzer-0.4.0.dist-info → tree_sitter_analyzer-0.6.1.dist-info}/entry_points.txt +0 -0
|
@@ -61,11 +61,11 @@ class TableFormatter:
|
|
|
61
61
|
if classes is None:
|
|
62
62
|
classes = []
|
|
63
63
|
if len(classes) > 1:
|
|
64
|
-
#
|
|
64
|
+
# Use file name when multiple classes exist
|
|
65
65
|
file_name = data.get("file_path", "Unknown").split("/")[-1].split("\\")[-1]
|
|
66
66
|
lines.append(f"# {file_name}")
|
|
67
67
|
else:
|
|
68
|
-
#
|
|
68
|
+
# Use class name for single class as before
|
|
69
69
|
class_name = classes[0].get("name", "Unknown") if classes else "Unknown"
|
|
70
70
|
lines.append(
|
|
71
71
|
f"# {(data.get('package') or {}).get('name', 'unknown')}.{class_name}"
|
|
@@ -82,7 +82,7 @@ class TableFormatter:
|
|
|
82
82
|
lines.append("```")
|
|
83
83
|
lines.append("")
|
|
84
84
|
|
|
85
|
-
# Class Info -
|
|
85
|
+
# Class Info - Support for multiple classes
|
|
86
86
|
classes = data.get("classes", [])
|
|
87
87
|
if classes is None:
|
|
88
88
|
classes = []
|
|
@@ -98,7 +98,7 @@ class TableFormatter:
|
|
|
98
98
|
line_range = class_info.get("line_range", {})
|
|
99
99
|
lines_str = f"{line_range.get('start', 0)}-{line_range.get('end', 0)}"
|
|
100
100
|
|
|
101
|
-
#
|
|
101
|
+
# Calculate method and field counts for this class
|
|
102
102
|
class_methods = [
|
|
103
103
|
m
|
|
104
104
|
for m in data.get("methods", [])
|
|
@@ -118,7 +118,7 @@ class TableFormatter:
|
|
|
118
118
|
f"| {name} | {class_type} | {visibility} | {lines_str} | {len(class_methods)} | {len(class_fields)} |"
|
|
119
119
|
)
|
|
120
120
|
else:
|
|
121
|
-
#
|
|
121
|
+
# Use traditional format for single class
|
|
122
122
|
lines.append("## Class Info")
|
|
123
123
|
lines.append("| Property | Value |")
|
|
124
124
|
lines.append("|----------|-------|")
|
|
@@ -210,7 +210,7 @@ class TableFormatter:
|
|
|
210
210
|
lines.append(self._format_method_row(method))
|
|
211
211
|
lines.append("")
|
|
212
212
|
|
|
213
|
-
#
|
|
213
|
+
# Remove trailing empty lines
|
|
214
214
|
while lines and lines[-1] == "":
|
|
215
215
|
lines.pop()
|
|
216
216
|
|
|
@@ -229,7 +229,7 @@ class TableFormatter:
|
|
|
229
229
|
lines.append(f"# {package_name}.{class_name}")
|
|
230
230
|
lines.append("")
|
|
231
231
|
|
|
232
|
-
#
|
|
232
|
+
# Basic information
|
|
233
233
|
stats = data.get("statistics") or {}
|
|
234
234
|
lines.append("## Info")
|
|
235
235
|
lines.append("| Property | Value |")
|
|
@@ -239,7 +239,7 @@ class TableFormatter:
|
|
|
239
239
|
lines.append(f"| Fields | {stats.get('field_count', 0)} |")
|
|
240
240
|
lines.append("")
|
|
241
241
|
|
|
242
|
-
#
|
|
242
|
+
# Methods (simplified version)
|
|
243
243
|
methods = data.get("methods", [])
|
|
244
244
|
if methods is None:
|
|
245
245
|
methods = []
|
|
@@ -264,7 +264,7 @@ class TableFormatter:
|
|
|
264
264
|
)
|
|
265
265
|
lines.append("")
|
|
266
266
|
|
|
267
|
-
#
|
|
267
|
+
# Remove trailing empty lines
|
|
268
268
|
while lines and lines[-1] == "":
|
|
269
269
|
lines.pop()
|
|
270
270
|
|
|
@@ -282,7 +282,7 @@ class TableFormatter:
|
|
|
282
282
|
["Type", "Name", "Signature", "Visibility", "Lines", "Complexity", "Doc"]
|
|
283
283
|
)
|
|
284
284
|
|
|
285
|
-
#
|
|
285
|
+
# Fields
|
|
286
286
|
for field in data.get("fields", []):
|
|
287
287
|
writer.writerow(
|
|
288
288
|
[
|
|
@@ -298,7 +298,7 @@ class TableFormatter:
|
|
|
298
298
|
]
|
|
299
299
|
)
|
|
300
300
|
|
|
301
|
-
#
|
|
301
|
+
# Methods
|
|
302
302
|
for method in data.get("methods", []):
|
|
303
303
|
writer.writerow(
|
|
304
304
|
[
|
|
@@ -324,13 +324,15 @@ class TableFormatter:
|
|
|
324
324
|
return csv_content
|
|
325
325
|
|
|
326
326
|
def _format_method_row(self, method: dict[str, Any]) -> str:
|
|
327
|
-
"""
|
|
327
|
+
"""Format method row"""
|
|
328
328
|
name = str(method.get("name", ""))
|
|
329
329
|
signature = self._create_full_signature(method)
|
|
330
330
|
visibility = self._convert_visibility(str(method.get("visibility", "")))
|
|
331
331
|
line_range = method.get("line_range", {})
|
|
332
332
|
lines_str = f"{line_range.get('start', 0)}-{line_range.get('end', 0)}"
|
|
333
|
-
cols_str =
|
|
333
|
+
cols_str = (
|
|
334
|
+
"5-6" # Default value (actual implementation should get accurate values)
|
|
335
|
+
)
|
|
334
336
|
complexity = method.get("complexity_score", 0)
|
|
335
337
|
if self.include_javadoc:
|
|
336
338
|
doc = self._clean_csv_text(
|
|
@@ -342,7 +344,7 @@ class TableFormatter:
|
|
|
342
344
|
return f"| {name} | {signature} | {visibility} | {lines_str} | {cols_str} | {complexity} | {doc} |"
|
|
343
345
|
|
|
344
346
|
def _create_full_signature(self, method: dict[str, Any]) -> str:
|
|
345
|
-
"""
|
|
347
|
+
"""Create complete method signature"""
|
|
346
348
|
params = method.get("parameters", [])
|
|
347
349
|
param_strs = []
|
|
348
350
|
for param in params:
|
|
@@ -366,7 +368,7 @@ class TableFormatter:
|
|
|
366
368
|
return signature
|
|
367
369
|
|
|
368
370
|
def _create_compact_signature(self, method: dict[str, Any]) -> str:
|
|
369
|
-
"""
|
|
371
|
+
"""Create compact method signature"""
|
|
370
372
|
params = method.get("parameters", [])
|
|
371
373
|
param_types = [self._shorten_type(p.get("type", "O")) for p in params]
|
|
372
374
|
params_str = ",".join(param_types)
|
|
@@ -375,7 +377,7 @@ class TableFormatter:
|
|
|
375
377
|
return f"({params_str}):{return_type}"
|
|
376
378
|
|
|
377
379
|
def _shorten_type(self, type_name: Any) -> str:
|
|
378
|
-
"""
|
|
380
|
+
"""Shorten type name"""
|
|
379
381
|
if type_name is None:
|
|
380
382
|
return "O"
|
|
381
383
|
|
|
@@ -423,12 +425,12 @@ class TableFormatter:
|
|
|
423
425
|
return type_mapping.get(type_name, type_name)
|
|
424
426
|
|
|
425
427
|
def _convert_visibility(self, visibility: str) -> str:
|
|
426
|
-
"""
|
|
428
|
+
"""Convert visibility to symbol"""
|
|
427
429
|
mapping = {"public": "+", "private": "-", "protected": "#", "package": "~"}
|
|
428
430
|
return mapping.get(visibility, visibility)
|
|
429
431
|
|
|
430
432
|
def _extract_doc_summary(self, javadoc: str) -> str:
|
|
431
|
-
"""JavaDoc
|
|
433
|
+
"""Extract summary from JavaDoc"""
|
|
432
434
|
if not javadoc:
|
|
433
435
|
return "-"
|
|
434
436
|
|
tree_sitter_analyzer/utils.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tree-sitter-analyzer
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.1
|
|
4
4
|
Summary: Extensible multi-language code analyzer framework using Tree-sitter with dynamic plugin architecture
|
|
5
5
|
Project-URL: Homepage, https://github.com/aimasteracc/tree-sitter-analyzer
|
|
6
6
|
Project-URL: Documentation, https://github.com/aimasteracc/tree-sitter-analyzer#readme
|
|
@@ -35,7 +35,7 @@ Requires-Dist: cachetools>=5.0.0
|
|
|
35
35
|
Requires-Dist: chardet>=5.0.0
|
|
36
36
|
Requires-Dist: tree-sitter-cpp>=0.23.4
|
|
37
37
|
Requires-Dist: tree-sitter-java>=0.23.5
|
|
38
|
-
Requires-Dist: tree-sitter
|
|
38
|
+
Requires-Dist: tree-sitter==0.24.0
|
|
39
39
|
Provides-Extra: all-languages
|
|
40
40
|
Requires-Dist: tree-sitter-c>=0.20.0; extra == 'all-languages'
|
|
41
41
|
Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'all-languages'
|
|
@@ -134,7 +134,7 @@ Description-Content-Type: text/markdown
|
|
|
134
134
|
|
|
135
135
|
[](https://python.org)
|
|
136
136
|
[](LICENSE)
|
|
137
|
-
[](#testing)
|
|
138
138
|
|
|
139
139
|
**Solve the LLM token limit problem for large code files.**
|
|
140
140
|
|
|
@@ -301,14 +301,14 @@ uv sync --extra all --extra mcp
|
|
|
301
301
|
|
|
302
302
|
## 📚 Documentation
|
|
303
303
|
|
|
304
|
-
- **[MCP Setup Guide for Users](MCP_SETUP_USERS.md)** - Simple setup for AI assistant users
|
|
305
|
-
- **[MCP Setup Guide for Developers](MCP_SETUP_DEVELOPERS.md)** - Local development configuration
|
|
306
|
-
- **[API Documentation](docs/api.md)** - Detailed API reference
|
|
307
|
-
- **[Contributing Guide](CONTRIBUTING.md)** - How to contribute
|
|
304
|
+
- **[MCP Setup Guide for Users](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/MCP_SETUP_USERS.md)** - Simple setup for AI assistant users
|
|
305
|
+
- **[MCP Setup Guide for Developers](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/MCP_SETUP_DEVELOPERS.md)** - Local development configuration
|
|
306
|
+
- **[API Documentation](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/docs/api.md)** - Detailed API reference
|
|
307
|
+
- **[Contributing Guide](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/CONTRIBUTING.md)** - How to contribute
|
|
308
308
|
|
|
309
309
|
## 🧪 Testing
|
|
310
310
|
|
|
311
|
-
This project maintains high code quality with **
|
|
311
|
+
This project maintains high code quality with **1126 passing tests**.
|
|
312
312
|
|
|
313
313
|
```bash
|
|
314
314
|
# Run tests
|
|
@@ -324,7 +324,7 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
324
324
|
|
|
325
325
|
## 🤝 Contributing
|
|
326
326
|
|
|
327
|
-
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
327
|
+
We welcome contributions! Please see our [Contributing Guide](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/CONTRIBUTING.md) for details.
|
|
328
328
|
|
|
329
329
|
### 🤖 AI/LLM Collaboration
|
|
330
330
|
|
|
@@ -339,7 +339,7 @@ python llm_code_checker.py --check-all
|
|
|
339
339
|
python llm_code_checker.py path/to/new_file.py
|
|
340
340
|
```
|
|
341
341
|
|
|
342
|
-
📖 **See our [AI Collaboration Guide](AI_COLLABORATION_GUIDE.md) and [LLM Coding Guidelines](LLM_CODING_GUIDELINES.md) for detailed instructions on working with AI systems.**
|
|
342
|
+
📖 **See our [AI Collaboration Guide](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/AI_COLLABORATION_GUIDE.md) and [LLM Coding Guidelines](https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/LLM_CODING_GUIDELINES.md) for detailed instructions on working with AI systems.**
|
|
343
343
|
|
|
344
344
|
---
|
|
345
345
|
|
|
@@ -1,55 +1,54 @@
|
|
|
1
|
-
tree_sitter_analyzer/__init__.py,sha256=
|
|
2
|
-
tree_sitter_analyzer/__main__.py,sha256=
|
|
1
|
+
tree_sitter_analyzer/__init__.py,sha256=s-D-sjxwExZ3p9ur1f9_ueeAQDmAJ5HtTxHiHKOw4XM,3067
|
|
2
|
+
tree_sitter_analyzer/__main__.py,sha256=Zl79tpe4UaMu-7yeztc06tgP0CVMRnvGgas4ZQP5SCs,228
|
|
3
3
|
tree_sitter_analyzer/api.py,sha256=naRtGuZ27AIVfn6Rid0zQcHDI71UpO9Nh4NQM9JyD3c,16954
|
|
4
|
-
tree_sitter_analyzer/cli_main.py,sha256=
|
|
5
|
-
tree_sitter_analyzer/encoding_utils.py,sha256=
|
|
4
|
+
tree_sitter_analyzer/cli_main.py,sha256=YgAymgIYTcJrdyEOwsZmTW_iiyF3LmpEmE6Iy0GTwdA,9284
|
|
5
|
+
tree_sitter_analyzer/encoding_utils.py,sha256=ItN5dKfuGY9xqvUVQIRYjOrb3fZ_8_CEMQMQ31sScvc,14479
|
|
6
6
|
tree_sitter_analyzer/exceptions.py,sha256=PxQzmkwbaK_8JneWNniKNgBIjOwrOW-yYbj5pmQgvRs,9772
|
|
7
|
-
tree_sitter_analyzer/file_handler.py,sha256=
|
|
8
|
-
tree_sitter_analyzer/
|
|
9
|
-
tree_sitter_analyzer/
|
|
10
|
-
tree_sitter_analyzer/
|
|
11
|
-
tree_sitter_analyzer/
|
|
12
|
-
tree_sitter_analyzer/
|
|
13
|
-
tree_sitter_analyzer/
|
|
14
|
-
tree_sitter_analyzer/
|
|
15
|
-
tree_sitter_analyzer/utils.py,sha256=B75-lozMxALATmYZE1guJPKgS8k2KeRjhyfg1EqSbio,7994
|
|
7
|
+
tree_sitter_analyzer/file_handler.py,sha256=MnbK3aMk6tzB-sjF2U58YHbqqijvecNQqql16K-IM5s,6894
|
|
8
|
+
tree_sitter_analyzer/language_detector.py,sha256=IjkYF1E7_TtWlwYjz780ZUJAyPltL2aZVzo-doTbAug,12540
|
|
9
|
+
tree_sitter_analyzer/language_loader.py,sha256=gdLxkSoajm-q7c1vcvFONtBf5XJRgasUVI4L0wMzra0,8124
|
|
10
|
+
tree_sitter_analyzer/models.py,sha256=z0aqdZOVA8rYWF0143TSAUoCvncVRLZ1O70eAjV87gU,16564
|
|
11
|
+
tree_sitter_analyzer/output_manager.py,sha256=saZ8Ss6PhUJgjjwviLgrePFL7CCLMixxdKtdrpuFgHM,8146
|
|
12
|
+
tree_sitter_analyzer/query_loader.py,sha256=jcJc6_kIMeZINfTVGuiEmDii9LViP_pbJfg4A9phJY4,9863
|
|
13
|
+
tree_sitter_analyzer/table_formatter.py,sha256=NS8nPrgi_tjlqksRXtoPCv6NAUD4scNPH_-MQAIdU1s,17798
|
|
14
|
+
tree_sitter_analyzer/utils.py,sha256=AarFoPxiU20y8U8ysy8G6JWK-XLMP3tUoySv6qc8nr8,7991
|
|
16
15
|
tree_sitter_analyzer/cli/__init__.py,sha256=O_3URpbdu5Ilb2-r48LjbZuWtOWQu_BhL3pa6C0G3Bk,871
|
|
17
16
|
tree_sitter_analyzer/cli/__main__.py,sha256=Xq8o8-0dPnMDU9WZqmqhzr98rx8rvoffTUHAkAwl-L8,218
|
|
18
|
-
tree_sitter_analyzer/cli/info_commands.py,sha256=
|
|
17
|
+
tree_sitter_analyzer/cli/info_commands.py,sha256=UjgjDi3RQy_lqvj00FP1Qj-yas-5bB_ZTZcp6MWXiUM,4298
|
|
19
18
|
tree_sitter_analyzer/cli/commands/__init__.py,sha256=jpcpM1ptLuxLMBDUv1y_a87k8RAw1otFzeYpWtXvz3Y,671
|
|
20
19
|
tree_sitter_analyzer/cli/commands/advanced_command.py,sha256=xDZI4zKTMHNdf7fc_QN0eAQ8a5MnRb5DJ29ERLBDUQs,3424
|
|
21
20
|
tree_sitter_analyzer/cli/commands/base_command.py,sha256=dNg1JkWSPLHsjIF8yTtVUNk_b7FqM-hGRiHl47ztkqw,5787
|
|
22
|
-
tree_sitter_analyzer/cli/commands/default_command.py,sha256=
|
|
21
|
+
tree_sitter_analyzer/cli/commands/default_command.py,sha256=qUHmop7ya_wyDfAlCOI7klESDuBU9rRo7V7Lle8gzKo,531
|
|
23
22
|
tree_sitter_analyzer/cli/commands/partial_read_command.py,sha256=R-dfWvVKxGdZyeieNjJAZQvgM13O3JZa6Fkmjc3sDqk,4684
|
|
24
|
-
tree_sitter_analyzer/cli/commands/query_command.py,sha256=
|
|
23
|
+
tree_sitter_analyzer/cli/commands/query_command.py,sha256=iGa-kebJhsUgsk1HMREdVKItWHwBZXr7AEwcE2LVUAI,3119
|
|
25
24
|
tree_sitter_analyzer/cli/commands/structure_command.py,sha256=0iJwjOgtW838hXleXogWhbu6eQFfrLR1QgKe5PFBqvU,5220
|
|
26
25
|
tree_sitter_analyzer/cli/commands/summary_command.py,sha256=02WA3sOzfT83FVT6sW7nK04zVcZ9Qj_1S0WloqlTnFk,3602
|
|
27
|
-
tree_sitter_analyzer/cli/commands/table_command.py,sha256=
|
|
26
|
+
tree_sitter_analyzer/cli/commands/table_command.py,sha256=EtMVI_Ui1wTblcDpSHWVOvoN-Ne_QJxT0iE7JtqYRxA,9448
|
|
28
27
|
tree_sitter_analyzer/core/__init__.py,sha256=VlYOy1epW16vjaVd__knESewnU0sfXF9a4hjrFxiSEE,440
|
|
29
|
-
tree_sitter_analyzer/core/analysis_engine.py,sha256=
|
|
30
|
-
tree_sitter_analyzer/core/cache_service.py,sha256=
|
|
28
|
+
tree_sitter_analyzer/core/analysis_engine.py,sha256=ReWaW-ZtuyKwtR-XdVd8J-A0oN5tWmKUEyZS6LJJa8E,18567
|
|
29
|
+
tree_sitter_analyzer/core/cache_service.py,sha256=TQrOI9xwI-0KRF8c6-cXwXM1Ut3AhLOXa4GpyQsIHW4,9624
|
|
31
30
|
tree_sitter_analyzer/core/engine.py,sha256=6vdXcYfcHqv9tyJfT7iRPsdIIndf73wo71qT6Rt9Zow,18356
|
|
32
31
|
tree_sitter_analyzer/core/parser.py,sha256=qT3yIlTRdod4tf_2o1hU_B-GYGukyM2BtaFxzSoxois,9293
|
|
33
|
-
tree_sitter_analyzer/core/query.py,sha256=
|
|
32
|
+
tree_sitter_analyzer/core/query.py,sha256=fmuPMLsU4XUnMViaQADPRPoiZ-MzeE2k_e9N35VBNSA,16899
|
|
34
33
|
tree_sitter_analyzer/formatters/__init__.py,sha256=yVb4HF_4EEPRwTf3y3-vM2NllrhykG3zlvQhN-6dB4c,31
|
|
35
|
-
tree_sitter_analyzer/formatters/base_formatter.py,sha256=
|
|
36
|
-
tree_sitter_analyzer/formatters/formatter_factory.py,sha256=
|
|
37
|
-
tree_sitter_analyzer/formatters/java_formatter.py,sha256=
|
|
38
|
-
tree_sitter_analyzer/formatters/python_formatter.py,sha256=
|
|
34
|
+
tree_sitter_analyzer/formatters/base_formatter.py,sha256=Uv6uVgUKwbBn6of26bnvr4u6CmX2ka1a405VL17CGFU,5763
|
|
35
|
+
tree_sitter_analyzer/formatters/formatter_factory.py,sha256=mCnAbEHycoSttSuF4dU78hzcxyg-h57bo0_bj00zw58,2069
|
|
36
|
+
tree_sitter_analyzer/formatters/java_formatter.py,sha256=MKssGZwvOXxARq-P9DT0ksclAYC3YpVQuY3c-oiKQhI,11622
|
|
37
|
+
tree_sitter_analyzer/formatters/python_formatter.py,sha256=HkkUu5O7pGvw2e5SSsQTSUJWkS84pg6uuIkiG0lDxkQ,10275
|
|
39
38
|
tree_sitter_analyzer/interfaces/__init__.py,sha256=OcT7eNIU0ZXvAeAXbhDqRG3puxn93HeSLqplwj6npTM,271
|
|
40
39
|
tree_sitter_analyzer/interfaces/cli.py,sha256=EsRcy0Wrt5BzR8RxBaXToH29XZoahR-fSLwGaMyf2LE,16840
|
|
41
|
-
tree_sitter_analyzer/interfaces/cli_adapter.py,sha256=
|
|
42
|
-
tree_sitter_analyzer/interfaces/mcp_adapter.py,sha256=
|
|
40
|
+
tree_sitter_analyzer/interfaces/cli_adapter.py,sha256=ANl2kEirv5_mf87dlZRZvMp_oqLQT8khyyVH50khARA,11192
|
|
41
|
+
tree_sitter_analyzer/interfaces/mcp_adapter.py,sha256=DJugCRVL-AR6gJRaRrBW5JVXRvfl_iiRjupcnsb0_sE,7111
|
|
43
42
|
tree_sitter_analyzer/interfaces/mcp_server.py,sha256=TvcmWWRxyWp5LrbDRGAeTZww_mmyarA8Mz9eL5xiQv0,16200
|
|
44
43
|
tree_sitter_analyzer/languages/__init__.py,sha256=VTXxJgVjHJAciLhX0zzXOS4EygZMtebeYUbi_0z6fGw,340
|
|
45
|
-
tree_sitter_analyzer/languages/java_plugin.py,sha256=
|
|
44
|
+
tree_sitter_analyzer/languages/java_plugin.py,sha256=jhrOeJhp3CBMW_bjWXWwoc78DxGsLzo6YAUtkY4hJ-c,47076
|
|
46
45
|
tree_sitter_analyzer/languages/javascript_plugin.py,sha256=k14kHfi5II9MRTsVuy0NQq5l2KZYncCnM1Q6T1c5q_U,15844
|
|
47
|
-
tree_sitter_analyzer/languages/python_plugin.py,sha256=
|
|
46
|
+
tree_sitter_analyzer/languages/python_plugin.py,sha256=MJ03F_Nv-nmInIkEFmPyEXYhyGbLHyr5kCbj2taEDYk,29144
|
|
48
47
|
tree_sitter_analyzer/mcp/__init__.py,sha256=76ZKgWbsXZWB8mNER2D0fNHdULPZhqqBJHi8R0uHDPE,721
|
|
49
48
|
tree_sitter_analyzer/mcp/server.py,sha256=chXNK7jA9SgEqZElKjej63pDvYJqN0cHBzZES0R818s,12426
|
|
50
49
|
tree_sitter_analyzer/mcp/resources/__init__.py,sha256=SWnK8liTQkuQXlVgyRP9mf5HzpqmqohShrC98xlNnDc,1389
|
|
51
50
|
tree_sitter_analyzer/mcp/resources/code_file_resource.py,sha256=POhQ1xPMiGBVVm6AfOQNKM29svDLvlGLA97ZPQgVoHw,6253
|
|
52
|
-
tree_sitter_analyzer/mcp/resources/project_stats_resource.py,sha256=
|
|
51
|
+
tree_sitter_analyzer/mcp/resources/project_stats_resource.py,sha256=lZF9TGxjKvTwPyuWE_o3I3V4LK0zEj3lab4L0Iq-hho,19758
|
|
53
52
|
tree_sitter_analyzer/mcp/tools/__init__.py,sha256=u7JrSLwE95y50mfjSus6HRdtdhkNbVrW8jP4AooawEU,762
|
|
54
53
|
tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py,sha256=njQxFS5507RolQR_nEJEnZVQMfs2MBEenWEhDYJC1_o,26343
|
|
55
54
|
tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py,sha256=mssed7bEfGeGxW4mOf7dg8BDS1oqHLolIBNX9DaZ3DM,8997
|
|
@@ -60,14 +59,14 @@ tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py,sha256=Wl4wZWHYbvcYKnFm
|
|
|
60
59
|
tree_sitter_analyzer/mcp/utils/__init__.py,sha256=hibcoJc9PEetXqPIpvwHw1cpr1rabAm0QQaDZpxvA_g,2956
|
|
61
60
|
tree_sitter_analyzer/mcp/utils/error_handler.py,sha256=QgKqjUhe0QTCRrtoiuTxDMUt-eDRNclf1ToJtaCNoq8,17423
|
|
62
61
|
tree_sitter_analyzer/plugins/__init__.py,sha256=ITE9bTz7NO4axnn8g5Z-1_ydhSLT0RnY6Y1J9OhUP3E,10326
|
|
63
|
-
tree_sitter_analyzer/plugins/base.py,sha256=
|
|
62
|
+
tree_sitter_analyzer/plugins/base.py,sha256=FMRAOtjtDutNV8RnB6cmFgdvcjxKRAbrrzqldBBT1yk,17167
|
|
64
63
|
tree_sitter_analyzer/plugins/manager.py,sha256=PyEY3jeuCBpDVqguWhaAu7nzUZM17_pI6wml2e0Hamo,12535
|
|
65
64
|
tree_sitter_analyzer/queries/__init__.py,sha256=dwDDc7PCw_UWruxSeJ8uEBjY0O5uLDBI5YqyvBhbnN0,696
|
|
66
|
-
tree_sitter_analyzer/queries/java.py,sha256=
|
|
67
|
-
tree_sitter_analyzer/queries/javascript.py,sha256=
|
|
68
|
-
tree_sitter_analyzer/queries/python.py,sha256=
|
|
69
|
-
tree_sitter_analyzer/queries/typescript.py,sha256=
|
|
70
|
-
tree_sitter_analyzer-0.
|
|
71
|
-
tree_sitter_analyzer-0.
|
|
72
|
-
tree_sitter_analyzer-0.
|
|
73
|
-
tree_sitter_analyzer-0.
|
|
65
|
+
tree_sitter_analyzer/queries/java.py,sha256=NZTSzFADlGrm3MD0oIkOdkN_6wP2pGZpNs0Rb7I_mcw,12249
|
|
66
|
+
tree_sitter_analyzer/queries/javascript.py,sha256=pnXrgISwDE5GhPHDbUKEGI3thyLmebTeQt-l_-x4qT8,3962
|
|
67
|
+
tree_sitter_analyzer/queries/python.py,sha256=L33KRUyV3sAvA3_HFkPyGgtiq0ygSpNY_n2YojodPlc,7570
|
|
68
|
+
tree_sitter_analyzer/queries/typescript.py,sha256=eersyAF7TladuCWa8WE_-cO9YTF1LUSjLIl-tk2fZDo,6708
|
|
69
|
+
tree_sitter_analyzer-0.6.1.dist-info/METADATA,sha256=UAy45w-jCB94SHqwqoR6iFXeHC99Lq33d4iBR4lBeQY,13410
|
|
70
|
+
tree_sitter_analyzer-0.6.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
71
|
+
tree_sitter_analyzer-0.6.1.dist-info/entry_points.txt,sha256=EA0Ow27x2SqNt2300sv70RTWxKRIxJzOhNPIVlez4NM,417
|
|
72
|
+
tree_sitter_analyzer-0.6.1.dist-info/RECORD,,
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
Java Code Analyzer with tree-sitter
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
from typing import Any
|
|
7
|
-
|
|
8
|
-
try:
|
|
9
|
-
import tree_sitter
|
|
10
|
-
import tree_sitter_java as tsjava
|
|
11
|
-
from tree_sitter import Language, Parser
|
|
12
|
-
|
|
13
|
-
TREE_SITTER_AVAILABLE = True
|
|
14
|
-
except ImportError:
|
|
15
|
-
TREE_SITTER_AVAILABLE = False
|
|
16
|
-
from .utils import log_error
|
|
17
|
-
|
|
18
|
-
log_error(
|
|
19
|
-
"tree-sitter libraries not found. Please install tree-sitter and tree-sitter-java."
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
from .file_handler import read_file_with_fallback
|
|
23
|
-
from .output_manager import output_error, output_info, output_warning
|
|
24
|
-
from .utils import log_error, log_info
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class CodeAnalyzer:
|
|
28
|
-
"""
|
|
29
|
-
Tree-sitterを使用してソースコードを解析するコアクラス。
|
|
30
|
-
|
|
31
|
-
Attributes:
|
|
32
|
-
language: Tree-sitter言語オブジェクト
|
|
33
|
-
parser: Tree-sitterパーサー
|
|
34
|
-
source_code_bytes: 解析対象のソースコードのバイト列
|
|
35
|
-
tree: 構築されたAST
|
|
36
|
-
"""
|
|
37
|
-
|
|
38
|
-
def __init__(self, language: str = "java") -> None:
|
|
39
|
-
"""
|
|
40
|
-
指定された言語用のパーサーを初期化する。
|
|
41
|
-
|
|
42
|
-
Args:
|
|
43
|
-
language: 解析対象のプログラミング言語。現在はJavaのみサポート。
|
|
44
|
-
|
|
45
|
-
Raises:
|
|
46
|
-
SystemExit: Tree-sitterライブラリの初期化に失敗した場合
|
|
47
|
-
"""
|
|
48
|
-
if not TREE_SITTER_AVAILABLE:
|
|
49
|
-
output_error("ERROR: Tree-sitter libraries not available.")
|
|
50
|
-
raise RuntimeError("Tree-sitter libraries not available")
|
|
51
|
-
|
|
52
|
-
try:
|
|
53
|
-
if language != "java":
|
|
54
|
-
output_warning(
|
|
55
|
-
"WARNING: Currently only Java is supported. Using Java parser."
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
self.language = Language(tsjava.language())
|
|
59
|
-
self.parser = Parser(self.language)
|
|
60
|
-
self.source_code_bytes: bytes = b""
|
|
61
|
-
self.tree: tree_sitter.Tree | None = None
|
|
62
|
-
|
|
63
|
-
except Exception as e:
|
|
64
|
-
output_error(
|
|
65
|
-
f"ERROR: '{language}' 言語の初期化に失敗しました。ライブラリが正しくインストールされているか確認してください。"
|
|
66
|
-
)
|
|
67
|
-
output_error(f"詳細: {e}")
|
|
68
|
-
raise RuntimeError(
|
|
69
|
-
f"Failed to initialize language '{language}': {e}"
|
|
70
|
-
) from e
|
|
71
|
-
|
|
72
|
-
def parse_file(self, file_path: str) -> bool:
|
|
73
|
-
"""
|
|
74
|
-
指定されたファイルを解析し、AST(抽象構文木)を構築する。
|
|
75
|
-
|
|
76
|
-
Args:
|
|
77
|
-
file_path: 解析するソースファイルのパス
|
|
78
|
-
|
|
79
|
-
Returns:
|
|
80
|
-
解析に成功した場合はTrue、失敗した場合はFalse
|
|
81
|
-
|
|
82
|
-
Raises:
|
|
83
|
-
None: エラーは内部でハンドリングし、戻り値で示す
|
|
84
|
-
"""
|
|
85
|
-
try:
|
|
86
|
-
source_bytes = read_file_with_fallback(file_path)
|
|
87
|
-
if source_bytes is None:
|
|
88
|
-
output_error(
|
|
89
|
-
f"ERROR: ファイル '{file_path}' の読み込みに失敗しました。"
|
|
90
|
-
)
|
|
91
|
-
return False
|
|
92
|
-
|
|
93
|
-
self.source_code_bytes = source_bytes
|
|
94
|
-
self.tree = self.parser.parse(self.source_code_bytes)
|
|
95
|
-
|
|
96
|
-
# Tree parsing should always succeed with valid input
|
|
97
|
-
log_info(f"INFO: '{file_path}' の解析が完了し、ASTを構築しました。")
|
|
98
|
-
return True
|
|
99
|
-
|
|
100
|
-
except Exception as e:
|
|
101
|
-
output_error(f"ERROR: ファイル解析中にエラーが発生しました: {e}")
|
|
102
|
-
return False
|
|
103
|
-
|
|
104
|
-
def execute_query(self, query_string: str) -> list[dict[str, Any]]:
|
|
105
|
-
"""
|
|
106
|
-
ASTに対して指定されたクエリを実行し、マッチしたノードの情報を抽出する。
|
|
107
|
-
|
|
108
|
-
Args:
|
|
109
|
-
query_string: 実行するTree-sitterクエリ
|
|
110
|
-
|
|
111
|
-
Returns:
|
|
112
|
-
マッチした各ノードの情報(内容、位置、キャプチャ名)のリスト
|
|
113
|
-
|
|
114
|
-
Raises:
|
|
115
|
-
None: エラーは内部でハンドリングし、空リストを返す
|
|
116
|
-
"""
|
|
117
|
-
if not self.tree:
|
|
118
|
-
output_error(
|
|
119
|
-
"ERROR: ASTが構築されていません。先にparse_fileを実行してください。"
|
|
120
|
-
)
|
|
121
|
-
return []
|
|
122
|
-
|
|
123
|
-
try:
|
|
124
|
-
query = self.language.query(query_string)
|
|
125
|
-
except Exception as e:
|
|
126
|
-
output_error(
|
|
127
|
-
f"ERROR: クエリのコンパイルに失敗しました。\nクエリ: {query_string}\nエラー: {e}"
|
|
128
|
-
)
|
|
129
|
-
return []
|
|
130
|
-
|
|
131
|
-
try:
|
|
132
|
-
captures = query.captures(self.tree.root_node)
|
|
133
|
-
except Exception as e:
|
|
134
|
-
output_error(f"ERROR: クエリの実行に失敗しました: {e}")
|
|
135
|
-
return []
|
|
136
|
-
|
|
137
|
-
results = []
|
|
138
|
-
|
|
139
|
-
# Tree-sitter 0.24以降の辞書形式に対応
|
|
140
|
-
try:
|
|
141
|
-
# 辞書形式: {capture_name: [nodes...]}
|
|
142
|
-
for capture_name, nodes in captures.items():
|
|
143
|
-
if isinstance(nodes, list):
|
|
144
|
-
for node in nodes:
|
|
145
|
-
try:
|
|
146
|
-
start_line = node.start_point[0] + 1
|
|
147
|
-
end_line = node.end_point[0] + 1
|
|
148
|
-
node_text = self.source_code_bytes[
|
|
149
|
-
node.start_byte : node.end_byte
|
|
150
|
-
].decode("utf-8", errors="ignore")
|
|
151
|
-
|
|
152
|
-
results.append(
|
|
153
|
-
{
|
|
154
|
-
"capture_name": capture_name,
|
|
155
|
-
"content": node_text,
|
|
156
|
-
"start_line": start_line,
|
|
157
|
-
"end_line": end_line,
|
|
158
|
-
"node_type": node.type,
|
|
159
|
-
}
|
|
160
|
-
)
|
|
161
|
-
except Exception as e:
|
|
162
|
-
output_warning(
|
|
163
|
-
f"WARNING: ノード処理中にエラーが発生しました: {e}"
|
|
164
|
-
)
|
|
165
|
-
continue
|
|
166
|
-
|
|
167
|
-
except Exception as e:
|
|
168
|
-
output_error(f"ERROR: capture処理中に予期しないエラーが発生しました: {e}")
|
|
169
|
-
return []
|
|
170
|
-
|
|
171
|
-
return results
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
def main() -> None:
|
|
175
|
-
"""
|
|
176
|
-
モジュールが直接実行された場合のエントリーポイント。
|
|
177
|
-
通常はcli.pyを使用することを推奨。
|
|
178
|
-
"""
|
|
179
|
-
output_warning("注意: 直接的なモジュール実行は非推奨です。")
|
|
180
|
-
output_warning("代わりに以下を使用してください:")
|
|
181
|
-
output_info(" uv run java-analyzer <file> --query-key <key>")
|
|
182
|
-
output_info(" または")
|
|
183
|
-
output_info(" python -m tree_sitter_analyzer.cli <file> --query-key <key>")
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if __name__ == "__main__":
|
|
187
|
-
main()
|
|
File without changes
|
{tree_sitter_analyzer-0.4.0.dist-info → tree_sitter_analyzer-0.6.1.dist-info}/entry_points.txt
RENAMED
|
File without changes
|