tree-sitter-analyzer 0.2.0__py3-none-any.whl → 0.4.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 +134 -121
  2. tree_sitter_analyzer/__main__.py +11 -12
  3. tree_sitter_analyzer/api.py +533 -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 +235 -233
  15. tree_sitter_analyzer/cli/info_commands.py +120 -121
  16. tree_sitter_analyzer/cli_main.py +278 -276
  17. tree_sitter_analyzer/core/__init__.py +15 -20
  18. tree_sitter_analyzer/core/analysis_engine.py +555 -574
  19. tree_sitter_analyzer/core/cache_service.py +320 -330
  20. tree_sitter_analyzer/core/engine.py +559 -560
  21. tree_sitter_analyzer/core/parser.py +293 -288
  22. tree_sitter_analyzer/core/query.py +502 -502
  23. tree_sitter_analyzer/encoding_utils.py +456 -460
  24. tree_sitter_analyzer/exceptions.py +337 -340
  25. tree_sitter_analyzer/file_handler.py +210 -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 +291 -270
  30. tree_sitter_analyzer/formatters/python_formatter.py +259 -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 +343 -319
  34. tree_sitter_analyzer/interfaces/mcp_adapter.py +206 -170
  35. tree_sitter_analyzer/interfaces/mcp_server.py +405 -416
  36. tree_sitter_analyzer/java_analyzer.py +187 -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 +1174 -1113
  41. tree_sitter_analyzer/{plugins → languages}/javascript_plugin.py +446 -439
  42. tree_sitter_analyzer/languages/python_plugin.py +747 -712
  43. tree_sitter_analyzer/mcp/__init__.py +31 -32
  44. tree_sitter_analyzer/mcp/resources/__init__.py +44 -47
  45. tree_sitter_analyzer/mcp/resources/code_file_resource.py +209 -213
  46. tree_sitter_analyzer/mcp/resources/project_stats_resource.py +555 -550
  47. tree_sitter_analyzer/mcp/server.py +333 -345
  48. tree_sitter_analyzer/mcp/tools/__init__.py +30 -31
  49. tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +654 -557
  50. tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py +247 -245
  51. tree_sitter_analyzer/mcp/tools/base_tool.py +54 -55
  52. tree_sitter_analyzer/mcp/tools/read_partial_tool.py +300 -302
  53. tree_sitter_analyzer/mcp/tools/table_format_tool.py +362 -359
  54. tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py +543 -476
  55. tree_sitter_analyzer/mcp/utils/__init__.py +107 -106
  56. tree_sitter_analyzer/mcp/utils/error_handler.py +549 -549
  57. tree_sitter_analyzer/models.py +470 -481
  58. tree_sitter_analyzer/output_manager.py +255 -264
  59. tree_sitter_analyzer/plugins/__init__.py +280 -334
  60. tree_sitter_analyzer/plugins/base.py +496 -446
  61. tree_sitter_analyzer/plugins/manager.py +379 -355
  62. tree_sitter_analyzer/queries/__init__.py +26 -27
  63. tree_sitter_analyzer/queries/java.py +391 -394
  64. tree_sitter_analyzer/queries/javascript.py +148 -149
  65. tree_sitter_analyzer/queries/python.py +285 -286
  66. tree_sitter_analyzer/queries/typescript.py +229 -230
  67. tree_sitter_analyzer/query_loader.py +257 -260
  68. tree_sitter_analyzer/table_formatter.py +471 -448
  69. tree_sitter_analyzer/utils.py +277 -277
  70. {tree_sitter_analyzer-0.2.0.dist-info → tree_sitter_analyzer-0.4.0.dist-info}/METADATA +23 -8
  71. tree_sitter_analyzer-0.4.0.dist-info/RECORD +73 -0
  72. {tree_sitter_analyzer-0.2.0.dist-info → tree_sitter_analyzer-0.4.0.dist-info}/entry_points.txt +2 -1
  73. tree_sitter_analyzer/plugins/java_plugin.py +0 -625
  74. tree_sitter_analyzer/plugins/plugin_loader.py +0 -83
  75. tree_sitter_analyzer/plugins/python_plugin.py +0 -598
  76. tree_sitter_analyzer/plugins/registry.py +0 -366
  77. tree_sitter_analyzer-0.2.0.dist-info/RECORD +0 -77
  78. {tree_sitter_analyzer-0.2.0.dist-info → tree_sitter_analyzer-0.4.0.dist-info}/WHEEL +0 -0
@@ -1,625 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- """
4
- Java Language Plugin
5
-
6
- Provides Java-specific parsing and element extraction functionality.
7
- """
8
-
9
- import re
10
- from typing import TYPE_CHECKING, List, Optional
11
-
12
- if TYPE_CHECKING:
13
- import tree_sitter
14
- from ..core.analysis_engine import AnalysisRequest
15
- from ..models import AnalysisResult
16
-
17
- from ..language_loader import loader
18
- from ..models import (
19
- Class,
20
- Function,
21
- Import,
22
- JavaAnnotation,
23
- JavaClass,
24
- JavaField,
25
- JavaImport,
26
- JavaMethod,
27
- Variable,
28
- )
29
- from ..utils import log_debug, log_error, log_warning
30
- from . import ElementExtractor, LanguagePlugin
31
-
32
-
33
- class JavaElementExtractor(ElementExtractor):
34
- """Advanced Java-specific element extractor with comprehensive analysis"""
35
-
36
- def __init__(self) -> None:
37
- # 分析コンテキスト
38
- self.current_package: str = ""
39
- self.current_file: str = ""
40
- self.source_code: str = ""
41
- self.imports: List[str] = []
42
-
43
- def extract_functions(
44
- self, tree: "tree_sitter.Tree", source_code: str
45
- ) -> List[Function]:
46
- """Extract Java method definitions with comprehensive analysis"""
47
- self.source_code = source_code
48
- functions: List[Function] = []
49
-
50
- # 複数のメソッドパターンを検索
51
- method_queries = [
52
- # 通常のメソッド宣言
53
- """
54
- (method_declaration
55
- (modifiers)? @method.modifiers
56
- type: (_)? @method.return_type
57
- name: (identifier) @method.name
58
- parameters: (formal_parameters) @method.params
59
- (throws)? @method.throws
60
- body: (block)? @method.body) @method.declaration
61
- """,
62
- # コンストラクタ
63
- """
64
- (constructor_declaration
65
- (modifiers)? @constructor.modifiers
66
- name: (identifier) @constructor.name
67
- parameters: (formal_parameters) @constructor.params
68
- (throws)? @constructor.throws
69
- body: (constructor_body) @constructor.body) @constructor.declaration
70
- """,
71
- ]
72
-
73
- try:
74
- language = tree.language if hasattr(tree, "language") else None
75
- if language:
76
- for query_string in method_queries:
77
- query = language.query(query_string)
78
- captures = query.captures(tree.root_node)
79
-
80
- if isinstance(captures, dict):
81
- # メソッド宣言を処理
82
- method_nodes = captures.get("method.declaration", [])
83
- for node in method_nodes:
84
- function = self._extract_detailed_method_info(
85
- node, source_code, False
86
- )
87
- if function:
88
- functions.append(function)
89
-
90
- # コンストラクタを処理
91
- constructor_nodes = captures.get("constructor.declaration", [])
92
- for node in constructor_nodes:
93
- function = self._extract_detailed_method_info(
94
- node, source_code, True
95
- )
96
- if function:
97
- functions.append(function)
98
-
99
- except Exception as e:
100
- log_warning(f"Could not extract Java methods: {e}")
101
-
102
- return functions
103
-
104
- def extract_classes(
105
- self, tree: "tree_sitter.Tree", source_code: str
106
- ) -> List[Class]:
107
- """Extract Java class definitions with comprehensive analysis"""
108
- self.source_code = source_code
109
- classes: List[Class] = []
110
-
111
- # 複数のクラスタイプを検索
112
- class_queries = [
113
- # 通常のクラス
114
- """
115
- (class_declaration
116
- (modifiers)? @class.modifiers
117
- name: (identifier) @class.name
118
- (superclass)? @class.superclass
119
- (super_interfaces)? @class.interfaces
120
- body: (class_body) @class.body) @class.declaration
121
- """,
122
- # インターフェース
123
- """
124
- (interface_declaration
125
- (modifiers)? @interface.modifiers
126
- name: (identifier) @interface.name
127
- (extends_interfaces)? @interface.extends
128
- body: (interface_body) @interface.body) @interface.declaration
129
- """,
130
- # 列挙型
131
- """
132
- (enum_declaration
133
- (modifiers)? @enum.modifiers
134
- name: (identifier) @enum.name
135
- (super_interfaces)? @enum.interfaces
136
- body: (enum_body) @enum.body) @enum.declaration
137
- """,
138
- # アノテーション型
139
- """
140
- (annotation_type_declaration
141
- (modifiers)? @annotation.modifiers
142
- name: (identifier) @annotation.name
143
- body: (annotation_type_body) @annotation.body) @annotation.declaration
144
- """,
145
- ]
146
-
147
- try:
148
- language = tree.language if hasattr(tree, "language") else None
149
- if language:
150
- for query_string in class_queries:
151
- query = language.query(query_string)
152
- captures = query.captures(tree.root_node)
153
-
154
- if isinstance(captures, dict):
155
- # 各タイプのクラスを処理
156
- for key, nodes in captures.items():
157
- if key.endswith(".declaration"):
158
- class_type = key.split(".")[0]
159
- for node in nodes:
160
- cls = self._extract_detailed_class_info(
161
- node, source_code, class_type
162
- )
163
- if cls:
164
- classes.append(cls)
165
-
166
- except Exception as e:
167
- log_warning(f"Could not extract Java classes: {e}")
168
-
169
- return classes
170
-
171
- def extract_variables(
172
- self, tree: "tree_sitter.Tree", source_code: str
173
- ) -> List[Variable]:
174
- """Extract Java field and variable definitions"""
175
- variables: List[Variable] = []
176
-
177
- # Field declarations
178
- query_string = """
179
- (field_declaration
180
- type: (_) @field.type
181
- declarator: (variable_declarator
182
- name: (identifier) @field.name)) @field.declaration
183
- """
184
-
185
- try:
186
- language = tree.language if hasattr(tree, "language") else None
187
- if language:
188
- query = language.query(query_string)
189
- captures = query.captures(tree.root_node)
190
-
191
- if isinstance(captures, dict):
192
- field_nodes = captures.get("field.declaration", [])
193
- for node in field_nodes:
194
- variable = self._extract_field_info(node, source_code)
195
- if variable:
196
- variables.append(variable)
197
-
198
- except Exception as e:
199
- log_warning(f"Could not extract Java fields: {e}")
200
-
201
- return variables
202
-
203
- def extract_imports(
204
- self, tree: "tree_sitter.Tree", source_code: str
205
- ) -> List[Import]:
206
- """Extract Java import statements"""
207
- imports: List[Import] = []
208
-
209
- query_string = """
210
- (import_declaration
211
- (scoped_identifier) @import.name) @import.declaration
212
- """
213
-
214
- try:
215
- language = tree.language if hasattr(tree, "language") else None
216
- if language:
217
- query = language.query(query_string)
218
- captures = query.captures(tree.root_node)
219
-
220
- if isinstance(captures, dict):
221
- import_nodes = captures.get("import.declaration", [])
222
- for node in import_nodes:
223
- imp = self._extract_import_info(node, source_code)
224
- if imp:
225
- imports.append(imp)
226
-
227
- except Exception as e:
228
- log_warning(f"Could not extract Java imports: {e}")
229
-
230
- return imports
231
-
232
- def _extract_detailed_method_info(
233
- self, node: "tree_sitter.Node", source_code: str, is_constructor: bool = False
234
- ) -> Optional[Function]:
235
- """Extract comprehensive method information from AST node"""
236
- try:
237
- # 基本情報の抽出
238
- name = self._extract_name_from_node(node, source_code)
239
- if not name:
240
- return None
241
-
242
- # 詳細情報の抽出
243
- return_type = (
244
- self._extract_return_type_from_node(node, source_code)
245
- if not is_constructor
246
- else "void"
247
- )
248
- parameters = self._extract_parameters_from_node(node, source_code)
249
- modifiers = self._extract_modifiers_from_node(node, source_code)
250
- annotations = self._extract_annotations_from_node(node, source_code)
251
- throws = self._extract_throws_from_node(node, source_code)
252
-
253
- # 可視性の判定
254
- visibility = "public"
255
- if "private" in modifiers:
256
- visibility = "private"
257
- elif "protected" in modifiers:
258
- visibility = "protected"
259
- elif "public" not in modifiers and len(modifiers) > 0:
260
- visibility = "package"
261
-
262
- # メソッドボディの抽出
263
- body = self._extract_method_body(node, source_code)
264
- signature = self._generate_method_signature(
265
- name, return_type, parameters, modifiers
266
- )
267
-
268
- # 複雑度の簡易計算
269
- complexity_score = self._calculate_complexity(body)
270
-
271
- # Function型として返すため、基本的なFunction型を作成
272
- return Function(
273
- name=name,
274
- start_line=node.start_point[0] + 1,
275
- end_line=node.end_point[0] + 1,
276
- raw_text=source_code[node.start_byte : node.end_byte],
277
- language="java",
278
- parameters=parameters,
279
- return_type=return_type,
280
- modifiers=modifiers,
281
- is_static="static" in modifiers,
282
- is_private="private" in modifiers,
283
- is_public="public" in modifiers,
284
- )
285
-
286
- except Exception as e:
287
- log_warning(f"Could not extract detailed method info: {e}")
288
- return None
289
-
290
- def _extract_name_from_node(
291
- self, node: "tree_sitter.Node", source_code: str
292
- ) -> Optional[str]:
293
- """Extract name from AST node"""
294
- for child in node.children:
295
- if child.type == "identifier":
296
- return source_code[child.start_byte : child.end_byte]
297
- return None
298
-
299
- def _extract_return_type_from_node(
300
- self, node: "tree_sitter.Node", source_code: str
301
- ) -> str:
302
- """Extract return type from method node"""
303
- for child in node.children:
304
- if child.type in [
305
- "type_identifier",
306
- "generic_type",
307
- "array_type",
308
- "primitive_type",
309
- ]:
310
- return source_code[child.start_byte : child.end_byte]
311
- return "void"
312
-
313
- def _extract_parameters_from_node(
314
- self, node: "tree_sitter.Node", source_code: str
315
- ) -> List[str]:
316
- """Extract parameters from method node"""
317
- parameters: List[str] = []
318
- for child in node.children:
319
- if child.type == "formal_parameters":
320
- for param_child in child.children:
321
- if param_child.type == "formal_parameter":
322
- param_text = source_code[
323
- param_child.start_byte : param_child.end_byte
324
- ]
325
- parameters.append(param_text)
326
- return parameters
327
-
328
- def _extract_modifiers_from_node(
329
- self, node: "tree_sitter.Node", source_code: str
330
- ) -> List[str]:
331
- """Extract modifiers from node"""
332
- modifiers: List[str] = []
333
- for child in node.children:
334
- if child.type == "modifiers":
335
- modifier_text = source_code[child.start_byte : child.end_byte]
336
- # 簡単な分割で各修飾子を抽出
337
- for modifier in modifier_text.split():
338
- if modifier in [
339
- "public",
340
- "private",
341
- "protected",
342
- "static",
343
- "final",
344
- "abstract",
345
- "synchronized",
346
- ]:
347
- modifiers.append(modifier)
348
- return modifiers
349
-
350
- def _extract_annotations_from_node(
351
- self, node: "tree_sitter.Node", source_code: str
352
- ) -> List[JavaAnnotation]:
353
- """Extract annotations from node (simplified)"""
354
- annotations: List[JavaAnnotation] = []
355
- # より詳細な実装が必要だが、今回は簡略化
356
- return annotations
357
-
358
- def _extract_throws_from_node(
359
- self, node: "tree_sitter.Node", source_code: str
360
- ) -> List[str]:
361
- """Extract throws clause from method node"""
362
- throws: List[str] = []
363
- for child in node.children:
364
- if child.type == "throws":
365
- throws_text = source_code[child.start_byte : child.end_byte]
366
- # "throws" キーワードを除去して例外タイプを抽出
367
- if throws_text.startswith("throws"):
368
- exceptions = throws_text[6:].strip()
369
- throws.extend([ex.strip() for ex in exceptions.split(",")])
370
- return throws
371
-
372
- def _extract_method_body(self, node: "tree_sitter.Node", source_code: str) -> str:
373
- """Extract method body"""
374
- for child in node.children:
375
- if child.type in ["block", "constructor_body"]:
376
- return source_code[child.start_byte : child.end_byte]
377
- return ""
378
-
379
- def _generate_method_signature(
380
- self, name: str, return_type: str, parameters: List[str], modifiers: List[str]
381
- ) -> str:
382
- """Generate method signature"""
383
- modifier_str = " ".join(modifiers) + " " if modifiers else ""
384
- param_str = ", ".join(parameters) if parameters else ""
385
- return f"{modifier_str}{return_type} {name}({param_str})"
386
-
387
- def _calculate_complexity(self, body: str) -> int:
388
- """Calculate cyclomatic complexity (simplified)"""
389
- complexity = 1 # Base complexity
390
- keywords = ["if", "else", "for", "while", "switch", "case", "catch", "&&", "||"]
391
- for keyword in keywords:
392
- complexity += body.count(keyword)
393
- return complexity
394
-
395
- def _extract_detailed_class_info(
396
- self, node: "tree_sitter.Node", source_code: str, class_type: str = "class"
397
- ) -> Optional[Class]:
398
- """Extract comprehensive class information from AST node"""
399
- try:
400
- # 基本情報の抽出
401
- name = self._extract_name_from_node(node, source_code)
402
- if not name:
403
- return None
404
-
405
- # 詳細情報の抽出
406
- modifiers = self._extract_modifiers_from_node(node, source_code)
407
- annotations = self._extract_annotations_from_node(node, source_code)
408
- superclass = self._extract_superclass_from_node(node, source_code)
409
- interfaces = self._extract_interfaces_from_node(node, source_code)
410
-
411
- # 完全修飾名の生成
412
- full_qualified_name = (
413
- f"{self.current_package}.{name}" if self.current_package else name
414
- )
415
-
416
- # 可視性の判定
417
- visibility = "public"
418
- if "private" in modifiers:
419
- visibility = "private"
420
- elif "protected" in modifiers:
421
- visibility = "protected"
422
- elif "public" not in modifiers and len(modifiers) > 0:
423
- visibility = "package"
424
-
425
- # ネストクラスかどうかの判定(簡略化)
426
- is_nested = "." in self.current_package if self.current_package else False
427
-
428
- # Class型として返すため、基本的なClass型を作成
429
- return Class(
430
- name=name,
431
- start_line=node.start_point[0] + 1,
432
- end_line=node.end_point[0] + 1,
433
- raw_text=source_code[node.start_byte : node.end_byte],
434
- language="java",
435
- class_type=class_type,
436
- full_qualified_name=full_qualified_name,
437
- package_name=self.current_package,
438
- superclass=superclass,
439
- interfaces=interfaces,
440
- modifiers=modifiers,
441
- )
442
-
443
- except Exception as e:
444
- log_warning(f"Could not extract detailed class info: {e}")
445
- return None
446
-
447
- def _extract_superclass_from_node(
448
- self, node: "tree_sitter.Node", source_code: str
449
- ) -> Optional[str]:
450
- """Extract superclass from class node"""
451
- for child in node.children:
452
- if child.type == "superclass":
453
- for subchild in child.children:
454
- if subchild.type == "type_identifier":
455
- return source_code[subchild.start_byte : subchild.end_byte]
456
- return None
457
-
458
- def _extract_interfaces_from_node(
459
- self, node: "tree_sitter.Node", source_code: str
460
- ) -> List[str]:
461
- """Extract implemented interfaces from class node"""
462
- interfaces: List[str] = []
463
- for child in node.children:
464
- if child.type in ["super_interfaces", "extends_interfaces"]:
465
- for subchild in child.children:
466
- if subchild.type == "type_identifier":
467
- interfaces.append(
468
- source_code[subchild.start_byte : subchild.end_byte]
469
- )
470
- return interfaces
471
-
472
- def _extract_field_info(
473
- self, node: "tree_sitter.Node", source_code: str
474
- ) -> Optional[Variable]:
475
- """Extract detailed field information from AST node"""
476
- try:
477
- # Check if node has required attributes
478
- if (
479
- not hasattr(node, "start_byte")
480
- or not hasattr(node, "end_byte")
481
- or not hasattr(node, "start_point")
482
- or not hasattr(node, "end_point")
483
- ):
484
- return None
485
- if (
486
- node.start_byte is None
487
- or node.end_byte is None
488
- or node.start_point is None
489
- or node.end_point is None
490
- ):
491
- return None
492
-
493
- # Simple field extraction
494
- field_text = source_code[node.start_byte : node.end_byte]
495
-
496
- # Variable型として返すため、基本的なVariable型を作成
497
- return Variable(
498
- name="field", # Would need more sophisticated parsing
499
- start_line=node.start_point[0] + 1,
500
- end_line=node.end_point[0] + 1,
501
- raw_text=field_text,
502
- language="java",
503
- )
504
-
505
- except Exception as e:
506
- log_warning(f"Could not extract field info: {e}")
507
- return None
508
-
509
- def _extract_import_info(
510
- self, node: "tree_sitter.Node", source_code: str
511
- ) -> Optional[Import]:
512
- """Extract detailed import information from AST node"""
513
- try:
514
- # Check if node has required attributes
515
- if (
516
- not hasattr(node, "start_byte")
517
- or not hasattr(node, "end_byte")
518
- or not hasattr(node, "start_point")
519
- or not hasattr(node, "end_point")
520
- ):
521
- return None
522
- if (
523
- node.start_byte is None
524
- or node.end_byte is None
525
- or node.start_point is None
526
- or node.end_point is None
527
- ):
528
- return None
529
-
530
- import_text = source_code[node.start_byte : node.end_byte]
531
-
532
- # Import型として返すため、基本的なImport型を作成
533
- return Import(
534
- name="import", # Would need more sophisticated parsing
535
- start_line=node.start_point[0] + 1,
536
- end_line=node.end_point[0] + 1,
537
- raw_text=import_text,
538
- language="java",
539
- module_name=import_text,
540
- )
541
-
542
- except Exception as e:
543
- log_warning(f"Could not extract import info: {e}")
544
- return None
545
-
546
-
547
- class JavaPlugin(LanguagePlugin):
548
- """Java language plugin"""
549
-
550
- def __init__(self) -> None:
551
- self._extractor = JavaElementExtractor()
552
- self._language: Optional["tree_sitter.Language"] = None
553
-
554
- @property
555
- def language_name(self) -> str:
556
- return "java"
557
-
558
- @property
559
- def file_extensions(self) -> List[str]:
560
- return [".java", ".jsp", ".jspx"]
561
-
562
- def get_language_name(self) -> str:
563
- """Return the name of the programming language this plugin supports"""
564
- return "java"
565
-
566
- def get_file_extensions(self) -> List[str]:
567
- """Return list of file extensions this plugin supports"""
568
- return [".java", ".jsp", ".jspx"]
569
-
570
- def create_extractor(self) -> ElementExtractor:
571
- """Create and return an element extractor for this language"""
572
- return JavaElementExtractor()
573
-
574
- def get_extractor(self) -> ElementExtractor:
575
- return self._extractor
576
-
577
- def get_tree_sitter_language(self) -> Optional["tree_sitter.Language"]:
578
- """Load and return Java tree-sitter language"""
579
- if self._language is None:
580
- self._language = loader.load_language("java")
581
- return self._language
582
-
583
- async def analyze_file(self, file_path: str, request: 'AnalysisRequest') -> 'AnalysisResult':
584
- """
585
- Javaファイルを解析してAnalysisResultを返す
586
-
587
- Args:
588
- file_path: 解析対象ファイルのパス
589
- request: 解析リクエスト
590
-
591
- Returns:
592
- 解析結果
593
- """
594
- from ..models import AnalysisResult
595
- from ..core.analysis_engine import get_analysis_engine, AnalysisRequest
596
-
597
- try:
598
- # Use UnifiedAnalysisEngine for file analysis
599
- analyzer = get_analysis_engine()
600
-
601
- # Create analysis request and analyze file
602
- request = AnalysisRequest(
603
- file_path=file_path,
604
- language="java",
605
- include_complexity=True,
606
- include_details=True
607
- )
608
- result = await analyzer.analyze(request)
609
-
610
- if not result or not result.success:
611
- return AnalysisResult(
612
- file_path=file_path,
613
- success=False,
614
- error_message=f"Failed to analyze Java file: {file_path}"
615
- )
616
-
617
- return result
618
-
619
- except Exception as e:
620
- log_error(f"Error analyzing Java file {file_path}: {e}")
621
- return AnalysisResult(
622
- file_path=file_path,
623
- success=False,
624
- error_message=str(e)
625
- )