tree-sitter-analyzer 0.7.0__py3-none-any.whl → 0.8.0__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 +132 -132
- tree_sitter_analyzer/__main__.py +11 -11
- tree_sitter_analyzer/api.py +533 -533
- tree_sitter_analyzer/cli/__init__.py +39 -39
- tree_sitter_analyzer/cli/__main__.py +12 -12
- tree_sitter_analyzer/cli/commands/__init__.py +26 -26
- tree_sitter_analyzer/cli/commands/advanced_command.py +88 -88
- tree_sitter_analyzer/cli/commands/base_command.py +160 -160
- tree_sitter_analyzer/cli/commands/default_command.py +18 -18
- tree_sitter_analyzer/cli/commands/partial_read_command.py +141 -141
- tree_sitter_analyzer/cli/commands/query_command.py +81 -81
- tree_sitter_analyzer/cli/commands/structure_command.py +138 -138
- tree_sitter_analyzer/cli/commands/summary_command.py +101 -101
- tree_sitter_analyzer/cli/commands/table_command.py +235 -235
- tree_sitter_analyzer/cli/info_commands.py +121 -121
- tree_sitter_analyzer/cli_main.py +297 -297
- tree_sitter_analyzer/core/__init__.py +15 -15
- tree_sitter_analyzer/core/analysis_engine.py +555 -555
- tree_sitter_analyzer/core/cache_service.py +320 -320
- tree_sitter_analyzer/core/engine.py +566 -566
- tree_sitter_analyzer/core/parser.py +293 -293
- tree_sitter_analyzer/encoding_utils.py +459 -459
- tree_sitter_analyzer/exceptions.py +406 -337
- tree_sitter_analyzer/file_handler.py +210 -210
- tree_sitter_analyzer/formatters/__init__.py +1 -1
- tree_sitter_analyzer/formatters/base_formatter.py +167 -167
- tree_sitter_analyzer/formatters/formatter_factory.py +78 -78
- tree_sitter_analyzer/interfaces/__init__.py +9 -9
- tree_sitter_analyzer/interfaces/cli.py +528 -528
- tree_sitter_analyzer/interfaces/cli_adapter.py +343 -343
- tree_sitter_analyzer/interfaces/mcp_adapter.py +206 -206
- tree_sitter_analyzer/interfaces/mcp_server.py +425 -405
- tree_sitter_analyzer/languages/__init__.py +10 -10
- tree_sitter_analyzer/languages/javascript_plugin.py +446 -446
- tree_sitter_analyzer/languages/python_plugin.py +755 -755
- tree_sitter_analyzer/mcp/__init__.py +31 -31
- tree_sitter_analyzer/mcp/resources/__init__.py +44 -44
- tree_sitter_analyzer/mcp/resources/code_file_resource.py +209 -209
- tree_sitter_analyzer/mcp/server.py +346 -333
- tree_sitter_analyzer/mcp/tools/__init__.py +30 -30
- tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +654 -654
- tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py +247 -247
- tree_sitter_analyzer/mcp/tools/base_tool.py +54 -54
- tree_sitter_analyzer/mcp/tools/read_partial_tool.py +300 -300
- tree_sitter_analyzer/mcp/tools/table_format_tool.py +362 -362
- tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py +543 -543
- tree_sitter_analyzer/mcp/utils/__init__.py +107 -107
- tree_sitter_analyzer/mcp/utils/error_handler.py +549 -549
- tree_sitter_analyzer/output_manager.py +253 -253
- tree_sitter_analyzer/plugins/__init__.py +280 -280
- tree_sitter_analyzer/plugins/base.py +529 -529
- tree_sitter_analyzer/plugins/manager.py +379 -379
- tree_sitter_analyzer/queries/__init__.py +26 -26
- tree_sitter_analyzer/queries/java.py +391 -391
- tree_sitter_analyzer/queries/javascript.py +148 -148
- tree_sitter_analyzer/queries/python.py +285 -285
- tree_sitter_analyzer/queries/typescript.py +229 -229
- tree_sitter_analyzer/query_loader.py +257 -257
- tree_sitter_analyzer/security/__init__.py +22 -0
- tree_sitter_analyzer/security/boundary_manager.py +237 -0
- tree_sitter_analyzer/security/regex_checker.py +292 -0
- tree_sitter_analyzer/security/validator.py +224 -0
- tree_sitter_analyzer/table_formatter.py +652 -589
- tree_sitter_analyzer/utils.py +277 -277
- {tree_sitter_analyzer-0.7.0.dist-info → tree_sitter_analyzer-0.8.0.dist-info}/METADATA +4 -1
- tree_sitter_analyzer-0.8.0.dist-info/RECORD +76 -0
- tree_sitter_analyzer-0.7.0.dist-info/RECORD +0 -72
- {tree_sitter_analyzer-0.7.0.dist-info → tree_sitter_analyzer-0.8.0.dist-info}/WHEEL +0 -0
- {tree_sitter_analyzer-0.7.0.dist-info → tree_sitter_analyzer-0.8.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
JavaScript 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
|
-
body: (statement_block) @function.body) @function.declaration
|
|
12
|
-
|
|
13
|
-
(function_expression
|
|
14
|
-
name: (identifier)? @function.name
|
|
15
|
-
parameters: (formal_parameters) @function.params
|
|
16
|
-
body: (statement_block) @function.body) @function.expression
|
|
17
|
-
|
|
18
|
-
(arrow_function
|
|
19
|
-
parameters: (formal_parameters) @function.params
|
|
20
|
-
body: (_) @function.body) @function.arrow
|
|
21
|
-
|
|
22
|
-
(method_definition
|
|
23
|
-
name: (property_identifier) @function.name
|
|
24
|
-
parameters: (formal_parameters) @function.params
|
|
25
|
-
body: (statement_block) @function.body) @method.definition
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
# Class declarations
|
|
29
|
-
CLASSES = """
|
|
30
|
-
(class_declaration
|
|
31
|
-
name: (identifier) @class.name
|
|
32
|
-
superclass: (class_heritage)? @class.superclass
|
|
33
|
-
body: (class_body) @class.body) @class.declaration
|
|
34
|
-
|
|
35
|
-
(class_expression
|
|
36
|
-
name: (identifier)? @class.name
|
|
37
|
-
superclass: (class_heritage)? @class.superclass
|
|
38
|
-
body: (class_body) @class.body) @class.expression
|
|
39
|
-
"""
|
|
40
|
-
|
|
41
|
-
# Variable declarations
|
|
42
|
-
VARIABLES = """
|
|
43
|
-
(variable_declaration
|
|
44
|
-
(variable_declarator
|
|
45
|
-
name: (identifier) @variable.name
|
|
46
|
-
value: (_)? @variable.value)) @variable.declaration
|
|
47
|
-
|
|
48
|
-
(lexical_declaration
|
|
49
|
-
(variable_declarator
|
|
50
|
-
name: (identifier) @variable.name
|
|
51
|
-
value: (_)? @variable.value)) @variable.lexical
|
|
52
|
-
"""
|
|
53
|
-
|
|
54
|
-
# Import and export statements
|
|
55
|
-
IMPORTS = """
|
|
56
|
-
(import_statement
|
|
57
|
-
source: (string) @import.source) @import.statement
|
|
58
|
-
|
|
59
|
-
(import_statement
|
|
60
|
-
(import_clause
|
|
61
|
-
(named_imports
|
|
62
|
-
(import_specifier
|
|
63
|
-
name: (identifier) @import.name
|
|
64
|
-
alias: (identifier)? @import.alias))) @import.named
|
|
65
|
-
|
|
66
|
-
(import_statement
|
|
67
|
-
(import_clause
|
|
68
|
-
(import_default_specifier
|
|
69
|
-
(identifier) @import.default))) @import.default
|
|
70
|
-
|
|
71
|
-
(import_statement
|
|
72
|
-
(import_clause
|
|
73
|
-
(namespace_import
|
|
74
|
-
(identifier) @import.namespace))) @import.namespace
|
|
75
|
-
"""
|
|
76
|
-
|
|
77
|
-
EXPORTS = """
|
|
78
|
-
(export_statement
|
|
79
|
-
declaration: (_) @export.declaration) @export.statement
|
|
80
|
-
|
|
81
|
-
(export_statement
|
|
82
|
-
(export_clause
|
|
83
|
-
(export_specifier
|
|
84
|
-
name: (identifier) @export.name
|
|
85
|
-
alias: (identifier)? @export.alias))) @export.named
|
|
86
|
-
"""
|
|
87
|
-
|
|
88
|
-
# Object and property definitions
|
|
89
|
-
OBJECTS = """
|
|
90
|
-
(object
|
|
91
|
-
(pair
|
|
92
|
-
key: (_) @property.key
|
|
93
|
-
value: (_) @property.value)) @object.literal
|
|
94
|
-
|
|
95
|
-
(property_definition
|
|
96
|
-
property: (_) @property.name
|
|
97
|
-
value: (_)? @property.value) @property.definition
|
|
98
|
-
"""
|
|
99
|
-
|
|
100
|
-
# Comments
|
|
101
|
-
COMMENTS = """
|
|
102
|
-
(comment) @comment
|
|
103
|
-
"""
|
|
104
|
-
|
|
105
|
-
# All queries combined
|
|
106
|
-
ALL_QUERIES = {
|
|
107
|
-
"functions": {
|
|
108
|
-
"query": FUNCTIONS,
|
|
109
|
-
"description": "Search all function declarations, expressions, and methods",
|
|
110
|
-
},
|
|
111
|
-
"classes": {
|
|
112
|
-
"query": CLASSES,
|
|
113
|
-
"description": "Search all class declarations and expressions",
|
|
114
|
-
},
|
|
115
|
-
"variables": {
|
|
116
|
-
"query": VARIABLES,
|
|
117
|
-
"description": "Search all variable declarations (var, let, const)",
|
|
118
|
-
},
|
|
119
|
-
"imports": {
|
|
120
|
-
"query": IMPORTS,
|
|
121
|
-
"description": "Search all import statements and clauses",
|
|
122
|
-
},
|
|
123
|
-
"exports": {"query": EXPORTS, "description": "Search all export statements"},
|
|
124
|
-
"objects": {
|
|
125
|
-
"query": OBJECTS,
|
|
126
|
-
"description": "Search object literals and property definitions",
|
|
127
|
-
},
|
|
128
|
-
"comments": {"query": COMMENTS, "description": "Search all comments"},
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
def get_query(name: str) -> str:
|
|
133
|
-
"""Get a specific query by name."""
|
|
134
|
-
if name in ALL_QUERIES:
|
|
135
|
-
return ALL_QUERIES[name]["query"]
|
|
136
|
-
raise ValueError(
|
|
137
|
-
f"Query '{name}' not found. Available queries: {list(ALL_QUERIES.keys())}"
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
def get_all_queries() -> dict:
|
|
142
|
-
"""Get all available queries."""
|
|
143
|
-
return ALL_QUERIES
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
def list_queries() -> list:
|
|
147
|
-
"""List all available query names."""
|
|
148
|
-
return list(ALL_QUERIES.keys())
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
JavaScript 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
|
+
body: (statement_block) @function.body) @function.declaration
|
|
12
|
+
|
|
13
|
+
(function_expression
|
|
14
|
+
name: (identifier)? @function.name
|
|
15
|
+
parameters: (formal_parameters) @function.params
|
|
16
|
+
body: (statement_block) @function.body) @function.expression
|
|
17
|
+
|
|
18
|
+
(arrow_function
|
|
19
|
+
parameters: (formal_parameters) @function.params
|
|
20
|
+
body: (_) @function.body) @function.arrow
|
|
21
|
+
|
|
22
|
+
(method_definition
|
|
23
|
+
name: (property_identifier) @function.name
|
|
24
|
+
parameters: (formal_parameters) @function.params
|
|
25
|
+
body: (statement_block) @function.body) @method.definition
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
# Class declarations
|
|
29
|
+
CLASSES = """
|
|
30
|
+
(class_declaration
|
|
31
|
+
name: (identifier) @class.name
|
|
32
|
+
superclass: (class_heritage)? @class.superclass
|
|
33
|
+
body: (class_body) @class.body) @class.declaration
|
|
34
|
+
|
|
35
|
+
(class_expression
|
|
36
|
+
name: (identifier)? @class.name
|
|
37
|
+
superclass: (class_heritage)? @class.superclass
|
|
38
|
+
body: (class_body) @class.body) @class.expression
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
# Variable declarations
|
|
42
|
+
VARIABLES = """
|
|
43
|
+
(variable_declaration
|
|
44
|
+
(variable_declarator
|
|
45
|
+
name: (identifier) @variable.name
|
|
46
|
+
value: (_)? @variable.value)) @variable.declaration
|
|
47
|
+
|
|
48
|
+
(lexical_declaration
|
|
49
|
+
(variable_declarator
|
|
50
|
+
name: (identifier) @variable.name
|
|
51
|
+
value: (_)? @variable.value)) @variable.lexical
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
# Import and export statements
|
|
55
|
+
IMPORTS = """
|
|
56
|
+
(import_statement
|
|
57
|
+
source: (string) @import.source) @import.statement
|
|
58
|
+
|
|
59
|
+
(import_statement
|
|
60
|
+
(import_clause
|
|
61
|
+
(named_imports
|
|
62
|
+
(import_specifier
|
|
63
|
+
name: (identifier) @import.name
|
|
64
|
+
alias: (identifier)? @import.alias))) @import.named
|
|
65
|
+
|
|
66
|
+
(import_statement
|
|
67
|
+
(import_clause
|
|
68
|
+
(import_default_specifier
|
|
69
|
+
(identifier) @import.default))) @import.default
|
|
70
|
+
|
|
71
|
+
(import_statement
|
|
72
|
+
(import_clause
|
|
73
|
+
(namespace_import
|
|
74
|
+
(identifier) @import.namespace))) @import.namespace
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
EXPORTS = """
|
|
78
|
+
(export_statement
|
|
79
|
+
declaration: (_) @export.declaration) @export.statement
|
|
80
|
+
|
|
81
|
+
(export_statement
|
|
82
|
+
(export_clause
|
|
83
|
+
(export_specifier
|
|
84
|
+
name: (identifier) @export.name
|
|
85
|
+
alias: (identifier)? @export.alias))) @export.named
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
# Object and property definitions
|
|
89
|
+
OBJECTS = """
|
|
90
|
+
(object
|
|
91
|
+
(pair
|
|
92
|
+
key: (_) @property.key
|
|
93
|
+
value: (_) @property.value)) @object.literal
|
|
94
|
+
|
|
95
|
+
(property_definition
|
|
96
|
+
property: (_) @property.name
|
|
97
|
+
value: (_)? @property.value) @property.definition
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
# Comments
|
|
101
|
+
COMMENTS = """
|
|
102
|
+
(comment) @comment
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
# All queries combined
|
|
106
|
+
ALL_QUERIES = {
|
|
107
|
+
"functions": {
|
|
108
|
+
"query": FUNCTIONS,
|
|
109
|
+
"description": "Search all function declarations, expressions, and methods",
|
|
110
|
+
},
|
|
111
|
+
"classes": {
|
|
112
|
+
"query": CLASSES,
|
|
113
|
+
"description": "Search all class declarations and expressions",
|
|
114
|
+
},
|
|
115
|
+
"variables": {
|
|
116
|
+
"query": VARIABLES,
|
|
117
|
+
"description": "Search all variable declarations (var, let, const)",
|
|
118
|
+
},
|
|
119
|
+
"imports": {
|
|
120
|
+
"query": IMPORTS,
|
|
121
|
+
"description": "Search all import statements and clauses",
|
|
122
|
+
},
|
|
123
|
+
"exports": {"query": EXPORTS, "description": "Search all export statements"},
|
|
124
|
+
"objects": {
|
|
125
|
+
"query": OBJECTS,
|
|
126
|
+
"description": "Search object literals and property definitions",
|
|
127
|
+
},
|
|
128
|
+
"comments": {"query": COMMENTS, "description": "Search all comments"},
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def get_query(name: str) -> str:
|
|
133
|
+
"""Get a specific query by name."""
|
|
134
|
+
if name in ALL_QUERIES:
|
|
135
|
+
return ALL_QUERIES[name]["query"]
|
|
136
|
+
raise ValueError(
|
|
137
|
+
f"Query '{name}' not found. Available queries: {list(ALL_QUERIES.keys())}"
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def get_all_queries() -> dict:
|
|
142
|
+
"""Get all available queries."""
|
|
143
|
+
return ALL_QUERIES
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def list_queries() -> list:
|
|
147
|
+
"""List all available query names."""
|
|
148
|
+
return list(ALL_QUERIES.keys())
|