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