tree-sitter-analyzer 1.7.5__py3-none-any.whl → 1.8.2__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 +1 -1
- tree_sitter_analyzer/api.py +26 -32
- tree_sitter_analyzer/cli/argument_validator.py +77 -0
- tree_sitter_analyzer/cli/commands/table_command.py +7 -2
- tree_sitter_analyzer/cli_main.py +17 -3
- tree_sitter_analyzer/core/cache_service.py +15 -5
- tree_sitter_analyzer/core/query.py +33 -22
- tree_sitter_analyzer/core/query_service.py +179 -154
- tree_sitter_analyzer/exceptions.py +334 -0
- tree_sitter_analyzer/file_handler.py +16 -1
- tree_sitter_analyzer/formatters/formatter_registry.py +355 -0
- tree_sitter_analyzer/formatters/html_formatter.py +462 -0
- tree_sitter_analyzer/formatters/language_formatter_factory.py +3 -0
- tree_sitter_analyzer/formatters/markdown_formatter.py +1 -1
- tree_sitter_analyzer/interfaces/mcp_server.py +3 -1
- tree_sitter_analyzer/language_detector.py +91 -7
- tree_sitter_analyzer/languages/css_plugin.py +390 -0
- tree_sitter_analyzer/languages/html_plugin.py +395 -0
- tree_sitter_analyzer/languages/java_plugin.py +116 -0
- tree_sitter_analyzer/languages/javascript_plugin.py +113 -0
- tree_sitter_analyzer/languages/markdown_plugin.py +266 -46
- tree_sitter_analyzer/languages/python_plugin.py +176 -33
- tree_sitter_analyzer/languages/typescript_plugin.py +130 -1
- tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +68 -3
- tree_sitter_analyzer/mcp/tools/fd_rg_utils.py +32 -7
- tree_sitter_analyzer/mcp/tools/find_and_grep_tool.py +10 -0
- tree_sitter_analyzer/mcp/tools/list_files_tool.py +9 -0
- tree_sitter_analyzer/mcp/tools/query_tool.py +100 -52
- tree_sitter_analyzer/mcp/tools/read_partial_tool.py +98 -14
- tree_sitter_analyzer/mcp/tools/search_content_tool.py +9 -0
- tree_sitter_analyzer/mcp/tools/table_format_tool.py +37 -13
- tree_sitter_analyzer/models.py +53 -0
- tree_sitter_analyzer/output_manager.py +1 -1
- tree_sitter_analyzer/plugins/base.py +50 -0
- tree_sitter_analyzer/plugins/manager.py +5 -1
- tree_sitter_analyzer/queries/css.py +634 -0
- tree_sitter_analyzer/queries/html.py +556 -0
- tree_sitter_analyzer/queries/markdown.py +54 -164
- tree_sitter_analyzer/query_loader.py +16 -3
- tree_sitter_analyzer/security/validator.py +343 -46
- tree_sitter_analyzer/utils/__init__.py +113 -0
- tree_sitter_analyzer/utils/tree_sitter_compat.py +282 -0
- tree_sitter_analyzer/utils.py +62 -24
- {tree_sitter_analyzer-1.7.5.dist-info → tree_sitter_analyzer-1.8.2.dist-info}/METADATA +136 -14
- {tree_sitter_analyzer-1.7.5.dist-info → tree_sitter_analyzer-1.8.2.dist-info}/RECORD +47 -38
- {tree_sitter_analyzer-1.7.5.dist-info → tree_sitter_analyzer-1.8.2.dist-info}/entry_points.txt +2 -0
- {tree_sitter_analyzer-1.7.5.dist-info → tree_sitter_analyzer-1.8.2.dist-info}/WHEEL +0 -0
|
@@ -8,223 +8,113 @@ links, code blocks, lists, and other structural elements.
|
|
|
8
8
|
|
|
9
9
|
from typing import Dict, List
|
|
10
10
|
|
|
11
|
-
# Markdown element extraction queries
|
|
11
|
+
# Markdown element extraction queries - simplified for compatibility
|
|
12
12
|
MARKDOWN_QUERIES: Dict[str, str] = {
|
|
13
|
-
# Headers (H1-H6)
|
|
13
|
+
# Headers (H1-H6) - simplified
|
|
14
14
|
"headers": """
|
|
15
|
-
(atx_heading
|
|
16
|
-
|
|
17
|
-
heading_content: (inline) @h1.content) @h1.heading
|
|
18
|
-
|
|
19
|
-
(atx_heading
|
|
20
|
-
(atx_h2_marker) @h2.marker
|
|
21
|
-
heading_content: (inline) @h2.content) @h2.heading
|
|
22
|
-
|
|
23
|
-
(atx_heading
|
|
24
|
-
(atx_h3_marker) @h3.marker
|
|
25
|
-
heading_content: (inline) @h3.content) @h3.heading
|
|
26
|
-
|
|
27
|
-
(atx_heading
|
|
28
|
-
(atx_h4_marker) @h4.marker
|
|
29
|
-
heading_content: (inline) @h4.content) @h4.heading
|
|
30
|
-
|
|
31
|
-
(atx_heading
|
|
32
|
-
(atx_h5_marker) @h5.marker
|
|
33
|
-
heading_content: (inline) @h5.content) @h5.heading
|
|
34
|
-
|
|
35
|
-
(atx_heading
|
|
36
|
-
(atx_h6_marker) @h6.marker
|
|
37
|
-
heading_content: (inline) @h6.content) @h6.heading
|
|
38
|
-
|
|
39
|
-
(setext_heading
|
|
40
|
-
heading_content: (paragraph) @setext.content
|
|
41
|
-
(setext_h1_underline) @setext.h1) @setext.h1.heading
|
|
42
|
-
|
|
43
|
-
(setext_heading
|
|
44
|
-
heading_content: (paragraph) @setext.content
|
|
45
|
-
(setext_h2_underline) @setext.h2) @setext.h2.heading
|
|
15
|
+
(atx_heading) @header
|
|
16
|
+
(setext_heading) @header
|
|
46
17
|
""",
|
|
47
18
|
|
|
48
|
-
# Code blocks
|
|
19
|
+
# Code blocks - simplified
|
|
49
20
|
"code_blocks": """
|
|
50
|
-
(fenced_code_block
|
|
51
|
-
|
|
52
|
-
(info_string)? @code.language
|
|
53
|
-
(code_fence_content) @code.content
|
|
54
|
-
(fenced_code_block_delimiter) @code.end) @code.block
|
|
55
|
-
|
|
56
|
-
(indented_code_block
|
|
57
|
-
(code_fence_content) @indented_code.content) @indented_code.block
|
|
21
|
+
(fenced_code_block) @code_block
|
|
22
|
+
(indented_code_block) @code_block
|
|
58
23
|
""",
|
|
59
24
|
|
|
60
|
-
# Inline code
|
|
25
|
+
# Inline code - simplified
|
|
61
26
|
"inline_code": """
|
|
62
|
-
(
|
|
63
|
-
(code_span_delimiter) @inline_code.start
|
|
64
|
-
(code_span_content) @inline_code.content
|
|
65
|
-
(code_span_delimiter) @inline_code.end) @inline_code.span
|
|
27
|
+
(inline) @inline
|
|
66
28
|
""",
|
|
67
29
|
|
|
68
|
-
# Links
|
|
30
|
+
# Links - simplified to avoid invalid node types
|
|
69
31
|
"links": """
|
|
70
|
-
(
|
|
71
|
-
(link_text) @link.text
|
|
72
|
-
(link_destination) @link.url
|
|
73
|
-
(link_title)? @link.title) @link.element
|
|
74
|
-
|
|
75
|
-
(autolink
|
|
76
|
-
(uri_autolink) @autolink.uri) @autolink.element
|
|
77
|
-
|
|
78
|
-
(autolink
|
|
79
|
-
(email_autolink) @autolink.email) @autolink.element
|
|
80
|
-
|
|
81
|
-
(reference_link
|
|
82
|
-
(link_text) @ref_link.text
|
|
83
|
-
(link_label) @ref_link.label) @ref_link.element
|
|
84
|
-
|
|
85
|
-
(link_reference_definition
|
|
86
|
-
(link_label) @link_def.label
|
|
87
|
-
(link_destination) @link_def.url
|
|
88
|
-
(link_title)? @link_def.title) @link_def.element
|
|
32
|
+
(inline) @inline
|
|
89
33
|
""",
|
|
90
34
|
|
|
91
|
-
# Images
|
|
35
|
+
# Images - simplified to avoid invalid node types
|
|
92
36
|
"images": """
|
|
93
|
-
(
|
|
94
|
-
(image_description) @image.alt
|
|
95
|
-
(link_destination) @image.url
|
|
96
|
-
(link_title)? @image.title) @image.element
|
|
97
|
-
|
|
98
|
-
(reference_image
|
|
99
|
-
(image_description) @ref_image.alt
|
|
100
|
-
(link_label) @ref_image.label) @ref_image.element
|
|
37
|
+
(inline) @inline
|
|
101
38
|
""",
|
|
102
39
|
|
|
103
|
-
# Lists
|
|
40
|
+
# Lists - simplified to avoid invalid node types
|
|
104
41
|
"lists": """
|
|
105
|
-
(list
|
|
106
|
-
|
|
107
|
-
(list_marker) @list_item.marker
|
|
108
|
-
(paragraph)? @list_item.content) @list_item.element) @list.element
|
|
109
|
-
|
|
110
|
-
(tight_list
|
|
111
|
-
(list_item
|
|
112
|
-
(list_marker) @tight_list_item.marker
|
|
113
|
-
(paragraph)? @tight_list_item.content) @tight_list_item.element) @tight_list.element
|
|
42
|
+
(list) @list
|
|
43
|
+
(list_item) @list_item
|
|
114
44
|
""",
|
|
115
45
|
|
|
116
|
-
# Emphasis and strong
|
|
46
|
+
# Emphasis and strong - simplified
|
|
117
47
|
"emphasis": """
|
|
118
|
-
(
|
|
119
|
-
(emphasis_delimiter) @emphasis.start
|
|
120
|
-
(inline) @emphasis.content
|
|
121
|
-
(emphasis_delimiter) @emphasis.end) @emphasis.element
|
|
122
|
-
|
|
123
|
-
(strong_emphasis
|
|
124
|
-
(strong_emphasis_delimiter) @strong.start
|
|
125
|
-
(inline) @strong.content
|
|
126
|
-
(strong_emphasis_delimiter) @strong.end) @strong.element
|
|
48
|
+
(inline) @inline
|
|
127
49
|
""",
|
|
128
50
|
|
|
129
|
-
# Blockquotes
|
|
51
|
+
# Blockquotes - simplified
|
|
130
52
|
"blockquotes": """
|
|
131
|
-
(block_quote
|
|
132
|
-
(block_quote_marker) @blockquote.marker
|
|
133
|
-
(paragraph) @blockquote.content) @blockquote.element
|
|
53
|
+
(block_quote) @blockquote
|
|
134
54
|
""",
|
|
135
55
|
|
|
136
|
-
# Tables
|
|
56
|
+
# Tables - simplified
|
|
137
57
|
"tables": """
|
|
138
|
-
(pipe_table
|
|
139
|
-
(pipe_table_header
|
|
140
|
-
(pipe_table_cell) @table_header.cell) @table.header
|
|
141
|
-
(pipe_table_delimiter_row) @table.delimiter
|
|
142
|
-
(pipe_table_row
|
|
143
|
-
(pipe_table_cell) @table_row.cell) @table.row) @table.element
|
|
58
|
+
(pipe_table) @table
|
|
144
59
|
""",
|
|
145
60
|
|
|
146
|
-
# Horizontal rules
|
|
61
|
+
# Horizontal rules - simplified
|
|
147
62
|
"horizontal_rules": """
|
|
148
|
-
(thematic_break) @hr
|
|
63
|
+
(thematic_break) @hr
|
|
149
64
|
""",
|
|
150
65
|
|
|
151
|
-
# HTML blocks
|
|
66
|
+
# HTML blocks - simplified
|
|
152
67
|
"html_blocks": """
|
|
153
|
-
(html_block) @
|
|
68
|
+
(html_block) @html_block
|
|
154
69
|
""",
|
|
155
70
|
|
|
156
|
-
# Inline HTML
|
|
71
|
+
# Inline HTML - simplified
|
|
157
72
|
"inline_html": """
|
|
158
|
-
(
|
|
73
|
+
(inline) @inline
|
|
159
74
|
""",
|
|
160
75
|
|
|
161
|
-
# Strikethrough
|
|
76
|
+
# Strikethrough - simplified
|
|
162
77
|
"strikethrough": """
|
|
163
|
-
(
|
|
164
|
-
(strikethrough_delimiter) @strike.start
|
|
165
|
-
(inline) @strike.content
|
|
166
|
-
(strikethrough_delimiter) @strike.end) @strike.element
|
|
78
|
+
(inline) @inline
|
|
167
79
|
""",
|
|
168
80
|
|
|
169
|
-
# Task lists
|
|
81
|
+
# Task lists - simplified
|
|
170
82
|
"task_lists": """
|
|
171
|
-
(list_item
|
|
172
|
-
(list_marker) @task.marker
|
|
173
|
-
(task_list_marker_checked) @task.checked) @task.checked_item
|
|
174
|
-
|
|
175
|
-
(list_item
|
|
176
|
-
(list_marker) @task.marker
|
|
177
|
-
(task_list_marker_unchecked) @task.unchecked) @task.unchecked_item
|
|
83
|
+
(list_item) @list_item
|
|
178
84
|
""",
|
|
179
85
|
|
|
180
|
-
# Footnotes
|
|
86
|
+
# Footnotes - simplified
|
|
181
87
|
"footnotes": """
|
|
182
|
-
(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
(footnote_definition
|
|
186
|
-
(footnote_label) @footnote.def_label
|
|
187
|
-
(paragraph) @footnote.content) @footnote.definition
|
|
88
|
+
(paragraph) @paragraph
|
|
89
|
+
(inline) @inline
|
|
188
90
|
""",
|
|
189
91
|
|
|
190
|
-
# All text content
|
|
92
|
+
# All text content - simplified
|
|
191
93
|
"text_content": """
|
|
192
|
-
(paragraph
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
(inline) @text.inline
|
|
94
|
+
(paragraph) @paragraph
|
|
95
|
+
(inline) @inline
|
|
196
96
|
""",
|
|
197
97
|
|
|
198
|
-
# Document structure
|
|
98
|
+
# Document structure - simplified
|
|
199
99
|
"document": """
|
|
200
|
-
(document) @document
|
|
100
|
+
(document) @document
|
|
201
101
|
""",
|
|
202
102
|
|
|
203
|
-
# All elements (comprehensive)
|
|
103
|
+
# All elements (comprehensive) - simplified
|
|
204
104
|
"all_elements": """
|
|
205
|
-
(atx_heading) @
|
|
206
|
-
(setext_heading) @
|
|
207
|
-
(fenced_code_block) @
|
|
208
|
-
(indented_code_block) @
|
|
209
|
-
(
|
|
210
|
-
(
|
|
211
|
-
(
|
|
212
|
-
(
|
|
213
|
-
(
|
|
214
|
-
(
|
|
215
|
-
(
|
|
216
|
-
(
|
|
217
|
-
(
|
|
218
|
-
(strong_emphasis) @element.strong
|
|
219
|
-
(strikethrough) @element.strikethrough
|
|
220
|
-
(block_quote) @element.blockquote
|
|
221
|
-
(pipe_table) @element.table
|
|
222
|
-
(thematic_break) @element.hr
|
|
223
|
-
(html_block) @element.html_block
|
|
224
|
-
(html_tag) @element.html_inline
|
|
225
|
-
(footnote_reference) @element.footnote_ref
|
|
226
|
-
(footnote_definition) @element.footnote_def
|
|
227
|
-
(paragraph) @element.paragraph
|
|
105
|
+
(atx_heading) @heading
|
|
106
|
+
(setext_heading) @heading
|
|
107
|
+
(fenced_code_block) @code_block
|
|
108
|
+
(indented_code_block) @code_block
|
|
109
|
+
(inline) @inline
|
|
110
|
+
(list) @list
|
|
111
|
+
(list_item) @list_item
|
|
112
|
+
(block_quote) @blockquote
|
|
113
|
+
(pipe_table) @table
|
|
114
|
+
(thematic_break) @hr
|
|
115
|
+
(html_block) @html_block
|
|
116
|
+
(paragraph) @paragraph
|
|
117
|
+
(link_reference_definition) @reference
|
|
228
118
|
""",
|
|
229
119
|
}
|
|
230
120
|
|
|
@@ -55,6 +55,13 @@ class QueryLoader:
|
|
|
55
55
|
|
|
56
56
|
def load_language_queries(self, language: str) -> dict:
|
|
57
57
|
"""Load queries for a specific language with optimized caching."""
|
|
58
|
+
# Handle None or empty language - return empty dict without warning
|
|
59
|
+
if not language or language == "None" or language.strip() == "":
|
|
60
|
+
return {}
|
|
61
|
+
|
|
62
|
+
# Normalize language name
|
|
63
|
+
language = language.strip().lower()
|
|
64
|
+
|
|
58
65
|
if language in self._failed_languages:
|
|
59
66
|
return {}
|
|
60
67
|
|
|
@@ -87,9 +94,7 @@ class QueryLoader:
|
|
|
87
94
|
return queries
|
|
88
95
|
|
|
89
96
|
except ImportError:
|
|
90
|
-
|
|
91
|
-
f"No dynamic query module for '{language}', using predefined queries."
|
|
92
|
-
)
|
|
97
|
+
# Silently handle missing query modules - no warnings needed
|
|
93
98
|
self._loaded_queries[language] = queries
|
|
94
99
|
return queries
|
|
95
100
|
except Exception as e:
|
|
@@ -100,6 +105,10 @@ class QueryLoader:
|
|
|
100
105
|
|
|
101
106
|
def get_query(self, language: str, query_name: str) -> str | None:
|
|
102
107
|
"""Get a specific query for a language with optimized lookup."""
|
|
108
|
+
# Handle invalid language early
|
|
109
|
+
if not language or language == "None" or language.strip() == "":
|
|
110
|
+
return None
|
|
111
|
+
|
|
103
112
|
queries = self.load_language_queries(language)
|
|
104
113
|
|
|
105
114
|
if query_name in queries:
|
|
@@ -128,6 +137,10 @@ class QueryLoader:
|
|
|
128
137
|
|
|
129
138
|
def list_queries_for_language(self, language: str) -> list[str]:
|
|
130
139
|
"""List all available queries for a language."""
|
|
140
|
+
# Handle invalid language early
|
|
141
|
+
if not language or language == "None" or language.strip() == "":
|
|
142
|
+
return []
|
|
143
|
+
|
|
131
144
|
queries = self.load_language_queries(language)
|
|
132
145
|
return list(queries.keys())
|
|
133
146
|
|