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
| /*
| Language: ArcGIS Arcade
| Category: scripting
| Author: John Foster <jfoster@esri.com>
| Website: https://developers.arcgis.com/arcade/
| Description: ArcGIS Arcade is an expression language used in many Esri ArcGIS products such as Pro, Online, Server, Runtime, JavaScript, and Python
| */
|
| /** @type LanguageFn */
| function arcade(hljs) {
| const IDENT_RE = '[A-Za-z_][0-9A-Za-z_]*';
| const KEYWORDS = {
| keyword:
| 'if for while var new function do return void else break',
| literal:
| 'BackSlash DoubleQuote false ForwardSlash Infinity NaN NewLine null PI SingleQuote Tab TextFormatting true undefined',
| built_in:
| 'Abs Acos Angle Attachments Area AreaGeodetic Asin Atan Atan2 Average Bearing Boolean Buffer BufferGeodetic ' +
| 'Ceil Centroid Clip Console Constrain Contains Cos Count Crosses Cut Date DateAdd ' +
| 'DateDiff Day Decode DefaultValue Dictionary Difference Disjoint Distance DistanceGeodetic Distinct ' +
| 'DomainCode DomainName Equals Exp Extent Feature FeatureSet FeatureSetByAssociation FeatureSetById FeatureSetByPortalItem ' +
| 'FeatureSetByRelationshipName FeatureSetByTitle FeatureSetByUrl Filter First Floor Geometry GroupBy Guid HasKey Hour IIf IndexOf ' +
| 'Intersection Intersects IsEmpty IsNan IsSelfIntersecting Length LengthGeodetic Log Max Mean Millisecond Min Minute Month ' +
| 'MultiPartToSinglePart Multipoint NextSequenceValue Now Number OrderBy Overlaps Point Polygon ' +
| 'Polyline Portal Pow Random Relate Reverse RingIsClockWise Round Second SetGeometry Sin Sort Sqrt Stdev Sum ' +
| 'SymmetricDifference Tan Text Timestamp Today ToLocal Top Touches ToUTC TrackCurrentTime ' +
| 'TrackGeometryWindow TrackIndex TrackStartTime TrackWindow TypeOf Union UrlEncode Variance ' +
| 'Weekday When Within Year '
| };
| const SYMBOL = {
| className: 'symbol',
| begin: '\\$[datastore|feature|layer|map|measure|sourcefeature|sourcelayer|targetfeature|targetlayer|value|view]+'
| };
| const NUMBER = {
| className: 'number',
| variants: [
| {
| begin: '\\b(0[bB][01]+)'
| },
| {
| begin: '\\b(0[oO][0-7]+)'
| },
| {
| begin: hljs.C_NUMBER_RE
| }
| ],
| relevance: 0
| };
| const SUBST = {
| className: 'subst',
| begin: '\\$\\{',
| end: '\\}',
| keywords: KEYWORDS,
| contains: [] // defined later
| };
| const TEMPLATE_STRING = {
| className: 'string',
| begin: '`',
| end: '`',
| contains: [
| hljs.BACKSLASH_ESCAPE,
| SUBST
| ]
| };
| SUBST.contains = [
| hljs.APOS_STRING_MODE,
| hljs.QUOTE_STRING_MODE,
| TEMPLATE_STRING,
| NUMBER,
| hljs.REGEXP_MODE
| ];
| const PARAMS_CONTAINS = SUBST.contains.concat([
| hljs.C_BLOCK_COMMENT_MODE,
| hljs.C_LINE_COMMENT_MODE
| ]);
|
| return {
| name: 'ArcGIS Arcade',
| keywords: KEYWORDS,
| contains: [
| hljs.APOS_STRING_MODE,
| hljs.QUOTE_STRING_MODE,
| TEMPLATE_STRING,
| hljs.C_LINE_COMMENT_MODE,
| hljs.C_BLOCK_COMMENT_MODE,
| SYMBOL,
| NUMBER,
| { // object attr container
| begin: /[{,]\s*/,
| relevance: 0,
| contains: [{
| begin: IDENT_RE + '\\s*:',
| returnBegin: true,
| relevance: 0,
| contains: [{
| className: 'attr',
| begin: IDENT_RE,
| relevance: 0
| }]
| }]
| },
| { // "value" container
| begin: '(' + hljs.RE_STARTERS_RE + '|\\b(return)\\b)\\s*',
| keywords: 'return',
| contains: [
| hljs.C_LINE_COMMENT_MODE,
| hljs.C_BLOCK_COMMENT_MODE,
| hljs.REGEXP_MODE,
| {
| className: 'function',
| begin: '(\\(.*?\\)|' + IDENT_RE + ')\\s*=>',
| returnBegin: true,
| end: '\\s*=>',
| contains: [{
| className: 'params',
| variants: [
| {
| begin: IDENT_RE
| },
| {
| begin: /\(\s*\)/
| },
| {
| begin: /\(/,
| end: /\)/,
| excludeBegin: true,
| excludeEnd: true,
| keywords: KEYWORDS,
| contains: PARAMS_CONTAINS
| }
| ]
| }]
| }
| ],
| relevance: 0
| },
| {
| className: 'function',
| beginKeywords: 'function',
| end: /\{/,
| excludeEnd: true,
| contains: [
| hljs.inherit(hljs.TITLE_MODE, {
| begin: IDENT_RE
| }),
| {
| className: 'params',
| begin: /\(/,
| end: /\)/,
| excludeBegin: true,
| excludeEnd: true,
| contains: PARAMS_CONTAINS
| }
| ],
| illegal: /\[|%/
| },
| {
| begin: /\$[(.]/
| }
| ],
| illegal: /#(?!!)/
| };
| }
|
| module.exports = arcade;
|
|