tree-sitter-analyzer 0.9.1__py3-none-any.whl → 0.9.3__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.

Files changed (64) hide show
  1. tree_sitter_analyzer/__init__.py +132 -132
  2. tree_sitter_analyzer/__main__.py +11 -11
  3. tree_sitter_analyzer/api.py +533 -533
  4. tree_sitter_analyzer/cli/__init__.py +39 -39
  5. tree_sitter_analyzer/cli/__main__.py +12 -12
  6. tree_sitter_analyzer/cli/commands/__init__.py +26 -26
  7. tree_sitter_analyzer/cli/commands/advanced_command.py +88 -88
  8. tree_sitter_analyzer/cli/commands/base_command.py +181 -178
  9. tree_sitter_analyzer/cli/commands/structure_command.py +138 -138
  10. tree_sitter_analyzer/cli/commands/summary_command.py +101 -101
  11. tree_sitter_analyzer/cli_main.py +7 -3
  12. tree_sitter_analyzer/core/__init__.py +15 -15
  13. tree_sitter_analyzer/core/analysis_engine.py +91 -87
  14. tree_sitter_analyzer/core/cache_service.py +320 -320
  15. tree_sitter_analyzer/core/engine.py +566 -566
  16. tree_sitter_analyzer/core/parser.py +293 -293
  17. tree_sitter_analyzer/encoding_utils.py +459 -459
  18. tree_sitter_analyzer/file_handler.py +210 -210
  19. tree_sitter_analyzer/formatters/__init__.py +1 -1
  20. tree_sitter_analyzer/formatters/base_formatter.py +167 -167
  21. tree_sitter_analyzer/formatters/formatter_factory.py +78 -78
  22. tree_sitter_analyzer/formatters/java_formatter.py +18 -18
  23. tree_sitter_analyzer/formatters/python_formatter.py +19 -19
  24. tree_sitter_analyzer/interfaces/__init__.py +9 -9
  25. tree_sitter_analyzer/interfaces/cli.py +528 -528
  26. tree_sitter_analyzer/interfaces/cli_adapter.py +344 -343
  27. tree_sitter_analyzer/interfaces/mcp_adapter.py +206 -206
  28. tree_sitter_analyzer/language_detector.py +53 -53
  29. tree_sitter_analyzer/languages/__init__.py +10 -10
  30. tree_sitter_analyzer/languages/java_plugin.py +1 -1
  31. tree_sitter_analyzer/languages/javascript_plugin.py +446 -446
  32. tree_sitter_analyzer/languages/python_plugin.py +755 -755
  33. tree_sitter_analyzer/mcp/__init__.py +34 -45
  34. tree_sitter_analyzer/mcp/resources/__init__.py +44 -44
  35. tree_sitter_analyzer/mcp/resources/code_file_resource.py +209 -209
  36. tree_sitter_analyzer/mcp/server.py +623 -568
  37. tree_sitter_analyzer/mcp/tools/__init__.py +30 -30
  38. tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +681 -673
  39. tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py +247 -247
  40. tree_sitter_analyzer/mcp/tools/base_tool.py +54 -54
  41. tree_sitter_analyzer/mcp/tools/read_partial_tool.py +310 -308
  42. tree_sitter_analyzer/mcp/tools/table_format_tool.py +386 -379
  43. tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py +563 -559
  44. tree_sitter_analyzer/mcp/utils/__init__.py +107 -107
  45. tree_sitter_analyzer/models.py +10 -10
  46. tree_sitter_analyzer/output_manager.py +253 -253
  47. tree_sitter_analyzer/plugins/__init__.py +280 -280
  48. tree_sitter_analyzer/plugins/base.py +529 -529
  49. tree_sitter_analyzer/plugins/manager.py +379 -379
  50. tree_sitter_analyzer/project_detector.py +330 -317
  51. tree_sitter_analyzer/queries/__init__.py +26 -26
  52. tree_sitter_analyzer/queries/java.py +391 -391
  53. tree_sitter_analyzer/queries/javascript.py +148 -148
  54. tree_sitter_analyzer/queries/python.py +285 -285
  55. tree_sitter_analyzer/queries/typescript.py +229 -229
  56. tree_sitter_analyzer/query_loader.py +257 -257
  57. tree_sitter_analyzer/security/boundary_manager.py +57 -51
  58. tree_sitter_analyzer/security/validator.py +246 -241
  59. tree_sitter_analyzer/utils.py +294 -277
  60. {tree_sitter_analyzer-0.9.1.dist-info → tree_sitter_analyzer-0.9.3.dist-info}/METADATA +13 -13
  61. tree_sitter_analyzer-0.9.3.dist-info/RECORD +77 -0
  62. {tree_sitter_analyzer-0.9.1.dist-info → tree_sitter_analyzer-0.9.3.dist-info}/entry_points.txt +1 -0
  63. tree_sitter_analyzer-0.9.1.dist-info/RECORD +0 -77
  64. {tree_sitter_analyzer-0.9.1.dist-info → tree_sitter_analyzer-0.9.3.dist-info}/WHEEL +0 -0
@@ -1,229 +1,229 @@
1
- #!/usr/bin/env python3
2
- """
3
- TypeScript Tree-sitter queries for code analysis.
4
- """
5
-
6
- # Function declarations and expressions
7
- FUNCTIONS = """
8
- (function_declaration
9
- name: (identifier) @function.name
10
- parameters: (formal_parameters) @function.params
11
- return_type: (type_annotation)? @function.return_type
12
- body: (statement_block) @function.body) @function.declaration
13
-
14
- (function_expression
15
- name: (identifier)? @function.name
16
- parameters: (formal_parameters) @function.params
17
- return_type: (type_annotation)? @function.return_type
18
- body: (statement_block) @function.body) @function.expression
19
-
20
- (arrow_function
21
- parameters: (_) @function.params
22
- return_type: (type_annotation)? @function.return_type
23
- body: (_) @function.body) @function.arrow
24
-
25
- (method_definition
26
- name: (_) @function.name
27
- parameters: (formal_parameters) @function.params
28
- return_type: (type_annotation)? @function.return_type
29
- body: (statement_block) @function.body) @method.definition
30
- """
31
-
32
- # Class declarations
33
- CLASSES = """
34
- (class_declaration
35
- name: (type_identifier) @class.name
36
- type_parameters: (type_parameters)? @class.generics
37
- superclass: (class_heritage)? @class.superclass
38
- body: (class_body) @class.body) @class.declaration
39
-
40
- (abstract_class_declaration
41
- name: (type_identifier) @class.name
42
- type_parameters: (type_parameters)? @class.generics
43
- superclass: (class_heritage)? @class.superclass
44
- body: (class_body) @class.body) @class.abstract
45
- """
46
-
47
- # Interface declarations
48
- INTERFACES = """
49
- (interface_declaration
50
- name: (type_identifier) @interface.name
51
- type_parameters: (type_parameters)? @interface.generics
52
- body: (object_type) @interface.body) @interface.declaration
53
- """
54
-
55
- # Type aliases
56
- TYPE_ALIASES = """
57
- (type_alias_declaration
58
- name: (type_identifier) @type.name
59
- type_parameters: (type_parameters)? @type.generics
60
- value: (_) @type.value) @type.alias
61
- """
62
-
63
- # Enum declarations
64
- ENUMS = """
65
- (enum_declaration
66
- name: (identifier) @enum.name
67
- body: (enum_body) @enum.body) @enum.declaration
68
- """
69
-
70
- # Variable declarations with types
71
- VARIABLES = """
72
- (variable_declaration
73
- (variable_declarator
74
- name: (identifier) @variable.name
75
- type: (type_annotation)? @variable.type
76
- value: (_)? @variable.value)) @variable.declaration
77
-
78
- (lexical_declaration
79
- (variable_declarator
80
- name: (identifier) @variable.name
81
- type: (type_annotation)? @variable.type
82
- value: (_)? @variable.value)) @variable.lexical
83
- """
84
-
85
- # Import and export statements
86
- IMPORTS = """
87
- (import_statement
88
- source: (string) @import.source) @import.statement
89
-
90
- (import_statement
91
- (import_clause
92
- (named_imports
93
- (import_specifier
94
- name: (identifier) @import.name
95
- alias: (identifier)? @import.alias))) @import.named
96
-
97
- (import_statement
98
- (import_clause
99
- (import_default_specifier
100
- (identifier) @import.default))) @import.default
101
-
102
- (import_statement
103
- (import_clause
104
- (namespace_import
105
- (identifier) @import.namespace))) @import.namespace
106
-
107
- (type_import
108
- (import_clause
109
- (named_imports
110
- (import_specifier
111
- name: (identifier) @import.type.name
112
- alias: (identifier)? @import.type.alias)))) @import.type
113
- """
114
-
115
- EXPORTS = """
116
- (export_statement
117
- declaration: (_) @export.declaration) @export.statement
118
-
119
- (export_statement
120
- (export_clause
121
- (export_specifier
122
- name: (identifier) @export.name
123
- alias: (identifier)? @export.alias))) @export.named
124
- """
125
-
126
- # Decorators (TypeScript specific)
127
- DECORATORS = """
128
- (decorator
129
- (identifier) @decorator.name) @decorator.simple
130
-
131
- (decorator
132
- (call_expression
133
- function: (identifier) @decorator.name
134
- arguments: (arguments) @decorator.args)) @decorator.call
135
-
136
- (decorator
137
- (member_expression
138
- object: (identifier) @decorator.object
139
- property: (property_identifier) @decorator.name)) @decorator.member
140
- """
141
-
142
- # Generic type parameters
143
- GENERICS = """
144
- (type_parameters
145
- (type_parameter
146
- name: (type_identifier) @generic.name
147
- constraint: (type_annotation)? @generic.constraint
148
- default: (type_annotation)? @generic.default)) @generic.parameter
149
- """
150
-
151
- # Property signatures and method signatures
152
- SIGNATURES = """
153
- (property_signature
154
- name: (_) @property.name
155
- type: (type_annotation) @property.type) @property.signature
156
-
157
- (method_signature
158
- name: (_) @method.name
159
- parameters: (formal_parameters) @method.params
160
- return_type: (type_annotation)? @method.return_type) @method.signature
161
-
162
- (construct_signature
163
- parameters: (formal_parameters) @constructor.params
164
- return_type: (type_annotation)? @constructor.return_type) @constructor.signature
165
- """
166
-
167
- # Comments
168
- COMMENTS = """
169
- (comment) @comment
170
- """
171
-
172
- # All queries combined
173
- ALL_QUERIES = {
174
- "functions": {
175
- "query": FUNCTIONS,
176
- "description": "Search all function declarations, expressions, and methods with type annotations",
177
- },
178
- "classes": {
179
- "query": CLASSES,
180
- "description": "Search all class declarations including abstract classes",
181
- },
182
- "interfaces": {
183
- "query": INTERFACES,
184
- "description": "Search all interface declarations",
185
- },
186
- "type_aliases": {
187
- "query": TYPE_ALIASES,
188
- "description": "Search all type alias declarations",
189
- },
190
- "enums": {"query": ENUMS, "description": "Search all enum declarations"},
191
- "variables": {
192
- "query": VARIABLES,
193
- "description": "Search all variable declarations with type annotations",
194
- },
195
- "imports": {
196
- "query": IMPORTS,
197
- "description": "Search all import statements including type imports",
198
- },
199
- "exports": {"query": EXPORTS, "description": "Search all export statements"},
200
- "decorators": {"query": DECORATORS, "description": "Search all decorators"},
201
- "generics": {
202
- "query": GENERICS,
203
- "description": "Search all generic type parameters",
204
- },
205
- "signatures": {
206
- "query": SIGNATURES,
207
- "description": "Search property signatures, method signatures, and constructor signatures",
208
- },
209
- "comments": {"query": COMMENTS, "description": "Search all comments"},
210
- }
211
-
212
-
213
- def get_query(name: str) -> str:
214
- """Get a specific query by name."""
215
- if name in ALL_QUERIES:
216
- return ALL_QUERIES[name]["query"]
217
- raise ValueError(
218
- f"Query '{name}' not found. Available queries: {list(ALL_QUERIES.keys())}"
219
- )
220
-
221
-
222
- def get_all_queries() -> dict:
223
- """Get all available queries."""
224
- return ALL_QUERIES
225
-
226
-
227
- def list_queries() -> list:
228
- """List all available query names."""
229
- return list(ALL_QUERIES.keys())
1
+ #!/usr/bin/env python3
2
+ """
3
+ TypeScript Tree-sitter queries for code analysis.
4
+ """
5
+
6
+ # Function declarations and expressions
7
+ FUNCTIONS = """
8
+ (function_declaration
9
+ name: (identifier) @function.name
10
+ parameters: (formal_parameters) @function.params
11
+ return_type: (type_annotation)? @function.return_type
12
+ body: (statement_block) @function.body) @function.declaration
13
+
14
+ (function_expression
15
+ name: (identifier)? @function.name
16
+ parameters: (formal_parameters) @function.params
17
+ return_type: (type_annotation)? @function.return_type
18
+ body: (statement_block) @function.body) @function.expression
19
+
20
+ (arrow_function
21
+ parameters: (_) @function.params
22
+ return_type: (type_annotation)? @function.return_type
23
+ body: (_) @function.body) @function.arrow
24
+
25
+ (method_definition
26
+ name: (_) @function.name
27
+ parameters: (formal_parameters) @function.params
28
+ return_type: (type_annotation)? @function.return_type
29
+ body: (statement_block) @function.body) @method.definition
30
+ """
31
+
32
+ # Class declarations
33
+ CLASSES = """
34
+ (class_declaration
35
+ name: (type_identifier) @class.name
36
+ type_parameters: (type_parameters)? @class.generics
37
+ superclass: (class_heritage)? @class.superclass
38
+ body: (class_body) @class.body) @class.declaration
39
+
40
+ (abstract_class_declaration
41
+ name: (type_identifier) @class.name
42
+ type_parameters: (type_parameters)? @class.generics
43
+ superclass: (class_heritage)? @class.superclass
44
+ body: (class_body) @class.body) @class.abstract
45
+ """
46
+
47
+ # Interface declarations
48
+ INTERFACES = """
49
+ (interface_declaration
50
+ name: (type_identifier) @interface.name
51
+ type_parameters: (type_parameters)? @interface.generics
52
+ body: (object_type) @interface.body) @interface.declaration
53
+ """
54
+
55
+ # Type aliases
56
+ TYPE_ALIASES = """
57
+ (type_alias_declaration
58
+ name: (type_identifier) @type.name
59
+ type_parameters: (type_parameters)? @type.generics
60
+ value: (_) @type.value) @type.alias
61
+ """
62
+
63
+ # Enum declarations
64
+ ENUMS = """
65
+ (enum_declaration
66
+ name: (identifier) @enum.name
67
+ body: (enum_body) @enum.body) @enum.declaration
68
+ """
69
+
70
+ # Variable declarations with types
71
+ VARIABLES = """
72
+ (variable_declaration
73
+ (variable_declarator
74
+ name: (identifier) @variable.name
75
+ type: (type_annotation)? @variable.type
76
+ value: (_)? @variable.value)) @variable.declaration
77
+
78
+ (lexical_declaration
79
+ (variable_declarator
80
+ name: (identifier) @variable.name
81
+ type: (type_annotation)? @variable.type
82
+ value: (_)? @variable.value)) @variable.lexical
83
+ """
84
+
85
+ # Import and export statements
86
+ IMPORTS = """
87
+ (import_statement
88
+ source: (string) @import.source) @import.statement
89
+
90
+ (import_statement
91
+ (import_clause
92
+ (named_imports
93
+ (import_specifier
94
+ name: (identifier) @import.name
95
+ alias: (identifier)? @import.alias))) @import.named
96
+
97
+ (import_statement
98
+ (import_clause
99
+ (import_default_specifier
100
+ (identifier) @import.default))) @import.default
101
+
102
+ (import_statement
103
+ (import_clause
104
+ (namespace_import
105
+ (identifier) @import.namespace))) @import.namespace
106
+
107
+ (type_import
108
+ (import_clause
109
+ (named_imports
110
+ (import_specifier
111
+ name: (identifier) @import.type.name
112
+ alias: (identifier)? @import.type.alias)))) @import.type
113
+ """
114
+
115
+ EXPORTS = """
116
+ (export_statement
117
+ declaration: (_) @export.declaration) @export.statement
118
+
119
+ (export_statement
120
+ (export_clause
121
+ (export_specifier
122
+ name: (identifier) @export.name
123
+ alias: (identifier)? @export.alias))) @export.named
124
+ """
125
+
126
+ # Decorators (TypeScript specific)
127
+ DECORATORS = """
128
+ (decorator
129
+ (identifier) @decorator.name) @decorator.simple
130
+
131
+ (decorator
132
+ (call_expression
133
+ function: (identifier) @decorator.name
134
+ arguments: (arguments) @decorator.args)) @decorator.call
135
+
136
+ (decorator
137
+ (member_expression
138
+ object: (identifier) @decorator.object
139
+ property: (property_identifier) @decorator.name)) @decorator.member
140
+ """
141
+
142
+ # Generic type parameters
143
+ GENERICS = """
144
+ (type_parameters
145
+ (type_parameter
146
+ name: (type_identifier) @generic.name
147
+ constraint: (type_annotation)? @generic.constraint
148
+ default: (type_annotation)? @generic.default)) @generic.parameter
149
+ """
150
+
151
+ # Property signatures and method signatures
152
+ SIGNATURES = """
153
+ (property_signature
154
+ name: (_) @property.name
155
+ type: (type_annotation) @property.type) @property.signature
156
+
157
+ (method_signature
158
+ name: (_) @method.name
159
+ parameters: (formal_parameters) @method.params
160
+ return_type: (type_annotation)? @method.return_type) @method.signature
161
+
162
+ (construct_signature
163
+ parameters: (formal_parameters) @constructor.params
164
+ return_type: (type_annotation)? @constructor.return_type) @constructor.signature
165
+ """
166
+
167
+ # Comments
168
+ COMMENTS = """
169
+ (comment) @comment
170
+ """
171
+
172
+ # All queries combined
173
+ ALL_QUERIES = {
174
+ "functions": {
175
+ "query": FUNCTIONS,
176
+ "description": "Search all function declarations, expressions, and methods with type annotations",
177
+ },
178
+ "classes": {
179
+ "query": CLASSES,
180
+ "description": "Search all class declarations including abstract classes",
181
+ },
182
+ "interfaces": {
183
+ "query": INTERFACES,
184
+ "description": "Search all interface declarations",
185
+ },
186
+ "type_aliases": {
187
+ "query": TYPE_ALIASES,
188
+ "description": "Search all type alias declarations",
189
+ },
190
+ "enums": {"query": ENUMS, "description": "Search all enum declarations"},
191
+ "variables": {
192
+ "query": VARIABLES,
193
+ "description": "Search all variable declarations with type annotations",
194
+ },
195
+ "imports": {
196
+ "query": IMPORTS,
197
+ "description": "Search all import statements including type imports",
198
+ },
199
+ "exports": {"query": EXPORTS, "description": "Search all export statements"},
200
+ "decorators": {"query": DECORATORS, "description": "Search all decorators"},
201
+ "generics": {
202
+ "query": GENERICS,
203
+ "description": "Search all generic type parameters",
204
+ },
205
+ "signatures": {
206
+ "query": SIGNATURES,
207
+ "description": "Search property signatures, method signatures, and constructor signatures",
208
+ },
209
+ "comments": {"query": COMMENTS, "description": "Search all comments"},
210
+ }
211
+
212
+
213
+ def get_query(name: str) -> str:
214
+ """Get a specific query by name."""
215
+ if name in ALL_QUERIES:
216
+ return ALL_QUERIES[name]["query"]
217
+ raise ValueError(
218
+ f"Query '{name}' not found. Available queries: {list(ALL_QUERIES.keys())}"
219
+ )
220
+
221
+
222
+ def get_all_queries() -> dict:
223
+ """Get all available queries."""
224
+ return ALL_QUERIES
225
+
226
+
227
+ def list_queries() -> list:
228
+ """List all available query names."""
229
+ return list(ALL_QUERIES.keys())