tree-sitter-analyzer 0.1.3__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.3.0.dist-info/METADATA +346 -0
- tree_sitter_analyzer-0.3.0.dist-info/RECORD +77 -0
- tree_sitter_analyzer-0.1.3.dist-info/METADATA +0 -444
- tree_sitter_analyzer-0.1.3.dist-info/RECORD +0 -77
- {tree_sitter_analyzer-0.1.3.dist-info → tree_sitter_analyzer-0.3.0.dist-info}/WHEEL +0 -0
- {tree_sitter_analyzer-0.1.3.dist-info → tree_sitter_analyzer-0.3.0.dist-info}/entry_points.txt +0 -0
tree_sitter_analyzer/cli_main.py
CHANGED
|
@@ -1,276 +1,277 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
parser.add_argument(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
parser
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
return 1
|
|
196
|
-
|
|
197
|
-
if args.start_column is not None and args.start_column < 0:
|
|
198
|
-
output_error("ERROR: --start-column must be 0 or greater")
|
|
199
|
-
return 1
|
|
200
|
-
|
|
201
|
-
if args.end_column is not None and args.end_column < 0:
|
|
202
|
-
output_error("ERROR: --end-column must be 0 or greater")
|
|
203
|
-
return 1
|
|
204
|
-
|
|
205
|
-
# Query language commands
|
|
206
|
-
if args.show_query_languages:
|
|
207
|
-
output_list(["クエリサポートされている言語:"])
|
|
208
|
-
for lang in query_loader.list_supported_languages():
|
|
209
|
-
query_count = len(query_loader.list_queries_for_language(lang))
|
|
210
|
-
output_list([f" {lang:<15} ({query_count} クエリ)"])
|
|
211
|
-
return 0
|
|
212
|
-
|
|
213
|
-
if args.show_common_queries:
|
|
214
|
-
common_queries = query_loader.get_common_queries()
|
|
215
|
-
if common_queries:
|
|
216
|
-
output_list("複数言語共通のクエリ:")
|
|
217
|
-
for query in common_queries:
|
|
218
|
-
output_list(f" {query}")
|
|
219
|
-
else:
|
|
220
|
-
output_info("共通クエリが見つかりませんでした。")
|
|
221
|
-
return 0
|
|
222
|
-
|
|
223
|
-
return None
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
def main() -> None:
|
|
227
|
-
"""Main entry point for the CLI."""
|
|
228
|
-
# Early check for quiet mode to set environment variable before any imports
|
|
229
|
-
import os
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
logging.getLogger(
|
|
240
|
-
logging.getLogger("tree_sitter_analyzer
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
logging.getLogger(
|
|
246
|
-
logging.getLogger("tree_sitter_analyzer
|
|
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
|
-
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""CLI Main Module - Entry point for command-line interface."""
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import logging
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
# Import command classes
|
|
9
|
+
from .cli.commands import (
|
|
10
|
+
AdvancedCommand,
|
|
11
|
+
DefaultCommand,
|
|
12
|
+
PartialReadCommand,
|
|
13
|
+
QueryCommand,
|
|
14
|
+
StructureCommand,
|
|
15
|
+
SummaryCommand,
|
|
16
|
+
TableCommand,
|
|
17
|
+
)
|
|
18
|
+
from .cli.info_commands import (
|
|
19
|
+
DescribeQueryCommand,
|
|
20
|
+
ListQueriesCommand,
|
|
21
|
+
ShowExtensionsCommand,
|
|
22
|
+
ShowLanguagesCommand,
|
|
23
|
+
)
|
|
24
|
+
from .output_manager import output_error, output_info, output_list
|
|
25
|
+
from .query_loader import query_loader
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class CLICommandFactory:
|
|
29
|
+
"""Factory for creating CLI commands based on arguments."""
|
|
30
|
+
|
|
31
|
+
@staticmethod
|
|
32
|
+
def create_command(args: argparse.Namespace):
|
|
33
|
+
"""Create appropriate command based on arguments."""
|
|
34
|
+
|
|
35
|
+
# Information commands (no file analysis required)
|
|
36
|
+
if args.list_queries:
|
|
37
|
+
return ListQueriesCommand(args)
|
|
38
|
+
|
|
39
|
+
if args.describe_query:
|
|
40
|
+
return DescribeQueryCommand(args)
|
|
41
|
+
|
|
42
|
+
if args.show_supported_languages:
|
|
43
|
+
return ShowLanguagesCommand(args)
|
|
44
|
+
|
|
45
|
+
if args.show_supported_extensions:
|
|
46
|
+
return ShowExtensionsCommand(args)
|
|
47
|
+
|
|
48
|
+
# File analysis commands (require file path)
|
|
49
|
+
if not args.file_path:
|
|
50
|
+
return None
|
|
51
|
+
|
|
52
|
+
# Partial read command - highest priority for file operations
|
|
53
|
+
if hasattr(args, "partial_read") and args.partial_read:
|
|
54
|
+
return PartialReadCommand(args)
|
|
55
|
+
|
|
56
|
+
if hasattr(args, "table") and args.table:
|
|
57
|
+
return TableCommand(args)
|
|
58
|
+
|
|
59
|
+
if hasattr(args, "structure") and args.structure:
|
|
60
|
+
return StructureCommand(args)
|
|
61
|
+
|
|
62
|
+
if hasattr(args, "summary") and args.summary is not None:
|
|
63
|
+
return SummaryCommand(args)
|
|
64
|
+
|
|
65
|
+
if hasattr(args, "advanced") and args.advanced:
|
|
66
|
+
return AdvancedCommand(args)
|
|
67
|
+
|
|
68
|
+
if hasattr(args, "query_key") and args.query_key:
|
|
69
|
+
return QueryCommand(args)
|
|
70
|
+
|
|
71
|
+
if hasattr(args, "query_string") and args.query_string:
|
|
72
|
+
return QueryCommand(args)
|
|
73
|
+
|
|
74
|
+
# Default command - if file_path is provided but no specific command, use default analysis
|
|
75
|
+
return DefaultCommand(args)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def create_argument_parser() -> argparse.ArgumentParser:
|
|
79
|
+
"""Create and configure the argument parser."""
|
|
80
|
+
parser = argparse.ArgumentParser(
|
|
81
|
+
description="Tree-sitterを使用してコードを解析し、構造化された情報を抽出します。",
|
|
82
|
+
epilog="例: tree-sitter-analyzer example.java --table=full",
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
# File path
|
|
86
|
+
parser.add_argument("file_path", nargs="?", help="解析対象のファイルのパス")
|
|
87
|
+
|
|
88
|
+
# Query options
|
|
89
|
+
query_group = parser.add_mutually_exclusive_group(required=False)
|
|
90
|
+
query_group.add_argument(
|
|
91
|
+
"--query-key", help="利用可能なクエリのキー (例: class, method)"
|
|
92
|
+
)
|
|
93
|
+
query_group.add_argument(
|
|
94
|
+
"--query-string", help="実行するTree-sitterクエリを直接指定"
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
# Information options
|
|
98
|
+
parser.add_argument(
|
|
99
|
+
"--list-queries", action="store_true", help="利用可能なクエリキーの一覧を表示"
|
|
100
|
+
)
|
|
101
|
+
parser.add_argument("--describe-query", help="指定されたクエリキーの説明を表示")
|
|
102
|
+
parser.add_argument(
|
|
103
|
+
"--show-supported-languages",
|
|
104
|
+
action="store_true",
|
|
105
|
+
help="サポートされている言語一覧を表示",
|
|
106
|
+
)
|
|
107
|
+
parser.add_argument(
|
|
108
|
+
"--show-supported-extensions",
|
|
109
|
+
action="store_true",
|
|
110
|
+
help="サポートされている拡張子一覧を表示",
|
|
111
|
+
)
|
|
112
|
+
parser.add_argument(
|
|
113
|
+
"--show-common-queries",
|
|
114
|
+
action="store_true",
|
|
115
|
+
help="複数言語共通のクエリ一覧を表示",
|
|
116
|
+
)
|
|
117
|
+
parser.add_argument(
|
|
118
|
+
"--show-query-languages",
|
|
119
|
+
action="store_true",
|
|
120
|
+
help="クエリサポートされている言語一覧を表示",
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
# Output format options
|
|
124
|
+
parser.add_argument(
|
|
125
|
+
"--output-format",
|
|
126
|
+
choices=["json", "text"],
|
|
127
|
+
default="json",
|
|
128
|
+
help="出力形式を指定",
|
|
129
|
+
)
|
|
130
|
+
parser.add_argument(
|
|
131
|
+
"--table", choices=["full", "compact", "csv"], help="テーブル形式での出力"
|
|
132
|
+
)
|
|
133
|
+
parser.add_argument(
|
|
134
|
+
"--include-javadoc",
|
|
135
|
+
action="store_true",
|
|
136
|
+
help="JavaDoc/ドキュメントコメントを出力に含める",
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
# Analysis options
|
|
140
|
+
parser.add_argument("--advanced", action="store_true", help="高度な解析機能を使用")
|
|
141
|
+
parser.add_argument(
|
|
142
|
+
"--summary",
|
|
143
|
+
nargs="?",
|
|
144
|
+
const="classes,methods",
|
|
145
|
+
help="指定された要素タイプの要約を表示",
|
|
146
|
+
)
|
|
147
|
+
parser.add_argument(
|
|
148
|
+
"--structure", action="store_true", help="詳細な構造情報をJSON形式で出力"
|
|
149
|
+
)
|
|
150
|
+
parser.add_argument("--statistics", action="store_true", help="統計情報のみを表示")
|
|
151
|
+
|
|
152
|
+
# Language options
|
|
153
|
+
parser.add_argument(
|
|
154
|
+
"--language", help="言語を明示的に指定(省略時は拡張子から自動判定)"
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
# Logging options
|
|
158
|
+
parser.add_argument(
|
|
159
|
+
"--quiet", action="store_true", help="INFOレベルのログを抑制(エラーのみ表示)"
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
# Partial reading options
|
|
163
|
+
parser.add_argument(
|
|
164
|
+
"--partial-read",
|
|
165
|
+
action="store_true",
|
|
166
|
+
help="ファイルの部分読み込みモードを有効にする",
|
|
167
|
+
)
|
|
168
|
+
parser.add_argument("--start-line", type=int, help="読み込み開始行番号(1ベース)")
|
|
169
|
+
parser.add_argument("--end-line", type=int, help="読み込み終了行番号(1ベース)")
|
|
170
|
+
parser.add_argument(
|
|
171
|
+
"--start-column", type=int, help="読み込み開始列番号(0ベース)"
|
|
172
|
+
)
|
|
173
|
+
parser.add_argument("--end-column", type=int, help="読み込み終了列番号(0ベース)")
|
|
174
|
+
|
|
175
|
+
return parser
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def handle_special_commands(args: argparse.Namespace) -> int | None:
|
|
179
|
+
"""Handle special commands that don't fit the normal pattern."""
|
|
180
|
+
|
|
181
|
+
# Validate partial read options
|
|
182
|
+
if hasattr(args, "partial_read") and args.partial_read:
|
|
183
|
+
if args.start_line is None:
|
|
184
|
+
output_error("ERROR: --start-line is required")
|
|
185
|
+
return 1
|
|
186
|
+
|
|
187
|
+
if args.start_line < 1:
|
|
188
|
+
output_error("ERROR: --start-line must be 1 or greater")
|
|
189
|
+
return 1
|
|
190
|
+
|
|
191
|
+
if args.end_line and args.end_line < args.start_line:
|
|
192
|
+
output_error(
|
|
193
|
+
"ERROR: --end-line must be greater than or equal to --start-line"
|
|
194
|
+
)
|
|
195
|
+
return 1
|
|
196
|
+
|
|
197
|
+
if args.start_column is not None and args.start_column < 0:
|
|
198
|
+
output_error("ERROR: --start-column must be 0 or greater")
|
|
199
|
+
return 1
|
|
200
|
+
|
|
201
|
+
if args.end_column is not None and args.end_column < 0:
|
|
202
|
+
output_error("ERROR: --end-column must be 0 or greater")
|
|
203
|
+
return 1
|
|
204
|
+
|
|
205
|
+
# Query language commands
|
|
206
|
+
if args.show_query_languages:
|
|
207
|
+
output_list(["クエリサポートされている言語:"])
|
|
208
|
+
for lang in query_loader.list_supported_languages():
|
|
209
|
+
query_count = len(query_loader.list_queries_for_language(lang))
|
|
210
|
+
output_list([f" {lang:<15} ({query_count} クエリ)"])
|
|
211
|
+
return 0
|
|
212
|
+
|
|
213
|
+
if args.show_common_queries:
|
|
214
|
+
common_queries = query_loader.get_common_queries()
|
|
215
|
+
if common_queries:
|
|
216
|
+
output_list("複数言語共通のクエリ:")
|
|
217
|
+
for query in common_queries:
|
|
218
|
+
output_list(f" {query}")
|
|
219
|
+
else:
|
|
220
|
+
output_info("共通クエリが見つかりませんでした。")
|
|
221
|
+
return 0
|
|
222
|
+
|
|
223
|
+
return None
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def main() -> None:
|
|
227
|
+
"""Main entry point for the CLI."""
|
|
228
|
+
# Early check for quiet mode to set environment variable before any imports
|
|
229
|
+
import os
|
|
230
|
+
|
|
231
|
+
if "--quiet" in sys.argv:
|
|
232
|
+
os.environ["LOG_LEVEL"] = "ERROR"
|
|
233
|
+
|
|
234
|
+
parser = create_argument_parser()
|
|
235
|
+
args = parser.parse_args()
|
|
236
|
+
|
|
237
|
+
# Configure logging for table output
|
|
238
|
+
if hasattr(args, "table") and args.table:
|
|
239
|
+
logging.getLogger().setLevel(logging.ERROR)
|
|
240
|
+
logging.getLogger("tree_sitter_analyzer").setLevel(logging.ERROR)
|
|
241
|
+
logging.getLogger("tree_sitter_analyzer.performance").setLevel(logging.ERROR)
|
|
242
|
+
|
|
243
|
+
# Configure logging for quiet mode
|
|
244
|
+
if hasattr(args, "quiet") and args.quiet:
|
|
245
|
+
logging.getLogger().setLevel(logging.ERROR)
|
|
246
|
+
logging.getLogger("tree_sitter_analyzer").setLevel(logging.ERROR)
|
|
247
|
+
logging.getLogger("tree_sitter_analyzer.performance").setLevel(logging.ERROR)
|
|
248
|
+
|
|
249
|
+
# Handle special commands first
|
|
250
|
+
special_result = handle_special_commands(args)
|
|
251
|
+
if special_result is not None:
|
|
252
|
+
sys.exit(special_result)
|
|
253
|
+
|
|
254
|
+
# Create and execute command
|
|
255
|
+
command = CLICommandFactory.create_command(args)
|
|
256
|
+
|
|
257
|
+
if command:
|
|
258
|
+
exit_code = command.execute()
|
|
259
|
+
sys.exit(exit_code)
|
|
260
|
+
else:
|
|
261
|
+
if not args.file_path:
|
|
262
|
+
output_error("ERROR: File path not specified.")
|
|
263
|
+
else:
|
|
264
|
+
output_error("ERROR: 実行可能なコマンドが指定されていません。")
|
|
265
|
+
parser.print_help()
|
|
266
|
+
sys.exit(1)
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
if __name__ == "__main__":
|
|
270
|
+
try:
|
|
271
|
+
main()
|
|
272
|
+
except KeyboardInterrupt:
|
|
273
|
+
output_info("\nOperation cancelled by user.")
|
|
274
|
+
sys.exit(1)
|
|
275
|
+
except Exception as e:
|
|
276
|
+
output_error(f"Unexpected error: {e}")
|
|
277
|
+
sys.exit(1)
|
|
@@ -1,20 +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__ = [
|
|
16
|
-
'AnalysisEngine',
|
|
17
|
-
'Parser',
|
|
18
|
-
'ParseResult',
|
|
19
|
-
'QueryExecutor'
|
|
20
|
-
]
|
|
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"]
|