-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathapi.d.ts
More file actions
194 lines (177 loc) · 5.9 KB
/
Copy pathapi.d.ts
File metadata and controls
194 lines (177 loc) · 5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import { IToken } from "chevrotain";
import { DocumentCstNode } from "@xml-tools/parser";
import {
XMLAttribute,
XMLElement,
XMLTextContent,
XMLDocument,
} from "@xml-tools/ast";
declare function getSuggestions<OUT>(options: {
cst: DocumentCstNode;
ast: XMLDocument;
offset: number;
tokenVector: IToken[];
providers: SuggestionProviders<OUT>;
}): OUT[];
/**
* The `context` argument can be used to inject state/data
* to the be used in the implementation of the suggestionsProviders.
* For example a Symbol Table of known Attributes / Tags.
*/
declare function getSuggestions<OUT, CONTEXT>(options: {
cst: DocumentCstNode;
ast: XMLDocument;
offset: number;
tokenVector: IToken[];
providers: SuggestionProviders<OUT, CONTEXT>;
context: CONTEXT;
}): OUT[];
declare type SuggestionProviders<OUT, CONTEXT = undefined> = {
elementContent?: ElementContentCompletion<OUT, CONTEXT>[];
elementName?: ElementNameCompletion<OUT, CONTEXT>[];
attributeName?: AttributeNameCompletion<OUT, CONTEXT>[];
attributeValue?: AttributeValueCompletion<OUT, CONTEXT>[];
};
declare type ProviderOptions<CONTEXT = undefined> =
| ElementContentCompletionOptions<CONTEXT>
| ElementNameCompletionOptions<CONTEXT>
| AttributeNameCompletionOptions<CONTEXT>
| AttributeValueCompletionOptions<CONTEXT>;
declare type SuggestionProvider<
IN extends ProviderOptions<CONTEXT>,
OUT,
CONTEXT = undefined
> = (options: IN) => OUT[];
declare type ElementContentCompletionOptions<CONTEXT = undefined> = {
/**
* Element ASTNode for which the name content assist was requested.
* This ASTNode may be used to:
* - Inspect if there is any other content in the Element.
* - Inspect the available namespaces aliases in this scope.
* - ...
*/
element: XMLElement;
/**
* The pre-existing part of the name at the content assist request offset.
* This would normally be used to filter out suggestions that do not match the prefix.
*/
prefix: string | undefined;
/**
* TextContent ASTNode in which content assist was requested
* Note that this property may be undefined if no prefix was provided.
*/
textContent: XMLTextContent | undefined;
context: CONTEXT;
};
/**
* Suggestions provider for element's contents.
* This is triggered when content assist is requested:
* 1. **inside** an element's contents.
* 2. And **outside** any of the element's sub-parts
*
* For example: ('⇶' marks the content assist position):
* - <note>
* <to>bobi</to>
* ⇶
* <!-- I am a comment! -->
* </note>
*
* - <name>⇶</name>
*/
declare type ElementContentCompletion<
OUT,
CONTEXT = undefined
> = SuggestionProvider<ElementContentCompletionOptions<CONTEXT>, OUT, CONTEXT>;
declare type ElementNameCompletionOptions<CONTEXT = undefined> = {
/**
* Element ASTNode for which the name content assist was requested
*/
element: XMLElement;
/**
* The pre-existing part of the name at the content assist request offset.
* This would normally be used to filter out suggestions that do not match the prefix.
*/
prefix: string | undefined;
context: CONTEXT;
};
/**
* Suggestions provider for element names.
* This is triggered when content assist is requested:
* 1. **inside** an element's contents.
* 2. Following the '<' character.
* 3. optionally also following a name prefix.
*
* For example: ('⇶' marks the content assist position):
* - <pers⇶
* - <⇶
*/
declare type ElementNameCompletion<
OUT,
CONTEXT = undefined
> = SuggestionProvider<ElementNameCompletionOptions<CONTEXT>, OUT, CONTEXT>;
declare type AttributeNameCompletionOptions<CONTEXT = undefined> = {
/**
* Element ASTNode in which content assist was requested
* This ASTNode may be used to:
* - Inspect pre-existing attribute names.
* - Identify namespaces aliases available in this "scope"
* - ...
*/
element: XMLElement;
/**
* Attribute ASTNode in which content assist was requested
* Note that this property may be undefined if no prefix was provided.
*/
attribute: XMLAttribute | undefined;
/**
* The pre-existing part of the name at the content assist request offset.
* This would normally be used to filter out suggestions that do not match the prefix.
*/
prefix: string | undefined;
context: CONTEXT;
};
/**
* Suggestions provider for attribute names.
* This is triggered when content assist is requested **inside** an element opening name block
* in a position where an attribute is valid e.g ('⇶' marks the content assist position):
* - <person age='45' nam⇶ >
* - <person age='45' ⇶ >
*/
declare type AttributeNameCompletion<
OUT,
CONTEXT = undefined
> = SuggestionProvider<AttributeNameCompletionOptions<CONTEXT>, OUT, CONTEXT>;
declare type AttributeValueCompletionOptions<CONTEXT = undefined> = {
/**
* Element ASTNode in which content assist was requested
*/
element: XMLElement;
/**
* Attribute ASTNode in which content assist was requested
* Note that **unlike** `AttributeNameCompletion` this property **always** exists.
* This ASTNode may be used to:
* - Inspect the attribute key for which value suggestions are requested.
* - Inspect the **whole** pre-existing value of the attribute.
*/
attribute: XMLAttribute;
/**
* The pre-existing part of the value at the content assist request location.
* This would normally be used to filter out suggestions that do not match the prefix.
*
* Note that the prefix does not include any quotes.
*/
prefix: string | undefined;
context: CONTEXT;
};
/**
* Suggestions provider for attribute values.
* This is triggered when content assist is requested **inside** the quotes
* d.g: ('⇶' marks the content assist position):
* - <meeting day='wednes⇶' >
* - <meeting day='⇶' >
* - ...
*/
declare type AttributeValueCompletion<
OUT,
CONTEXT = undefined
> = SuggestionProvider<AttributeValueCompletionOptions<CONTEXT>, OUT, CONTEXT>;