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,121 +1,120 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
from
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
from ..
|
|
13
|
-
from ..
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class
|
|
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
|
-
return 0
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Information Commands for CLI
|
|
4
|
+
|
|
5
|
+
Commands that display information without requiring file analysis.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from abc import ABC, abstractmethod
|
|
9
|
+
from argparse import Namespace
|
|
10
|
+
|
|
11
|
+
from ..language_detector import detect_language_from_file, detector
|
|
12
|
+
from ..output_manager import output_data, output_error, output_info, output_list
|
|
13
|
+
from ..query_loader import query_loader
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class InfoCommand(ABC):
|
|
17
|
+
"""Base class for information commands that don't require file analysis."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, args: Namespace):
|
|
20
|
+
self.args = args
|
|
21
|
+
|
|
22
|
+
@abstractmethod
|
|
23
|
+
def execute(self) -> int:
|
|
24
|
+
"""Execute the information command."""
|
|
25
|
+
pass
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ListQueriesCommand(InfoCommand):
|
|
29
|
+
"""Command to list available queries."""
|
|
30
|
+
|
|
31
|
+
def execute(self) -> int:
|
|
32
|
+
if self.args.language:
|
|
33
|
+
language = self.args.language
|
|
34
|
+
elif hasattr(self.args, "file_path") and self.args.file_path:
|
|
35
|
+
language = detect_language_from_file(self.args.file_path)
|
|
36
|
+
else:
|
|
37
|
+
output_list("サポートされている言語:")
|
|
38
|
+
for lang in query_loader.list_supported_languages():
|
|
39
|
+
output_list(f" {lang}")
|
|
40
|
+
queries = query_loader.list_queries_for_language(lang)
|
|
41
|
+
for query_key in queries:
|
|
42
|
+
description = (
|
|
43
|
+
query_loader.get_query_description(lang, query_key)
|
|
44
|
+
or "説明なし"
|
|
45
|
+
)
|
|
46
|
+
output_list(f" {query_key:<20} - {description}")
|
|
47
|
+
return 0
|
|
48
|
+
|
|
49
|
+
output_list(f"利用可能なクエリキー ({language}):")
|
|
50
|
+
for query_key in query_loader.list_queries_for_language(language):
|
|
51
|
+
description = (
|
|
52
|
+
query_loader.get_query_description(language, query_key) or "説明なし"
|
|
53
|
+
)
|
|
54
|
+
output_list(f" {query_key:<20} - {description}")
|
|
55
|
+
return 0
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class DescribeQueryCommand(InfoCommand):
|
|
59
|
+
"""Command to describe a specific query."""
|
|
60
|
+
|
|
61
|
+
def execute(self) -> int:
|
|
62
|
+
if self.args.language:
|
|
63
|
+
language = self.args.language
|
|
64
|
+
elif hasattr(self.args, "file_path") and self.args.file_path:
|
|
65
|
+
language = detect_language_from_file(self.args.file_path)
|
|
66
|
+
else:
|
|
67
|
+
output_error(
|
|
68
|
+
"ERROR: クエリ説明表示には--languageまたは対象ファイルの指定が必要です"
|
|
69
|
+
)
|
|
70
|
+
return 1
|
|
71
|
+
|
|
72
|
+
try:
|
|
73
|
+
query_description = query_loader.get_query_description(
|
|
74
|
+
language, self.args.describe_query
|
|
75
|
+
)
|
|
76
|
+
query_content = query_loader.get_query(language, self.args.describe_query)
|
|
77
|
+
|
|
78
|
+
if query_description is None or query_content is None:
|
|
79
|
+
output_error(
|
|
80
|
+
f"ERROR: クエリ '{self.args.describe_query}' が言語 '{language}' で見つかりません"
|
|
81
|
+
)
|
|
82
|
+
return 1
|
|
83
|
+
|
|
84
|
+
output_info(
|
|
85
|
+
f"クエリキー '{self.args.describe_query}' ({language}): {query_description}"
|
|
86
|
+
)
|
|
87
|
+
output_data(f"クエリ内容:\n{query_content}")
|
|
88
|
+
except ValueError as e:
|
|
89
|
+
output_error(f"ERROR: {e}")
|
|
90
|
+
return 1
|
|
91
|
+
return 0
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class ShowLanguagesCommand(InfoCommand):
|
|
95
|
+
"""Command to show supported languages."""
|
|
96
|
+
|
|
97
|
+
def execute(self) -> int:
|
|
98
|
+
output_list("サポートされている言語:")
|
|
99
|
+
for language in detector.get_supported_languages():
|
|
100
|
+
info = detector.get_language_info(language)
|
|
101
|
+
extensions = ", ".join(info["extensions"][:5])
|
|
102
|
+
if len(info["extensions"]) > 5:
|
|
103
|
+
extensions += f", ... (他{len(info['extensions'])-5}個)"
|
|
104
|
+
output_list(f" {language:<12} - 拡張子: {extensions}")
|
|
105
|
+
return 0
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class ShowExtensionsCommand(InfoCommand):
|
|
109
|
+
"""Command to show supported extensions."""
|
|
110
|
+
|
|
111
|
+
def execute(self) -> int:
|
|
112
|
+
output_list("サポートされている拡張子:")
|
|
113
|
+
supported_extensions = detector.get_supported_extensions()
|
|
114
|
+
for i in range(0, len(supported_extensions), 8):
|
|
115
|
+
line = " " + " ".join(
|
|
116
|
+
f"{ext:<6}" for ext in supported_extensions[i : i + 8]
|
|
117
|
+
)
|
|
118
|
+
output_list(line)
|
|
119
|
+
output_info(f"\n合計 {len(supported_extensions)} 個の拡張子をサポート")
|
|
120
|
+
return 0
|