tree-sitter-analyzer 0.3.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.
- tree_sitter_analyzer/__init__.py +5 -6
- tree_sitter_analyzer/__main__.py +2 -2
- tree_sitter_analyzer/api.py +4 -2
- tree_sitter_analyzer/cli/__init__.py +3 -3
- tree_sitter_analyzer/cli/commands/advanced_command.py +1 -1
- tree_sitter_analyzer/cli/commands/base_command.py +1 -1
- tree_sitter_analyzer/cli/commands/default_command.py +1 -1
- tree_sitter_analyzer/cli/commands/partial_read_command.py +2 -2
- tree_sitter_analyzer/cli/commands/query_command.py +5 -5
- tree_sitter_analyzer/cli/commands/summary_command.py +2 -2
- tree_sitter_analyzer/cli/commands/table_command.py +14 -11
- tree_sitter_analyzer/cli/info_commands.py +14 -13
- tree_sitter_analyzer/cli_main.py +51 -31
- tree_sitter_analyzer/core/analysis_engine.py +54 -90
- tree_sitter_analyzer/core/cache_service.py +31 -31
- tree_sitter_analyzer/core/engine.py +6 -4
- tree_sitter_analyzer/core/parser.py +1 -1
- tree_sitter_analyzer/core/query.py +502 -494
- tree_sitter_analyzer/encoding_utils.py +3 -2
- tree_sitter_analyzer/exceptions.py +23 -23
- tree_sitter_analyzer/file_handler.py +7 -14
- tree_sitter_analyzer/formatters/base_formatter.py +18 -18
- tree_sitter_analyzer/formatters/formatter_factory.py +15 -15
- tree_sitter_analyzer/formatters/java_formatter.py +291 -287
- tree_sitter_analyzer/formatters/python_formatter.py +259 -255
- tree_sitter_analyzer/interfaces/cli.py +1 -1
- tree_sitter_analyzer/interfaces/cli_adapter.py +62 -41
- tree_sitter_analyzer/interfaces/mcp_adapter.py +43 -17
- tree_sitter_analyzer/interfaces/mcp_server.py +9 -9
- tree_sitter_analyzer/language_detector.py +398 -398
- tree_sitter_analyzer/language_loader.py +224 -224
- tree_sitter_analyzer/languages/java_plugin.py +1174 -1129
- tree_sitter_analyzer/{plugins → languages}/javascript_plugin.py +3 -3
- tree_sitter_analyzer/languages/python_plugin.py +26 -8
- tree_sitter_analyzer/mcp/resources/code_file_resource.py +0 -3
- tree_sitter_analyzer/mcp/resources/project_stats_resource.py +555 -560
- tree_sitter_analyzer/mcp/server.py +4 -4
- tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +63 -30
- tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py +9 -4
- tree_sitter_analyzer/mcp/tools/table_format_tool.py +2 -2
- tree_sitter_analyzer/mcp/utils/__init__.py +10 -8
- tree_sitter_analyzer/models.py +470 -470
- tree_sitter_analyzer/output_manager.py +12 -20
- tree_sitter_analyzer/plugins/__init__.py +9 -62
- tree_sitter_analyzer/plugins/base.py +53 -1
- tree_sitter_analyzer/plugins/manager.py +29 -12
- tree_sitter_analyzer/queries/java.py +78 -78
- tree_sitter_analyzer/queries/javascript.py +7 -7
- tree_sitter_analyzer/queries/python.py +18 -18
- tree_sitter_analyzer/queries/typescript.py +12 -12
- tree_sitter_analyzer/query_loader.py +17 -14
- tree_sitter_analyzer/table_formatter.py +24 -19
- tree_sitter_analyzer/utils.py +7 -7
- {tree_sitter_analyzer-0.3.0.dist-info → tree_sitter_analyzer-0.6.0.dist-info}/METADATA +11 -11
- tree_sitter_analyzer-0.6.0.dist-info/RECORD +72 -0
- {tree_sitter_analyzer-0.3.0.dist-info → tree_sitter_analyzer-0.6.0.dist-info}/entry_points.txt +2 -1
- tree_sitter_analyzer/java_analyzer.py +0 -218
- tree_sitter_analyzer/plugins/java_plugin.py +0 -608
- tree_sitter_analyzer/plugins/plugin_loader.py +0 -85
- tree_sitter_analyzer/plugins/python_plugin.py +0 -606
- tree_sitter_analyzer/plugins/registry.py +0 -374
- tree_sitter_analyzer-0.3.0.dist-info/RECORD +0 -77
- {tree_sitter_analyzer-0.3.0.dist-info → tree_sitter_analyzer-0.6.0.dist-info}/WHEEL +0 -0
|
@@ -106,26 +106,26 @@ COMMENTS = """
|
|
|
106
106
|
ALL_QUERIES = {
|
|
107
107
|
"functions": {
|
|
108
108
|
"query": FUNCTIONS,
|
|
109
|
-
"description": "
|
|
109
|
+
"description": "Search all function declarations, expressions, and methods",
|
|
110
110
|
},
|
|
111
111
|
"classes": {
|
|
112
112
|
"query": CLASSES,
|
|
113
|
-
"description": "
|
|
113
|
+
"description": "Search all class declarations and expressions",
|
|
114
114
|
},
|
|
115
115
|
"variables": {
|
|
116
116
|
"query": VARIABLES,
|
|
117
|
-
"description": "
|
|
117
|
+
"description": "Search all variable declarations (var, let, const)",
|
|
118
118
|
},
|
|
119
119
|
"imports": {
|
|
120
120
|
"query": IMPORTS,
|
|
121
|
-
"description": "
|
|
121
|
+
"description": "Search all import statements and clauses",
|
|
122
122
|
},
|
|
123
|
-
"exports": {"query": EXPORTS, "description": "
|
|
123
|
+
"exports": {"query": EXPORTS, "description": "Search all export statements"},
|
|
124
124
|
"objects": {
|
|
125
125
|
"query": OBJECTS,
|
|
126
|
-
"description": "
|
|
126
|
+
"description": "Search object literals and property definitions",
|
|
127
127
|
},
|
|
128
|
-
"comments": {"query": COMMENTS, "description": "
|
|
128
|
+
"comments": {"query": COMMENTS, "description": "Search all comments"},
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
|
|
@@ -210,58 +210,58 @@ MODERN_PATTERNS = """
|
|
|
210
210
|
ALL_QUERIES = {
|
|
211
211
|
"functions": {
|
|
212
212
|
"query": FUNCTIONS,
|
|
213
|
-
"description": "
|
|
213
|
+
"description": "Search all function definitions (including async)",
|
|
214
214
|
},
|
|
215
|
-
"classes": {"query": CLASSES, "description": "
|
|
216
|
-
"imports": {"query": IMPORTS, "description": "
|
|
217
|
-
"variables": {"query": VARIABLES, "description": "
|
|
218
|
-
"decorators": {"query": DECORATORS, "description": "
|
|
215
|
+
"classes": {"query": CLASSES, "description": "Search all class definitions"},
|
|
216
|
+
"imports": {"query": IMPORTS, "description": "Search all import statements"},
|
|
217
|
+
"variables": {"query": VARIABLES, "description": "Search all variable assignments"},
|
|
218
|
+
"decorators": {"query": DECORATORS, "description": "Search all decorators"},
|
|
219
219
|
"methods": {
|
|
220
220
|
"query": METHODS,
|
|
221
|
-
"description": "
|
|
221
|
+
"description": "Search all method definitions within classes",
|
|
222
222
|
},
|
|
223
223
|
"exceptions": {
|
|
224
224
|
"query": EXCEPTIONS,
|
|
225
|
-
"description": "
|
|
225
|
+
"description": "Search exception handling and raise statements",
|
|
226
226
|
},
|
|
227
227
|
"comprehensions": {
|
|
228
228
|
"query": COMPREHENSIONS,
|
|
229
|
-
"description": "
|
|
229
|
+
"description": "Search list, dictionary, and set comprehensions",
|
|
230
230
|
},
|
|
231
|
-
"comments": {"query": COMMENTS, "description": "
|
|
231
|
+
"comments": {"query": COMMENTS, "description": "Search comments and docstrings"},
|
|
232
232
|
"type_hints": {
|
|
233
233
|
"query": TYPE_HINTS,
|
|
234
|
-
"description": "
|
|
234
|
+
"description": "Search type hints and annotations",
|
|
235
235
|
},
|
|
236
236
|
"async_patterns": {
|
|
237
237
|
"query": ASYNC_PATTERNS,
|
|
238
|
-
"description": "async/await
|
|
238
|
+
"description": "Search async/await patterns",
|
|
239
239
|
},
|
|
240
240
|
"string_formatting": {
|
|
241
241
|
"query": STRING_FORMATTING,
|
|
242
|
-
"description": "f
|
|
242
|
+
"description": "Search f-strings and string formatting",
|
|
243
243
|
},
|
|
244
244
|
"context_managers": {
|
|
245
245
|
"query": CONTEXT_MANAGERS,
|
|
246
|
-
"description": "
|
|
246
|
+
"description": "Search context managers (with statements)",
|
|
247
247
|
},
|
|
248
|
-
"lambdas": {"query": LAMBDAS, "description": "
|
|
248
|
+
"lambdas": {"query": LAMBDAS, "description": "Search lambda expressions"},
|
|
249
249
|
"modern_patterns": {
|
|
250
250
|
"query": MODERN_PATTERNS,
|
|
251
|
-
"description": "
|
|
251
|
+
"description": "Search modern Python patterns (match/case, walrus operator)",
|
|
252
252
|
},
|
|
253
253
|
# Convenience aliases
|
|
254
254
|
"function_names": {
|
|
255
255
|
"query": FUNCTIONS,
|
|
256
|
-
"description": "
|
|
256
|
+
"description": "Function alias - search all function definitions",
|
|
257
257
|
},
|
|
258
258
|
"class_names": {
|
|
259
259
|
"query": CLASSES,
|
|
260
|
-
"description": "
|
|
260
|
+
"description": "Class alias - search all class definitions",
|
|
261
261
|
},
|
|
262
262
|
"all_declarations": {
|
|
263
263
|
"query": FUNCTIONS + "\n\n" + CLASSES + "\n\n" + VARIABLES,
|
|
264
|
-
"description": "
|
|
264
|
+
"description": "Search all function, class, and variable declarations",
|
|
265
265
|
},
|
|
266
266
|
}
|
|
267
267
|
|
|
@@ -173,40 +173,40 @@ COMMENTS = """
|
|
|
173
173
|
ALL_QUERIES = {
|
|
174
174
|
"functions": {
|
|
175
175
|
"query": FUNCTIONS,
|
|
176
|
-
"description": "
|
|
176
|
+
"description": "Search all function declarations, expressions, and methods with type annotations",
|
|
177
177
|
},
|
|
178
178
|
"classes": {
|
|
179
179
|
"query": CLASSES,
|
|
180
|
-
"description": "
|
|
180
|
+
"description": "Search all class declarations including abstract classes",
|
|
181
181
|
},
|
|
182
182
|
"interfaces": {
|
|
183
183
|
"query": INTERFACES,
|
|
184
|
-
"description": "
|
|
184
|
+
"description": "Search all interface declarations",
|
|
185
185
|
},
|
|
186
186
|
"type_aliases": {
|
|
187
187
|
"query": TYPE_ALIASES,
|
|
188
|
-
"description": "
|
|
188
|
+
"description": "Search all type alias declarations",
|
|
189
189
|
},
|
|
190
|
-
"enums": {"query": ENUMS, "description": "
|
|
190
|
+
"enums": {"query": ENUMS, "description": "Search all enum declarations"},
|
|
191
191
|
"variables": {
|
|
192
192
|
"query": VARIABLES,
|
|
193
|
-
"description": "
|
|
193
|
+
"description": "Search all variable declarations with type annotations",
|
|
194
194
|
},
|
|
195
195
|
"imports": {
|
|
196
196
|
"query": IMPORTS,
|
|
197
|
-
"description": "
|
|
197
|
+
"description": "Search all import statements including type imports",
|
|
198
198
|
},
|
|
199
|
-
"exports": {"query": EXPORTS, "description": "
|
|
200
|
-
"decorators": {"query": DECORATORS, "description": "
|
|
199
|
+
"exports": {"query": EXPORTS, "description": "Search all export statements"},
|
|
200
|
+
"decorators": {"query": DECORATORS, "description": "Search all decorators"},
|
|
201
201
|
"generics": {
|
|
202
202
|
"query": GENERICS,
|
|
203
|
-
"description": "
|
|
203
|
+
"description": "Search all generic type parameters",
|
|
204
204
|
},
|
|
205
205
|
"signatures": {
|
|
206
206
|
"query": SIGNATURES,
|
|
207
|
-
"description": "
|
|
207
|
+
"description": "Search property signatures, method signatures, and constructor signatures",
|
|
208
208
|
},
|
|
209
|
-
"comments": {"query": COMMENTS, "description": "
|
|
209
|
+
"comments": {"query": COMMENTS, "description": "Search all comments"},
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
|
|
@@ -33,19 +33,19 @@ class QueryLoader:
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
_QUERY_DESCRIPTIONS: dict[str, str] = {
|
|
36
|
-
"class": "
|
|
37
|
-
"interface": "
|
|
38
|
-
"method": "
|
|
39
|
-
"constructor": "
|
|
40
|
-
"field": "
|
|
41
|
-
"import": "
|
|
42
|
-
"package": "
|
|
43
|
-
"annotation": "
|
|
44
|
-
"method_name": "
|
|
45
|
-
"class_name": "
|
|
46
|
-
"method_invocations": "
|
|
47
|
-
"class_with_body": "
|
|
48
|
-
"method_with_body": "
|
|
36
|
+
"class": "Extract class declarations",
|
|
37
|
+
"interface": "Extract interface declarations",
|
|
38
|
+
"method": "Extract method declarations",
|
|
39
|
+
"constructor": "Extract constructor declarations",
|
|
40
|
+
"field": "Extract field declarations",
|
|
41
|
+
"import": "Extract import statements",
|
|
42
|
+
"package": "Extract package declarations",
|
|
43
|
+
"annotation": "Extract annotations",
|
|
44
|
+
"method_name": "Extract method names only",
|
|
45
|
+
"class_name": "Extract class names only",
|
|
46
|
+
"method_invocations": "Extract method invocations",
|
|
47
|
+
"class_with_body": "Extract class declarations with body",
|
|
48
|
+
"method_with_body": "Extract method declarations with body",
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
def __init__(self) -> None:
|
|
@@ -76,8 +76,11 @@ class QueryLoader:
|
|
|
76
76
|
for attr_name in dir(module):
|
|
77
77
|
if not attr_name.startswith("_"):
|
|
78
78
|
attr_value = getattr(module, attr_name)
|
|
79
|
-
if isinstance(attr_value, str
|
|
79
|
+
if isinstance(attr_value, str):
|
|
80
80
|
queries[attr_name] = attr_value
|
|
81
|
+
elif isinstance(attr_value, dict):
|
|
82
|
+
# Convert dict to string representation for queries
|
|
83
|
+
queries[attr_name] = str(attr_value)
|
|
81
84
|
|
|
82
85
|
self._loaded_queries[language] = queries
|
|
83
86
|
self._query_modules[language] = module
|
|
@@ -61,11 +61,11 @@ class TableFormatter:
|
|
|
61
61
|
if classes is None:
|
|
62
62
|
classes = []
|
|
63
63
|
if len(classes) > 1:
|
|
64
|
-
#
|
|
64
|
+
# Use file name when multiple classes exist
|
|
65
65
|
file_name = data.get("file_path", "Unknown").split("/")[-1].split("\\")[-1]
|
|
66
66
|
lines.append(f"# {file_name}")
|
|
67
67
|
else:
|
|
68
|
-
#
|
|
68
|
+
# Use class name for single class as before
|
|
69
69
|
class_name = classes[0].get("name", "Unknown") if classes else "Unknown"
|
|
70
70
|
lines.append(
|
|
71
71
|
f"# {(data.get('package') or {}).get('name', 'unknown')}.{class_name}"
|
|
@@ -82,7 +82,7 @@ class TableFormatter:
|
|
|
82
82
|
lines.append("```")
|
|
83
83
|
lines.append("")
|
|
84
84
|
|
|
85
|
-
# Class Info -
|
|
85
|
+
# Class Info - Support for multiple classes
|
|
86
86
|
classes = data.get("classes", [])
|
|
87
87
|
if classes is None:
|
|
88
88
|
classes = []
|
|
@@ -98,7 +98,7 @@ class TableFormatter:
|
|
|
98
98
|
line_range = class_info.get("line_range", {})
|
|
99
99
|
lines_str = f"{line_range.get('start', 0)}-{line_range.get('end', 0)}"
|
|
100
100
|
|
|
101
|
-
#
|
|
101
|
+
# Calculate method and field counts for this class
|
|
102
102
|
class_methods = [
|
|
103
103
|
m
|
|
104
104
|
for m in data.get("methods", [])
|
|
@@ -118,7 +118,7 @@ class TableFormatter:
|
|
|
118
118
|
f"| {name} | {class_type} | {visibility} | {lines_str} | {len(class_methods)} | {len(class_fields)} |"
|
|
119
119
|
)
|
|
120
120
|
else:
|
|
121
|
-
#
|
|
121
|
+
# Use traditional format for single class
|
|
122
122
|
lines.append("## Class Info")
|
|
123
123
|
lines.append("| Property | Value |")
|
|
124
124
|
lines.append("|----------|-------|")
|
|
@@ -210,7 +210,7 @@ class TableFormatter:
|
|
|
210
210
|
lines.append(self._format_method_row(method))
|
|
211
211
|
lines.append("")
|
|
212
212
|
|
|
213
|
-
#
|
|
213
|
+
# Remove trailing empty lines
|
|
214
214
|
while lines and lines[-1] == "":
|
|
215
215
|
lines.pop()
|
|
216
216
|
|
|
@@ -229,7 +229,7 @@ class TableFormatter:
|
|
|
229
229
|
lines.append(f"# {package_name}.{class_name}")
|
|
230
230
|
lines.append("")
|
|
231
231
|
|
|
232
|
-
#
|
|
232
|
+
# Basic information
|
|
233
233
|
stats = data.get("statistics") or {}
|
|
234
234
|
lines.append("## Info")
|
|
235
235
|
lines.append("| Property | Value |")
|
|
@@ -239,7 +239,7 @@ class TableFormatter:
|
|
|
239
239
|
lines.append(f"| Fields | {stats.get('field_count', 0)} |")
|
|
240
240
|
lines.append("")
|
|
241
241
|
|
|
242
|
-
#
|
|
242
|
+
# Methods (simplified version)
|
|
243
243
|
methods = data.get("methods", [])
|
|
244
244
|
if methods is None:
|
|
245
245
|
methods = []
|
|
@@ -264,7 +264,7 @@ class TableFormatter:
|
|
|
264
264
|
)
|
|
265
265
|
lines.append("")
|
|
266
266
|
|
|
267
|
-
#
|
|
267
|
+
# Remove trailing empty lines
|
|
268
268
|
while lines and lines[-1] == "":
|
|
269
269
|
lines.pop()
|
|
270
270
|
|
|
@@ -282,7 +282,7 @@ class TableFormatter:
|
|
|
282
282
|
["Type", "Name", "Signature", "Visibility", "Lines", "Complexity", "Doc"]
|
|
283
283
|
)
|
|
284
284
|
|
|
285
|
-
#
|
|
285
|
+
# Fields
|
|
286
286
|
for field in data.get("fields", []):
|
|
287
287
|
writer.writerow(
|
|
288
288
|
[
|
|
@@ -298,7 +298,7 @@ class TableFormatter:
|
|
|
298
298
|
]
|
|
299
299
|
)
|
|
300
300
|
|
|
301
|
-
#
|
|
301
|
+
# Methods
|
|
302
302
|
for method in data.get("methods", []):
|
|
303
303
|
writer.writerow(
|
|
304
304
|
[
|
|
@@ -324,13 +324,15 @@ class TableFormatter:
|
|
|
324
324
|
return csv_content
|
|
325
325
|
|
|
326
326
|
def _format_method_row(self, method: dict[str, Any]) -> str:
|
|
327
|
-
"""
|
|
327
|
+
"""Format method row"""
|
|
328
328
|
name = str(method.get("name", ""))
|
|
329
329
|
signature = self._create_full_signature(method)
|
|
330
330
|
visibility = self._convert_visibility(str(method.get("visibility", "")))
|
|
331
331
|
line_range = method.get("line_range", {})
|
|
332
332
|
lines_str = f"{line_range.get('start', 0)}-{line_range.get('end', 0)}"
|
|
333
|
-
cols_str =
|
|
333
|
+
cols_str = (
|
|
334
|
+
"5-6" # Default value (actual implementation should get accurate values)
|
|
335
|
+
)
|
|
334
336
|
complexity = method.get("complexity_score", 0)
|
|
335
337
|
if self.include_javadoc:
|
|
336
338
|
doc = self._clean_csv_text(
|
|
@@ -342,7 +344,7 @@ class TableFormatter:
|
|
|
342
344
|
return f"| {name} | {signature} | {visibility} | {lines_str} | {cols_str} | {complexity} | {doc} |"
|
|
343
345
|
|
|
344
346
|
def _create_full_signature(self, method: dict[str, Any]) -> str:
|
|
345
|
-
"""
|
|
347
|
+
"""Create complete method signature"""
|
|
346
348
|
params = method.get("parameters", [])
|
|
347
349
|
param_strs = []
|
|
348
350
|
for param in params:
|
|
@@ -366,7 +368,7 @@ class TableFormatter:
|
|
|
366
368
|
return signature
|
|
367
369
|
|
|
368
370
|
def _create_compact_signature(self, method: dict[str, Any]) -> str:
|
|
369
|
-
"""
|
|
371
|
+
"""Create compact method signature"""
|
|
370
372
|
params = method.get("parameters", [])
|
|
371
373
|
param_types = [self._shorten_type(p.get("type", "O")) for p in params]
|
|
372
374
|
params_str = ",".join(param_types)
|
|
@@ -375,7 +377,7 @@ class TableFormatter:
|
|
|
375
377
|
return f"({params_str}):{return_type}"
|
|
376
378
|
|
|
377
379
|
def _shorten_type(self, type_name: Any) -> str:
|
|
378
|
-
"""
|
|
380
|
+
"""Shorten type name"""
|
|
379
381
|
if type_name is None:
|
|
380
382
|
return "O"
|
|
381
383
|
|
|
@@ -383,6 +385,9 @@ class TableFormatter:
|
|
|
383
385
|
if not isinstance(type_name, str):
|
|
384
386
|
type_name = str(type_name)
|
|
385
387
|
|
|
388
|
+
# At this point, type_name is guaranteed to be a string
|
|
389
|
+
assert isinstance(type_name, str)
|
|
390
|
+
|
|
386
391
|
type_mapping = {
|
|
387
392
|
"String": "S",
|
|
388
393
|
"int": "i",
|
|
@@ -420,12 +425,12 @@ class TableFormatter:
|
|
|
420
425
|
return type_mapping.get(type_name, type_name)
|
|
421
426
|
|
|
422
427
|
def _convert_visibility(self, visibility: str) -> str:
|
|
423
|
-
"""
|
|
428
|
+
"""Convert visibility to symbol"""
|
|
424
429
|
mapping = {"public": "+", "private": "-", "protected": "#", "package": "~"}
|
|
425
430
|
return mapping.get(visibility, visibility)
|
|
426
431
|
|
|
427
432
|
def _extract_doc_summary(self, javadoc: str) -> str:
|
|
428
|
-
"""JavaDoc
|
|
433
|
+
"""Extract summary from JavaDoc"""
|
|
429
434
|
if not javadoc:
|
|
430
435
|
return "-"
|
|
431
436
|
|
|
@@ -462,7 +467,7 @@ class TableFormatter:
|
|
|
462
467
|
|
|
463
468
|
def create_table_formatter(
|
|
464
469
|
format_type: str, language: str = "java", include_javadoc: bool = False
|
|
465
|
-
):
|
|
470
|
+
) -> "TableFormatter":
|
|
466
471
|
"""Create table formatter (using new factory)"""
|
|
467
472
|
# Create TableFormatter directly (for JavaDoc support)
|
|
468
473
|
return TableFormatter(format_type, language, include_javadoc)
|
tree_sitter_analyzer/utils.py
CHANGED
|
@@ -19,7 +19,7 @@ def setup_logger(
|
|
|
19
19
|
"""Setup unified logger for the project"""
|
|
20
20
|
import os
|
|
21
21
|
|
|
22
|
-
#
|
|
22
|
+
# Get log level from environment variable
|
|
23
23
|
env_level = os.environ.get("LOG_LEVEL", "").upper()
|
|
24
24
|
if env_level == "DEBUG":
|
|
25
25
|
level = logging.DEBUG
|
|
@@ -50,7 +50,7 @@ class SafeStreamHandler(logging.StreamHandler):
|
|
|
50
50
|
A StreamHandler that safely handles closed streams
|
|
51
51
|
"""
|
|
52
52
|
|
|
53
|
-
def emit(self, record):
|
|
53
|
+
def emit(self, record: Any) -> None:
|
|
54
54
|
"""
|
|
55
55
|
Emit a record, safely handling closed streams
|
|
56
56
|
"""
|
|
@@ -72,12 +72,12 @@ class SafeStreamHandler(logging.StreamHandler):
|
|
|
72
72
|
self.handleError(record)
|
|
73
73
|
|
|
74
74
|
|
|
75
|
-
def setup_safe_logging_shutdown():
|
|
75
|
+
def setup_safe_logging_shutdown() -> None:
|
|
76
76
|
"""
|
|
77
77
|
Setup safe logging shutdown to prevent I/O errors
|
|
78
78
|
"""
|
|
79
79
|
|
|
80
|
-
def cleanup_logging():
|
|
80
|
+
def cleanup_logging() -> None:
|
|
81
81
|
"""Clean up logging handlers safely"""
|
|
82
82
|
try:
|
|
83
83
|
# Get all loggers
|
|
@@ -178,7 +178,7 @@ class QuietMode:
|
|
|
178
178
|
if self.enabled:
|
|
179
179
|
self.old_level = logger.level
|
|
180
180
|
logger.setLevel(logging.ERROR)
|
|
181
|
-
return self
|
|
181
|
+
return self
|
|
182
182
|
|
|
183
183
|
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
|
|
184
184
|
if self.enabled and self.old_level is not None:
|
|
@@ -222,7 +222,7 @@ perf_logger = create_performance_logger("tree_sitter_analyzer")
|
|
|
222
222
|
def log_performance(
|
|
223
223
|
operation: str,
|
|
224
224
|
execution_time: float | None = None,
|
|
225
|
-
details: dict | None = None,
|
|
225
|
+
details: dict[Any, Any] | str | None = None,
|
|
226
226
|
) -> None:
|
|
227
227
|
"""Log performance metrics"""
|
|
228
228
|
try:
|
|
@@ -270,7 +270,7 @@ class LoggingContext:
|
|
|
270
270
|
if self.enabled and self.level is not None:
|
|
271
271
|
self.old_level = self.target_logger.level
|
|
272
272
|
self.target_logger.setLevel(self.level)
|
|
273
|
-
return self
|
|
273
|
+
return self
|
|
274
274
|
|
|
275
275
|
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
|
|
276
276
|
if self.enabled and self.old_level is not None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tree-sitter-analyzer
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Extensible multi-language code analyzer framework using Tree-sitter with dynamic plugin architecture
|
|
5
5
|
Project-URL: Homepage, https://github.com/aimasteracc/tree-sitter-analyzer
|
|
6
6
|
Project-URL: Documentation, https://github.com/aimasteracc/tree-sitter-analyzer#readme
|
|
@@ -35,7 +35,7 @@ Requires-Dist: cachetools>=5.0.0
|
|
|
35
35
|
Requires-Dist: chardet>=5.0.0
|
|
36
36
|
Requires-Dist: tree-sitter-cpp>=0.23.4
|
|
37
37
|
Requires-Dist: tree-sitter-java>=0.23.5
|
|
38
|
-
Requires-Dist: tree-sitter
|
|
38
|
+
Requires-Dist: tree-sitter==0.24.0
|
|
39
39
|
Provides-Extra: all-languages
|
|
40
40
|
Requires-Dist: tree-sitter-c>=0.20.0; extra == 'all-languages'
|
|
41
41
|
Requires-Dist: tree-sitter-cpp>=0.23.4; extra == 'all-languages'
|
|
@@ -134,7 +134,7 @@ Description-Content-Type: text/markdown
|
|
|
134
134
|
|
|
135
135
|
[](https://python.org)
|
|
136
136
|
[](LICENSE)
|
|
137
|
-
[](#testing)
|
|
138
138
|
|
|
139
139
|
**Solve the LLM token limit problem for large code files.**
|
|
140
140
|
|
|
@@ -294,21 +294,21 @@ uv add "tree-sitter-analyzer[all,mcp]"
|
|
|
294
294
|
### For Developers
|
|
295
295
|
```bash
|
|
296
296
|
# Clone and install for development
|
|
297
|
-
git clone https://github.com/
|
|
297
|
+
git clone https://github.com/aisheng-yu/tree-sitter-analyzer.git
|
|
298
298
|
cd tree-sitter-analyzer
|
|
299
299
|
uv sync --extra all --extra mcp
|
|
300
300
|
```
|
|
301
301
|
|
|
302
302
|
## 📚 Documentation
|
|
303
303
|
|
|
304
|
-
- **[MCP Setup Guide for Users](MCP_SETUP_USERS.md)** - Simple setup for AI assistant users
|
|
305
|
-
- **[MCP Setup Guide for Developers](MCP_SETUP_DEVELOPERS.md)** - Local development configuration
|
|
306
|
-
- **[API Documentation](docs/api.md)** - Detailed API reference
|
|
307
|
-
- **[Contributing Guide](CONTRIBUTING.md)** - How to contribute
|
|
304
|
+
- **[MCP Setup Guide for Users](https://github.com/aisheng-yu/tree-sitter-analyzer/blob/main/MCP_SETUP_USERS.md)** - Simple setup for AI assistant users
|
|
305
|
+
- **[MCP Setup Guide for Developers](https://github.com/aisheng-yu/tree-sitter-analyzer/blob/main/MCP_SETUP_DEVELOPERS.md)** - Local development configuration
|
|
306
|
+
- **[API Documentation](https://github.com/aisheng-yu/tree-sitter-analyzer/blob/main/docs/api.md)** - Detailed API reference
|
|
307
|
+
- **[Contributing Guide](https://github.com/aisheng-yu/tree-sitter-analyzer/blob/main/CONTRIBUTING.md)** - How to contribute
|
|
308
308
|
|
|
309
309
|
## 🧪 Testing
|
|
310
310
|
|
|
311
|
-
This project maintains high code quality with **
|
|
311
|
+
This project maintains high code quality with **1126 passing tests**.
|
|
312
312
|
|
|
313
313
|
```bash
|
|
314
314
|
# Run tests
|
|
@@ -324,7 +324,7 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
324
324
|
|
|
325
325
|
## 🤝 Contributing
|
|
326
326
|
|
|
327
|
-
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
327
|
+
We welcome contributions! Please see our [Contributing Guide](https://github.com/aisheng-yu/tree-sitter-analyzer/blob/main/CONTRIBUTING.md) for details.
|
|
328
328
|
|
|
329
329
|
### 🤖 AI/LLM Collaboration
|
|
330
330
|
|
|
@@ -339,7 +339,7 @@ python llm_code_checker.py --check-all
|
|
|
339
339
|
python llm_code_checker.py path/to/new_file.py
|
|
340
340
|
```
|
|
341
341
|
|
|
342
|
-
📖 **See our [AI Collaboration Guide](AI_COLLABORATION_GUIDE.md) and [LLM Coding Guidelines](LLM_CODING_GUIDELINES.md) for detailed instructions on working with AI systems.**
|
|
342
|
+
📖 **See our [AI Collaboration Guide](https://github.com/aisheng-yu/tree-sitter-analyzer/blob/main/AI_COLLABORATION_GUIDE.md) and [LLM Coding Guidelines](https://github.com/aisheng-yu/tree-sitter-analyzer/blob/main/LLM_CODING_GUIDELINES.md) for detailed instructions on working with AI systems.**
|
|
343
343
|
|
|
344
344
|
---
|
|
345
345
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
tree_sitter_analyzer/__init__.py,sha256=s-D-sjxwExZ3p9ur1f9_ueeAQDmAJ5HtTxHiHKOw4XM,3067
|
|
2
|
+
tree_sitter_analyzer/__main__.py,sha256=Zl79tpe4UaMu-7yeztc06tgP0CVMRnvGgas4ZQP5SCs,228
|
|
3
|
+
tree_sitter_analyzer/api.py,sha256=naRtGuZ27AIVfn6Rid0zQcHDI71UpO9Nh4NQM9JyD3c,16954
|
|
4
|
+
tree_sitter_analyzer/cli_main.py,sha256=YgAymgIYTcJrdyEOwsZmTW_iiyF3LmpEmE6Iy0GTwdA,9284
|
|
5
|
+
tree_sitter_analyzer/encoding_utils.py,sha256=ItN5dKfuGY9xqvUVQIRYjOrb3fZ_8_CEMQMQ31sScvc,14479
|
|
6
|
+
tree_sitter_analyzer/exceptions.py,sha256=PxQzmkwbaK_8JneWNniKNgBIjOwrOW-yYbj5pmQgvRs,9772
|
|
7
|
+
tree_sitter_analyzer/file_handler.py,sha256=MnbK3aMk6tzB-sjF2U58YHbqqijvecNQqql16K-IM5s,6894
|
|
8
|
+
tree_sitter_analyzer/language_detector.py,sha256=IjkYF1E7_TtWlwYjz780ZUJAyPltL2aZVzo-doTbAug,12540
|
|
9
|
+
tree_sitter_analyzer/language_loader.py,sha256=gdLxkSoajm-q7c1vcvFONtBf5XJRgasUVI4L0wMzra0,8124
|
|
10
|
+
tree_sitter_analyzer/models.py,sha256=z0aqdZOVA8rYWF0143TSAUoCvncVRLZ1O70eAjV87gU,16564
|
|
11
|
+
tree_sitter_analyzer/output_manager.py,sha256=saZ8Ss6PhUJgjjwviLgrePFL7CCLMixxdKtdrpuFgHM,8146
|
|
12
|
+
tree_sitter_analyzer/query_loader.py,sha256=jcJc6_kIMeZINfTVGuiEmDii9LViP_pbJfg4A9phJY4,9863
|
|
13
|
+
tree_sitter_analyzer/table_formatter.py,sha256=NS8nPrgi_tjlqksRXtoPCv6NAUD4scNPH_-MQAIdU1s,17798
|
|
14
|
+
tree_sitter_analyzer/utils.py,sha256=AarFoPxiU20y8U8ysy8G6JWK-XLMP3tUoySv6qc8nr8,7991
|
|
15
|
+
tree_sitter_analyzer/cli/__init__.py,sha256=O_3URpbdu5Ilb2-r48LjbZuWtOWQu_BhL3pa6C0G3Bk,871
|
|
16
|
+
tree_sitter_analyzer/cli/__main__.py,sha256=Xq8o8-0dPnMDU9WZqmqhzr98rx8rvoffTUHAkAwl-L8,218
|
|
17
|
+
tree_sitter_analyzer/cli/info_commands.py,sha256=UjgjDi3RQy_lqvj00FP1Qj-yas-5bB_ZTZcp6MWXiUM,4298
|
|
18
|
+
tree_sitter_analyzer/cli/commands/__init__.py,sha256=jpcpM1ptLuxLMBDUv1y_a87k8RAw1otFzeYpWtXvz3Y,671
|
|
19
|
+
tree_sitter_analyzer/cli/commands/advanced_command.py,sha256=xDZI4zKTMHNdf7fc_QN0eAQ8a5MnRb5DJ29ERLBDUQs,3424
|
|
20
|
+
tree_sitter_analyzer/cli/commands/base_command.py,sha256=dNg1JkWSPLHsjIF8yTtVUNk_b7FqM-hGRiHl47ztkqw,5787
|
|
21
|
+
tree_sitter_analyzer/cli/commands/default_command.py,sha256=qUHmop7ya_wyDfAlCOI7klESDuBU9rRo7V7Lle8gzKo,531
|
|
22
|
+
tree_sitter_analyzer/cli/commands/partial_read_command.py,sha256=R-dfWvVKxGdZyeieNjJAZQvgM13O3JZa6Fkmjc3sDqk,4684
|
|
23
|
+
tree_sitter_analyzer/cli/commands/query_command.py,sha256=iGa-kebJhsUgsk1HMREdVKItWHwBZXr7AEwcE2LVUAI,3119
|
|
24
|
+
tree_sitter_analyzer/cli/commands/structure_command.py,sha256=0iJwjOgtW838hXleXogWhbu6eQFfrLR1QgKe5PFBqvU,5220
|
|
25
|
+
tree_sitter_analyzer/cli/commands/summary_command.py,sha256=02WA3sOzfT83FVT6sW7nK04zVcZ9Qj_1S0WloqlTnFk,3602
|
|
26
|
+
tree_sitter_analyzer/cli/commands/table_command.py,sha256=EtMVI_Ui1wTblcDpSHWVOvoN-Ne_QJxT0iE7JtqYRxA,9448
|
|
27
|
+
tree_sitter_analyzer/core/__init__.py,sha256=VlYOy1epW16vjaVd__knESewnU0sfXF9a4hjrFxiSEE,440
|
|
28
|
+
tree_sitter_analyzer/core/analysis_engine.py,sha256=ReWaW-ZtuyKwtR-XdVd8J-A0oN5tWmKUEyZS6LJJa8E,18567
|
|
29
|
+
tree_sitter_analyzer/core/cache_service.py,sha256=TQrOI9xwI-0KRF8c6-cXwXM1Ut3AhLOXa4GpyQsIHW4,9624
|
|
30
|
+
tree_sitter_analyzer/core/engine.py,sha256=6vdXcYfcHqv9tyJfT7iRPsdIIndf73wo71qT6Rt9Zow,18356
|
|
31
|
+
tree_sitter_analyzer/core/parser.py,sha256=qT3yIlTRdod4tf_2o1hU_B-GYGukyM2BtaFxzSoxois,9293
|
|
32
|
+
tree_sitter_analyzer/core/query.py,sha256=fmuPMLsU4XUnMViaQADPRPoiZ-MzeE2k_e9N35VBNSA,16899
|
|
33
|
+
tree_sitter_analyzer/formatters/__init__.py,sha256=yVb4HF_4EEPRwTf3y3-vM2NllrhykG3zlvQhN-6dB4c,31
|
|
34
|
+
tree_sitter_analyzer/formatters/base_formatter.py,sha256=Uv6uVgUKwbBn6of26bnvr4u6CmX2ka1a405VL17CGFU,5763
|
|
35
|
+
tree_sitter_analyzer/formatters/formatter_factory.py,sha256=mCnAbEHycoSttSuF4dU78hzcxyg-h57bo0_bj00zw58,2069
|
|
36
|
+
tree_sitter_analyzer/formatters/java_formatter.py,sha256=MKssGZwvOXxARq-P9DT0ksclAYC3YpVQuY3c-oiKQhI,11622
|
|
37
|
+
tree_sitter_analyzer/formatters/python_formatter.py,sha256=HkkUu5O7pGvw2e5SSsQTSUJWkS84pg6uuIkiG0lDxkQ,10275
|
|
38
|
+
tree_sitter_analyzer/interfaces/__init__.py,sha256=OcT7eNIU0ZXvAeAXbhDqRG3puxn93HeSLqplwj6npTM,271
|
|
39
|
+
tree_sitter_analyzer/interfaces/cli.py,sha256=EsRcy0Wrt5BzR8RxBaXToH29XZoahR-fSLwGaMyf2LE,16840
|
|
40
|
+
tree_sitter_analyzer/interfaces/cli_adapter.py,sha256=ANl2kEirv5_mf87dlZRZvMp_oqLQT8khyyVH50khARA,11192
|
|
41
|
+
tree_sitter_analyzer/interfaces/mcp_adapter.py,sha256=DJugCRVL-AR6gJRaRrBW5JVXRvfl_iiRjupcnsb0_sE,7111
|
|
42
|
+
tree_sitter_analyzer/interfaces/mcp_server.py,sha256=TvcmWWRxyWp5LrbDRGAeTZww_mmyarA8Mz9eL5xiQv0,16200
|
|
43
|
+
tree_sitter_analyzer/languages/__init__.py,sha256=VTXxJgVjHJAciLhX0zzXOS4EygZMtebeYUbi_0z6fGw,340
|
|
44
|
+
tree_sitter_analyzer/languages/java_plugin.py,sha256=jhrOeJhp3CBMW_bjWXWwoc78DxGsLzo6YAUtkY4hJ-c,47076
|
|
45
|
+
tree_sitter_analyzer/languages/javascript_plugin.py,sha256=k14kHfi5II9MRTsVuy0NQq5l2KZYncCnM1Q6T1c5q_U,15844
|
|
46
|
+
tree_sitter_analyzer/languages/python_plugin.py,sha256=MJ03F_Nv-nmInIkEFmPyEXYhyGbLHyr5kCbj2taEDYk,29144
|
|
47
|
+
tree_sitter_analyzer/mcp/__init__.py,sha256=76ZKgWbsXZWB8mNER2D0fNHdULPZhqqBJHi8R0uHDPE,721
|
|
48
|
+
tree_sitter_analyzer/mcp/server.py,sha256=chXNK7jA9SgEqZElKjej63pDvYJqN0cHBzZES0R818s,12426
|
|
49
|
+
tree_sitter_analyzer/mcp/resources/__init__.py,sha256=SWnK8liTQkuQXlVgyRP9mf5HzpqmqohShrC98xlNnDc,1389
|
|
50
|
+
tree_sitter_analyzer/mcp/resources/code_file_resource.py,sha256=POhQ1xPMiGBVVm6AfOQNKM29svDLvlGLA97ZPQgVoHw,6253
|
|
51
|
+
tree_sitter_analyzer/mcp/resources/project_stats_resource.py,sha256=lZF9TGxjKvTwPyuWE_o3I3V4LK0zEj3lab4L0Iq-hho,19758
|
|
52
|
+
tree_sitter_analyzer/mcp/tools/__init__.py,sha256=u7JrSLwE95y50mfjSus6HRdtdhkNbVrW8jP4AooawEU,762
|
|
53
|
+
tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py,sha256=njQxFS5507RolQR_nEJEnZVQMfs2MBEenWEhDYJC1_o,26343
|
|
54
|
+
tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py,sha256=mssed7bEfGeGxW4mOf7dg8BDS1oqHLolIBNX9DaZ3DM,8997
|
|
55
|
+
tree_sitter_analyzer/mcp/tools/base_tool.py,sha256=FVSMgKIliQ5EBVQEfjYwWeqzWt9OqOFDr3dyACIDxig,1210
|
|
56
|
+
tree_sitter_analyzer/mcp/tools/read_partial_tool.py,sha256=0Rb-jI2CfzN1PVeJZnkERaowm9Y8iFSZl8W-VIQQ8cI,10735
|
|
57
|
+
tree_sitter_analyzer/mcp/tools/table_format_tool.py,sha256=mydPcWazEIaF1IYEgmWTu2HAOVXVVb6s1-Pmcnnh6HE,14261
|
|
58
|
+
tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py,sha256=Wl4wZWHYbvcYKnFmdkEn7FTNSel_jlnpQCjfSuzYkEg,20785
|
|
59
|
+
tree_sitter_analyzer/mcp/utils/__init__.py,sha256=hibcoJc9PEetXqPIpvwHw1cpr1rabAm0QQaDZpxvA_g,2956
|
|
60
|
+
tree_sitter_analyzer/mcp/utils/error_handler.py,sha256=QgKqjUhe0QTCRrtoiuTxDMUt-eDRNclf1ToJtaCNoq8,17423
|
|
61
|
+
tree_sitter_analyzer/plugins/__init__.py,sha256=ITE9bTz7NO4axnn8g5Z-1_ydhSLT0RnY6Y1J9OhUP3E,10326
|
|
62
|
+
tree_sitter_analyzer/plugins/base.py,sha256=FMRAOtjtDutNV8RnB6cmFgdvcjxKRAbrrzqldBBT1yk,17167
|
|
63
|
+
tree_sitter_analyzer/plugins/manager.py,sha256=PyEY3jeuCBpDVqguWhaAu7nzUZM17_pI6wml2e0Hamo,12535
|
|
64
|
+
tree_sitter_analyzer/queries/__init__.py,sha256=dwDDc7PCw_UWruxSeJ8uEBjY0O5uLDBI5YqyvBhbnN0,696
|
|
65
|
+
tree_sitter_analyzer/queries/java.py,sha256=NZTSzFADlGrm3MD0oIkOdkN_6wP2pGZpNs0Rb7I_mcw,12249
|
|
66
|
+
tree_sitter_analyzer/queries/javascript.py,sha256=pnXrgISwDE5GhPHDbUKEGI3thyLmebTeQt-l_-x4qT8,3962
|
|
67
|
+
tree_sitter_analyzer/queries/python.py,sha256=L33KRUyV3sAvA3_HFkPyGgtiq0ygSpNY_n2YojodPlc,7570
|
|
68
|
+
tree_sitter_analyzer/queries/typescript.py,sha256=eersyAF7TladuCWa8WE_-cO9YTF1LUSjLIl-tk2fZDo,6708
|
|
69
|
+
tree_sitter_analyzer-0.6.0.dist-info/METADATA,sha256=2mCHLLbFZoK60hHUnXqWM8t8hBimZnZ4xRxLOobr5EY,13402
|
|
70
|
+
tree_sitter_analyzer-0.6.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
71
|
+
tree_sitter_analyzer-0.6.0.dist-info/entry_points.txt,sha256=EA0Ow27x2SqNt2300sv70RTWxKRIxJzOhNPIVlez4NM,417
|
|
72
|
+
tree_sitter_analyzer-0.6.0.dist-info/RECORD,,
|
{tree_sitter_analyzer-0.3.0.dist-info → tree_sitter_analyzer-0.6.0.dist-info}/entry_points.txt
RENAMED
|
@@ -5,4 +5,5 @@ tree-sitter-analyzer = tree_sitter_analyzer.cli_main:main
|
|
|
5
5
|
|
|
6
6
|
[tree_sitter_analyzer.plugins]
|
|
7
7
|
java = tree_sitter_analyzer.languages.java_plugin:JavaPlugin
|
|
8
|
-
|
|
8
|
+
javascript = tree_sitter_analyzer.languages.javascript_plugin:JavaScriptPlugin
|
|
9
|
+
python = tree_sitter_analyzer.languages.python_plugin:PythonPlugin
|