tree-sitter-analyzer 0.9.3__py3-none-any.whl → 0.9.5__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/cli/commands/default_command.py +18 -18
- tree_sitter_analyzer/cli/commands/partial_read_command.py +139 -141
- tree_sitter_analyzer/cli/commands/query_command.py +92 -88
- tree_sitter_analyzer/cli/commands/table_command.py +235 -235
- tree_sitter_analyzer/cli/info_commands.py +121 -121
- tree_sitter_analyzer/cli_main.py +307 -307
- tree_sitter_analyzer/core/analysis_engine.py +584 -584
- tree_sitter_analyzer/core/cache_service.py +5 -4
- tree_sitter_analyzer/core/query.py +502 -502
- tree_sitter_analyzer/encoding_utils.py +9 -2
- tree_sitter_analyzer/exceptions.py +400 -406
- tree_sitter_analyzer/formatters/java_formatter.py +291 -291
- tree_sitter_analyzer/formatters/python_formatter.py +259 -259
- tree_sitter_analyzer/interfaces/mcp_server.py +426 -425
- tree_sitter_analyzer/language_detector.py +398 -398
- tree_sitter_analyzer/language_loader.py +224 -224
- tree_sitter_analyzer/languages/java_plugin.py +1202 -1202
- tree_sitter_analyzer/mcp/resources/project_stats_resource.py +559 -555
- tree_sitter_analyzer/mcp/server.py +30 -9
- tree_sitter_analyzer/mcp/tools/read_partial_tool.py +21 -4
- tree_sitter_analyzer/mcp/tools/table_format_tool.py +22 -4
- tree_sitter_analyzer/mcp/utils/error_handler.py +569 -567
- tree_sitter_analyzer/models.py +470 -470
- tree_sitter_analyzer/security/__init__.py +22 -22
- tree_sitter_analyzer/security/boundary_manager.py +251 -243
- tree_sitter_analyzer/security/regex_checker.py +297 -292
- tree_sitter_analyzer/table_formatter.py +708 -652
- tree_sitter_analyzer/utils.py +61 -19
- tree_sitter_analyzer-0.9.5.dist-info/METADATA +567 -0
- {tree_sitter_analyzer-0.9.3.dist-info → tree_sitter_analyzer-0.9.5.dist-info}/RECORD +32 -32
- tree_sitter_analyzer-0.9.3.dist-info/METADATA +0 -409
- {tree_sitter_analyzer-0.9.3.dist-info → tree_sitter_analyzer-0.9.5.dist-info}/WHEEL +0 -0
- {tree_sitter_analyzer-0.9.3.dist-info → tree_sitter_analyzer-0.9.5.dist-info}/entry_points.txt +0 -0
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
Information Commands for CLI
|
|
4
|
-
|
|
5
|
-
Commands that display information without requiring file analysis.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
from abc import ABC, abstractmethod
|
|
9
|
-
from argparse import Namespace
|
|
10
|
-
|
|
11
|
-
from ..language_detector import detect_language_from_file, detector
|
|
12
|
-
from ..output_manager import output_data, output_error, output_info, output_list
|
|
13
|
-
from ..query_loader import query_loader
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class InfoCommand(ABC):
|
|
17
|
-
"""Base class for information commands that don't require file analysis."""
|
|
18
|
-
|
|
19
|
-
def __init__(self, args: Namespace):
|
|
20
|
-
self.args = args
|
|
21
|
-
|
|
22
|
-
@abstractmethod
|
|
23
|
-
def execute(self) -> int:
|
|
24
|
-
"""Execute the information command."""
|
|
25
|
-
pass
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
class ListQueriesCommand(InfoCommand):
|
|
29
|
-
"""Command to list available queries."""
|
|
30
|
-
|
|
31
|
-
def execute(self) -> int:
|
|
32
|
-
if self.args.language:
|
|
33
|
-
language = self.args.language
|
|
34
|
-
elif hasattr(self.args, "file_path") and self.args.file_path:
|
|
35
|
-
language = detect_language_from_file(self.args.file_path)
|
|
36
|
-
else:
|
|
37
|
-
output_list("Supported languages:")
|
|
38
|
-
for lang in query_loader.list_supported_languages():
|
|
39
|
-
output_list(f" {lang}")
|
|
40
|
-
queries = query_loader.list_queries_for_language(lang)
|
|
41
|
-
for query_key in queries:
|
|
42
|
-
description = (
|
|
43
|
-
query_loader.get_query_description(lang, query_key)
|
|
44
|
-
or "No description"
|
|
45
|
-
)
|
|
46
|
-
output_list(f" {query_key:<20} - {description}")
|
|
47
|
-
return 0
|
|
48
|
-
|
|
49
|
-
output_list(f"Available query keys ({language}):")
|
|
50
|
-
for query_key in query_loader.list_queries_for_language(language):
|
|
51
|
-
description = (
|
|
52
|
-
query_loader.get_query_description(language, query_key)
|
|
53
|
-
or "No description"
|
|
54
|
-
)
|
|
55
|
-
output_list(f" {query_key:<20} - {description}")
|
|
56
|
-
return 0
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
class DescribeQueryCommand(InfoCommand):
|
|
60
|
-
"""Command to describe a specific query."""
|
|
61
|
-
|
|
62
|
-
def execute(self) -> int:
|
|
63
|
-
if self.args.language:
|
|
64
|
-
language = self.args.language
|
|
65
|
-
elif hasattr(self.args, "file_path") and self.args.file_path:
|
|
66
|
-
language = detect_language_from_file(self.args.file_path)
|
|
67
|
-
else:
|
|
68
|
-
output_error(
|
|
69
|
-
"ERROR: Query description display requires --language or target file specification"
|
|
70
|
-
)
|
|
71
|
-
return 1
|
|
72
|
-
|
|
73
|
-
try:
|
|
74
|
-
query_description = query_loader.get_query_description(
|
|
75
|
-
language, self.args.describe_query
|
|
76
|
-
)
|
|
77
|
-
query_content = query_loader.get_query(language, self.args.describe_query)
|
|
78
|
-
|
|
79
|
-
if query_description is None or query_content is None:
|
|
80
|
-
output_error(
|
|
81
|
-
f"Query '{self.args.describe_query}' not found for language '{language}'"
|
|
82
|
-
)
|
|
83
|
-
return 1
|
|
84
|
-
|
|
85
|
-
output_info(
|
|
86
|
-
f"Query key '{self.args.describe_query}' ({language}): {query_description}"
|
|
87
|
-
)
|
|
88
|
-
output_data(f"Query content:\n{query_content}")
|
|
89
|
-
except ValueError as e:
|
|
90
|
-
output_error(f"{e}")
|
|
91
|
-
return 1
|
|
92
|
-
return 0
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
class ShowLanguagesCommand(InfoCommand):
|
|
96
|
-
"""Command to show supported languages."""
|
|
97
|
-
|
|
98
|
-
def execute(self) -> int:
|
|
99
|
-
output_list("Supported languages:")
|
|
100
|
-
for language in detector.get_supported_languages():
|
|
101
|
-
info = detector.get_language_info(language)
|
|
102
|
-
extensions = ", ".join(info["extensions"][:5])
|
|
103
|
-
if len(info["extensions"]) > 5:
|
|
104
|
-
extensions += f", ... ({len(info['extensions'])-5} more)"
|
|
105
|
-
output_list(f" {language:<12} - Extensions: {extensions}")
|
|
106
|
-
return 0
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
class ShowExtensionsCommand(InfoCommand):
|
|
110
|
-
"""Command to show supported extensions."""
|
|
111
|
-
|
|
112
|
-
def execute(self) -> int:
|
|
113
|
-
output_list("Supported file extensions:")
|
|
114
|
-
supported_extensions = detector.get_supported_extensions()
|
|
115
|
-
for i in range(0, len(supported_extensions), 8):
|
|
116
|
-
line = " " + " ".join(
|
|
117
|
-
f"{ext:<6}" for ext in supported_extensions[i : i + 8]
|
|
118
|
-
)
|
|
119
|
-
output_list(line)
|
|
120
|
-
output_info(f"\nTotal {len(supported_extensions)} extensions supported")
|
|
121
|
-
return 0
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Information Commands for CLI
|
|
4
|
+
|
|
5
|
+
Commands that display information without requiring file analysis.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from abc import ABC, abstractmethod
|
|
9
|
+
from argparse import Namespace
|
|
10
|
+
|
|
11
|
+
from ..language_detector import detect_language_from_file, detector
|
|
12
|
+
from ..output_manager import output_data, output_error, output_info, output_list
|
|
13
|
+
from ..query_loader import query_loader
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class InfoCommand(ABC):
|
|
17
|
+
"""Base class for information commands that don't require file analysis."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, args: Namespace):
|
|
20
|
+
self.args = args
|
|
21
|
+
|
|
22
|
+
@abstractmethod
|
|
23
|
+
def execute(self) -> int:
|
|
24
|
+
"""Execute the information command."""
|
|
25
|
+
pass
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ListQueriesCommand(InfoCommand):
|
|
29
|
+
"""Command to list available queries."""
|
|
30
|
+
|
|
31
|
+
def execute(self) -> int:
|
|
32
|
+
if self.args.language:
|
|
33
|
+
language = self.args.language
|
|
34
|
+
elif hasattr(self.args, "file_path") and self.args.file_path:
|
|
35
|
+
language = detect_language_from_file(self.args.file_path)
|
|
36
|
+
else:
|
|
37
|
+
output_list("Supported languages:")
|
|
38
|
+
for lang in query_loader.list_supported_languages():
|
|
39
|
+
output_list(f" {lang}")
|
|
40
|
+
queries = query_loader.list_queries_for_language(lang)
|
|
41
|
+
for query_key in queries:
|
|
42
|
+
description = (
|
|
43
|
+
query_loader.get_query_description(lang, query_key)
|
|
44
|
+
or "No description"
|
|
45
|
+
)
|
|
46
|
+
output_list(f" {query_key:<20} - {description}")
|
|
47
|
+
return 0
|
|
48
|
+
|
|
49
|
+
output_list(f"Available query keys ({language}):")
|
|
50
|
+
for query_key in query_loader.list_queries_for_language(language):
|
|
51
|
+
description = (
|
|
52
|
+
query_loader.get_query_description(language, query_key)
|
|
53
|
+
or "No description"
|
|
54
|
+
)
|
|
55
|
+
output_list(f" {query_key:<20} - {description}")
|
|
56
|
+
return 0
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class DescribeQueryCommand(InfoCommand):
|
|
60
|
+
"""Command to describe a specific query."""
|
|
61
|
+
|
|
62
|
+
def execute(self) -> int:
|
|
63
|
+
if self.args.language:
|
|
64
|
+
language = self.args.language
|
|
65
|
+
elif hasattr(self.args, "file_path") and self.args.file_path:
|
|
66
|
+
language = detect_language_from_file(self.args.file_path)
|
|
67
|
+
else:
|
|
68
|
+
output_error(
|
|
69
|
+
"ERROR: Query description display requires --language or target file specification"
|
|
70
|
+
)
|
|
71
|
+
return 1
|
|
72
|
+
|
|
73
|
+
try:
|
|
74
|
+
query_description = query_loader.get_query_description(
|
|
75
|
+
language, self.args.describe_query
|
|
76
|
+
)
|
|
77
|
+
query_content = query_loader.get_query(language, self.args.describe_query)
|
|
78
|
+
|
|
79
|
+
if query_description is None or query_content is None:
|
|
80
|
+
output_error(
|
|
81
|
+
f"Query '{self.args.describe_query}' not found for language '{language}'"
|
|
82
|
+
)
|
|
83
|
+
return 1
|
|
84
|
+
|
|
85
|
+
output_info(
|
|
86
|
+
f"Query key '{self.args.describe_query}' ({language}): {query_description}"
|
|
87
|
+
)
|
|
88
|
+
output_data(f"Query content:\n{query_content}")
|
|
89
|
+
except ValueError as e:
|
|
90
|
+
output_error(f"{e}")
|
|
91
|
+
return 1
|
|
92
|
+
return 0
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class ShowLanguagesCommand(InfoCommand):
|
|
96
|
+
"""Command to show supported languages."""
|
|
97
|
+
|
|
98
|
+
def execute(self) -> int:
|
|
99
|
+
output_list("Supported languages:")
|
|
100
|
+
for language in detector.get_supported_languages():
|
|
101
|
+
info = detector.get_language_info(language)
|
|
102
|
+
extensions = ", ".join(info["extensions"][:5])
|
|
103
|
+
if len(info["extensions"]) > 5:
|
|
104
|
+
extensions += f", ... ({len(info['extensions'])-5} more)"
|
|
105
|
+
output_list(f" {language:<12} - Extensions: {extensions}")
|
|
106
|
+
return 0
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class ShowExtensionsCommand(InfoCommand):
|
|
110
|
+
"""Command to show supported extensions."""
|
|
111
|
+
|
|
112
|
+
def execute(self) -> int:
|
|
113
|
+
output_list("Supported file extensions:")
|
|
114
|
+
supported_extensions = detector.get_supported_extensions()
|
|
115
|
+
for i in range(0, len(supported_extensions), 8):
|
|
116
|
+
line = " " + " ".join(
|
|
117
|
+
f"{ext:<6}" for ext in supported_extensions[i : i + 8]
|
|
118
|
+
)
|
|
119
|
+
output_list(line)
|
|
120
|
+
output_info(f"\nTotal {len(supported_extensions)} extensions supported")
|
|
121
|
+
return 0
|