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.

Files changed (79) hide show
  1. tree_sitter_analyzer/__init__.py +133 -121
  2. tree_sitter_analyzer/__main__.py +11 -12
  3. tree_sitter_analyzer/api.py +531 -539
  4. tree_sitter_analyzer/cli/__init__.py +39 -39
  5. tree_sitter_analyzer/cli/__main__.py +12 -13
  6. tree_sitter_analyzer/cli/commands/__init__.py +26 -27
  7. tree_sitter_analyzer/cli/commands/advanced_command.py +88 -88
  8. tree_sitter_analyzer/cli/commands/base_command.py +160 -155
  9. tree_sitter_analyzer/cli/commands/default_command.py +18 -19
  10. tree_sitter_analyzer/cli/commands/partial_read_command.py +141 -133
  11. tree_sitter_analyzer/cli/commands/query_command.py +81 -82
  12. tree_sitter_analyzer/cli/commands/structure_command.py +138 -121
  13. tree_sitter_analyzer/cli/commands/summary_command.py +101 -93
  14. tree_sitter_analyzer/cli/commands/table_command.py +232 -233
  15. tree_sitter_analyzer/cli/info_commands.py +120 -121
  16. tree_sitter_analyzer/cli_main.py +277 -276
  17. tree_sitter_analyzer/core/__init__.py +15 -20
  18. tree_sitter_analyzer/core/analysis_engine.py +591 -574
  19. tree_sitter_analyzer/core/cache_service.py +320 -330
  20. tree_sitter_analyzer/core/engine.py +557 -560
  21. tree_sitter_analyzer/core/parser.py +293 -288
  22. tree_sitter_analyzer/core/query.py +494 -502
  23. tree_sitter_analyzer/encoding_utils.py +458 -460
  24. tree_sitter_analyzer/exceptions.py +337 -340
  25. tree_sitter_analyzer/file_handler.py +217 -222
  26. tree_sitter_analyzer/formatters/__init__.py +1 -1
  27. tree_sitter_analyzer/formatters/base_formatter.py +167 -168
  28. tree_sitter_analyzer/formatters/formatter_factory.py +78 -74
  29. tree_sitter_analyzer/formatters/java_formatter.py +287 -270
  30. tree_sitter_analyzer/formatters/python_formatter.py +255 -235
  31. tree_sitter_analyzer/interfaces/__init__.py +9 -10
  32. tree_sitter_analyzer/interfaces/cli.py +528 -557
  33. tree_sitter_analyzer/interfaces/cli_adapter.py +322 -319
  34. tree_sitter_analyzer/interfaces/mcp_adapter.py +180 -170
  35. tree_sitter_analyzer/interfaces/mcp_server.py +405 -416
  36. tree_sitter_analyzer/java_analyzer.py +218 -219
  37. tree_sitter_analyzer/language_detector.py +398 -400
  38. tree_sitter_analyzer/language_loader.py +224 -228
  39. tree_sitter_analyzer/languages/__init__.py +10 -11
  40. tree_sitter_analyzer/languages/java_plugin.py +1129 -1113
  41. tree_sitter_analyzer/languages/python_plugin.py +737 -712
  42. tree_sitter_analyzer/mcp/__init__.py +31 -32
  43. tree_sitter_analyzer/mcp/resources/__init__.py +44 -47
  44. tree_sitter_analyzer/mcp/resources/code_file_resource.py +212 -213
  45. tree_sitter_analyzer/mcp/resources/project_stats_resource.py +560 -550
  46. tree_sitter_analyzer/mcp/server.py +333 -345
  47. tree_sitter_analyzer/mcp/tools/__init__.py +30 -31
  48. tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +621 -557
  49. tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py +242 -245
  50. tree_sitter_analyzer/mcp/tools/base_tool.py +54 -55
  51. tree_sitter_analyzer/mcp/tools/read_partial_tool.py +300 -302
  52. tree_sitter_analyzer/mcp/tools/table_format_tool.py +362 -359
  53. tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py +543 -476
  54. tree_sitter_analyzer/mcp/utils/__init__.py +105 -106
  55. tree_sitter_analyzer/mcp/utils/error_handler.py +549 -549
  56. tree_sitter_analyzer/models.py +470 -481
  57. tree_sitter_analyzer/output_manager.py +261 -264
  58. tree_sitter_analyzer/plugins/__init__.py +333 -334
  59. tree_sitter_analyzer/plugins/base.py +477 -446
  60. tree_sitter_analyzer/plugins/java_plugin.py +608 -625
  61. tree_sitter_analyzer/plugins/javascript_plugin.py +446 -439
  62. tree_sitter_analyzer/plugins/manager.py +362 -355
  63. tree_sitter_analyzer/plugins/plugin_loader.py +85 -83
  64. tree_sitter_analyzer/plugins/python_plugin.py +606 -598
  65. tree_sitter_analyzer/plugins/registry.py +374 -366
  66. tree_sitter_analyzer/queries/__init__.py +26 -27
  67. tree_sitter_analyzer/queries/java.py +391 -394
  68. tree_sitter_analyzer/queries/javascript.py +148 -149
  69. tree_sitter_analyzer/queries/python.py +285 -286
  70. tree_sitter_analyzer/queries/typescript.py +229 -230
  71. tree_sitter_analyzer/query_loader.py +254 -260
  72. tree_sitter_analyzer/table_formatter.py +468 -448
  73. tree_sitter_analyzer/utils.py +277 -277
  74. tree_sitter_analyzer-0.3.0.dist-info/METADATA +346 -0
  75. tree_sitter_analyzer-0.3.0.dist-info/RECORD +77 -0
  76. tree_sitter_analyzer-0.1.3.dist-info/METADATA +0 -444
  77. tree_sitter_analyzer-0.1.3.dist-info/RECORD +0 -77
  78. {tree_sitter_analyzer-0.1.3.dist-info → tree_sitter_analyzer-0.3.0.dist-info}/WHEEL +0 -0
  79. {tree_sitter_analyzer-0.1.3.dist-info → tree_sitter_analyzer-0.3.0.dist-info}/entry_points.txt +0 -0
@@ -1,276 +1,277 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- """CLI Main Module - Entry point for command-line interface."""
4
-
5
- import argparse
6
- import logging
7
- import sys
8
- from typing import Optional
9
-
10
- # Import command classes
11
- from .cli.commands import (
12
- AdvancedCommand,
13
- DefaultCommand,
14
- PartialReadCommand,
15
- QueryCommand,
16
- StructureCommand,
17
- SummaryCommand,
18
- TableCommand,
19
- )
20
- from .cli.info_commands import (
21
- DescribeQueryCommand,
22
- ListQueriesCommand,
23
- ShowExtensionsCommand,
24
- ShowLanguagesCommand,
25
- )
26
- from .output_manager import output_error, output_info, output_list
27
- from .query_loader import query_loader
28
-
29
-
30
- class CLICommandFactory:
31
- """Factory for creating CLI commands based on arguments."""
32
-
33
- @staticmethod
34
- def create_command(args: argparse.Namespace):
35
- """Create appropriate command based on arguments."""
36
-
37
- # Information commands (no file analysis required)
38
- if args.list_queries:
39
- return ListQueriesCommand(args)
40
-
41
- if args.describe_query:
42
- return DescribeQueryCommand(args)
43
-
44
- if args.show_supported_languages:
45
- return ShowLanguagesCommand(args)
46
-
47
- if args.show_supported_extensions:
48
- return ShowExtensionsCommand(args)
49
-
50
- # File analysis commands (require file path)
51
- if not args.file_path:
52
- return None
53
-
54
- # Partial read command - highest priority for file operations
55
- if hasattr(args, "partial_read") and args.partial_read:
56
- return PartialReadCommand(args)
57
-
58
- if hasattr(args, "table") and args.table:
59
- return TableCommand(args)
60
-
61
- if hasattr(args, "structure") and args.structure:
62
- return StructureCommand(args)
63
-
64
- if hasattr(args, "summary") and args.summary is not None:
65
- return SummaryCommand(args)
66
-
67
- if hasattr(args, "advanced") and args.advanced:
68
- return AdvancedCommand(args)
69
-
70
- if hasattr(args, "query_key") and args.query_key:
71
- return QueryCommand(args)
72
-
73
- if hasattr(args, "query_string") and args.query_string:
74
- return QueryCommand(args)
75
-
76
- # Default command - if file_path is provided but no specific command, use default analysis
77
- return DefaultCommand(args)
78
-
79
-
80
- def create_argument_parser() -> argparse.ArgumentParser:
81
- """Create and configure the argument parser."""
82
- parser = argparse.ArgumentParser(
83
- description="Tree-sitterを使用してコードを解析し、構造化された情報を抽出します。",
84
- epilog="例: tree-sitter-analyzer example.java --table=full",
85
- )
86
-
87
- # File path
88
- parser.add_argument("file_path", nargs="?", help="解析対象のファイルのパス")
89
-
90
- # Query options
91
- query_group = parser.add_mutually_exclusive_group(required=False)
92
- query_group.add_argument(
93
- "--query-key", help="利用可能なクエリのキー (例: class, method)"
94
- )
95
- query_group.add_argument(
96
- "--query-string", help="実行するTree-sitterクエリを直接指定"
97
- )
98
-
99
- # Information options
100
- parser.add_argument(
101
- "--list-queries", action="store_true", help="利用可能なクエリキーの一覧を表示"
102
- )
103
- parser.add_argument("--describe-query", help="指定されたクエリキーの説明を表示")
104
- parser.add_argument(
105
- "--show-supported-languages",
106
- action="store_true",
107
- help="サポートされている言語一覧を表示",
108
- )
109
- parser.add_argument(
110
- "--show-supported-extensions",
111
- action="store_true",
112
- help="サポートされている拡張子一覧を表示",
113
- )
114
- parser.add_argument(
115
- "--show-common-queries",
116
- action="store_true",
117
- help="複数言語共通のクエリ一覧を表示",
118
- )
119
- parser.add_argument(
120
- "--show-query-languages",
121
- action="store_true",
122
- help="クエリサポートされている言語一覧を表示",
123
- )
124
-
125
- # Output format options
126
- parser.add_argument(
127
- "--output-format",
128
- choices=["json", "text"],
129
- default="json",
130
- help="出力形式を指定",
131
- )
132
- parser.add_argument(
133
- "--table", choices=["full", "compact", "csv"], help="テーブル形式での出力"
134
- )
135
- parser.add_argument(
136
- "--include-javadoc",
137
- action="store_true",
138
- help="JavaDoc/ドキュメントコメントを出力に含める",
139
- )
140
-
141
- # Analysis options
142
- parser.add_argument("--advanced", action="store_true", help="高度な解析機能を使用")
143
- parser.add_argument(
144
- "--summary",
145
- nargs="?",
146
- const="classes,methods",
147
- help="指定された要素タイプの要約を表示",
148
- )
149
- parser.add_argument(
150
- "--structure", action="store_true", help="詳細な構造情報をJSON形式で出力"
151
- )
152
- parser.add_argument("--statistics", action="store_true", help="統計情報のみを表示")
153
-
154
- # Language options
155
- parser.add_argument(
156
- "--language", help="言語を明示的に指定(省略時は拡張子から自動判定)"
157
- )
158
-
159
- # Logging options
160
- parser.add_argument(
161
- "--quiet", action="store_true", help="INFOレベルのログを抑制(エラーのみ表示)"
162
- )
163
-
164
- # Partial reading options
165
- parser.add_argument(
166
- "--partial-read",
167
- action="store_true",
168
- help="ファイルの部分読み込みモードを有効にする",
169
- )
170
- parser.add_argument("--start-line", type=int, help="読み込み開始行番号(1ベース)")
171
- parser.add_argument("--end-line", type=int, help="読み込み終了行番号(1ベース)")
172
- parser.add_argument(
173
- "--start-column", type=int, help="読み込み開始列番号(0ベース)"
174
- )
175
- parser.add_argument("--end-column", type=int, help="読み込み終了列番号(0ベース)")
176
-
177
- return parser
178
-
179
-
180
- def handle_special_commands(args: argparse.Namespace) -> Optional[int]:
181
- """Handle special commands that don't fit the normal pattern."""
182
-
183
- # Validate partial read options
184
- if hasattr(args, 'partial_read') and args.partial_read:
185
- if args.start_line is None:
186
- output_error("ERROR: --start-line is required")
187
- return 1
188
-
189
- if args.start_line < 1:
190
- output_error("ERROR: --start-line must be 1 or greater")
191
- return 1
192
-
193
- if args.end_line and args.end_line < args.start_line:
194
- output_error("ERROR: --end-line must be greater than or equal to --start-line")
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
- if "--quiet" in sys.argv:
231
- os.environ['LOG_LEVEL'] = 'ERROR'
232
-
233
- parser = create_argument_parser()
234
- args = parser.parse_args()
235
-
236
- # Configure logging for table output
237
- if hasattr(args, "table") and args.table:
238
- logging.getLogger().setLevel(logging.ERROR)
239
- logging.getLogger("tree_sitter_analyzer").setLevel(logging.ERROR)
240
- logging.getLogger("tree_sitter_analyzer.performance").setLevel(logging.ERROR)
241
-
242
- # Configure logging for quiet mode
243
- if hasattr(args, "quiet") and args.quiet:
244
- logging.getLogger().setLevel(logging.ERROR)
245
- logging.getLogger("tree_sitter_analyzer").setLevel(logging.ERROR)
246
- logging.getLogger("tree_sitter_analyzer.performance").setLevel(logging.ERROR)
247
-
248
- # Handle special commands first
249
- special_result = handle_special_commands(args)
250
- if special_result is not None:
251
- sys.exit(special_result)
252
-
253
- # Create and execute command
254
- command = CLICommandFactory.create_command(args)
255
-
256
- if command:
257
- exit_code = command.execute()
258
- sys.exit(exit_code)
259
- else:
260
- if not args.file_path:
261
- output_error("ERROR: File path not specified.")
262
- else:
263
- output_error("ERROR: 実行可能なコマンドが指定されていません。")
264
- parser.print_help()
265
- sys.exit(1)
266
-
267
-
268
- if __name__ == "__main__":
269
- try:
270
- main()
271
- except KeyboardInterrupt:
272
- output_info("\nOperation cancelled by user.")
273
- sys.exit(1)
274
- except Exception as e:
275
- output_error(f"Unexpected error: {e}")
276
- sys.exit(1)
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"]