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,319 +1,322 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
CLI Adapter for tree-sitter-analyzer
|
|
4
|
-
|
|
5
|
-
既存のCLI APIとの互換性を保ちながら、新しい統一解析エンジンを使用するアダプター。
|
|
6
|
-
|
|
7
|
-
Roo Code規約準拠:
|
|
8
|
-
- 型ヒント: 全関数に型ヒント必須
|
|
9
|
-
- MCPログ: 各ステップでログ出力
|
|
10
|
-
- docstring: Google Style docstring
|
|
11
|
-
- エラーハンドリング: 適切な例外処理
|
|
12
|
-
- パフォーマンス: 統一エンジンによる最適化
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
import asyncio
|
|
16
|
-
import logging
|
|
17
|
-
import time
|
|
18
|
-
from
|
|
19
|
-
from
|
|
20
|
-
|
|
21
|
-
from ..core.analysis_engine import
|
|
22
|
-
from ..models import AnalysisResult
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
>>>
|
|
44
|
-
>>> result
|
|
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
|
-
>>> structure
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
kwargs[
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
>>>
|
|
181
|
-
>>>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
>>>
|
|
218
|
-
>>>
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
>>> adapter
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
>>>
|
|
243
|
-
>>>
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
>>>
|
|
303
|
-
>>>
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
CLI Adapter for tree-sitter-analyzer
|
|
4
|
+
|
|
5
|
+
既存のCLI APIとの互換性を保ちながら、新しい統一解析エンジンを使用するアダプター。
|
|
6
|
+
|
|
7
|
+
Roo Code規約準拠:
|
|
8
|
+
- 型ヒント: 全関数に型ヒント必須
|
|
9
|
+
- MCPログ: 各ステップでログ出力
|
|
10
|
+
- docstring: Google Style docstring
|
|
11
|
+
- エラーハンドリング: 適切な例外処理
|
|
12
|
+
- パフォーマンス: 統一エンジンによる最適化
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import asyncio
|
|
16
|
+
import logging
|
|
17
|
+
import time
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
from typing import Any
|
|
20
|
+
|
|
21
|
+
from ..core.analysis_engine import AnalysisRequest, UnifiedAnalysisEngine
|
|
22
|
+
from ..models import AnalysisResult
|
|
23
|
+
|
|
24
|
+
logger = logging.getLogger(__name__)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class CLIAdapter:
|
|
28
|
+
"""
|
|
29
|
+
CLI用アダプター
|
|
30
|
+
|
|
31
|
+
既存のCLI APIとの互換性を保ちながら、新しい統一解析エンジンを使用します。
|
|
32
|
+
同期APIを提供し、内部的に非同期エンジンを呼び出します。
|
|
33
|
+
|
|
34
|
+
Features:
|
|
35
|
+
- 既存API互換性の維持
|
|
36
|
+
- 統一解析エンジンの活用
|
|
37
|
+
- 同期/非同期変換
|
|
38
|
+
- パフォーマンス監視
|
|
39
|
+
- エラーハンドリング
|
|
40
|
+
|
|
41
|
+
Example:
|
|
42
|
+
>>> adapter = CLIAdapter()
|
|
43
|
+
>>> result = adapter.analyze_file("example.java")
|
|
44
|
+
>>> print(result.classes)
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
def __init__(self) -> None:
|
|
48
|
+
"""
|
|
49
|
+
CLIアダプターを初期化
|
|
50
|
+
|
|
51
|
+
Raises:
|
|
52
|
+
Exception: 統一解析エンジンの初期化に失敗した場合
|
|
53
|
+
"""
|
|
54
|
+
try:
|
|
55
|
+
self._engine = UnifiedAnalysisEngine()
|
|
56
|
+
logger.info("CLIAdapter initialized successfully")
|
|
57
|
+
except Exception as e:
|
|
58
|
+
logger.error(f"Failed to initialize CLIAdapter: {e}")
|
|
59
|
+
raise
|
|
60
|
+
|
|
61
|
+
def analyze_file(self, file_path: str, **kwargs: Any) -> AnalysisResult:
|
|
62
|
+
"""
|
|
63
|
+
ファイルを解析(同期版)
|
|
64
|
+
|
|
65
|
+
既存のCLI APIとの互換性を保つため、同期インターフェースを提供します。
|
|
66
|
+
内部的には統一解析エンジンの非同期メソッドを呼び出します。
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
file_path: 解析対象ファイルのパス
|
|
70
|
+
**kwargs: 解析オプション
|
|
71
|
+
- language: 言語指定(自動検出も可能)
|
|
72
|
+
- include_complexity: 複雑度計算を含める
|
|
73
|
+
- include_details: 詳細情報を含める
|
|
74
|
+
- format_type: 出力形式("standard", "structure", "summary")
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
AnalysisResult: 解析結果
|
|
78
|
+
|
|
79
|
+
Raises:
|
|
80
|
+
ValueError: 無効なファイルパスの場合
|
|
81
|
+
FileNotFoundError: ファイルが存在しない場合
|
|
82
|
+
UnsupportedLanguageError: サポートされていない言語の場合
|
|
83
|
+
|
|
84
|
+
Example:
|
|
85
|
+
>>> adapter = CLIAdapter()
|
|
86
|
+
>>> result = adapter.analyze_file("example.java", include_complexity=True)
|
|
87
|
+
>>> print(f"Classes: {len(result.classes)}")
|
|
88
|
+
"""
|
|
89
|
+
start_time = time.time()
|
|
90
|
+
|
|
91
|
+
# 入力検証
|
|
92
|
+
if not file_path or not file_path.strip():
|
|
93
|
+
raise ValueError("File path cannot be empty")
|
|
94
|
+
|
|
95
|
+
# ファイル存在チェック
|
|
96
|
+
if not Path(file_path).exists():
|
|
97
|
+
raise FileNotFoundError(f"File not found: {file_path}")
|
|
98
|
+
|
|
99
|
+
try:
|
|
100
|
+
# AnalysisRequestを作成
|
|
101
|
+
request = AnalysisRequest(
|
|
102
|
+
file_path=file_path,
|
|
103
|
+
language=kwargs.get("language"),
|
|
104
|
+
include_complexity=kwargs.get("include_complexity", False),
|
|
105
|
+
include_details=kwargs.get("include_details", True),
|
|
106
|
+
format_type=kwargs.get("format_type", "standard"),
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
# 非同期エンジンを同期的に実行
|
|
110
|
+
result = asyncio.run(self._engine.analyze(request))
|
|
111
|
+
|
|
112
|
+
# パフォーマンスログ
|
|
113
|
+
elapsed_time = time.time() - start_time
|
|
114
|
+
logger.info(f"CLI analysis completed: {file_path} in {elapsed_time:.3f}s")
|
|
115
|
+
|
|
116
|
+
return result
|
|
117
|
+
|
|
118
|
+
except Exception as e:
|
|
119
|
+
logger.error(f"CLI analysis failed for {file_path}: {e}")
|
|
120
|
+
raise
|
|
121
|
+
|
|
122
|
+
def analyze_structure(self, file_path: str, **kwargs: Any) -> dict[str, Any]:
|
|
123
|
+
"""
|
|
124
|
+
構造解析(既存API互換)
|
|
125
|
+
|
|
126
|
+
既存のCLI APIとの互換性を保つため、構造情報を辞書形式で返します。
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
file_path: 解析対象ファイルのパス
|
|
130
|
+
**kwargs: 解析オプション
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
Dict[str, Any]: 構造情報の辞書
|
|
134
|
+
- file_path: ファイルパス
|
|
135
|
+
- classes: クラス情報のリスト
|
|
136
|
+
- methods: メソッド情報のリスト
|
|
137
|
+
- fields: フィールド情報のリスト
|
|
138
|
+
- imports: インポート情報のリスト
|
|
139
|
+
|
|
140
|
+
Example:
|
|
141
|
+
>>> adapter = CLIAdapter()
|
|
142
|
+
>>> structure = adapter.analyze_structure("example.java")
|
|
143
|
+
>>> print(structure["classes"])
|
|
144
|
+
"""
|
|
145
|
+
# 詳細情報を含めて解析
|
|
146
|
+
kwargs["include_details"] = True
|
|
147
|
+
kwargs["format_type"] = "structure"
|
|
148
|
+
|
|
149
|
+
result = self.analyze_file(file_path, **kwargs)
|
|
150
|
+
|
|
151
|
+
# 構造情報を辞書形式に変換
|
|
152
|
+
return {
|
|
153
|
+
"file_path": result.file_path,
|
|
154
|
+
"language": result.language,
|
|
155
|
+
"package": result.package,
|
|
156
|
+
"imports": [imp.to_dict() for imp in result.imports],
|
|
157
|
+
"classes": [cls.to_dict() for cls in result.classes],
|
|
158
|
+
"methods": [method.to_dict() for method in result.methods],
|
|
159
|
+
"fields": [field.to_dict() for field in result.fields],
|
|
160
|
+
"annotations": [ann.to_dict() for ann in result.annotations],
|
|
161
|
+
"analysis_time": result.analysis_time,
|
|
162
|
+
"elements": [elem.to_dict() for elem in result.elements],
|
|
163
|
+
"success": result.success,
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
def analyze_batch(
|
|
167
|
+
self, file_paths: list[str], **kwargs: Any
|
|
168
|
+
) -> list[AnalysisResult]:
|
|
169
|
+
"""
|
|
170
|
+
複数ファイルの一括解析
|
|
171
|
+
|
|
172
|
+
Args:
|
|
173
|
+
file_paths: 解析対象ファイルパスのリスト
|
|
174
|
+
**kwargs: 解析オプション
|
|
175
|
+
|
|
176
|
+
Returns:
|
|
177
|
+
list[AnalysisResult]: 解析結果のリスト
|
|
178
|
+
|
|
179
|
+
Example:
|
|
180
|
+
>>> adapter = CLIAdapter()
|
|
181
|
+
>>> results = adapter.analyze_batch(["file1.java", "file2.java"])
|
|
182
|
+
>>> print(f"Analyzed {len(results)} files")
|
|
183
|
+
"""
|
|
184
|
+
results = []
|
|
185
|
+
|
|
186
|
+
for file_path in file_paths:
|
|
187
|
+
try:
|
|
188
|
+
result = self.analyze_file(file_path, **kwargs)
|
|
189
|
+
results.append(result)
|
|
190
|
+
except Exception as e:
|
|
191
|
+
logger.warning(f"Failed to analyze {file_path}: {e}")
|
|
192
|
+
# エラーの場合も結果に含める(失敗情報付き)
|
|
193
|
+
error_result = AnalysisResult(
|
|
194
|
+
file_path=file_path,
|
|
195
|
+
package=None,
|
|
196
|
+
imports=[],
|
|
197
|
+
classes=[],
|
|
198
|
+
methods=[],
|
|
199
|
+
fields=[],
|
|
200
|
+
annotations=[],
|
|
201
|
+
analysis_time=0.0,
|
|
202
|
+
success=False,
|
|
203
|
+
error_message=str(e),
|
|
204
|
+
)
|
|
205
|
+
results.append(error_result)
|
|
206
|
+
|
|
207
|
+
return results
|
|
208
|
+
|
|
209
|
+
def get_supported_languages(self) -> list[str]:
|
|
210
|
+
"""
|
|
211
|
+
サポートされている言語のリストを取得
|
|
212
|
+
|
|
213
|
+
Returns:
|
|
214
|
+
list[str]: サポート言語のリスト
|
|
215
|
+
|
|
216
|
+
Example:
|
|
217
|
+
>>> adapter = CLIAdapter()
|
|
218
|
+
>>> languages = adapter.get_supported_languages()
|
|
219
|
+
>>> print(languages)
|
|
220
|
+
"""
|
|
221
|
+
return self._engine.get_supported_languages()
|
|
222
|
+
|
|
223
|
+
def clear_cache(self) -> None:
|
|
224
|
+
"""
|
|
225
|
+
キャッシュをクリア
|
|
226
|
+
|
|
227
|
+
Example:
|
|
228
|
+
>>> adapter = CLIAdapter()
|
|
229
|
+
>>> adapter.clear_cache()
|
|
230
|
+
"""
|
|
231
|
+
self._engine.clear_cache()
|
|
232
|
+
logger.info("CLI adapter cache cleared")
|
|
233
|
+
|
|
234
|
+
def get_cache_stats(self) -> dict[str, Any]:
|
|
235
|
+
"""
|
|
236
|
+
キャッシュ統計情報を取得
|
|
237
|
+
|
|
238
|
+
Returns:
|
|
239
|
+
Dict[str, Any]: キャッシュ統計情報
|
|
240
|
+
|
|
241
|
+
Example:
|
|
242
|
+
>>> adapter = CLIAdapter()
|
|
243
|
+
>>> stats = adapter.get_cache_stats()
|
|
244
|
+
>>> print(f"Cache hit rate: {stats['hit_rate']:.2%}")
|
|
245
|
+
"""
|
|
246
|
+
return self._engine.get_cache_stats()
|
|
247
|
+
|
|
248
|
+
def validate_file(self, file_path: str) -> bool:
|
|
249
|
+
"""
|
|
250
|
+
ファイルが解析可能かどうかを検証
|
|
251
|
+
|
|
252
|
+
Args:
|
|
253
|
+
file_path: 検証対象ファイルのパス
|
|
254
|
+
|
|
255
|
+
Returns:
|
|
256
|
+
bool: 解析可能な場合True
|
|
257
|
+
|
|
258
|
+
Example:
|
|
259
|
+
>>> adapter = CLIAdapter()
|
|
260
|
+
>>> if adapter.validate_file("example.java"):
|
|
261
|
+
... result = adapter.analyze_file("example.java")
|
|
262
|
+
"""
|
|
263
|
+
try:
|
|
264
|
+
# ファイル存在チェック
|
|
265
|
+
if not Path(file_path).exists():
|
|
266
|
+
return False
|
|
267
|
+
|
|
268
|
+
# 言語サポートチェック
|
|
269
|
+
supported_languages = self.get_supported_languages()
|
|
270
|
+
file_extension = Path(file_path).suffix.lower()
|
|
271
|
+
|
|
272
|
+
# 拡張子から言語を推定
|
|
273
|
+
extension_map = {
|
|
274
|
+
".java": "java",
|
|
275
|
+
".py": "python",
|
|
276
|
+
".js": "javascript",
|
|
277
|
+
".ts": "typescript",
|
|
278
|
+
".cpp": "cpp",
|
|
279
|
+
".c": "c",
|
|
280
|
+
".cs": "csharp",
|
|
281
|
+
".go": "go",
|
|
282
|
+
".rs": "rust",
|
|
283
|
+
".php": "php",
|
|
284
|
+
".rb": "ruby",
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
language = extension_map.get(file_extension)
|
|
288
|
+
return language in supported_languages if language else False
|
|
289
|
+
|
|
290
|
+
except Exception as e:
|
|
291
|
+
logger.warning(f"File validation failed for {file_path}: {e}")
|
|
292
|
+
return False
|
|
293
|
+
|
|
294
|
+
def get_engine_info(self) -> dict[str, Any]:
|
|
295
|
+
"""
|
|
296
|
+
エンジン情報を取得
|
|
297
|
+
|
|
298
|
+
Returns:
|
|
299
|
+
Dict[str, Any]: エンジン情報
|
|
300
|
+
|
|
301
|
+
Example:
|
|
302
|
+
>>> adapter = CLIAdapter()
|
|
303
|
+
>>> info = adapter.get_engine_info()
|
|
304
|
+
>>> print(f"Engine version: {info['version']}")
|
|
305
|
+
"""
|
|
306
|
+
return {
|
|
307
|
+
"adapter_type": "CLI",
|
|
308
|
+
"engine_type": "UnifiedAnalysisEngine",
|
|
309
|
+
"supported_languages": self.get_supported_languages(),
|
|
310
|
+
"cache_enabled": True,
|
|
311
|
+
"async_support": True,
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
# Legacy AdvancedAnalyzerAdapter removed - use UnifiedAnalysisEngine directly
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def get_analysis_engine():
|
|
319
|
+
"""Get analysis engine instance for testing compatibility."""
|
|
320
|
+
from ..core.analysis_engine import AnalysisEngine
|
|
321
|
+
|
|
322
|
+
return AnalysisEngine()
|