@getodk/xforms-engine 0.1.1 → 0.3.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/dist/body/BodyDefinition.d.ts +24 -7
- package/dist/body/BodyElementDefinition.d.ts +4 -3
- package/dist/body/RepeatElementDefinition.d.ts +19 -0
- package/dist/body/appearance/inputAppearanceParser.d.ts +4 -0
- package/dist/body/appearance/selectAppearanceParser.d.ts +4 -0
- package/dist/body/appearance/structureElementAppearanceParser.d.ts +4 -0
- package/dist/body/control/ControlDefinition.d.ts +4 -2
- package/dist/body/control/InputDefinition.d.ts +5 -0
- package/dist/body/control/select/ItemDefinition.d.ts +2 -2
- package/dist/body/control/select/ItemsetDefinition.d.ts +5 -4
- package/dist/body/control/select/SelectDefinition.d.ts +11 -1
- package/dist/body/group/BaseGroupDefinition.d.ts +4 -9
- package/dist/body/group/PresentationGroupDefinition.d.ts +1 -1
- package/dist/client/BaseNode.d.ts +74 -3
- package/dist/client/GroupNode.d.ts +7 -2
- package/dist/client/ModelValueNode.d.ts +37 -0
- package/dist/client/NodeAppearances.d.ts +15 -0
- package/dist/client/NoteNode.d.ts +53 -0
- package/dist/client/RootNode.d.ts +21 -0
- package/dist/client/SelectNode.d.ts +8 -3
- package/dist/client/StringNode.d.ts +8 -3
- package/dist/client/SubtreeNode.d.ts +3 -0
- package/dist/client/TextRange.d.ts +85 -2
- package/dist/client/constants.d.ts +9 -0
- package/dist/client/hierarchy.d.ts +14 -9
- package/dist/client/node-types.d.ts +2 -1
- package/dist/client/{RepeatRangeNode.d.ts → repeat/BaseRepeatRangeNode.d.ts} +19 -15
- package/dist/client/{RepeatInstanceNode.d.ts → repeat/RepeatInstanceNode.d.ts} +11 -7
- package/dist/client/repeat/RepeatRangeControlledNode.d.ts +19 -0
- package/dist/client/repeat/RepeatRangeUncontrolledNode.d.ts +20 -0
- package/dist/client/validation.d.ts +163 -0
- package/dist/expression/DependentExpression.d.ts +12 -8
- package/dist/index.d.ts +9 -4
- package/dist/index.js +3173 -960
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +6 -4
- package/dist/instance/ModelValue.d.ts +40 -0
- package/dist/instance/Note.d.ts +42 -0
- package/dist/instance/Root.d.ts +10 -23
- package/dist/instance/SelectField.d.ts +12 -6
- package/dist/instance/StringField.d.ts +13 -7
- package/dist/instance/Subtree.d.ts +3 -1
- package/dist/instance/abstract/DescendantNode.d.ts +16 -9
- package/dist/instance/abstract/InstanceNode.d.ts +28 -29
- package/dist/instance/hierarchy.d.ts +10 -5
- package/dist/instance/internal-api/EvaluationContext.d.ts +5 -4
- package/dist/instance/internal-api/ValidationContext.d.ts +21 -0
- package/dist/instance/internal-api/ValueContext.d.ts +2 -2
- package/dist/instance/repeat/BaseRepeatRange.d.ts +160 -0
- package/dist/instance/{RepeatInstance.d.ts → repeat/RepeatInstance.d.ts} +38 -13
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +16 -0
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +35 -0
- package/dist/instance/text/TextRange.d.ts +4 -4
- package/dist/lib/TokenListParser.d.ts +84 -0
- package/dist/lib/dom/query.d.ts +5 -0
- package/dist/lib/reactivity/createComputedExpression.d.ts +6 -1
- package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +5 -0
- package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +2 -1
- package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +1 -1
- package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +1 -1
- package/dist/lib/reactivity/text/createFieldHint.d.ts +3 -3
- package/dist/lib/reactivity/text/createNodeLabel.d.ts +2 -2
- package/dist/lib/reactivity/text/createNoteText.d.ts +25 -0
- package/dist/lib/reactivity/text/createTextRange.d.ts +5 -7
- package/dist/lib/reactivity/validation/createAggregatedViolations.d.ts +9 -0
- package/dist/lib/reactivity/validation/createValidation.d.ts +18 -0
- package/dist/model/BindDefinition.d.ts +4 -2
- package/dist/model/BindElement.d.ts +1 -0
- package/dist/model/DescendentNodeDefinition.d.ts +1 -2
- package/dist/model/{ValueNodeDefinition.d.ts → LeafNodeDefinition.d.ts} +3 -4
- package/dist/model/NodeDefinition.d.ts +16 -16
- package/dist/model/RepeatInstanceDefinition.d.ts +5 -6
- package/dist/model/RepeatRangeDefinition.d.ts +30 -0
- package/dist/model/RepeatTemplateDefinition.d.ts +6 -7
- package/dist/model/RootDefinition.d.ts +3 -1
- package/dist/model/SubtreeDefinition.d.ts +2 -2
- package/dist/parse/NoteNodeDefinition.d.ts +31 -0
- package/dist/parse/expression/RepeatCountControlExpression.d.ts +19 -0
- package/dist/parse/text/HintDefinition.d.ts +9 -0
- package/dist/parse/text/ItemLabelDefinition.d.ts +9 -0
- package/dist/parse/text/ItemsetLabelDefinition.d.ts +13 -0
- package/dist/parse/text/LabelDefinition.d.ts +15 -0
- package/dist/parse/text/MessageDefinition.d.ts +15 -0
- package/dist/parse/text/OutputChunkDefinition.d.ts +8 -0
- package/dist/parse/text/ReferenceChunkDefinition.d.ts +8 -0
- package/dist/parse/text/StaticTextChunkDefinition.d.ts +10 -0
- package/dist/parse/text/TranslationChunkDefinition.d.ts +9 -0
- package/dist/parse/text/abstract/TextChunkDefinition.d.ts +18 -0
- package/dist/parse/text/abstract/TextElementDefinition.d.ts +23 -0
- package/dist/parse/text/abstract/TextRangeDefinition.d.ts +35 -0
- package/dist/parse/xpath/dependency-analysis.d.ts +40 -0
- package/dist/parse/xpath/path-resolution.d.ts +70 -0
- package/dist/parse/xpath/predicate-analysis.d.ts +30 -0
- package/dist/parse/xpath/reference-parsing.d.ts +18 -0
- package/dist/parse/xpath/semantic-analysis.d.ts +98 -0
- package/dist/parse/xpath/syntax-traversal.d.ts +69 -0
- package/dist/solid.js +3174 -961
- package/dist/solid.js.map +1 -1
- package/package.json +14 -15
- package/src/XFormDOM.ts +81 -8
- package/src/body/BodyDefinition.ts +38 -23
- package/src/body/BodyElementDefinition.ts +4 -3
- package/src/body/RepeatElementDefinition.ts +58 -0
- package/src/body/appearance/inputAppearanceParser.ts +39 -0
- package/src/body/appearance/selectAppearanceParser.ts +38 -0
- package/src/body/appearance/structureElementAppearanceParser.ts +7 -0
- package/src/body/control/ControlDefinition.ts +8 -3
- package/src/body/control/InputDefinition.ts +13 -0
- package/src/body/control/select/ItemDefinition.ts +3 -3
- package/src/body/control/select/ItemsetDefinition.ts +29 -12
- package/src/body/control/select/ItemsetNodesetExpression.ts +1 -1
- package/src/body/control/select/SelectDefinition.ts +14 -5
- package/src/body/group/BaseGroupDefinition.ts +14 -51
- package/src/body/group/PresentationGroupDefinition.ts +1 -1
- package/src/client/BaseNode.ts +82 -8
- package/src/client/GroupNode.ts +8 -2
- package/src/client/ModelValueNode.ts +40 -0
- package/src/client/NodeAppearances.ts +22 -0
- package/src/client/NoteNode.ts +74 -0
- package/src/client/README.md +1 -0
- package/src/client/RootNode.ts +24 -0
- package/src/client/SelectNode.ts +9 -3
- package/src/client/StringNode.ts +9 -3
- package/src/client/SubtreeNode.ts +3 -0
- package/src/client/TextRange.ts +99 -2
- package/src/client/constants.ts +10 -0
- package/src/client/hierarchy.ts +30 -14
- package/src/client/node-types.ts +8 -1
- package/src/client/{RepeatRangeNode.ts → repeat/BaseRepeatRangeNode.ts} +20 -17
- package/src/client/{RepeatInstanceNode.ts → repeat/RepeatInstanceNode.ts} +13 -7
- package/src/client/repeat/RepeatRangeControlledNode.ts +20 -0
- package/src/client/repeat/RepeatRangeUncontrolledNode.ts +21 -0
- package/src/client/validation.ts +199 -0
- package/src/expression/DependentExpression.ts +45 -27
- package/src/index.ts +15 -8
- package/src/instance/Group.ts +24 -13
- package/src/instance/ModelValue.ts +104 -0
- package/src/instance/Note.ts +142 -0
- package/src/instance/Root.ts +29 -67
- package/src/instance/SelectField.ts +35 -13
- package/src/instance/StringField.ts +40 -13
- package/src/instance/Subtree.ts +19 -10
- package/src/instance/abstract/DescendantNode.ts +50 -49
- package/src/instance/abstract/InstanceNode.ts +89 -92
- package/src/instance/children.ts +47 -10
- package/src/instance/hierarchy.ts +21 -2
- package/src/instance/index.ts +1 -1
- package/src/instance/internal-api/EvaluationContext.ts +5 -6
- package/src/instance/internal-api/ValidationContext.ts +23 -0
- package/src/instance/internal-api/ValueContext.ts +2 -2
- package/src/instance/repeat/BaseRepeatRange.ts +347 -0
- package/src/instance/{RepeatInstance.ts → repeat/RepeatInstance.ts} +85 -36
- package/src/instance/repeat/RepeatRangeControlled.ts +82 -0
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +67 -0
- package/src/instance/text/TextRange.ts +10 -4
- package/src/lib/TokenListParser.ts +156 -0
- package/src/lib/dom/query.ts +13 -0
- package/src/lib/reactivity/createChildrenState.ts +51 -6
- package/src/lib/reactivity/createComputedExpression.ts +23 -25
- package/src/lib/reactivity/createNoteReadonlyThunk.ts +33 -0
- package/src/lib/reactivity/createSelectItems.ts +25 -20
- package/src/lib/reactivity/createValueState.ts +6 -6
- package/src/lib/reactivity/materializeCurrentStateChildren.ts +3 -1
- package/src/lib/reactivity/node-state/createSharedNodeState.ts +1 -1
- package/src/lib/reactivity/text/createFieldHint.ts +9 -7
- package/src/lib/reactivity/text/createNodeLabel.ts +7 -5
- package/src/lib/reactivity/text/createNoteText.ts +72 -0
- package/src/lib/reactivity/text/createTextRange.ts +17 -90
- package/src/lib/reactivity/validation/createAggregatedViolations.ts +70 -0
- package/src/lib/reactivity/validation/createValidation.ts +196 -0
- package/src/model/BindComputation.ts +0 -4
- package/src/model/BindDefinition.ts +8 -6
- package/src/model/BindElement.ts +1 -0
- package/src/model/DescendentNodeDefinition.ts +1 -2
- package/src/model/{ValueNodeDefinition.ts → LeafNodeDefinition.ts} +5 -6
- package/src/model/ModelBindMap.ts +4 -0
- package/src/model/ModelDefinition.ts +1 -1
- package/src/model/NodeDefinition.ts +21 -21
- package/src/model/RepeatInstanceDefinition.ts +8 -13
- package/src/model/RepeatRangeDefinition.ts +94 -0
- package/src/model/RepeatTemplateDefinition.ts +10 -15
- package/src/model/RootDefinition.ts +12 -14
- package/src/model/SubtreeDefinition.ts +3 -3
- package/src/parse/NoteNodeDefinition.ts +70 -0
- package/src/parse/TODO.md +3 -0
- package/src/parse/expression/RepeatCountControlExpression.ts +44 -0
- package/src/parse/text/HintDefinition.ts +25 -0
- package/src/parse/text/ItemLabelDefinition.ts +25 -0
- package/src/parse/text/ItemsetLabelDefinition.ts +44 -0
- package/src/parse/text/LabelDefinition.ts +61 -0
- package/src/parse/text/MessageDefinition.ts +49 -0
- package/src/parse/text/OutputChunkDefinition.ts +25 -0
- package/src/parse/text/ReferenceChunkDefinition.ts +14 -0
- package/src/parse/text/StaticTextChunkDefinition.ts +19 -0
- package/src/parse/text/TranslationChunkDefinition.ts +38 -0
- package/src/parse/text/abstract/TextChunkDefinition.ts +38 -0
- package/src/parse/text/abstract/TextElementDefinition.ts +71 -0
- package/src/parse/text/abstract/TextRangeDefinition.ts +70 -0
- package/src/parse/xpath/dependency-analysis.ts +105 -0
- package/src/parse/xpath/path-resolution.ts +475 -0
- package/src/parse/xpath/predicate-analysis.ts +61 -0
- package/src/parse/xpath/reference-parsing.ts +90 -0
- package/src/parse/xpath/semantic-analysis.ts +466 -0
- package/src/parse/xpath/syntax-traversal.ts +129 -0
- package/dist/body/RepeatDefinition.d.ts +0 -16
- package/dist/body/group/RepeatGroupDefinition.d.ts +0 -13
- package/dist/body/text/HintDefinition.d.ts +0 -11
- package/dist/body/text/LabelDefinition.d.ts +0 -20
- package/dist/body/text/TextElementDefinition.d.ts +0 -33
- package/dist/body/text/TextElementOutputPart.d.ts +0 -13
- package/dist/body/text/TextElementPart.d.ts +0 -13
- package/dist/body/text/TextElementReferencePart.d.ts +0 -7
- package/dist/body/text/TextElementStaticPart.d.ts +0 -7
- package/dist/instance/RepeatRange.d.ts +0 -80
- package/dist/lib/xpath/analysis.d.ts +0 -23
- package/dist/model/RepeatSequenceDefinition.d.ts +0 -20
- package/src/body/RepeatDefinition.ts +0 -54
- package/src/body/group/RepeatGroupDefinition.ts +0 -91
- package/src/body/text/HintDefinition.ts +0 -26
- package/src/body/text/LabelDefinition.ts +0 -54
- package/src/body/text/TextElementDefinition.ts +0 -97
- package/src/body/text/TextElementOutputPart.ts +0 -27
- package/src/body/text/TextElementPart.ts +0 -31
- package/src/body/text/TextElementReferencePart.ts +0 -21
- package/src/body/text/TextElementStaticPart.ts +0 -26
- package/src/instance/RepeatRange.ts +0 -214
- package/src/lib/xpath/analysis.ts +0 -241
- package/src/model/RepeatSequenceDefinition.ts +0 -53
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { AbsoluteLocationPathNode, AnySyntaxNode, FilterPathExprNode, RelativeLocationPathNode } from '@getodk/xpath/static/grammar/SyntaxNode.js';
|
|
2
|
+
|
|
3
|
+
type LocalNameLiteral<LocalName extends string> = LocalName | `${string}:${LocalName}`;
|
|
4
|
+
type LocalNamedFunctionCallLiteral<LocalName extends string> = `${LocalNameLiteral<LocalName>}(${string})`;
|
|
5
|
+
export type TranslationExpression = LocalNamedFunctionCallLiteral<'itext'>;
|
|
6
|
+
/**
|
|
7
|
+
* Determines if an arbitrary XPath expression is (in whole) a translation
|
|
8
|
+
* expression (i.e. a call to `jr:itext`).
|
|
9
|
+
*
|
|
10
|
+
* @todo We may also want a companion function: `hasTranslationExpression`,
|
|
11
|
+
* which could be used for `<label ref>`/`<hint ref>` or anywhere else that an
|
|
12
|
+
* arbitrary expression may call `jr:itext`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const isTranslationExpression: (expression: string) => expression is TranslationExpression;
|
|
15
|
+
/**
|
|
16
|
+
* Predicate to determine if a FilterPathExpr (as currently produced by
|
|
17
|
+
* `tree-sitter-xpath`) is one of:
|
|
18
|
+
*
|
|
19
|
+
* - `current()`
|
|
20
|
+
* - `current()/...` (where `...` represents additional steps)
|
|
21
|
+
* - `current()//...` (^)
|
|
22
|
+
*
|
|
23
|
+
* @todo XPath grammar technically also allows for FilterExpr[Predicate],
|
|
24
|
+
* and our `tree-sitter-xpath` grammar/parser also allow for this. But
|
|
25
|
+
* `@getodk/xpath` types do not currently acknowledge this possibility.
|
|
26
|
+
*/
|
|
27
|
+
export declare const isCurrentPath: (syntaxNode: FilterPathExprNode) => boolean;
|
|
28
|
+
declare const FILTER_PATH_NODE: unique symbol;
|
|
29
|
+
/**
|
|
30
|
+
* Used to narrow types where a SyntaxNode with type 'filter_path_expr' is not
|
|
31
|
+
* **known to produce** a node-set result.
|
|
32
|
+
*
|
|
33
|
+
* This addresses some awkwardness in the XPath grammar (and our implementation
|
|
34
|
+
* parsing it) where FilterExpr _may be_ a FunctionCall, and one of the
|
|
35
|
+
* following _may also be true_:
|
|
36
|
+
*
|
|
37
|
+
* - The function call is known by name to produce a node-set result, **OR**
|
|
38
|
+
*
|
|
39
|
+
* - The function call is followed by one or more Steps (or the Step-like '//'
|
|
40
|
+
* shorthand), which must produce a node-set **OR**
|
|
41
|
+
*
|
|
42
|
+
* - The function call is followed by one or more Predicates, which must produce
|
|
43
|
+
* a node-set
|
|
44
|
+
*
|
|
45
|
+
* Any other FilterExpr (and thus our containing synthetic 'filter_path_expr'
|
|
46
|
+
* SyntaxNode) is treated as a non-path [sub-]expression, excluding it from
|
|
47
|
+
* analysis as such (and any downstream logic such as nodeset resolution).
|
|
48
|
+
*/
|
|
49
|
+
export interface FilterPathNode extends FilterPathExprNode {
|
|
50
|
+
readonly [FILTER_PATH_NODE]: true;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Determines whether a given expression beginning with a FilterExpr is known to
|
|
54
|
+
* produce a node-set result. Used in downstream dependency analysis, as well as
|
|
55
|
+
* path resolution.
|
|
56
|
+
*/
|
|
57
|
+
export declare const isNodeSetFilterPathExpression: (syntaxNode: FilterPathExprNode) => syntaxNode is FilterPathNode;
|
|
58
|
+
export type PathExpressionNode = AbsoluteLocationPathNode | FilterPathNode | RelativeLocationPathNode;
|
|
59
|
+
/**
|
|
60
|
+
* Locates sub-expression {@link PathExpressionNode}s within a parsed XPath
|
|
61
|
+
* expression (or any arbitrary sub-expression thereof).
|
|
62
|
+
*/
|
|
63
|
+
export declare const findLocationPathSubExpressionNodes: (syntaxNode: AnySyntaxNode) => readonly PathExpressionNode[];
|
|
64
|
+
/**
|
|
65
|
+
* Gets the parsed representation of an XPath path expression, iff the complete
|
|
66
|
+
* expression is any {@link PathExpressionNode} syntax type.
|
|
67
|
+
*/
|
|
68
|
+
export declare const getPathExpressionNode: (expression: string) => PathExpressionNode | null;
|
|
69
|
+
type BrandedExpression<Expression extends string, Brand extends symbol> = Expression & {
|
|
70
|
+
readonly [K in Brand]: true;
|
|
71
|
+
};
|
|
72
|
+
declare const CONSTANT_EXPRESSION: unique symbol;
|
|
73
|
+
type CONSTANT_EXPRESSION = typeof CONSTANT_EXPRESSION;
|
|
74
|
+
/**
|
|
75
|
+
* Represents an expression which produces a constant result:
|
|
76
|
+
*
|
|
77
|
+
* - Makes no reference to explicit dependencies
|
|
78
|
+
* - Does not depend on any known, implicit state
|
|
79
|
+
* - Evaluation does not depend in any way on context
|
|
80
|
+
* - Evaluation can be treated as referentially transparent
|
|
81
|
+
*/
|
|
82
|
+
export type ConstantExpression = BrandedExpression<string, CONSTANT_EXPRESSION>;
|
|
83
|
+
/**
|
|
84
|
+
* @see {@link ConstantExpression}
|
|
85
|
+
*/
|
|
86
|
+
export declare const isConstantExpression: (expression: string) => expression is ConstantExpression;
|
|
87
|
+
declare const CONSTANT_TRUTHY_EXPRESSION: unique symbol;
|
|
88
|
+
type CONSTANT_TRUTHY_EXPRESSION = typeof CONSTANT_TRUTHY_EXPRESSION;
|
|
89
|
+
/**
|
|
90
|
+
* Represents an expression which is {@link ConstantExpression | constant},
|
|
91
|
+
* and which will always produce `true` when evaluated as a boolean.
|
|
92
|
+
*/
|
|
93
|
+
export type ConstantTruthyExpression = BrandedExpression<ConstantExpression, CONSTANT_TRUTHY_EXPRESSION>;
|
|
94
|
+
/**
|
|
95
|
+
* @see {@link ConstantTruthyExpression}
|
|
96
|
+
*/
|
|
97
|
+
export declare const isConstantTruthyExpression: (expression: string) => expression is ConstantTruthyExpression;
|
|
98
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Identity } from '../../../../common/types/helpers.js';
|
|
2
|
+
import { AnySyntaxNode, XPathNode } from '@getodk/xpath/static/grammar/SyntaxNode.js';
|
|
3
|
+
import { AnySyntaxType } from '@getodk/xpath/static/grammar/type-names.js';
|
|
4
|
+
|
|
5
|
+
export type TypedSyntaxNode<Type extends AnySyntaxType> = Extract<AnySyntaxNode, {
|
|
6
|
+
readonly type: Type;
|
|
7
|
+
}>;
|
|
8
|
+
type CollectedNodes<Type extends AnySyntaxType> = Identity<ReadonlyArray<TypedSyntaxNode<Type>>>;
|
|
9
|
+
interface CollectNodesOptions {
|
|
10
|
+
readonly recurseMatchedNodes?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Collects XPath {@link SyntaxNode}s matching any of the specified
|
|
14
|
+
* {@link types}.
|
|
15
|
+
*
|
|
16
|
+
* By default, search is **shallowly recursive** (i.e. the descendants of
|
|
17
|
+
* matches are not searched).
|
|
18
|
+
*
|
|
19
|
+
* {@link CollectNodesOptions.recurseMatchedNodes | `options.recurseMatchedNodes: true`}
|
|
20
|
+
* can be specified to recursively search descendants of matches.
|
|
21
|
+
*
|
|
22
|
+
* This may be useful for analysis of XPath sub-expressions, for instance
|
|
23
|
+
* identifying all LocationPaths referenced by a broader expression.
|
|
24
|
+
*/
|
|
25
|
+
export declare const collectTypedNodes: <const Type extends AnySyntaxType>(types: readonly [Type, ...Type[]], currentNode: AnySyntaxNode, options?: CollectNodesOptions) => CollectedNodes<Type>;
|
|
26
|
+
/**
|
|
27
|
+
* Predicate to determine whether {@link descendantNode} represents the complete
|
|
28
|
+
* syntax of {@link subExpressionNode}. This can be useful for targeting
|
|
29
|
+
* specific aspects of syntax which tend to be wrapped (sometimes several layers
|
|
30
|
+
* deep) in more general syntax types.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* const pathExpression = '/foo[@bar = 1]';
|
|
36
|
+
* const numericExpression = '2';
|
|
37
|
+
*
|
|
38
|
+
* const pathRootNode = expressionParser.parse(pathExpression).rootNode;
|
|
39
|
+
* // ^?: XPathNode
|
|
40
|
+
* const [pathNumberNode] = collectTypedNodes(['number'], pathRootNode);
|
|
41
|
+
* // ^?: NumberNode
|
|
42
|
+
*
|
|
43
|
+
* isCompleteSubExpression(pathRootNode, pathNumberNode); // false
|
|
44
|
+
*
|
|
45
|
+
* const numericRootNode = expressionParser.parse(numericExpression).rootNode;
|
|
46
|
+
* // ^?: XPathNode
|
|
47
|
+
* const [numericNumberNode] = collectTypedNodes(['number'], numericRootNode);
|
|
48
|
+
* // ^?: NumberNode
|
|
49
|
+
*
|
|
50
|
+
* isCompleteSubExpression(numericRootNode, numericNumberNode); // true
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare const isCompleteSubExpression: (subExpressionNode: AnySyntaxNode, descendantNode: AnySyntaxNode) => boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Finds a syntax node which:
|
|
56
|
+
*
|
|
57
|
+
* - Matches one of the specified {@link types}, and
|
|
58
|
+
* - Represents the complete expression
|
|
59
|
+
*
|
|
60
|
+
* This may be useful for performing semantic analysis on expressions, for
|
|
61
|
+
* instance identifying when an expression **is a FunctionCall**, and producing
|
|
62
|
+
* the {@link SyntaxNode} representing that FunctionCall.
|
|
63
|
+
*
|
|
64
|
+
* In contrast, this would produce `null` for an expression **containing a
|
|
65
|
+
* FunctionCall** in some sub-expression position (e.g. the call to `position`
|
|
66
|
+
* in `foo[position() = 2]`).
|
|
67
|
+
*/
|
|
68
|
+
export declare const findTypedPrincipalExpressionNode: <const Type extends AnySyntaxType>(types: readonly [Type, ...Type[]], xpathNode: XPathNode) => TypedSyntaxNode<Type> | null;
|
|
69
|
+
export {};
|