jaclang 0.8.0__py3-none-any.whl → 0.8.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 jaclang might be problematic. Click here for more details.
- jaclang/cli/cli.py +11 -9
- jaclang/compiler/jac.lark +2 -12
- jaclang/compiler/larkparse/jac_parser.py +1 -1
- jaclang/compiler/parser.py +360 -521
- jaclang/compiler/passes/main/cfg_build_pass.py +2 -2
- jaclang/compiler/passes/main/def_impl_match_pass.py +14 -13
- jaclang/compiler/passes/main/def_use_pass.py +4 -7
- jaclang/compiler/passes/main/import_pass.py +3 -3
- jaclang/compiler/passes/main/inheritance_pass.py +2 -2
- jaclang/compiler/passes/main/pyast_gen_pass.py +196 -218
- jaclang/compiler/passes/main/pyast_load_pass.py +115 -311
- jaclang/compiler/passes/main/pyjac_ast_link_pass.py +8 -7
- jaclang/compiler/passes/main/sym_tab_build_pass.py +3 -3
- jaclang/compiler/passes/main/sym_tab_link_pass.py +4 -4
- jaclang/compiler/passes/main/tests/fixtures/symtab_link_tests/action/actions.jac +1 -5
- jaclang/compiler/passes/main/tests/fixtures/symtab_link_tests/main.jac +1 -8
- jaclang/compiler/passes/main/tests/test_cfg_build_pass.py +4 -2
- jaclang/compiler/passes/tool/doc_ir_gen_pass.py +197 -120
- jaclang/compiler/program.py +2 -7
- jaclang/compiler/tests/fixtures/fam.jac +2 -2
- jaclang/compiler/tests/fixtures/pkg_import_lib/__init__.jac +1 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib/sub/__init__.jac +1 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib/sub/helper.jac +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib/tools.jac +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib_py/__init__.py +11 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib_py/sub/__init__.py +7 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib_py/sub/helper.jac +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib_py/tools.jac +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_main.jac +10 -0
- jaclang/compiler/tests/fixtures/pkg_import_main_py.jac +11 -0
- jaclang/compiler/tests/test_importer.py +20 -0
- jaclang/compiler/tests/test_parser.py +1 -0
- jaclang/compiler/unitree.py +456 -304
- jaclang/langserve/engine.jac +498 -0
- jaclang/langserve/sem_manager.jac +309 -0
- jaclang/langserve/server.jac +186 -0
- jaclang/langserve/tests/server_test/test_lang_serve.py +6 -7
- jaclang/langserve/tests/server_test/utils.py +4 -1
- jaclang/langserve/tests/session.jac +294 -0
- jaclang/langserve/tests/test_sem_tokens.py +2 -2
- jaclang/langserve/tests/test_server.py +12 -7
- jaclang/langserve/utils.jac +51 -30
- jaclang/runtimelib/archetype.py +1 -1
- jaclang/runtimelib/builtin.py +17 -14
- jaclang/runtimelib/importer.py +26 -8
- jaclang/runtimelib/machine.py +96 -55
- jaclang/runtimelib/tests/fixtures/traversing_save.jac +7 -5
- jaclang/runtimelib/utils.py +3 -3
- jaclang/tests/fixtures/backward_edge_visit.jac +31 -0
- jaclang/tests/fixtures/builtin_printgraph.jac +85 -0
- jaclang/tests/fixtures/builtin_printgraph_json.jac +21 -0
- jaclang/tests/fixtures/builtin_printgraph_mermaid.jac +16 -0
- jaclang/tests/fixtures/chandra_bugs2.jac +20 -13
- jaclang/tests/fixtures/concurrency.jac +1 -1
- jaclang/tests/fixtures/edge_ability.jac +49 -0
- jaclang/tests/fixtures/guess_game.jac +1 -1
- jaclang/tests/fixtures/here_usage_error.jac +21 -0
- jaclang/tests/fixtures/here_visitor_usage.jac +21 -0
- jaclang/tests/fixtures/node_del.jac +30 -36
- jaclang/tests/fixtures/visit_traversal.jac +47 -0
- jaclang/tests/test_cli.py +12 -7
- jaclang/tests/test_language.py +91 -16
- jaclang/utils/helpers.py +14 -6
- jaclang/utils/lang_tools.py +2 -3
- jaclang/utils/tests/test_lang_tools.py +2 -1
- jaclang/utils/treeprinter.py +3 -4
- {jaclang-0.8.0.dist-info → jaclang-0.8.1.dist-info}/METADATA +4 -3
- {jaclang-0.8.0.dist-info → jaclang-0.8.1.dist-info}/RECORD +71 -55
- {jaclang-0.8.0.dist-info → jaclang-0.8.1.dist-info}/WHEEL +1 -1
- jaclang/langserve/engine.py +0 -553
- jaclang/langserve/sem_manager.py +0 -383
- jaclang/langserve/server.py +0 -167
- jaclang/langserve/tests/session.py +0 -255
- jaclang/tests/fixtures/builtin_dotgen.jac +0 -42
- jaclang/tests/fixtures/builtin_dotgen_json.jac +0 -21
- /jaclang/langserve/{__init__.py → __init__.jac} +0 -0
- {jaclang-0.8.0.dist-info → jaclang-0.8.1.dist-info}/entry_points.txt +0 -0
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
"""Provides LSP session helpers for testing."""
|
|
2
|
-
|
|
3
|
-
import os
|
|
4
|
-
import subprocess
|
|
5
|
-
import sys
|
|
6
|
-
from concurrent.futures import Future, ThreadPoolExecutor
|
|
7
|
-
from threading import Event
|
|
8
|
-
|
|
9
|
-
from .pylsp_jsonrpc.dispatchers import MethodDispatcher
|
|
10
|
-
from .pylsp_jsonrpc.endpoint import Endpoint
|
|
11
|
-
from .pylsp_jsonrpc.streams import JsonRpcStreamReader, JsonRpcStreamWriter
|
|
12
|
-
|
|
13
|
-
from . import defaults
|
|
14
|
-
|
|
15
|
-
LSP_EXIT_TIMEOUT = 5000
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
PUBLISH_DIAGNOSTICS = "textDocument/publishDiagnostics"
|
|
19
|
-
WINDOW_LOG_MESSAGE = "window/logMessage"
|
|
20
|
-
WINDOW_SHOW_MESSAGE = "window/showMessage"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class LspSession(MethodDispatcher):
|
|
24
|
-
"""Send and Receive messages over LSP as a test LS Client."""
|
|
25
|
-
|
|
26
|
-
def __init__(self, cwd=None):
|
|
27
|
-
self.cwd = cwd if cwd else os.getcwd()
|
|
28
|
-
self._thread_pool = ThreadPoolExecutor()
|
|
29
|
-
self._sub = None
|
|
30
|
-
self._writer = None
|
|
31
|
-
self._reader = None
|
|
32
|
-
self._endpoint = None
|
|
33
|
-
self._notification_callbacks = {}
|
|
34
|
-
|
|
35
|
-
def __enter__(self):
|
|
36
|
-
"""Context manager entrypoint.
|
|
37
|
-
|
|
38
|
-
shell=True needed for pytest-cov to work in subprocess.
|
|
39
|
-
"""
|
|
40
|
-
self._sub = subprocess.Popen(
|
|
41
|
-
[
|
|
42
|
-
sys.executable,
|
|
43
|
-
os.path.join(os.path.dirname(os.path.dirname(__file__)), "server.py"),
|
|
44
|
-
],
|
|
45
|
-
stdout=subprocess.PIPE,
|
|
46
|
-
stdin=subprocess.PIPE,
|
|
47
|
-
stderr=subprocess.DEVNULL,
|
|
48
|
-
bufsize=0,
|
|
49
|
-
cwd=self.cwd,
|
|
50
|
-
env=os.environ,
|
|
51
|
-
shell="WITH_COVERAGE" in os.environ,
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
self._writer = JsonRpcStreamWriter(os.fdopen(self._sub.stdin.fileno(), "wb"))
|
|
55
|
-
self._reader = JsonRpcStreamReader(os.fdopen(self._sub.stdout.fileno(), "rb"))
|
|
56
|
-
|
|
57
|
-
dispatcher = {
|
|
58
|
-
PUBLISH_DIAGNOSTICS: self._publish_diagnostics,
|
|
59
|
-
WINDOW_SHOW_MESSAGE: self._window_show_message,
|
|
60
|
-
WINDOW_LOG_MESSAGE: self._window_log_message,
|
|
61
|
-
}
|
|
62
|
-
self._endpoint = Endpoint(dispatcher, self._writer.write)
|
|
63
|
-
self._thread_pool.submit(self._reader.listen, self._endpoint.consume)
|
|
64
|
-
return self
|
|
65
|
-
|
|
66
|
-
def __exit__(self, typ, value, _tb):
|
|
67
|
-
self.shutdown(True)
|
|
68
|
-
try:
|
|
69
|
-
self._sub.terminate()
|
|
70
|
-
except Exception as e:
|
|
71
|
-
pass
|
|
72
|
-
self._endpoint.shutdown()
|
|
73
|
-
self._thread_pool.shutdown()
|
|
74
|
-
|
|
75
|
-
def initialize(
|
|
76
|
-
self,
|
|
77
|
-
initialize_params=None,
|
|
78
|
-
process_server_capabilities=None,
|
|
79
|
-
):
|
|
80
|
-
"""Sends the initialize request to LSP server."""
|
|
81
|
-
server_initialized = Event()
|
|
82
|
-
|
|
83
|
-
def _after_initialize(fut):
|
|
84
|
-
if process_server_capabilities:
|
|
85
|
-
process_server_capabilities(fut.result())
|
|
86
|
-
self.initialized()
|
|
87
|
-
server_initialized.set()
|
|
88
|
-
|
|
89
|
-
self._send_request(
|
|
90
|
-
"initialize",
|
|
91
|
-
params=(
|
|
92
|
-
initialize_params
|
|
93
|
-
if initialize_params is not None
|
|
94
|
-
else defaults.VSCODE_DEFAULT_INITIALIZE
|
|
95
|
-
),
|
|
96
|
-
handle_response=_after_initialize,
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
server_initialized.wait()
|
|
100
|
-
|
|
101
|
-
def initialized(self, initialized_params=None):
|
|
102
|
-
"""Sends the initialized notification to LSP server."""
|
|
103
|
-
if initialized_params is None:
|
|
104
|
-
initialized_params = {}
|
|
105
|
-
self._endpoint.notify("initialized", initialized_params)
|
|
106
|
-
|
|
107
|
-
def shutdown(self, should_exit, exit_timeout=LSP_EXIT_TIMEOUT):
|
|
108
|
-
"""Sends the shutdown request to LSP server."""
|
|
109
|
-
|
|
110
|
-
def _after_shutdown(_):
|
|
111
|
-
if should_exit:
|
|
112
|
-
self.exit_lsp(exit_timeout)
|
|
113
|
-
|
|
114
|
-
self._send_request("shutdown", handle_response=_after_shutdown)
|
|
115
|
-
|
|
116
|
-
def exit_lsp(self, exit_timeout=LSP_EXIT_TIMEOUT):
|
|
117
|
-
"""Handles LSP server process exit."""
|
|
118
|
-
self._endpoint.notify("exit")
|
|
119
|
-
assert self._sub.wait(exit_timeout) == 0
|
|
120
|
-
|
|
121
|
-
def text_document_completion(self, completion_params):
|
|
122
|
-
"""Sends text document completion request to LSP server."""
|
|
123
|
-
fut = self._send_request("textDocument/completion", params=completion_params)
|
|
124
|
-
return fut.result()
|
|
125
|
-
|
|
126
|
-
def text_document_rename(self, rename_params):
|
|
127
|
-
"""Sends text document rename request to LSP server."""
|
|
128
|
-
fut = self._send_request("textDocument/rename", params=rename_params)
|
|
129
|
-
return fut.result()
|
|
130
|
-
|
|
131
|
-
def text_document_code_action(self, code_action_params):
|
|
132
|
-
"""Sends text document code action request to LSP server."""
|
|
133
|
-
fut = self._send_request("textDocument/codeAction", params=code_action_params)
|
|
134
|
-
return fut.result()
|
|
135
|
-
|
|
136
|
-
def text_document_hover(self, hover_params):
|
|
137
|
-
"""Sends text document hover request to LSP server."""
|
|
138
|
-
fut = self._send_request("textDocument/hover", params=hover_params)
|
|
139
|
-
return fut.result()
|
|
140
|
-
|
|
141
|
-
def text_document_formatting(self, formatting_params):
|
|
142
|
-
"""Sends text document formatting request to LSP server."""
|
|
143
|
-
fut = self._send_request("textDocument/formatting", params=formatting_params)
|
|
144
|
-
return fut.result()
|
|
145
|
-
|
|
146
|
-
def text_document_signature_help(self, signature_help_params):
|
|
147
|
-
"""Sends text document hover request to LSP server."""
|
|
148
|
-
fut = self._send_request(
|
|
149
|
-
"textDocument/signatureHelp", params=signature_help_params
|
|
150
|
-
)
|
|
151
|
-
return fut.result()
|
|
152
|
-
|
|
153
|
-
def text_document_declaration(self, declaration_params):
|
|
154
|
-
"""Sends text document declaration request to LSP server."""
|
|
155
|
-
fut = self._send_request("textDocument/declaration", params=declaration_params)
|
|
156
|
-
return fut.result()
|
|
157
|
-
|
|
158
|
-
def text_document_definition(self, definition_params):
|
|
159
|
-
"""Sends text document definition request to LSP server."""
|
|
160
|
-
fut = self._send_request("textDocument/definition", params=definition_params)
|
|
161
|
-
return fut.result()
|
|
162
|
-
|
|
163
|
-
def text_document_symbol(self, document_symbol_params):
|
|
164
|
-
"""Sends text document symbol request to LSP server."""
|
|
165
|
-
fut = self._send_request(
|
|
166
|
-
"textDocument/documentSymbol", params=document_symbol_params
|
|
167
|
-
)
|
|
168
|
-
return fut.result()
|
|
169
|
-
|
|
170
|
-
def text_document_highlight(self, document_highlight_params):
|
|
171
|
-
"""Sends text document highlight request to LSP server."""
|
|
172
|
-
fut = self._send_request(
|
|
173
|
-
"textDocument/documentHighlight", params=document_highlight_params
|
|
174
|
-
)
|
|
175
|
-
return fut.result()
|
|
176
|
-
|
|
177
|
-
def text_document_references(self, references_params):
|
|
178
|
-
"""Sends text document references request to LSP server."""
|
|
179
|
-
fut = self._send_request("textDocument/references", params=references_params)
|
|
180
|
-
return fut.result()
|
|
181
|
-
|
|
182
|
-
def workspace_symbol(self, workspace_symbol_params):
|
|
183
|
-
"""Sends workspace symbol request to LSP server."""
|
|
184
|
-
fut = self._send_request("workspace/symbol", params=workspace_symbol_params)
|
|
185
|
-
return fut.result()
|
|
186
|
-
|
|
187
|
-
def completion_item_resolve(self, resolve_params):
|
|
188
|
-
"""Sends completion item resolve request to LSP server."""
|
|
189
|
-
fut = self._send_request("completionItem/resolve", params=resolve_params)
|
|
190
|
-
return fut.result()
|
|
191
|
-
|
|
192
|
-
def notify_did_change(self, did_change_params):
|
|
193
|
-
"""Sends did change notification to LSP Server."""
|
|
194
|
-
self._send_notification("textDocument/didChange", params=did_change_params)
|
|
195
|
-
|
|
196
|
-
def notify_did_save(self, did_save_params):
|
|
197
|
-
"""Sends did save notification to LSP Server."""
|
|
198
|
-
self._send_notification("textDocument/didSave", params=did_save_params)
|
|
199
|
-
|
|
200
|
-
def notify_did_open(self, did_open_params):
|
|
201
|
-
"""Sends did open notification to LSP Server."""
|
|
202
|
-
self._send_notification("textDocument/didOpen", params=did_open_params)
|
|
203
|
-
|
|
204
|
-
def set_notification_callback(self, notification_name, callback):
|
|
205
|
-
"""Set custom LS notification handler."""
|
|
206
|
-
self._notification_callbacks[notification_name] = callback
|
|
207
|
-
|
|
208
|
-
def get_notification_callback(self, notification_name):
|
|
209
|
-
"""Gets callback if set or default callback for a given LS notification."""
|
|
210
|
-
try:
|
|
211
|
-
return self._notification_callbacks[notification_name]
|
|
212
|
-
except KeyError:
|
|
213
|
-
|
|
214
|
-
def _default_handler(_params):
|
|
215
|
-
"""Default notification handler."""
|
|
216
|
-
|
|
217
|
-
return _default_handler
|
|
218
|
-
|
|
219
|
-
def _publish_diagnostics(self, publish_diagnostics_params):
|
|
220
|
-
"""Internal handler for text document publish diagnostics."""
|
|
221
|
-
return self._handle_notification(
|
|
222
|
-
PUBLISH_DIAGNOSTICS, publish_diagnostics_params
|
|
223
|
-
)
|
|
224
|
-
|
|
225
|
-
def _window_log_message(self, window_log_message_params):
|
|
226
|
-
"""Internal handler for window log message."""
|
|
227
|
-
return self._handle_notification(WINDOW_LOG_MESSAGE, window_log_message_params)
|
|
228
|
-
|
|
229
|
-
def _window_show_message(self, window_show_message_params):
|
|
230
|
-
"""Internal handler for window show message."""
|
|
231
|
-
return self._handle_notification(
|
|
232
|
-
WINDOW_SHOW_MESSAGE, window_show_message_params
|
|
233
|
-
)
|
|
234
|
-
|
|
235
|
-
def _handle_notification(self, notification_name, params):
|
|
236
|
-
"""Internal handler for notifications."""
|
|
237
|
-
fut = Future()
|
|
238
|
-
|
|
239
|
-
def _handler():
|
|
240
|
-
callback = self.get_notification_callback(notification_name)
|
|
241
|
-
callback(params)
|
|
242
|
-
fut.set_result(None)
|
|
243
|
-
|
|
244
|
-
self._thread_pool.submit(_handler)
|
|
245
|
-
return fut
|
|
246
|
-
|
|
247
|
-
def _send_request(self, name, params=None, handle_response=lambda f: f.done()):
|
|
248
|
-
"""Sends {name} request to the LSP server."""
|
|
249
|
-
fut = self._endpoint.request(name, params)
|
|
250
|
-
fut.add_done_callback(handle_response)
|
|
251
|
-
return fut
|
|
252
|
-
|
|
253
|
-
def _send_notification(self, name, params=None):
|
|
254
|
-
"""Sends {name} notification to the LSP server."""
|
|
255
|
-
self._endpoint.notify(name, params)
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
node a{
|
|
2
|
-
has val:int;
|
|
3
|
-
}
|
|
4
|
-
edge Edge1 {
|
|
5
|
-
has val: int = 5;
|
|
6
|
-
}
|
|
7
|
-
with entry{
|
|
8
|
-
end=root;
|
|
9
|
-
for i in range(0,4){
|
|
10
|
-
end++>(end:=[a(val=i) for i in range(0,3)]);
|
|
11
|
-
}
|
|
12
|
-
x=[a(val=i) for i in range(0,3)];
|
|
13
|
-
end=x[1];
|
|
14
|
-
for i in range(0,8){
|
|
15
|
-
locals()[chr(ord('b') + i)] = (values:=[a(val=j*i+5.2*i+6) for j in range(0,3)]);
|
|
16
|
-
end ++> (end:=values);
|
|
17
|
-
}
|
|
18
|
-
p=b[1];
|
|
19
|
-
for k in range(0,10){
|
|
20
|
-
p+>:Edge1:val=6:+>(p:=a(val=k));
|
|
21
|
-
}
|
|
22
|
-
# b++>c;
|
|
23
|
-
# c++>b;
|
|
24
|
-
d1=dotgen();l1=d1|>len; #generate dot for all connected with root
|
|
25
|
-
# d2=dotgen(b[1],Traverse=True,depth=20,bfs=False,node_limit=12);l2=d2|>len; #generate dot for all connected with root
|
|
26
|
-
d2=dotgen(b[1],edge_type= ["Edge1"],depth=20,traverse=True,bfs=False,node_limit=19);l2=d2|>len; #generate dot for all connected with root
|
|
27
|
-
d3=dotgen(b[2],edge_limit=5,depth=5);l3=d3|>len; #generate dot for all connected with b[1] node
|
|
28
|
-
d4=dotgen(b[1],bfs=True,edge_type= ["Edge1"],node_limit=100,edge_limit=900,depth=300);l4=d4|>len; #generate dot from nodes with depth 3 connected with b[1] node
|
|
29
|
-
d5=dotgen(b[1],node_limit=10,edge_limit=90);l5:=d5|>len; #generate dot from nodes with depth 3 connected with b[1] node
|
|
30
|
-
print(d1.count('a(val')==12,d1.count('#FFFFE0')==3,'Root' in d1,d1.count('label=""')==30);
|
|
31
|
-
print(d2.count('a(val')==19,d2.count('#F5E5FF')==2 ,'Edge1' not in d2,d2.count('label=""')==42);
|
|
32
|
-
print(d3.count('a(val')==6,d3.count('label=""')==5,d3.count('#F5E5FF')==1);
|
|
33
|
-
print(d4.count("a(val")==25,d4.count('label=""')==66,d4.count('#FFF0F')==3);
|
|
34
|
-
print(d5.count("Edge1(val=6)")==2, d5.count('label=""')==24);
|
|
35
|
-
# print(l3<l2);
|
|
36
|
-
# print(d1);
|
|
37
|
-
# print(d2);
|
|
38
|
-
# print(d3);
|
|
39
|
-
# print(d4);
|
|
40
|
-
# print(dotgen(node=b[2],bfs=True,depth=3.96,edge_limit=12,node_limit=12.96));
|
|
41
|
-
|
|
42
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import json;
|
|
2
|
-
|
|
3
|
-
node N {
|
|
4
|
-
has val: int;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
edge E {
|
|
8
|
-
has val: int = 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
with entry {
|
|
12
|
-
|
|
13
|
-
end = root;
|
|
14
|
-
|
|
15
|
-
for i in range(0, 2){
|
|
16
|
-
end+>:E:val=i:+>(end := [ N(val=i) for i in range(0, 2) ]);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
data = dotgen(node=root, as_json=True);
|
|
20
|
-
print(data);
|
|
21
|
-
}
|
|
File without changes
|
|
File without changes
|