@blockml/parser 0.9.0 → 0.9.1
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/blocks/org/blockml/bml/compiler/parser/Library.bml +4 -1
- package/blocks/org/blockml/bml/compiler/parser/capability/ContainsUnescapedInterpolation.bml +53 -0
- package/blocks/org/blockml/bml/compiler/parser/capability/ParseDirectives.bml +2 -1
- package/blocks/org/blockml/bml/compiler/parser/capability/ParseGenericArgumentList.bml +57 -0
- package/blocks/org/blockml/bml/compiler/parser/capability/ParseGenericsBinding.bml +58 -0
- package/blocks/org/blockml/bml/compiler/parser/documentation/ArchitectureOverview.bml +1 -1
- package/blocks/org/blockml/bml/compiler/parser/documentation/AttributeClassification.bml +1 -1
- package/blocks/org/blockml/bml/compiler/parser/documentation/ExpressionCapture.bml +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/map/directives.d.ts +28 -1
- package/dist/map/directives.d.ts.map +1 -1
- package/dist/map/directives.js +54 -3
- package/dist/map/directives.js.map +1 -1
- package/dist/map/map-block.d.ts.map +1 -1
- package/dist/map/map-block.js +81 -1
- package/dist/map/map-block.js.map +1 -1
- package/dist/map/map-composition.d.ts +8 -0
- package/dist/map/map-composition.d.ts.map +1 -1
- package/dist/map/map-composition.js +15 -2
- package/dist/map/map-composition.js.map +1 -1
- package/dist/map/member-value.d.ts +1 -0
- package/dist/map/member-value.d.ts.map +1 -1
- package/dist/map/member-value.js +22 -0
- package/dist/map/member-value.js.map +1 -1
- package/dist/map/structural.d.ts.map +1 -1
- package/dist/map/structural.js +3 -1
- package/dist/map/structural.js.map +1 -1
- package/dist/map/type-expression.d.ts +17 -0
- package/dist/map/type-expression.d.ts.map +1 -1
- package/dist/map/type-expression.js +32 -2
- package/dist/map/type-expression.js.map +1 -1
- package/package.json +3 -3
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
(@blockml/bom). Membership is defined exclusively by this blocks list.
|
|
44
44
|
</documentation>
|
|
45
45
|
|
|
46
|
-
<version>0.9.
|
|
46
|
+
<version>0.9.1</version>
|
|
47
47
|
|
|
48
48
|
<language>
|
|
49
49
|
<English />
|
|
@@ -96,11 +96,14 @@
|
|
|
96
96
|
<parcap:MapTypeReferenceEntityInstance />
|
|
97
97
|
<parcap:BuildSubBlockIndex />
|
|
98
98
|
<parcap:ParseTypeExpression />
|
|
99
|
+
<parcap:ParseGenericArgumentList />
|
|
99
100
|
<parcap:InferCardinality />
|
|
100
101
|
<parcap:TypeExpressionToString />
|
|
101
102
|
<parcap:ParseMemberValue />
|
|
103
|
+
<parcap:ContainsUnescapedInterpolation />
|
|
102
104
|
<parcap:ExpressionFromRaw />
|
|
103
105
|
<parcap:ParseDirectives />
|
|
106
|
+
<parcap:ParseGenericsBinding />
|
|
104
107
|
<parcap:ParseBmlMeta />
|
|
105
108
|
<parcap:ParseVisibilityFromName />
|
|
106
109
|
<parcap:VisibilityPrefix />
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Parser Capability — ContainsUnescapedInterpolation
|
|
3
|
+
FQN: org.blockml.bml.compiler.parser.capability.ContainsUnescapedInterpolation
|
|
4
|
+
-->
|
|
5
|
+
<block
|
|
6
|
+
xmlns="http://blockml.org/bml"
|
|
7
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
8
|
+
xsi:schemaLocation="http://blockml.org/bml https://blockml.org/schemas/bml.xsd
|
|
9
|
+
"
|
|
10
|
+
xmlns:blockml="org.blockml.bml"
|
|
11
|
+
xmlns:bom="org.blockml.bml.bom"
|
|
12
|
+
xmlns:bomapi="org.blockml.bml.bom.api"
|
|
13
|
+
xmlns:bomblock="org.blockml.bml.bom.block"
|
|
14
|
+
xmlns:bomcommon="org.blockml.bml.bom.common"
|
|
15
|
+
xmlns:bomcomp="org.blockml.bml.bom.composition"
|
|
16
|
+
xmlns:bomdoc="org.blockml.bml.bom.document"
|
|
17
|
+
xmlns:bomtype="org.blockml.bml.bom.type"
|
|
18
|
+
xmlns:bomvalue="org.blockml.bml.bom.value"
|
|
19
|
+
xmlns:core="org.blockml.bml.core"
|
|
20
|
+
xmlns:def="org.blockml.bml.definition"
|
|
21
|
+
xmlns:parser="org.blockml.bml.compiler.parser"
|
|
22
|
+
xmlns:parcap="org.blockml.bml.compiler.parser.capability"
|
|
23
|
+
xmlns:parconfig="org.blockml.bml.compiler.parser.config"
|
|
24
|
+
xmlns:pardocumentation="org.blockml.bml.compiler.parser.documentation"
|
|
25
|
+
xmlns:parmap="org.blockml.bml.compiler.parser.map"
|
|
26
|
+
xmlns:type="org.blockml.bml.type"
|
|
27
|
+
xmlns:bomdocumentation="org.blockml.bml.bom.documentation"
|
|
28
|
+
xmlns:bomcap="org.blockml.bml.bom.capability"
|
|
29
|
+
xmlns:serdocumentation="org.blockml.bml.compiler.serializer.documentation"
|
|
30
|
+
xmlns:valdocumentation="org.blockml.bml.compiler.validator.documentation">
|
|
31
|
+
|
|
32
|
+
<name>ContainsUnescapedInterpolation</name>
|
|
33
|
+
<type>parcap:ContainsUnescapedInterpolation</type>
|
|
34
|
+
<baseType>core:Capability</baseType>
|
|
35
|
+
<is>Detect unescaped ${…} interpolation in raw text</is>
|
|
36
|
+
|
|
37
|
+
<documentation>True when raw contains ${ not preceded by a backslash. Used by ParseMemberValue and ParseDirectives to choose InterpolatedTextValue over a JSON-like literal.</documentation>
|
|
38
|
+
|
|
39
|
+
<references>
|
|
40
|
+
<see type="pardocumentation:ExpressionCapture" relation="SeeAlso" />
|
|
41
|
+
<see type="parcap:ParseMemberValue" relation="SeeAlso" />
|
|
42
|
+
</references>
|
|
43
|
+
|
|
44
|
+
<properties>
|
|
45
|
+
<raw type="type:Text">
|
|
46
|
+
<documentation>raw. TS type: type:Text. (required)</documentation>
|
|
47
|
+
</raw>
|
|
48
|
+
<result type="type:Boolean">
|
|
49
|
+
<documentation>result. TS type: type:Boolean. (required)</documentation>
|
|
50
|
+
</result>
|
|
51
|
+
</properties>
|
|
52
|
+
|
|
53
|
+
</block>
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
<baseType>core:Capability</baseType>
|
|
35
35
|
<is>Parse bml:each/if/unless/with directive attributes</is>
|
|
36
36
|
|
|
37
|
-
<documentation>Parse bml:each/if/unless/with directive attributes
|
|
37
|
+
<documentation>Parse bml:each/if/unless/with directive attributes.
|
|
38
|
+
bml:generics is composition meta (ParseGenericsBinding), not a flow-control directive.</documentation>
|
|
38
39
|
|
|
39
40
|
<references>
|
|
40
41
|
<see type="pardocumentation:AttributeClassification" relation="SeeAlso" />
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Parser Capability — ParseGenericArgumentList
|
|
3
|
+
FQN: org.blockml.bml.compiler.parser.capability.ParseGenericArgumentList
|
|
4
|
+
-->
|
|
5
|
+
<block
|
|
6
|
+
xmlns="http://blockml.org/bml"
|
|
7
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
8
|
+
xsi:schemaLocation="http://blockml.org/bml https://blockml.org/schemas/bml.xsd
|
|
9
|
+
"
|
|
10
|
+
xmlns:blockml="org.blockml.bml"
|
|
11
|
+
xmlns:bom="org.blockml.bml.bom"
|
|
12
|
+
xmlns:bomapi="org.blockml.bml.bom.api"
|
|
13
|
+
xmlns:bomblock="org.blockml.bml.bom.block"
|
|
14
|
+
xmlns:bomcommon="org.blockml.bml.bom.common"
|
|
15
|
+
xmlns:bomcomp="org.blockml.bml.bom.composition"
|
|
16
|
+
xmlns:bomdoc="org.blockml.bml.bom.document"
|
|
17
|
+
xmlns:bomtype="org.blockml.bml.bom.type"
|
|
18
|
+
xmlns:bomvalue="org.blockml.bml.bom.value"
|
|
19
|
+
xmlns:core="org.blockml.bml.core"
|
|
20
|
+
xmlns:def="org.blockml.bml.definition"
|
|
21
|
+
xmlns:parser="org.blockml.bml.compiler.parser"
|
|
22
|
+
xmlns:parcap="org.blockml.bml.compiler.parser.capability"
|
|
23
|
+
xmlns:parconfig="org.blockml.bml.compiler.parser.config"
|
|
24
|
+
xmlns:pardocumentation="org.blockml.bml.compiler.parser.documentation"
|
|
25
|
+
xmlns:parmap="org.blockml.bml.compiler.parser.map"
|
|
26
|
+
xmlns:type="org.blockml.bml.type"
|
|
27
|
+
xmlns:bomdocumentation="org.blockml.bml.bom.documentation"
|
|
28
|
+
xmlns:bomcap="org.blockml.bml.bom.capability"
|
|
29
|
+
xmlns:serdocumentation="org.blockml.bml.compiler.serializer.documentation"
|
|
30
|
+
xmlns:valdocumentation="org.blockml.bml.compiler.validator.documentation">
|
|
31
|
+
|
|
32
|
+
<name>ParseGenericArgumentList</name>
|
|
33
|
+
<type>parcap:ParseGenericArgumentList</type>
|
|
34
|
+
<baseType>core:Capability</baseType>
|
|
35
|
+
<is>Parse a parenthesized TypeExpression list for bml:generics</is>
|
|
36
|
+
|
|
37
|
+
<documentation>Parse a parenthesized TypeExpression list for bml:generics.
|
|
38
|
+
Outer parentheses are required. Reuses the TypeExpression parser used by
|
|
39
|
+
baseType generic applications, without a leading type name.</documentation>
|
|
40
|
+
|
|
41
|
+
<references>
|
|
42
|
+
<see type="parcap:ParseTypeExpression" relation="SeeAlso" />
|
|
43
|
+
</references>
|
|
44
|
+
|
|
45
|
+
<properties>
|
|
46
|
+
<raw type="type:Text">
|
|
47
|
+
<documentation>raw. TS type: type:Text. (required)</documentation>
|
|
48
|
+
</raw>
|
|
49
|
+
<bindings type="type:Text">
|
|
50
|
+
<documentation>xmlns prefix bindings. (required)</documentation>
|
|
51
|
+
</bindings>
|
|
52
|
+
<arguments type="bomtype:TypeExpression[]">
|
|
53
|
+
<documentation>arguments. TS type: bomtype:TypeExpression[]. (required)</documentation>
|
|
54
|
+
</arguments>
|
|
55
|
+
</properties>
|
|
56
|
+
|
|
57
|
+
</block>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Parser Capability — ParseGenericsBinding
|
|
3
|
+
FQN: org.blockml.bml.compiler.parser.capability.ParseGenericsBinding
|
|
4
|
+
-->
|
|
5
|
+
<block
|
|
6
|
+
xmlns="http://blockml.org/bml"
|
|
7
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
8
|
+
xsi:schemaLocation="http://blockml.org/bml https://blockml.org/schemas/bml.xsd
|
|
9
|
+
"
|
|
10
|
+
xmlns:blockml="org.blockml.bml"
|
|
11
|
+
xmlns:bom="org.blockml.bml.bom"
|
|
12
|
+
xmlns:bomapi="org.blockml.bml.bom.api"
|
|
13
|
+
xmlns:bomblock="org.blockml.bml.bom.block"
|
|
14
|
+
xmlns:bomcommon="org.blockml.bml.bom.common"
|
|
15
|
+
xmlns:bomcomp="org.blockml.bml.bom.composition"
|
|
16
|
+
xmlns:bomdoc="org.blockml.bml.bom.document"
|
|
17
|
+
xmlns:bomtype="org.blockml.bml.bom.type"
|
|
18
|
+
xmlns:bomvalue="org.blockml.bml.bom.value"
|
|
19
|
+
xmlns:core="org.blockml.bml.core"
|
|
20
|
+
xmlns:def="org.blockml.bml.definition"
|
|
21
|
+
xmlns:parser="org.blockml.bml.compiler.parser"
|
|
22
|
+
xmlns:parcap="org.blockml.bml.compiler.parser.capability"
|
|
23
|
+
xmlns:parconfig="org.blockml.bml.compiler.parser.config"
|
|
24
|
+
xmlns:pardocumentation="org.blockml.bml.compiler.parser.documentation"
|
|
25
|
+
xmlns:parmap="org.blockml.bml.compiler.parser.map"
|
|
26
|
+
xmlns:type="org.blockml.bml.type"
|
|
27
|
+
xmlns:bomdocumentation="org.blockml.bml.bom.documentation"
|
|
28
|
+
xmlns:bomcap="org.blockml.bml.bom.capability"
|
|
29
|
+
xmlns:serdocumentation="org.blockml.bml.compiler.serializer.documentation"
|
|
30
|
+
xmlns:valdocumentation="org.blockml.bml.compiler.validator.documentation">
|
|
31
|
+
|
|
32
|
+
<name>ParseGenericsBinding</name>
|
|
33
|
+
<type>parcap:ParseGenericsBinding</type>
|
|
34
|
+
<baseType>core:Capability</baseType>
|
|
35
|
+
<is>Parse bml:generics attribute or child element into GenericsBinding</is>
|
|
36
|
+
|
|
37
|
+
<documentation>Parse bml:generics as attribute or child element. Attribute form wins.
|
|
38
|
+
Stores lossless raw plus parsed TypeExpression arguments when parentheses
|
|
39
|
+
are present and well-formed.</documentation>
|
|
40
|
+
|
|
41
|
+
<references>
|
|
42
|
+
<see type="parcap:ParseGenericArgumentList" relation="SeeAlso" />
|
|
43
|
+
<see type="pardocumentation:AttributeClassification" relation="SeeAlso" />
|
|
44
|
+
</references>
|
|
45
|
+
|
|
46
|
+
<properties>
|
|
47
|
+
<element type="parmap:XmlDomNode">
|
|
48
|
+
<documentation>element. TS type: parmap:XmlDomNode. (required)</documentation>
|
|
49
|
+
</element>
|
|
50
|
+
<ctx type="parmap:MapContext">
|
|
51
|
+
<documentation>ctx. TS type: parmap:MapContext. (required)</documentation>
|
|
52
|
+
</ctx>
|
|
53
|
+
<binding type="bomcomp:GenericsBinding">
|
|
54
|
+
<documentation>binding. TS type: bomcomp:GenericsBinding. (optional)</documentation>
|
|
55
|
+
</binding>
|
|
56
|
+
</properties>
|
|
57
|
+
|
|
58
|
+
</block>
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
• map/map-block.ts → parcap:MapDocumentBlock, MapBlock
|
|
55
55
|
• map/map-composition.ts → composition tree mapping
|
|
56
56
|
• map/type-expression.ts → parcap:ParseTypeExpression
|
|
57
|
-
• map/member-value.ts → parcap:ParseMemberValue
|
|
57
|
+
• map/member-value.ts → parcap:ParseMemberValue, ContainsUnescapedInterpolation, ExpressionFromRaw
|
|
58
58
|
• map/directives.ts → parcap:ParseDirectives, ParseBmlMeta
|
|
59
59
|
• util/* → visibility, boolean, qname, xml helpers]]></documentation>
|
|
60
60
|
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
• other xsi:* → ignore (not memberValues)
|
|
44
44
|
|
|
45
45
|
Rule 2 — bml:* attributes:
|
|
46
|
-
• Composition meta (bml:id, bml:version, …) → BlockInstance fields
|
|
46
|
+
• Composition meta (bml:id, bml:version, bml:generics, …) → BlockInstance fields
|
|
47
47
|
• Directives (bml:each, bml:if, …) → directives[]
|
|
48
48
|
• Unknown bml:* → BML_UNKNOWN_DIRECTIVE (error at map time — B2)
|
|
49
49
|
|
|
@@ -36,10 +36,12 @@
|
|
|
36
36
|
<is>Raw expression storage — no AST in Urmodell (B4)</is>
|
|
37
37
|
|
|
38
38
|
<documentation>${ … } attribute/element values → ExpressionValue { raw, source }.
|
|
39
|
+
Mixed text with ${ … } holes → InterpolatedTextValue { raw, source }.
|
|
39
40
|
Implementation CDATA → embeddedExpressions[] with source offsets.
|
|
40
41
|
|
|
41
42
|
Parser step [5] captures raw text only. AST construction via parseExpression()
|
|
42
|
-
in @blockml/framework (Stage 2 utility) — never stored
|
|
43
|
+
/ parseInterpolatedText() in @blockml/framework (Stage 2 utility) — never stored
|
|
44
|
+
on Urmodell.
|
|
43
45
|
|
|
44
46
|
inputType/outputType on capabilities → TypeExpression at map time (B3).</documentation>
|
|
45
47
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { parse } from "./parse.js";
|
|
2
2
|
export { isWellKnownTypeFqn, resolveTypeName, type ImplicitNamespaceContext, } from "./util/qname.js";
|
|
3
|
+
export { parseTypeExpression, parseGenericArgumentList, type ParseGenericArgumentListResult, type TypeExpressionResolveOptions, } from "./map/type-expression.js";
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,KAAK,wBAAwB,GAC9B,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,KAAK,wBAAwB,GAC9B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,GAClC,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,kBAAkB,EAClB,eAAe,GAEhB,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,kBAAkB,EAClB,eAAe,GAEhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,GAGzB,MAAM,0BAA0B,CAAC"}
|
package/dist/map/directives.d.ts
CHANGED
|
@@ -1,23 +1,50 @@
|
|
|
1
|
-
import type { DirectiveAttribute, ExpressionValue } from "@blockml/bom";
|
|
1
|
+
import type { DirectiveAttribute, ExpressionValue, GenericsBinding } from "@blockml/bom";
|
|
2
2
|
import type { Element } from "@xmldom/xmldom";
|
|
3
3
|
import type { SourceLocation } from "@blockml/bom";
|
|
4
4
|
import type { MapContext } from "./context.js";
|
|
5
|
+
import { type TypeExpressionResolveOptions } from "./type-expression.js";
|
|
6
|
+
export declare const isGenericsDirectiveElement: (element: Element) => boolean;
|
|
7
|
+
export declare function parseGenericsBinding(element: Element, ctx: MapContext, options?: TypeExpressionResolveOptions): GenericsBinding | undefined;
|
|
5
8
|
export declare function parseDirectives(element: Element, loc: SourceLocation, ctx?: MapContext): DirectiveAttribute[];
|
|
6
9
|
export declare function parseBmlMeta(element: Element, typeFqn: string, file: string, loc: SourceLocation): {
|
|
7
10
|
id: ExpressionValue | {
|
|
11
|
+
kind: "interpolated";
|
|
12
|
+
raw: string;
|
|
13
|
+
source: SourceLocation;
|
|
14
|
+
value?: never;
|
|
15
|
+
typeFqn?: never;
|
|
16
|
+
} | {
|
|
8
17
|
kind: "literal";
|
|
9
18
|
value: string;
|
|
10
19
|
typeFqn: string;
|
|
20
|
+
raw?: never;
|
|
21
|
+
source?: never;
|
|
11
22
|
} | undefined;
|
|
12
23
|
version: ExpressionValue | {
|
|
24
|
+
kind: "interpolated";
|
|
25
|
+
raw: string;
|
|
26
|
+
source: SourceLocation;
|
|
27
|
+
value?: never;
|
|
28
|
+
typeFqn?: never;
|
|
29
|
+
} | {
|
|
13
30
|
kind: "literal";
|
|
14
31
|
value: string;
|
|
15
32
|
typeFqn: string;
|
|
33
|
+
raw?: never;
|
|
34
|
+
source?: never;
|
|
16
35
|
} | undefined;
|
|
17
36
|
bean: ExpressionValue | {
|
|
37
|
+
kind: "interpolated";
|
|
38
|
+
raw: string;
|
|
39
|
+
source: SourceLocation;
|
|
40
|
+
value?: never;
|
|
41
|
+
typeFqn?: never;
|
|
42
|
+
} | {
|
|
18
43
|
kind: "literal";
|
|
19
44
|
value: string;
|
|
20
45
|
typeFqn: string;
|
|
46
|
+
raw?: never;
|
|
47
|
+
source?: never;
|
|
21
48
|
} | undefined;
|
|
22
49
|
scope: "local" | "context" | undefined;
|
|
23
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directives.d.ts","sourceRoot":"","sources":["../../src/map/directives.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAElB,eAAe,EAKhB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"directives.d.ts","sourceRoot":"","sources":["../../src/map/directives.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAElB,eAAe,EACf,eAAe,EAKhB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAS9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,sBAAsB,CAAC;AAY9B,eAAO,MAAM,0BAA0B,GAAI,SAAS,OAAO,KAAG,OAI7D,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,UAAU,EACf,OAAO,CAAC,EAAE,4BAA4B,GACrC,eAAe,GAAG,SAAS,CAoC7B;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,cAAc,EACnB,GAAG,CAAC,EAAE,UAAU,GACf,kBAAkB,EAAE,CAgEtB;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBpB"}
|
package/dist/map/directives.js
CHANGED
|
@@ -1,11 +1,53 @@
|
|
|
1
|
-
import { expressionFromRaw } from "./member-value.js";
|
|
2
|
-
import { getAttribute } from "../util/xml.js";
|
|
3
|
-
import { collectUnknownBmlAttributes } from "./structural.js";
|
|
1
|
+
import { containsUnescapedInterpolation, expressionFromRaw } from "./member-value.js";
|
|
2
|
+
import { elementChildren, elementLocalName, elementPrefix, getAttribute, getCharacterData, } from "../util/xml.js";
|
|
3
|
+
import { collectUnknownBmlAttributes, reportDiagnostic } from "./structural.js";
|
|
4
|
+
import { parseGenericArgumentList, } from "./type-expression.js";
|
|
5
|
+
import { attributeValueLoc, elementSourceLoc } from "../util/qname.js";
|
|
4
6
|
const BML_NS = "http://blockml.org/bml";
|
|
5
7
|
function bmlAttr(element, local) {
|
|
6
8
|
return (getAttribute(element, `bml:${local}`) ??
|
|
7
9
|
getAttribute(element, `${BML_NS}:${local}`));
|
|
8
10
|
}
|
|
11
|
+
export const isGenericsDirectiveElement = (element) => {
|
|
12
|
+
const local = elementLocalName(element);
|
|
13
|
+
const prefix = elementPrefix(element);
|
|
14
|
+
return (prefix === "bml" && local === "generics") || local === "bml:generics";
|
|
15
|
+
};
|
|
16
|
+
export function parseGenericsBinding(element, ctx, options) {
|
|
17
|
+
const loc = elementSourceLoc(ctx.filePath, ctx.source, element);
|
|
18
|
+
const attr = bmlAttr(element, "generics");
|
|
19
|
+
const child = elementChildren(element).find(isGenericsDirectiveElement);
|
|
20
|
+
let raw;
|
|
21
|
+
let authoredPlacement;
|
|
22
|
+
let source = loc;
|
|
23
|
+
if (attr !== undefined) {
|
|
24
|
+
raw = attr;
|
|
25
|
+
authoredPlacement = "attribute";
|
|
26
|
+
source =
|
|
27
|
+
attributeValueLoc(ctx.filePath, ctx.source, element, "bml:generics", attr) ?? loc;
|
|
28
|
+
}
|
|
29
|
+
else if (child) {
|
|
30
|
+
raw = getCharacterData(child).text;
|
|
31
|
+
authoredPlacement = "element";
|
|
32
|
+
source = elementSourceLoc(ctx.filePath, ctx.source, child);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
const binding = {
|
|
38
|
+
raw,
|
|
39
|
+
authoredPlacement,
|
|
40
|
+
source,
|
|
41
|
+
};
|
|
42
|
+
const parsed = parseGenericArgumentList(raw, ctx.bindings, "type", options);
|
|
43
|
+
if (parsed.ok) {
|
|
44
|
+
binding.arguments = parsed.arguments;
|
|
45
|
+
}
|
|
46
|
+
else if (parsed.code === "BML_INVALID_TYPE_REFERENCE") {
|
|
47
|
+
reportDiagnostic(ctx, parsed.code, parsed.message, source);
|
|
48
|
+
}
|
|
49
|
+
return binding;
|
|
50
|
+
}
|
|
9
51
|
export function parseDirectives(element, loc, ctx) {
|
|
10
52
|
const directives = [];
|
|
11
53
|
if (ctx) {
|
|
@@ -84,6 +126,15 @@ function parseMetaValue(raw, typeFqn, file, loc) {
|
|
|
84
126
|
if (raw.startsWith("${") && raw.endsWith("}")) {
|
|
85
127
|
return expressionFromRaw(raw, loc);
|
|
86
128
|
}
|
|
129
|
+
const trimmed = raw.trim();
|
|
130
|
+
const looksLikeJson = trimmed.startsWith("[") || trimmed.startsWith("{");
|
|
131
|
+
if (!looksLikeJson && containsUnescapedInterpolation(raw)) {
|
|
132
|
+
return {
|
|
133
|
+
kind: "interpolated",
|
|
134
|
+
raw,
|
|
135
|
+
source: loc,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
87
138
|
return {
|
|
88
139
|
kind: "literal",
|
|
89
140
|
value: raw,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directives.js","sourceRoot":"","sources":["../../src/map/directives.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"directives.js","sourceRoot":"","sources":["../../src/map/directives.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtF,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EACL,wBAAwB,GAEzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEvE,MAAM,MAAM,GAAG,wBAAwB,CAAC;AAExC,SAAS,OAAO,CAAC,OAAgB,EAAE,KA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AAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"map-block.d.ts","sourceRoot":"","sources":["../../src/map/map-block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,eAAe,EAKf,UAAU,EAkBX,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAmzCjE,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,GAAG,eAAe,CAE3E;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,WAAW,GAAE,UAAU,EAAO,GAC7B,eAAe,CAGjB"}
|
package/dist/map/map-block.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createMapContext } from "./context.js";
|
|
|
2
2
|
import { mapBlockInstanceNode, mapCompositionTemplate, mapTypeReferenceEntityInstance, isTypeReferenceEntitySugar, buildSubBlockIndex, } from "./map-composition.js";
|
|
3
3
|
import { parseTypeExpression, inferCardinality, } from "./type-expression.js";
|
|
4
4
|
import { parseMemberValue } from "./member-value.js";
|
|
5
|
+
import { parseGenericsBinding, isGenericsDirectiveElement } from "./directives.js";
|
|
5
6
|
import { elementChildren, elementLocalName, elementPrefix, getAttribute, getCharacterData, xmlTriviaFromElement, } from "../util/xml.js";
|
|
6
7
|
import { parseVisibilityFromName } from "../util/visibility.js";
|
|
7
8
|
import { parseBooleanAttribute, isBooleanLiteral } from "../util/boolean.js";
|
|
@@ -32,6 +33,10 @@ function mapBlockDefinition(element, ctx, parentType) {
|
|
|
32
33
|
if (unknownAttrs) {
|
|
33
34
|
block.unknownAttributes = unknownAttrs;
|
|
34
35
|
}
|
|
36
|
+
const blockGenerics = parseGenericsBinding(element, ctx, typeResolveOptions(ctx));
|
|
37
|
+
if (blockGenerics) {
|
|
38
|
+
block.generics = blockGenerics;
|
|
39
|
+
}
|
|
35
40
|
const childElements = elementChildren(element);
|
|
36
41
|
const subBlocksRaw = [];
|
|
37
42
|
const embeddedRaw = [];
|
|
@@ -81,6 +86,7 @@ function mapBlockDefinition(element, ctx, parentType) {
|
|
|
81
86
|
if (unknownElements.length > 0) {
|
|
82
87
|
block.unknownElements = unknownElements;
|
|
83
88
|
}
|
|
89
|
+
seedSubBlockIndex(element, block, ctx, parentType, subBlocksRaw);
|
|
84
90
|
mapMetadataFields(element, block, ctx);
|
|
85
91
|
if (!block.name) {
|
|
86
92
|
block.name = block.type.split(".").pop() ?? "Block";
|
|
@@ -159,6 +165,8 @@ const MEMBER_CHILD_METADATA = new Set([
|
|
|
159
165
|
"throws",
|
|
160
166
|
"bml:xml",
|
|
161
167
|
"xml",
|
|
168
|
+
"generics",
|
|
169
|
+
"bml:generics",
|
|
162
170
|
"abstract",
|
|
163
171
|
"final",
|
|
164
172
|
"language",
|
|
@@ -170,7 +178,7 @@ function isMemberMetadataChild(element) {
|
|
|
170
178
|
if (MEMBER_CHILD_METADATA.has(local)) {
|
|
171
179
|
return true;
|
|
172
180
|
}
|
|
173
|
-
if (prefix === "bml" && (local === "xml" || local === "container")) {
|
|
181
|
+
if (prefix === "bml" && (local === "xml" || local === "container" || local === "generics")) {
|
|
174
182
|
return true;
|
|
175
183
|
}
|
|
176
184
|
return false;
|
|
@@ -361,6 +369,10 @@ function mapMemberBase(element, name, visibility, namespace, ctx) {
|
|
|
361
369
|
const { text } = getCharacterData(xmlEl);
|
|
362
370
|
base.xmlRendering = parseMemberXmlRendering(text, "element");
|
|
363
371
|
}
|
|
372
|
+
const memberGenerics = parseGenericsBinding(element, ctx, typeResolveOptions(ctx));
|
|
373
|
+
if (memberGenerics) {
|
|
374
|
+
base.generics = memberGenerics;
|
|
375
|
+
}
|
|
364
376
|
mapMemberDocumentation(element, base, ctx);
|
|
365
377
|
mapMemberConstraints(element, base, ctx);
|
|
366
378
|
return base;
|
|
@@ -405,6 +417,12 @@ function mapMetadataFields(element, block, ctx) {
|
|
|
405
417
|
if (extraAttrs) {
|
|
406
418
|
block.unknownAttributes = { ...block.unknownAttributes, ...extraAttrs };
|
|
407
419
|
}
|
|
420
|
+
if (MEMBER_SECTIONS.has(elementLocalName(child)) && !block.generics) {
|
|
421
|
+
const sectionGenerics = parseGenericsBinding(child, ctx, typeResolveOptions(ctx));
|
|
422
|
+
if (sectionGenerics) {
|
|
423
|
+
block.generics = sectionGenerics;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
408
426
|
const local = elementLocalName(child);
|
|
409
427
|
switch (local) {
|
|
410
428
|
case "name":
|
|
@@ -505,6 +523,15 @@ function mapMetadataFields(element, block, ctx) {
|
|
|
505
523
|
block.xmlRendering = { raw: text };
|
|
506
524
|
break;
|
|
507
525
|
}
|
|
526
|
+
case "bml:generics":
|
|
527
|
+
case "generics":
|
|
528
|
+
if (isGenericsDirectiveElement(child) && !block.generics) {
|
|
529
|
+
const fromChild = parseGenericsBinding(element, ctx, typeResolveOptions(ctx));
|
|
530
|
+
if (fromChild) {
|
|
531
|
+
block.generics = fromChild;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
break;
|
|
508
535
|
default:
|
|
509
536
|
break;
|
|
510
537
|
}
|
|
@@ -514,6 +541,59 @@ function mapMetadataFields(element, block, ctx) {
|
|
|
514
541
|
block.xmlRendering = { raw: xmlAttr };
|
|
515
542
|
}
|
|
516
543
|
}
|
|
544
|
+
function seedSubBlockIndex(element, block, ctx, parentType, subBlocksRaw) {
|
|
545
|
+
if (subBlocksRaw.length === 0) {
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
let peekedName = block.name;
|
|
549
|
+
let peekedType = block.type;
|
|
550
|
+
for (const child of elementChildren(element)) {
|
|
551
|
+
const local = elementLocalName(child);
|
|
552
|
+
if (local === "name") {
|
|
553
|
+
peekedName = getTextOrAttr(child) ?? peekedName;
|
|
554
|
+
}
|
|
555
|
+
else if (local === "type") {
|
|
556
|
+
const typeText = getTextOrAttr(child);
|
|
557
|
+
if (typeText) {
|
|
558
|
+
peekedType = resolveBlockReference(typeText, ctx.bindings, ctx.subBlockIndex, parentType);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
if (!peekedType && parentType && peekedName) {
|
|
563
|
+
peekedType = `${parentType}.${peekedName}`;
|
|
564
|
+
}
|
|
565
|
+
if (!peekedType) {
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
const peeked = subBlocksRaw
|
|
569
|
+
.map((el) => peekSubBlock(el, peekedType, ctx, parentType))
|
|
570
|
+
.filter((entry) => entry !== undefined);
|
|
571
|
+
if (peeked.length === 0) {
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
ctx.subBlockIndex = buildSubBlockIndex(peeked, peekedType);
|
|
575
|
+
ctx.parentBlockType = peekedType;
|
|
576
|
+
}
|
|
577
|
+
function peekSubBlock(element, parentType, ctx, enclosingParent) {
|
|
578
|
+
let name = getAttribute(element, "name");
|
|
579
|
+
let typeText;
|
|
580
|
+
for (const child of elementChildren(element)) {
|
|
581
|
+
const local = elementLocalName(child);
|
|
582
|
+
if (local === "name" && !name) {
|
|
583
|
+
name = getTextOrAttr(child);
|
|
584
|
+
}
|
|
585
|
+
else if (local === "type") {
|
|
586
|
+
typeText = getTextOrAttr(child);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
if (!name) {
|
|
590
|
+
return undefined;
|
|
591
|
+
}
|
|
592
|
+
const type = typeText
|
|
593
|
+
? resolveBlockReference(typeText, ctx.bindings, ctx.subBlockIndex, enclosingParent ?? parentType)
|
|
594
|
+
: `${parentType}.${name}`;
|
|
595
|
+
return { name, type };
|
|
596
|
+
}
|
|
517
597
|
function getTextOrAttr(element, tag) {
|
|
518
598
|
const el = tag
|
|
519
599
|
? elementChildren(element).find((c) => elementLocalName(c) === tag) ?? element
|