tree-sitter-analyzer 0.4.0__py3-none-any.whl → 0.6.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.
Potentially problematic release.
This version of tree-sitter-analyzer might be problematic. Click here for more details.
- tree_sitter_analyzer/__init__.py +1 -3
- tree_sitter_analyzer/__main__.py +2 -2
- tree_sitter_analyzer/cli/commands/default_command.py +1 -1
- tree_sitter_analyzer/cli/commands/query_command.py +5 -5
- tree_sitter_analyzer/cli/commands/table_command.py +3 -3
- tree_sitter_analyzer/cli/info_commands.py +14 -13
- tree_sitter_analyzer/cli_main.py +49 -30
- tree_sitter_analyzer/core/analysis_engine.py +21 -21
- tree_sitter_analyzer/core/cache_service.py +31 -31
- tree_sitter_analyzer/core/query.py +502 -502
- tree_sitter_analyzer/encoding_utils.py +5 -2
- tree_sitter_analyzer/file_handler.py +3 -3
- tree_sitter_analyzer/formatters/base_formatter.py +18 -18
- tree_sitter_analyzer/formatters/formatter_factory.py +15 -15
- tree_sitter_analyzer/formatters/java_formatter.py +291 -291
- tree_sitter_analyzer/formatters/python_formatter.py +259 -259
- tree_sitter_analyzer/interfaces/cli_adapter.py +32 -32
- tree_sitter_analyzer/interfaces/mcp_adapter.py +2 -2
- tree_sitter_analyzer/language_detector.py +398 -398
- tree_sitter_analyzer/language_loader.py +224 -224
- tree_sitter_analyzer/languages/java_plugin.py +1174 -1174
- tree_sitter_analyzer/languages/python_plugin.py +10 -2
- tree_sitter_analyzer/mcp/resources/project_stats_resource.py +555 -555
- tree_sitter_analyzer/models.py +470 -470
- tree_sitter_analyzer/output_manager.py +8 -10
- tree_sitter_analyzer/plugins/base.py +33 -0
- tree_sitter_analyzer/queries/java.py +78 -78
- tree_sitter_analyzer/queries/javascript.py +7 -7
- tree_sitter_analyzer/queries/python.py +18 -18
- tree_sitter_analyzer/queries/typescript.py +12 -12
- tree_sitter_analyzer/query_loader.py +13 -13
- tree_sitter_analyzer/table_formatter.py +20 -18
- tree_sitter_analyzer/utils.py +1 -1
- {tree_sitter_analyzer-0.4.0.dist-info → tree_sitter_analyzer-0.6.1.dist-info}/METADATA +10 -10
- {tree_sitter_analyzer-0.4.0.dist-info → tree_sitter_analyzer-0.6.1.dist-info}/RECORD +37 -38
- tree_sitter_analyzer/java_analyzer.py +0 -187
- {tree_sitter_analyzer-0.4.0.dist-info → tree_sitter_analyzer-0.6.1.dist-info}/WHEEL +0 -0
- {tree_sitter_analyzer-0.4.0.dist-info → tree_sitter_analyzer-0.6.1.dist-info}/entry_points.txt +0 -0
|
@@ -86,22 +86,22 @@ class OutputManager:
|
|
|
86
86
|
f"\n{index}. {result.get('capture_name', 'Unknown')} ({result.get('node_type', 'Unknown')})"
|
|
87
87
|
)
|
|
88
88
|
print(
|
|
89
|
-
f"
|
|
89
|
+
f" Position: Line {result.get('start_line', '?')}-{result.get('end_line', '?')}"
|
|
90
90
|
)
|
|
91
91
|
if "content" in result:
|
|
92
|
-
print(f"
|
|
92
|
+
print(f" Content:\n{result['content']}")
|
|
93
93
|
|
|
94
94
|
def analysis_summary(self, stats: dict[str, Any]) -> None:
|
|
95
95
|
"""Output analysis summary"""
|
|
96
96
|
if self.json_output:
|
|
97
97
|
self.data(stats)
|
|
98
98
|
else:
|
|
99
|
-
self.results_header("
|
|
99
|
+
self.results_header("Statistics")
|
|
100
100
|
for key, value in stats.items():
|
|
101
101
|
print(f"{key}: {value}")
|
|
102
102
|
|
|
103
103
|
def language_list(
|
|
104
|
-
self, languages: list[str], title: str = "
|
|
104
|
+
self, languages: list[str], title: str = "Supported Languages"
|
|
105
105
|
) -> None:
|
|
106
106
|
"""Output language list"""
|
|
107
107
|
if not self.quiet:
|
|
@@ -112,18 +112,18 @@ class OutputManager:
|
|
|
112
112
|
def query_list(self, queries: dict[str, str], language: str) -> None:
|
|
113
113
|
"""Output query list for a language"""
|
|
114
114
|
if not self.quiet:
|
|
115
|
-
print(f"
|
|
115
|
+
print(f"Available query keys ({language}):")
|
|
116
116
|
for query_key, description in queries.items():
|
|
117
117
|
print(f" {query_key:<20} - {description}")
|
|
118
118
|
|
|
119
119
|
def extension_list(self, extensions: list[str]) -> None:
|
|
120
120
|
"""Output supported extensions"""
|
|
121
121
|
if not self.quiet:
|
|
122
|
-
print("
|
|
122
|
+
print("Supported file extensions:")
|
|
123
123
|
for i in range(0, len(extensions), 10):
|
|
124
124
|
chunk = extensions[i : i + 10]
|
|
125
125
|
print(f" {' '.join(chunk)}")
|
|
126
|
-
print(f"
|
|
126
|
+
print(f"Total {len(extensions)} extensions supported")
|
|
127
127
|
|
|
128
128
|
def output_json(self, data: Any) -> None:
|
|
129
129
|
"""Output JSON data"""
|
|
@@ -232,9 +232,7 @@ def output_statistics(stats: dict[str, Any]) -> None:
|
|
|
232
232
|
_output_manager.output_statistics(stats)
|
|
233
233
|
|
|
234
234
|
|
|
235
|
-
def output_languages(
|
|
236
|
-
languages: list[str], title: str = "サポートされている言語"
|
|
237
|
-
) -> None:
|
|
235
|
+
def output_languages(languages: list[str], title: str = "Supported Languages") -> None:
|
|
238
236
|
"""Output available languages"""
|
|
239
237
|
_output_manager.language_list(languages, title)
|
|
240
238
|
|
|
@@ -494,3 +494,36 @@ class DefaultLanguagePlugin(LanguagePlugin):
|
|
|
494
494
|
|
|
495
495
|
def create_extractor(self) -> ElementExtractor:
|
|
496
496
|
return DefaultExtractor()
|
|
497
|
+
|
|
498
|
+
async def analyze_file(
|
|
499
|
+
self, file_path: str, request: "AnalysisRequest"
|
|
500
|
+
) -> "AnalysisResult":
|
|
501
|
+
"""
|
|
502
|
+
Analyze a file using the default extractor.
|
|
503
|
+
|
|
504
|
+
Args:
|
|
505
|
+
file_path: Path to the file to analyze
|
|
506
|
+
request: Analysis request with configuration
|
|
507
|
+
|
|
508
|
+
Returns:
|
|
509
|
+
AnalysisResult containing extracted information
|
|
510
|
+
"""
|
|
511
|
+
from ..core.analysis_engine import UnifiedAnalysisEngine
|
|
512
|
+
from ..models import AnalysisResult
|
|
513
|
+
|
|
514
|
+
try:
|
|
515
|
+
engine = UnifiedAnalysisEngine()
|
|
516
|
+
return await engine.analyze_file(file_path)
|
|
517
|
+
except Exception as e:
|
|
518
|
+
log_error(f"Failed to analyze file {file_path}: {e}")
|
|
519
|
+
return AnalysisResult(
|
|
520
|
+
file_path=file_path,
|
|
521
|
+
language=self.get_language_name(),
|
|
522
|
+
line_count=0,
|
|
523
|
+
elements=[],
|
|
524
|
+
node_count=0,
|
|
525
|
+
query_results={},
|
|
526
|
+
source_code="",
|
|
527
|
+
success=False,
|
|
528
|
+
error_message=str(e),
|
|
529
|
+
)
|
|
@@ -6,9 +6,9 @@ Tree-sitter queries specific to Java language constructs.
|
|
|
6
6
|
Covers classes, methods, annotations, imports, and other Java-specific elements.
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
-
# Java
|
|
9
|
+
# Java-specific query library
|
|
10
10
|
JAVA_QUERIES: dict[str, str] = {
|
|
11
|
-
# ---
|
|
11
|
+
# --- Basic Structure ---
|
|
12
12
|
"class": """
|
|
13
13
|
(class_declaration) @class
|
|
14
14
|
""",
|
|
@@ -21,7 +21,7 @@ JAVA_QUERIES: dict[str, str] = {
|
|
|
21
21
|
"annotation_type": """
|
|
22
22
|
(annotation_type_declaration) @annotation_type
|
|
23
23
|
""",
|
|
24
|
-
# ---
|
|
24
|
+
# --- Methods and Constructors ---
|
|
25
25
|
"method": """
|
|
26
26
|
(method_declaration) @method
|
|
27
27
|
""",
|
|
@@ -33,7 +33,7 @@ JAVA_QUERIES: dict[str, str] = {
|
|
|
33
33
|
(modifiers) @mod
|
|
34
34
|
(#match? @mod "abstract")) @abstract_method
|
|
35
35
|
""",
|
|
36
|
-
# ---
|
|
36
|
+
# --- Fields and Variables ---
|
|
37
37
|
"field": """
|
|
38
38
|
(field_declaration) @field
|
|
39
39
|
""",
|
|
@@ -47,7 +47,7 @@ JAVA_QUERIES: dict[str, str] = {
|
|
|
47
47
|
(modifiers) @mod
|
|
48
48
|
(#match? @mod "final")) @final_field
|
|
49
49
|
""",
|
|
50
|
-
# ---
|
|
50
|
+
# --- Imports and Packages ---
|
|
51
51
|
"import": """
|
|
52
52
|
(import_declaration) @import
|
|
53
53
|
""",
|
|
@@ -58,7 +58,7 @@ JAVA_QUERIES: dict[str, str] = {
|
|
|
58
58
|
"package": """
|
|
59
59
|
(package_declaration) @package
|
|
60
60
|
""",
|
|
61
|
-
# ---
|
|
61
|
+
# --- Annotations ---
|
|
62
62
|
"annotation": """
|
|
63
63
|
(annotation) @annotation
|
|
64
64
|
""",
|
|
@@ -69,7 +69,7 @@ JAVA_QUERIES: dict[str, str] = {
|
|
|
69
69
|
(annotation
|
|
70
70
|
(annotation_argument_list)) @annotation_with_params
|
|
71
71
|
""",
|
|
72
|
-
# --- Java
|
|
72
|
+
# --- Java-specific Constructs ---
|
|
73
73
|
"lambda": """
|
|
74
74
|
(lambda_expression) @lambda
|
|
75
75
|
""",
|
|
@@ -82,7 +82,7 @@ JAVA_QUERIES: dict[str, str] = {
|
|
|
82
82
|
"generic_type": """
|
|
83
83
|
(generic_type) @generic_type
|
|
84
84
|
""",
|
|
85
|
-
# ---
|
|
85
|
+
# --- Name-only Extraction ---
|
|
86
86
|
"class_name": """
|
|
87
87
|
(class_declaration
|
|
88
88
|
name: (identifier) @class_name)
|
|
@@ -96,7 +96,7 @@ JAVA_QUERIES: dict[str, str] = {
|
|
|
96
96
|
declarator: (variable_declarator
|
|
97
97
|
name: (identifier) @field_name))
|
|
98
98
|
""",
|
|
99
|
-
# ---
|
|
99
|
+
# --- Detailed Queries ---
|
|
100
100
|
"class_with_body": """
|
|
101
101
|
(class_declaration
|
|
102
102
|
name: (identifier) @name
|
|
@@ -112,7 +112,7 @@ JAVA_QUERIES: dict[str, str] = {
|
|
|
112
112
|
(modifiers (annotation) @annotation)*
|
|
113
113
|
name: (identifier) @name) @method_with_annotations
|
|
114
114
|
""",
|
|
115
|
-
# ---
|
|
115
|
+
# --- Inheritance Relations ---
|
|
116
116
|
"extends_clause": """
|
|
117
117
|
(class_declaration
|
|
118
118
|
(superclass) @extends_clause)
|
|
@@ -121,7 +121,7 @@ JAVA_QUERIES: dict[str, str] = {
|
|
|
121
121
|
(class_declaration
|
|
122
122
|
(super_interfaces) @implements_clause)
|
|
123
123
|
""",
|
|
124
|
-
# ---
|
|
124
|
+
# --- By Modifiers ---
|
|
125
125
|
"public_methods": """
|
|
126
126
|
(method_declaration
|
|
127
127
|
(modifiers) @mod
|
|
@@ -140,7 +140,7 @@ JAVA_QUERIES: dict[str, str] = {
|
|
|
140
140
|
(#match? @mod "static")
|
|
141
141
|
name: (identifier) @name) @static_methods
|
|
142
142
|
""",
|
|
143
|
-
# --- Spring Framework
|
|
143
|
+
# --- Spring Framework Annotations ---
|
|
144
144
|
"spring_controller": """
|
|
145
145
|
(class_declaration
|
|
146
146
|
(modifiers (annotation
|
|
@@ -162,7 +162,7 @@ JAVA_QUERIES: dict[str, str] = {
|
|
|
162
162
|
(#match? @annotation_name "Repository")))
|
|
163
163
|
name: (identifier) @repository_name) @spring_repository
|
|
164
164
|
""",
|
|
165
|
-
# --- JPA
|
|
165
|
+
# --- JPA Annotations ---
|
|
166
166
|
"jpa_entity": """
|
|
167
167
|
(class_declaration
|
|
168
168
|
(modifiers (annotation
|
|
@@ -178,7 +178,7 @@ JAVA_QUERIES: dict[str, str] = {
|
|
|
178
178
|
declarator: (variable_declarator
|
|
179
179
|
name: (identifier) @field_name)) @jpa_id_field
|
|
180
180
|
""",
|
|
181
|
-
# ---
|
|
181
|
+
# --- Structural Information Extraction Queries ---
|
|
182
182
|
"javadoc_comment": """
|
|
183
183
|
(block_comment) @javadoc_comment
|
|
184
184
|
(#match? @javadoc_comment "^/\\*\\*")
|
|
@@ -257,108 +257,108 @@ JAVA_QUERIES: dict[str, str] = {
|
|
|
257
257
|
""",
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
#
|
|
260
|
+
# Query descriptions
|
|
261
261
|
JAVA_QUERY_DESCRIPTIONS: dict[str, str] = {
|
|
262
|
-
"class": "Java
|
|
263
|
-
"interface": "Java
|
|
264
|
-
"enum": "Java
|
|
265
|
-
"annotation_type": "Java
|
|
266
|
-
"method": "Java
|
|
267
|
-
"constructor": "Java
|
|
268
|
-
"field": "Java
|
|
269
|
-
"import": "Java
|
|
270
|
-
"package": "Java
|
|
271
|
-
"annotation": "Java
|
|
272
|
-
"lambda": "Java
|
|
273
|
-
"try_catch": "Java try-catch
|
|
274
|
-
"class_name": "
|
|
275
|
-
"method_name": "
|
|
276
|
-
"field_name": "
|
|
277
|
-
"class_with_body": "
|
|
278
|
-
"method_with_body": "
|
|
279
|
-
"extends_clause": "
|
|
280
|
-
"implements_clause": "
|
|
281
|
-
"public_methods": "public
|
|
282
|
-
"private_methods": "private
|
|
283
|
-
"static_methods": "static
|
|
284
|
-
#
|
|
285
|
-
"javadoc_comment": "JavaDoc
|
|
286
|
-
"class_with_javadoc": "JavaDoc
|
|
287
|
-
"method_with_javadoc": "JavaDoc
|
|
288
|
-
"field_with_javadoc": "JavaDoc
|
|
289
|
-
"method_parameters_detailed": "
|
|
290
|
-
"class_inheritance_detailed": "
|
|
291
|
-
"annotation_detailed": "
|
|
292
|
-
"import_detailed": "
|
|
293
|
-
"package_detailed": "
|
|
294
|
-
"constructor_detailed": "
|
|
295
|
-
"enum_constant": "
|
|
296
|
-
"interface_method": "
|
|
297
|
-
"spring_controller": "Spring Controller
|
|
298
|
-
"spring_service": "Spring Service
|
|
299
|
-
"spring_repository": "Spring Repository
|
|
300
|
-
"jpa_entity": "JPA Entity
|
|
301
|
-
"abstract_method": "
|
|
302
|
-
"static_field": "
|
|
303
|
-
"final_field": "final
|
|
304
|
-
"static_import": "
|
|
305
|
-
"marker_annotation": "
|
|
306
|
-
"annotation_with_params": "
|
|
307
|
-
"synchronized_block": "synchronized
|
|
308
|
-
"generic_type": "
|
|
309
|
-
"method_with_annotations": "
|
|
310
|
-
"jpa_id_field": "JPA ID
|
|
262
|
+
"class": "Extract Java class declarations",
|
|
263
|
+
"interface": "Extract Java interface declarations",
|
|
264
|
+
"enum": "Extract Java enum declarations",
|
|
265
|
+
"annotation_type": "Extract Java annotation type declarations",
|
|
266
|
+
"method": "Extract Java method declarations",
|
|
267
|
+
"constructor": "Extract Java constructor declarations",
|
|
268
|
+
"field": "Extract Java field declarations",
|
|
269
|
+
"import": "Extract Java import statements",
|
|
270
|
+
"package": "Extract Java package declarations",
|
|
271
|
+
"annotation": "Extract Java annotations",
|
|
272
|
+
"lambda": "Extract Java lambda expressions",
|
|
273
|
+
"try_catch": "Extract Java try-catch statements",
|
|
274
|
+
"class_name": "Extract class names only",
|
|
275
|
+
"method_name": "Extract method names only",
|
|
276
|
+
"field_name": "Extract field names only",
|
|
277
|
+
"class_with_body": "Extract class declarations with body",
|
|
278
|
+
"method_with_body": "Extract method declarations with body",
|
|
279
|
+
"extends_clause": "Extract class inheritance clauses",
|
|
280
|
+
"implements_clause": "Extract class implementation clauses",
|
|
281
|
+
"public_methods": "Extract public methods",
|
|
282
|
+
"private_methods": "Extract private methods",
|
|
283
|
+
"static_methods": "Extract static methods",
|
|
284
|
+
# Structural information extraction query descriptions
|
|
285
|
+
"javadoc_comment": "Extract JavaDoc comments",
|
|
286
|
+
"class_with_javadoc": "Extract classes with JavaDoc",
|
|
287
|
+
"method_with_javadoc": "Extract methods with JavaDoc",
|
|
288
|
+
"field_with_javadoc": "Extract fields with JavaDoc",
|
|
289
|
+
"method_parameters_detailed": "Extract detailed method parameter information",
|
|
290
|
+
"class_inheritance_detailed": "Extract detailed class inheritance relationships",
|
|
291
|
+
"annotation_detailed": "Extract detailed annotation information",
|
|
292
|
+
"import_detailed": "Extract detailed import statement information",
|
|
293
|
+
"package_detailed": "Extract detailed package declaration information",
|
|
294
|
+
"constructor_detailed": "Extract detailed constructor information",
|
|
295
|
+
"enum_constant": "Extract enum constants",
|
|
296
|
+
"interface_method": "Extract interface methods",
|
|
297
|
+
"spring_controller": "Extract Spring Controller classes",
|
|
298
|
+
"spring_service": "Extract Spring Service classes",
|
|
299
|
+
"spring_repository": "Extract Spring Repository classes",
|
|
300
|
+
"jpa_entity": "Extract JPA Entity classes",
|
|
301
|
+
"abstract_method": "Extract abstract methods",
|
|
302
|
+
"static_field": "Extract static fields",
|
|
303
|
+
"final_field": "Extract final fields",
|
|
304
|
+
"static_import": "Extract static import statements",
|
|
305
|
+
"marker_annotation": "Extract marker annotations",
|
|
306
|
+
"annotation_with_params": "Extract annotations with parameters",
|
|
307
|
+
"synchronized_block": "Extract synchronized statements",
|
|
308
|
+
"generic_type": "Extract generic types",
|
|
309
|
+
"method_with_annotations": "Extract methods with annotations",
|
|
310
|
+
"jpa_id_field": "Extract JPA ID fields",
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
|
|
314
314
|
def get_java_query(name: str) -> str:
|
|
315
315
|
"""
|
|
316
|
-
|
|
316
|
+
Get the specified Java query
|
|
317
317
|
|
|
318
318
|
Args:
|
|
319
|
-
name:
|
|
319
|
+
name: Query name
|
|
320
320
|
|
|
321
321
|
Returns:
|
|
322
|
-
|
|
322
|
+
Query string
|
|
323
323
|
|
|
324
324
|
Raises:
|
|
325
|
-
ValueError:
|
|
325
|
+
ValueError: When query is not found
|
|
326
326
|
"""
|
|
327
327
|
if name not in JAVA_QUERIES:
|
|
328
328
|
available = list(JAVA_QUERIES.keys())
|
|
329
|
-
raise ValueError(f"Java
|
|
329
|
+
raise ValueError(f"Java query '{name}' does not exist. Available: {available}")
|
|
330
330
|
|
|
331
331
|
return JAVA_QUERIES[name]
|
|
332
332
|
|
|
333
333
|
|
|
334
334
|
def get_java_query_description(name: str) -> str:
|
|
335
335
|
"""
|
|
336
|
-
|
|
336
|
+
Get the description of the specified Java query
|
|
337
337
|
|
|
338
338
|
Args:
|
|
339
|
-
name:
|
|
339
|
+
name: Query name
|
|
340
340
|
|
|
341
341
|
Returns:
|
|
342
|
-
|
|
342
|
+
Query description
|
|
343
343
|
"""
|
|
344
|
-
return JAVA_QUERY_DESCRIPTIONS.get(name, "
|
|
344
|
+
return JAVA_QUERY_DESCRIPTIONS.get(name, "No description")
|
|
345
345
|
|
|
346
346
|
|
|
347
347
|
# Convert to ALL_QUERIES format for dynamic loader compatibility
|
|
348
348
|
ALL_QUERIES = {}
|
|
349
349
|
for query_name, query_string in JAVA_QUERIES.items():
|
|
350
|
-
description = JAVA_QUERY_DESCRIPTIONS.get(query_name, "
|
|
350
|
+
description = JAVA_QUERY_DESCRIPTIONS.get(query_name, "No description")
|
|
351
351
|
ALL_QUERIES[query_name] = {"query": query_string, "description": description}
|
|
352
352
|
|
|
353
353
|
# Add common query aliases for cross-language compatibility
|
|
354
354
|
ALL_QUERIES["functions"] = {
|
|
355
355
|
"query": JAVA_QUERIES["method"],
|
|
356
|
-
"description": "
|
|
356
|
+
"description": "Search all function/method declarations (alias for method)",
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
ALL_QUERIES["classes"] = {
|
|
360
360
|
"query": JAVA_QUERIES["class"],
|
|
361
|
-
"description": "
|
|
361
|
+
"description": "Search all class declarations (alias for class)",
|
|
362
362
|
}
|
|
363
363
|
|
|
364
364
|
|
|
@@ -383,9 +383,9 @@ def list_queries() -> list:
|
|
|
383
383
|
|
|
384
384
|
def get_available_java_queries() -> list[str]:
|
|
385
385
|
"""
|
|
386
|
-
|
|
386
|
+
Get list of available Java queries
|
|
387
387
|
|
|
388
388
|
Returns:
|
|
389
|
-
|
|
389
|
+
List of query names
|
|
390
390
|
"""
|
|
391
391
|
return list(JAVA_QUERIES.keys())
|
|
@@ -106,26 +106,26 @@ COMMENTS = """
|
|
|
106
106
|
ALL_QUERIES = {
|
|
107
107
|
"functions": {
|
|
108
108
|
"query": FUNCTIONS,
|
|
109
|
-
"description": "
|
|
109
|
+
"description": "Search all function declarations, expressions, and methods",
|
|
110
110
|
},
|
|
111
111
|
"classes": {
|
|
112
112
|
"query": CLASSES,
|
|
113
|
-
"description": "
|
|
113
|
+
"description": "Search all class declarations and expressions",
|
|
114
114
|
},
|
|
115
115
|
"variables": {
|
|
116
116
|
"query": VARIABLES,
|
|
117
|
-
"description": "
|
|
117
|
+
"description": "Search all variable declarations (var, let, const)",
|
|
118
118
|
},
|
|
119
119
|
"imports": {
|
|
120
120
|
"query": IMPORTS,
|
|
121
|
-
"description": "
|
|
121
|
+
"description": "Search all import statements and clauses",
|
|
122
122
|
},
|
|
123
|
-
"exports": {"query": EXPORTS, "description": "
|
|
123
|
+
"exports": {"query": EXPORTS, "description": "Search all export statements"},
|
|
124
124
|
"objects": {
|
|
125
125
|
"query": OBJECTS,
|
|
126
|
-
"description": "
|
|
126
|
+
"description": "Search object literals and property definitions",
|
|
127
127
|
},
|
|
128
|
-
"comments": {"query": COMMENTS, "description": "
|
|
128
|
+
"comments": {"query": COMMENTS, "description": "Search all comments"},
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
|
|
@@ -210,58 +210,58 @@ MODERN_PATTERNS = """
|
|
|
210
210
|
ALL_QUERIES = {
|
|
211
211
|
"functions": {
|
|
212
212
|
"query": FUNCTIONS,
|
|
213
|
-
"description": "
|
|
213
|
+
"description": "Search all function definitions (including async)",
|
|
214
214
|
},
|
|
215
|
-
"classes": {"query": CLASSES, "description": "
|
|
216
|
-
"imports": {"query": IMPORTS, "description": "
|
|
217
|
-
"variables": {"query": VARIABLES, "description": "
|
|
218
|
-
"decorators": {"query": DECORATORS, "description": "
|
|
215
|
+
"classes": {"query": CLASSES, "description": "Search all class definitions"},
|
|
216
|
+
"imports": {"query": IMPORTS, "description": "Search all import statements"},
|
|
217
|
+
"variables": {"query": VARIABLES, "description": "Search all variable assignments"},
|
|
218
|
+
"decorators": {"query": DECORATORS, "description": "Search all decorators"},
|
|
219
219
|
"methods": {
|
|
220
220
|
"query": METHODS,
|
|
221
|
-
"description": "
|
|
221
|
+
"description": "Search all method definitions within classes",
|
|
222
222
|
},
|
|
223
223
|
"exceptions": {
|
|
224
224
|
"query": EXCEPTIONS,
|
|
225
|
-
"description": "
|
|
225
|
+
"description": "Search exception handling and raise statements",
|
|
226
226
|
},
|
|
227
227
|
"comprehensions": {
|
|
228
228
|
"query": COMPREHENSIONS,
|
|
229
|
-
"description": "
|
|
229
|
+
"description": "Search list, dictionary, and set comprehensions",
|
|
230
230
|
},
|
|
231
|
-
"comments": {"query": COMMENTS, "description": "
|
|
231
|
+
"comments": {"query": COMMENTS, "description": "Search comments and docstrings"},
|
|
232
232
|
"type_hints": {
|
|
233
233
|
"query": TYPE_HINTS,
|
|
234
|
-
"description": "
|
|
234
|
+
"description": "Search type hints and annotations",
|
|
235
235
|
},
|
|
236
236
|
"async_patterns": {
|
|
237
237
|
"query": ASYNC_PATTERNS,
|
|
238
|
-
"description": "async/await
|
|
238
|
+
"description": "Search async/await patterns",
|
|
239
239
|
},
|
|
240
240
|
"string_formatting": {
|
|
241
241
|
"query": STRING_FORMATTING,
|
|
242
|
-
"description": "f
|
|
242
|
+
"description": "Search f-strings and string formatting",
|
|
243
243
|
},
|
|
244
244
|
"context_managers": {
|
|
245
245
|
"query": CONTEXT_MANAGERS,
|
|
246
|
-
"description": "
|
|
246
|
+
"description": "Search context managers (with statements)",
|
|
247
247
|
},
|
|
248
|
-
"lambdas": {"query": LAMBDAS, "description": "
|
|
248
|
+
"lambdas": {"query": LAMBDAS, "description": "Search lambda expressions"},
|
|
249
249
|
"modern_patterns": {
|
|
250
250
|
"query": MODERN_PATTERNS,
|
|
251
|
-
"description": "
|
|
251
|
+
"description": "Search modern Python patterns (match/case, walrus operator)",
|
|
252
252
|
},
|
|
253
253
|
# Convenience aliases
|
|
254
254
|
"function_names": {
|
|
255
255
|
"query": FUNCTIONS,
|
|
256
|
-
"description": "
|
|
256
|
+
"description": "Function alias - search all function definitions",
|
|
257
257
|
},
|
|
258
258
|
"class_names": {
|
|
259
259
|
"query": CLASSES,
|
|
260
|
-
"description": "
|
|
260
|
+
"description": "Class alias - search all class definitions",
|
|
261
261
|
},
|
|
262
262
|
"all_declarations": {
|
|
263
263
|
"query": FUNCTIONS + "\n\n" + CLASSES + "\n\n" + VARIABLES,
|
|
264
|
-
"description": "
|
|
264
|
+
"description": "Search all function, class, and variable declarations",
|
|
265
265
|
},
|
|
266
266
|
}
|
|
267
267
|
|
|
@@ -173,40 +173,40 @@ COMMENTS = """
|
|
|
173
173
|
ALL_QUERIES = {
|
|
174
174
|
"functions": {
|
|
175
175
|
"query": FUNCTIONS,
|
|
176
|
-
"description": "
|
|
176
|
+
"description": "Search all function declarations, expressions, and methods with type annotations",
|
|
177
177
|
},
|
|
178
178
|
"classes": {
|
|
179
179
|
"query": CLASSES,
|
|
180
|
-
"description": "
|
|
180
|
+
"description": "Search all class declarations including abstract classes",
|
|
181
181
|
},
|
|
182
182
|
"interfaces": {
|
|
183
183
|
"query": INTERFACES,
|
|
184
|
-
"description": "
|
|
184
|
+
"description": "Search all interface declarations",
|
|
185
185
|
},
|
|
186
186
|
"type_aliases": {
|
|
187
187
|
"query": TYPE_ALIASES,
|
|
188
|
-
"description": "
|
|
188
|
+
"description": "Search all type alias declarations",
|
|
189
189
|
},
|
|
190
|
-
"enums": {"query": ENUMS, "description": "
|
|
190
|
+
"enums": {"query": ENUMS, "description": "Search all enum declarations"},
|
|
191
191
|
"variables": {
|
|
192
192
|
"query": VARIABLES,
|
|
193
|
-
"description": "
|
|
193
|
+
"description": "Search all variable declarations with type annotations",
|
|
194
194
|
},
|
|
195
195
|
"imports": {
|
|
196
196
|
"query": IMPORTS,
|
|
197
|
-
"description": "
|
|
197
|
+
"description": "Search all import statements including type imports",
|
|
198
198
|
},
|
|
199
|
-
"exports": {"query": EXPORTS, "description": "
|
|
200
|
-
"decorators": {"query": DECORATORS, "description": "
|
|
199
|
+
"exports": {"query": EXPORTS, "description": "Search all export statements"},
|
|
200
|
+
"decorators": {"query": DECORATORS, "description": "Search all decorators"},
|
|
201
201
|
"generics": {
|
|
202
202
|
"query": GENERICS,
|
|
203
|
-
"description": "
|
|
203
|
+
"description": "Search all generic type parameters",
|
|
204
204
|
},
|
|
205
205
|
"signatures": {
|
|
206
206
|
"query": SIGNATURES,
|
|
207
|
-
"description": "
|
|
207
|
+
"description": "Search property signatures, method signatures, and constructor signatures",
|
|
208
208
|
},
|
|
209
|
-
"comments": {"query": COMMENTS, "description": "
|
|
209
|
+
"comments": {"query": COMMENTS, "description": "Search all comments"},
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
|
|
@@ -33,19 +33,19 @@ class QueryLoader:
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
_QUERY_DESCRIPTIONS: dict[str, str] = {
|
|
36
|
-
"class": "
|
|
37
|
-
"interface": "
|
|
38
|
-
"method": "
|
|
39
|
-
"constructor": "
|
|
40
|
-
"field": "
|
|
41
|
-
"import": "
|
|
42
|
-
"package": "
|
|
43
|
-
"annotation": "
|
|
44
|
-
"method_name": "
|
|
45
|
-
"class_name": "
|
|
46
|
-
"method_invocations": "
|
|
47
|
-
"class_with_body": "
|
|
48
|
-
"method_with_body": "
|
|
36
|
+
"class": "Extract class declarations",
|
|
37
|
+
"interface": "Extract interface declarations",
|
|
38
|
+
"method": "Extract method declarations",
|
|
39
|
+
"constructor": "Extract constructor declarations",
|
|
40
|
+
"field": "Extract field declarations",
|
|
41
|
+
"import": "Extract import statements",
|
|
42
|
+
"package": "Extract package declarations",
|
|
43
|
+
"annotation": "Extract annotations",
|
|
44
|
+
"method_name": "Extract method names only",
|
|
45
|
+
"class_name": "Extract class names only",
|
|
46
|
+
"method_invocations": "Extract method invocations",
|
|
47
|
+
"class_with_body": "Extract class declarations with body",
|
|
48
|
+
"method_with_body": "Extract method declarations with body",
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
def __init__(self) -> None:
|