@aehrc/ecl-core 1.0.0
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.
- package/LICENSE +201 -0
- package/README.md +142 -0
- package/dist/completion/context-detector.d.ts +51 -0
- package/dist/completion/context-detector.d.ts.map +1 -0
- package/dist/completion/context-detector.js +286 -0
- package/dist/completion/context-detector.js.map +1 -0
- package/dist/completion/context-items.d.ts +50 -0
- package/dist/completion/context-items.d.ts.map +1 -0
- package/dist/completion/context-items.js +526 -0
- package/dist/completion/context-items.js.map +1 -0
- package/dist/completion/filter-cache.d.ts +14 -0
- package/dist/completion/filter-cache.d.ts.map +1 -0
- package/dist/completion/filter-cache.js +55 -0
- package/dist/completion/filter-cache.js.map +1 -0
- package/dist/completion/provider.d.ts +34 -0
- package/dist/completion/provider.d.ts.map +1 -0
- package/dist/completion/provider.js +283 -0
- package/dist/completion/provider.js.map +1 -0
- package/dist/completion/snippets.d.ts +11 -0
- package/dist/completion/snippets.d.ts.map +1 -0
- package/dist/completion/snippets.js +80 -0
- package/dist/completion/snippets.js.map +1 -0
- package/dist/formatter/ast-printer.d.ts +12 -0
- package/dist/formatter/ast-printer.d.ts.map +1 -0
- package/dist/formatter/ast-printer.js +251 -0
- package/dist/formatter/ast-printer.js.map +1 -0
- package/dist/formatter/comments.d.ts +14 -0
- package/dist/formatter/comments.d.ts.map +1 -0
- package/dist/formatter/comments.js +232 -0
- package/dist/formatter/comments.js.map +1 -0
- package/dist/formatter/config.d.ts +5 -0
- package/dist/formatter/config.d.ts.map +1 -0
- package/dist/formatter/config.js +45 -0
- package/dist/formatter/config.js.map +1 -0
- package/dist/formatter/formatter.d.ts +3 -0
- package/dist/formatter/formatter.d.ts.map +1 -0
- package/dist/formatter/formatter.js +368 -0
- package/dist/formatter/formatter.js.map +1 -0
- package/dist/formatter/index.d.ts +6 -0
- package/dist/formatter/index.d.ts.map +1 -0
- package/dist/formatter/index.js +19 -0
- package/dist/formatter/index.js.map +1 -0
- package/dist/formatter/options.d.ts +31 -0
- package/dist/formatter/options.d.ts.map +1 -0
- package/dist/formatter/options.js +17 -0
- package/dist/formatter/options.js.map +1 -0
- package/dist/formatter/range.d.ts +16 -0
- package/dist/formatter/range.d.ts.map +1 -0
- package/dist/formatter/range.js +129 -0
- package/dist/formatter/range.js.map +1 -0
- package/dist/formatter/rules.d.ts +8 -0
- package/dist/formatter/rules.d.ts.map +1 -0
- package/dist/formatter/rules.js +42 -0
- package/dist/formatter/rules.js.map +1 -0
- package/dist/grammar/ECLLexer.d.ts +122 -0
- package/dist/grammar/ECLLexer.d.ts.map +1 -0
- package/dist/grammar/ECLLexer.js +399 -0
- package/dist/grammar/ECLLexer.js.map +1 -0
- package/dist/grammar/ECLParser.d.ts +2905 -0
- package/dist/grammar/ECLParser.d.ts.map +1 -0
- package/dist/grammar/ECLParser.js +24911 -0
- package/dist/grammar/ECLParser.js.map +1 -0
- package/dist/grammar/ECLVisitor.d.ts +1208 -0
- package/dist/grammar/ECLVisitor.d.ts.map +1 -0
- package/dist/grammar/ECLVisitor.js +4 -0
- package/dist/grammar/ECLVisitor.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +107 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge/filters.d.ts +6 -0
- package/dist/knowledge/filters.d.ts.map +1 -0
- package/dist/knowledge/filters.js +99 -0
- package/dist/knowledge/filters.js.map +1 -0
- package/dist/knowledge/grammar.d.ts +7 -0
- package/dist/knowledge/grammar.d.ts.map +1 -0
- package/dist/knowledge/grammar.js +217 -0
- package/dist/knowledge/grammar.js.map +1 -0
- package/dist/knowledge/index.d.ts +24 -0
- package/dist/knowledge/index.d.ts.map +1 -0
- package/dist/knowledge/index.js +101 -0
- package/dist/knowledge/index.js.map +1 -0
- package/dist/knowledge/operators.d.ts +10 -0
- package/dist/knowledge/operators.d.ts.map +1 -0
- package/dist/knowledge/operators.js +324 -0
- package/dist/knowledge/operators.js.map +1 -0
- package/dist/knowledge/patterns.d.ts +6 -0
- package/dist/knowledge/patterns.d.ts.map +1 -0
- package/dist/knowledge/patterns.js +172 -0
- package/dist/knowledge/patterns.js.map +1 -0
- package/dist/knowledge/refinements.d.ts +6 -0
- package/dist/knowledge/refinements.d.ts.map +1 -0
- package/dist/knowledge/refinements.js +134 -0
- package/dist/knowledge/refinements.js.map +1 -0
- package/dist/knowledge/types.d.ts +41 -0
- package/dist/knowledge/types.d.ts.map +1 -0
- package/dist/knowledge/types.js +5 -0
- package/dist/knowledge/types.js.map +1 -0
- package/dist/parser/ast.d.ts +111 -0
- package/dist/parser/ast.d.ts.map +1 -0
- package/dist/parser/ast.js +25 -0
- package/dist/parser/ast.js.map +1 -0
- package/dist/parser/concept-extractor.d.ts +21 -0
- package/dist/parser/concept-extractor.d.ts.map +1 -0
- package/dist/parser/concept-extractor.js +126 -0
- package/dist/parser/concept-extractor.js.map +1 -0
- package/dist/parser/error-analysis.d.ts +54 -0
- package/dist/parser/error-analysis.d.ts.map +1 -0
- package/dist/parser/error-analysis.js +260 -0
- package/dist/parser/error-analysis.js.map +1 -0
- package/dist/parser/error-listener.d.ts +14 -0
- package/dist/parser/error-listener.d.ts.map +1 -0
- package/dist/parser/error-listener.js +24 -0
- package/dist/parser/error-listener.js.map +1 -0
- package/dist/parser/expression-grouper.d.ts +20 -0
- package/dist/parser/expression-grouper.d.ts.map +1 -0
- package/dist/parser/expression-grouper.js +99 -0
- package/dist/parser/expression-grouper.js.map +1 -0
- package/dist/parser/generated/grammar/ECLLexer.d.ts +122 -0
- package/dist/parser/generated/grammar/ECLLexer.d.ts.map +1 -0
- package/dist/parser/generated/grammar/ECLLexer.js +399 -0
- package/dist/parser/generated/grammar/ECLLexer.js.map +1 -0
- package/dist/parser/generated/grammar/ECLParser.d.ts +2905 -0
- package/dist/parser/generated/grammar/ECLParser.d.ts.map +1 -0
- package/dist/parser/generated/grammar/ECLParser.js +24911 -0
- package/dist/parser/generated/grammar/ECLParser.js.map +1 -0
- package/dist/parser/generated/grammar/ECLVisitor.d.ts +1208 -0
- package/dist/parser/generated/grammar/ECLVisitor.d.ts.map +1 -0
- package/dist/parser/generated/grammar/ECLVisitor.js +4 -0
- package/dist/parser/generated/grammar/ECLVisitor.js.map +1 -0
- package/dist/parser/index.d.ts +26 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +202 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/position-detector.d.ts +45 -0
- package/dist/parser/position-detector.d.ts.map +1 -0
- package/dist/parser/position-detector.js +149 -0
- package/dist/parser/position-detector.js.map +1 -0
- package/dist/parser/refinement-check.d.ts +22 -0
- package/dist/parser/refinement-check.d.ts.map +1 -0
- package/dist/parser/refinement-check.js +194 -0
- package/dist/parser/refinement-check.js.map +1 -0
- package/dist/parser/visitor.d.ts +40 -0
- package/dist/parser/visitor.d.ts.map +1 -0
- package/dist/parser/visitor.js +587 -0
- package/dist/parser/visitor.js.map +1 -0
- package/dist/refactoring/add-description-filter.d.ts +8 -0
- package/dist/refactoring/add-description-filter.d.ts.map +1 -0
- package/dist/refactoring/add-description-filter.js +73 -0
- package/dist/refactoring/add-description-filter.js.map +1 -0
- package/dist/refactoring/add-display-terms.d.ts +20 -0
- package/dist/refactoring/add-display-terms.d.ts.map +1 -0
- package/dist/refactoring/add-display-terms.js +104 -0
- package/dist/refactoring/add-display-terms.js.map +1 -0
- package/dist/refactoring/add-history-supplement.d.ts +13 -0
- package/dist/refactoring/add-history-supplement.d.ts.map +1 -0
- package/dist/refactoring/add-history-supplement.js +80 -0
- package/dist/refactoring/add-history-supplement.js.map +1 -0
- package/dist/refactoring/add-parentheses.d.ts +14 -0
- package/dist/refactoring/add-parentheses.d.ts.map +1 -0
- package/dist/refactoring/add-parentheses.js +341 -0
- package/dist/refactoring/add-parentheses.js.map +1 -0
- package/dist/refactoring/index.d.ts +27 -0
- package/dist/refactoring/index.d.ts.map +1 -0
- package/dist/refactoring/index.js +237 -0
- package/dist/refactoring/index.js.map +1 -0
- package/dist/refactoring/remove-parentheses.d.ts +8 -0
- package/dist/refactoring/remove-parentheses.d.ts.map +1 -0
- package/dist/refactoring/remove-parentheses.js +162 -0
- package/dist/refactoring/remove-parentheses.js.map +1 -0
- package/dist/refactoring/simplify-expression.d.ts +15 -0
- package/dist/refactoring/simplify-expression.d.ts.map +1 -0
- package/dist/refactoring/simplify-expression.js +435 -0
- package/dist/refactoring/simplify-expression.js.map +1 -0
- package/dist/refactoring/strip-display-terms.d.ts +8 -0
- package/dist/refactoring/strip-display-terms.d.ts.map +1 -0
- package/dist/refactoring/strip-display-terms.js +27 -0
- package/dist/refactoring/strip-display-terms.js.map +1 -0
- package/dist/semantic/ecl-text.d.ts +35 -0
- package/dist/semantic/ecl-text.d.ts.map +1 -0
- package/dist/semantic/ecl-text.js +54 -0
- package/dist/semantic/ecl-text.js.map +1 -0
- package/dist/semantic/validator.d.ts +14 -0
- package/dist/semantic/validator.d.ts.map +1 -0
- package/dist/semantic/validator.js +183 -0
- package/dist/semantic/validator.js.map +1 -0
- package/dist/semantic-tokens.d.ts +12 -0
- package/dist/semantic-tokens.d.ts.map +1 -0
- package/dist/semantic-tokens.js +362 -0
- package/dist/semantic-tokens.js.map +1 -0
- package/dist/terminology/fetch-compat-browser.d.ts +3 -0
- package/dist/terminology/fetch-compat-browser.d.ts.map +1 -0
- package/dist/terminology/fetch-compat-browser.js +7 -0
- package/dist/terminology/fetch-compat-browser.js.map +1 -0
- package/dist/terminology/fetch-compat.d.ts +4 -0
- package/dist/terminology/fetch-compat.d.ts.map +1 -0
- package/dist/terminology/fetch-compat.js +18 -0
- package/dist/terminology/fetch-compat.js.map +1 -0
- package/dist/terminology/fhir-service.d.ts +65 -0
- package/dist/terminology/fhir-service.d.ts.map +1 -0
- package/dist/terminology/fhir-service.js +456 -0
- package/dist/terminology/fhir-service.js.map +1 -0
- package/dist/terminology/index.d.ts +4 -0
- package/dist/terminology/index.d.ts.map +1 -0
- package/dist/terminology/index.js +22 -0
- package/dist/terminology/index.js.map +1 -0
- package/dist/terminology/mock-service.d.ts +11 -0
- package/dist/terminology/mock-service.d.ts.map +1 -0
- package/dist/terminology/mock-service.js +108 -0
- package/dist/terminology/mock-service.js.map +1 -0
- package/dist/terminology/types.d.ts +31 -0
- package/dist/terminology/types.d.ts.map +1 -0
- package/dist/terminology/types.js +5 -0
- package/dist/terminology/types.js.map +1 -0
- package/dist/terminology/verhoeff.d.ts +38 -0
- package/dist/terminology/verhoeff.d.ts.map +1 -0
- package/dist/terminology/verhoeff.js +118 -0
- package/dist/terminology/verhoeff.js.map +1 -0
- package/dist/text-utils.d.ts +17 -0
- package/dist/text-utils.d.ts.map +1 -0
- package/dist/text-utils.js +49 -0
- package/dist/text-utils.js.map +1 -0
- package/dist/types.d.ts +64 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/types.js.map +1 -0
- package/dist/validation/error-refinement.d.ts +31 -0
- package/dist/validation/error-refinement.d.ts.map +1 -0
- package/dist/validation/error-refinement.js +173 -0
- package/dist/validation/error-refinement.js.map +1 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. Please also get an approval
|
|
186
|
+
from your employer if applicable.
|
|
187
|
+
|
|
188
|
+
Copyright 2024-2026 Commonwealth Scientific and Industrial Research
|
|
189
|
+
Organisation (CSIRO) ABN 41 687 119 230
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# @aehrc/ecl-core
|
|
2
|
+
|
|
3
|
+
Zero-dependency core library for SNOMED CT Expression Constraint Language (ECL) 2.2 — parsing, formatting, validation, completion, refactoring, and terminology integration.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @aehrc/ecl-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**Runtime dependencies:**
|
|
12
|
+
|
|
13
|
+
- `antlr4ts` — ANTLR4 TypeScript runtime (required)
|
|
14
|
+
- `node-fetch` — HTTP client for FHIR integration (optional; not needed if you provide your own `ITerminologyService`)
|
|
15
|
+
|
|
16
|
+
## API Overview
|
|
17
|
+
|
|
18
|
+
### Parsing
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { parseECL, extractConceptIds, groupIntoExpressions } from '@aehrc/ecl-core';
|
|
22
|
+
|
|
23
|
+
// Parse an ECL expression into an AST
|
|
24
|
+
const result = parseECL('< 404684003 |Clinical finding|');
|
|
25
|
+
console.log(result.ast); // ExpressionNode
|
|
26
|
+
console.log(result.errors); // ParseError[]
|
|
27
|
+
|
|
28
|
+
// Extract all concept IDs referenced in the AST
|
|
29
|
+
const concepts = extractConceptIds(result.ast);
|
|
30
|
+
// [{ id: '404684003', term: 'Clinical finding', range: { ... } }]
|
|
31
|
+
|
|
32
|
+
// Split a multi-expression document into individual expressions
|
|
33
|
+
const expressions = groupIntoExpressions(text);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**AST types:** `ExpressionNode`, `CompoundExpressionNode`, `RefinedExpressionNode`, `SubExpressionNode`, `AttributeNode`, `FilterConstraintNode`, `HistorySupplementNode`
|
|
37
|
+
|
|
38
|
+
### Formatting
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { formatDocument, defaultFormattingOptions } from '@aehrc/ecl-core';
|
|
42
|
+
|
|
43
|
+
const formatted = formatDocument('<<404684003:246075003=<<19829001', {
|
|
44
|
+
...defaultFormattingOptions,
|
|
45
|
+
maxLineLength: 80,
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Options:** `indentSize`, `indentStyle`, `spaceAroundOperators`, `maxLineLength`, `alignTerms`, `wrapComments`, `breakOnOperators`, `breakOnRefinementComma`, `breakAfterColon`
|
|
50
|
+
|
|
51
|
+
Range formatting is also supported via `expandToExpressionBoundaries`, `getExpressionsInRange`, and `formatRangeExpressions`.
|
|
52
|
+
|
|
53
|
+
### Validation
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { refineParseError } from '@aehrc/ecl-core';
|
|
57
|
+
|
|
58
|
+
// Convert ANTLR error messages to user-friendly diagnostics
|
|
59
|
+
const refined = refineParseError({ line, column, message, expression });
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Semantic Validation
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { validateSemantics, FhirTerminologyService } from '@aehrc/ecl-core';
|
|
66
|
+
|
|
67
|
+
const terminology = new FhirTerminologyService('https://tx.ontoserver.csiro.au/fhir');
|
|
68
|
+
const diagnostics = await validateSemantics(ast, text, terminology);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Completion
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { getCompletionItems, getCompletionItemsWithSearch } from '@aehrc/ecl-core';
|
|
75
|
+
|
|
76
|
+
// Synchronous completions (operators, keywords, snippets)
|
|
77
|
+
const items = getCompletionItems(text, offset);
|
|
78
|
+
|
|
79
|
+
// With FHIR concept search (async)
|
|
80
|
+
const items = await getCompletionItemsWithSearch(text, offset, terminology);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Refactoring
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { getRefactoringActions } from '@aehrc/ecl-core';
|
|
87
|
+
|
|
88
|
+
const actions = getRefactoringActions({ text, range, ast, errors });
|
|
89
|
+
// Returns: strip/add display terms, simplify, add/remove parentheses,
|
|
90
|
+
// history supplement, description filter
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Terminology
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { FhirTerminologyService } from '@aehrc/ecl-core';
|
|
97
|
+
|
|
98
|
+
const fhir = new FhirTerminologyService(
|
|
99
|
+
'https://tx.ontoserver.csiro.au/fhir', // server URL
|
|
100
|
+
2000, // lookup timeout (ms)
|
|
101
|
+
'', // SNOMED version URI (empty = server default)
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const concept = await fhir.lookupConcept('404684003');
|
|
105
|
+
// { id, fsn, pt, active }
|
|
106
|
+
|
|
107
|
+
const results = await fhir.evaluateEcl('< 404684003');
|
|
108
|
+
// { concepts: [...], total }
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Knowledge
|
|
112
|
+
|
|
113
|
+
Structured ECL reference documentation — 50 articles across 6 categories.
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
import { getArticle, getArticlesByCategory, getOperatorHoverDoc, getGuide } from '@aehrc/ecl-core';
|
|
117
|
+
|
|
118
|
+
const doc = getOperatorHoverDoc('<<'); // Hover documentation for descendantOrSelfOf
|
|
119
|
+
const articles = getArticlesByCategory('operators');
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Semantic Tokens
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import { computeSemanticTokens, eclTokenTypes, eclTokenModifiers } from '@aehrc/ecl-core';
|
|
126
|
+
|
|
127
|
+
const tokens = computeSemanticTokens(text);
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Utility
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import { isValidSnomedId, isValidConceptId, isValidDescriptionId } from '@aehrc/ecl-core';
|
|
134
|
+
import { checkMixedRefinementOperators } from '@aehrc/ecl-core';
|
|
135
|
+
import { analyzeExpression } from '@aehrc/ecl-core';
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
Copyright 2026 Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230
|
|
141
|
+
|
|
142
|
+
Apache License 2.0 — see [LICENSE](../../LICENSE).
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Sub-context within a filter block. */
|
|
2
|
+
export type FilterSubContext = 'after-opening' | 'after-keyword' | {
|
|
3
|
+
kind: 'after-equals';
|
|
4
|
+
keyword: string | null;
|
|
5
|
+
} | 'after-value';
|
|
6
|
+
/** Filter type character for filter blocks. */
|
|
7
|
+
export type FilterType = 'D' | 'C' | 'M' | '+';
|
|
8
|
+
/** Discriminated union of all cursor contexts for ECL completion. */
|
|
9
|
+
export type CursorContext = {
|
|
10
|
+
kind: 'expression-start';
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'after-operator';
|
|
13
|
+
operator: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'after-concept';
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'after-logical-operator';
|
|
18
|
+
operator: string;
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'refinement-start';
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'after-attribute-name';
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'after-comparison-operator';
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'after-cardinality';
|
|
27
|
+
} | {
|
|
28
|
+
kind: 'dotted-awaiting-attribute';
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'filter-block';
|
|
31
|
+
filterType: FilterType;
|
|
32
|
+
subContext: FilterSubContext;
|
|
33
|
+
} | {
|
|
34
|
+
kind: 'inside-display-term';
|
|
35
|
+
} | {
|
|
36
|
+
kind: 'unknown';
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Detect if the cursor is inside a filter block by scanning for unmatched `{{`.
|
|
40
|
+
*
|
|
41
|
+
* Returns a filter-block CursorContext if inside one, or null otherwise.
|
|
42
|
+
*/
|
|
43
|
+
export declare function detectFilterContext(text: string): CursorContext | null;
|
|
44
|
+
/**
|
|
45
|
+
* Detect the cursor context for ECL completion.
|
|
46
|
+
*
|
|
47
|
+
* 1. Checks for filter block context first via text scan (filters are opaque to ANTLR)
|
|
48
|
+
* 2. Parses with parseECL() and inspects the partial AST for everything else
|
|
49
|
+
*/
|
|
50
|
+
export declare function detectCursorContext(textBeforeCursor: string): CursorContext;
|
|
51
|
+
//# sourceMappingURL=context-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-detector.d.ts","sourceRoot":"","sources":["../../src/completion/context-detector.ts"],"names":[],"mappings":"AAWA,yCAAyC;AACzC,MAAM,MAAM,gBAAgB,GACxB,eAAe,GACf,eAAe,GACf;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAChD,aAAa,CAAC;AAElB,+CAA+C;AAC/C,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAE/C,qEAAqE;AACrE,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,wBAAwB,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACpD;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,sBAAsB,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,2BAA2B,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,2BAA2B,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,UAAU,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,gBAAgB,CAAA;CAAE,GAC9E;IAAE,IAAI,EAAE,qBAAqB,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AA4GxB;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAiBtE;AA+DD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,gBAAgB,EAAE,MAAM,GAAG,aAAa,CA8B3E"}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2026 Commonwealth Scientific and Industrial Research Organisation (CSIRO)
|
|
3
|
+
// ABN 41 687 119 230. SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.detectFilterContext = detectFilterContext;
|
|
6
|
+
exports.detectCursorContext = detectCursorContext;
|
|
7
|
+
// Context detection for ECL completion — hybrid AST + text approach
|
|
8
|
+
//
|
|
9
|
+
// Uses ANTLR partial AST for core grammar (refinements, compounds, dots)
|
|
10
|
+
// and text scanning for filter blocks (opaque to ANTLR).
|
|
11
|
+
const parser_1 = require("../parser");
|
|
12
|
+
const ast_1 = require("../parser/ast");
|
|
13
|
+
// ── Display term detection ──────────────────────────────────────────────
|
|
14
|
+
/**
|
|
15
|
+
* Check if the cursor is inside a pipe-delimited display term `|...|`.
|
|
16
|
+
* Skips pipes that appear inside block comments or line comments.
|
|
17
|
+
*/
|
|
18
|
+
function isInsideDisplayTerm(text) {
|
|
19
|
+
let inBlockComment = false;
|
|
20
|
+
let inTerm = false;
|
|
21
|
+
let i = 0;
|
|
22
|
+
while (i < text.length) {
|
|
23
|
+
if (!inTerm && text[i] === '/' && text[i + 1] === '*') {
|
|
24
|
+
inBlockComment = true;
|
|
25
|
+
i += 2;
|
|
26
|
+
}
|
|
27
|
+
else if (inBlockComment && text[i] === '*' && text[i + 1] === '/') {
|
|
28
|
+
inBlockComment = false;
|
|
29
|
+
i += 2;
|
|
30
|
+
}
|
|
31
|
+
else if (inBlockComment) {
|
|
32
|
+
// skip comment content
|
|
33
|
+
i++;
|
|
34
|
+
}
|
|
35
|
+
else if (text[i] === '/' && text[i + 1] === '/') {
|
|
36
|
+
// Line comment — skip to end of line
|
|
37
|
+
const newline = text.indexOf('\n', i);
|
|
38
|
+
if (newline === -1)
|
|
39
|
+
break;
|
|
40
|
+
i = newline + 1;
|
|
41
|
+
}
|
|
42
|
+
else if (text[i] === '|') {
|
|
43
|
+
inTerm = !inTerm;
|
|
44
|
+
i++;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
i++;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return inTerm;
|
|
51
|
+
}
|
|
52
|
+
// ── Filter block text scanner ───────────────────────────────────────────
|
|
53
|
+
/** Filter keywords by filter type. */
|
|
54
|
+
const DESCRIPTION_FILTER_KEYWORDS = [
|
|
55
|
+
'term',
|
|
56
|
+
'type',
|
|
57
|
+
'typeid',
|
|
58
|
+
'language',
|
|
59
|
+
'dialect',
|
|
60
|
+
'dialectid',
|
|
61
|
+
'moduleid',
|
|
62
|
+
'effectivetime',
|
|
63
|
+
'active',
|
|
64
|
+
'id',
|
|
65
|
+
];
|
|
66
|
+
const CONCEPT_FILTER_KEYWORDS = ['definitionstatus', 'definitionstatusid', 'moduleid', 'effectivetime', 'active'];
|
|
67
|
+
const MEMBER_FILTER_KEYWORDS = ['moduleid', 'effectivetime', 'active'];
|
|
68
|
+
function getFilterKeywords(filterType) {
|
|
69
|
+
switch (filterType) {
|
|
70
|
+
case 'D':
|
|
71
|
+
return DESCRIPTION_FILTER_KEYWORDS;
|
|
72
|
+
case 'C':
|
|
73
|
+
return CONCEPT_FILTER_KEYWORDS;
|
|
74
|
+
case 'M':
|
|
75
|
+
return MEMBER_FILTER_KEYWORDS;
|
|
76
|
+
case '+':
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Scan text for an unmatched `{{` to find the filter block start index.
|
|
82
|
+
* Skips `{{`/`}}` inside block comments and pipe-delimited terms.
|
|
83
|
+
* Returns -1 if not inside an open filter block.
|
|
84
|
+
*/
|
|
85
|
+
function findOpenFilterStart(text) {
|
|
86
|
+
let inComment = false;
|
|
87
|
+
let inTerm = false;
|
|
88
|
+
let filterStart = -1;
|
|
89
|
+
let i = 0;
|
|
90
|
+
while (i < text.length) {
|
|
91
|
+
if (!inTerm && text[i] === '/' && text[i + 1] === '*') {
|
|
92
|
+
inComment = true;
|
|
93
|
+
i += 2;
|
|
94
|
+
}
|
|
95
|
+
else if (inComment && text[i] === '*' && text[i + 1] === '/') {
|
|
96
|
+
inComment = false;
|
|
97
|
+
i += 2;
|
|
98
|
+
}
|
|
99
|
+
else if (inComment) {
|
|
100
|
+
// skip comment content
|
|
101
|
+
i++;
|
|
102
|
+
}
|
|
103
|
+
else if (text[i] === '|') {
|
|
104
|
+
inTerm = !inTerm;
|
|
105
|
+
i++;
|
|
106
|
+
}
|
|
107
|
+
else if (!inTerm && text[i] === '{' && text[i + 1] === '{') {
|
|
108
|
+
filterStart = i;
|
|
109
|
+
i += 2;
|
|
110
|
+
}
|
|
111
|
+
else if (!inTerm && text[i] === '}' && text[i + 1] === '}') {
|
|
112
|
+
filterStart = -1;
|
|
113
|
+
i += 2;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
i++;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return filterStart;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Detect if the cursor is inside a filter block by scanning for unmatched `{{`.
|
|
123
|
+
*
|
|
124
|
+
* Returns a filter-block CursorContext if inside one, or null otherwise.
|
|
125
|
+
*/
|
|
126
|
+
function detectFilterContext(text) {
|
|
127
|
+
// Quick check: no `{{` means no filter block
|
|
128
|
+
if (!text.includes('{{'))
|
|
129
|
+
return null;
|
|
130
|
+
const filterStart = findOpenFilterStart(text);
|
|
131
|
+
if (filterStart === -1)
|
|
132
|
+
return null;
|
|
133
|
+
// Extract content after {{ up to cursor
|
|
134
|
+
const afterOpening = text.substring(filterStart + 2).trimStart();
|
|
135
|
+
// Determine filter type from prefix
|
|
136
|
+
const { filterType, contentAfterType } = parseFilterPrefix(afterOpening);
|
|
137
|
+
// Determine sub-context within the filter block
|
|
138
|
+
const subContext = detectFilterSubContext(contentAfterType, filterType);
|
|
139
|
+
return { kind: 'filter-block', filterType, subContext };
|
|
140
|
+
}
|
|
141
|
+
/** Parse the filter type prefix character after `{{`. */
|
|
142
|
+
function parseFilterPrefix(afterOpening) {
|
|
143
|
+
if (/^[Dd]\s/.test(afterOpening)) {
|
|
144
|
+
return { filterType: 'D', contentAfterType: afterOpening.substring(1).trimStart() };
|
|
145
|
+
}
|
|
146
|
+
if (/^[Cc]\s/.test(afterOpening)) {
|
|
147
|
+
return { filterType: 'C', contentAfterType: afterOpening.substring(1).trimStart() };
|
|
148
|
+
}
|
|
149
|
+
if (/^[Mm]\s/.test(afterOpening)) {
|
|
150
|
+
return { filterType: 'M', contentAfterType: afterOpening.substring(1).trimStart() };
|
|
151
|
+
}
|
|
152
|
+
if (afterOpening.startsWith('+')) {
|
|
153
|
+
return { filterType: '+', contentAfterType: afterOpening.substring(1).trimStart() };
|
|
154
|
+
}
|
|
155
|
+
// No prefix or just opened — default to description filter
|
|
156
|
+
return { filterType: 'D', contentAfterType: afterOpening };
|
|
157
|
+
}
|
|
158
|
+
// eslint-disable-next-line sonarjs/function-return-type -- returns discriminated union FilterSubContext (string | object)
|
|
159
|
+
function detectFilterSubContext(content, filterType) {
|
|
160
|
+
if (content.length === 0)
|
|
161
|
+
return 'after-opening';
|
|
162
|
+
// For history supplement, everything after + is handled by history completions
|
|
163
|
+
if (filterType === '+')
|
|
164
|
+
return 'after-opening';
|
|
165
|
+
// Check if the content ends with a comma (ready for next keyword)
|
|
166
|
+
if (/,\s*$/.test(content))
|
|
167
|
+
return 'after-opening';
|
|
168
|
+
// Check if content ends with = followed by optional whitespace (awaiting value)
|
|
169
|
+
if (/[=!]=?\s*$/.test(content)) {
|
|
170
|
+
// Extract the keyword preceding the = sign
|
|
171
|
+
// eslint-disable-next-line sonarjs/slow-regex -- bounded to filter block content
|
|
172
|
+
const kwMatch = /(\w+)\s*[=!]=?\s*$/.exec(content);
|
|
173
|
+
const keyword = kwMatch ? kwMatch[1].toLowerCase() : null;
|
|
174
|
+
return { kind: 'after-equals', keyword };
|
|
175
|
+
}
|
|
176
|
+
// Check if a keyword is present by looking at the last token
|
|
177
|
+
const keywords = getFilterKeywords(filterType);
|
|
178
|
+
const trimmed = content.trimEnd();
|
|
179
|
+
const lastWord = trimmed.split(/\s+/).pop()?.toLowerCase() ?? '';
|
|
180
|
+
// If the last word matches a keyword exactly, we're after-keyword (awaiting operator)
|
|
181
|
+
if (keywords.includes(lastWord) && /\s$/.test(content)) {
|
|
182
|
+
return 'after-keyword';
|
|
183
|
+
}
|
|
184
|
+
// If there's a value after an = sign, we're after-value
|
|
185
|
+
// Pattern: keyword = value (where value is non-empty)
|
|
186
|
+
if (/[=!]=?\s+\S+/.test(content) && /\S\s*$/.test(content)) {
|
|
187
|
+
return 'after-value';
|
|
188
|
+
}
|
|
189
|
+
return 'after-opening';
|
|
190
|
+
}
|
|
191
|
+
// ── AST-based context detection ─────────────────────────────────────────
|
|
192
|
+
/** Match constraint operators at end of text. */
|
|
193
|
+
const CONSTRAINT_OP_REGEX = /(?:<<!|<<|<!|<|>>!|>>|>!|>|\^|!!>|!!<)\s*$/;
|
|
194
|
+
/**
|
|
195
|
+
* Detect the cursor context for ECL completion.
|
|
196
|
+
*
|
|
197
|
+
* 1. Checks for filter block context first via text scan (filters are opaque to ANTLR)
|
|
198
|
+
* 2. Parses with parseECL() and inspects the partial AST for everything else
|
|
199
|
+
*/
|
|
200
|
+
function detectCursorContext(textBeforeCursor) {
|
|
201
|
+
const trimmed = textBeforeCursor.trim();
|
|
202
|
+
// Empty or whitespace only
|
|
203
|
+
if (trimmed.length === 0)
|
|
204
|
+
return { kind: 'expression-start' };
|
|
205
|
+
// 1. Display term detection — suppress completions inside |...|
|
|
206
|
+
if (isInsideDisplayTerm(textBeforeCursor)) {
|
|
207
|
+
return { kind: 'inside-display-term' };
|
|
208
|
+
}
|
|
209
|
+
// 2. Filter block detection (text-based, runs first)
|
|
210
|
+
const filterContext = detectFilterContext(textBeforeCursor);
|
|
211
|
+
if (filterContext)
|
|
212
|
+
return filterContext;
|
|
213
|
+
// 3. Cardinality detection (text-based, not in AST)
|
|
214
|
+
if (/\[\d+\.\.\d+\]\s*$/.test(trimmed) || /\[\d+\.\.\*\]\s*$/.test(trimmed)) {
|
|
215
|
+
return { kind: 'after-cardinality' };
|
|
216
|
+
}
|
|
217
|
+
// 4. Parse and inspect AST
|
|
218
|
+
const result = (0, parser_1.parseECL)(trimmed);
|
|
219
|
+
const ast = result.ast;
|
|
220
|
+
// No AST or null expression — check if last token is an operator
|
|
221
|
+
if (!ast?.expression) {
|
|
222
|
+
return detectFromOperatorOrStart(trimmed);
|
|
223
|
+
}
|
|
224
|
+
return detectFromAST(ast.expression, trimmed, result.errors.length);
|
|
225
|
+
}
|
|
226
|
+
/** When there's no AST expression, check for trailing operator or default to expression-start. */
|
|
227
|
+
function detectFromOperatorOrStart(trimmed) {
|
|
228
|
+
const operatorMatch = CONSTRAINT_OP_REGEX.exec(trimmed);
|
|
229
|
+
if (operatorMatch) {
|
|
230
|
+
return { kind: 'after-operator', operator: operatorMatch[0].trim() };
|
|
231
|
+
}
|
|
232
|
+
return { kind: 'expression-start' };
|
|
233
|
+
}
|
|
234
|
+
/** Detect context from a parsed AST expression node. */
|
|
235
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity -- unavoidable: one branch per AST node type
|
|
236
|
+
function detectFromAST(inner, trimmed, errorCount) {
|
|
237
|
+
// RefinedExpression — after :, after attribute name, or after comparison operator
|
|
238
|
+
if (inner.type === ast_1.NodeType.RefinedExpression) {
|
|
239
|
+
if (inner.refinement.attributes.length === 0) {
|
|
240
|
+
return { kind: 'refinement-start' };
|
|
241
|
+
}
|
|
242
|
+
if (/[!=]=?\s*$/.test(trimmed)) {
|
|
243
|
+
return { kind: 'after-comparison-operator' };
|
|
244
|
+
}
|
|
245
|
+
if (/\d{6,18}(\s*\|[^|]*\|)?\s*$/.test(trimmed) && !/=\s*\d{6,18}/.test(trimmed.slice(-50))) {
|
|
246
|
+
return { kind: 'after-attribute-name' };
|
|
247
|
+
}
|
|
248
|
+
return { kind: 'refinement-start' };
|
|
249
|
+
}
|
|
250
|
+
// DottedExpression — after .
|
|
251
|
+
if (inner.type === ast_1.NodeType.DottedExpression) {
|
|
252
|
+
if (inner.attributes.length === 0) {
|
|
253
|
+
return { kind: 'dotted-awaiting-attribute' };
|
|
254
|
+
}
|
|
255
|
+
return errorCount === 0 ? { kind: 'after-concept' } : { kind: 'dotted-awaiting-attribute' };
|
|
256
|
+
}
|
|
257
|
+
// CompoundExpression — after AND/OR/MINUS
|
|
258
|
+
if (inner.type === ast_1.NodeType.CompoundExpression) {
|
|
259
|
+
const lastOperand = inner.operands.at(-1);
|
|
260
|
+
if (!lastOperand)
|
|
261
|
+
return { kind: 'unknown' };
|
|
262
|
+
if (lastOperand.focus.type === ast_1.NodeType.Wildcard) {
|
|
263
|
+
const range = lastOperand.focus.range;
|
|
264
|
+
if (range.start.offset === range.end.offset) {
|
|
265
|
+
return { kind: 'after-logical-operator', operator: inner.operator.operator };
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (/\b(AND|OR|MINUS)\s*$/i.test(trimmed)) {
|
|
269
|
+
return { kind: 'after-logical-operator', operator: inner.operator.operator };
|
|
270
|
+
}
|
|
271
|
+
if (errorCount === 0) {
|
|
272
|
+
return { kind: 'after-concept' };
|
|
273
|
+
}
|
|
274
|
+
return { kind: 'unknown' };
|
|
275
|
+
}
|
|
276
|
+
// SubExpressionConstraint — continuation point or after operator
|
|
277
|
+
if (errorCount === 0) {
|
|
278
|
+
return { kind: 'after-concept' };
|
|
279
|
+
}
|
|
280
|
+
const operatorMatch = CONSTRAINT_OP_REGEX.exec(trimmed);
|
|
281
|
+
if (operatorMatch) {
|
|
282
|
+
return { kind: 'after-operator', operator: operatorMatch[0].trim() };
|
|
283
|
+
}
|
|
284
|
+
return { kind: 'unknown' };
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=context-detector.js.map
|