1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | function arcade(hljs) {
|
11 | const IDENT_RE = '[A-Za-z_][0-9A-Za-z_]*';
|
12 | const KEYWORDS = {
|
13 | keyword: [
|
14 | "if",
|
15 | "for",
|
16 | "while",
|
17 | "var",
|
18 | "new",
|
19 | "function",
|
20 | "do",
|
21 | "return",
|
22 | "void",
|
23 | "else",
|
24 | "break"
|
25 | ],
|
26 | literal: [
|
27 | "BackSlash",
|
28 | "DoubleQuote",
|
29 | "false",
|
30 | "ForwardSlash",
|
31 | "Infinity",
|
32 | "NaN",
|
33 | "NewLine",
|
34 | "null",
|
35 | "PI",
|
36 | "SingleQuote",
|
37 | "Tab",
|
38 | "TextFormatting",
|
39 | "true",
|
40 | "undefined"
|
41 | ],
|
42 | built_in: [
|
43 | "Abs",
|
44 | "Acos",
|
45 | "All",
|
46 | "Angle",
|
47 | "Any",
|
48 | "Area",
|
49 | "AreaGeodetic",
|
50 | "Array",
|
51 | "Asin",
|
52 | "Atan",
|
53 | "Atan2",
|
54 | "Attachments",
|
55 | "Average",
|
56 | "Back",
|
57 | "Bearing",
|
58 | "Boolean",
|
59 | "Buffer",
|
60 | "BufferGeodetic",
|
61 | "Ceil",
|
62 | "Centroid",
|
63 | "Clip",
|
64 | "Concatenate",
|
65 | "Console",
|
66 | "Constrain",
|
67 | "Contains",
|
68 | "ConvertDirection",
|
69 | "Cos",
|
70 | "Count",
|
71 | "Crosses",
|
72 | "Cut",
|
73 | "Date",
|
74 | "DateAdd",
|
75 | "DateDiff",
|
76 | "Day",
|
77 | "Decode",
|
78 | "DefaultValue",
|
79 | "Densify",
|
80 | "DensifyGeodetic",
|
81 | "Dictionary",
|
82 | "Difference",
|
83 | "Disjoint",
|
84 | "Distance",
|
85 | "DistanceGeodetic",
|
86 | "Distinct",
|
87 | "Domain",
|
88 | "DomainCode",
|
89 | "DomainName",
|
90 | "EnvelopeIntersects",
|
91 | "Equals",
|
92 | "Erase",
|
93 | "Exp",
|
94 | "Expects",
|
95 | "Extent",
|
96 | "Feature",
|
97 | "FeatureSet",
|
98 | "FeatureSetByAssociation",
|
99 | "FeatureSetById",
|
100 | "FeatureSetByName",
|
101 | "FeatureSetByPortalItem",
|
102 | "FeatureSetByRelationshipName",
|
103 | "Filter",
|
104 | "Find",
|
105 | "First",
|
106 | "Floor",
|
107 | "FromCharCode",
|
108 | "FromCodePoint",
|
109 | "FromJSON",
|
110 | "GdbVersion",
|
111 | "Generalize",
|
112 | "Geometry",
|
113 | "GetFeatureSet",
|
114 | "GetUser",
|
115 | "GroupBy",
|
116 | "Guid",
|
117 | "Hash",
|
118 | "HasKey",
|
119 | "Hour",
|
120 | "IIf",
|
121 | "Includes",
|
122 | "IndexOf",
|
123 | "Insert",
|
124 | "Intersection",
|
125 | "Intersects",
|
126 | "IsEmpty",
|
127 | "IsNan",
|
128 | "ISOMonth",
|
129 | "ISOWeek",
|
130 | "ISOWeekday",
|
131 | "ISOYear",
|
132 | "IsSelfIntersecting",
|
133 | "IsSimple",
|
134 | "Left|0",
|
135 | "Length",
|
136 | "Length3D",
|
137 | "LengthGeodetic",
|
138 | "Log",
|
139 | "Lower",
|
140 | "Map",
|
141 | "Max",
|
142 | "Mean",
|
143 | "Mid",
|
144 | "Millisecond",
|
145 | "Min",
|
146 | "Minute",
|
147 | "Month",
|
148 | "MultiPartToSinglePart",
|
149 | "Multipoint",
|
150 | "NextSequenceValue",
|
151 | "None",
|
152 | "Now",
|
153 | "Number",
|
154 | "Offset|0",
|
155 | "OrderBy",
|
156 | "Overlaps",
|
157 | "Point",
|
158 | "Polygon",
|
159 | "Polyline",
|
160 | "Pop",
|
161 | "Portal",
|
162 | "Pow",
|
163 | "Proper",
|
164 | "Push",
|
165 | "Random",
|
166 | "Reduce",
|
167 | "Relate",
|
168 | "Replace",
|
169 | "Resize",
|
170 | "Reverse",
|
171 | "Right|0",
|
172 | "RingIsClockwise",
|
173 | "Rotate",
|
174 | "Round",
|
175 | "Schema",
|
176 | "Second",
|
177 | "SetGeometry",
|
178 | "Simplify",
|
179 | "Sin",
|
180 | "Slice",
|
181 | "Sort",
|
182 | "Splice",
|
183 | "Split",
|
184 | "Sqrt",
|
185 | "Stdev",
|
186 | "SubtypeCode",
|
187 | "SubtypeName",
|
188 | "Subtypes",
|
189 | "Sum",
|
190 | "SymmetricDifference",
|
191 | "Tan",
|
192 | "Text",
|
193 | "Timestamp",
|
194 | "ToCharCode",
|
195 | "ToCodePoint",
|
196 | "Today",
|
197 | "ToHex",
|
198 | "ToLocal",
|
199 | "Top|0",
|
200 | "Touches",
|
201 | "ToUTC",
|
202 | "TrackAccelerationAt",
|
203 | "TrackAccelerationWindow",
|
204 | "TrackCurrentAcceleration",
|
205 | "TrackCurrentDistance",
|
206 | "TrackCurrentSpeed",
|
207 | "TrackCurrentTime",
|
208 | "TrackDistanceAt",
|
209 | "TrackDistanceWindow",
|
210 | "TrackDuration",
|
211 | "TrackFieldWindow",
|
212 | "TrackGeometryWindow",
|
213 | "TrackIndex",
|
214 | "TrackSpeedAt",
|
215 | "TrackSpeedWindow",
|
216 | "TrackStartTime",
|
217 | "TrackWindow",
|
218 | "Trim",
|
219 | "TypeOf",
|
220 | "Union",
|
221 | "Upper",
|
222 | "UrlEncode",
|
223 | "Variance",
|
224 | "Week",
|
225 | "Weekday",
|
226 | "When",
|
227 | "Within",
|
228 | "Year"
|
229 | ]
|
230 | };
|
231 | const SYMBOL = {
|
232 | className: 'symbol',
|
233 | begin: '\\$[datastore|feature|layer|map|measure|sourcefeature|sourcelayer|targetfeature|targetlayer|value|view]+'
|
234 | };
|
235 | const NUMBER = {
|
236 | className: 'number',
|
237 | variants: [
|
238 | { begin: '\\b(0[bB][01]+)' },
|
239 | { begin: '\\b(0[oO][0-7]+)' },
|
240 | { begin: hljs.C_NUMBER_RE }
|
241 | ],
|
242 | relevance: 0
|
243 | };
|
244 | const SUBST = {
|
245 | className: 'subst',
|
246 | begin: '\\$\\{',
|
247 | end: '\\}',
|
248 | keywords: KEYWORDS,
|
249 | contains: []
|
250 | };
|
251 | const TEMPLATE_STRING = {
|
252 | className: 'string',
|
253 | begin: '`',
|
254 | end: '`',
|
255 | contains: [
|
256 | hljs.BACKSLASH_ESCAPE,
|
257 | SUBST
|
258 | ]
|
259 | };
|
260 | SUBST.contains = [
|
261 | hljs.APOS_STRING_MODE,
|
262 | hljs.QUOTE_STRING_MODE,
|
263 | TEMPLATE_STRING,
|
264 | NUMBER,
|
265 | hljs.REGEXP_MODE
|
266 | ];
|
267 | const PARAMS_CONTAINS = SUBST.contains.concat([
|
268 | hljs.C_BLOCK_COMMENT_MODE,
|
269 | hljs.C_LINE_COMMENT_MODE
|
270 | ]);
|
271 |
|
272 | return {
|
273 | name: 'ArcGIS Arcade',
|
274 | case_insensitive: true,
|
275 | keywords: KEYWORDS,
|
276 | contains: [
|
277 | hljs.APOS_STRING_MODE,
|
278 | hljs.QUOTE_STRING_MODE,
|
279 | TEMPLATE_STRING,
|
280 | hljs.C_LINE_COMMENT_MODE,
|
281 | hljs.C_BLOCK_COMMENT_MODE,
|
282 | SYMBOL,
|
283 | NUMBER,
|
284 | {
|
285 | begin: /[{,]\s*/,
|
286 | relevance: 0,
|
287 | contains: [
|
288 | {
|
289 | begin: IDENT_RE + '\\s*:',
|
290 | returnBegin: true,
|
291 | relevance: 0,
|
292 | contains: [
|
293 | {
|
294 | className: 'attr',
|
295 | begin: IDENT_RE,
|
296 | relevance: 0
|
297 | }
|
298 | ]
|
299 | }
|
300 | ]
|
301 | },
|
302 | {
|
303 | begin: '(' + hljs.RE_STARTERS_RE + '|\\b(return)\\b)\\s*',
|
304 | keywords: 'return',
|
305 | contains: [
|
306 | hljs.C_LINE_COMMENT_MODE,
|
307 | hljs.C_BLOCK_COMMENT_MODE,
|
308 | hljs.REGEXP_MODE,
|
309 | {
|
310 | className: 'function',
|
311 | begin: '(\\(.*?\\)|' + IDENT_RE + ')\\s*=>',
|
312 | returnBegin: true,
|
313 | end: '\\s*=>',
|
314 | contains: [
|
315 | {
|
316 | className: 'params',
|
317 | variants: [
|
318 | { begin: IDENT_RE },
|
319 | { begin: /\(\s*\)/ },
|
320 | {
|
321 | begin: /\(/,
|
322 | end: /\)/,
|
323 | excludeBegin: true,
|
324 | excludeEnd: true,
|
325 | keywords: KEYWORDS,
|
326 | contains: PARAMS_CONTAINS
|
327 | }
|
328 | ]
|
329 | }
|
330 | ]
|
331 | }
|
332 | ],
|
333 | relevance: 0
|
334 | },
|
335 | {
|
336 | beginKeywords: 'function',
|
337 | end: /\{/,
|
338 | excludeEnd: true,
|
339 | contains: [
|
340 | hljs.inherit(hljs.TITLE_MODE, {
|
341 | className: "title.function",
|
342 | begin: IDENT_RE
|
343 | }),
|
344 | {
|
345 | className: 'params',
|
346 | begin: /\(/,
|
347 | end: /\)/,
|
348 | excludeBegin: true,
|
349 | excludeEnd: true,
|
350 | contains: PARAMS_CONTAINS
|
351 | }
|
352 | ],
|
353 | illegal: /\[|%/
|
354 | },
|
355 | { begin: /\$[(.]/ }
|
356 | ],
|
357 | illegal: /#(?!!)/
|
358 | };
|
359 | }
|
360 |
|
361 | module.exports = arcade;
|