tree-sitter-analyzer 0.9.1__py3-none-any.whl → 0.9.3__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 +181 -178
- tree_sitter_analyzer/cli/commands/structure_command.py +138 -138
- tree_sitter_analyzer/cli/commands/summary_command.py +101 -101
- tree_sitter_analyzer/cli_main.py +7 -3
- tree_sitter_analyzer/core/__init__.py +15 -15
- tree_sitter_analyzer/core/analysis_engine.py +91 -87
- 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/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/formatters/java_formatter.py +18 -18
- tree_sitter_analyzer/formatters/python_formatter.py +19 -19
- tree_sitter_analyzer/interfaces/__init__.py +9 -9
- tree_sitter_analyzer/interfaces/cli.py +528 -528
- tree_sitter_analyzer/interfaces/cli_adapter.py +344 -343
- tree_sitter_analyzer/interfaces/mcp_adapter.py +206 -206
- tree_sitter_analyzer/language_detector.py +53 -53
- tree_sitter_analyzer/languages/__init__.py +10 -10
- tree_sitter_analyzer/languages/java_plugin.py +1 -1
- tree_sitter_analyzer/languages/javascript_plugin.py +446 -446
- tree_sitter_analyzer/languages/python_plugin.py +755 -755
- tree_sitter_analyzer/mcp/__init__.py +34 -45
- 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 +623 -568
- tree_sitter_analyzer/mcp/tools/__init__.py +30 -30
- tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +681 -673
- 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 +310 -308
- tree_sitter_analyzer/mcp/tools/table_format_tool.py +386 -379
- tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py +563 -559
- tree_sitter_analyzer/mcp/utils/__init__.py +107 -107
- tree_sitter_analyzer/models.py +10 -10
- 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/project_detector.py +330 -317
- 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/boundary_manager.py +57 -51
- tree_sitter_analyzer/security/validator.py +246 -241
- tree_sitter_analyzer/utils.py +294 -277
- {tree_sitter_analyzer-0.9.1.dist-info → tree_sitter_analyzer-0.9.3.dist-info}/METADATA +13 -13
- tree_sitter_analyzer-0.9.3.dist-info/RECORD +77 -0
- {tree_sitter_analyzer-0.9.1.dist-info → tree_sitter_analyzer-0.9.3.dist-info}/entry_points.txt +1 -0
- tree_sitter_analyzer-0.9.1.dist-info/RECORD +0 -77
- {tree_sitter_analyzer-0.9.1.dist-info → tree_sitter_analyzer-0.9.3.dist-info}/WHEEL +0 -0
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
Summary Command
|
|
4
|
-
|
|
5
|
-
Handles summary functionality with specified element types.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
from typing import TYPE_CHECKING, Any
|
|
9
|
-
|
|
10
|
-
from ...output_manager import output_data, output_json, output_section
|
|
11
|
-
from .base_command import BaseCommand
|
|
12
|
-
|
|
13
|
-
if TYPE_CHECKING:
|
|
14
|
-
from ...models import AnalysisResult
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class SummaryCommand(BaseCommand):
|
|
18
|
-
"""Command for summary analysis with specified element types."""
|
|
19
|
-
|
|
20
|
-
async def execute_async(self, language: str) -> int:
|
|
21
|
-
analysis_result = await self.analyze_file(language)
|
|
22
|
-
if not analysis_result:
|
|
23
|
-
return 1
|
|
24
|
-
|
|
25
|
-
self._output_summary_analysis(analysis_result)
|
|
26
|
-
return 0
|
|
27
|
-
|
|
28
|
-
def _output_summary_analysis(self, analysis_result: "AnalysisResult") -> None:
|
|
29
|
-
"""Output summary analysis results."""
|
|
30
|
-
output_section("Summary Results")
|
|
31
|
-
|
|
32
|
-
# Get summary types from args (default: classes,methods)
|
|
33
|
-
summary_types = getattr(self.args, "summary", "classes,methods")
|
|
34
|
-
if summary_types:
|
|
35
|
-
requested_types = [t.strip() for t in summary_types.split(",")]
|
|
36
|
-
else:
|
|
37
|
-
requested_types = ["classes", "methods"]
|
|
38
|
-
|
|
39
|
-
# Extract elements by type
|
|
40
|
-
classes = [
|
|
41
|
-
e for e in analysis_result.elements if e.__class__.__name__ == "Class"
|
|
42
|
-
]
|
|
43
|
-
methods = [
|
|
44
|
-
e for e in analysis_result.elements if e.__class__.__name__ == "Function"
|
|
45
|
-
]
|
|
46
|
-
fields = [
|
|
47
|
-
e for e in analysis_result.elements if e.__class__.__name__ == "Variable"
|
|
48
|
-
]
|
|
49
|
-
imports = [
|
|
50
|
-
e for e in analysis_result.elements if e.__class__.__name__ == "Import"
|
|
51
|
-
]
|
|
52
|
-
|
|
53
|
-
summary_data: dict[str, Any] = {
|
|
54
|
-
"file_path": analysis_result.file_path,
|
|
55
|
-
"language": analysis_result.language,
|
|
56
|
-
"summary": {},
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if "classes" in requested_types:
|
|
60
|
-
summary_data["summary"]["classes"] = [
|
|
61
|
-
{"name": getattr(c, "name", "unknown")} for c in classes
|
|
62
|
-
]
|
|
63
|
-
|
|
64
|
-
if "methods" in requested_types:
|
|
65
|
-
summary_data["summary"]["methods"] = [
|
|
66
|
-
{"name": getattr(m, "name", "unknown")} for m in methods
|
|
67
|
-
]
|
|
68
|
-
|
|
69
|
-
if "fields" in requested_types:
|
|
70
|
-
summary_data["summary"]["fields"] = [
|
|
71
|
-
{"name": getattr(f, "name", "unknown")} for f in fields
|
|
72
|
-
]
|
|
73
|
-
|
|
74
|
-
if "imports" in requested_types:
|
|
75
|
-
summary_data["summary"]["imports"] = [
|
|
76
|
-
{"name": getattr(i, "name", "unknown")} for i in imports
|
|
77
|
-
]
|
|
78
|
-
|
|
79
|
-
if self.args.output_format == "json":
|
|
80
|
-
output_json(summary_data)
|
|
81
|
-
else:
|
|
82
|
-
self._output_text_format(summary_data, requested_types)
|
|
83
|
-
|
|
84
|
-
def _output_text_format(self, summary_data: dict, requested_types: list) -> None:
|
|
85
|
-
"""Output summary in human-readable text format."""
|
|
86
|
-
output_data(f"File: {summary_data['file_path']}")
|
|
87
|
-
output_data(f"Language: {summary_data['language']}")
|
|
88
|
-
|
|
89
|
-
for element_type in requested_types:
|
|
90
|
-
if element_type in summary_data["summary"]:
|
|
91
|
-
elements = summary_data["summary"][element_type]
|
|
92
|
-
type_name_map = {
|
|
93
|
-
"classes": "Classes",
|
|
94
|
-
"methods": "Methods",
|
|
95
|
-
"fields": "Fields",
|
|
96
|
-
"imports": "Imports",
|
|
97
|
-
}
|
|
98
|
-
type_name = type_name_map.get(element_type, element_type)
|
|
99
|
-
output_data(f"\n{type_name} ({len(elements)} items):")
|
|
100
|
-
for element in elements:
|
|
101
|
-
output_data(f" - {element['name']}")
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Summary Command
|
|
4
|
+
|
|
5
|
+
Handles summary functionality with specified element types.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import TYPE_CHECKING, Any
|
|
9
|
+
|
|
10
|
+
from ...output_manager import output_data, output_json, output_section
|
|
11
|
+
from .base_command import BaseCommand
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from ...models import AnalysisResult
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class SummaryCommand(BaseCommand):
|
|
18
|
+
"""Command for summary analysis with specified element types."""
|
|
19
|
+
|
|
20
|
+
async def execute_async(self, language: str) -> int:
|
|
21
|
+
analysis_result = await self.analyze_file(language)
|
|
22
|
+
if not analysis_result:
|
|
23
|
+
return 1
|
|
24
|
+
|
|
25
|
+
self._output_summary_analysis(analysis_result)
|
|
26
|
+
return 0
|
|
27
|
+
|
|
28
|
+
def _output_summary_analysis(self, analysis_result: "AnalysisResult") -> None:
|
|
29
|
+
"""Output summary analysis results."""
|
|
30
|
+
output_section("Summary Results")
|
|
31
|
+
|
|
32
|
+
# Get summary types from args (default: classes,methods)
|
|
33
|
+
summary_types = getattr(self.args, "summary", "classes,methods")
|
|
34
|
+
if summary_types:
|
|
35
|
+
requested_types = [t.strip() for t in summary_types.split(",")]
|
|
36
|
+
else:
|
|
37
|
+
requested_types = ["classes", "methods"]
|
|
38
|
+
|
|
39
|
+
# Extract elements by type
|
|
40
|
+
classes = [
|
|
41
|
+
e for e in analysis_result.elements if e.__class__.__name__ == "Class"
|
|
42
|
+
]
|
|
43
|
+
methods = [
|
|
44
|
+
e for e in analysis_result.elements if e.__class__.__name__ == "Function"
|
|
45
|
+
]
|
|
46
|
+
fields = [
|
|
47
|
+
e for e in analysis_result.elements if e.__class__.__name__ == "Variable"
|
|
48
|
+
]
|
|
49
|
+
imports = [
|
|
50
|
+
e for e in analysis_result.elements if e.__class__.__name__ == "Import"
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
summary_data: dict[str, Any] = {
|
|
54
|
+
"file_path": analysis_result.file_path,
|
|
55
|
+
"language": analysis_result.language,
|
|
56
|
+
"summary": {},
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if "classes" in requested_types:
|
|
60
|
+
summary_data["summary"]["classes"] = [
|
|
61
|
+
{"name": getattr(c, "name", "unknown")} for c in classes
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
if "methods" in requested_types:
|
|
65
|
+
summary_data["summary"]["methods"] = [
|
|
66
|
+
{"name": getattr(m, "name", "unknown")} for m in methods
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
if "fields" in requested_types:
|
|
70
|
+
summary_data["summary"]["fields"] = [
|
|
71
|
+
{"name": getattr(f, "name", "unknown")} for f in fields
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
if "imports" in requested_types:
|
|
75
|
+
summary_data["summary"]["imports"] = [
|
|
76
|
+
{"name": getattr(i, "name", "unknown")} for i in imports
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
if self.args.output_format == "json":
|
|
80
|
+
output_json(summary_data)
|
|
81
|
+
else:
|
|
82
|
+
self._output_text_format(summary_data, requested_types)
|
|
83
|
+
|
|
84
|
+
def _output_text_format(self, summary_data: dict, requested_types: list) -> None:
|
|
85
|
+
"""Output summary in human-readable text format."""
|
|
86
|
+
output_data(f"File: {summary_data['file_path']}")
|
|
87
|
+
output_data(f"Language: {summary_data['language']}")
|
|
88
|
+
|
|
89
|
+
for element_type in requested_types:
|
|
90
|
+
if element_type in summary_data["summary"]:
|
|
91
|
+
elements = summary_data["summary"][element_type]
|
|
92
|
+
type_name_map = {
|
|
93
|
+
"classes": "Classes",
|
|
94
|
+
"methods": "Methods",
|
|
95
|
+
"fields": "Fields",
|
|
96
|
+
"imports": "Imports",
|
|
97
|
+
}
|
|
98
|
+
type_name = type_name_map.get(element_type, element_type)
|
|
99
|
+
output_data(f"\n{type_name} ({len(elements)} items):")
|
|
100
|
+
for element in elements:
|
|
101
|
+
output_data(f" - {element['name']}")
|
tree_sitter_analyzer/cli_main.py
CHANGED
|
@@ -215,9 +215,7 @@ def handle_special_commands(args: argparse.Namespace) -> int | None:
|
|
|
215
215
|
return 1
|
|
216
216
|
|
|
217
217
|
if args.end_line and args.end_line < args.start_line:
|
|
218
|
-
output_error(
|
|
219
|
-
"--end-line must be greater than or equal to --start-line"
|
|
220
|
-
)
|
|
218
|
+
output_error("--end-line must be greater than or equal to --start-line")
|
|
221
219
|
return 1
|
|
222
220
|
|
|
223
221
|
if args.start_column is not None and args.start_column < 0:
|
|
@@ -256,10 +254,16 @@ def main() -> None:
|
|
|
256
254
|
|
|
257
255
|
if "--quiet" in sys.argv:
|
|
258
256
|
os.environ["LOG_LEVEL"] = "ERROR"
|
|
257
|
+
else:
|
|
258
|
+
# Set default log level to WARNING to reduce output
|
|
259
|
+
os.environ.setdefault("LOG_LEVEL", "WARNING")
|
|
259
260
|
|
|
260
261
|
parser = create_argument_parser()
|
|
261
262
|
args = parser.parse_args()
|
|
262
263
|
|
|
264
|
+
# Configure default logging levels to reduce output
|
|
265
|
+
logging.getLogger("tree_sitter_analyzer.performance").setLevel(logging.ERROR)
|
|
266
|
+
|
|
263
267
|
# Configure logging for table output
|
|
264
268
|
if hasattr(args, "table") and args.table:
|
|
265
269
|
logging.getLogger().setLevel(logging.ERROR)
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
Core module for tree_sitter_analyzer.
|
|
4
|
-
|
|
5
|
-
This module contains the core components of the new architecture:
|
|
6
|
-
- AnalysisEngine: Main analysis orchestrator
|
|
7
|
-
- Parser: Tree-sitter parsing wrapper
|
|
8
|
-
- QueryExecutor: Query execution engine
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
from .engine import AnalysisEngine
|
|
12
|
-
from .parser import Parser, ParseResult
|
|
13
|
-
from .query import QueryExecutor
|
|
14
|
-
|
|
15
|
-
__all__ = ["AnalysisEngine", "Parser", "ParseResult", "QueryExecutor"]
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Core module for tree_sitter_analyzer.
|
|
4
|
+
|
|
5
|
+
This module contains the core components of the new architecture:
|
|
6
|
+
- AnalysisEngine: Main analysis orchestrator
|
|
7
|
+
- Parser: Tree-sitter parsing wrapper
|
|
8
|
+
- QueryExecutor: Query execution engine
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from .engine import AnalysisEngine
|
|
12
|
+
from .parser import Parser, ParseResult
|
|
13
|
+
from .query import QueryExecutor
|
|
14
|
+
|
|
15
|
+
__all__ = ["AnalysisEngine", "Parser", "ParseResult", "QueryExecutor"]
|