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.
- tree_sitter_analyzer/__init__.py +132 -0
- tree_sitter_analyzer/__main__.py +11 -0
- tree_sitter_analyzer/api.py +853 -0
- tree_sitter_analyzer/cli/__init__.py +39 -0
- tree_sitter_analyzer/cli/__main__.py +12 -0
- tree_sitter_analyzer/cli/argument_validator.py +89 -0
- tree_sitter_analyzer/cli/commands/__init__.py +26 -0
- tree_sitter_analyzer/cli/commands/advanced_command.py +226 -0
- tree_sitter_analyzer/cli/commands/base_command.py +181 -0
- tree_sitter_analyzer/cli/commands/default_command.py +18 -0
- tree_sitter_analyzer/cli/commands/find_and_grep_cli.py +188 -0
- tree_sitter_analyzer/cli/commands/list_files_cli.py +133 -0
- tree_sitter_analyzer/cli/commands/partial_read_command.py +139 -0
- tree_sitter_analyzer/cli/commands/query_command.py +109 -0
- tree_sitter_analyzer/cli/commands/search_content_cli.py +161 -0
- tree_sitter_analyzer/cli/commands/structure_command.py +156 -0
- tree_sitter_analyzer/cli/commands/summary_command.py +116 -0
- tree_sitter_analyzer/cli/commands/table_command.py +414 -0
- tree_sitter_analyzer/cli/info_commands.py +124 -0
- tree_sitter_analyzer/cli_main.py +472 -0
- tree_sitter_analyzer/constants.py +85 -0
- tree_sitter_analyzer/core/__init__.py +15 -0
- tree_sitter_analyzer/core/analysis_engine.py +580 -0
- tree_sitter_analyzer/core/cache_service.py +333 -0
- tree_sitter_analyzer/core/engine.py +585 -0
- tree_sitter_analyzer/core/parser.py +293 -0
- tree_sitter_analyzer/core/query.py +605 -0
- tree_sitter_analyzer/core/query_filter.py +200 -0
- tree_sitter_analyzer/core/query_service.py +340 -0
- tree_sitter_analyzer/encoding_utils.py +530 -0
- tree_sitter_analyzer/exceptions.py +747 -0
- tree_sitter_analyzer/file_handler.py +246 -0
- tree_sitter_analyzer/formatters/__init__.py +1 -0
- tree_sitter_analyzer/formatters/base_formatter.py +201 -0
- tree_sitter_analyzer/formatters/csharp_formatter.py +367 -0
- tree_sitter_analyzer/formatters/formatter_config.py +197 -0
- tree_sitter_analyzer/formatters/formatter_factory.py +84 -0
- tree_sitter_analyzer/formatters/formatter_registry.py +377 -0
- tree_sitter_analyzer/formatters/formatter_selector.py +96 -0
- tree_sitter_analyzer/formatters/go_formatter.py +368 -0
- tree_sitter_analyzer/formatters/html_formatter.py +498 -0
- tree_sitter_analyzer/formatters/java_formatter.py +423 -0
- tree_sitter_analyzer/formatters/javascript_formatter.py +611 -0
- tree_sitter_analyzer/formatters/kotlin_formatter.py +268 -0
- tree_sitter_analyzer/formatters/language_formatter_factory.py +123 -0
- tree_sitter_analyzer/formatters/legacy_formatter_adapters.py +228 -0
- tree_sitter_analyzer/formatters/markdown_formatter.py +725 -0
- tree_sitter_analyzer/formatters/php_formatter.py +301 -0
- tree_sitter_analyzer/formatters/python_formatter.py +830 -0
- tree_sitter_analyzer/formatters/ruby_formatter.py +278 -0
- tree_sitter_analyzer/formatters/rust_formatter.py +233 -0
- tree_sitter_analyzer/formatters/sql_formatter_wrapper.py +689 -0
- tree_sitter_analyzer/formatters/sql_formatters.py +536 -0
- tree_sitter_analyzer/formatters/typescript_formatter.py +543 -0
- tree_sitter_analyzer/formatters/yaml_formatter.py +462 -0
- tree_sitter_analyzer/interfaces/__init__.py +9 -0
- tree_sitter_analyzer/interfaces/cli.py +535 -0
- tree_sitter_analyzer/interfaces/cli_adapter.py +359 -0
- tree_sitter_analyzer/interfaces/mcp_adapter.py +224 -0
- tree_sitter_analyzer/interfaces/mcp_server.py +428 -0
- tree_sitter_analyzer/language_detector.py +553 -0
- tree_sitter_analyzer/language_loader.py +271 -0
- tree_sitter_analyzer/languages/__init__.py +10 -0
- tree_sitter_analyzer/languages/csharp_plugin.py +1076 -0
- tree_sitter_analyzer/languages/css_plugin.py +449 -0
- tree_sitter_analyzer/languages/go_plugin.py +836 -0
- tree_sitter_analyzer/languages/html_plugin.py +496 -0
- tree_sitter_analyzer/languages/java_plugin.py +1299 -0
- tree_sitter_analyzer/languages/javascript_plugin.py +1622 -0
- tree_sitter_analyzer/languages/kotlin_plugin.py +656 -0
- tree_sitter_analyzer/languages/markdown_plugin.py +1928 -0
- tree_sitter_analyzer/languages/php_plugin.py +862 -0
- tree_sitter_analyzer/languages/python_plugin.py +1636 -0
- tree_sitter_analyzer/languages/ruby_plugin.py +757 -0
- tree_sitter_analyzer/languages/rust_plugin.py +673 -0
- tree_sitter_analyzer/languages/sql_plugin.py +2444 -0
- tree_sitter_analyzer/languages/typescript_plugin.py +1892 -0
- tree_sitter_analyzer/languages/yaml_plugin.py +695 -0
- tree_sitter_analyzer/legacy_table_formatter.py +860 -0
- tree_sitter_analyzer/mcp/__init__.py +34 -0
- tree_sitter_analyzer/mcp/resources/__init__.py +43 -0
- tree_sitter_analyzer/mcp/resources/code_file_resource.py +208 -0
- tree_sitter_analyzer/mcp/resources/project_stats_resource.py +586 -0
- tree_sitter_analyzer/mcp/server.py +869 -0
- tree_sitter_analyzer/mcp/tools/__init__.py +28 -0
- tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +779 -0
- tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py +291 -0
- tree_sitter_analyzer/mcp/tools/base_tool.py +139 -0
- tree_sitter_analyzer/mcp/tools/fd_rg_utils.py +816 -0
- tree_sitter_analyzer/mcp/tools/find_and_grep_tool.py +686 -0
- tree_sitter_analyzer/mcp/tools/list_files_tool.py +413 -0
- tree_sitter_analyzer/mcp/tools/output_format_validator.py +148 -0
- tree_sitter_analyzer/mcp/tools/query_tool.py +443 -0
- tree_sitter_analyzer/mcp/tools/read_partial_tool.py +464 -0
- tree_sitter_analyzer/mcp/tools/search_content_tool.py +836 -0
- tree_sitter_analyzer/mcp/tools/table_format_tool.py +572 -0
- tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py +653 -0
- tree_sitter_analyzer/mcp/utils/__init__.py +113 -0
- tree_sitter_analyzer/mcp/utils/error_handler.py +569 -0
- tree_sitter_analyzer/mcp/utils/file_output_factory.py +217 -0
- tree_sitter_analyzer/mcp/utils/file_output_manager.py +322 -0
- tree_sitter_analyzer/mcp/utils/gitignore_detector.py +358 -0
- tree_sitter_analyzer/mcp/utils/path_resolver.py +414 -0
- tree_sitter_analyzer/mcp/utils/search_cache.py +343 -0
- tree_sitter_analyzer/models.py +840 -0
- tree_sitter_analyzer/mypy_current_errors.txt +2 -0
- tree_sitter_analyzer/output_manager.py +255 -0
- tree_sitter_analyzer/platform_compat/__init__.py +3 -0
- tree_sitter_analyzer/platform_compat/adapter.py +324 -0
- tree_sitter_analyzer/platform_compat/compare.py +224 -0
- tree_sitter_analyzer/platform_compat/detector.py +67 -0
- tree_sitter_analyzer/platform_compat/fixtures.py +228 -0
- tree_sitter_analyzer/platform_compat/profiles.py +217 -0
- tree_sitter_analyzer/platform_compat/record.py +55 -0
- tree_sitter_analyzer/platform_compat/recorder.py +155 -0
- tree_sitter_analyzer/platform_compat/report.py +92 -0
- tree_sitter_analyzer/plugins/__init__.py +280 -0
- tree_sitter_analyzer/plugins/base.py +647 -0
- tree_sitter_analyzer/plugins/manager.py +384 -0
- tree_sitter_analyzer/project_detector.py +328 -0
- tree_sitter_analyzer/queries/__init__.py +27 -0
- tree_sitter_analyzer/queries/csharp.py +216 -0
- tree_sitter_analyzer/queries/css.py +615 -0
- tree_sitter_analyzer/queries/go.py +275 -0
- tree_sitter_analyzer/queries/html.py +543 -0
- tree_sitter_analyzer/queries/java.py +402 -0
- tree_sitter_analyzer/queries/javascript.py +724 -0
- tree_sitter_analyzer/queries/kotlin.py +192 -0
- tree_sitter_analyzer/queries/markdown.py +258 -0
- tree_sitter_analyzer/queries/php.py +95 -0
- tree_sitter_analyzer/queries/python.py +859 -0
- tree_sitter_analyzer/queries/ruby.py +92 -0
- tree_sitter_analyzer/queries/rust.py +223 -0
- tree_sitter_analyzer/queries/sql.py +555 -0
- tree_sitter_analyzer/queries/typescript.py +871 -0
- tree_sitter_analyzer/queries/yaml.py +236 -0
- tree_sitter_analyzer/query_loader.py +272 -0
- tree_sitter_analyzer/security/__init__.py +22 -0
- tree_sitter_analyzer/security/boundary_manager.py +277 -0
- tree_sitter_analyzer/security/regex_checker.py +297 -0
- tree_sitter_analyzer/security/validator.py +599 -0
- tree_sitter_analyzer/table_formatter.py +782 -0
- tree_sitter_analyzer/utils/__init__.py +53 -0
- tree_sitter_analyzer/utils/logging.py +433 -0
- tree_sitter_analyzer/utils/tree_sitter_compat.py +289 -0
- tree_sitter_analyzer-1.9.17.1.dist-info/METADATA +485 -0
- tree_sitter_analyzer-1.9.17.1.dist-info/RECORD +149 -0
- tree_sitter_analyzer-1.9.17.1.dist-info/WHEEL +4 -0
- tree_sitter_analyzer-1.9.17.1.dist-info/entry_points.txt +25 -0
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Java Language Queries
|
|
4
|
+
|
|
5
|
+
Tree-sitter queries specific to Java language constructs.
|
|
6
|
+
Covers classes, methods, annotations, imports, and other Java-specific elements.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Java-specific query library
|
|
10
|
+
JAVA_QUERIES: dict[str, str] = {
|
|
11
|
+
# --- Basic Structure ---
|
|
12
|
+
"class": """
|
|
13
|
+
(class_declaration) @class
|
|
14
|
+
""",
|
|
15
|
+
"interface": """
|
|
16
|
+
(interface_declaration) @interface
|
|
17
|
+
""",
|
|
18
|
+
"enum": """
|
|
19
|
+
(enum_declaration) @enum
|
|
20
|
+
""",
|
|
21
|
+
"annotation_type": """
|
|
22
|
+
(annotation_type_declaration) @annotation_type
|
|
23
|
+
""",
|
|
24
|
+
# --- Methods and Constructors ---
|
|
25
|
+
"method": """
|
|
26
|
+
(method_declaration) @method
|
|
27
|
+
""",
|
|
28
|
+
"constructor": """
|
|
29
|
+
(constructor_declaration) @constructor
|
|
30
|
+
""",
|
|
31
|
+
"abstract_method": """
|
|
32
|
+
(method_declaration
|
|
33
|
+
(modifiers) @mod
|
|
34
|
+
(#match? @mod "abstract")) @abstract_method
|
|
35
|
+
""",
|
|
36
|
+
# --- Fields and Variables ---
|
|
37
|
+
"field": """
|
|
38
|
+
(field_declaration) @field
|
|
39
|
+
""",
|
|
40
|
+
"static_field": """
|
|
41
|
+
(field_declaration
|
|
42
|
+
(modifiers) @mod
|
|
43
|
+
(#match? @mod "static")) @static_field
|
|
44
|
+
""",
|
|
45
|
+
"final_field": """
|
|
46
|
+
(field_declaration
|
|
47
|
+
(modifiers) @mod
|
|
48
|
+
(#match? @mod "final")) @final_field
|
|
49
|
+
""",
|
|
50
|
+
# --- Imports and Packages ---
|
|
51
|
+
"import": """
|
|
52
|
+
(import_declaration) @import
|
|
53
|
+
""",
|
|
54
|
+
"static_import": """
|
|
55
|
+
(import_declaration
|
|
56
|
+
"static") @static_import
|
|
57
|
+
""",
|
|
58
|
+
"package": """
|
|
59
|
+
(package_declaration) @package
|
|
60
|
+
""",
|
|
61
|
+
# --- Annotations ---
|
|
62
|
+
"annotation": """
|
|
63
|
+
(annotation) @annotation
|
|
64
|
+
""",
|
|
65
|
+
"marker_annotation": """
|
|
66
|
+
(marker_annotation) @marker_annotation
|
|
67
|
+
""",
|
|
68
|
+
"annotation_with_params": """
|
|
69
|
+
(annotation
|
|
70
|
+
(annotation_argument_list)) @annotation_with_params
|
|
71
|
+
""",
|
|
72
|
+
# --- Java-specific Constructs ---
|
|
73
|
+
"lambda": """
|
|
74
|
+
(lambda_expression) @lambda
|
|
75
|
+
""",
|
|
76
|
+
"try_catch": """
|
|
77
|
+
(try_statement) @try_catch
|
|
78
|
+
""",
|
|
79
|
+
"synchronized_block": """
|
|
80
|
+
(synchronized_statement) @synchronized_block
|
|
81
|
+
""",
|
|
82
|
+
"generic_type": """
|
|
83
|
+
(generic_type) @generic_type
|
|
84
|
+
""",
|
|
85
|
+
# --- Name-only Extraction ---
|
|
86
|
+
"class_name": """
|
|
87
|
+
(class_declaration
|
|
88
|
+
name: (identifier) @class_name)
|
|
89
|
+
""",
|
|
90
|
+
"method_name": """
|
|
91
|
+
(method_declaration
|
|
92
|
+
name: (identifier) @method_name)
|
|
93
|
+
""",
|
|
94
|
+
"field_name": """
|
|
95
|
+
(field_declaration
|
|
96
|
+
declarator: (variable_declarator
|
|
97
|
+
name: (identifier) @field_name))
|
|
98
|
+
""",
|
|
99
|
+
# --- Detailed Queries ---
|
|
100
|
+
"class_with_body": """
|
|
101
|
+
(class_declaration
|
|
102
|
+
name: (identifier) @name
|
|
103
|
+
body: (class_body) @body) @class_with_body
|
|
104
|
+
""",
|
|
105
|
+
"method_with_body": """
|
|
106
|
+
(method_declaration
|
|
107
|
+
name: (identifier) @name
|
|
108
|
+
body: (block) @body) @method_with_body
|
|
109
|
+
""",
|
|
110
|
+
# Fixed: Match methods WITH annotations (at least one required)
|
|
111
|
+
# Uses alternation [(annotation) (marker_annotation)] to match both types:
|
|
112
|
+
# - marker_annotation: Annotations without parameters (e.g., @Override)
|
|
113
|
+
# - annotation: Annotations with parameters (e.g., @SuppressWarnings("unchecked"))
|
|
114
|
+
# The + quantifier requires at least one annotation
|
|
115
|
+
"method_with_annotations": """
|
|
116
|
+
(method_declaration
|
|
117
|
+
(modifiers
|
|
118
|
+
[(annotation) (marker_annotation)]+ @annotation)
|
|
119
|
+
name: (identifier) @name) @method
|
|
120
|
+
""",
|
|
121
|
+
# --- Inheritance Relations ---
|
|
122
|
+
"extends_clause": """
|
|
123
|
+
(class_declaration
|
|
124
|
+
(superclass) @extends_clause)
|
|
125
|
+
""",
|
|
126
|
+
"implements_clause": """
|
|
127
|
+
(class_declaration
|
|
128
|
+
(super_interfaces) @implements_clause)
|
|
129
|
+
""",
|
|
130
|
+
# --- By Modifiers ---
|
|
131
|
+
"public_methods": """
|
|
132
|
+
(method_declaration
|
|
133
|
+
(modifiers) @mod
|
|
134
|
+
(#match? @mod "public")
|
|
135
|
+
name: (identifier) @name) @public_methods
|
|
136
|
+
""",
|
|
137
|
+
"private_methods": """
|
|
138
|
+
(method_declaration
|
|
139
|
+
(modifiers) @mod
|
|
140
|
+
(#match? @mod "private")
|
|
141
|
+
name: (identifier) @name) @private_methods
|
|
142
|
+
""",
|
|
143
|
+
"static_methods": """
|
|
144
|
+
(method_declaration
|
|
145
|
+
(modifiers) @mod
|
|
146
|
+
(#match? @mod "static")
|
|
147
|
+
name: (identifier) @name) @static_methods
|
|
148
|
+
""",
|
|
149
|
+
# --- Spring Framework Annotations ---
|
|
150
|
+
"spring_controller": """
|
|
151
|
+
(class_declaration
|
|
152
|
+
(modifiers (annotation
|
|
153
|
+
name: (identifier) @annotation_name
|
|
154
|
+
(#match? @annotation_name "Controller|RestController")))
|
|
155
|
+
name: (identifier) @controller_name) @spring_controller
|
|
156
|
+
""",
|
|
157
|
+
"spring_service": """
|
|
158
|
+
(class_declaration
|
|
159
|
+
(modifiers (annotation
|
|
160
|
+
name: (identifier) @annotation_name
|
|
161
|
+
(#match? @annotation_name "Service")))
|
|
162
|
+
name: (identifier) @service_name) @spring_service
|
|
163
|
+
""",
|
|
164
|
+
"spring_repository": """
|
|
165
|
+
(class_declaration
|
|
166
|
+
(modifiers (annotation
|
|
167
|
+
name: (identifier) @annotation_name
|
|
168
|
+
(#match? @annotation_name "Repository")))
|
|
169
|
+
name: (identifier) @repository_name) @spring_repository
|
|
170
|
+
""",
|
|
171
|
+
# --- JPA Annotations ---
|
|
172
|
+
"jpa_entity": """
|
|
173
|
+
(class_declaration
|
|
174
|
+
(modifiers (annotation
|
|
175
|
+
name: (identifier) @annotation_name
|
|
176
|
+
(#match? @annotation_name "Entity")))
|
|
177
|
+
name: (identifier) @entity_name) @jpa_entity
|
|
178
|
+
""",
|
|
179
|
+
"jpa_id_field": """
|
|
180
|
+
(field_declaration
|
|
181
|
+
(modifiers (annotation
|
|
182
|
+
name: (identifier) @annotation_name
|
|
183
|
+
(#match? @annotation_name "Id")))
|
|
184
|
+
declarator: (variable_declarator
|
|
185
|
+
name: (identifier) @field_name)) @jpa_id_field
|
|
186
|
+
""",
|
|
187
|
+
# --- Structural Information Extraction Queries ---
|
|
188
|
+
"javadoc_comment": """
|
|
189
|
+
(block_comment) @javadoc_comment
|
|
190
|
+
(#match? @javadoc_comment "^/\\\\\\\\\\\\*\\\\\\\\\\\\*")
|
|
191
|
+
""",
|
|
192
|
+
"class_with_javadoc": """
|
|
193
|
+
(class_declaration
|
|
194
|
+
name: (identifier) @class_name
|
|
195
|
+
body: (class_body) @class_body) @class_with_javadoc
|
|
196
|
+
""",
|
|
197
|
+
"method_with_javadoc": """
|
|
198
|
+
(method_declaration
|
|
199
|
+
name: (identifier) @method_name
|
|
200
|
+
parameters: (formal_parameters) @parameters
|
|
201
|
+
body: (block) @method_body) @method_with_javadoc
|
|
202
|
+
""",
|
|
203
|
+
"field_with_javadoc": """
|
|
204
|
+
(field_declaration
|
|
205
|
+
type: (_) @field_type
|
|
206
|
+
declarator: (variable_declarator
|
|
207
|
+
name: (identifier) @field_name)) @field_with_javadoc
|
|
208
|
+
""",
|
|
209
|
+
"method_parameters_detailed": """
|
|
210
|
+
(method_declaration
|
|
211
|
+
name: (identifier) @method_name
|
|
212
|
+
parameters: (formal_parameters
|
|
213
|
+
(formal_parameter
|
|
214
|
+
type: (_) @param_type
|
|
215
|
+
name: (identifier) @param_name)*) @parameters) @method_parameters_detailed
|
|
216
|
+
""",
|
|
217
|
+
"class_inheritance_detailed": """
|
|
218
|
+
(class_declaration
|
|
219
|
+
name: (identifier) @class_name
|
|
220
|
+
(superclass
|
|
221
|
+
(type_identifier) @extends_class)?
|
|
222
|
+
(super_interfaces
|
|
223
|
+
(interface_type_list
|
|
224
|
+
(type_identifier) @implements_interface)*)?
|
|
225
|
+
body: (class_body) @class_body) @class_inheritance_detailed
|
|
226
|
+
""",
|
|
227
|
+
"annotation_detailed": """
|
|
228
|
+
(annotation
|
|
229
|
+
name: (identifier) @annotation_name
|
|
230
|
+
(annotation_argument_list
|
|
231
|
+
(element_value_pair
|
|
232
|
+
key: (identifier) @param_key
|
|
233
|
+
value: (_) @param_value)*)?
|
|
234
|
+
) @annotation_detailed
|
|
235
|
+
""",
|
|
236
|
+
"import_detailed": """
|
|
237
|
+
(import_declaration
|
|
238
|
+
"static"? @static_modifier
|
|
239
|
+
(scoped_identifier) @import_path) @import_detailed
|
|
240
|
+
""",
|
|
241
|
+
"package_detailed": """
|
|
242
|
+
(package_declaration
|
|
243
|
+
(scoped_identifier) @package_name) @package_detailed
|
|
244
|
+
""",
|
|
245
|
+
"constructor_detailed": """
|
|
246
|
+
(constructor_declaration
|
|
247
|
+
name: (identifier) @constructor_name
|
|
248
|
+
parameters: (formal_parameters) @parameters
|
|
249
|
+
body: (constructor_body) @constructor_body) @constructor_detailed
|
|
250
|
+
""",
|
|
251
|
+
"enum_constant": """
|
|
252
|
+
(enum_declaration
|
|
253
|
+
body: (enum_body
|
|
254
|
+
(enum_constant
|
|
255
|
+
name: (identifier) @constant_name)*)) @enum_constant
|
|
256
|
+
""",
|
|
257
|
+
"interface_method": """
|
|
258
|
+
(interface_declaration
|
|
259
|
+
body: (interface_body
|
|
260
|
+
(method_declaration
|
|
261
|
+
name: (identifier) @method_name
|
|
262
|
+
parameters: (formal_parameters) @parameters)*)) @interface_method
|
|
263
|
+
""",
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
# Query descriptions
|
|
267
|
+
JAVA_QUERY_DESCRIPTIONS: dict[str, str] = {
|
|
268
|
+
"class": "Extract Java class declarations",
|
|
269
|
+
"interface": "Extract Java interface declarations",
|
|
270
|
+
"enum": "Extract Java enum declarations",
|
|
271
|
+
"annotation_type": "Extract Java annotation type declarations",
|
|
272
|
+
"method": "Extract Java method declarations",
|
|
273
|
+
"constructor": "Extract Java constructor declarations",
|
|
274
|
+
"field": "Extract Java field declarations",
|
|
275
|
+
"import": "Extract Java import statements",
|
|
276
|
+
"package": "Extract Java package declarations",
|
|
277
|
+
"annotation": "Extract Java annotations",
|
|
278
|
+
"lambda": "Extract Java lambda expressions",
|
|
279
|
+
"try_catch": "Extract Java try-catch statements",
|
|
280
|
+
"class_name": "Extract class names only",
|
|
281
|
+
"method_name": "Extract method names only",
|
|
282
|
+
"field_name": "Extract field names only",
|
|
283
|
+
"class_with_body": "Extract class declarations with body",
|
|
284
|
+
"method_with_body": "Extract method declarations with body",
|
|
285
|
+
"extends_clause": "Extract class inheritance clauses",
|
|
286
|
+
"implements_clause": "Extract class implementation clauses",
|
|
287
|
+
"public_methods": "Extract public methods",
|
|
288
|
+
"private_methods": "Extract private methods",
|
|
289
|
+
"static_methods": "Extract static methods",
|
|
290
|
+
# Structural information extraction query descriptions
|
|
291
|
+
"javadoc_comment": "Extract JavaDoc comments",
|
|
292
|
+
"class_with_javadoc": "Extract classes with JavaDoc",
|
|
293
|
+
"method_with_javadoc": "Extract methods with JavaDoc",
|
|
294
|
+
"field_with_javadoc": "Extract fields with JavaDoc",
|
|
295
|
+
"method_parameters_detailed": "Extract detailed method parameter information",
|
|
296
|
+
"class_inheritance_detailed": "Extract detailed class inheritance relationships",
|
|
297
|
+
"annotation_detailed": "Extract detailed annotation information",
|
|
298
|
+
"import_detailed": "Extract detailed import statement information",
|
|
299
|
+
"package_detailed": "Extract detailed package declaration information",
|
|
300
|
+
"constructor_detailed": "Extract detailed constructor information",
|
|
301
|
+
"enum_constant": "Extract enum constants",
|
|
302
|
+
"interface_method": "Extract interface methods",
|
|
303
|
+
"spring_controller": "Extract Spring Controller classes",
|
|
304
|
+
"spring_service": "Extract Spring Service classes",
|
|
305
|
+
"spring_repository": "Extract Spring Repository classes",
|
|
306
|
+
"jpa_entity": "Extract JPA Entity classes",
|
|
307
|
+
"abstract_method": "Extract abstract methods",
|
|
308
|
+
"static_field": "Extract static fields",
|
|
309
|
+
"final_field": "Extract final fields",
|
|
310
|
+
"static_import": "Extract static import statements",
|
|
311
|
+
"marker_annotation": "Extract marker annotations",
|
|
312
|
+
"annotation_with_params": "Extract annotations with parameters",
|
|
313
|
+
"synchronized_block": "Extract synchronized statements",
|
|
314
|
+
"generic_type": "Extract generic types",
|
|
315
|
+
"method_with_annotations": "Extract methods with annotations",
|
|
316
|
+
"jpa_id_field": "Extract JPA ID fields",
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def get_java_query(name: str) -> str:
|
|
321
|
+
"""
|
|
322
|
+
Get the specified Java query
|
|
323
|
+
|
|
324
|
+
Args:
|
|
325
|
+
name: Query name
|
|
326
|
+
|
|
327
|
+
Returns:
|
|
328
|
+
Query string
|
|
329
|
+
|
|
330
|
+
Raises:
|
|
331
|
+
ValueError: When query is not found
|
|
332
|
+
"""
|
|
333
|
+
if name not in JAVA_QUERIES:
|
|
334
|
+
available = list(JAVA_QUERIES.keys())
|
|
335
|
+
raise ValueError(f"Java query '{name}' does not exist. Available: {available}")
|
|
336
|
+
|
|
337
|
+
return JAVA_QUERIES[name]
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
def get_java_query_description(name: str) -> str:
|
|
341
|
+
"""
|
|
342
|
+
Get the description of the specified Java query
|
|
343
|
+
|
|
344
|
+
Args:
|
|
345
|
+
name: Query name
|
|
346
|
+
|
|
347
|
+
Returns:
|
|
348
|
+
Query description
|
|
349
|
+
"""
|
|
350
|
+
return JAVA_QUERY_DESCRIPTIONS.get(name, "No description")
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
# Convert to ALL_QUERIES format for dynamic loader compatibility
|
|
354
|
+
ALL_QUERIES = {}
|
|
355
|
+
for query_name, query_string in JAVA_QUERIES.items():
|
|
356
|
+
description = JAVA_QUERY_DESCRIPTIONS.get(query_name, "No description")
|
|
357
|
+
ALL_QUERIES[query_name] = {"query": query_string, "description": description}
|
|
358
|
+
|
|
359
|
+
# Add common query aliases for cross-language compatibility
|
|
360
|
+
ALL_QUERIES["functions"] = {
|
|
361
|
+
"query": JAVA_QUERIES["method"],
|
|
362
|
+
"description": "Search all function/method declarations (alias for method)",
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
ALL_QUERIES["methods"] = {
|
|
366
|
+
"query": JAVA_QUERIES["method"],
|
|
367
|
+
"description": "Search all method declarations (alias for method)",
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
ALL_QUERIES["classes"] = {
|
|
371
|
+
"query": JAVA_QUERIES["class"],
|
|
372
|
+
"description": "Search all class declarations (alias for class)",
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
def get_query(name: str) -> str:
|
|
377
|
+
"""Get a specific query by name."""
|
|
378
|
+
if name in ALL_QUERIES:
|
|
379
|
+
return ALL_QUERIES[name]["query"]
|
|
380
|
+
raise ValueError(
|
|
381
|
+
f"Query '{name}' not found. Available queries: {list(ALL_QUERIES.keys())}"
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
def get_all_queries() -> dict:
|
|
386
|
+
"""Get all available queries."""
|
|
387
|
+
return ALL_QUERIES
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
def list_queries() -> list:
|
|
391
|
+
"""List all available query names."""
|
|
392
|
+
return list(ALL_QUERIES.keys())
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
def get_available_java_queries() -> list[str]:
|
|
396
|
+
"""
|
|
397
|
+
Get list of available Java queries
|
|
398
|
+
|
|
399
|
+
Returns:
|
|
400
|
+
List of query names
|
|
401
|
+
"""
|
|
402
|
+
return list(JAVA_QUERIES.keys())
|