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.

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