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
@@ -1,291 +1,291 @@
1
- #!/usr/bin/env python3
2
- """
3
- Java-specific table formatter.
4
- """
5
-
6
- from typing import Any
7
-
8
- from .base_formatter import BaseTableFormatter
9
-
10
-
11
- class JavaTableFormatter(BaseTableFormatter):
12
- """Java言語専用のテーブルフォーマッター"""
13
-
14
- def _format_full_table(self, data: dict[str, Any]) -> str:
15
- """Java用完全版テーブル形式"""
16
- lines = []
17
-
18
- # ヘッダー - Java用(複数クラス対応)
19
- classes = data.get("classes", [])
20
- package_name = (data.get("package") or {}).get("name", "unknown")
21
-
22
- if len(classes) > 1:
23
- # 複数クラスがある場合はファイル名を使用
24
- file_name = data.get("file_path", "Unknown").split("/")[-1].split("\\")[-1]
25
- lines.append(f"# {package_name}.{file_name}")
26
- else:
27
- # 単一クラスの場合は従来通り
28
- class_name = classes[0].get("name", "Unknown") if classes else "Unknown"
29
- lines.append(f"# {package_name}.{class_name}")
30
- lines.append("")
31
-
32
- # Imports
33
- imports = data.get("imports", [])
34
- if imports:
35
- lines.append("## Imports")
36
- lines.append("```java")
37
- for imp in imports:
38
- lines.append(str(imp.get("statement", "")))
39
- lines.append("```")
40
- lines.append("")
41
-
42
- # Class Info - Java用(複数クラス対応)
43
- if len(classes) > 1:
44
- lines.append("## Classes")
45
- lines.append("| Class | Type | Visibility | Lines | Methods | Fields |")
46
- lines.append("|-------|------|------------|-------|---------|--------|")
47
-
48
- for class_info in classes:
49
- name = str(class_info.get("name", "Unknown"))
50
- class_type = str(class_info.get("type", "class"))
51
- visibility = str(class_info.get("visibility", "public"))
52
- line_range = class_info.get("line_range", {})
53
- lines_str = f"{line_range.get('start', 0)}-{line_range.get('end', 0)}"
54
-
55
- # このクラスのメソッド数とフィールド数を計算
56
- class_methods = [
57
- m
58
- for m in data.get("methods", [])
59
- if line_range.get("start", 0)
60
- <= m.get("line_range", {}).get("start", 0)
61
- <= line_range.get("end", 0)
62
- ]
63
- class_fields = [
64
- f
65
- for f in data.get("fields", [])
66
- if line_range.get("start", 0)
67
- <= f.get("line_range", {}).get("start", 0)
68
- <= line_range.get("end", 0)
69
- ]
70
-
71
- lines.append(
72
- f"| {name} | {class_type} | {visibility} | {lines_str} | {len(class_methods)} | {len(class_fields)} |"
73
- )
74
- else:
75
- # 単一クラスの場合は従来通り
76
- lines.append("## Class Info")
77
- lines.append("| Property | Value |")
78
- lines.append("|----------|-------|")
79
-
80
- class_info = data.get("classes", [{}])[0] if data.get("classes") else {}
81
- stats = data.get("statistics") or {}
82
-
83
- lines.append(f"| Package | {package_name} |")
84
- lines.append(f"| Type | {str(class_info.get('type', 'class'))} |")
85
- lines.append(
86
- f"| Visibility | {str(class_info.get('visibility', 'public'))} |"
87
- )
88
- lines.append(
89
- f"| Lines | {class_info.get('line_range', {}).get('start', 0)}-{class_info.get('line_range', {}).get('end', 0)} |"
90
- )
91
- lines.append(f"| Total Methods | {stats.get('method_count', 0)} |")
92
- lines.append(f"| Total Fields | {stats.get('field_count', 0)} |")
93
-
94
- lines.append("")
95
-
96
- # Fields
97
- fields = data.get("fields", [])
98
- if fields:
99
- lines.append("## Fields")
100
- lines.append("| Name | Type | Vis | Modifiers | Line | Doc |")
101
- lines.append("|------|------|-----|-----------|------|-----|")
102
-
103
- for field in fields:
104
- name = str(field.get("name", ""))
105
- field_type = str(field.get("type", ""))
106
- visibility = self._convert_visibility(str(field.get("visibility", "")))
107
- modifiers = ",".join([str(m) for m in field.get("modifiers", [])])
108
- line = field.get("line_range", {}).get("start", 0)
109
- doc = str(field.get("javadoc", "")) or "-"
110
- doc = doc.replace("\n", " ").replace("|", "\\|")[:50]
111
-
112
- lines.append(
113
- f"| {name} | {field_type} | {visibility} | {modifiers} | {line} | {doc} |"
114
- )
115
- lines.append("")
116
-
117
- # Constructor
118
- constructors = [
119
- m for m in (data.get("methods") or []) if m.get("is_constructor", False)
120
- ]
121
- if constructors:
122
- lines.append("## Constructor")
123
- lines.append("| Method | Signature | Vis | Lines | Cols | Cx | Doc |")
124
- lines.append("|--------|-----------|-----|-------|------|----|----|")
125
-
126
- for method in constructors:
127
- lines.append(self._format_method_row(method))
128
- lines.append("")
129
-
130
- # Public Methods
131
- public_methods = [
132
- m
133
- for m in (data.get("methods") or [])
134
- if not m.get("is_constructor", False)
135
- and str(m.get("visibility")) == "public"
136
- ]
137
- if public_methods:
138
- lines.append("## Public Methods")
139
- lines.append("| Method | Signature | Vis | Lines | Cols | Cx | Doc |")
140
- lines.append("|--------|-----------|-----|-------|------|----|----|")
141
-
142
- for method in public_methods:
143
- lines.append(self._format_method_row(method))
144
- lines.append("")
145
-
146
- # Private Methods
147
- private_methods = [
148
- m
149
- for m in (data.get("methods") or [])
150
- if not m.get("is_constructor", False)
151
- and str(m.get("visibility")) == "private"
152
- ]
153
- if private_methods:
154
- lines.append("## Private Methods")
155
- lines.append("| Method | Signature | Vis | Lines | Cols | Cx | Doc |")
156
- lines.append("|--------|-----------|-----|-------|------|----|----|")
157
-
158
- for method in private_methods:
159
- lines.append(self._format_method_row(method))
160
- lines.append("")
161
-
162
- # 末尾の空行を削除
163
- while lines and lines[-1] == "":
164
- lines.pop()
165
-
166
- return "\n".join(lines)
167
-
168
- def _format_compact_table(self, data: dict[str, Any]) -> str:
169
- """Java用コンパクト版テーブル形式"""
170
- lines = []
171
-
172
- # ヘッダー
173
- package_name = (data.get("package") or {}).get("name", "unknown")
174
- classes = data.get("classes", [])
175
- class_name = classes[0].get("name", "Unknown") if classes else "Unknown"
176
- lines.append(f"# {package_name}.{class_name}")
177
- lines.append("")
178
-
179
- # 基本情報
180
- stats = data.get("statistics") or {}
181
- lines.append("## Info")
182
- lines.append("| Property | Value |")
183
- lines.append("|----------|-------|")
184
- lines.append(f"| Package | {package_name} |")
185
- lines.append(f"| Methods | {stats.get('method_count', 0)} |")
186
- lines.append(f"| Fields | {stats.get('field_count', 0)} |")
187
- lines.append("")
188
-
189
- # メソッド(簡略版)
190
- methods = data.get("methods", [])
191
- if methods:
192
- lines.append("## Methods")
193
- lines.append("| Method | Sig | V | L | Cx | Doc |")
194
- lines.append("|--------|-----|---|---|----|----|")
195
-
196
- for method in methods:
197
- name = str(method.get("name", ""))
198
- signature = self._create_compact_signature(method)
199
- visibility = self._convert_visibility(str(method.get("visibility", "")))
200
- line_range = method.get("line_range", {})
201
- lines_str = f"{line_range.get('start', 0)}-{line_range.get('end', 0)}"
202
- complexity = method.get("complexity_score", 0)
203
- doc = self._clean_csv_text(
204
- self._extract_doc_summary(str(method.get("javadoc", "")))
205
- )
206
-
207
- lines.append(
208
- f"| {name} | {signature} | {visibility} | {lines_str} | {complexity} | {doc} |"
209
- )
210
- lines.append("")
211
-
212
- # 末尾の空行を削除
213
- while lines and lines[-1] == "":
214
- lines.pop()
215
-
216
- return "\n".join(lines)
217
-
218
- def _format_method_row(self, method: dict[str, Any]) -> str:
219
- """Java用メソッド行のフォーマット"""
220
- name = str(method.get("name", ""))
221
- signature = self._create_full_signature(method)
222
- visibility = self._convert_visibility(str(method.get("visibility", "")))
223
- line_range = method.get("line_range", {})
224
- lines_str = f"{line_range.get('start', 0)}-{line_range.get('end', 0)}"
225
- cols_str = "5-6" # デフォルト値
226
- complexity = method.get("complexity_score", 0)
227
- doc = self._clean_csv_text(
228
- self._extract_doc_summary(str(method.get("javadoc", "")))
229
- )
230
-
231
- return f"| {name} | {signature} | {visibility} | {lines_str} | {cols_str} | {complexity} | {doc} |"
232
-
233
- def _create_compact_signature(self, method: dict[str, Any]) -> str:
234
- """Java用コンパクトなメソッドシグネチャを作成"""
235
- params = method.get("parameters", [])
236
- param_types = [
237
- self._shorten_type(p.get("type", "O") if isinstance(p, dict) else str(p))
238
- for p in params
239
- ]
240
- params_str = ",".join(param_types)
241
- return_type = self._shorten_type(method.get("return_type", "void"))
242
-
243
- return f"({params_str}):{return_type}"
244
-
245
- def _shorten_type(self, type_name: Any) -> str:
246
- """Java用型名を短縮"""
247
- if type_name is None:
248
- return "O"
249
-
250
- if not isinstance(type_name, str):
251
- type_name = str(type_name)
252
-
253
- type_mapping = {
254
- "String": "S",
255
- "int": "i",
256
- "long": "l",
257
- "double": "d",
258
- "boolean": "b",
259
- "void": "void",
260
- "Object": "O",
261
- "Exception": "E",
262
- "SQLException": "SE",
263
- "IllegalArgumentException": "IAE",
264
- "RuntimeException": "RE",
265
- }
266
-
267
- # Map<String,Object> -> M<S,O>
268
- if "Map<" in type_name:
269
- result = (
270
- type_name.replace("Map<", "M<")
271
- .replace("String", "S")
272
- .replace("Object", "O")
273
- )
274
- return str(result)
275
-
276
- # List<String> -> L<S>
277
- if "List<" in type_name:
278
- result = type_name.replace("List<", "L<").replace("String", "S")
279
- return str(result)
280
-
281
- # String[] -> S[]
282
- if "[]" in type_name:
283
- base_type = type_name.replace("[]", "")
284
- if base_type:
285
- result = type_mapping.get(base_type, base_type[0].upper()) + "[]"
286
- return str(result)
287
- else:
288
- return "O[]"
289
-
290
- result = type_mapping.get(type_name, type_name)
291
- return str(result)
1
+ #!/usr/bin/env python3
2
+ """
3
+ Java-specific table formatter.
4
+ """
5
+
6
+ from typing import Any
7
+
8
+ from .base_formatter import BaseTableFormatter
9
+
10
+
11
+ class JavaTableFormatter(BaseTableFormatter):
12
+ """Java言語専用のテーブルフォーマッター"""
13
+
14
+ def _format_full_table(self, data: dict[str, Any]) -> str:
15
+ """Java用完全版テーブル形式"""
16
+ lines = []
17
+
18
+ # ヘッダー - Java用(複数クラス対応)
19
+ classes = data.get("classes", [])
20
+ package_name = (data.get("package") or {}).get("name", "unknown")
21
+
22
+ if len(classes) > 1:
23
+ # 複数クラスがある場合はファイル名を使用
24
+ file_name = data.get("file_path", "Unknown").split("/")[-1].split("\\")[-1]
25
+ lines.append(f"# {package_name}.{file_name}")
26
+ else:
27
+ # 単一クラスの場合は従来通り
28
+ class_name = classes[0].get("name", "Unknown") if classes else "Unknown"
29
+ lines.append(f"# {package_name}.{class_name}")
30
+ lines.append("")
31
+
32
+ # Imports
33
+ imports = data.get("imports", [])
34
+ if imports:
35
+ lines.append("## Imports")
36
+ lines.append("```java")
37
+ for imp in imports:
38
+ lines.append(str(imp.get("statement", "")))
39
+ lines.append("```")
40
+ lines.append("")
41
+
42
+ # Class Info - Java用(複数クラス対応)
43
+ if len(classes) > 1:
44
+ lines.append("## Classes")
45
+ lines.append("| Class | Type | Visibility | Lines | Methods | Fields |")
46
+ lines.append("|-------|------|------------|-------|---------|--------|")
47
+
48
+ for class_info in classes:
49
+ name = str(class_info.get("name", "Unknown"))
50
+ class_type = str(class_info.get("type", "class"))
51
+ visibility = str(class_info.get("visibility", "public"))
52
+ line_range = class_info.get("line_range", {})
53
+ lines_str = f"{line_range.get('start', 0)}-{line_range.get('end', 0)}"
54
+
55
+ # このクラスのメソッド数とフィールド数を計算
56
+ class_methods = [
57
+ m
58
+ for m in data.get("methods", [])
59
+ if line_range.get("start", 0)
60
+ <= m.get("line_range", {}).get("start", 0)
61
+ <= line_range.get("end", 0)
62
+ ]
63
+ class_fields = [
64
+ f
65
+ for f in data.get("fields", [])
66
+ if line_range.get("start", 0)
67
+ <= f.get("line_range", {}).get("start", 0)
68
+ <= line_range.get("end", 0)
69
+ ]
70
+
71
+ lines.append(
72
+ f"| {name} | {class_type} | {visibility} | {lines_str} | {len(class_methods)} | {len(class_fields)} |"
73
+ )
74
+ else:
75
+ # 単一クラスの場合は従来通り
76
+ lines.append("## Class Info")
77
+ lines.append("| Property | Value |")
78
+ lines.append("|----------|-------|")
79
+
80
+ class_info = data.get("classes", [{}])[0] if data.get("classes") else {}
81
+ stats = data.get("statistics") or {}
82
+
83
+ lines.append(f"| Package | {package_name} |")
84
+ lines.append(f"| Type | {str(class_info.get('type', 'class'))} |")
85
+ lines.append(
86
+ f"| Visibility | {str(class_info.get('visibility', 'public'))} |"
87
+ )
88
+ lines.append(
89
+ f"| Lines | {class_info.get('line_range', {}).get('start', 0)}-{class_info.get('line_range', {}).get('end', 0)} |"
90
+ )
91
+ lines.append(f"| Total Methods | {stats.get('method_count', 0)} |")
92
+ lines.append(f"| Total Fields | {stats.get('field_count', 0)} |")
93
+
94
+ lines.append("")
95
+
96
+ # Fields
97
+ fields = data.get("fields", [])
98
+ if fields:
99
+ lines.append("## Fields")
100
+ lines.append("| Name | Type | Vis | Modifiers | Line | Doc |")
101
+ lines.append("|------|------|-----|-----------|------|-----|")
102
+
103
+ for field in fields:
104
+ name = str(field.get("name", ""))
105
+ field_type = str(field.get("type", ""))
106
+ visibility = self._convert_visibility(str(field.get("visibility", "")))
107
+ modifiers = ",".join([str(m) for m in field.get("modifiers", [])])
108
+ line = field.get("line_range", {}).get("start", 0)
109
+ doc = str(field.get("javadoc", "")) or "-"
110
+ doc = doc.replace("\n", " ").replace("|", "\\|")[:50]
111
+
112
+ lines.append(
113
+ f"| {name} | {field_type} | {visibility} | {modifiers} | {line} | {doc} |"
114
+ )
115
+ lines.append("")
116
+
117
+ # Constructor
118
+ constructors = [
119
+ m for m in (data.get("methods") or []) if m.get("is_constructor", False)
120
+ ]
121
+ if constructors:
122
+ lines.append("## Constructor")
123
+ lines.append("| Method | Signature | Vis | Lines | Cols | Cx | Doc |")
124
+ lines.append("|--------|-----------|-----|-------|------|----|----|")
125
+
126
+ for method in constructors:
127
+ lines.append(self._format_method_row(method))
128
+ lines.append("")
129
+
130
+ # Public Methods
131
+ public_methods = [
132
+ m
133
+ for m in (data.get("methods") or [])
134
+ if not m.get("is_constructor", False)
135
+ and str(m.get("visibility")) == "public"
136
+ ]
137
+ if public_methods:
138
+ lines.append("## Public Methods")
139
+ lines.append("| Method | Signature | Vis | Lines | Cols | Cx | Doc |")
140
+ lines.append("|--------|-----------|-----|-------|------|----|----|")
141
+
142
+ for method in public_methods:
143
+ lines.append(self._format_method_row(method))
144
+ lines.append("")
145
+
146
+ # Private Methods
147
+ private_methods = [
148
+ m
149
+ for m in (data.get("methods") or [])
150
+ if not m.get("is_constructor", False)
151
+ and str(m.get("visibility")) == "private"
152
+ ]
153
+ if private_methods:
154
+ lines.append("## Private Methods")
155
+ lines.append("| Method | Signature | Vis | Lines | Cols | Cx | Doc |")
156
+ lines.append("|--------|-----------|-----|-------|------|----|----|")
157
+
158
+ for method in private_methods:
159
+ lines.append(self._format_method_row(method))
160
+ lines.append("")
161
+
162
+ # 末尾の空行を削除
163
+ while lines and lines[-1] == "":
164
+ lines.pop()
165
+
166
+ return "\n".join(lines)
167
+
168
+ def _format_compact_table(self, data: dict[str, Any]) -> str:
169
+ """Java用コンパクト版テーブル形式"""
170
+ lines = []
171
+
172
+ # ヘッダー
173
+ package_name = (data.get("package") or {}).get("name", "unknown")
174
+ classes = data.get("classes", [])
175
+ class_name = classes[0].get("name", "Unknown") if classes else "Unknown"
176
+ lines.append(f"# {package_name}.{class_name}")
177
+ lines.append("")
178
+
179
+ # 基本情報
180
+ stats = data.get("statistics") or {}
181
+ lines.append("## Info")
182
+ lines.append("| Property | Value |")
183
+ lines.append("|----------|-------|")
184
+ lines.append(f"| Package | {package_name} |")
185
+ lines.append(f"| Methods | {stats.get('method_count', 0)} |")
186
+ lines.append(f"| Fields | {stats.get('field_count', 0)} |")
187
+ lines.append("")
188
+
189
+ # メソッド(簡略版)
190
+ methods = data.get("methods", [])
191
+ if methods:
192
+ lines.append("## Methods")
193
+ lines.append("| Method | Sig | V | L | Cx | Doc |")
194
+ lines.append("|--------|-----|---|---|----|----|")
195
+
196
+ for method in methods:
197
+ name = str(method.get("name", ""))
198
+ signature = self._create_compact_signature(method)
199
+ visibility = self._convert_visibility(str(method.get("visibility", "")))
200
+ line_range = method.get("line_range", {})
201
+ lines_str = f"{line_range.get('start', 0)}-{line_range.get('end', 0)}"
202
+ complexity = method.get("complexity_score", 0)
203
+ doc = self._clean_csv_text(
204
+ self._extract_doc_summary(str(method.get("javadoc", "")))
205
+ )
206
+
207
+ lines.append(
208
+ f"| {name} | {signature} | {visibility} | {lines_str} | {complexity} | {doc} |"
209
+ )
210
+ lines.append("")
211
+
212
+ # 末尾の空行を削除
213
+ while lines and lines[-1] == "":
214
+ lines.pop()
215
+
216
+ return "\n".join(lines)
217
+
218
+ def _format_method_row(self, method: dict[str, Any]) -> str:
219
+ """Java用メソッド行のフォーマット"""
220
+ name = str(method.get("name", ""))
221
+ signature = self._create_full_signature(method)
222
+ visibility = self._convert_visibility(str(method.get("visibility", "")))
223
+ line_range = method.get("line_range", {})
224
+ lines_str = f"{line_range.get('start', 0)}-{line_range.get('end', 0)}"
225
+ cols_str = "5-6" # デフォルト値
226
+ complexity = method.get("complexity_score", 0)
227
+ doc = self._clean_csv_text(
228
+ self._extract_doc_summary(str(method.get("javadoc", "")))
229
+ )
230
+
231
+ return f"| {name} | {signature} | {visibility} | {lines_str} | {cols_str} | {complexity} | {doc} |"
232
+
233
+ def _create_compact_signature(self, method: dict[str, Any]) -> str:
234
+ """Java用コンパクトなメソッドシグネチャを作成"""
235
+ params = method.get("parameters", [])
236
+ param_types = [
237
+ self._shorten_type(p.get("type", "O") if isinstance(p, dict) else str(p))
238
+ for p in params
239
+ ]
240
+ params_str = ",".join(param_types)
241
+ return_type = self._shorten_type(method.get("return_type", "void"))
242
+
243
+ return f"({params_str}):{return_type}"
244
+
245
+ def _shorten_type(self, type_name: Any) -> str:
246
+ """Java用型名を短縮"""
247
+ if type_name is None:
248
+ return "O"
249
+
250
+ if not isinstance(type_name, str):
251
+ type_name = str(type_name)
252
+
253
+ type_mapping = {
254
+ "String": "S",
255
+ "int": "i",
256
+ "long": "l",
257
+ "double": "d",
258
+ "boolean": "b",
259
+ "void": "void",
260
+ "Object": "O",
261
+ "Exception": "E",
262
+ "SQLException": "SE",
263
+ "IllegalArgumentException": "IAE",
264
+ "RuntimeException": "RE",
265
+ }
266
+
267
+ # Map<String,Object> -> M<S,O>
268
+ if "Map<" in type_name:
269
+ result = (
270
+ type_name.replace("Map<", "M<")
271
+ .replace("String", "S")
272
+ .replace("Object", "O")
273
+ )
274
+ return str(result)
275
+
276
+ # List<String> -> L<S>
277
+ if "List<" in type_name:
278
+ result = type_name.replace("List<", "L<").replace("String", "S")
279
+ return str(result)
280
+
281
+ # String[] -> S[]
282
+ if "[]" in type_name:
283
+ base_type = type_name.replace("[]", "")
284
+ if base_type:
285
+ result = type_mapping.get(base_type, base_type[0].upper()) + "[]"
286
+ return str(result)
287
+ else:
288
+ return "O[]"
289
+
290
+ result = type_mapping.get(type_name, type_name)
291
+ return str(result)