tree-sitter-analyzer 1.9.17.1__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.
Files changed (149) hide show
  1. tree_sitter_analyzer/__init__.py +132 -0
  2. tree_sitter_analyzer/__main__.py +11 -0
  3. tree_sitter_analyzer/api.py +853 -0
  4. tree_sitter_analyzer/cli/__init__.py +39 -0
  5. tree_sitter_analyzer/cli/__main__.py +12 -0
  6. tree_sitter_analyzer/cli/argument_validator.py +89 -0
  7. tree_sitter_analyzer/cli/commands/__init__.py +26 -0
  8. tree_sitter_analyzer/cli/commands/advanced_command.py +226 -0
  9. tree_sitter_analyzer/cli/commands/base_command.py +181 -0
  10. tree_sitter_analyzer/cli/commands/default_command.py +18 -0
  11. tree_sitter_analyzer/cli/commands/find_and_grep_cli.py +188 -0
  12. tree_sitter_analyzer/cli/commands/list_files_cli.py +133 -0
  13. tree_sitter_analyzer/cli/commands/partial_read_command.py +139 -0
  14. tree_sitter_analyzer/cli/commands/query_command.py +109 -0
  15. tree_sitter_analyzer/cli/commands/search_content_cli.py +161 -0
  16. tree_sitter_analyzer/cli/commands/structure_command.py +156 -0
  17. tree_sitter_analyzer/cli/commands/summary_command.py +116 -0
  18. tree_sitter_analyzer/cli/commands/table_command.py +414 -0
  19. tree_sitter_analyzer/cli/info_commands.py +124 -0
  20. tree_sitter_analyzer/cli_main.py +472 -0
  21. tree_sitter_analyzer/constants.py +85 -0
  22. tree_sitter_analyzer/core/__init__.py +15 -0
  23. tree_sitter_analyzer/core/analysis_engine.py +580 -0
  24. tree_sitter_analyzer/core/cache_service.py +333 -0
  25. tree_sitter_analyzer/core/engine.py +585 -0
  26. tree_sitter_analyzer/core/parser.py +293 -0
  27. tree_sitter_analyzer/core/query.py +605 -0
  28. tree_sitter_analyzer/core/query_filter.py +200 -0
  29. tree_sitter_analyzer/core/query_service.py +340 -0
  30. tree_sitter_analyzer/encoding_utils.py +530 -0
  31. tree_sitter_analyzer/exceptions.py +747 -0
  32. tree_sitter_analyzer/file_handler.py +246 -0
  33. tree_sitter_analyzer/formatters/__init__.py +1 -0
  34. tree_sitter_analyzer/formatters/base_formatter.py +201 -0
  35. tree_sitter_analyzer/formatters/csharp_formatter.py +367 -0
  36. tree_sitter_analyzer/formatters/formatter_config.py +197 -0
  37. tree_sitter_analyzer/formatters/formatter_factory.py +84 -0
  38. tree_sitter_analyzer/formatters/formatter_registry.py +377 -0
  39. tree_sitter_analyzer/formatters/formatter_selector.py +96 -0
  40. tree_sitter_analyzer/formatters/go_formatter.py +368 -0
  41. tree_sitter_analyzer/formatters/html_formatter.py +498 -0
  42. tree_sitter_analyzer/formatters/java_formatter.py +423 -0
  43. tree_sitter_analyzer/formatters/javascript_formatter.py +611 -0
  44. tree_sitter_analyzer/formatters/kotlin_formatter.py +268 -0
  45. tree_sitter_analyzer/formatters/language_formatter_factory.py +123 -0
  46. tree_sitter_analyzer/formatters/legacy_formatter_adapters.py +228 -0
  47. tree_sitter_analyzer/formatters/markdown_formatter.py +725 -0
  48. tree_sitter_analyzer/formatters/php_formatter.py +301 -0
  49. tree_sitter_analyzer/formatters/python_formatter.py +830 -0
  50. tree_sitter_analyzer/formatters/ruby_formatter.py +278 -0
  51. tree_sitter_analyzer/formatters/rust_formatter.py +233 -0
  52. tree_sitter_analyzer/formatters/sql_formatter_wrapper.py +689 -0
  53. tree_sitter_analyzer/formatters/sql_formatters.py +536 -0
  54. tree_sitter_analyzer/formatters/typescript_formatter.py +543 -0
  55. tree_sitter_analyzer/formatters/yaml_formatter.py +462 -0
  56. tree_sitter_analyzer/interfaces/__init__.py +9 -0
  57. tree_sitter_analyzer/interfaces/cli.py +535 -0
  58. tree_sitter_analyzer/interfaces/cli_adapter.py +359 -0
  59. tree_sitter_analyzer/interfaces/mcp_adapter.py +224 -0
  60. tree_sitter_analyzer/interfaces/mcp_server.py +428 -0
  61. tree_sitter_analyzer/language_detector.py +553 -0
  62. tree_sitter_analyzer/language_loader.py +271 -0
  63. tree_sitter_analyzer/languages/__init__.py +10 -0
  64. tree_sitter_analyzer/languages/csharp_plugin.py +1076 -0
  65. tree_sitter_analyzer/languages/css_plugin.py +449 -0
  66. tree_sitter_analyzer/languages/go_plugin.py +836 -0
  67. tree_sitter_analyzer/languages/html_plugin.py +496 -0
  68. tree_sitter_analyzer/languages/java_plugin.py +1299 -0
  69. tree_sitter_analyzer/languages/javascript_plugin.py +1622 -0
  70. tree_sitter_analyzer/languages/kotlin_plugin.py +656 -0
  71. tree_sitter_analyzer/languages/markdown_plugin.py +1928 -0
  72. tree_sitter_analyzer/languages/php_plugin.py +862 -0
  73. tree_sitter_analyzer/languages/python_plugin.py +1636 -0
  74. tree_sitter_analyzer/languages/ruby_plugin.py +757 -0
  75. tree_sitter_analyzer/languages/rust_plugin.py +673 -0
  76. tree_sitter_analyzer/languages/sql_plugin.py +2444 -0
  77. tree_sitter_analyzer/languages/typescript_plugin.py +1892 -0
  78. tree_sitter_analyzer/languages/yaml_plugin.py +695 -0
  79. tree_sitter_analyzer/legacy_table_formatter.py +860 -0
  80. tree_sitter_analyzer/mcp/__init__.py +34 -0
  81. tree_sitter_analyzer/mcp/resources/__init__.py +43 -0
  82. tree_sitter_analyzer/mcp/resources/code_file_resource.py +208 -0
  83. tree_sitter_analyzer/mcp/resources/project_stats_resource.py +586 -0
  84. tree_sitter_analyzer/mcp/server.py +869 -0
  85. tree_sitter_analyzer/mcp/tools/__init__.py +28 -0
  86. tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +779 -0
  87. tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py +291 -0
  88. tree_sitter_analyzer/mcp/tools/base_tool.py +139 -0
  89. tree_sitter_analyzer/mcp/tools/fd_rg_utils.py +816 -0
  90. tree_sitter_analyzer/mcp/tools/find_and_grep_tool.py +686 -0
  91. tree_sitter_analyzer/mcp/tools/list_files_tool.py +413 -0
  92. tree_sitter_analyzer/mcp/tools/output_format_validator.py +148 -0
  93. tree_sitter_analyzer/mcp/tools/query_tool.py +443 -0
  94. tree_sitter_analyzer/mcp/tools/read_partial_tool.py +464 -0
  95. tree_sitter_analyzer/mcp/tools/search_content_tool.py +836 -0
  96. tree_sitter_analyzer/mcp/tools/table_format_tool.py +572 -0
  97. tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py +653 -0
  98. tree_sitter_analyzer/mcp/utils/__init__.py +113 -0
  99. tree_sitter_analyzer/mcp/utils/error_handler.py +569 -0
  100. tree_sitter_analyzer/mcp/utils/file_output_factory.py +217 -0
  101. tree_sitter_analyzer/mcp/utils/file_output_manager.py +322 -0
  102. tree_sitter_analyzer/mcp/utils/gitignore_detector.py +358 -0
  103. tree_sitter_analyzer/mcp/utils/path_resolver.py +414 -0
  104. tree_sitter_analyzer/mcp/utils/search_cache.py +343 -0
  105. tree_sitter_analyzer/models.py +840 -0
  106. tree_sitter_analyzer/mypy_current_errors.txt +2 -0
  107. tree_sitter_analyzer/output_manager.py +255 -0
  108. tree_sitter_analyzer/platform_compat/__init__.py +3 -0
  109. tree_sitter_analyzer/platform_compat/adapter.py +324 -0
  110. tree_sitter_analyzer/platform_compat/compare.py +224 -0
  111. tree_sitter_analyzer/platform_compat/detector.py +67 -0
  112. tree_sitter_analyzer/platform_compat/fixtures.py +228 -0
  113. tree_sitter_analyzer/platform_compat/profiles.py +217 -0
  114. tree_sitter_analyzer/platform_compat/record.py +55 -0
  115. tree_sitter_analyzer/platform_compat/recorder.py +155 -0
  116. tree_sitter_analyzer/platform_compat/report.py +92 -0
  117. tree_sitter_analyzer/plugins/__init__.py +280 -0
  118. tree_sitter_analyzer/plugins/base.py +647 -0
  119. tree_sitter_analyzer/plugins/manager.py +384 -0
  120. tree_sitter_analyzer/project_detector.py +328 -0
  121. tree_sitter_analyzer/queries/__init__.py +27 -0
  122. tree_sitter_analyzer/queries/csharp.py +216 -0
  123. tree_sitter_analyzer/queries/css.py +615 -0
  124. tree_sitter_analyzer/queries/go.py +275 -0
  125. tree_sitter_analyzer/queries/html.py +543 -0
  126. tree_sitter_analyzer/queries/java.py +402 -0
  127. tree_sitter_analyzer/queries/javascript.py +724 -0
  128. tree_sitter_analyzer/queries/kotlin.py +192 -0
  129. tree_sitter_analyzer/queries/markdown.py +258 -0
  130. tree_sitter_analyzer/queries/php.py +95 -0
  131. tree_sitter_analyzer/queries/python.py +859 -0
  132. tree_sitter_analyzer/queries/ruby.py +92 -0
  133. tree_sitter_analyzer/queries/rust.py +223 -0
  134. tree_sitter_analyzer/queries/sql.py +555 -0
  135. tree_sitter_analyzer/queries/typescript.py +871 -0
  136. tree_sitter_analyzer/queries/yaml.py +236 -0
  137. tree_sitter_analyzer/query_loader.py +272 -0
  138. tree_sitter_analyzer/security/__init__.py +22 -0
  139. tree_sitter_analyzer/security/boundary_manager.py +277 -0
  140. tree_sitter_analyzer/security/regex_checker.py +297 -0
  141. tree_sitter_analyzer/security/validator.py +599 -0
  142. tree_sitter_analyzer/table_formatter.py +782 -0
  143. tree_sitter_analyzer/utils/__init__.py +53 -0
  144. tree_sitter_analyzer/utils/logging.py +433 -0
  145. tree_sitter_analyzer/utils/tree_sitter_compat.py +289 -0
  146. tree_sitter_analyzer-1.9.17.1.dist-info/METADATA +485 -0
  147. tree_sitter_analyzer-1.9.17.1.dist-info/RECORD +149 -0
  148. tree_sitter_analyzer-1.9.17.1.dist-info/WHEEL +4 -0
  149. tree_sitter_analyzer-1.9.17.1.dist-info/entry_points.txt +25 -0
@@ -0,0 +1,368 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Go-specific table formatter.
4
+
5
+ Uses Go-specific terminology:
6
+ - package (not module)
7
+ - func (not function/method)
8
+ - struct (not class)
9
+ - interface
10
+ - receiver (for methods)
11
+ - goroutine, channel, defer
12
+ """
13
+
14
+ from typing import Any
15
+
16
+ from .base_formatter import BaseTableFormatter
17
+
18
+
19
+ class GoTableFormatter(BaseTableFormatter):
20
+ """Table formatter specialized for Go"""
21
+
22
+ def _format_full_table(self, data: dict[str, Any]) -> str:
23
+ """Full table format for Go"""
24
+ lines = []
25
+
26
+ # Header - Package name
27
+ package_name = self._get_package_name(data)
28
+ file_name = data.get("file_path", "Unknown").split("/")[-1].split("\\")[-1]
29
+
30
+ if package_name:
31
+ lines.append(f"# {package_name}/{file_name}")
32
+ else:
33
+ lines.append(f"# {file_name}")
34
+ lines.append("")
35
+
36
+ # Package Info
37
+ lines.append("## Package Info")
38
+ lines.append("| Property | Value |")
39
+ lines.append("|----------|-------|")
40
+ lines.append(f"| Package | {package_name or 'main'} |")
41
+
42
+ stats = data.get("statistics") or {}
43
+ lines.append(f"| Functions | {stats.get('function_count', 0)} |")
44
+ lines.append(f"| Types | {stats.get('class_count', 0)} |")
45
+ lines.append(f"| Variables | {stats.get('variable_count', 0)} |")
46
+ lines.append("")
47
+
48
+ # Imports
49
+ imports = data.get("imports", [])
50
+ if imports:
51
+ lines.append("## Imports")
52
+ lines.append("```go")
53
+ for imp in imports:
54
+ stmt = imp.get("import_statement", "") or imp.get("raw_text", "")
55
+ if stmt:
56
+ # Clean up the import statement
57
+ stmt = stmt.strip()
58
+ if not stmt.startswith("import"):
59
+ stmt = f'import "{stmt}"'
60
+ lines.append(stmt)
61
+ lines.append("```")
62
+ lines.append("")
63
+
64
+ # Types (Structs, Interfaces, Type Aliases)
65
+ classes = data.get("classes", [])
66
+ structs = [c for c in classes if c.get("type") == "struct"]
67
+ interfaces = [c for c in classes if c.get("type") == "interface"]
68
+ type_aliases = [c for c in classes if c.get("type") == "type_alias"]
69
+
70
+ if structs:
71
+ lines.append("## Structs")
72
+ lines.append("| Name | Visibility | Lines | Embedded | Doc |")
73
+ lines.append("|------|------------|-------|----------|-----|")
74
+ for s in structs:
75
+ name = s.get("name", "")
76
+ vis = self._go_visibility(name)
77
+ line_range = s.get("line_range", {})
78
+ lines_str = f"{line_range.get('start', 0)}-{line_range.get('end', 0)}"
79
+ embedded = ", ".join(s.get("interfaces", []) or [])
80
+ doc = self._extract_doc_summary(s.get("docstring", "") or "")
81
+ lines.append(
82
+ f"| {name} | {vis} | {lines_str} | {embedded or '-'} | {doc or '-'} |"
83
+ )
84
+ lines.append("")
85
+
86
+ if interfaces:
87
+ lines.append("## Interfaces")
88
+ lines.append("| Name | Visibility | Lines | Doc |")
89
+ lines.append("|------|------------|-------|-----|")
90
+ for i in interfaces:
91
+ name = i.get("name", "")
92
+ vis = self._go_visibility(name)
93
+ line_range = i.get("line_range", {})
94
+ lines_str = f"{line_range.get('start', 0)}-{line_range.get('end', 0)}"
95
+ doc = self._extract_doc_summary(i.get("docstring", "") or "")
96
+ lines.append(f"| {name} | {vis} | {lines_str} | {doc or '-'} |")
97
+ lines.append("")
98
+
99
+ if type_aliases:
100
+ lines.append("## Type Aliases")
101
+ lines.append("| Name | Visibility | Lines |")
102
+ lines.append("|------|------------|-------|")
103
+ for t in type_aliases:
104
+ name = t.get("name", "")
105
+ vis = self._go_visibility(name)
106
+ line_range = t.get("line_range", {})
107
+ lines_str = f"{line_range.get('start', 0)}-{line_range.get('end', 0)}"
108
+ lines.append(f"| {name} | {vis} | {lines_str} |")
109
+ lines.append("")
110
+
111
+ # Functions (non-methods)
112
+ functions = data.get("functions", []) or data.get("methods", [])
113
+ funcs = [
114
+ f
115
+ for f in functions
116
+ if not getattr(f, "is_method", False) and not f.get("is_method", False)
117
+ ]
118
+ methods = [
119
+ f
120
+ for f in functions
121
+ if getattr(f, "is_method", False) or f.get("is_method", False)
122
+ ]
123
+
124
+ if funcs:
125
+ lines.append("## Functions")
126
+ lines.append("| Func | Signature | Vis | Lines | Doc |")
127
+ lines.append("|------|-----------|-----|-------|-----|")
128
+ for func in funcs:
129
+ lines.append(self._format_func_row(func))
130
+ lines.append("")
131
+
132
+ # Methods (with receiver)
133
+ if methods:
134
+ lines.append("## Methods")
135
+ lines.append("| Receiver | Func | Signature | Vis | Lines | Doc |")
136
+ lines.append("|----------|------|-----------|-----|-------|-----|")
137
+ for method in methods:
138
+ lines.append(self._format_method_row(method))
139
+ lines.append("")
140
+
141
+ # Constants
142
+ variables = data.get("variables", []) or data.get("fields", [])
143
+ consts = [v for v in variables if v.get("is_constant", False)]
144
+ vars_list = [v for v in variables if not v.get("is_constant", False)]
145
+
146
+ if consts:
147
+ lines.append("## Constants")
148
+ lines.append("| Name | Type | Vis | Line |")
149
+ lines.append("|------|------|-----|------|")
150
+ for c in consts:
151
+ name = c.get("name", "")
152
+ var_type = c.get("variable_type", "") or c.get("type", "") or "-"
153
+ vis = self._go_visibility(name)
154
+ line = c.get("line_range", {}).get("start", 0)
155
+ lines.append(f"| {name} | {var_type} | {vis} | {line} |")
156
+ lines.append("")
157
+
158
+ if vars_list:
159
+ lines.append("## Variables")
160
+ lines.append("| Name | Type | Vis | Line |")
161
+ lines.append("|------|------|-----|------|")
162
+ for v in vars_list:
163
+ name = v.get("name", "")
164
+ var_type = v.get("variable_type", "") or v.get("type", "") or "-"
165
+ vis = self._go_visibility(name)
166
+ line = v.get("line_range", {}).get("start", 0)
167
+ lines.append(f"| {name} | {var_type} | {vis} | {line} |")
168
+ lines.append("")
169
+
170
+ # Trim trailing blank lines
171
+ while lines and lines[-1] == "":
172
+ lines.pop()
173
+
174
+ return "\n".join(lines)
175
+
176
+ def _format_compact_table(self, data: dict[str, Any]) -> str:
177
+ """Compact table format for Go"""
178
+ lines = []
179
+
180
+ # Header
181
+ package_name = self._get_package_name(data)
182
+ file_name = data.get("file_path", "Unknown").split("/")[-1].split("\\")[-1]
183
+
184
+ if package_name:
185
+ lines.append(f"# {package_name}/{file_name}")
186
+ else:
187
+ lines.append(f"# {file_name}")
188
+ lines.append("")
189
+
190
+ # Info
191
+ stats = data.get("statistics") or {}
192
+ lines.append("## Info")
193
+ lines.append("| Property | Value |")
194
+ lines.append("|----------|-------|")
195
+ lines.append(f"| Package | {package_name or 'main'} |")
196
+ lines.append(f"| Funcs | {stats.get('function_count', 0)} |")
197
+ lines.append(f"| Types | {stats.get('class_count', 0)} |")
198
+ lines.append("")
199
+
200
+ # Functions (compact)
201
+ functions = data.get("functions", []) or data.get("methods", [])
202
+ if functions:
203
+ lines.append("## Funcs")
204
+ lines.append("| Func | Sig | V | L | Doc |")
205
+ lines.append("|------|-----|---|---|-----|")
206
+ for func in functions:
207
+ name = func.get("name", "")
208
+ sig = self._create_go_compact_signature(func)
209
+ vis = "E" if self._go_visibility(name) == "exported" else "u"
210
+ line_range = func.get("line_range", {})
211
+ lines_str = f"{line_range.get('start', 0)}-{line_range.get('end', 0)}"
212
+ doc = self._extract_doc_summary(func.get("docstring", "") or "")[:20]
213
+ lines.append(f"| {name} | {sig} | {vis} | {lines_str} | {doc or '-'} |")
214
+ lines.append("")
215
+
216
+ # Trim trailing blank lines
217
+ while lines and lines[-1] == "":
218
+ lines.pop()
219
+
220
+ return "\n".join(lines)
221
+
222
+ def _format_func_row(self, func: dict[str, Any]) -> str:
223
+ """Format a function table row for Go"""
224
+ name = func.get("name", "")
225
+ sig = self._create_go_signature(func)
226
+ vis = self._go_visibility(name)
227
+ line_range = func.get("line_range", {})
228
+ lines_str = f"{line_range.get('start', 0)}-{line_range.get('end', 0)}"
229
+ doc = self._extract_doc_summary(func.get("docstring", "") or "")
230
+
231
+ return f"| {name} | {sig} | {vis} | {lines_str} | {doc or '-'} |"
232
+
233
+ def _format_method_row(self, method: dict[str, Any]) -> str:
234
+ """Format a method table row for Go (with receiver)"""
235
+ receiver_type = getattr(method, "receiver_type", None) or method.get(
236
+ "receiver_type", "-"
237
+ )
238
+ name = method.get("name", "")
239
+ sig = self._create_go_signature(method)
240
+ vis = self._go_visibility(name)
241
+ line_range = method.get("line_range", {})
242
+ lines_str = f"{line_range.get('start', 0)}-{line_range.get('end', 0)}"
243
+ doc = self._extract_doc_summary(method.get("docstring", "") or "")
244
+
245
+ return (
246
+ f"| {receiver_type} | {name} | {sig} | {vis} | {lines_str} | {doc or '-'} |"
247
+ )
248
+
249
+ def _create_go_signature(self, func: dict[str, Any]) -> str:
250
+ """Create Go function signature"""
251
+ params = func.get("parameters", [])
252
+ if isinstance(params, list):
253
+ params_str = ", ".join(str(p) for p in params)
254
+ else:
255
+ params_str = str(params)
256
+
257
+ return_type = func.get("return_type", "")
258
+ if return_type:
259
+ return f"({params_str}) {return_type}"
260
+ return f"({params_str})"
261
+
262
+ def _create_go_compact_signature(self, func: dict[str, Any]) -> str:
263
+ """Create compact Go function signature"""
264
+ params = func.get("parameters", [])
265
+ param_count = len(params) if isinstance(params, list) else 0
266
+
267
+ return_type = func.get("return_type", "")
268
+ ret = self._shorten_go_type(return_type) if return_type else "-"
269
+
270
+ return f"({param_count}):{ret}"
271
+
272
+ def _shorten_go_type(self, type_name: str) -> str:
273
+ """Shorten Go type name for compact display"""
274
+ if not type_name:
275
+ return "-"
276
+
277
+ type_mapping = {
278
+ "string": "s",
279
+ "int": "i",
280
+ "int64": "i64",
281
+ "int32": "i32",
282
+ "float64": "f64",
283
+ "float32": "f32",
284
+ "bool": "b",
285
+ "error": "err",
286
+ "interface{}": "any",
287
+ "any": "any",
288
+ "[]byte": "[]b",
289
+ "[]string": "[]s",
290
+ }
291
+
292
+ # Handle pointer types
293
+ if type_name.startswith("*"):
294
+ inner = type_name[1:]
295
+ short = type_mapping.get(inner, inner[:3])
296
+ return f"*{short}"
297
+
298
+ # Handle slice types
299
+ if type_name.startswith("[]"):
300
+ inner = type_name[2:]
301
+ short = type_mapping.get(inner, inner[:3])
302
+ return f"[]{short}"
303
+
304
+ return type_mapping.get(
305
+ type_name, type_name[:5] if len(type_name) > 5 else type_name
306
+ )
307
+
308
+ def _go_visibility(self, name: str) -> str:
309
+ """Determine Go visibility based on name capitalization"""
310
+ if name and name[0].isupper():
311
+ return "exported"
312
+ return "unexported"
313
+
314
+ def _get_package_name(self, data: dict[str, Any]) -> str:
315
+ """Extract package name from data"""
316
+ # Try packages list first
317
+ packages = data.get("packages", [])
318
+ if packages and len(packages) > 0:
319
+ return packages[0].get("name", "")
320
+
321
+ # Try package dict
322
+ package = data.get("package", {})
323
+ if isinstance(package, dict):
324
+ return package.get("name", "")
325
+
326
+ return ""
327
+
328
+ def format_table(
329
+ self, analysis_result: dict[str, Any], table_type: str = "full"
330
+ ) -> str:
331
+ """Format table output for Go"""
332
+ original_format_type = self.format_type
333
+ self.format_type = table_type
334
+
335
+ try:
336
+ if table_type == "json":
337
+ return self._format_json(analysis_result)
338
+ return self.format_structure(analysis_result)
339
+ finally:
340
+ self.format_type = original_format_type
341
+
342
+ def format_summary(self, analysis_result: dict[str, Any]) -> str:
343
+ """Format summary output for Go"""
344
+ return self._format_compact_table(analysis_result)
345
+
346
+ def format_structure(self, analysis_result: dict[str, Any]) -> str:
347
+ """Format structure analysis output for Go"""
348
+ return super().format_structure(analysis_result)
349
+
350
+ def format_advanced(
351
+ self, analysis_result: dict[str, Any], output_format: str = "json"
352
+ ) -> str:
353
+ """Format advanced analysis output for Go"""
354
+ if output_format == "json":
355
+ return self._format_json(analysis_result)
356
+ elif output_format == "csv":
357
+ return self._format_csv(analysis_result)
358
+ else:
359
+ return self._format_full_table(analysis_result)
360
+
361
+ def _format_json(self, data: dict[str, Any]) -> str:
362
+ """Format data as JSON"""
363
+ import json
364
+
365
+ try:
366
+ return json.dumps(data, indent=2, ensure_ascii=False)
367
+ except (TypeError, ValueError) as e:
368
+ return f"# JSON serialization error: {e}\n"