forked from SAP/ui5-language-assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.d.ts
264 lines (234 loc) · 6.73 KB
/
api.d.ts
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
import { XMLElement, XMLAttribute } from "@xml-tools/ast";
import {
BaseUI5Node,
UI5Aggregation,
UI5Class,
UI5Event,
UI5Interface,
UI5Prop,
UI5Association,
UI5SemanticModel,
UI5Type,
UI5DeprecatedInfo,
} from "@ui5-language-assistant/semantic-model-types";
export interface OffsetRange {
start: number;
end: number;
}
/**
* Resolves an XML Tag's fully qualified name using available `xmlns`
* and UI5 semantics.
*/
export function xmlToFQN(astElement: XMLElement): string;
/**
* Resolve and XML closing tag's fully qualified name using available `xmlns`
* and UI5 semantics.
*/
export function xmlClosingTagToFQN(astElement: XMLElement): string;
/**
* Returns the fully qualified name of a UI5 Semantic Model Node.
*/
export function ui5NodeToFQN(ui5Node: BaseUI5Node): string;
/**
* Returns a list of all "ancestors" classes.
*/
export function getSuperClasses(clazz: UI5Class): UI5Class[];
/**
* Returns `true` if the provided class extends "sap.ui.core.Element"
* - The inheritance relation may be transitive.
* - Note that sap.ui.core.Control extends sap.ui.core.Element directly.
*/
export function isElementSubClass(
clazz: UI5Class | undefined
): clazz is UI5Class;
/**
* Returns a list of all direct and borrowed aggregations of a UI5 Class
*/
export function flattenAggregations(ui5Class: UI5Class): UI5Aggregation[];
/**
* Returns a list of all direct and borrowed properties of a UI5 Class
*/
export function flattenProperties(ui5Class: UI5Class): UI5Prop[];
/**
* Returns a list of all direct and borrowed events of a UI5 Class
*/
export function flattenEvents(ui5Class: UI5Class): UI5Event[];
/**
* Returns a list of all direct and borrowed associations of a UI5 Class
*/
export function flattenAssociations(ui5Class: UI5Class): UI5Association[];
/**
* Returns a list of all UI5Classes in the model which either extend (transitively)
* or Implement (Directly) the `type`.
*/
export function findClassesMatchingType({
type,
model,
}: {
type: UI5Class | UI5Interface;
model: UI5SemanticModel;
}): UI5Class[];
/**
* Check if a UI5 Class is type of the give `type`.
*/
export function classIsOfType(
clazz: UI5Class,
type: UI5Class | UI5Interface
): boolean;
/**
* Check if a UI5 node is a root symbol. A root symbol is a symbol that exists in one of the model symbol maps.
*/
export function isRootSymbol(node: BaseUI5Node): boolean;
/**
* Get the root symbol parent of a UI5 node (for example, get the class of a property).
* The same node is returned for root symbols.
*/
export function getRootSymbolParent(node: BaseUI5Node): BaseUI5Node | undefined;
/**
* Return a human-readable string representation of a UI5 type
*/
export function typeToString(type: UI5Type | undefined): string;
/**
* Return the UI5 Class for an XML Element
* @param element
* @param model
*/
export function getUI5ClassByXMLElement(
element: XMLElement,
model: UI5SemanticModel
): UI5Class | undefined;
/**
* Return the UI5 Class for an XML Element closing tag
* @param element
* @param model
*/
export function getUI5ClassByXMLElementClosingTag(
element: XMLElement,
model: UI5SemanticModel
): UI5Class | undefined;
/**
* Return the UI5 Aggregation for an XML Element
* @param element
* @param model
*/
export function getUI5AggregationByXMLElement(
element: XMLElement,
model: UI5SemanticModel
): UI5Aggregation | undefined;
/**
* Return the UI5 Property for an XML Attribute
* @param attribute
* @param model
*/
export function getUI5PropertyByXMLAttributeKey(
attribute: XMLAttribute,
model: UI5SemanticModel
): UI5Prop | undefined;
/**
* Return the UI5 node for an XML Attribute
* @param attribute
* @param model
*/
export function getUI5NodeByXMLAttribute(
attribute: XMLAttribute,
model: UI5SemanticModel
): UI5Prop | UI5Event | UI5Association | UI5Aggregation | undefined;
/**
* Return the UI5 Namespace from the specified or default XML Element namespace
*
* @param xmlElement
* @param model
*/
export function getUI5NodeFromXMLElementNamespace(
xmlElement: XMLElement,
model: UI5SemanticModel
): {
namespace: BaseUI5Node | undefined;
isDefault: boolean;
isXmlnsDefined: boolean;
};
/**
* Get the deprecated message. The returned string contains jsdoc tags.
*
* @param opts.title - The opening sentence for the deprecation message. It should not contain a dot. "Deprecated" by default.
*/
export function getDeprecationMessage(opts: {
title?: string;
since: string | undefined;
text: string | undefined;
}): string;
/**
* Get a snippet (first line) of the deprecated documentation without jsdoc tags.
*
* @param opts.title - The opening sentence for the deprecation message. It should not contain a dot. "Deprecated" by default.
*/
export function getDeprecationPlainTextSnippet(opts: {
title?: string;
deprecatedInfo: UI5DeprecatedInfo;
model: UI5SemanticModel;
}): string;
/**
* Convert jsdoc description to markdown format string
* @param jsdocDescription
* @param model
*/
export function convertJSDocToMarkdown(
jsdocDescription: string,
model: UI5SemanticModel
): string;
/**
* Get a link according to the link text.
* Supported links:
* - http/https links - returned as-is
* - Other strings are considered to be UI5 FQNs. A link to the relevant SDK page is returned.
*
* @param model
* @param link
*/
export function getLink(model: UI5SemanticModel, link: string): string;
/**
* Split possibly qualified XML Tag or XML Attribute name to prefix and local name.
* If there is no prefix in the qualified name, the returned prefix will be undefined.
* @param qName
*/
export function splitQNameByNamespace(
qName: string
): { prefix: string | undefined; localName: string };
/**
* Return the xml namespace defined for the xml element prefix (ns), or undefined if not found
* @param xmlElement
*/
export function resolveXMLNS(xmlElement: XMLElement): string | undefined;
/**
* Return the xml namespace defined for this prefix, or undefined if not found.
* The defined namespaces are taken from the xml element.
* @param prefix
* @param xmlElement
*/
export function resolveXMLNSFromPrefix(
prefix: string | undefined,
xmlElement: XMLElement
): string | undefined;
/**
* Check if the xml element namespace prefixes (ns) reference the same namespace
* @param xmlElement1
* @param xmlElement2
*/
export function isSameXMLNS(
xmlElement1: XMLElement,
xmlElement2: XMLElement
): boolean;
/**
* Check if the xml namespace prefixes reference the same namespace.
* The defined namespaces are taken from the respective xml elements.
* @param prefix1
* @param xmlElement1
* @param prefix2
* @param xmlElement2
*/
export function isSameXMLNSFromPrefix(
prefix1: string | undefined,
xmlElement1: XMLElement,
prefix2: string | undefined,
xmlElement2: XMLElement
): boolean;