jaclang 0.0.6__py3-none-any.whl → 0.0.8__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.

Files changed (82) hide show
  1. jaclang/__init__.py +2 -1
  2. jaclang/cli/__jac_gen__/__init__.py +0 -0
  3. jaclang/cli/__jac_gen__/cli.py +175 -0
  4. jaclang/cli/__jac_gen__/cmds.py +132 -0
  5. jaclang/cli/cmds.jac +3 -0
  6. jaclang/cli/impl/__jac_gen__/__init__.py +0 -0
  7. jaclang/cli/impl/__jac_gen__/cli_impl.py +16 -0
  8. jaclang/cli/impl/__jac_gen__/cmds_impl.py +26 -0
  9. jaclang/cli/impl/cmds_impl.jac +17 -3
  10. jaclang/core/__jac_gen__/__init__.py +0 -0
  11. jaclang/core/__jac_gen__/primitives.py +567 -0
  12. jaclang/core/impl/__jac_gen__/__init__.py +0 -0
  13. jaclang/core/impl/__jac_gen__/arch_impl.py +24 -0
  14. jaclang/core/impl/__jac_gen__/element_impl.py +26 -0
  15. jaclang/core/impl/__jac_gen__/exec_ctx_impl.py +12 -0
  16. jaclang/core/impl/__jac_gen__/memory_impl.py +14 -0
  17. jaclang/core/impl/element_impl.jac +2 -2
  18. jaclang/core/primitives.jac +1 -0
  19. jaclang/jac/absyntree.py +65 -42
  20. jaclang/jac/constant.py +4 -0
  21. jaclang/jac/importer.py +18 -60
  22. jaclang/jac/langserve.py +26 -0
  23. jaclang/jac/lexer.py +9 -1
  24. jaclang/jac/parser.py +135 -123
  25. jaclang/jac/passes/blue/ast_build_pass.py +410 -353
  26. jaclang/jac/passes/blue/blue_pygen_pass.py +15 -0
  27. jaclang/jac/passes/blue/decl_def_match_pass.py +33 -21
  28. jaclang/jac/passes/blue/import_pass.py +1 -1
  29. jaclang/jac/passes/blue/pyout_pass.py +47 -12
  30. jaclang/jac/passes/blue/sym_tab_build_pass.py +38 -127
  31. jaclang/jac/passes/blue/tests/test_ast_build_pass.py +2 -2
  32. jaclang/jac/passes/blue/tests/test_blue_pygen_pass.py +9 -30
  33. jaclang/jac/passes/blue/tests/test_decl_def_match_pass.py +13 -13
  34. jaclang/jac/passes/blue/tests/test_sym_tab_build_pass.py +6 -4
  35. jaclang/jac/passes/ir_pass.py +1 -1
  36. jaclang/jac/passes/purple/__jac_gen__/__init__.py +0 -0
  37. jaclang/jac/passes/purple/__jac_gen__/analyze_pass.py +37 -0
  38. jaclang/jac/passes/purple/__jac_gen__/purple_pygen_pass.py +305 -0
  39. jaclang/jac/passes/purple/impl/__jac_gen__/__init__.py +0 -0
  40. jaclang/jac/passes/purple/impl/__jac_gen__/purple_pygen_pass_impl.py +23 -0
  41. jaclang/jac/symtable.py +12 -4
  42. jaclang/jac/tests/fixtures/__jac_gen__/__init__.py +0 -0
  43. jaclang/jac/tests/fixtures/__jac_gen__/hello_world.py +16 -0
  44. jaclang/jac/tests/fixtures/fam.jac +7 -8
  45. jaclang/jac/transform.py +4 -3
  46. jaclang/jac/transpiler.py +13 -9
  47. jaclang/utils/fstring_parser.py +2 -2
  48. jaclang/utils/helpers.py +41 -0
  49. jaclang/utils/test.py +30 -0
  50. jaclang/vendor/__init__.py +1 -0
  51. jaclang/vendor/pygls/__init__.py +25 -0
  52. jaclang/vendor/pygls/capabilities.py +502 -0
  53. jaclang/vendor/pygls/client.py +176 -0
  54. jaclang/vendor/pygls/constants.py +26 -0
  55. jaclang/vendor/pygls/exceptions.py +220 -0
  56. jaclang/vendor/pygls/feature_manager.py +241 -0
  57. jaclang/vendor/pygls/lsp/__init__.py +139 -0
  58. jaclang/vendor/pygls/lsp/client.py +2224 -0
  59. jaclang/vendor/pygls/lsprotocol/__init__.py +2 -0
  60. jaclang/vendor/pygls/lsprotocol/_hooks.py +1233 -0
  61. jaclang/vendor/pygls/lsprotocol/converters.py +17 -0
  62. jaclang/vendor/pygls/lsprotocol/types.py +12820 -0
  63. jaclang/vendor/pygls/lsprotocol/validators.py +47 -0
  64. jaclang/vendor/pygls/progress.py +79 -0
  65. jaclang/vendor/pygls/protocol.py +1184 -0
  66. jaclang/vendor/pygls/server.py +620 -0
  67. jaclang/vendor/pygls/uris.py +184 -0
  68. jaclang/vendor/pygls/workspace/__init__.py +81 -0
  69. jaclang/vendor/pygls/workspace/position.py +204 -0
  70. jaclang/vendor/pygls/workspace/text_document.py +234 -0
  71. jaclang/vendor/pygls/workspace/workspace.py +311 -0
  72. {jaclang-0.0.6.dist-info → jaclang-0.0.8.dist-info}/METADATA +1 -1
  73. jaclang-0.0.8.dist-info/RECORD +118 -0
  74. jaclang/core/jaclang.jac +0 -62
  75. jaclang-0.0.6.dist-info/RECORD +0 -76
  76. /jaclang/{utils → vendor}/sly/__init__.py +0 -0
  77. /jaclang/{utils → vendor}/sly/docparse.py +0 -0
  78. /jaclang/{utils → vendor}/sly/lex.py +0 -0
  79. /jaclang/{utils → vendor}/sly/yacc.py +0 -0
  80. {jaclang-0.0.6.dist-info → jaclang-0.0.8.dist-info}/WHEEL +0 -0
  81. {jaclang-0.0.6.dist-info → jaclang-0.0.8.dist-info}/entry_points.txt +0 -0
  82. {jaclang-0.0.6.dist-info → jaclang-0.0.8.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,139 @@
1
+ ############################################################################
2
+ # Copyright(c) Open Law Library. All rights reserved. #
3
+ # See ThirdPartyNotices.txt in the project root for additional notices. #
4
+ # #
5
+ # Licensed under the Apache License, Version 2.0 (the "License") #
6
+ # you may not use this file except in compliance with the License. #
7
+ # You may obtain a copy of the License at #
8
+ # #
9
+ # http: // www.apache.org/licenses/LICENSE-2.0 #
10
+ # #
11
+ # Unless required by applicable law or agreed to in writing, software #
12
+ # distributed under the License is distributed on an "AS IS" BASIS, #
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14
+ # See the License for the specific language governing permissions and #
15
+ # limitations under the License. #
16
+ ############################################################################
17
+ from typing import Any, Callable, List, Optional, Union
18
+
19
+ from jaclang.vendor.pygls.lsprotocol.types import (
20
+ ALL_TYPES_MAP,
21
+ METHOD_TO_TYPES,
22
+ TEXT_DOCUMENT_DID_SAVE,
23
+ TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL,
24
+ TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL_DELTA,
25
+ TEXT_DOCUMENT_SEMANTIC_TOKENS_RANGE,
26
+ WORKSPACE_DID_CREATE_FILES,
27
+ WORKSPACE_DID_DELETE_FILES,
28
+ WORKSPACE_DID_RENAME_FILES,
29
+ WORKSPACE_WILL_CREATE_FILES,
30
+ WORKSPACE_WILL_DELETE_FILES,
31
+ WORKSPACE_WILL_RENAME_FILES,
32
+ FileOperationRegistrationOptions,
33
+ SaveOptions,
34
+ SemanticTokensLegend,
35
+ SemanticTokensRegistrationOptions,
36
+ ShowDocumentResult,
37
+ )
38
+ from typeguard import check_type
39
+
40
+ from jaclang.vendor.pygls.exceptions import MethodTypeNotRegisteredError
41
+
42
+ ConfigCallbackType = Callable[[List[Any]], None]
43
+ ShowDocumentCallbackType = Callable[[ShowDocumentResult], None]
44
+
45
+ METHOD_TO_OPTIONS = {
46
+ TEXT_DOCUMENT_DID_SAVE: SaveOptions,
47
+ TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL: Union[
48
+ SemanticTokensLegend, SemanticTokensRegistrationOptions
49
+ ],
50
+ TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL_DELTA: Union[
51
+ SemanticTokensLegend, SemanticTokensRegistrationOptions
52
+ ],
53
+ TEXT_DOCUMENT_SEMANTIC_TOKENS_RANGE: Union[
54
+ SemanticTokensLegend, SemanticTokensRegistrationOptions
55
+ ],
56
+ WORKSPACE_DID_CREATE_FILES: FileOperationRegistrationOptions,
57
+ WORKSPACE_DID_DELETE_FILES: FileOperationRegistrationOptions,
58
+ WORKSPACE_DID_RENAME_FILES: FileOperationRegistrationOptions,
59
+ WORKSPACE_WILL_CREATE_FILES: FileOperationRegistrationOptions,
60
+ WORKSPACE_WILL_DELETE_FILES: FileOperationRegistrationOptions,
61
+ WORKSPACE_WILL_RENAME_FILES: FileOperationRegistrationOptions,
62
+ }
63
+
64
+
65
+ def get_method_registration_options_type(
66
+ method_name, lsp_methods_map=METHOD_TO_TYPES
67
+ ) -> Optional[Any]:
68
+ """The type corresponding with a method's options when dynamically registering
69
+ capability for it."""
70
+
71
+ try:
72
+ return lsp_methods_map[method_name][3]
73
+ except KeyError:
74
+ raise MethodTypeNotRegisteredError(method_name)
75
+
76
+
77
+ def get_method_options_type(
78
+ method_name, lsp_options_map=METHOD_TO_OPTIONS, lsp_methods_map=METHOD_TO_TYPES
79
+ ) -> Optional[Any]:
80
+ """Return the type corresponding with a method's ``ServerCapabilities`` fields.
81
+
82
+ In the majority of cases this simply means returning the ``<MethodName>Options``
83
+ type, which we can easily derive from the method's
84
+ ``<MethodName>RegistrationOptions`` type.
85
+
86
+ However, where the options are more involved (such as semantic tokens) and
87
+ ``pygls`` does some extra work to help derive the options for the user the type
88
+ has to be provided via the ``lsp_options_map``
89
+
90
+ Arguments:
91
+ method_name:
92
+ The lsp method name to retrieve the options for
93
+
94
+ lsp_options_map:
95
+ The map used to override the default options type finding behavior
96
+
97
+ lsp_methods_map:
98
+ The standard map used to look up the various method types.
99
+ """
100
+
101
+ options_type = lsp_options_map.get(method_name, None)
102
+ if options_type is not None:
103
+ return options_type
104
+
105
+ registration_type = get_method_registration_options_type(
106
+ method_name, lsp_methods_map
107
+ )
108
+ if registration_type is None:
109
+ return None
110
+
111
+ type_name = registration_type.__name__.replace("Registration", "")
112
+ options_type = ALL_TYPES_MAP.get(type_name, None)
113
+
114
+ if options_type is None:
115
+ raise MethodTypeNotRegisteredError(method_name)
116
+
117
+ return options_type
118
+
119
+
120
+ def get_method_params_type(method_name, lsp_methods_map=METHOD_TO_TYPES):
121
+ try:
122
+ return lsp_methods_map[method_name][2]
123
+ except KeyError:
124
+ raise MethodTypeNotRegisteredError(method_name)
125
+
126
+
127
+ def get_method_return_type(method_name, lsp_methods_map=METHOD_TO_TYPES):
128
+ try:
129
+ return lsp_methods_map[method_name][1]
130
+ except KeyError:
131
+ raise MethodTypeNotRegisteredError(method_name)
132
+
133
+
134
+ def is_instance(o, t):
135
+ try:
136
+ check_type(o, t)
137
+ return True
138
+ except TypeError:
139
+ return False