tree-sitter-analyzer 0.2.0__py3-none-any.whl → 0.3.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.

Files changed (78) hide show
  1. tree_sitter_analyzer/__init__.py +133 -121
  2. tree_sitter_analyzer/__main__.py +11 -12
  3. tree_sitter_analyzer/api.py +531 -539
  4. tree_sitter_analyzer/cli/__init__.py +39 -39
  5. tree_sitter_analyzer/cli/__main__.py +12 -13
  6. tree_sitter_analyzer/cli/commands/__init__.py +26 -27
  7. tree_sitter_analyzer/cli/commands/advanced_command.py +88 -88
  8. tree_sitter_analyzer/cli/commands/base_command.py +160 -155
  9. tree_sitter_analyzer/cli/commands/default_command.py +18 -19
  10. tree_sitter_analyzer/cli/commands/partial_read_command.py +141 -133
  11. tree_sitter_analyzer/cli/commands/query_command.py +81 -82
  12. tree_sitter_analyzer/cli/commands/structure_command.py +138 -121
  13. tree_sitter_analyzer/cli/commands/summary_command.py +101 -93
  14. tree_sitter_analyzer/cli/commands/table_command.py +232 -233
  15. tree_sitter_analyzer/cli/info_commands.py +120 -121
  16. tree_sitter_analyzer/cli_main.py +277 -276
  17. tree_sitter_analyzer/core/__init__.py +15 -20
  18. tree_sitter_analyzer/core/analysis_engine.py +591 -574
  19. tree_sitter_analyzer/core/cache_service.py +320 -330
  20. tree_sitter_analyzer/core/engine.py +557 -560
  21. tree_sitter_analyzer/core/parser.py +293 -288
  22. tree_sitter_analyzer/core/query.py +494 -502
  23. tree_sitter_analyzer/encoding_utils.py +458 -460
  24. tree_sitter_analyzer/exceptions.py +337 -340
  25. tree_sitter_analyzer/file_handler.py +217 -222
  26. tree_sitter_analyzer/formatters/__init__.py +1 -1
  27. tree_sitter_analyzer/formatters/base_formatter.py +167 -168
  28. tree_sitter_analyzer/formatters/formatter_factory.py +78 -74
  29. tree_sitter_analyzer/formatters/java_formatter.py +287 -270
  30. tree_sitter_analyzer/formatters/python_formatter.py +255 -235
  31. tree_sitter_analyzer/interfaces/__init__.py +9 -10
  32. tree_sitter_analyzer/interfaces/cli.py +528 -557
  33. tree_sitter_analyzer/interfaces/cli_adapter.py +322 -319
  34. tree_sitter_analyzer/interfaces/mcp_adapter.py +180 -170
  35. tree_sitter_analyzer/interfaces/mcp_server.py +405 -416
  36. tree_sitter_analyzer/java_analyzer.py +218 -219
  37. tree_sitter_analyzer/language_detector.py +398 -400
  38. tree_sitter_analyzer/language_loader.py +224 -228
  39. tree_sitter_analyzer/languages/__init__.py +10 -11
  40. tree_sitter_analyzer/languages/java_plugin.py +1129 -1113
  41. tree_sitter_analyzer/languages/python_plugin.py +737 -712
  42. tree_sitter_analyzer/mcp/__init__.py +31 -32
  43. tree_sitter_analyzer/mcp/resources/__init__.py +44 -47
  44. tree_sitter_analyzer/mcp/resources/code_file_resource.py +212 -213
  45. tree_sitter_analyzer/mcp/resources/project_stats_resource.py +560 -550
  46. tree_sitter_analyzer/mcp/server.py +333 -345
  47. tree_sitter_analyzer/mcp/tools/__init__.py +30 -31
  48. tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +621 -557
  49. tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py +242 -245
  50. tree_sitter_analyzer/mcp/tools/base_tool.py +54 -55
  51. tree_sitter_analyzer/mcp/tools/read_partial_tool.py +300 -302
  52. tree_sitter_analyzer/mcp/tools/table_format_tool.py +362 -359
  53. tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py +543 -476
  54. tree_sitter_analyzer/mcp/utils/__init__.py +105 -106
  55. tree_sitter_analyzer/mcp/utils/error_handler.py +549 -549
  56. tree_sitter_analyzer/models.py +470 -481
  57. tree_sitter_analyzer/output_manager.py +261 -264
  58. tree_sitter_analyzer/plugins/__init__.py +333 -334
  59. tree_sitter_analyzer/plugins/base.py +477 -446
  60. tree_sitter_analyzer/plugins/java_plugin.py +608 -625
  61. tree_sitter_analyzer/plugins/javascript_plugin.py +446 -439
  62. tree_sitter_analyzer/plugins/manager.py +362 -355
  63. tree_sitter_analyzer/plugins/plugin_loader.py +85 -83
  64. tree_sitter_analyzer/plugins/python_plugin.py +606 -598
  65. tree_sitter_analyzer/plugins/registry.py +374 -366
  66. tree_sitter_analyzer/queries/__init__.py +26 -27
  67. tree_sitter_analyzer/queries/java.py +391 -394
  68. tree_sitter_analyzer/queries/javascript.py +148 -149
  69. tree_sitter_analyzer/queries/python.py +285 -286
  70. tree_sitter_analyzer/queries/typescript.py +229 -230
  71. tree_sitter_analyzer/query_loader.py +254 -260
  72. tree_sitter_analyzer/table_formatter.py +468 -448
  73. tree_sitter_analyzer/utils.py +277 -277
  74. {tree_sitter_analyzer-0.2.0.dist-info → tree_sitter_analyzer-0.3.0.dist-info}/METADATA +21 -6
  75. tree_sitter_analyzer-0.3.0.dist-info/RECORD +77 -0
  76. tree_sitter_analyzer-0.2.0.dist-info/RECORD +0 -77
  77. {tree_sitter_analyzer-0.2.0.dist-info → tree_sitter_analyzer-0.3.0.dist-info}/WHEEL +0 -0
  78. {tree_sitter_analyzer-0.2.0.dist-info → tree_sitter_analyzer-0.3.0.dist-info}/entry_points.txt +0 -0
@@ -1,149 +1,148 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- """
4
- JavaScript Tree-sitter queries for code analysis.
5
- """
6
-
7
- # Function declarations and expressions
8
- FUNCTIONS = """
9
- (function_declaration
10
- name: (identifier) @function.name
11
- parameters: (formal_parameters) @function.params
12
- body: (statement_block) @function.body) @function.declaration
13
-
14
- (function_expression
15
- name: (identifier)? @function.name
16
- parameters: (formal_parameters) @function.params
17
- body: (statement_block) @function.body) @function.expression
18
-
19
- (arrow_function
20
- parameters: (formal_parameters) @function.params
21
- body: (_) @function.body) @function.arrow
22
-
23
- (method_definition
24
- name: (property_identifier) @function.name
25
- parameters: (formal_parameters) @function.params
26
- body: (statement_block) @function.body) @method.definition
27
- """
28
-
29
- # Class declarations
30
- CLASSES = """
31
- (class_declaration
32
- name: (identifier) @class.name
33
- superclass: (class_heritage)? @class.superclass
34
- body: (class_body) @class.body) @class.declaration
35
-
36
- (class_expression
37
- name: (identifier)? @class.name
38
- superclass: (class_heritage)? @class.superclass
39
- body: (class_body) @class.body) @class.expression
40
- """
41
-
42
- # Variable declarations
43
- VARIABLES = """
44
- (variable_declaration
45
- (variable_declarator
46
- name: (identifier) @variable.name
47
- value: (_)? @variable.value)) @variable.declaration
48
-
49
- (lexical_declaration
50
- (variable_declarator
51
- name: (identifier) @variable.name
52
- value: (_)? @variable.value)) @variable.lexical
53
- """
54
-
55
- # Import and export statements
56
- IMPORTS = """
57
- (import_statement
58
- source: (string) @import.source) @import.statement
59
-
60
- (import_statement
61
- (import_clause
62
- (named_imports
63
- (import_specifier
64
- name: (identifier) @import.name
65
- alias: (identifier)? @import.alias))) @import.named
66
-
67
- (import_statement
68
- (import_clause
69
- (import_default_specifier
70
- (identifier) @import.default))) @import.default
71
-
72
- (import_statement
73
- (import_clause
74
- (namespace_import
75
- (identifier) @import.namespace))) @import.namespace
76
- """
77
-
78
- EXPORTS = """
79
- (export_statement
80
- declaration: (_) @export.declaration) @export.statement
81
-
82
- (export_statement
83
- (export_clause
84
- (export_specifier
85
- name: (identifier) @export.name
86
- alias: (identifier)? @export.alias))) @export.named
87
- """
88
-
89
- # Object and property definitions
90
- OBJECTS = """
91
- (object
92
- (pair
93
- key: (_) @property.key
94
- value: (_) @property.value)) @object.literal
95
-
96
- (property_definition
97
- property: (_) @property.name
98
- value: (_)? @property.value) @property.definition
99
- """
100
-
101
- # Comments
102
- COMMENTS = """
103
- (comment) @comment
104
- """
105
-
106
- # All queries combined
107
- ALL_QUERIES = {
108
- "functions": {
109
- "query": FUNCTIONS,
110
- "description": "すべての関数宣言、式、メソッドを検索",
111
- },
112
- "classes": {
113
- "query": CLASSES,
114
- "description": "すべてのクラス宣言と式を検索",
115
- },
116
- "variables": {
117
- "query": VARIABLES,
118
- "description": "すべての変数宣言(var、let、const)を検索",
119
- },
120
- "imports": {
121
- "query": IMPORTS,
122
- "description": "すべてのインポート文と句を検索",
123
- },
124
- "exports": {"query": EXPORTS, "description": "すべてのエクスポート文を検索"},
125
- "objects": {
126
- "query": OBJECTS,
127
- "description": "オブジェクトリテラルとプロパティ定義を検索",
128
- },
129
- "comments": {"query": COMMENTS, "description": "すべてのコメントを検索"},
130
- }
131
-
132
-
133
- def get_query(name: str) -> str:
134
- """Get a specific query by name."""
135
- if name in ALL_QUERIES:
136
- return ALL_QUERIES[name]["query"]
137
- raise ValueError(
138
- f"Query '{name}' not found. Available queries: {list(ALL_QUERIES.keys())}"
139
- )
140
-
141
-
142
- def get_all_queries() -> dict:
143
- """Get all available queries."""
144
- return ALL_QUERIES
145
-
146
-
147
- def list_queries() -> list:
148
- """List all available query names."""
149
- 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": "すべての関数宣言、式、メソッドを検索",
110
+ },
111
+ "classes": {
112
+ "query": CLASSES,
113
+ "description": "すべてのクラス宣言と式を検索",
114
+ },
115
+ "variables": {
116
+ "query": VARIABLES,
117
+ "description": "すべての変数宣言(var、let、const)を検索",
118
+ },
119
+ "imports": {
120
+ "query": IMPORTS,
121
+ "description": "すべてのインポート文と句を検索",
122
+ },
123
+ "exports": {"query": EXPORTS, "description": "すべてのエクスポート文を検索"},
124
+ "objects": {
125
+ "query": OBJECTS,
126
+ "description": "オブジェクトリテラルとプロパティ定義を検索",
127
+ },
128
+ "comments": {"query": COMMENTS, "description": "すべてのコメントを検索"},
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())