tree-sitter-analyzer 0.9.2__py3-none-any.whl → 0.9.4__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 (37) hide show
  1. tree_sitter_analyzer/__init__.py +1 -1
  2. tree_sitter_analyzer/cli/commands/base_command.py +2 -3
  3. tree_sitter_analyzer/cli/commands/default_command.py +18 -18
  4. tree_sitter_analyzer/cli/commands/partial_read_command.py +139 -141
  5. tree_sitter_analyzer/cli/commands/query_command.py +92 -88
  6. tree_sitter_analyzer/cli/commands/table_command.py +235 -235
  7. tree_sitter_analyzer/cli/info_commands.py +121 -121
  8. tree_sitter_analyzer/cli_main.py +307 -303
  9. tree_sitter_analyzer/core/analysis_engine.py +584 -576
  10. tree_sitter_analyzer/core/cache_service.py +6 -5
  11. tree_sitter_analyzer/core/query.py +502 -502
  12. tree_sitter_analyzer/encoding_utils.py +6 -2
  13. tree_sitter_analyzer/exceptions.py +400 -406
  14. tree_sitter_analyzer/formatters/java_formatter.py +291 -291
  15. tree_sitter_analyzer/formatters/python_formatter.py +259 -259
  16. tree_sitter_analyzer/interfaces/cli.py +1 -1
  17. tree_sitter_analyzer/interfaces/cli_adapter.py +3 -3
  18. tree_sitter_analyzer/interfaces/mcp_server.py +426 -425
  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 +1202 -1202
  22. tree_sitter_analyzer/mcp/resources/project_stats_resource.py +559 -555
  23. tree_sitter_analyzer/mcp/server.py +30 -9
  24. tree_sitter_analyzer/mcp/tools/read_partial_tool.py +21 -4
  25. tree_sitter_analyzer/mcp/tools/table_format_tool.py +22 -4
  26. tree_sitter_analyzer/mcp/utils/error_handler.py +569 -567
  27. tree_sitter_analyzer/models.py +470 -470
  28. tree_sitter_analyzer/project_detector.py +330 -317
  29. tree_sitter_analyzer/security/__init__.py +22 -22
  30. tree_sitter_analyzer/security/boundary_manager.py +243 -237
  31. tree_sitter_analyzer/security/regex_checker.py +297 -292
  32. tree_sitter_analyzer/table_formatter.py +703 -652
  33. tree_sitter_analyzer/utils.py +53 -22
  34. {tree_sitter_analyzer-0.9.2.dist-info → tree_sitter_analyzer-0.9.4.dist-info}/METADATA +13 -13
  35. {tree_sitter_analyzer-0.9.2.dist-info → tree_sitter_analyzer-0.9.4.dist-info}/RECORD +37 -37
  36. {tree_sitter_analyzer-0.9.2.dist-info → tree_sitter_analyzer-0.9.4.dist-info}/WHEEL +0 -0
  37. {tree_sitter_analyzer-0.9.2.dist-info → tree_sitter_analyzer-0.9.4.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
- """Table formatter specialized for Java"""
13
-
14
- def _format_full_table(self, data: dict[str, Any]) -> str:
15
- """Full table format for Java"""
16
- lines = []
17
-
18
- # Header - Java (multi-class supported)
19
- classes = data.get("classes", [])
20
- package_name = (data.get("package") or {}).get("name", "unknown")
21
-
22
- if len(classes) > 1:
23
- # If multiple classes exist, use filename
24
- file_name = data.get("file_path", "Unknown").split("/")[-1].split("\\")[-1]
25
- lines.append(f"# {package_name}.{file_name}")
26
- else:
27
- # Single class: use class name
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 (multi-class aware)
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
- # Count methods/fields within the class range
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
- # Single class details
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
- # Trim trailing blank lines
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
- """Compact table format for Java"""
170
- lines = []
171
-
172
- # Header
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
- # Info
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
- # Methods (compact)
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
- # Trim trailing blank lines
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
- """Format a method table row for 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" # default placeholder
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
- """Create compact method signature for 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
- """Shorten type name for Java tables"""
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
+ """Table formatter specialized for Java"""
13
+
14
+ def _format_full_table(self, data: dict[str, Any]) -> str:
15
+ """Full table format for Java"""
16
+ lines = []
17
+
18
+ # Header - Java (multi-class supported)
19
+ classes = data.get("classes", [])
20
+ package_name = (data.get("package") or {}).get("name", "unknown")
21
+
22
+ if len(classes) > 1:
23
+ # If multiple classes exist, use filename
24
+ file_name = data.get("file_path", "Unknown").split("/")[-1].split("\\")[-1]
25
+ lines.append(f"# {package_name}.{file_name}")
26
+ else:
27
+ # Single class: use class name
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 (multi-class aware)
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
+ # Count methods/fields within the class range
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
+ # Single class details
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
+ # Trim trailing blank lines
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
+ """Compact table format for Java"""
170
+ lines = []
171
+
172
+ # Header
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
+ # Info
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
+ # Methods (compact)
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
+ # Trim trailing blank lines
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
+ """Format a method table row for 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" # default placeholder
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
+ """Create compact method signature for 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
+ """Shorten type name for Java tables"""
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)