@arcgis/coding-components 4.29.0-beta.47 → 4.29.0-beta.49
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/arcgis-coding-components/arcgis-coding-components.esm.js +1 -1
- package/dist/arcgis-coding-components/assets/code-editor/arcade.worker.js +13 -13
- package/dist/arcgis-coding-components/index.esm.js +1 -1
- package/dist/arcgis-coding-components/{p-10a322ec.js → p-0d616249.js} +9 -9
- package/dist/arcgis-coding-components/p-2c0d6f15.js +2 -0
- package/dist/arcgis-coding-components/{p-71faf9a4.js → p-5802524a.js} +1 -1
- package/dist/arcgis-coding-components/{p-9eabda86.js → p-5ddccf04.js} +1 -1
- package/dist/arcgis-coding-components/p-7475f3a6.js +1 -0
- package/dist/arcgis-coding-components/{p-e6ede32d.js → p-7d8caba9.js} +1 -1
- package/dist/arcgis-coding-components/{p-f7d7d78d.js → p-9f6db08a.js} +1 -1
- package/dist/arcgis-coding-components/{p-e475e6cd.js → p-aefe77ce.js} +1 -1
- package/dist/arcgis-coding-components/p-ce2be55e.entry.js +1 -0
- package/dist/arcgis-coding-components/{p-ce586a8c.js → p-d425a387.js} +1 -1
- package/dist/arcgis-coding-components/{p-c084ada8.js → p-ff21f230.js} +1 -1
- package/dist/cjs/{arcade-defaults-8445d852.js → arcade-defaults-2d513b59.js} +1534 -1534
- package/dist/cjs/arcade-mode-6219f1b8.js +599 -0
- package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +1404 -1408
- package/dist/cjs/arcgis-coding-components.cjs.js +2 -2
- package/dist/cjs/{cssMode-e63287bb.js → cssMode-1ec48254.js} +2 -2
- package/dist/cjs/{html-c0d4db3b.js → html-0e1741fe.js} +2 -2
- package/dist/cjs/{htmlMode-fdc44d57.js → htmlMode-279d3c29.js} +2 -2
- package/dist/cjs/{index-6a382a34.js → index-ac186201.js} +67 -24
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/{javascript-a419d064.js → javascript-04f1bce0.js} +3 -3
- package/dist/cjs/{jsonMode-73aee5d2.js → jsonMode-59322f7a.js} +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{tsMode-37d1b053.js → tsMode-17561f70.js} +2 -2
- package/dist/cjs/{typescript-53f9f36a.js → typescript-b7da8629.js} +2 -2
- package/dist/components/arcade-api.js +160 -160
- package/dist/components/arcade-contribution.js +60 -60
- package/dist/components/arcade-defaults.js +1240 -1240
- package/dist/components/arcade-mode.js +514 -513
- package/dist/components/arcade-results.js +426 -430
- package/dist/components/arcade-suggestions.js +130 -132
- package/dist/components/arcade-variables.js +157 -155
- package/dist/components/arcgis-arcade-api.d.ts +2 -2
- package/dist/components/arcgis-arcade-editor.d.ts +2 -2
- package/dist/components/arcgis-arcade-editor.js +391 -391
- package/dist/components/arcgis-arcade-results.d.ts +2 -2
- package/dist/components/arcgis-arcade-suggestions.d.ts +2 -2
- package/dist/components/arcgis-arcade-variables.d.ts +2 -2
- package/dist/components/arcgis-code-editor.d.ts +2 -2
- package/dist/components/code-editor.js +251 -251
- package/dist/components/fields.js +69 -69
- package/dist/components/functional-components.js +1 -1
- package/dist/components/index2.js +2 -2
- package/dist/components/markdown.js +28 -28
- package/dist/components/utilities.js +20 -20
- package/dist/esm/{arcade-defaults-d7893362.js → arcade-defaults-0bafa696.js} +1534 -1534
- package/dist/esm/arcade-mode-c17a1fa1.js +595 -0
- package/dist/esm/arcgis-arcade-api_6.entry.js +1404 -1408
- package/dist/esm/arcgis-coding-components.js +3 -3
- package/dist/esm/{cssMode-b1771f92.js → cssMode-3d18bd2b.js} +2 -2
- package/dist/esm/{html-af635d52.js → html-2bce5d77.js} +2 -2
- package/dist/esm/{htmlMode-3021c301.js → htmlMode-69d56956.js} +2 -2
- package/dist/esm/{index-fd6b2fd8.js → index-022fb97b.js} +67 -24
- package/dist/esm/index.js +2 -2
- package/dist/esm/{javascript-70589186.js → javascript-ded5c9d7.js} +3 -3
- package/dist/esm/{jsonMode-cb509b79.js → jsonMode-0bf84cb2.js} +2 -2
- package/dist/esm/loader.js +2 -2
- package/dist/esm/{tsMode-ed90c9aa.js → tsMode-15d4e936.js} +2 -2
- package/dist/esm/{typescript-db8a0b18.js → typescript-cc4d00f0.js} +2 -2
- package/dist/types/components/arcade-api/arcade-api.d.ts +40 -40
- package/dist/types/components/arcade-api/t9n-types.d.ts +6 -6
- package/dist/types/components/arcade-editor/arcade-editor.d.ts +127 -127
- package/dist/types/components/arcade-editor/t9n-types.d.ts +6 -6
- package/dist/types/components/arcade-results/arcade-results.d.ts +47 -47
- package/dist/types/components/arcade-results/t9n-types.d.ts +11 -11
- package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +34 -34
- package/dist/types/components/arcade-suggestions/t9n-types.d.ts +4 -4
- package/dist/types/components/arcade-variables/arcade-variables.d.ts +41 -41
- package/dist/types/components/arcade-variables/t9n-types.d.ts +6 -6
- package/dist/types/components/code-editor/code-editor.d.ts +73 -73
- package/dist/types/stencil-public-runtime.d.ts +8 -0
- package/dist/types/utils/arcade-executor.d.ts +79 -79
- package/dist/types/utils/arcade-monaco/arcade-defaults.d.ts +66 -66
- package/dist/types/utils/arcade-monaco/arcade-language-features.d.ts +23 -23
- package/dist/types/utils/arcade-monaco/arcade-mode.d.ts +9 -9
- package/dist/types/utils/arcade-monaco/arcade-theme.d.ts +7 -7
- package/dist/types/utils/arcade-monaco/arcade-worker-manager.d.ts +9 -9
- package/dist/types/utils/arcade-monaco/arcade.worker.d.ts +12 -12
- package/dist/types/utils/arcade-monaco/types.d.ts +29 -29
- package/dist/types/utils/editor-suggestions.d.ts +24 -24
- package/dist/types/utils/functional-components.d.ts +1 -1
- package/dist/types/utils/markdown.d.ts +1 -1
- package/dist/types/utils/profile/editor-profile.d.ts +185 -185
- package/dist/types/utils/profile/types.d.ts +101 -101
- package/dist/types/utils/utilities.d.ts +1 -1
- package/package.json +7 -7
- package/dist/arcgis-coding-components/p-5d670bd2.js +0 -2
- package/dist/arcgis-coding-components/p-9e242e76.js +0 -1
- package/dist/arcgis-coding-components/p-ccdf0ac1.entry.js +0 -1
- package/dist/cjs/arcade-mode-b77afcc9.js +0 -598
- package/dist/esm/arcade-mode-70e22d22.js +0 -594
|
@@ -4,480 +4,480 @@ import { CompletionItemKind, DiagnosticSeverity, InsertTextFormat } from 'vscode
|
|
|
4
4
|
var ge=(e=>(e.False="false",e.Null="null",e.True="true",e))(ge||{}),xe=(e=>(e.Break="break",e.Continue="continue",e.Else="else",e.For="for",e.From="from",e.Function="function",e.If="if",e.Import="import",e.Export="export",e.In="in",e.Return="return",e.Var="var",e.While="while",e))(xe||{}),c=(e=>(e.AssignmentExpression="AssignmentExpression",e.ArrayExpression="ArrayExpression",e.BlockComment="BlockComment",e.BlockStatement="BlockStatement",e.BinaryExpression="BinaryExpression",e.BreakStatement="BreakStatement",e.CallExpression="CallExpression",e.ContinueStatement="ContinueStatement",e.EmptyStatement="EmptyStatement",e.ExpressionStatement="ExpressionStatement",e.ExportNamedDeclaration="ExportNamedDeclaration",e.ExportSpecifier="ExportSpecifier",e.ForStatement="ForStatement",e.ForInStatement="ForInStatement",e.FunctionDeclaration="FunctionDeclaration",e.Identifier="Identifier",e.IfStatement="IfStatement",e.ImportDeclaration="ImportDeclaration",e.ImportDefaultSpecifier="ImportDefaultSpecifier",e.LineComment="LineComment",e.Literal="Literal",e.LogicalExpression="LogicalExpression",e.MemberExpression="MemberExpression",e.ObjectExpression="ObjectExpression",e.Program="Program",e.Property="Property",e.ReturnStatement="ReturnStatement",e.TemplateElement="TemplateElement",e.TemplateLiteral="TemplateLiteral",e.UnaryExpression="UnaryExpression",e.UpdateExpression="UpdateExpression",e.VariableDeclaration="VariableDeclaration",e.VariableDeclarator="VariableDeclarator",e.WhileStatement="WhileStatement",e))(c||{}),De=["++","--"],We=["-","+","!","~"],qe=["=","/=","*=","%=","+=","-="],He=["||","&&"],bt=["|","&",">>","<<",">>>","^","==","!=","<","<=",">",">=","+","-","*","/","%"],It=(e=>(e[e.Unknown=0]="Unknown",e[e.BooleanLiteral=1]="BooleanLiteral",e[e.EOF=2]="EOF",e[e.Identifier=3]="Identifier",e[e.Keyword=4]="Keyword",e[e.NullLiteral=5]="NullLiteral",e[e.NumericLiteral=6]="NumericLiteral",e[e.Punctuator=7]="Punctuator",e[e.StringLiteral=8]="StringLiteral",e[e.Template=10]="Template",e))(It||{}),kt=(e=>(e.InvalidModuleUri="InvalidModuleUri",e.ForInOfLoopInitializer="ForInOfLoopInitializer",e.IdentiferExpected="IdentiferExpected",e.InvalidEscapedReservedWord="InvalidEscapedReservedWord",e.InvalidExpression="InvalidExpression",e.InvalidFunctionIdentifier="InvalidFunctionIdentifier",e.InvalidHexEscapeSequence="InvalidHexEscapeSequence",e.InvalidLeftHandSideInAssignment="InvalidLeftHandSideInAssignment",e.InvalidLeftHandSideInForIn="InvalidLeftHandSideInForIn",e.InvalidTemplateHead="InvalidTemplateHead",e.InvalidVariableAssignment="InvalidVariableAssignment",e.KeyMustBeString="KeyMustBeString",e.NoFunctionInsideBlock="NoFunctionInsideBlock",e.NoFunctionInsideFunction="NoFunctionInsideFunction",e.ModuleExportRootOnly="ModuleExportRootOnly",e.ModuleImportRootOnly="ModuleImportRootOnly",e.PunctuatorExpected="PunctuatorExpected",e.TemplateOctalLiteral="TemplateOctalLiteral",e.UnexpectedBoolean="UnexpectedBoolean",e.UnexpectedEndOfScript="UnexpectedEndOfScript",e.UnexpectedIdentifier="UnexpectedIdentifier",e.UnexpectedKeyword="UnexpectedKeyword",e.UnexpectedNull="UnexpectedNull",e.UnexpectedNumber="UnexpectedNumber",e.UnexpectedPunctuator="UnexpectedPunctuator",e.UnexpectedString="UnexpectedString",e.UnexpectedTemplate="UnexpectedTemplate",e.UnexpectedToken="UnexpectedToken",e))(kt||{});var v=[[],[],[]];De.forEach(e=>v[e.length-1].push(e));We.forEach(e=>v[e.length-1].push(e));He.forEach(e=>v[e.length-1].push(e));qe.forEach(e=>v[e.length-1].push(e));bt.forEach(e=>v[e.length-1].push(e));var rt=(D=>(D.AlreadyDefined="AlreadyDefined",D.ApiConflict="ApiConflict",D.AssignedNeverUsed="AssignedNeverUsed",D.DefinedNeverAssigned="DefinedNeverAssigned",D.DefinedNeverUsed="DefinedNeverUsed",D.EmptyBlockStatement="EmptyBlockStatement",D.ExecutionError="ExecutionError",D.InvalidApiFunctionUsage="InvalidApiFunctionUsage",D.InvalidConstantIdentifier="InvalidConstantIdentifier",D.InvalidPropertyIdentifier="InvalidPropertyIdentifier",D.NoArgumentExpected="NoArgumentExpected",D.NotADictionary="NotADictionary",D.NotDefined="NotDefined",D.NotEnoughArguments="NotEnoughArguments",D.ProfileVariablesAreImmutable="ProfileVariablesAreImmutable",D.ProfileVariablesConflict="ProfileVariablesConflict",D.ReservedKeyword="ReservedKeyword",D.TooManyArguments="TooManyArguments",D.UnexpectedEmptyFunction="UnexpectedEmptyFunction",D.UnexpectedPropertyIdentifier="UnexpectedPropertyIdentifier",D.UnknownPropertyIdentifier="UnknownPropertyIdentifier",D))(rt||{});var st=Object.values(xe),at=Object.values(ge);at.map(e=>({label:e,kind:CompletionItemKind.Constant}));st.map(e=>({label:e,kind:CompletionItemKind.Keyword}));
|
|
5
5
|
|
|
6
6
|
const operators = [
|
|
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
|
-
|
|
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
35
|
];
|
|
36
36
|
const arcadeLanguageConfiguration = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
37
|
+
// the default separators except `@$`
|
|
38
|
+
wordPattern: /(-?\d*\.\d\w*)|([^`~!#%\^&\*\(\)\-=\+\[\{\]\}\\\|;:'",\.<>\/\?\s]+)/gu,
|
|
39
|
+
comments: {
|
|
40
|
+
lineComment: "//",
|
|
41
|
+
blockComment: ["/*", "*/"]
|
|
42
|
+
},
|
|
43
|
+
brackets: [
|
|
44
|
+
["{", "}"],
|
|
45
|
+
["[", "]"],
|
|
46
|
+
["(", ")"]
|
|
47
|
+
],
|
|
48
|
+
autoClosingPairs: [
|
|
49
|
+
{ open: "{", close: "}" },
|
|
50
|
+
{ open: "[", close: "]" },
|
|
51
|
+
{ open: "(", close: ")" },
|
|
52
|
+
{ open: '"', close: '"', notIn: ["string"] },
|
|
53
|
+
{ open: "'", close: "'", notIn: ["string", "comment"] },
|
|
54
|
+
{ open: "`", close: "`", notIn: ["string", "comment"] }
|
|
55
|
+
],
|
|
56
|
+
autoCloseBefore: ";:.,=}])` \n\t",
|
|
57
|
+
folding: {
|
|
58
|
+
markers: {
|
|
59
|
+
start: /^\s*\/\/\s*#?region\b/u,
|
|
60
|
+
end: /^\s*\/\/\s*#?endregion\b/u
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
indentationRules: {
|
|
64
|
+
// ^(.*\*/)?\s*\}.*$
|
|
65
|
+
decreaseIndentPattern: /^((?!.*?\/\*).*\*\/)?\s*[\}\]\)].*$/u,
|
|
66
|
+
// ^.*\{[^}"']*$
|
|
67
|
+
increaseIndentPattern: /^((?!\/\/).)*(\{[^}"'`]*|\([^)"'`]*|\[[^\]"'`]*)$/u
|
|
61
68
|
}
|
|
62
|
-
},
|
|
63
|
-
indentationRules: {
|
|
64
|
-
// ^(.*\*/)?\s*\}.*$
|
|
65
|
-
decreaseIndentPattern: /^((?!.*?\/\*).*\*\/)?\s*[\}\]\)].*$/,
|
|
66
|
-
// ^.*\{[^}"']*$
|
|
67
|
-
increaseIndentPattern: /^((?!\/\/).)*(\{[^}"'`]*|\([^)"'`]*|\[[^\]"'`]*)$/
|
|
68
|
-
}
|
|
69
69
|
};
|
|
70
70
|
const arcadeMonarchLanguage = {
|
|
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
|
-
|
|
71
|
+
// Set defaultToken to invalid to see what you do not tokenize yet
|
|
72
|
+
defaultToken: "invalid",
|
|
73
|
+
tokenPostfix: ".arc",
|
|
74
|
+
// Arcade is case insensitive
|
|
75
|
+
ignoreCase: true,
|
|
76
|
+
// builtinFunctions: Array.from(arcadeService.FunctionNames),
|
|
77
|
+
// Arcade keywords. 'from' is a special case as we want to treat it as a keyword in
|
|
78
|
+
// import statement but as an identifer in var statement.
|
|
79
|
+
keywords: st.filter((k) => k !== "from"),
|
|
80
|
+
operators,
|
|
81
|
+
constants: ["true", "false", "null"],
|
|
82
|
+
// we include these common regular expressions
|
|
83
|
+
symbols: /[=><!~?:&|+\-*\/\^%]+/u,
|
|
84
|
+
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/u,
|
|
85
|
+
digits: /\d+(_+\d+)*/u,
|
|
86
|
+
octaldigits: /[0-7]+(_+[0-7]+)*/u,
|
|
87
|
+
binarydigits: /[0-1]+(_+[0-1]+)*/u,
|
|
88
|
+
hexdigits: /[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/u,
|
|
89
|
+
regexpctl: /[(){}\[\]\$\^|\-*+?\.]/u,
|
|
90
|
+
regexpesc: /\\(?:[bBdDfnrstvwWn0\\\/]|@regexpctl|c[A-Z]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})/u,
|
|
91
|
+
// The main tokenizer for our languages
|
|
92
|
+
tokenizer: {
|
|
93
|
+
root: [[/[{}]/u, "delimiter.bracket"], { include: "common" }],
|
|
94
|
+
common: [
|
|
95
|
+
// import statement. import followed by a white space
|
|
96
|
+
[/import(?=\s)/u, { token: "keyword", next: "@import" }],
|
|
97
|
+
// identifiers and keywords
|
|
98
|
+
[
|
|
99
|
+
/[a-z_$][\w$]*/u,
|
|
100
|
+
{
|
|
101
|
+
cases: {
|
|
102
|
+
"@constants": "constant",
|
|
103
|
+
"@keywords": "keyword",
|
|
104
|
+
"@default": "identifier"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
// whitespace
|
|
109
|
+
{ include: "@whitespace" },
|
|
110
|
+
// regular expression: ensure it is terminated before beginning (otherwise it is an opeator)
|
|
111
|
+
[
|
|
112
|
+
/\/(?=([^\\\/]|\\.)+\/([gimsuy]*)(\s*)(\.|;|\/|,|\)|\]|\}|$))/u,
|
|
113
|
+
{ token: "regexp", bracket: "@open", next: "@regexp" }
|
|
114
|
+
],
|
|
115
|
+
// delimiters and operators
|
|
116
|
+
[/[()\[\]]/u, "@brackets"],
|
|
117
|
+
[/[<>](?!@symbols)/u, "@brackets"],
|
|
118
|
+
[
|
|
119
|
+
/@symbols/u,
|
|
120
|
+
{
|
|
121
|
+
cases: {
|
|
122
|
+
"@operators": "delimiter",
|
|
123
|
+
"@default": ""
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
// numbers
|
|
128
|
+
[/(@digits)[eE]([\-+]?(@digits))?/u, "number"],
|
|
129
|
+
[/(@digits)\.(@digits)([eE][\-+]?(@digits))?/u, "number"],
|
|
130
|
+
[/0[xX](@hexdigits)/u, "number"],
|
|
131
|
+
[/0[oO]?(@octaldigits)/u, "number"],
|
|
132
|
+
[/0[bB](@binarydigits)/u, "number"],
|
|
133
|
+
[/(@digits)/u, "number"],
|
|
134
|
+
// delimiter: after number because of .\d floats
|
|
135
|
+
[/[;,.]/u, "delimiter"],
|
|
136
|
+
// strings
|
|
137
|
+
[/"([^"\\]|\\.)*$/u, "string.invalid"],
|
|
138
|
+
[/'([^'\\]|\\.)*$/u, "string.invalid"],
|
|
139
|
+
[/"/u, "string", "@string_double"],
|
|
140
|
+
[/'/u, "string", "@string_single"],
|
|
141
|
+
[/`/u, "string", "@string_backtick"]
|
|
142
|
+
],
|
|
143
|
+
import: [
|
|
144
|
+
// import keyword
|
|
145
|
+
[/import(?=\s)/u, { token: "keyword" }],
|
|
146
|
+
// whitespace
|
|
147
|
+
{ include: "@whitespace" },
|
|
148
|
+
// identifier
|
|
149
|
+
[/[a-z_$][\w$]*/u, "identifier"],
|
|
150
|
+
// whitespace
|
|
151
|
+
{ include: "@whitespace" },
|
|
152
|
+
// from keyword
|
|
153
|
+
[/from/u, { token: "keyword", next: "@popall" }]
|
|
154
|
+
],
|
|
155
|
+
whitespace: [
|
|
156
|
+
[/[ \t\r\n]+/u, ""],
|
|
157
|
+
[/\/\*/u, "comment", "@comment"],
|
|
158
|
+
[/\/\/.*$/u, "comment"]
|
|
159
|
+
],
|
|
160
|
+
comment: [
|
|
161
|
+
[/[^\/*]+/u, "comment"],
|
|
162
|
+
[/\*\//u, "comment", "@pop"],
|
|
163
|
+
[/[\/*]/u, "comment"]
|
|
164
|
+
],
|
|
165
|
+
// We match regular expression quite precisely
|
|
166
|
+
regexp: [
|
|
167
|
+
[/(\{)(\d+(?:,\d*)?)(\})/u, ["regexp.escape.control", "regexp.escape.control", "regexp.escape.control"]],
|
|
168
|
+
[
|
|
169
|
+
/(\[)(\^?)(?=(?:[^\]\\\/]|\\.)+)/u,
|
|
170
|
+
["regexp.escape.control", { token: "regexp.escape.control", next: "@regexrange" }]
|
|
171
|
+
],
|
|
172
|
+
[/(\()(\?:|\?=|\?!)/u, ["regexp.escape.control", "regexp.escape.control"]],
|
|
173
|
+
[/[()]/u, "regexp.escape.control"],
|
|
174
|
+
[/@regexpctl/u, "regexp.escape.control"],
|
|
175
|
+
[/[^\\\/]/u, "regexp"],
|
|
176
|
+
[/@regexpesc/u, "regexp.escape"],
|
|
177
|
+
[/\\\./u, "regexp.invalid"],
|
|
178
|
+
[/(\/)([gimsuy]*)/u, [{ token: "regexp", bracket: "@close", next: "@pop" }, "keyword.other"]]
|
|
179
|
+
],
|
|
180
|
+
regexrange: [
|
|
181
|
+
[/-/u, "regexp.escape.control"],
|
|
182
|
+
[/\^/u, "regexp.invalid"],
|
|
183
|
+
[/@regexpesc/u, "regexp.escape"],
|
|
184
|
+
[/[^\]]/u, "regexp"],
|
|
185
|
+
[/\]/u, { token: "regexp.escape.control", next: "@pop", bracket: "@close" }]
|
|
186
|
+
],
|
|
187
|
+
string_double: [
|
|
188
|
+
[/[^\\"]+/u, "string"],
|
|
189
|
+
[/@escapes/u, "string.escape"],
|
|
190
|
+
[/\\./u, "string.escape.invalid"],
|
|
191
|
+
[/"/u, "string", "@pop"]
|
|
192
|
+
],
|
|
193
|
+
string_single: [
|
|
194
|
+
[/[^\\']+/u, "string"],
|
|
195
|
+
[/@escapes/u, "string.escape"],
|
|
196
|
+
[/\\./u, "string.escape.invalid"],
|
|
197
|
+
[/'/u, "string", "@pop"]
|
|
198
|
+
],
|
|
199
|
+
string_backtick: [
|
|
200
|
+
[/\$\{/u, { token: "delimiter.bracket", next: "@bracketCounting" }],
|
|
201
|
+
[/[^\\`$]+/u, "string"],
|
|
202
|
+
[/@escapes/u, "string.escape"],
|
|
203
|
+
[/\\./u, "string.escape.invalid"],
|
|
204
|
+
[/`/u, "string", "@pop"]
|
|
205
|
+
],
|
|
206
|
+
bracketCounting: [
|
|
207
|
+
[/\{/u, "delimiter.bracket", "@bracketCounting"],
|
|
208
|
+
[/\}/u, "delimiter.bracket", "@pop"],
|
|
209
|
+
{ include: "common" }
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
212
|
};
|
|
213
213
|
|
|
214
214
|
//#region Diagnostic
|
|
215
215
|
class DiagnosticsAdapter {
|
|
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
|
-
|
|
216
|
+
constructor(_languageId, _worker, { defaults, diagnosticsService }) {
|
|
217
|
+
this._languageId = _languageId;
|
|
218
|
+
this._worker = _worker;
|
|
219
|
+
this._disposables = [];
|
|
220
|
+
this._listener = Object.create(null);
|
|
221
|
+
this._diagnosticsService = diagnosticsService;
|
|
222
|
+
this._defaults = defaults;
|
|
223
|
+
const onModelAdd = (model) => {
|
|
224
|
+
const languageId = model.getLanguageId();
|
|
225
|
+
if (languageId !== this._languageId) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
let handle;
|
|
229
|
+
this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
|
|
230
|
+
window.clearTimeout(handle);
|
|
231
|
+
handle = window.setTimeout(() => this._doValidate(model, languageId), 500);
|
|
232
|
+
});
|
|
233
|
+
this._doValidate(model, languageId);
|
|
234
|
+
};
|
|
235
|
+
const onModelRemoved = (model) => {
|
|
236
|
+
const uriStr = model.uri.toString();
|
|
237
|
+
editor.setModelMarkers(model, this._languageId, []);
|
|
238
|
+
const listener = this._listener[uriStr];
|
|
239
|
+
if (listener) {
|
|
240
|
+
listener.dispose();
|
|
241
|
+
delete this._listener[uriStr];
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
this._disposables.push(editor.onDidCreateModel(onModelAdd));
|
|
245
|
+
this._disposables.push(editor.onWillDisposeModel((model) => {
|
|
246
|
+
onModelRemoved(model);
|
|
247
|
+
}));
|
|
248
|
+
this._disposables.push(editor.onDidChangeModelLanguage((event) => {
|
|
249
|
+
onModelRemoved(event.model);
|
|
250
|
+
onModelAdd(event.model);
|
|
251
|
+
}));
|
|
252
|
+
this._disposables.push(defaults.onDidChange(() => {
|
|
253
|
+
editor.getModels().forEach((model) => {
|
|
254
|
+
if (model.getLanguageId() === this._languageId) {
|
|
255
|
+
onModelRemoved(model);
|
|
256
|
+
onModelAdd(model);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}));
|
|
260
|
+
this._disposables.push(defaults.onModelContextDidChange((key) => {
|
|
261
|
+
editor.getModels().forEach((model) => {
|
|
262
|
+
if (model.getLanguageId() === this._languageId && model.uri.toString() === key) {
|
|
263
|
+
this._doValidate(model, this._languageId);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}));
|
|
267
|
+
this._disposables.push({
|
|
268
|
+
dispose: () => {
|
|
269
|
+
for (const key of Object.keys(this._listener)) {
|
|
270
|
+
this._listener[key].dispose();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
editor.getModels().forEach(onModelAdd);
|
|
275
|
+
}
|
|
276
|
+
dispose() {
|
|
277
|
+
this._disposables.forEach((d) => d && d.dispose());
|
|
278
|
+
this._disposables = [];
|
|
279
|
+
}
|
|
280
|
+
async _doValidate(model, languageId) {
|
|
281
|
+
if (!model.isAttachedToEditor()) {
|
|
282
|
+
return;
|
|
257
283
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
284
|
+
try {
|
|
285
|
+
const workerProxy = await this._worker(model.uri);
|
|
286
|
+
const context = this._defaults.getApiContextForModel(model.uri);
|
|
287
|
+
const diagnostics = await workerProxy.doValidation(model.uri.toString(), context);
|
|
288
|
+
const markers = diagnostics.map((d) => toMarker(model.uri, d));
|
|
289
|
+
this._diagnosticsService.fireDiagnosticsChange(model.uri, diagnostics);
|
|
290
|
+
editor.setModelMarkers(model, languageId, markers);
|
|
264
291
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
this._disposables.push({
|
|
268
|
-
dispose: () => {
|
|
269
|
-
for (const key in this._listener) {
|
|
270
|
-
this._listener[key].dispose();
|
|
292
|
+
catch (err) {
|
|
293
|
+
console.error(err);
|
|
271
294
|
}
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
editor.getModels().forEach(onModelAdd);
|
|
275
|
-
}
|
|
276
|
-
dispose() {
|
|
277
|
-
this._disposables.forEach((d) => d && d.dispose());
|
|
278
|
-
this._disposables = [];
|
|
279
|
-
}
|
|
280
|
-
async _doValidate(model, languageId) {
|
|
281
|
-
if (!model.isAttachedToEditor()) {
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
try {
|
|
285
|
-
const workerProxy = await this._worker(model.uri);
|
|
286
|
-
const context = this._defaults.getApiContextForModel(model.uri);
|
|
287
|
-
const diagnostics = await workerProxy.doValidation(model.uri.toString(), context);
|
|
288
|
-
const markers = diagnostics.map((d) => toMarker(model.uri, d));
|
|
289
|
-
this._diagnosticsService.fireDiagnosticsChange(model.uri, diagnostics);
|
|
290
|
-
editor.setModelMarkers(model, languageId, markers);
|
|
291
295
|
}
|
|
292
|
-
catch (err) {
|
|
293
|
-
console.error(err);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
296
|
}
|
|
297
297
|
function toSeverity(languageServiceSeverity) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
298
|
+
switch (languageServiceSeverity) {
|
|
299
|
+
case DiagnosticSeverity.Error:
|
|
300
|
+
return MarkerSeverity.Error;
|
|
301
|
+
case DiagnosticSeverity.Warning:
|
|
302
|
+
return MarkerSeverity.Warning;
|
|
303
|
+
case DiagnosticSeverity.Information:
|
|
304
|
+
return MarkerSeverity.Info;
|
|
305
|
+
case DiagnosticSeverity.Hint:
|
|
306
|
+
return MarkerSeverity.Hint;
|
|
307
|
+
default:
|
|
308
|
+
return MarkerSeverity.Info;
|
|
309
|
+
}
|
|
310
310
|
}
|
|
311
311
|
function toMarker(_resource, diag) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
312
|
+
// Diagnostics positions are zero-based, MarkerData are 1-based
|
|
313
|
+
return {
|
|
314
|
+
severity: toSeverity(diag.severity),
|
|
315
|
+
startLineNumber: diag.range.start.line + 1,
|
|
316
|
+
startColumn: diag.range.start.character + 1,
|
|
317
|
+
endLineNumber: diag.range.end.line + 1,
|
|
318
|
+
endColumn: diag.range.end.character + 1,
|
|
319
|
+
message: diag.message
|
|
320
|
+
};
|
|
321
321
|
}
|
|
322
322
|
//#endregion
|
|
323
323
|
//#region Completion
|
|
324
324
|
function fromPosition(position) {
|
|
325
|
-
|
|
326
|
-
|
|
325
|
+
// Language service is zero based
|
|
326
|
+
return { character: position.column - 1, line: position.lineNumber - 1 };
|
|
327
327
|
}
|
|
328
328
|
function toRange(range) {
|
|
329
|
-
|
|
329
|
+
return new Range(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);
|
|
330
330
|
}
|
|
331
331
|
function toTextEdit(textEdit) {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
332
|
+
return {
|
|
333
|
+
range: toRange(textEdit.range),
|
|
334
|
+
text: textEdit.newText
|
|
335
|
+
};
|
|
336
336
|
}
|
|
337
337
|
function isInsertReplaceEdit(edit) {
|
|
338
|
-
|
|
338
|
+
return (typeof edit.insert !== "undefined" && typeof edit.replace !== "undefined");
|
|
339
339
|
}
|
|
340
340
|
function toCompletionItemKind(kind) {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
341
|
+
const mItemKind = languages.CompletionItemKind;
|
|
342
|
+
switch (kind) {
|
|
343
|
+
case CompletionItemKind.Text:
|
|
344
|
+
return mItemKind.Text;
|
|
345
|
+
case CompletionItemKind.Method:
|
|
346
|
+
return mItemKind.Method;
|
|
347
|
+
case CompletionItemKind.Function:
|
|
348
|
+
return mItemKind.Function;
|
|
349
|
+
case CompletionItemKind.Constructor:
|
|
350
|
+
return mItemKind.Constructor;
|
|
351
|
+
case CompletionItemKind.Field:
|
|
352
|
+
return mItemKind.Field;
|
|
353
|
+
case CompletionItemKind.Variable:
|
|
354
|
+
return mItemKind.Variable;
|
|
355
|
+
case CompletionItemKind.Class:
|
|
356
|
+
return mItemKind.Class;
|
|
357
|
+
case CompletionItemKind.Interface:
|
|
358
|
+
return mItemKind.Interface;
|
|
359
|
+
case CompletionItemKind.Module:
|
|
360
|
+
return mItemKind.Module;
|
|
361
|
+
case CompletionItemKind.Property:
|
|
362
|
+
return mItemKind.Property;
|
|
363
|
+
case CompletionItemKind.Unit:
|
|
364
|
+
return mItemKind.Unit;
|
|
365
|
+
case CompletionItemKind.Value:
|
|
366
|
+
return mItemKind.Value;
|
|
367
|
+
case CompletionItemKind.Enum:
|
|
368
|
+
return mItemKind.Enum;
|
|
369
|
+
case CompletionItemKind.Keyword:
|
|
370
|
+
return mItemKind.Keyword;
|
|
371
|
+
case CompletionItemKind.Snippet:
|
|
372
|
+
return mItemKind.Snippet;
|
|
373
|
+
case CompletionItemKind.Color:
|
|
374
|
+
return mItemKind.Color;
|
|
375
|
+
case CompletionItemKind.File:
|
|
376
|
+
return mItemKind.File;
|
|
377
|
+
case CompletionItemKind.Reference:
|
|
378
|
+
return mItemKind.Reference;
|
|
379
|
+
case CompletionItemKind.Folder:
|
|
380
|
+
return mItemKind.Folder;
|
|
381
|
+
case CompletionItemKind.EnumMember:
|
|
382
|
+
return mItemKind.EnumMember;
|
|
383
|
+
case CompletionItemKind.Constant:
|
|
384
|
+
return mItemKind.Constant;
|
|
385
|
+
case CompletionItemKind.Struct:
|
|
386
|
+
return mItemKind.Struct;
|
|
387
|
+
case CompletionItemKind.Event:
|
|
388
|
+
return mItemKind.Event;
|
|
389
|
+
case CompletionItemKind.Operator:
|
|
390
|
+
return mItemKind.Operator;
|
|
391
|
+
case CompletionItemKind.TypeParameter:
|
|
392
|
+
return mItemKind.TypeParameter;
|
|
393
|
+
}
|
|
394
|
+
return mItemKind.Property;
|
|
395
395
|
}
|
|
396
396
|
class CompletionProvider {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
async provideCompletionItems(model, position
|
|
403
|
-
// _context: languages.CompletionContext,
|
|
404
|
-
// _token: CancellationToken,
|
|
405
|
-
) {
|
|
406
|
-
const worker = await this._worker(model.uri);
|
|
407
|
-
const context = this._defaults.getApiContextForModel(model.uri);
|
|
408
|
-
const completionList = await worker.doComplete(model.uri.toString(), fromPosition(position), context);
|
|
409
|
-
if (!completionList) {
|
|
410
|
-
return;
|
|
397
|
+
constructor(_worker, _defaults) {
|
|
398
|
+
this._worker = _worker;
|
|
399
|
+
this._defaults = _defaults;
|
|
400
|
+
this.triggerCharacters = [".", "("];
|
|
411
401
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
range: wordRange,
|
|
422
|
-
kind: toCompletionItemKind(entry.kind)
|
|
423
|
-
};
|
|
424
|
-
if (entry.textEdit) {
|
|
425
|
-
if (isInsertReplaceEdit(entry.textEdit)) {
|
|
426
|
-
item.range = {
|
|
427
|
-
insert: toRange(entry.textEdit.insert),
|
|
428
|
-
replace: toRange(entry.textEdit.replace)
|
|
429
|
-
};
|
|
430
|
-
}
|
|
431
|
-
else {
|
|
432
|
-
item.range = toRange(entry.textEdit.range);
|
|
433
|
-
}
|
|
434
|
-
item.insertText = entry.textEdit.newText;
|
|
435
|
-
}
|
|
436
|
-
if (entry.additionalTextEdits) {
|
|
437
|
-
item.additionalTextEdits = entry.additionalTextEdits.map(toTextEdit);
|
|
438
|
-
}
|
|
439
|
-
if (entry.insertTextFormat === InsertTextFormat.Snippet) {
|
|
440
|
-
item.insertTextRules = languages.CompletionItemInsertTextRule.InsertAsSnippet;
|
|
441
|
-
}
|
|
442
|
-
if (entry.documentation) {
|
|
443
|
-
if (typeof entry.documentation === "string") {
|
|
444
|
-
item.documentation = entry.documentation;
|
|
402
|
+
async provideCompletionItems(model, position
|
|
403
|
+
// _context: languages.CompletionContext,
|
|
404
|
+
// _token: CancellationToken,
|
|
405
|
+
) {
|
|
406
|
+
const worker = await this._worker(model.uri);
|
|
407
|
+
const context = this._defaults.getApiContextForModel(model.uri);
|
|
408
|
+
const completionList = await worker.doComplete(model.uri.toString(), fromPosition(position), context);
|
|
409
|
+
if (!completionList) {
|
|
410
|
+
return;
|
|
445
411
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
412
|
+
const wordInfo = model.getWordUntilPosition(position);
|
|
413
|
+
const wordRange = new Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);
|
|
414
|
+
const items = completionList.items.map((entry) => {
|
|
415
|
+
const item = {
|
|
416
|
+
label: entry.label,
|
|
417
|
+
insertText: entry.insertText || entry.label,
|
|
418
|
+
sortText: entry.sortText,
|
|
419
|
+
filterText: entry.filterText,
|
|
420
|
+
detail: entry.detail,
|
|
421
|
+
range: wordRange,
|
|
422
|
+
kind: toCompletionItemKind(entry.kind)
|
|
423
|
+
};
|
|
424
|
+
if (entry.textEdit) {
|
|
425
|
+
if (isInsertReplaceEdit(entry.textEdit)) {
|
|
426
|
+
item.range = {
|
|
427
|
+
insert: toRange(entry.textEdit.insert),
|
|
428
|
+
replace: toRange(entry.textEdit.replace)
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
item.range = toRange(entry.textEdit.range);
|
|
433
|
+
}
|
|
434
|
+
item.insertText = entry.textEdit.newText;
|
|
435
|
+
}
|
|
436
|
+
if (entry.additionalTextEdits) {
|
|
437
|
+
item.additionalTextEdits = entry.additionalTextEdits.map(toTextEdit);
|
|
438
|
+
}
|
|
439
|
+
if (entry.insertTextFormat === InsertTextFormat.Snippet) {
|
|
440
|
+
item.insertTextRules = languages.CompletionItemInsertTextRule.InsertAsSnippet;
|
|
441
|
+
}
|
|
442
|
+
if (entry.documentation) {
|
|
443
|
+
if (typeof entry.documentation === "string") {
|
|
444
|
+
item.documentation = entry.documentation;
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
item.documentation = {
|
|
448
|
+
supportThemeIcons: false,
|
|
449
|
+
value: entry.documentation.value,
|
|
450
|
+
supportHtml: true
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return item;
|
|
455
|
+
});
|
|
456
|
+
return {
|
|
457
|
+
incomplete: completionList.isIncomplete,
|
|
458
|
+
suggestions: items
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
461
|
}
|
|
462
462
|
//#endregion
|
|
463
463
|
//#region Formatter
|
|
464
464
|
class FormattingProvider {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
465
|
+
constructor(_worker, _defaults) {
|
|
466
|
+
this._worker = _worker;
|
|
467
|
+
this._defaults = _defaults;
|
|
468
|
+
}
|
|
469
|
+
async provideDocumentFormattingEdits(model
|
|
470
|
+
// _options: languages.FormattingOptions,
|
|
471
|
+
// _token: CancellationToken,
|
|
472
|
+
) {
|
|
473
|
+
const worker = await this._worker(model.uri);
|
|
474
|
+
const context = this._defaults.getApiContextForModel(model.uri.toString());
|
|
475
|
+
const edits = await worker.doFormat(model.uri.toString(), context);
|
|
476
|
+
if (!edits) {
|
|
477
|
+
return [];
|
|
478
|
+
}
|
|
479
|
+
return edits.map((e) => ({ range: toRange(e.range), text: e.newText }));
|
|
478
480
|
}
|
|
479
|
-
return edits.map((e) => ({ range: toRange(e.range), text: e.newText }));
|
|
480
|
-
}
|
|
481
481
|
}
|
|
482
482
|
//#endregion
|
|
483
483
|
|
|
@@ -485,46 +485,46 @@ class FormattingProvider {
|
|
|
485
485
|
* Manager to create our arcade worker and client proxy
|
|
486
486
|
*/
|
|
487
487
|
class WorkerManager {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
488
|
+
constructor(_defaults) {
|
|
489
|
+
this._defaults = _defaults;
|
|
490
|
+
this._worker = null;
|
|
491
|
+
this._client = null;
|
|
492
|
+
// Observes the arcade defaults. If modified then stop the worker.
|
|
493
|
+
this._configChangeListener = this._defaults.onDidChange(() => this.stopWorker());
|
|
494
|
+
}
|
|
495
|
+
dispose() {
|
|
496
|
+
this._configChangeListener.dispose();
|
|
497
|
+
this.stopWorker();
|
|
498
|
+
}
|
|
499
|
+
stopWorker() {
|
|
500
|
+
if (this._worker) {
|
|
501
|
+
this._worker.dispose();
|
|
502
|
+
this._worker = null;
|
|
503
|
+
}
|
|
504
|
+
this._client = null;
|
|
503
505
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
506
|
+
_getClientProxy() {
|
|
507
|
+
// We used createWebWorker to create or run the web worker if it isn’t already created.
|
|
508
|
+
// Otherwise, we get and return the proxy client.
|
|
509
|
+
if (!this._client) {
|
|
510
|
+
const { languageId, languageOptions } = this._defaults;
|
|
511
|
+
this._worker = editor.createWebWorker({
|
|
512
|
+
moduleId: "ArcadeWorker",
|
|
513
|
+
label: languageId,
|
|
514
|
+
createData: {
|
|
515
|
+
languageId,
|
|
516
|
+
languageOptions
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
this._client = this._worker.getProxy();
|
|
517
520
|
}
|
|
518
|
-
|
|
519
|
-
|
|
521
|
+
return this._client;
|
|
522
|
+
}
|
|
523
|
+
async getLanguageServiceWorker(...resources) {
|
|
524
|
+
const _client = await this._getClientProxy();
|
|
525
|
+
await this._worker?.withSyncedResources(resources);
|
|
526
|
+
return _client;
|
|
520
527
|
}
|
|
521
|
-
return this._client;
|
|
522
|
-
}
|
|
523
|
-
async getLanguageServiceWorker(...resources) {
|
|
524
|
-
const _client = await this._getClientProxy();
|
|
525
|
-
await this._worker?.withSyncedResources(resources);
|
|
526
|
-
return _client;
|
|
527
|
-
}
|
|
528
528
|
}
|
|
529
529
|
|
|
530
530
|
let arcadeWorker;
|
|
@@ -534,36 +534,36 @@ let arcadeWorker;
|
|
|
534
534
|
* @returns The arcade worker.
|
|
535
535
|
*/
|
|
536
536
|
async function getArcadeWorker(...uris) {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
537
|
+
return new Promise((resolve, reject) => {
|
|
538
|
+
if (!arcadeWorker) {
|
|
539
|
+
return reject(new Error("TypeScript not registered!"));
|
|
540
|
+
}
|
|
541
|
+
resolve(arcadeWorker(...uris));
|
|
542
|
+
});
|
|
543
543
|
}
|
|
544
544
|
/**
|
|
545
545
|
* The Arcade Language Diagnostic Service.
|
|
546
546
|
* Consumers can listen to the diagnostics change event to get notified when the diagnostics change.
|
|
547
547
|
*/
|
|
548
548
|
class ArcadeDiagnosticService {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
549
|
+
constructor() {
|
|
550
|
+
this._onDiagnosticsChange = new Emitter();
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* An event to signal changes to the diagnostics.
|
|
554
|
+
* The event value is the uri string and the diagnostics.
|
|
555
|
+
*/
|
|
556
|
+
get onDiagnosticsChange() {
|
|
557
|
+
return this._onDiagnosticsChange.event;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Fires the diagnostics change event.
|
|
561
|
+
* @param uri The uri of the model for which the diagnostics changed.
|
|
562
|
+
* @param diagnostics The diagnostics for the model.
|
|
563
|
+
*/
|
|
564
|
+
fireDiagnosticsChange(uri, diagnostics) {
|
|
565
|
+
this._onDiagnosticsChange.fire({ uri, diagnostics });
|
|
566
|
+
}
|
|
567
567
|
}
|
|
568
568
|
const arcadeDiagnosticService = new ArcadeDiagnosticService();
|
|
569
569
|
/**
|
|
@@ -571,24 +571,25 @@ const arcadeDiagnosticService = new ArcadeDiagnosticService();
|
|
|
571
571
|
* @returns The Arcade Language Diagnostic Service.
|
|
572
572
|
*/
|
|
573
573
|
function getArcadeDiagnosticService() {
|
|
574
|
-
|
|
574
|
+
return arcadeDiagnosticService;
|
|
575
575
|
}
|
|
576
576
|
function setupMode(arcadeDefaults) {
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
577
|
+
const client = new WorkerManager(arcadeDefaults);
|
|
578
|
+
const workerAccessor = (...uris) => client.getLanguageServiceWorker(...uris);
|
|
579
|
+
arcadeWorker = workerAccessor;
|
|
580
|
+
// Use the arcade Monarch Json to define the highlighting
|
|
581
|
+
languages.setMonarchTokensProvider(arcadeDefaults.languageId, arcadeMonarchLanguage);
|
|
582
|
+
languages.setLanguageConfiguration(arcadeDefaults.languageId, arcadeLanguageConfiguration);
|
|
583
|
+
// Creates and registers a Completion Adapter
|
|
584
|
+
languages.registerCompletionItemProvider(arcadeDefaults.languageId, new CompletionProvider(workerAccessor, arcadeDefaults));
|
|
585
|
+
// Creates and registers a Formatter
|
|
586
|
+
languages.registerDocumentFormattingEditProvider(arcadeDefaults.languageId, new FormattingProvider(workerAccessor, arcadeDefaults));
|
|
587
|
+
// Creates a Diagnostic Adapter
|
|
588
|
+
// eslint-disable-next-line no-new
|
|
589
|
+
new DiagnosticsAdapter(arcadeDefaults.languageId, workerAccessor, {
|
|
590
|
+
defaults: arcadeDefaults,
|
|
591
|
+
diagnosticsService: arcadeDiagnosticService
|
|
592
|
+
});
|
|
592
593
|
}
|
|
593
594
|
|
|
594
595
|
export { getArcadeDiagnosticService, getArcadeWorker, setupMode };
|