jaclang 0.8.8__py3-none-any.whl → 0.8.10__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 +194 -10
- jaclang/cli/cmdreg.py +144 -8
- jaclang/compiler/__init__.py +6 -1
- jaclang/compiler/codeinfo.py +16 -1
- jaclang/compiler/constant.py +33 -8
- jaclang/compiler/jac.lark +154 -62
- jaclang/compiler/larkparse/jac_parser.py +2 -2
- jaclang/compiler/parser.py +656 -149
- jaclang/compiler/passes/__init__.py +2 -1
- jaclang/compiler/passes/ast_gen/__init__.py +5 -0
- jaclang/compiler/passes/ast_gen/base_ast_gen_pass.py +54 -0
- jaclang/compiler/passes/ast_gen/jsx_processor.py +344 -0
- jaclang/compiler/passes/ecmascript/__init__.py +25 -0
- jaclang/compiler/passes/ecmascript/es_unparse.py +576 -0
- jaclang/compiler/passes/ecmascript/esast_gen_pass.py +2068 -0
- jaclang/compiler/passes/ecmascript/estree.py +972 -0
- jaclang/compiler/passes/ecmascript/tests/__init__.py +1 -0
- jaclang/compiler/passes/ecmascript/tests/fixtures/advanced_language_features.jac +170 -0
- jaclang/compiler/passes/ecmascript/tests/fixtures/class_separate_impl.impl.jac +30 -0
- jaclang/compiler/passes/ecmascript/tests/fixtures/class_separate_impl.jac +14 -0
- jaclang/compiler/passes/ecmascript/tests/fixtures/client_jsx.jac +89 -0
- jaclang/compiler/passes/ecmascript/tests/fixtures/core_language_features.jac +195 -0
- jaclang/compiler/passes/ecmascript/tests/test_esast_gen_pass.py +167 -0
- jaclang/compiler/passes/ecmascript/tests/test_js_generation.py +239 -0
- jaclang/compiler/passes/main/__init__.py +0 -3
- jaclang/compiler/passes/main/annex_pass.py +23 -1
- jaclang/compiler/passes/main/def_use_pass.py +1 -0
- jaclang/compiler/passes/main/pyast_gen_pass.py +413 -255
- jaclang/compiler/passes/main/pyast_load_pass.py +48 -11
- jaclang/compiler/passes/main/pyjac_ast_link_pass.py +2 -0
- jaclang/compiler/passes/main/sym_tab_build_pass.py +18 -1
- jaclang/compiler/passes/main/tests/fixtures/autoimpl.cl.jac +7 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_arity.jac +3 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_class_construct.jac +33 -0
- jaclang/compiler/passes/main/tests/fixtures/defuse_modpath.jac +7 -0
- jaclang/compiler/passes/main/tests/fixtures/member_access_type_resolve.jac +2 -1
- jaclang/compiler/passes/main/tests/test_checker_pass.py +31 -3
- jaclang/compiler/passes/main/tests/test_def_use_pass.py +12 -0
- jaclang/compiler/passes/main/tests/test_import_pass.py +23 -4
- jaclang/compiler/passes/main/tests/test_predynamo_pass.py +13 -14
- jaclang/compiler/passes/main/tests/test_pyast_gen_pass.py +25 -0
- jaclang/compiler/passes/main/type_checker_pass.py +7 -0
- jaclang/compiler/passes/tool/doc_ir_gen_pass.py +219 -20
- jaclang/compiler/passes/tool/fuse_comments_pass.py +1 -10
- jaclang/compiler/passes/tool/jac_formatter_pass.py +2 -2
- jaclang/compiler/passes/tool/tests/fixtures/import_fmt.jac +7 -1
- jaclang/compiler/passes/tool/tests/fixtures/tagbreak.jac +135 -29
- jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +4 -1
- jaclang/compiler/passes/transform.py +9 -1
- jaclang/compiler/passes/uni_pass.py +5 -7
- jaclang/compiler/program.py +27 -26
- jaclang/compiler/tests/test_client_codegen.py +113 -0
- jaclang/compiler/tests/test_importer.py +12 -10
- jaclang/compiler/tests/test_parser.py +249 -3
- jaclang/compiler/type_system/type_evaluator.jac +1078 -0
- jaclang/compiler/type_system/type_utils.py +1 -1
- jaclang/compiler/type_system/types.py +6 -0
- jaclang/compiler/unitree.py +438 -82
- jaclang/langserve/engine.jac +224 -288
- jaclang/langserve/sem_manager.jac +12 -8
- jaclang/langserve/server.jac +48 -48
- jaclang/langserve/tests/fixtures/greet.py +17 -0
- jaclang/langserve/tests/fixtures/md_path.jac +22 -0
- jaclang/langserve/tests/fixtures/user.jac +15 -0
- jaclang/langserve/tests/test_server.py +66 -371
- jaclang/lib.py +17 -0
- jaclang/runtimelib/archetype.py +25 -25
- jaclang/runtimelib/client_bundle.py +169 -0
- jaclang/runtimelib/client_runtime.jac +586 -0
- jaclang/runtimelib/constructs.py +4 -2
- jaclang/runtimelib/machine.py +308 -139
- jaclang/runtimelib/meta_importer.py +111 -22
- jaclang/runtimelib/mtp.py +15 -0
- jaclang/runtimelib/server.py +1089 -0
- jaclang/runtimelib/tests/fixtures/client_app.jac +18 -0
- jaclang/runtimelib/tests/fixtures/custom_access_validation.jac +1 -1
- jaclang/runtimelib/tests/fixtures/savable_object.jac +4 -5
- jaclang/runtimelib/tests/fixtures/serve_api.jac +75 -0
- jaclang/runtimelib/tests/test_client_bundle.py +55 -0
- jaclang/runtimelib/tests/test_client_render.py +63 -0
- jaclang/runtimelib/tests/test_serve.py +1069 -0
- jaclang/settings.py +0 -3
- jaclang/tests/fixtures/attr_pattern_case.jac +18 -0
- jaclang/tests/fixtures/funccall_genexpr.jac +7 -0
- jaclang/tests/fixtures/funccall_genexpr.py +5 -0
- jaclang/tests/fixtures/iife_functions.jac +142 -0
- jaclang/tests/fixtures/iife_functions_client.jac +143 -0
- jaclang/tests/fixtures/multistatement_lambda.jac +116 -0
- jaclang/tests/fixtures/multistatement_lambda_client.jac +113 -0
- jaclang/tests/fixtures/needs_import_dup.jac +6 -4
- jaclang/tests/fixtures/py2jac_empty.py +0 -0
- jaclang/tests/fixtures/py_run.py +7 -5
- jaclang/tests/fixtures/pyfunc_fstr.py +2 -2
- jaclang/tests/fixtures/simple_lambda_test.jac +12 -0
- jaclang/tests/test_cli.py +134 -18
- jaclang/tests/test_language.py +120 -32
- jaclang/tests/test_reference.py +20 -3
- jaclang/utils/NonGPT.py +375 -0
- jaclang/utils/helpers.py +64 -20
- jaclang/utils/lang_tools.py +31 -4
- jaclang/utils/tests/test_lang_tools.py +5 -16
- jaclang/utils/treeprinter.py +8 -3
- {jaclang-0.8.8.dist-info → jaclang-0.8.10.dist-info}/METADATA +3 -3
- {jaclang-0.8.8.dist-info → jaclang-0.8.10.dist-info}/RECORD +106 -71
- jaclang/compiler/passes/main/binder_pass.py +0 -594
- jaclang/compiler/passes/main/tests/fixtures/sym_binder.jac +0 -47
- jaclang/compiler/passes/main/tests/test_binder_pass.py +0 -111
- jaclang/compiler/type_system/type_evaluator.py +0 -844
- jaclang/langserve/tests/session.jac +0 -294
- jaclang/langserve/tests/test_dev_server.py +0 -80
- jaclang/runtimelib/importer.py +0 -351
- jaclang/tests/test_typecheck.py +0 -542
- {jaclang-0.8.8.dist-info → jaclang-0.8.10.dist-info}/WHEEL +0 -0
- {jaclang-0.8.8.dist-info → jaclang-0.8.10.dist-info}/entry_points.txt +0 -0
|
@@ -6,7 +6,11 @@ import from typing { List, Optional, Tuple }
|
|
|
6
6
|
|
|
7
7
|
import jaclang.compiler.unitree as uni;
|
|
8
8
|
import from jaclang { JacMachineInterface as Jac }
|
|
9
|
-
import utils
|
|
9
|
+
import from jaclang.langserve.utils {
|
|
10
|
+
find_surrounding_tokens,
|
|
11
|
+
get_token_start,
|
|
12
|
+
get_line_of_code
|
|
13
|
+
}
|
|
10
14
|
import lsprotocol.types as lspt;
|
|
11
15
|
|
|
12
16
|
|
|
@@ -65,14 +69,14 @@ class SemTokManager {
|
|
|
65
69
|
change_end_line= change.range.end.line;
|
|
66
70
|
change_end_char= change.range.end.character;
|
|
67
71
|
is_delete= change.text == '';
|
|
68
|
-
(prev_token_index, next_token_index, insert_inside_token)=
|
|
72
|
+
(prev_token_index, next_token_index, insert_inside_token)= find_surrounding_tokens(change_start_line,
|
|
69
73
|
change_start_char,
|
|
70
74
|
change_end_line,
|
|
71
75
|
change_end_char,
|
|
72
76
|
sem_tokens);
|
|
73
|
-
prev_tok_pos=
|
|
74
|
-
nxt_tok_pos=
|
|
75
|
-
changing_line_text=
|
|
77
|
+
prev_tok_pos= get_token_start(prev_token_index, sem_tokens);
|
|
78
|
+
nxt_tok_pos= get_token_start(next_token_index, sem_tokens);
|
|
79
|
+
changing_line_text= get_line_of_code(change_start_line, document_lines);
|
|
76
80
|
if not changing_line_text {return sem_tokens ;}
|
|
77
81
|
is_edit_between_tokens= bool(change_start_line > prev_tok_pos[0] or change_start_line == prev_tok_pos[0] and change_start_char > ( prev_tok_pos[
|
|
78
82
|
1
|
|
@@ -86,7 +90,7 @@ class SemTokManager {
|
|
|
86
90
|
if is_delete {
|
|
87
91
|
next_token_index= ( prev_token_index + 5 ) if insert_inside_token and prev_token_index is not None or next_token_index and prev_token_index is not None and next_token_index >= 10 and ( next_token_index - prev_token_index ) == 10 else next_token_index;
|
|
88
92
|
if next_token_index is None {return sem_tokens ;}
|
|
89
|
-
nxt_tok_pos=
|
|
93
|
+
nxt_tok_pos= get_token_start(next_token_index, sem_tokens);
|
|
90
94
|
is_single_line_change= change_end_line == change_start_line;
|
|
91
95
|
is_next_token_same_line= change_end_line == nxt_tok_pos[0];
|
|
92
96
|
if is_single_line_change and insert_inside_token and prev_token_index is not None {
|
|
@@ -290,7 +294,7 @@ class SemTokManager {
|
|
|
290
294
|
} else {
|
|
291
295
|
is_token_boundary_edit= True;
|
|
292
296
|
next_token_index= ( prev_token_index + 5 );
|
|
293
|
-
nxt_tok_pos=
|
|
297
|
+
nxt_tok_pos= get_token_start(next_token_index, sem_tokens);
|
|
294
298
|
break ;
|
|
295
299
|
}
|
|
296
300
|
}
|
|
@@ -299,7 +303,7 @@ class SemTokManager {
|
|
|
299
303
|
selected_region= ( change_end_char - change_start_char );
|
|
300
304
|
index_offset= 2;
|
|
301
305
|
sem_tokens[( prev_token_index + index_offset )] += ( len(change.text) - selected_region );
|
|
302
|
-
if prev_tok_pos[0] ==
|
|
306
|
+
if prev_tok_pos[0] == get_token_start(( prev_token_index + 5 ),
|
|
303
307
|
sem_tokens)[0] {
|
|
304
308
|
sem_tokens[( ( prev_token_index + index_offset ) + 4 )] += ( len(change.text) - selected_region );
|
|
305
309
|
}
|
jaclang/langserve/server.jac
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"""Jaclang Language Server."""
|
|
2
2
|
|
|
3
3
|
import asyncio;
|
|
4
|
+
import sys;
|
|
5
|
+
import time;
|
|
4
6
|
|
|
5
7
|
import from typing { Optional }
|
|
6
8
|
|
|
@@ -9,7 +11,7 @@ import from jaclang.compiler.constant {
|
|
|
9
11
|
JacSemTokenType as SemTokType
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
import from engine { JacLangServer }
|
|
14
|
+
import from .engine { JacLangServer }
|
|
13
15
|
import from jaclang.settings { settings }
|
|
14
16
|
|
|
15
17
|
import lsprotocol.types as lspt;
|
|
@@ -19,16 +21,18 @@ with entry {
|
|
|
19
21
|
server = JacLangServer();
|
|
20
22
|
}
|
|
21
23
|
|
|
24
|
+
|
|
22
25
|
def debug(ls: JacLangServer, msg: str) -> None {
|
|
23
26
|
ls.log_py(f"[DEBUG] " + ("-" * 80));
|
|
24
27
|
ls.log_py(f"[DEBUG]' {msg} ");
|
|
25
28
|
ls.log_py(f"[DEBUG] " + ("-" * 80));
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
|
|
28
32
|
"""Check syntax on change."""
|
|
29
33
|
@server.feature(lspt.TEXT_DOCUMENT_DID_OPEN)
|
|
30
34
|
async def did_open(ls: JacLangServer, params: lspt.DidOpenTextDocumentParams) -> None {
|
|
31
|
-
await ls.
|
|
35
|
+
await ls.type_check(params.text_document.uri);
|
|
32
36
|
ls.lsp.send_request(lspt.WORKSPACE_SEMANTIC_TOKENS_REFRESH);
|
|
33
37
|
}
|
|
34
38
|
|
|
@@ -36,31 +40,31 @@ async def did_open(ls: JacLangServer, params: lspt.DidOpenTextDocumentParams) ->
|
|
|
36
40
|
"""Check syntax on change."""
|
|
37
41
|
@server.feature(lspt.TEXT_DOCUMENT_DID_SAVE)
|
|
38
42
|
async def did_save(ls: JacLangServer, params: lspt.DidOpenTextDocumentParams) -> None {
|
|
43
|
+
|
|
39
44
|
file_path = params.text_document.uri;
|
|
40
|
-
|
|
41
|
-
if not quick_check_passed {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
await ls.launch_deep_check(file_path, delay=0.2);
|
|
45
|
+
await ls.type_check(file_path);
|
|
45
46
|
ls.lsp.send_request(lspt.WORKSPACE_SEMANTIC_TOKENS_REFRESH);
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
|
|
48
50
|
glob still_compiling = False;
|
|
49
51
|
|
|
52
|
+
|
|
50
53
|
"""Check syntax on change with debouncing."""
|
|
51
|
-
@
|
|
54
|
+
@server.feature(lspt.TEXT_DOCUMENT_DID_CHANGE)
|
|
52
55
|
async def did_change(
|
|
53
|
-
ls: JacLangServer,
|
|
54
|
-
params: lspt.DidChangeTextDocumentParams
|
|
56
|
+
ls: JacLangServer, params: lspt.DidChangeTextDocumentParams
|
|
55
57
|
) -> None {
|
|
58
|
+
print("********* ->", time.time(), file=sys.stderr);
|
|
59
|
+
|
|
56
60
|
global still_compiling;
|
|
57
61
|
still_compiling = True;
|
|
58
|
-
|
|
59
62
|
file_path = params.text_document.uri;
|
|
60
63
|
try {
|
|
61
64
|
document = ls.workspace.get_text_document(file_path);
|
|
62
65
|
lines = document.source.splitlines();
|
|
63
|
-
fs_path = document.path;
|
|
66
|
+
fs_path :str= document.path;
|
|
67
|
+
fs_path;
|
|
64
68
|
if (fs_path in ls.sem_managers) {
|
|
65
69
|
sem_manager = ls.sem_managers[fs_path];
|
|
66
70
|
sem_manager.update_sem_tokens(params, sem_manager.sem_tokens, lines);
|
|
@@ -69,27 +73,20 @@ async def did_change(
|
|
|
69
73
|
} except Exception as e {
|
|
70
74
|
ls.log_py(f" 'Failed to update semantic tokens: ' {e} ");
|
|
71
75
|
}
|
|
76
|
+
debug(ls, "Type checking started...");
|
|
77
|
+
ls.log_py(f" 'Launching type check for ' {file_path} ");
|
|
78
|
+
await ls.type_check(file_path);
|
|
79
|
+
ls.lsp.send_request(lspt.WORKSPACE_SEMANTIC_TOKENS_REFRESH);
|
|
72
80
|
|
|
73
|
-
debug(ls, "Compilation started...");
|
|
74
|
-
ls.log_py(f" 'Launching debounced quick check for ' {file_path} ");
|
|
75
|
-
quick_check_passed = await ls.launch_quick_check(file_path, delay=0.5);
|
|
76
|
-
if quick_check_passed {
|
|
77
|
-
ls.log_py(
|
|
78
|
-
f" 'Quick check passed, launching debounced deep check for ' {file_path} "
|
|
79
|
-
);
|
|
80
|
-
await ls.launch_deep_check(file_path, delay=1.0);
|
|
81
|
-
|
|
82
|
-
ls.lsp.send_request(lspt.WORKSPACE_SEMANTIC_TOKENS_REFRESH);
|
|
83
|
-
}
|
|
84
81
|
still_compiling = False;
|
|
85
|
-
debug(ls, "
|
|
82
|
+
debug(ls, "Type checking finished...");
|
|
86
83
|
}
|
|
87
84
|
|
|
85
|
+
|
|
88
86
|
"""Format the given document."""
|
|
89
87
|
@server.feature(lspt.TEXT_DOCUMENT_FORMATTING)
|
|
90
88
|
def formatting(
|
|
91
|
-
ls: JacLangServer,
|
|
92
|
-
params: lspt.DocumentFormattingParams
|
|
89
|
+
ls: JacLangServer, params: lspt.DocumentFormattingParams
|
|
93
90
|
) -> list[lspt.TextEdit] {
|
|
94
91
|
return ls.formatted_jac(params.text_document.uri);
|
|
95
92
|
}
|
|
@@ -99,22 +96,26 @@ def formatting(
|
|
|
99
96
|
@server.feature(
|
|
100
97
|
lspt.WORKSPACE_DID_CREATE_FILES,
|
|
101
98
|
lspt.FileOperationRegistrationOptions(
|
|
102
|
-
filters=[
|
|
99
|
+
filters=[
|
|
100
|
+
lspt.FileOperationFilter(pattern=lspt.FileOperationPattern('**/*.jac'))
|
|
101
|
+
]
|
|
103
102
|
)
|
|
104
103
|
)
|
|
105
|
-
def did_create_files(ls: JacLangServer, params: lspt.CreateFilesParams) -> None {}
|
|
104
|
+
def did_create_files(ls: JacLangServer, params: lspt.CreateFilesParams) -> None { }
|
|
106
105
|
|
|
107
106
|
|
|
108
107
|
"""Check syntax on file rename."""
|
|
109
108
|
@server.feature(
|
|
110
109
|
lspt.WORKSPACE_DID_RENAME_FILES,
|
|
111
110
|
lspt.FileOperationRegistrationOptions(
|
|
112
|
-
filters=[
|
|
111
|
+
filters=[
|
|
112
|
+
lspt.FileOperationFilter(pattern=lspt.FileOperationPattern('**/*.jac'))
|
|
113
|
+
]
|
|
113
114
|
)
|
|
114
115
|
)
|
|
115
116
|
def did_rename_files(ls: JacLangServer, params: lspt.RenameFilesParams) -> None {
|
|
116
|
-
new_uris = [
|
|
117
|
-
old_uris = [
|
|
117
|
+
new_uris = [file.new_uri for file in params.files];
|
|
118
|
+
old_uris = [file.old_uri for file in params.files];
|
|
118
119
|
for i in range(len(new_uris)) {
|
|
119
120
|
ls.rename_module(old_uris[i], new_uris[i]);
|
|
120
121
|
}
|
|
@@ -125,7 +126,9 @@ def did_rename_files(ls: JacLangServer, params: lspt.RenameFilesParams) -> None
|
|
|
125
126
|
@server.feature(
|
|
126
127
|
lspt.WORKSPACE_DID_DELETE_FILES,
|
|
127
128
|
lspt.FileOperationRegistrationOptions(
|
|
128
|
-
filters=[
|
|
129
|
+
filters=[
|
|
130
|
+
lspt.FileOperationFilter(pattern=lspt.FileOperationPattern('**/*.jac'))
|
|
131
|
+
]
|
|
129
132
|
)
|
|
130
133
|
)
|
|
131
134
|
def did_delete_files(ls: JacLangServer, params: lspt.DeleteFilesParams) -> None {
|
|
@@ -140,19 +143,19 @@ def did_delete_files(ls: JacLangServer, params: lspt.DeleteFilesParams) -> None
|
|
|
140
143
|
lspt.TEXT_DOCUMENT_COMPLETION,
|
|
141
144
|
lspt.CompletionOptions(trigger_characters=['.', ':', 'a-zA-Z0-9'])
|
|
142
145
|
)
|
|
143
|
-
async def completion(
|
|
144
|
-
|
|
146
|
+
async def completion(
|
|
147
|
+
ls: JacLangServer, params: lspt.CompletionParams
|
|
148
|
+
) -> lspt.CompletionList {
|
|
145
149
|
debug(ls, "Waiting for compilation to finish...");
|
|
146
150
|
global still_compiling;
|
|
147
151
|
while still_compiling {
|
|
148
152
|
await asyncio.sleep(0.1);
|
|
149
153
|
}
|
|
150
154
|
debug(ls, "Compilation finished, providing completions...");
|
|
151
|
-
|
|
152
155
|
return ls.get_completion(
|
|
153
156
|
params.text_document.uri,
|
|
154
157
|
params.position,
|
|
155
|
-
params.context.trigger_character if params.context else None
|
|
158
|
+
(params.context.trigger_character if params.context else None)
|
|
156
159
|
);
|
|
157
160
|
}
|
|
158
161
|
|
|
@@ -160,8 +163,7 @@ async def completion(ls: JacLangServer, params: lspt.CompletionParams) -> lspt.C
|
|
|
160
163
|
"""Provide hover information for the given hover request."""
|
|
161
164
|
@server.feature(lspt.TEXT_DOCUMENT_HOVER, lspt.HoverOptions(work_done_progress=True))
|
|
162
165
|
def hover(
|
|
163
|
-
ls: JacLangServer,
|
|
164
|
-
params: lspt.TextDocumentPositionParams
|
|
166
|
+
ls: JacLangServer, params: lspt.TextDocumentPositionParams
|
|
165
167
|
) -> Optional[lspt.Hover] {
|
|
166
168
|
return ls.get_hover_info(params.text_document.uri, params.position);
|
|
167
169
|
}
|
|
@@ -170,8 +172,7 @@ def hover(
|
|
|
170
172
|
"""Provide document symbols."""
|
|
171
173
|
@server.feature(lspt.TEXT_DOCUMENT_DOCUMENT_SYMBOL)
|
|
172
174
|
def document_symbol(
|
|
173
|
-
ls: JacLangServer,
|
|
174
|
-
params: lspt.DocumentSymbolParams
|
|
175
|
+
ls: JacLangServer, params: lspt.DocumentSymbolParams
|
|
175
176
|
) -> list[lspt.DocumentSymbol] {
|
|
176
177
|
return ls.get_outline(params.text_document.uri);
|
|
177
178
|
}
|
|
@@ -180,8 +181,7 @@ def document_symbol(
|
|
|
180
181
|
"""Provide definition."""
|
|
181
182
|
@server.feature(lspt.TEXT_DOCUMENT_DEFINITION)
|
|
182
183
|
def definition(
|
|
183
|
-
ls: JacLangServer,
|
|
184
|
-
params: lspt.TextDocumentPositionParams
|
|
184
|
+
ls: JacLangServer, params: lspt.TextDocumentPositionParams
|
|
185
185
|
) -> Optional[lspt.Location] {
|
|
186
186
|
return ls.get_definition(params.text_document.uri, params.position);
|
|
187
187
|
}
|
|
@@ -196,7 +196,9 @@ def references(ls: JacLangServer, params: lspt.ReferenceParams) -> list[lspt.Loc
|
|
|
196
196
|
|
|
197
197
|
"""Rename symbol."""
|
|
198
198
|
@server.feature(lspt.TEXT_DOCUMENT_RENAME)
|
|
199
|
-
def rename(
|
|
199
|
+
def rename(
|
|
200
|
+
ls: JacLangServer, params: lspt.RenameParams
|
|
201
|
+
) -> Optional[lspt.WorkspaceEdit] {
|
|
200
202
|
ls.log_warning('Auto Rename is Experimental, Please use with caution.');
|
|
201
203
|
return ls.rename_symbol(params.text_document.uri, params.position, params.new_name);
|
|
202
204
|
}
|
|
@@ -206,20 +208,18 @@ def rename(ls: JacLangServer, params: lspt.RenameParams) -> Optional[lspt.Worksp
|
|
|
206
208
|
@server.feature(
|
|
207
209
|
lspt.TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL,
|
|
208
210
|
lspt.SemanticTokensLegend(
|
|
209
|
-
token_types=SemTokType.as_str_list(),
|
|
210
|
-
token_modifiers=SemTokMod.as_str_list()
|
|
211
|
+
token_types=SemTokType.as_str_list(), token_modifiers=SemTokMod.as_str_list()
|
|
211
212
|
)
|
|
212
213
|
)
|
|
213
214
|
def semantic_tokens_full(
|
|
214
|
-
ls: JacLangServer,
|
|
215
|
-
params: lspt.SemanticTokensParams
|
|
215
|
+
ls: JacLangServer, params: lspt.SemanticTokensParams
|
|
216
216
|
) -> lspt.SemanticTokens {
|
|
217
217
|
return ls.get_semantic_tokens(params.text_document.uri);
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
|
|
221
221
|
"""Run the language server."""
|
|
222
|
-
def run_lang_server()
|
|
222
|
+
def run_lang_server() -> None {
|
|
223
223
|
settings.pass_timer = True;
|
|
224
224
|
server.start_io();
|
|
225
225
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class GreetMessage:
|
|
5
|
+
|
|
6
|
+
def pass_message(self, msg: str) -> str:
|
|
7
|
+
return f"Hello, {msg}!"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Greet:
|
|
12
|
+
|
|
13
|
+
def try_to_greet(self) -> GreetMessage:
|
|
14
|
+
return GreetMessage()
|
|
15
|
+
|
|
16
|
+
def say_hello(self) -> str:
|
|
17
|
+
return self.try_to_greet().pass_message("World")
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Living Workspace of Jac project."""
|
|
2
|
+
|
|
3
|
+
import asyncio;
|
|
4
|
+
import logging;
|
|
5
|
+
import time;
|
|
6
|
+
import from concurrent.futures { ThreadPoolExecutor } # TODO: go_to_def is not working here bcz threadpoolexecutor is inside some if statement
|
|
7
|
+
import from typing { Callable, Optional }
|
|
8
|
+
|
|
9
|
+
import jaclang.compiler.unitree as uni;
|
|
10
|
+
import from jaclang { JacMachineInterface } # TODO: go_to_def is not working here
|
|
11
|
+
import from jaclang.compiler.constant { SymbolType }
|
|
12
|
+
import from jaclang.compiler.program { JacProgram }
|
|
13
|
+
import from jaclang.compiler.type_system.type_utils { get_completion_items }
|
|
14
|
+
import from jaclang.compiler.type_system.types { ClassType, FunctionType, ModuleType, TypeBase }
|
|
15
|
+
import from jaclang.compiler.unitree { UniScopeNode }
|
|
16
|
+
import from missing_mod { SemTokManager }
|
|
17
|
+
import from circle {RAD}
|
|
18
|
+
import from jaclang.vendor.pygls { uris }
|
|
19
|
+
import from jaclang.vendor.pygls.server { LanguageServer }
|
|
20
|
+
|
|
21
|
+
import lsprotocol.types as lspt;
|
|
22
|
+
import nonexistent_module;
|