tree-sitter-analyzer 0.4.0__py3-none-any.whl → 0.6.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 (38) hide show
  1. tree_sitter_analyzer/__init__.py +1 -3
  2. tree_sitter_analyzer/__main__.py +2 -2
  3. tree_sitter_analyzer/cli/commands/default_command.py +1 -1
  4. tree_sitter_analyzer/cli/commands/query_command.py +5 -5
  5. tree_sitter_analyzer/cli/commands/table_command.py +3 -3
  6. tree_sitter_analyzer/cli/info_commands.py +14 -13
  7. tree_sitter_analyzer/cli_main.py +49 -30
  8. tree_sitter_analyzer/core/analysis_engine.py +21 -21
  9. tree_sitter_analyzer/core/cache_service.py +31 -31
  10. tree_sitter_analyzer/core/query.py +502 -502
  11. tree_sitter_analyzer/encoding_utils.py +5 -2
  12. tree_sitter_analyzer/file_handler.py +3 -3
  13. tree_sitter_analyzer/formatters/base_formatter.py +18 -18
  14. tree_sitter_analyzer/formatters/formatter_factory.py +15 -15
  15. tree_sitter_analyzer/formatters/java_formatter.py +291 -291
  16. tree_sitter_analyzer/formatters/python_formatter.py +259 -259
  17. tree_sitter_analyzer/interfaces/cli_adapter.py +32 -32
  18. tree_sitter_analyzer/interfaces/mcp_adapter.py +2 -2
  19. tree_sitter_analyzer/language_detector.py +398 -398
  20. tree_sitter_analyzer/language_loader.py +224 -224
  21. tree_sitter_analyzer/languages/java_plugin.py +1174 -1174
  22. tree_sitter_analyzer/languages/python_plugin.py +10 -2
  23. tree_sitter_analyzer/mcp/resources/project_stats_resource.py +555 -555
  24. tree_sitter_analyzer/models.py +470 -470
  25. tree_sitter_analyzer/output_manager.py +8 -10
  26. tree_sitter_analyzer/plugins/base.py +33 -0
  27. tree_sitter_analyzer/queries/java.py +78 -78
  28. tree_sitter_analyzer/queries/javascript.py +7 -7
  29. tree_sitter_analyzer/queries/python.py +18 -18
  30. tree_sitter_analyzer/queries/typescript.py +12 -12
  31. tree_sitter_analyzer/query_loader.py +13 -13
  32. tree_sitter_analyzer/table_formatter.py +20 -18
  33. tree_sitter_analyzer/utils.py +1 -1
  34. {tree_sitter_analyzer-0.4.0.dist-info → tree_sitter_analyzer-0.6.0.dist-info}/METADATA +11 -11
  35. {tree_sitter_analyzer-0.4.0.dist-info → tree_sitter_analyzer-0.6.0.dist-info}/RECORD +37 -38
  36. tree_sitter_analyzer/java_analyzer.py +0 -187
  37. {tree_sitter_analyzer-0.4.0.dist-info → tree_sitter_analyzer-0.6.0.dist-info}/WHEEL +0 -0
  38. {tree_sitter_analyzer-0.4.0.dist-info → tree_sitter_analyzer-0.6.0.dist-info}/entry_points.txt +0 -0
@@ -151,17 +151,20 @@ class EncodingManager:
151
151
  FALLBACK_ENCODINGS = ["utf-8", "cp1252", "iso-8859-1", "shift_jis", "gbk"]
152
152
 
153
153
  @classmethod
154
- def safe_encode(cls, text: str, encoding: str | None = None) -> bytes:
154
+ def safe_encode(cls, text: str | None, encoding: str | None = None) -> bytes:
155
155
  """
156
156
  Safely encode text to bytes with fallback handling
157
157
 
158
158
  Args:
159
- text: Text to encode
159
+ text: Text to encode (can be None)
160
160
  encoding: Target encoding (defaults to UTF-8)
161
161
 
162
162
  Returns:
163
163
  Encoded bytes
164
164
  """
165
+ # Handle None input
166
+ if text is None:
167
+ return b""
165
168
 
166
169
  target_encoding = encoding or cls.DEFAULT_ENCODING
167
170
 
@@ -13,13 +13,13 @@ from .utils import log_error, log_info, log_warning
13
13
 
14
14
  def detect_language_from_extension(file_path: str) -> str:
15
15
  """
16
- ファイル拡張子から言語を判定
16
+ Detect programming language from file extension
17
17
 
18
18
  Args:
19
- file_path: ファイルパス
19
+ file_path: File path to analyze
20
20
 
21
21
  Returns:
22
- 言語名または'unknown'
22
+ Language name or 'unknown' if not recognized
23
23
  """
24
24
  extension = os.path.splitext(file_path)[1].lower()
25
25
 
@@ -17,17 +17,17 @@ class BaseTableFormatter(ABC):
17
17
  self.format_type = format_type
18
18
 
19
19
  def _get_platform_newline(self) -> str:
20
- """プラットフォーム固有の改行コードを取得"""
20
+ """Get platform-specific newline code"""
21
21
  return os.linesep
22
22
 
23
23
  def _convert_to_platform_newlines(self, text: str) -> str:
24
- """通常の\nをプラットフォーム固有の改行コードに変換"""
24
+ """Convert regular \n to platform-specific newline code"""
25
25
  if os.linesep != "\n":
26
26
  return text.replace("\n", os.linesep)
27
27
  return text
28
28
 
29
29
  def format_structure(self, structure_data: dict[str, Any]) -> str:
30
- """構造データをテーブル形式でフォーマット"""
30
+ """Format structure data in table format"""
31
31
  if self.format_type == "full":
32
32
  result = self._format_full_table(structure_data)
33
33
  elif self.format_type == "compact":
@@ -37,7 +37,7 @@ class BaseTableFormatter(ABC):
37
37
  else:
38
38
  raise ValueError(f"Unsupported format type: {self.format_type}")
39
39
 
40
- # 最終的にプラットフォーム固有の改行コードに変換
40
+ # Finally convert to platform-specific newline code
41
41
  if self.format_type == "csv":
42
42
  return result
43
43
 
@@ -45,25 +45,25 @@ class BaseTableFormatter(ABC):
45
45
 
46
46
  @abstractmethod
47
47
  def _format_full_table(self, data: dict[str, Any]) -> str:
48
- """完全版テーブル形式(言語固有実装)"""
48
+ """Full table format (language-specific implementation)"""
49
49
  pass
50
50
 
51
51
  @abstractmethod
52
52
  def _format_compact_table(self, data: dict[str, Any]) -> str:
53
- """コンパクト版テーブル形式(言語固有実装)"""
53
+ """Compact table format (language-specific implementation)"""
54
54
  pass
55
55
 
56
56
  def _format_csv(self, data: dict[str, Any]) -> str:
57
- """CSV形式(共通実装)"""
57
+ """CSV format (common implementation)"""
58
58
  output = io.StringIO()
59
59
  writer = csv.writer(output, lineterminator="\n")
60
60
 
61
- # ヘッダー
61
+ # Header
62
62
  writer.writerow(
63
63
  ["Type", "Name", "Signature", "Visibility", "Lines", "Complexity", "Doc"]
64
64
  )
65
65
 
66
- # フィールド
66
+ # Fields
67
67
  for field in data.get("fields", []):
68
68
  writer.writerow(
69
69
  [
@@ -79,7 +79,7 @@ class BaseTableFormatter(ABC):
79
79
  ]
80
80
  )
81
81
 
82
- # メソッド
82
+ # Methods
83
83
  for method in data.get("methods", []):
84
84
  writer.writerow(
85
85
  [
@@ -102,9 +102,9 @@ class BaseTableFormatter(ABC):
102
102
 
103
103
  return csv_content
104
104
 
105
- # 共通ヘルパーメソッド
105
+ # Common helper methods
106
106
  def _create_full_signature(self, method: dict[str, Any]) -> str:
107
- """完全なメソッドシグネチャを作成"""
107
+ """Create complete method signature"""
108
108
  params = method.get("parameters", [])
109
109
  param_strs = []
110
110
  for param in params:
@@ -131,32 +131,32 @@ class BaseTableFormatter(ABC):
131
131
  return signature
132
132
 
133
133
  def _convert_visibility(self, visibility: str) -> str:
134
- """可視性を記号に変換"""
134
+ """Convert visibility to symbol"""
135
135
  mapping = {"public": "+", "private": "-", "protected": "#", "package": "~"}
136
136
  return mapping.get(visibility, visibility)
137
137
 
138
138
  def _extract_doc_summary(self, javadoc: str) -> str:
139
- """ドキュメントから要約を抽出"""
139
+ """Extract summary from documentation"""
140
140
  if not javadoc:
141
141
  return "-"
142
142
 
143
- # コメント記号を除去
143
+ # Remove comment symbols
144
144
  clean_doc = (
145
145
  javadoc.replace("/**", "").replace("*/", "").replace("*", "").strip()
146
146
  )
147
147
 
148
- # 最初の行を取得
148
+ # Get first line
149
149
  lines = clean_doc.split("\n")
150
150
  first_line = lines[0].strip()
151
151
 
152
- # 長すぎる場合は切り詰め
152
+ # Truncate if too long
153
153
  if len(first_line) > 50:
154
154
  first_line = first_line[:47] + "..."
155
155
 
156
156
  return first_line.replace("|", "\\|").replace("\n", " ")
157
157
 
158
158
  def _clean_csv_text(self, text: str) -> str:
159
- """CSV形式用のテキストクリーニング"""
159
+ """Text cleaning for CSV format"""
160
160
  if not text:
161
161
  return ""
162
162
 
@@ -9,7 +9,7 @@ from .python_formatter import PythonTableFormatter
9
9
 
10
10
 
11
11
  class TableFormatterFactory:
12
- """言語固有のテーブルフォーマッターを作成するファクトリー"""
12
+ """Factory for creating language-specific table formatters"""
13
13
 
14
14
  _formatters: dict[str, type[BaseTableFormatter]] = {
15
15
  "java": JavaTableFormatter,
@@ -21,19 +21,19 @@ class TableFormatterFactory:
21
21
  cls, language: str, format_type: str = "full"
22
22
  ) -> BaseTableFormatter:
23
23
  """
24
- 指定された言語用のテーブルフォーマッターを作成
24
+ Create table formatter for specified language
25
25
 
26
26
  Args:
27
- language: プログラミング言語名
28
- format_type: フォーマットタイプ(full, compact, csv
27
+ language: Programming language name
28
+ format_type: Format type (full, compact, csv)
29
29
 
30
30
  Returns:
31
- 言語固有のテーブルフォーマッター
31
+ Language-specific table formatter
32
32
  """
33
33
  formatter_class = cls._formatters.get(language.lower())
34
34
 
35
35
  if formatter_class is None:
36
- # デフォルトとしてJavaフォーマッターを使用
36
+ # Use Java formatter as default
37
37
  formatter_class = JavaTableFormatter
38
38
 
39
39
  return formatter_class(format_type)
@@ -43,21 +43,21 @@ class TableFormatterFactory:
43
43
  cls, language: str, formatter_class: type[BaseTableFormatter]
44
44
  ) -> None:
45
45
  """
46
- 新しい言語フォーマッターを登録
46
+ Register new language formatter
47
47
 
48
48
  Args:
49
- language: プログラミング言語名
50
- formatter_class: フォーマッタークラス
49
+ language: Programming language name
50
+ formatter_class: Formatter class
51
51
  """
52
52
  cls._formatters[language.lower()] = formatter_class
53
53
 
54
54
  @classmethod
55
55
  def get_supported_languages(cls) -> list[str]:
56
56
  """
57
- サポートされている言語一覧を取得
57
+ Get list of supported languages
58
58
 
59
59
  Returns:
60
- サポートされている言語のリスト
60
+ List of supported languages
61
61
  """
62
62
  return list(cls._formatters.keys())
63
63
 
@@ -66,13 +66,13 @@ def create_table_formatter(
66
66
  format_type: str, language: str = "java"
67
67
  ) -> BaseTableFormatter:
68
68
  """
69
- テーブルフォーマッターを作成(互換性のための関数)
69
+ Create table formatter (function for compatibility)
70
70
 
71
71
  Args:
72
- format_type: フォーマットタイプ
73
- language: プログラミング言語名
72
+ format_type: Format type
73
+ language: Programming language name
74
74
 
75
75
  Returns:
76
- テーブルフォーマッター
76
+ Table formatter
77
77
  """
78
78
  return TableFormatterFactory.create_formatter(language, format_type)