forked from SAP/ui5-language-assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.d.ts
150 lines (131 loc) · 4.4 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
import {
XMLAttribute,
XMLElement,
XMLDocument,
XMLAstNode,
} from "@xml-tools/ast";
import { DocumentCstNode } from "@xml-tools/parser";
import { IToken } from "chevrotain";
import {
UI5Aggregation,
UI5Class,
UI5Event,
UI5Namespace,
UI5Prop,
UI5Association,
UI5EnumValue,
} from "@ui5-language-assistant/semantic-model-types/api";
import { CodeAssistSettings } from "@ui5-language-assistant/settings";
import { Context } from "@ui5-language-assistant/context";
export function getXMLViewCompletions(
opts: GetXMLViewCompletionsOpts
): UI5XMLViewCompletion[];
export interface GetXMLViewCompletionsOpts {
context: Context;
offset: number;
cst: DocumentCstNode;
ast: XMLDocument;
tokenVector: IToken[];
settings: CodeAssistSettings;
}
export type UI5CompletionNode =
| UI5Namespace
| UI5Class
| UI5Aggregation
| UI5Event
| UI5Prop
| UI5Association
| UI5EnumValue
| BooleanValue;
export type UI5XMLViewCompletion =
| UI5NodeXMLViewCompletion
| BooleanValueInXMLAttributeValueCompletion;
export type UI5NodeXMLViewCompletion =
| UI5ClassesInXMLTagNameCompletion
| UI5AggregationsInXMLTagNameCompletion
| UI5EnumsInXMLAttributeValueCompletion
| UI5PropsInXMLAttributeKeyCompletion
| UI5EventsInXMLAttributeKeyCompletion
| UI5AssociationsInXMLAttributeKeyCompletion
| UI5NamespacesInXMLAttributeKeyCompletion
| UI5NamespacesInXMLAttributeValueCompletion;
export type UI5XMLViewCompletionTypeName =
| "UI5ClassesInXMLTagName"
| "UI5AggregationsInXMLTagName"
| "UI5EnumsInXMLAttributeValue"
| "UI5PropsInXMLAttributeKey"
| "UI5EventsInXMLAttributeKey"
| "UI5AssociationsInXMLAttributeKey"
| "UI5NamespacesInXMLAttributeKey"
| "UI5NamespacesInXMLAttributeValue"
| "BooleanValueInXMLAttributeValue";
/**
* Note that this interface does not deal with "Editor Behavior". e.g:
* - The Text to insert may differ from the label.
* - Additional text insertions may be needed:
* - Align open and close tags.
* - Add '>' to close a tag.
* - Add quotes to wrap an attribute's value.
*
* Rather it should contain the completion "pure" data.
*/
export interface BaseXMLViewCompletion<
XML extends XMLAstNode,
UI5 extends UI5CompletionNode
> {
type: UI5XMLViewCompletionTypeName;
// The Node we want to suggest as a possible completion.
// Note this carries all the additional semantic data (deprecated/description/...).
ui5Node: UI5;
// The specific ASTNode where the completion happened
// may be useful for LSP Layer to implement Editor Level Logic.
// - e.g: the "additional text insertions" mentioned above.
astNode: XML;
}
export interface UI5ClassesInXMLTagNameCompletion
extends BaseXMLViewCompletion<XMLElement, UI5Class> {
type: "UI5ClassesInXMLTagName";
}
export interface UI5AggregationsInXMLTagNameCompletion
extends BaseXMLViewCompletion<XMLElement, UI5Aggregation> {
type: "UI5AggregationsInXMLTagName";
}
export interface UI5EnumsInXMLAttributeValueCompletion
extends BaseXMLViewCompletion<XMLAttribute, UI5EnumValue> {
type: "UI5EnumsInXMLAttributeValue";
}
export interface UI5PropsInXMLAttributeKeyCompletion
extends BaseXMLViewCompletion<XMLAttribute, UI5Prop> {
type: "UI5PropsInXMLAttributeKey";
}
export interface UI5EventsInXMLAttributeKeyCompletion
extends BaseXMLViewCompletion<XMLAttribute, UI5Event> {
type: "UI5EventsInXMLAttributeKey";
}
export interface UI5AssociationsInXMLAttributeKeyCompletion
extends BaseXMLViewCompletion<XMLAttribute, UI5Association> {
type: "UI5AssociationsInXMLAttributeKey";
}
export interface UI5NamespacesInXMLAttributeKeyCompletion
extends BaseXMLViewCompletion<XMLAttribute, UI5Namespace> {
type: "UI5NamespacesInXMLAttributeKey";
}
export interface UI5NamespacesInXMLAttributeValueCompletion
extends BaseXMLViewCompletion<XMLAttribute, UI5Namespace> {
type: "UI5NamespacesInXMLAttributeValue";
}
export interface BooleanValue {
kind: "BooleanValue";
// The name of the suggestion
name: string;
// The literal value that we want to suggest as a possible completion
value: boolean;
}
export interface BooleanValueInXMLAttributeValueCompletion
extends BaseXMLViewCompletion<XMLAttribute, BooleanValue> {
type: "BooleanValueInXMLAttributeValue";
}
/** Check if the suggestion is a UI5 semantic model xml completion according to its type property */
export function isUI5NodeXMLViewCompletion(
suggestion: UI5XMLViewCompletion
): suggestion is UI5NodeXMLViewCompletion;