tree-sitter-analyzer 1.5.0__py3-none-any.whl → 1.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 -1
- tree_sitter_analyzer/cli_main.py +3 -1
- tree_sitter_analyzer/formatters/python_formatter.py +161 -20
- tree_sitter_analyzer/languages/python_plugin.py +581 -148
- tree_sitter_analyzer/mcp/server.py +17 -2
- tree_sitter_analyzer/mcp/tools/table_format_tool.py +106 -4
- tree_sitter_analyzer/mcp/utils/file_output_manager.py +257 -0
- tree_sitter_analyzer/models.py +8 -0
- tree_sitter_analyzer/queries/python.py +617 -58
- tree_sitter_analyzer/table_formatter.py +26 -2
- tree_sitter_analyzer-1.6.1.dist-info/METADATA +845 -0
- {tree_sitter_analyzer-1.5.0.dist-info → tree_sitter_analyzer-1.6.1.dist-info}/RECORD +14 -13
- tree_sitter_analyzer-1.5.0.dist-info/METADATA +0 -1229
- {tree_sitter_analyzer-1.5.0.dist-info → tree_sitter_analyzer-1.6.1.dist-info}/WHEEL +0 -0
- {tree_sitter_analyzer-1.5.0.dist-info → tree_sitter_analyzer-1.6.1.dist-info}/entry_points.txt +0 -0
|
@@ -7,6 +7,7 @@ Provides table-formatted output for Java code analysis results.
|
|
|
7
7
|
|
|
8
8
|
import csv
|
|
9
9
|
import io
|
|
10
|
+
import json
|
|
10
11
|
from typing import Any
|
|
11
12
|
|
|
12
13
|
|
|
@@ -44,12 +45,14 @@ class TableFormatter:
|
|
|
44
45
|
result = self._format_compact_table(structure_data)
|
|
45
46
|
elif self.format_type == "csv":
|
|
46
47
|
result = self._format_csv(structure_data)
|
|
48
|
+
elif self.format_type == "json":
|
|
49
|
+
result = self._format_json(structure_data)
|
|
47
50
|
else:
|
|
48
51
|
raise ValueError(f"Unsupported format type: {self.format_type}")
|
|
49
52
|
|
|
50
53
|
# Finally convert to platform-specific newline characters
|
|
51
|
-
# Skip newline conversion for CSV
|
|
52
|
-
if self.format_type
|
|
54
|
+
# Skip newline conversion for CSV and JSON formats
|
|
55
|
+
if self.format_type in ["csv", "json"]:
|
|
53
56
|
return result
|
|
54
57
|
|
|
55
58
|
return self._convert_to_platform_newlines(result)
|
|
@@ -555,6 +558,27 @@ class TableFormatter:
|
|
|
555
558
|
|
|
556
559
|
return csv_content
|
|
557
560
|
|
|
561
|
+
def _format_json(self, data: dict[str, Any]) -> str:
|
|
562
|
+
"""JSON format"""
|
|
563
|
+
# Create a clean JSON structure with all the analysis data
|
|
564
|
+
json_data = {
|
|
565
|
+
"file_info": {
|
|
566
|
+
"file_path": data.get("file_path", ""),
|
|
567
|
+
"language": data.get("language", ""),
|
|
568
|
+
"package": data.get("package"),
|
|
569
|
+
},
|
|
570
|
+
"statistics": data.get("statistics", {}),
|
|
571
|
+
"elements": {
|
|
572
|
+
"classes": data.get("classes", []),
|
|
573
|
+
"methods": data.get("methods", []),
|
|
574
|
+
"fields": data.get("fields", []),
|
|
575
|
+
"imports": data.get("imports", []),
|
|
576
|
+
},
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
# Return formatted JSON with proper indentation
|
|
580
|
+
return json.dumps(json_data, indent=2, ensure_ascii=False)
|
|
581
|
+
|
|
558
582
|
def _format_method_row(self, method: dict[str, Any]) -> str:
|
|
559
583
|
"""Format method row"""
|
|
560
584
|
name = str(method.get("name", ""))
|