1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/highlight.js/lib/languages/arcade.js

166 lines
4.8 KiB
JavaScript
Raw Normal View History

2024-01-16 21:26:16 +08:00
/*
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 = {
2023-12-18 13:12:25 +08:00
keyword:
'if for while var new function do return void else break',
literal:
2024-01-16 21:26:16 +08:00
'BackSlash DoubleQuote false ForwardSlash Infinity NaN NewLine null PI SingleQuote Tab TextFormatting true undefined',
2023-12-18 13:12:25 +08:00
built_in:
2024-01-16 21:26:16 +08:00
'Abs Acos Angle Attachments Area AreaGeodetic Asin Atan Atan2 Average Bearing Boolean Buffer BufferGeodetic ' +
2023-12-18 13:12:25 +08:00
'Ceil Centroid Clip Console Constrain Contains Cos Count Crosses Cut Date DateAdd ' +
2024-01-16 21:26:16 +08:00
'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 ' +
2023-12-18 13:12:25 +08:00
'MultiPartToSinglePart Multipoint NextSequenceValue Now Number OrderBy Overlaps Point Polygon ' +
2024-01-16 21:26:16 +08:00
'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 ' +
2023-12-18 13:12:25 +08:00
'Weekday When Within Year '
};
2024-01-16 21:26:16 +08:00
const SYMBOL = {
2023-12-18 13:12:25 +08:00
className: 'symbol',
2024-01-16 21:26:16 +08:00
begin: '\\$[datastore|feature|layer|map|measure|sourcefeature|sourcelayer|targetfeature|targetlayer|value|view]+'
2023-12-18 13:12:25 +08:00
};
2024-01-16 21:26:16 +08:00
const NUMBER = {
2023-12-18 13:12:25 +08:00
className: 'number',
variants: [
2024-01-16 21:26:16 +08:00
{
begin: '\\b(0[bB][01]+)'
},
{
begin: '\\b(0[oO][0-7]+)'
},
{
begin: hljs.C_NUMBER_RE
}
2023-12-18 13:12:25 +08:00
],
relevance: 0
};
2024-01-16 21:26:16 +08:00
const SUBST = {
2023-12-18 13:12:25 +08:00
className: 'subst',
2024-01-16 21:26:16 +08:00
begin: '\\$\\{',
end: '\\}',
2023-12-18 13:12:25 +08:00
keywords: KEYWORDS,
2024-01-16 21:26:16 +08:00
contains: [] // defined later
2023-12-18 13:12:25 +08:00
};
2024-01-16 21:26:16 +08:00
const TEMPLATE_STRING = {
2023-12-18 13:12:25 +08:00
className: 'string',
2024-01-16 21:26:16 +08:00
begin: '`',
end: '`',
2023-12-18 13:12:25 +08:00
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
]
};
SUBST.contains = [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
TEMPLATE_STRING,
NUMBER,
hljs.REGEXP_MODE
];
2024-01-16 21:26:16 +08:00
const PARAMS_CONTAINS = SUBST.contains.concat([
2023-12-18 13:12:25 +08:00
hljs.C_BLOCK_COMMENT_MODE,
hljs.C_LINE_COMMENT_MODE
]);
return {
2024-01-16 21:26:16 +08:00
name: 'ArcGIS Arcade',
2023-12-18 13:12:25 +08:00
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
2024-01-16 21:26:16 +08:00
begin: /[{,]\s*/,
relevance: 0,
contains: [{
begin: IDENT_RE + '\\s*:',
returnBegin: true,
relevance: 0,
contains: [{
className: 'attr',
begin: IDENT_RE,
relevance: 0
}]
}]
2023-12-18 13:12:25 +08:00
},
{ // "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',
2024-01-16 21:26:16 +08:00
begin: '(\\(.*?\\)|' + IDENT_RE + ')\\s*=>',
returnBegin: true,
2023-12-18 13:12:25 +08:00
end: '\\s*=>',
2024-01-16 21:26:16 +08:00
contains: [{
className: 'params',
variants: [
{
begin: IDENT_RE
},
{
begin: /\(\s*\)/
},
{
begin: /\(/,
end: /\)/,
excludeBegin: true,
excludeEnd: true,
keywords: KEYWORDS,
contains: PARAMS_CONTAINS
}
]
}]
2023-12-18 13:12:25 +08:00
}
],
relevance: 0
},
{
className: 'function',
2024-01-16 21:26:16 +08:00
beginKeywords: 'function',
end: /\{/,
excludeEnd: true,
2023-12-18 13:12:25 +08:00
contains: [
2024-01-16 21:26:16 +08:00
hljs.inherit(hljs.TITLE_MODE, {
begin: IDENT_RE
}),
2023-12-18 13:12:25 +08:00
{
className: 'params',
2024-01-16 21:26:16 +08:00
begin: /\(/,
end: /\)/,
2023-12-18 13:12:25 +08:00
excludeBegin: true,
excludeEnd: true,
contains: PARAMS_CONTAINS
}
],
illegal: /\[|%/
},
{
begin: /\$[(.]/
}
],
illegal: /#(?!!)/
};
2024-01-16 21:26:16 +08:00
}
module.exports = arcade;