tree-sitter-analyzer 1.7.7__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 +23 -30
- 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/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/language_detector.py +80 -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/query_tool.py +99 -58
- tree_sitter_analyzer/mcp/tools/table_format_tool.py +24 -10
- 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 +182 -44
- 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.7.dist-info → tree_sitter_analyzer-1.8.2.dist-info}/METADATA +120 -14
- {tree_sitter_analyzer-1.7.7.dist-info → tree_sitter_analyzer-1.8.2.dist-info}/RECORD +38 -29
- {tree_sitter_analyzer-1.7.7.dist-info → tree_sitter_analyzer-1.8.2.dist-info}/entry_points.txt +2 -0
- {tree_sitter_analyzer-1.7.7.dist-info → tree_sitter_analyzer-1.8.2.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
CSS Language Queries
|
|
4
|
+
|
|
5
|
+
Comprehensive Tree-sitter queries for CSS language constructs.
|
|
6
|
+
Covers selectors, properties, rules, at-rules, and CSS features.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# CSS-specific query library
|
|
10
|
+
CSS_QUERIES: dict[str, str] = {
|
|
11
|
+
# --- Basic Rules ---
|
|
12
|
+
"rule_set": """
|
|
13
|
+
(rule_set) @rule_set
|
|
14
|
+
""",
|
|
15
|
+
"rule": """
|
|
16
|
+
(rule_set
|
|
17
|
+
selectors: (selectors) @selectors
|
|
18
|
+
block: (block) @block) @rule
|
|
19
|
+
""",
|
|
20
|
+
"declaration": """
|
|
21
|
+
(declaration
|
|
22
|
+
property: (property_name) @property_name
|
|
23
|
+
value: (_) @property_value) @declaration
|
|
24
|
+
""",
|
|
25
|
+
"property": """
|
|
26
|
+
(property_name) @property
|
|
27
|
+
""",
|
|
28
|
+
"property_name": """
|
|
29
|
+
(property_name) @property_name
|
|
30
|
+
""",
|
|
31
|
+
"property_value": """
|
|
32
|
+
(declaration
|
|
33
|
+
value: (_) @property_value)
|
|
34
|
+
""",
|
|
35
|
+
|
|
36
|
+
# --- Selectors ---
|
|
37
|
+
"selector": """
|
|
38
|
+
(selectors
|
|
39
|
+
(selector) @selector)
|
|
40
|
+
""",
|
|
41
|
+
"selectors": """
|
|
42
|
+
(selectors) @selectors
|
|
43
|
+
""",
|
|
44
|
+
"class_selector": """
|
|
45
|
+
(class_selector) @class_selector
|
|
46
|
+
""",
|
|
47
|
+
"id_selector": """
|
|
48
|
+
(id_selector) @id_selector
|
|
49
|
+
""",
|
|
50
|
+
"tag_selector": """
|
|
51
|
+
(tag_name) @tag_selector
|
|
52
|
+
""",
|
|
53
|
+
"universal_selector": """
|
|
54
|
+
(universal_selector) @universal_selector
|
|
55
|
+
""",
|
|
56
|
+
"attribute_selector": """
|
|
57
|
+
(attribute_selector) @attribute_selector
|
|
58
|
+
""",
|
|
59
|
+
"pseudo_class_selector": """
|
|
60
|
+
(pseudo_class_selector) @pseudo_class_selector
|
|
61
|
+
""",
|
|
62
|
+
"pseudo_element_selector": """
|
|
63
|
+
(pseudo_element_selector) @pseudo_element_selector
|
|
64
|
+
""",
|
|
65
|
+
"descendant_selector": """
|
|
66
|
+
(descendant_selector) @descendant_selector
|
|
67
|
+
""",
|
|
68
|
+
"child_selector": """
|
|
69
|
+
(child_selector) @child_selector
|
|
70
|
+
""",
|
|
71
|
+
"sibling_selector": """
|
|
72
|
+
(sibling_selector) @sibling_selector
|
|
73
|
+
""",
|
|
74
|
+
"adjacent_sibling_selector": """
|
|
75
|
+
(adjacent_sibling_selector) @adjacent_sibling_selector
|
|
76
|
+
""",
|
|
77
|
+
|
|
78
|
+
# --- At-Rules ---
|
|
79
|
+
"at_rule": """
|
|
80
|
+
(at_rule) @at_rule
|
|
81
|
+
""",
|
|
82
|
+
"import_statement": """
|
|
83
|
+
(import_statement) @import_statement
|
|
84
|
+
""",
|
|
85
|
+
"media_statement": """
|
|
86
|
+
(media_statement) @media_statement
|
|
87
|
+
""",
|
|
88
|
+
"charset_statement": """
|
|
89
|
+
(charset_statement) @charset_statement
|
|
90
|
+
""",
|
|
91
|
+
"namespace_statement": """
|
|
92
|
+
(namespace_statement) @namespace_statement
|
|
93
|
+
""",
|
|
94
|
+
"keyframes_statement": """
|
|
95
|
+
(keyframes_statement) @keyframes_statement
|
|
96
|
+
""",
|
|
97
|
+
"supports_statement": """
|
|
98
|
+
(supports_statement) @supports_statement
|
|
99
|
+
""",
|
|
100
|
+
"page_statement": """
|
|
101
|
+
(page_statement) @page_statement
|
|
102
|
+
""",
|
|
103
|
+
"font_face_statement": """
|
|
104
|
+
(font_face_statement) @font_face_statement
|
|
105
|
+
""",
|
|
106
|
+
|
|
107
|
+
# --- Media Queries ---
|
|
108
|
+
"media_query": """
|
|
109
|
+
(media_query) @media_query
|
|
110
|
+
""",
|
|
111
|
+
"media_feature": """
|
|
112
|
+
(media_feature) @media_feature
|
|
113
|
+
""",
|
|
114
|
+
"media_type": """
|
|
115
|
+
(media_type) @media_type
|
|
116
|
+
""",
|
|
117
|
+
|
|
118
|
+
# --- Values ---
|
|
119
|
+
"string_value": """
|
|
120
|
+
(string_value) @string_value
|
|
121
|
+
""",
|
|
122
|
+
"integer_value": """
|
|
123
|
+
(integer_value) @integer_value
|
|
124
|
+
""",
|
|
125
|
+
"float_value": """
|
|
126
|
+
(float_value) @float_value
|
|
127
|
+
""",
|
|
128
|
+
"color_value": """
|
|
129
|
+
(color_value) @color_value
|
|
130
|
+
""",
|
|
131
|
+
"call_expression": """
|
|
132
|
+
(call_expression) @call_expression
|
|
133
|
+
""",
|
|
134
|
+
"function_name": """
|
|
135
|
+
(call_expression
|
|
136
|
+
function: (function_name) @function_name)
|
|
137
|
+
""",
|
|
138
|
+
"arguments": """
|
|
139
|
+
(call_expression
|
|
140
|
+
arguments: (arguments) @arguments)
|
|
141
|
+
""",
|
|
142
|
+
"url": """
|
|
143
|
+
(call_expression
|
|
144
|
+
function: (function_name) @func_name
|
|
145
|
+
(#match? @func_name "^url$")
|
|
146
|
+
arguments: (arguments) @url_args) @url
|
|
147
|
+
""",
|
|
148
|
+
"calc": """
|
|
149
|
+
(call_expression
|
|
150
|
+
function: (function_name) @func_name
|
|
151
|
+
(#match? @func_name "^calc$")
|
|
152
|
+
arguments: (arguments) @calc_args) @calc
|
|
153
|
+
""",
|
|
154
|
+
"var": """
|
|
155
|
+
(call_expression
|
|
156
|
+
function: (function_name) @func_name
|
|
157
|
+
(#match? @func_name "^var$")
|
|
158
|
+
arguments: (arguments) @var_args) @var
|
|
159
|
+
""",
|
|
160
|
+
"rgb": """
|
|
161
|
+
(call_expression
|
|
162
|
+
function: (function_name) @func_name
|
|
163
|
+
(#match? @func_name "^rgb$")
|
|
164
|
+
arguments: (arguments) @rgb_args) @rgb
|
|
165
|
+
""",
|
|
166
|
+
"rgba": """
|
|
167
|
+
(call_expression
|
|
168
|
+
function: (function_name) @func_name
|
|
169
|
+
(#match? @func_name "^rgba$")
|
|
170
|
+
arguments: (arguments) @rgba_args) @rgba
|
|
171
|
+
""",
|
|
172
|
+
"hsl": """
|
|
173
|
+
(call_expression
|
|
174
|
+
function: (function_name) @func_name
|
|
175
|
+
(#match? @func_name "^hsl$")
|
|
176
|
+
arguments: (arguments) @hsl_args) @hsl
|
|
177
|
+
""",
|
|
178
|
+
"hsla": """
|
|
179
|
+
(call_expression
|
|
180
|
+
function: (function_name) @func_name
|
|
181
|
+
(#match? @func_name "^hsla$")
|
|
182
|
+
arguments: (arguments) @hsla_args) @hsla
|
|
183
|
+
""",
|
|
184
|
+
|
|
185
|
+
# --- Units ---
|
|
186
|
+
"dimension": """
|
|
187
|
+
(dimension) @dimension
|
|
188
|
+
""",
|
|
189
|
+
"percentage": """
|
|
190
|
+
(percentage) @percentage
|
|
191
|
+
""",
|
|
192
|
+
"unit": """
|
|
193
|
+
(dimension
|
|
194
|
+
unit: (unit) @unit)
|
|
195
|
+
""",
|
|
196
|
+
|
|
197
|
+
# --- Layout Properties ---
|
|
198
|
+
"display": """
|
|
199
|
+
(declaration
|
|
200
|
+
property: (property_name) @prop_name
|
|
201
|
+
(#match? @prop_name "^display$")
|
|
202
|
+
value: (_) @display_value) @display
|
|
203
|
+
""",
|
|
204
|
+
"position": """
|
|
205
|
+
(declaration
|
|
206
|
+
property: (property_name) @prop_name
|
|
207
|
+
(#match? @prop_name "^position$")
|
|
208
|
+
value: (_) @position_value) @position
|
|
209
|
+
""",
|
|
210
|
+
"float": """
|
|
211
|
+
(declaration
|
|
212
|
+
property: (property_name) @prop_name
|
|
213
|
+
(#match? @prop_name "^float$")
|
|
214
|
+
value: (_) @float_value) @float
|
|
215
|
+
""",
|
|
216
|
+
"clear": """
|
|
217
|
+
(declaration
|
|
218
|
+
property: (property_name) @prop_name
|
|
219
|
+
(#match? @prop_name "^clear$")
|
|
220
|
+
value: (_) @clear_value) @clear
|
|
221
|
+
""",
|
|
222
|
+
"overflow": """
|
|
223
|
+
(declaration
|
|
224
|
+
property: (property_name) @prop_name
|
|
225
|
+
(#match? @prop_name "^overflow$")
|
|
226
|
+
value: (_) @overflow_value) @overflow
|
|
227
|
+
""",
|
|
228
|
+
"visibility": """
|
|
229
|
+
(declaration
|
|
230
|
+
property: (property_name) @prop_name
|
|
231
|
+
(#match? @prop_name "^visibility$")
|
|
232
|
+
value: (_) @visibility_value) @visibility
|
|
233
|
+
""",
|
|
234
|
+
"z_index": """
|
|
235
|
+
(declaration
|
|
236
|
+
property: (property_name) @prop_name
|
|
237
|
+
(#match? @prop_name "^z-index$")
|
|
238
|
+
value: (_) @z_index_value) @z_index
|
|
239
|
+
""",
|
|
240
|
+
|
|
241
|
+
# --- Box Model Properties ---
|
|
242
|
+
"width": """
|
|
243
|
+
(declaration
|
|
244
|
+
property: (property_name) @prop_name
|
|
245
|
+
(#match? @prop_name "^width$")
|
|
246
|
+
value: (_) @width_value) @width
|
|
247
|
+
""",
|
|
248
|
+
"height": """
|
|
249
|
+
(declaration
|
|
250
|
+
property: (property_name) @prop_name
|
|
251
|
+
(#match? @prop_name "^height$")
|
|
252
|
+
value: (_) @height_value) @height
|
|
253
|
+
""",
|
|
254
|
+
"margin": """
|
|
255
|
+
(declaration
|
|
256
|
+
property: (property_name) @prop_name
|
|
257
|
+
(#match? @prop_name "^margin")
|
|
258
|
+
value: (_) @margin_value) @margin
|
|
259
|
+
""",
|
|
260
|
+
"padding": """
|
|
261
|
+
(declaration
|
|
262
|
+
property: (property_name) @prop_name
|
|
263
|
+
(#match? @prop_name "^padding")
|
|
264
|
+
value: (_) @padding_value) @padding
|
|
265
|
+
""",
|
|
266
|
+
"border": """
|
|
267
|
+
(declaration
|
|
268
|
+
property: (property_name) @prop_name
|
|
269
|
+
(#match? @prop_name "^border")
|
|
270
|
+
value: (_) @border_value) @border
|
|
271
|
+
""",
|
|
272
|
+
"box_sizing": """
|
|
273
|
+
(declaration
|
|
274
|
+
property: (property_name) @prop_name
|
|
275
|
+
(#match? @prop_name "^box-sizing$")
|
|
276
|
+
value: (_) @box_sizing_value) @box_sizing
|
|
277
|
+
""",
|
|
278
|
+
|
|
279
|
+
# --- Typography Properties ---
|
|
280
|
+
"font": """
|
|
281
|
+
(declaration
|
|
282
|
+
property: (property_name) @prop_name
|
|
283
|
+
(#match? @prop_name "^font")
|
|
284
|
+
value: (_) @font_value) @font
|
|
285
|
+
""",
|
|
286
|
+
"color": """
|
|
287
|
+
(declaration
|
|
288
|
+
property: (property_name) @prop_name
|
|
289
|
+
(#match? @prop_name "^color$")
|
|
290
|
+
value: (_) @color_value) @color
|
|
291
|
+
""",
|
|
292
|
+
"text": """
|
|
293
|
+
(declaration
|
|
294
|
+
property: (property_name) @prop_name
|
|
295
|
+
(#match? @prop_name "^text-")
|
|
296
|
+
value: (_) @text_value) @text
|
|
297
|
+
""",
|
|
298
|
+
"line_height": """
|
|
299
|
+
(declaration
|
|
300
|
+
property: (property_name) @prop_name
|
|
301
|
+
(#match? @prop_name "^line-height$")
|
|
302
|
+
value: (_) @line_height_value) @line_height
|
|
303
|
+
""",
|
|
304
|
+
"letter_spacing": """
|
|
305
|
+
(declaration
|
|
306
|
+
property: (property_name) @prop_name
|
|
307
|
+
(#match? @prop_name "^letter-spacing$")
|
|
308
|
+
value: (_) @letter_spacing_value) @letter_spacing
|
|
309
|
+
""",
|
|
310
|
+
"word_spacing": """
|
|
311
|
+
(declaration
|
|
312
|
+
property: (property_name) @prop_name
|
|
313
|
+
(#match? @prop_name "^word-spacing$")
|
|
314
|
+
value: (_) @word_spacing_value) @word_spacing
|
|
315
|
+
""",
|
|
316
|
+
|
|
317
|
+
# --- Background Properties ---
|
|
318
|
+
"background": """
|
|
319
|
+
(declaration
|
|
320
|
+
property: (property_name) @prop_name
|
|
321
|
+
(#match? @prop_name "^background")
|
|
322
|
+
value: (_) @background_value) @background
|
|
323
|
+
""",
|
|
324
|
+
|
|
325
|
+
# --- Flexbox Properties ---
|
|
326
|
+
"flex": """
|
|
327
|
+
(declaration
|
|
328
|
+
property: (property_name) @prop_name
|
|
329
|
+
(#match? @prop_name "^flex")
|
|
330
|
+
value: (_) @flex_value) @flex
|
|
331
|
+
""",
|
|
332
|
+
"justify_content": """
|
|
333
|
+
(declaration
|
|
334
|
+
property: (property_name) @prop_name
|
|
335
|
+
(#match? @prop_name "^justify-content$")
|
|
336
|
+
value: (_) @justify_content_value) @justify_content
|
|
337
|
+
""",
|
|
338
|
+
"align_items": """
|
|
339
|
+
(declaration
|
|
340
|
+
property: (property_name) @prop_name
|
|
341
|
+
(#match? @prop_name "^align-items$")
|
|
342
|
+
value: (_) @align_items_value) @align_items
|
|
343
|
+
""",
|
|
344
|
+
"align_content": """
|
|
345
|
+
(declaration
|
|
346
|
+
property: (property_name) @prop_name
|
|
347
|
+
(#match? @prop_name "^align-content$")
|
|
348
|
+
value: (_) @align_content_value) @align_content
|
|
349
|
+
""",
|
|
350
|
+
|
|
351
|
+
# --- Grid Properties ---
|
|
352
|
+
"grid": """
|
|
353
|
+
(declaration
|
|
354
|
+
property: (property_name) @prop_name
|
|
355
|
+
(#match? @prop_name "^grid")
|
|
356
|
+
value: (_) @grid_value) @grid
|
|
357
|
+
""",
|
|
358
|
+
|
|
359
|
+
# --- Animation Properties ---
|
|
360
|
+
"animation": """
|
|
361
|
+
(declaration
|
|
362
|
+
property: (property_name) @prop_name
|
|
363
|
+
(#match? @prop_name "^animation")
|
|
364
|
+
value: (_) @animation_value) @animation
|
|
365
|
+
""",
|
|
366
|
+
"transition": """
|
|
367
|
+
(declaration
|
|
368
|
+
property: (property_name) @prop_name
|
|
369
|
+
(#match? @prop_name "^transition")
|
|
370
|
+
value: (_) @transition_value) @transition
|
|
371
|
+
""",
|
|
372
|
+
"transform": """
|
|
373
|
+
(declaration
|
|
374
|
+
property: (property_name) @prop_name
|
|
375
|
+
(#match? @prop_name "^transform")
|
|
376
|
+
value: (_) @transform_value) @transform
|
|
377
|
+
""",
|
|
378
|
+
|
|
379
|
+
# --- Comments ---
|
|
380
|
+
"comment": """
|
|
381
|
+
(comment) @comment
|
|
382
|
+
""",
|
|
383
|
+
|
|
384
|
+
# --- Custom Properties (CSS Variables) ---
|
|
385
|
+
"custom_property": """
|
|
386
|
+
(declaration
|
|
387
|
+
property: (property_name) @prop_name
|
|
388
|
+
(#match? @prop_name "^--")
|
|
389
|
+
value: (_) @custom_value) @custom_property
|
|
390
|
+
""",
|
|
391
|
+
|
|
392
|
+
# --- Important Declarations ---
|
|
393
|
+
"important": """
|
|
394
|
+
(declaration
|
|
395
|
+
value: (_)
|
|
396
|
+
"!" @important_mark
|
|
397
|
+
"important" @important_keyword) @important
|
|
398
|
+
""",
|
|
399
|
+
|
|
400
|
+
# --- Keyframe Rules ---
|
|
401
|
+
"keyframe_block": """
|
|
402
|
+
(keyframe_block) @keyframe_block
|
|
403
|
+
""",
|
|
404
|
+
"keyframe_block_list": """
|
|
405
|
+
(keyframe_block_list) @keyframe_block_list
|
|
406
|
+
""",
|
|
407
|
+
"from": """
|
|
408
|
+
(from) @from
|
|
409
|
+
""",
|
|
410
|
+
"to": """
|
|
411
|
+
(to) @to
|
|
412
|
+
""",
|
|
413
|
+
|
|
414
|
+
# --- Name-only Extraction ---
|
|
415
|
+
"class_name": """
|
|
416
|
+
(class_selector
|
|
417
|
+
name: (class_name) @class_name)
|
|
418
|
+
""",
|
|
419
|
+
"id_name": """
|
|
420
|
+
(id_selector
|
|
421
|
+
name: (id_name) @id_name)
|
|
422
|
+
""",
|
|
423
|
+
"tag_name": """
|
|
424
|
+
(tag_name) @tag_name
|
|
425
|
+
""",
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
# Query descriptions
|
|
429
|
+
CSS_QUERY_DESCRIPTIONS: dict[str, str] = {
|
|
430
|
+
"rule_set": "Search CSS rule sets",
|
|
431
|
+
"rule": "Search CSS rules with selectors and blocks",
|
|
432
|
+
"declaration": "Search CSS property declarations",
|
|
433
|
+
"property": "Search CSS properties",
|
|
434
|
+
"property_name": "Search CSS property names",
|
|
435
|
+
"property_value": "Search CSS property values",
|
|
436
|
+
"selector": "Search CSS selectors",
|
|
437
|
+
"selectors": "Search CSS selector lists",
|
|
438
|
+
"class_selector": "Search class selectors",
|
|
439
|
+
"id_selector": "Search ID selectors",
|
|
440
|
+
"tag_selector": "Search tag selectors",
|
|
441
|
+
"universal_selector": "Search universal selectors",
|
|
442
|
+
"attribute_selector": "Search attribute selectors",
|
|
443
|
+
"pseudo_class_selector": "Search pseudo-class selectors",
|
|
444
|
+
"pseudo_element_selector": "Search pseudo-element selectors",
|
|
445
|
+
"descendant_selector": "Search descendant selectors",
|
|
446
|
+
"child_selector": "Search child selectors",
|
|
447
|
+
"sibling_selector": "Search sibling selectors",
|
|
448
|
+
"adjacent_sibling_selector": "Search adjacent sibling selectors",
|
|
449
|
+
"at_rule": "Search at-rules",
|
|
450
|
+
"import_statement": "Search @import statements",
|
|
451
|
+
"media_statement": "Search @media statements",
|
|
452
|
+
"charset_statement": "Search @charset statements",
|
|
453
|
+
"namespace_statement": "Search @namespace statements",
|
|
454
|
+
"keyframes_statement": "Search @keyframes statements",
|
|
455
|
+
"supports_statement": "Search @supports statements",
|
|
456
|
+
"page_statement": "Search @page statements",
|
|
457
|
+
"font_face_statement": "Search @font-face statements",
|
|
458
|
+
"media_query": "Search media queries",
|
|
459
|
+
"media_feature": "Search media features",
|
|
460
|
+
"media_type": "Search media types",
|
|
461
|
+
"string_value": "Search string values",
|
|
462
|
+
"integer_value": "Search integer values",
|
|
463
|
+
"float_value": "Search float values",
|
|
464
|
+
"color_value": "Search color values",
|
|
465
|
+
"call_expression": "Search function calls",
|
|
466
|
+
"function_name": "Search function names",
|
|
467
|
+
"arguments": "Search function arguments",
|
|
468
|
+
"url": "Search url() functions",
|
|
469
|
+
"calc": "Search calc() functions",
|
|
470
|
+
"var": "Search var() functions",
|
|
471
|
+
"rgb": "Search rgb() functions",
|
|
472
|
+
"rgba": "Search rgba() functions",
|
|
473
|
+
"hsl": "Search hsl() functions",
|
|
474
|
+
"hsla": "Search hsla() functions",
|
|
475
|
+
"dimension": "Search dimension values",
|
|
476
|
+
"percentage": "Search percentage values",
|
|
477
|
+
"unit": "Search units",
|
|
478
|
+
"display": "Search display properties",
|
|
479
|
+
"position": "Search position properties",
|
|
480
|
+
"float": "Search float properties",
|
|
481
|
+
"clear": "Search clear properties",
|
|
482
|
+
"overflow": "Search overflow properties",
|
|
483
|
+
"visibility": "Search visibility properties",
|
|
484
|
+
"z_index": "Search z-index properties",
|
|
485
|
+
"width": "Search width properties",
|
|
486
|
+
"height": "Search height properties",
|
|
487
|
+
"margin": "Search margin properties",
|
|
488
|
+
"padding": "Search padding properties",
|
|
489
|
+
"border": "Search border properties",
|
|
490
|
+
"box_sizing": "Search box-sizing properties",
|
|
491
|
+
"font": "Search font properties",
|
|
492
|
+
"color": "Search color properties",
|
|
493
|
+
"text": "Search text properties",
|
|
494
|
+
"line_height": "Search line-height properties",
|
|
495
|
+
"letter_spacing": "Search letter-spacing properties",
|
|
496
|
+
"word_spacing": "Search word-spacing properties",
|
|
497
|
+
"background": "Search background properties",
|
|
498
|
+
"flex": "Search flex properties",
|
|
499
|
+
"justify_content": "Search justify-content properties",
|
|
500
|
+
"align_items": "Search align-items properties",
|
|
501
|
+
"align_content": "Search align-content properties",
|
|
502
|
+
"grid": "Search grid properties",
|
|
503
|
+
"animation": "Search animation properties",
|
|
504
|
+
"transition": "Search transition properties",
|
|
505
|
+
"transform": "Search transform properties",
|
|
506
|
+
"comment": "Search CSS comments",
|
|
507
|
+
"custom_property": "Search CSS custom properties (variables)",
|
|
508
|
+
"important": "Search !important declarations",
|
|
509
|
+
"keyframe_block": "Search keyframe blocks",
|
|
510
|
+
"keyframe_block_list": "Search keyframe block lists",
|
|
511
|
+
"from": "Search from keyframes",
|
|
512
|
+
"to": "Search to keyframes",
|
|
513
|
+
"class_name": "Search class names only",
|
|
514
|
+
"id_name": "Search ID names only",
|
|
515
|
+
"tag_name": "Search tag names only",
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
# Legacy query definitions for backward compatibility
|
|
519
|
+
RULES = """
|
|
520
|
+
(rule_set
|
|
521
|
+
selectors: (selectors) @rule.selectors
|
|
522
|
+
block: (block) @rule.block) @rule.set
|
|
523
|
+
"""
|
|
524
|
+
|
|
525
|
+
SELECTORS = """
|
|
526
|
+
(selectors
|
|
527
|
+
(selector) @selector) @selectors
|
|
528
|
+
"""
|
|
529
|
+
|
|
530
|
+
DECLARATIONS = """
|
|
531
|
+
(declaration
|
|
532
|
+
property: (property_name) @declaration.property
|
|
533
|
+
value: (_) @declaration.value) @declaration.full
|
|
534
|
+
"""
|
|
535
|
+
|
|
536
|
+
COMMENTS = """
|
|
537
|
+
(comment) @comment
|
|
538
|
+
"""
|
|
539
|
+
|
|
540
|
+
AT_RULES = """
|
|
541
|
+
(at_rule) @at_rule
|
|
542
|
+
"""
|
|
543
|
+
|
|
544
|
+
# Convert to ALL_QUERIES format for dynamic loader compatibility
|
|
545
|
+
ALL_QUERIES = {}
|
|
546
|
+
for query_name, query_string in CSS_QUERIES.items():
|
|
547
|
+
description = CSS_QUERY_DESCRIPTIONS.get(query_name, "No description")
|
|
548
|
+
ALL_QUERIES[query_name] = {"query": query_string, "description": description}
|
|
549
|
+
|
|
550
|
+
# Add legacy queries for backward compatibility
|
|
551
|
+
ALL_QUERIES["rules"] = {
|
|
552
|
+
"query": RULES,
|
|
553
|
+
"description": "Search all CSS rules with selectors and blocks",
|
|
554
|
+
}
|
|
555
|
+
ALL_QUERIES["selectors"] = {
|
|
556
|
+
"query": SELECTORS,
|
|
557
|
+
"description": "Search all CSS selectors",
|
|
558
|
+
}
|
|
559
|
+
ALL_QUERIES["declarations"] = {
|
|
560
|
+
"query": DECLARATIONS,
|
|
561
|
+
"description": "Search all CSS declarations",
|
|
562
|
+
}
|
|
563
|
+
ALL_QUERIES["comments"] = {
|
|
564
|
+
"query": COMMENTS,
|
|
565
|
+
"description": "Search all CSS comments",
|
|
566
|
+
}
|
|
567
|
+
ALL_QUERIES["at_rules"] = {
|
|
568
|
+
"query": AT_RULES,
|
|
569
|
+
"description": "Search all CSS at-rules",
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
def get_css_query(name: str) -> str:
|
|
574
|
+
"""
|
|
575
|
+
Get the specified CSS query
|
|
576
|
+
|
|
577
|
+
Args:
|
|
578
|
+
name: Query name
|
|
579
|
+
|
|
580
|
+
Returns:
|
|
581
|
+
Query string
|
|
582
|
+
|
|
583
|
+
Raises:
|
|
584
|
+
ValueError: When query is not found
|
|
585
|
+
"""
|
|
586
|
+
if name not in CSS_QUERIES:
|
|
587
|
+
available = list(CSS_QUERIES.keys())
|
|
588
|
+
raise ValueError(
|
|
589
|
+
f"CSS query '{name}' does not exist. Available: {available}"
|
|
590
|
+
)
|
|
591
|
+
|
|
592
|
+
return CSS_QUERIES[name]
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
def get_css_query_description(name: str) -> str:
|
|
596
|
+
"""
|
|
597
|
+
Get the description of the specified CSS query
|
|
598
|
+
|
|
599
|
+
Args:
|
|
600
|
+
name: Query name
|
|
601
|
+
|
|
602
|
+
Returns:
|
|
603
|
+
Query description
|
|
604
|
+
"""
|
|
605
|
+
return CSS_QUERY_DESCRIPTIONS.get(name, "No description")
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
def get_query(name: str) -> str:
|
|
609
|
+
"""Get a specific query by name."""
|
|
610
|
+
if name in ALL_QUERIES:
|
|
611
|
+
return ALL_QUERIES[name]["query"]
|
|
612
|
+
raise ValueError(
|
|
613
|
+
f"Query '{name}' not found. Available queries: {list(ALL_QUERIES.keys())}"
|
|
614
|
+
)
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
def get_all_queries() -> dict:
|
|
618
|
+
"""Get all available queries."""
|
|
619
|
+
return ALL_QUERIES
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
def list_queries() -> list:
|
|
623
|
+
"""List all available query names."""
|
|
624
|
+
return list(ALL_QUERIES.keys())
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
def get_available_css_queries() -> list[str]:
|
|
628
|
+
"""
|
|
629
|
+
Get list of available CSS queries
|
|
630
|
+
|
|
631
|
+
Returns:
|
|
632
|
+
List of query names
|
|
633
|
+
"""
|
|
634
|
+
return list(CSS_QUERIES.keys())
|