@arcgis/arcade-languageservice 4.28.0-beta.39 → 4.28.0-beta.40

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/LICENSE.md CHANGED
@@ -1,13 +1,13 @@
1
- # Licensing
2
-
3
- COPYRIGHT © 2023 Esri
4
-
5
- All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
6
-
7
- This material is licensed for use under the Esri Master License Agreement (MLA), and is bound by the terms of that agreement. You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.
8
-
9
- See use restrictions at http://www.esri.com/legal/pdfs/mla_e204_e300/english
10
-
11
- For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA
12
-
1
+ # Licensing
2
+
3
+ COPYRIGHT © 2023 Esri
4
+
5
+ All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
6
+
7
+ This material is licensed for use under the Esri Master License Agreement (MLA), and is bound by the terms of that agreement. You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.
8
+
9
+ See use restrictions at http://www.esri.com/legal/pdfs/mla_e204_e300/english
10
+
11
+ For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA
12
+
13
13
  email: contracts@esri.com
package/README.md CHANGED
@@ -1,21 +1,21 @@
1
- # @arcgis/arcade-languageservice (beta)
2
-
3
- This package is part of the [ArcGIS Maps SDK for JavaScript](https://developers.arcgis.com/javascript).
4
-
5
- It is not intended to be used directly, but rather used as a dependency by other packages in the SDK.
6
-
7
- No customer support provided.
8
-
9
- ## License
10
-
11
- COPYRIGHT © 2023 Esri
12
-
13
- All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
14
-
15
- This material is licensed for use under the Esri Master License Agreement (MLA), and is bound by the terms of that agreement. You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.
16
-
17
- See use restrictions at <http://www.esri.com/legal/pdfs/mla_e204_e300/english>
18
-
19
- For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA
20
-
21
- email: contracts@esri.com
1
+ # @arcgis/arcade-languageservice (beta)
2
+
3
+ This package is part of the [ArcGIS Maps SDK for JavaScript](https://developers.arcgis.com/javascript).
4
+
5
+ It is not intended to be used directly, but rather used as a dependency by other packages in the SDK.
6
+
7
+ No customer support provided.
8
+
9
+ ## License
10
+
11
+ COPYRIGHT © 2023 Esri
12
+
13
+ All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
14
+
15
+ This material is licensed for use under the Esri Master License Agreement (MLA), and is bound by the terms of that agreement. You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.
16
+
17
+ See use restrictions at <http://www.esri.com/legal/pdfs/mla_e204_e300/english>
18
+
19
+ For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA
20
+
21
+ email: contracts@esri.com
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arcgis/arcade-languageservice",
3
3
  "description": "Arcade Language Service",
4
- "version": "4.28.0-beta.39",
4
+ "version": "4.28.0-beta.40",
5
5
  "type": "module",
6
6
  "module": "dist/esm/index.js",
7
7
  "main": "dist/esm/index.js",
@@ -32,7 +32,7 @@
32
32
  "@arcgis/arcade-parser": "1.20.5",
33
33
  "@arcgis/arcade-sdk": "~1.24.0",
34
34
  "@arcgis/arcade-tests": "^1.20.0",
35
- "@arcgis/components-plugins": "4.28.0-beta.39",
35
+ "@arcgis/components-plugins": "4.28.0-beta.40",
36
36
  "@arcgis/eslint-config": "1.0.0",
37
37
  "@arcgis/typescript-config": "1.0.0",
38
38
  "@types/fs-extra": "^11.0.1",
@@ -52,5 +52,5 @@
52
52
  "tsup": "^7.2.0",
53
53
  "typescript": "4.9.5"
54
54
  },
55
- "gitHead": "a891f979920c10c3dbe7727af366067dce473d0f"
55
+ "gitHead": "6292afdce9a33b8f82cb540d94b2bacf9c085858"
56
56
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/services/api-context.ts","../../../arcade-parser/src/types.ts","../../../arcade-parser/src/comment-handler.ts","../../../arcade-parser/src/error-handler.ts","../../../arcade-parser/src/assert.ts","../../../arcade-parser/src/character.ts","../../../arcade-parser/src/scanner.ts","../../../arcade-parser/src/parser.ts","../../../arcade-parser/src/tokenizer.ts","../../../arcade-parser/src/index.ts","../../src/services/api-diagnostic.ts","../../src/services/languageKeywords.ts","../../src/services/arcade-api/arcade-api.ts","../../src/services/arcade-completetion/arcade-completion.ts","../../src/services/arcade-completetion/snippets.ts","../../src/services/arcade-completetion/utils.ts","../../src/services/utils.ts","../../src/services/arcade-formatting/utils.ts","../../src/services/arcade-formatting/options.ts","../../src/services/arcade-formatting/lines.ts","../../src/services/arcade-formatting/expression-printers.ts","../../src/services/arcade-formatting/statement-printers.ts","../../src/services/arcade-formatting/arcade-formatting.ts","../../src/services/arcade-validation/arcade-validation.ts","../../src/arcade-language-service.ts"],"sourcesContent":["import type {\n BundleType,\n ProfileId,\n SdkVariableType as ApiVariableType,\n SdkPredefinedProfile\n} from \"@arcgis/arcade-sdk\";\nimport type { FormattingOptions } from \"./arcade-formatting/options\";\nimport type { CompletionItem } from \"vscode-languageserver-types\";\n\nexport type { FormattingOptions, ProfileId, ApiVariableType, SdkPredefinedProfile };\n\n/**\n * The editor can be extended with custom snippets\n */\nexport interface ApiSnippet {\n /**\n * The label for the snippet. The editor will use it to offer the snippet based on the text typed in the editor.\n * It's recommended to keep it short and as close as possible to what the user may be looking for.\n * For example: 'polyline'\n */\n label: string;\n\n /**\n * A slightly longer description of what the snippet offers.\n */\n detail: string;\n\n /**\n * A string that should be inserted into the script when selecting\n * this snippet.\n *\n * The `insertText` is subject to interpretation by the editor.\n * Use this rules: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#snippet_syntax\n */\n insertText: string;\n}\n\n/**\n * Language service api options\n */\nexport interface ApiContext {\n /**\n * The profile (variables, additional api items, bundles, etc.)\n */\n profile?: ApiProfile;\n\n /**\n * The locale for the Api\n */\n locale?: string;\n\n /**\n * Options to control how the script should be formatted\n */\n formattingOptions?: FormattingOptions;\n\n /**\n * Allows to augment the arcade snippets with a collection of snippets\n */\n snippets?: ApiSnippet[];\n}\n\n/**\n * Language service profile\n */\nexport interface ApiProfile {\n /**\n * The wellknown profile id if applicable\n */\n id?: ProfileId;\n\n /**\n * The set of profile variables\n */\n variables: ApiVariable[];\n\n /**\n * The api version to use\n */\n apiVersion?: string;\n\n /**\n * The api bundles to use\n */\n bundles?: BundleType[];\n\n /**\n * A collection of api item names to hide.\n */\n hiddenApiItems?: Array<string>;\n}\n\n/**\n * The type for value variable.\n */\nexport type ApiValueVariableType = Exclude<ApiVariableType, \"dictionary\">;\n\ninterface ApiVariableBase {\n /**\n * Name of the variable\n */\n name: string;\n\n /**\n * Optional short description for the variable\n */\n description?: string;\n\n /**\n * Completion item for the variable, leveraged bu the editor\n */\n completion?: CompletionItem;\n}\n\n/**\n * Describes a dictionary type (feature, dictionary)\n */\nexport interface ApiDictionaryVariable extends ApiVariableBase {\n type: \"dictionary\";\n\n /**\n * Dictionary properties\n */\n properties: ApiVariable[];\n}\n\n/**\n * Describes a simple variable type (number, featureSet, etc.)\n */\nexport interface ApiValueVariable extends ApiVariableBase {\n type: ApiValueVariableType;\n}\n\n/**\n * The profile variable type\n */\nexport type ApiVariable = ApiDictionaryVariable | ApiValueVariable;\n\n/**\n * Helper function to test if a variable is a value variable\n */\nexport function isValueVariable(variable: ApiVariable | null | undefined): variable is ApiValueVariable {\n return !!variable && variable.type !== \"dictionary\";\n}\n\n/**\n * Helper function to test if a variable is a dictionary variable\n */\nexport function isDictionaryVariable(variable: ApiVariable | null | undefined): variable is ApiDictionaryVariable {\n return variable?.type === \"dictionary\";\n}\n","//#region Keywords\nexport enum Literals {\n False = \"false\",\n Null = \"null\",\n True = \"true\"\n}\n\nexport enum Keywords {\n Break = \"break\",\n Continue = \"continue\",\n Else = \"else\",\n For = \"for\",\n From = \"from\",\n Function = \"function\",\n If = \"if\",\n Import = \"import\",\n Export = \"export\",\n In = \"in\",\n Return = \"return\",\n Var = \"var\",\n While = \"while\"\n}\n//#endregion\n\n//#region Syntax\nexport const enum Syntax {\n AssignmentExpression = \"AssignmentExpression\",\n ArrayExpression = \"ArrayExpression\",\n BlockComment = \"BlockComment\",\n BlockStatement = \"BlockStatement\",\n BinaryExpression = \"BinaryExpression\",\n BreakStatement = \"BreakStatement\",\n CallExpression = \"CallExpression\",\n ContinueStatement = \"ContinueStatement\",\n EmptyStatement = \"EmptyStatement\",\n ExpressionStatement = \"ExpressionStatement\",\n ExportNamedDeclaration = \"ExportNamedDeclaration\",\n ExportSpecifier = \"ExportSpecifier\",\n ForStatement = \"ForStatement\",\n ForInStatement = \"ForInStatement\",\n FunctionDeclaration = \"FunctionDeclaration\",\n Identifier = \"Identifier\",\n IfStatement = \"IfStatement\",\n ImportDeclaration = \"ImportDeclaration\",\n ImportDefaultSpecifier = \"ImportDefaultSpecifier\",\n LineComment = \"LineComment\",\n Literal = \"Literal\",\n LogicalExpression = \"LogicalExpression\",\n MemberExpression = \"MemberExpression\",\n ObjectExpression = \"ObjectExpression\",\n Program = \"Program\",\n Property = \"Property\",\n ReturnStatement = \"ReturnStatement\",\n TemplateElement = \"TemplateElement\",\n TemplateLiteral = \"TemplateLiteral\",\n UnaryExpression = \"UnaryExpression\",\n UpdateExpression = \"UpdateExpression\",\n VariableDeclaration = \"VariableDeclaration\",\n VariableDeclarator = \"VariableDeclarator\",\n WhileStatement = \"WhileStatement\"\n}\n\nexport type NodeType = `${Syntax}`;\n//#endregion\n\n//#region Operators\nexport const UpdateOperators: ReadonlyArray<string> = [\"++\", \"--\"];\nexport type UpdateOperator = (typeof UpdateOperators)[number];\n\nexport const UnaryOperators: ReadonlyArray<string> = [\"-\", \"+\", \"!\", \"~\"];\nexport type UnaryOperator = (typeof UnaryOperators)[number];\n\nexport const AssignmentOperators: ReadonlyArray<string> = [\"=\", \"/=\", \"*=\", \"%=\", \"+=\", \"-=\"];\nexport type AssignmentOperator = (typeof AssignmentOperators)[number];\n\nexport const LogicalOperators: ReadonlyArray<string> = [\"||\", \"&&\"];\nexport type LogicalOperator = (typeof LogicalOperators)[number];\n\nexport const BinaryOperators: ReadonlyArray<string> = [\n \"|\",\n \"&\",\n \">>\",\n \"<<\",\n \">>>\",\n \"^\",\n \"==\",\n \"!=\",\n \"<\",\n \"<=\",\n \">\",\n \">=\",\n \"+\",\n \"-\",\n \"*\",\n \"/\",\n \"%\"\n];\nexport type BinaryOperator = (typeof BinaryOperators)[number];\n\nexport const OperatorPrecedence = {\n \"||\": 1,\n \"&&\": 2,\n \"|\": 3,\n \"^\": 4,\n \"&\": 5,\n \"==\": 6,\n \"!=\": 6,\n \"<\": 7,\n \">\": 7,\n \"<=\": 7,\n \">=\": 7,\n \"<<\": 8,\n \">>\": 8,\n \">>>\": 8,\n \"+\": 9,\n \"-\": 9,\n \"*\": 10,\n \"/\": 10,\n \"%\": 10\n} as const;\n//#endregion\n\n//#region Positioning\nexport interface Position {\n line: number; // 1-based\n column: number; // 0-based\n}\n\nexport interface SourceLocation {\n start: Position; // Inclusive\n end: Position; // Exclusive\n}\n\nexport interface Marker {\n index: number;\n line: number;\n column: number;\n}\n\nexport interface ItemLocation {\n loc: SourceLocation;\n range: [number, number]; // [inclusive, exclusive]\n}\n//#endregion\n\n//#region Scanner and Tokenizer\nexport const enum TokenType {\n Unknown = 0,\n BooleanLiteral = 1,\n EOF = 2,\n Identifier = 3,\n Keyword = 4,\n NullLiteral = 5,\n NumericLiteral = 6,\n Punctuator = 7,\n StringLiteral = 8,\n Template = 10\n}\n\nexport const TokenNames = [\n \"Unknown\",\n \"Boolean\",\n \"<end>\",\n \"Identifier\",\n \"Keyword\",\n \"Null\",\n \"Numeric\",\n \"Punctuator\",\n \"String\",\n \"RegularExpression\",\n \"Template\"\n] as const;\n\nexport type TokenName = (typeof TokenNames)[number];\n\nexport interface TokenizeOptions {\n tolerant?: boolean;\n range?: boolean;\n loc?: boolean;\n comment?: boolean;\n}\n\nexport interface Token extends ItemLocation {\n type: TokenName | Syntax.BlockComment | Syntax.LineComment;\n value: string;\n regex?: {\n pattern: string;\n flags: string;\n };\n}\n//#endregion\n\n//#region Errors\nexport interface ParseOptions {\n tolerant?: boolean;\n tokens?: boolean;\n comments?: boolean;\n}\n\nexport enum DiagnosticCodes {\n InvalidModuleUri = \"InvalidModuleUri\",\n ForInOfLoopInitializer = \"ForInOfLoopInitializer\",\n IdentiferExpected = \"IdentiferExpected\",\n InvalidEscapedReservedWord = \"InvalidEscapedReservedWord\",\n InvalidExpression = \"InvalidExpression\",\n InvalidFunctionIdentifier = \"InvalidFunctionIdentifier\",\n InvalidHexEscapeSequence = \"InvalidHexEscapeSequence\",\n InvalidLeftHandSideInAssignment = \"InvalidLeftHandSideInAssignment\",\n InvalidLeftHandSideInForIn = \"InvalidLeftHandSideInForIn\",\n InvalidTemplateHead = \"InvalidTemplateHead\",\n InvalidVariableAssignment = \"InvalidVariableAssignment\",\n KeyMustBeString = \"KeyMustBeString\",\n NoFunctionInsideBlock = \"NoFunctionInsideBlock\",\n NoFunctionInsideFunction = \"NoFunctionInsideFunction\",\n ModuleExportRootOnly = \"ModuleExportRootOnly\",\n ModuleImportRootOnly = \"ModuleImportRootOnly\",\n PunctuatorExpected = \"PunctuatorExpected\",\n TemplateOctalLiteral = \"TemplateOctalLiteral\",\n UnexpectedBoolean = \"UnexpectedBoolean\",\n UnexpectedEndOfScript = \"UnexpectedEndOfScript\",\n UnexpectedIdentifier = \"UnexpectedIdentifier\",\n UnexpectedKeyword = \"UnexpectedKeyword\",\n UnexpectedNull = \"UnexpectedNull\",\n UnexpectedNumber = \"UnexpectedNumber\",\n UnexpectedPunctuator = \"UnexpectedPunctuator\",\n UnexpectedString = \"UnexpectedString\",\n UnexpectedTemplate = \"UnexpectedTemplate\",\n UnexpectedToken = \"UnexpectedToken\"\n}\n\nexport const DiagnosticMessages: { [key in DiagnosticCodes]: string } = {\n [DiagnosticCodes.InvalidModuleUri]: \"Module uri must be a text literal.\",\n [DiagnosticCodes.ForInOfLoopInitializer]: \"for-in loop variable declaration may not have an initializer.\",\n [DiagnosticCodes.IdentiferExpected]: \"'${value}' is an invalid identifier.\",\n [DiagnosticCodes.InvalidEscapedReservedWord]: \"Keyword cannot contain escaped characters.\",\n [DiagnosticCodes.InvalidExpression]: \"Invalid expression.\",\n [DiagnosticCodes.InvalidFunctionIdentifier]: \"'${value}' is an invalid function identifier.\",\n [DiagnosticCodes.InvalidHexEscapeSequence]: \"Invalid hexadecimal escape sequence.\",\n [DiagnosticCodes.InvalidLeftHandSideInAssignment]: \"Invalid left-hand side in assignment.\",\n [DiagnosticCodes.InvalidLeftHandSideInForIn]: \"Invalid left-hand side in for-in.\",\n [DiagnosticCodes.InvalidTemplateHead]: \"Invalid template structure.\",\n [DiagnosticCodes.InvalidVariableAssignment]: \"Invalid variable assignment.\",\n [DiagnosticCodes.KeyMustBeString]: \"Object property keys must be a word starting with a letter.\",\n [DiagnosticCodes.NoFunctionInsideBlock]: \"Functions cannot be declared inside of code blocks.\",\n [DiagnosticCodes.NoFunctionInsideFunction]: \"Functions cannot be declared inside another function.\",\n [DiagnosticCodes.ModuleExportRootOnly]: \"Module exports cannot be declared inside of code blocks.\",\n [DiagnosticCodes.ModuleImportRootOnly]: \"Module import cannot be declared inside of code blocks.\",\n [DiagnosticCodes.PunctuatorExpected]: \"'${value}' expected.\",\n [DiagnosticCodes.TemplateOctalLiteral]: \"Octal literals are not allowed in template literals.\",\n [DiagnosticCodes.UnexpectedBoolean]: \"Unexpected boolean literal.\",\n [DiagnosticCodes.UnexpectedEndOfScript]: \"Unexpected end of Arcade expression.\",\n [DiagnosticCodes.UnexpectedIdentifier]: \"Unexpected identifier.\",\n [DiagnosticCodes.UnexpectedKeyword]: \"Unexpected keyword.\",\n [DiagnosticCodes.UnexpectedNull]: \"Unexpected null literal.\",\n [DiagnosticCodes.UnexpectedNumber]: \"Unexpected number.\",\n [DiagnosticCodes.UnexpectedPunctuator]: \"Unexpected ponctuator.\",\n [DiagnosticCodes.UnexpectedString]: \"Unexpected text literal.\",\n [DiagnosticCodes.UnexpectedTemplate]: \"Unexpected quasi '${value}'.\",\n [DiagnosticCodes.UnexpectedToken]: \"Unexpected token '${value}'.\"\n} as const;\n\nexport type DiagnosticData = Record<string, number | string>;\n\nexport interface DiagnosticApi {\n code: DiagnosticCodes;\n index: number;\n line: number;\n column: number;\n description?: string;\n len?: number;\n data?: DiagnosticData | null;\n}\n\nexport class Diagnostic extends Error implements DiagnosticApi {\n readonly declaredRootClass: string = \"esri.arcade.lib.diagnostic\";\n\n code: DiagnosticCodes;\n index: number;\n line: number;\n column: number;\n len: number;\n range: SourceLocation;\n description?: string;\n data?: DiagnosticData | null;\n\n constructor({ code, index, line, column, len = 0, description, data }: DiagnosticApi) {\n super(`${description ?? code}`);\n this.name = \"ParsingError\";\n this.code = code;\n this.index = index;\n this.line = line;\n this.column = column;\n this.len = len;\n this.data = data;\n this.description = description;\n this.range = {\n start: { line, column: column - 1 },\n end: { line, column: column + len }\n };\n // Only available on V8\n (Error as any).captureStackTrace?.(this, Diagnostic);\n }\n}\n//#endregion\n\n//#region Comment\nexport interface LineComment extends ItemLocation {\n readonly type: Syntax.LineComment;\n value: string;\n}\n\nexport interface BlockComment extends ItemLocation {\n readonly type: Syntax.BlockComment;\n value: string;\n}\n\nexport type Comment = LineComment | BlockComment;\n//#endregion\n\n//#region Parsing Delegate\nexport type Delegate = (node: Node) => void;\n//#endregion\n\n//#region AST Definitions\n\nexport type Declaration = ExportNamedDeclaration | FunctionDeclaration | ImportDeclaration | VariableDeclaration;\n\nexport type Statement =\n | BlockStatement\n | BreakStatement\n | ContinueStatement\n | Declaration\n | EmptyStatement\n | ExpressionStatement\n | ForInStatement\n | ForStatement\n | IfStatement\n | ReturnStatement\n | WhileStatement;\n\nexport type Expression =\n | ArrayExpression\n | AssignmentExpression\n | BinaryExpression\n | CallExpression\n | Identifier\n | Literal\n | LogicalExpression\n | MemberExpression\n | ObjectExpression\n | TemplateLiteral\n | UpdateExpression\n | UnaryExpression;\n\nexport type Node =\n | Program\n | Expression\n | Statement\n | Property\n | TemplateElement\n | VariableDeclarator\n | ImportDefaultSpecifier;\n\nexport type TreeItem = Node | Comment;\n\nexport interface NodeBase extends ItemLocation {\n type: NodeType;\n leadingComments?: Array<Comment>;\n trailingComments?: Array<Comment>;\n}\n\n//#region AST - Declarations\nexport interface ExportNamedDeclaration extends NodeBase {\n readonly type: Syntax.ExportNamedDeclaration;\n declaration: FunctionDeclaration | VariableDeclaration;\n specifiers: ExportSpecifier[];\n source: Literal | null;\n}\n\nexport interface ExportSpecifier extends NodeBase {\n type: Syntax.ExportSpecifier;\n exported: Identifier;\n local: Identifier;\n}\n\nexport interface FunctionDeclaration extends NodeBase {\n readonly type: Syntax.FunctionDeclaration;\n id: Identifier;\n params: Array<Identifier>;\n body: BlockStatement;\n}\n\nexport interface ImportDeclaration extends NodeBase {\n type: Syntax.ImportDeclaration;\n specifiers: ImportDefaultSpecifier[];\n source: Literal;\n}\n\nexport interface ImportDefaultSpecifier extends NodeBase {\n type: Syntax.ImportDefaultSpecifier;\n local: Identifier;\n}\n\nexport interface VariableDeclaration extends NodeBase {\n readonly type: Syntax.VariableDeclaration;\n declarations: Array<VariableDeclarator>;\n kind: string;\n}\n\nexport interface VariableDeclarator extends NodeBase {\n readonly type: Syntax.VariableDeclarator;\n id: Identifier;\n init: Expression | null;\n}\n//#endregion\n\n//#region AST - Statements\nexport interface BlockStatement extends NodeBase {\n readonly type: Syntax.BlockStatement;\n body: Array<Statement>;\n innerComments?: Array<Comment>;\n}\n\nexport interface BreakStatement extends NodeBase {\n readonly type: Syntax.BreakStatement;\n}\n\nexport interface ContinueStatement extends NodeBase {\n readonly type: Syntax.ContinueStatement;\n}\n\nexport interface EmptyStatement extends NodeBase {\n readonly type: Syntax.EmptyStatement;\n}\n\nexport interface ExpressionStatement extends NodeBase {\n readonly type: Syntax.ExpressionStatement;\n expression: Expression;\n}\n\nexport interface ForInStatement extends NodeBase {\n readonly type: Syntax.ForInStatement;\n left: Identifier | VariableDeclaration;\n right: Expression;\n body: Statement;\n}\n\nexport interface ForStatement extends NodeBase {\n readonly type: Syntax.ForStatement;\n init: Expression | VariableDeclaration | null;\n test: Expression | null;\n update: Expression | null;\n body: Statement;\n}\n\nexport interface WhileStatement extends NodeBase {\n readonly type: Syntax.WhileStatement;\n test: Expression | null;\n body: Statement;\n}\n\nexport interface IfStatement extends NodeBase {\n readonly type: Syntax.IfStatement;\n test: Exclude<Expression, AssignmentExpression | UpdateExpression>;\n consequent: Statement;\n alternate: Statement | null;\n}\n\nexport interface Program extends NodeBase {\n readonly type: Syntax.Program;\n body: Array<Statement>;\n comments?: Array<Comment>;\n tokens?: Array<Token>;\n errors?: Array<Error>;\n}\n\nexport interface ReturnStatement extends NodeBase {\n readonly type: Syntax.ReturnStatement;\n argument: Expression | null;\n}\n//#endregion\n\n//#region AST - Expressions\nexport interface ArrayExpression extends NodeBase {\n readonly type: Syntax.ArrayExpression;\n elements: Array<Expression | null>;\n}\n\nexport interface AssignmentExpression extends NodeBase {\n readonly type: Syntax.AssignmentExpression;\n operator: AssignmentOperator;\n left: Identifier | MemberExpression;\n right: Expression;\n}\n\nexport interface BinaryExpression extends NodeBase {\n readonly type: Syntax.BinaryExpression;\n operator: BinaryOperator;\n left: Expression;\n right: Expression;\n}\n\nexport interface CallExpression extends NodeBase {\n readonly type: Syntax.CallExpression;\n callee: Identifier | MemberExpression;\n arguments: Array<Expression>;\n}\n\nexport interface Identifier extends NodeBase {\n readonly type: Syntax.Identifier;\n name: string;\n}\n\nexport interface Literal extends NodeBase {\n readonly type: Syntax.Literal;\n isString: boolean;\n value: boolean | number | string | null;\n raw: string;\n}\n\nexport type LRLogicalExpression = Exclude<Expression, AssignmentExpression | UpdateExpression>;\nexport interface LogicalExpression extends NodeBase {\n readonly type: Syntax.LogicalExpression;\n operator: LogicalOperator;\n left: LRLogicalExpression;\n right: LRLogicalExpression;\n}\n\nexport interface ComputedMemberExpression extends NodeBase {\n readonly type: Syntax.MemberExpression;\n readonly computed: true;\n object: Expression;\n property: Expression;\n}\n\ninterface NonComputedMemberExpression extends NodeBase {\n readonly type: Syntax.MemberExpression;\n readonly computed: false;\n object: Expression;\n property: Identifier;\n}\n\nexport type MemberExpression = ComputedMemberExpression | NonComputedMemberExpression;\n\nexport interface ObjectExpression extends NodeBase {\n readonly type: Syntax.ObjectExpression;\n properties: Array<Property>;\n}\n\nexport interface Property extends NodeBase {\n readonly type: Syntax.Property;\n kind: \"init\";\n key: Identifier | Literal;\n value: Expression | null;\n shorthand: boolean;\n}\n\nexport interface TemplateElement extends NodeBase {\n readonly type: Syntax.TemplateElement;\n value: TemplateElementValue;\n tail?: boolean;\n}\n\ninterface TemplateElementValue {\n cooked?: string;\n raw: string;\n}\n\nexport interface TemplateLiteral extends NodeBase {\n readonly type: Syntax.TemplateLiteral;\n quasis: Array<TemplateElement>;\n expressions: Array<Expression>;\n}\n\nexport interface UnaryExpression extends NodeBase {\n readonly type: Syntax.UnaryExpression;\n readonly prefix: true;\n operator: UnaryOperator;\n argument: Expression;\n}\n\nexport interface UpdateExpression extends NodeBase {\n readonly type: Syntax.UpdateExpression;\n operator: UpdateOperator;\n argument: Identifier | MemberExpression | CallExpression;\n prefix: boolean;\n}\n//#endregion\n//#endregion\n\n//#region Validators\nexport function isProgram(item: TreeItem | null | undefined): item is Program {\n return item?.type === Syntax.Program;\n}\n\nexport function isStatement(item: TreeItem | null | undefined): item is Statement {\n switch (item?.type) {\n case Syntax.BlockStatement:\n case Syntax.BreakStatement:\n case Syntax.ContinueStatement:\n case Syntax.EmptyStatement:\n case Syntax.ExpressionStatement:\n case Syntax.ForInStatement:\n case Syntax.ForStatement:\n case Syntax.FunctionDeclaration:\n case Syntax.IfStatement:\n case Syntax.ReturnStatement:\n case Syntax.VariableDeclaration:\n return true;\n\n default:\n return false;\n }\n}\n\nexport function isBlockStatement(item: TreeItem | null | undefined): item is BlockStatement {\n return item?.type === Syntax.BlockStatement;\n}\n\nexport function isBlockComment(item: TreeItem | null | undefined): item is BlockComment {\n return item?.type === Syntax.BlockComment;\n}\n\nexport function isBreakStatement(item: TreeItem | null | undefined): item is BreakStatement {\n return item?.type === Syntax.BreakStatement;\n}\n\nexport function isContinueStatement(item: TreeItem | null | undefined): item is ContinueStatement {\n return item?.type === Syntax.ContinueStatement;\n}\n\nexport function isEmptyStatement(item: TreeItem | null | undefined): item is EmptyStatement {\n return item?.type === Syntax.EmptyStatement;\n}\n\nexport function isExpressionStatement(item: TreeItem | null | undefined): item is ExpressionStatement {\n return item?.type === Syntax.ExpressionStatement;\n}\n\nexport function isForInStatement(item: TreeItem | null | undefined): item is ForInStatement {\n return item?.type === Syntax.ForInStatement;\n}\n\nexport function isForStatement(item: TreeItem | null | undefined): item is ForStatement {\n return item?.type === Syntax.ForStatement;\n}\n\nexport function isFunctionDeclaration(item: TreeItem | null | undefined): item is FunctionDeclaration {\n return item?.type === Syntax.FunctionDeclaration;\n}\n\nexport function isIfStatement(item: TreeItem | null | undefined): item is IfStatement {\n return item?.type === Syntax.IfStatement;\n}\n\nexport function isReturnStatement(item: TreeItem | null | undefined): item is ReturnStatement {\n return item?.type === Syntax.ReturnStatement;\n}\n\nexport function isVariableDeclaration(item: TreeItem | null | undefined): item is VariableDeclaration {\n return item?.type === Syntax.VariableDeclaration;\n}\n\nexport function isExpression(item: TreeItem | null | undefined): item is Expression {\n switch (item?.type) {\n case Syntax.ArrayExpression:\n case Syntax.AssignmentExpression:\n case Syntax.BinaryExpression:\n case Syntax.CallExpression:\n case Syntax.Identifier:\n case Syntax.Literal:\n case Syntax.LogicalExpression:\n case Syntax.MemberExpression:\n case Syntax.ObjectExpression:\n case Syntax.TemplateLiteral:\n case Syntax.UpdateExpression:\n case Syntax.UnaryExpression:\n return true;\n\n default:\n return false;\n }\n}\n\nexport function isArrayExpression(item: TreeItem | null | undefined): item is ArrayExpression {\n return item?.type === Syntax.ArrayExpression;\n}\n\nexport function isAssignmentExpression(item: TreeItem | null | undefined): item is AssignmentExpression {\n return item?.type === Syntax.AssignmentExpression;\n}\n\nexport function isBinaryExpression(item: TreeItem | null | undefined): item is BinaryExpression {\n return item?.type === Syntax.BinaryExpression;\n}\n\nexport function isCallExpression(item: TreeItem | null | undefined): item is CallExpression {\n return item?.type === Syntax.CallExpression;\n}\n\nexport function isIdentifier(item: TreeItem | null | undefined): item is Identifier {\n return item?.type === Syntax.Identifier;\n}\n\nexport function isLiteral(item: TreeItem | null | undefined): item is Literal {\n return item?.type === Syntax.Literal;\n}\n\nexport function isLogicalExpression(item: TreeItem | null | undefined): item is LogicalExpression {\n return item?.type === Syntax.LogicalExpression;\n}\n\nexport function isObjectExpression(item: TreeItem | null | undefined): item is ObjectExpression {\n return item?.type === Syntax.ObjectExpression;\n}\n\nexport function isTemplateLiteral(item: TreeItem | null | undefined): item is TemplateLiteral {\n return item?.type === Syntax.TemplateLiteral;\n}\n\nexport function isMemberExpression(item: TreeItem | null | undefined): item is MemberExpression {\n return item?.type === Syntax.MemberExpression;\n}\n\nexport function isUnaryExpression(item: TreeItem | null | undefined): item is UnaryExpression {\n return item?.type === Syntax.UnaryExpression;\n}\n\nexport function isUpdateExpression(item: TreeItem | null | undefined): item is UpdateExpression {\n return item?.type === Syntax.UpdateExpression;\n}\n\nexport function isVariableDeclarator(item: TreeItem | null | undefined): item is VariableDeclarator {\n return item?.type === Syntax.VariableDeclarator;\n}\n\nexport function isProperty(item: TreeItem | null | undefined): item is Property {\n return item?.type === Syntax.Property;\n}\n\nexport function isTemplateElement(item: TreeItem | null | undefined): item is TemplateElement {\n return item?.type === Syntax.TemplateElement;\n}\n\n//#endregion\n","// esri.arcade.lib\nimport type { Comment, Node, ItemLocation } from \"./types\";\nimport { isBlockStatement, isVariableDeclarator, isBlockComment, isProgram } from \"./types\";\n\nfunction isTrailingCommentForNode(comment: Comment, node: Node): boolean {\n if (!node) {\n return false;\n }\n return node.loc.end.line === comment.loc.start.line && node.loc.end.column <= comment.loc.start.column;\n}\n\nfunction isInside(node: ItemLocation, other: ItemLocation): boolean {\n return node.range[0] >= other.range[0] && node.range[1] <= other.range[1];\n}\n\nexport class CommentHandler {\n comments: Comment[] = [];\n private _nodeStack: Node[] = [];\n private _newComments: Comment[] = [];\n\n private insertInnerComments(node: Node): void {\n // innnerComments for properties empty block\n // `function a() {/** comments **\\/}`\n if (!isBlockStatement(node) || node.body.length !== 0) {\n return;\n }\n\n const innerComments: Comment[] = [];\n for (let i = this._newComments.length - 1; i >= 0; --i) {\n const comment = this._newComments[i];\n if (node.range[1] >= comment.range[0]) {\n innerComments.unshift(comment);\n this._newComments.splice(i, 1);\n }\n }\n if (innerComments.length) {\n node.innerComments = innerComments;\n }\n }\n\n private attachTrailingComments(node: Node): void {\n if (!node) {\n return;\n }\n\n // Check if the new comments could:\n //\n // - be attached to the previous node in the stack first. In some cases, the comments are collected after\n // a statement.\n // For example:\n // for (\n // var i = 0; // Comment\n // i < 10; // Comment\n // i++ /* Comment */ // More comment\n // ) {}\n //\n // or\n //\n // if (true) {\n // i++;\n // // Comment\n // }\n const lastNode = this._nodeStack[this._nodeStack.length - 1];\n if (isBlockStatement(node) && isInside(lastNode, node)) {\n // Attach the new comments that are inside the block to the last node\n for (let i = this._newComments.length - 1; i >= 0; --i) {\n const comment = this._newComments[i];\n if (isInside(comment, node)) {\n lastNode.trailingComments = [...(lastNode.trailingComments ?? []), comment];\n this._newComments.splice(i, 1);\n }\n }\n }\n\n // Trailing comment must be on the same line as the target node.\n let trailingComments: Comment[] = [];\n if (this._newComments.length > 0) {\n for (let i = this._newComments.length - 1; i >= 0; --i) {\n const comment = this._newComments[i];\n if (isTrailingCommentForNode(comment, lastNode)) {\n lastNode.trailingComments = [...(lastNode.trailingComments ?? []), comment];\n this._newComments.splice(i, 1);\n } else if (isTrailingCommentForNode(comment, node)) {\n trailingComments.unshift(comment);\n this._newComments.splice(i, 1);\n }\n }\n }\n\n // Check if we should move trailing comments from enclosed nodes\n if (lastNode?.trailingComments) {\n const firstComment = lastNode.trailingComments[0];\n if (isTrailingCommentForNode(firstComment, node)) {\n trailingComments = [...trailingComments, ...lastNode.trailingComments];\n delete lastNode.trailingComments;\n }\n }\n\n if (trailingComments.length > 0) {\n node.trailingComments = trailingComments;\n }\n }\n\n private attachLeadingComments(node: Node): void {\n if (!node) {\n return;\n }\n\n // Check if the previous node is enclosed in this node\n let enclosedNode: Node | undefined;\n while (this._nodeStack.length > 0) {\n const lastNode = this._nodeStack[this._nodeStack.length - 1];\n if (node.range[0] <= lastNode.range[0]) {\n enclosedNode = lastNode;\n this._nodeStack.pop();\n continue;\n }\n break;\n }\n\n // Extract the leading comments from the previous node that can\n // be moved to the enclosing node\n const leadingComments: Comment[] = [];\n const trailingComments: Comment[] = [];\n if (enclosedNode != null) {\n if (!enclosedNode.leadingComments) {\n return;\n }\n\n for (let i = enclosedNode.leadingComments.length - 1; i >= 0; --i) {\n const comment = enclosedNode.leadingComments[i];\n\n if (node.range[0] >= comment.range[1]) {\n // The comment is before the node location. Remove it\n // from the previous node\n leadingComments.unshift(comment);\n enclosedNode.leadingComments.splice(i, 1);\n continue;\n }\n\n if (isVariableDeclarator(node) && !isBlockComment(comment)) {\n // Special case. We have a variable declarator. The enclosing nodes cannot\n // have line comment\n trailingComments.unshift(comment);\n enclosedNode.leadingComments.splice(i, 1);\n }\n }\n\n if (enclosedNode.leadingComments?.length === 0) {\n delete enclosedNode.leadingComments;\n }\n\n if (leadingComments.length) {\n node.leadingComments = leadingComments;\n }\n\n if (trailingComments.length) {\n node.trailingComments = [...trailingComments, ...(node.trailingComments ?? [])];\n }\n return;\n }\n\n // It's not and enclosed node.\n // Look at the collection of new comments and return the ones that\n // can be attached to the node\n for (let i = this._newComments.length - 1; i >= 0; --i) {\n const comment = this._newComments[i];\n if (node.range[0] >= comment.range[0]) {\n // The node location is after the comment. We can use it for this node\n leadingComments.unshift(comment);\n this._newComments.splice(i, 1);\n }\n }\n\n if (leadingComments.length) {\n node.leadingComments = leadingComments;\n }\n }\n\n attachComments(node: Node): void {\n if (isProgram(node) && node.body.length > 0) {\n // Attach the comments that inside the block to the last node inside the block\n const lastNode = this._nodeStack[this._nodeStack.length - 1];\n if (lastNode) {\n lastNode.trailingComments = [...(lastNode.trailingComments ?? []), ...this._newComments];\n this._newComments.length = 0;\n this._nodeStack.pop();\n return;\n }\n\n // Attach to the program what's left over\n node.trailingComments = [...this._newComments];\n this._newComments.length = 0;\n return;\n }\n\n // Try to attach the trailing comments first. We may attach to a previous node in the stack\n this.attachTrailingComments(node);\n\n // Try to attach the leading comments.\n this.attachLeadingComments(node);\n\n // If there is some left over then attach as inner comments\n // This is the case for empty blocks\n this.insertInnerComments(node);\n\n // Stack the node\n this._nodeStack.push(node);\n }\n\n collectComment(comment: Comment): void {\n this.comments.push(comment);\n this._newComments.push(comment);\n }\n}\n","// esri.arcade.lib\nimport type { DiagnosticData, DiagnosticApi, DiagnosticCodes } from \"./types\";\nimport { Diagnostic, DiagnosticMessages } from \"./types\";\n\nexport function formatErrorDescription(code: DiagnosticCodes, data?: DiagnosticData | null): string {\n const str = DiagnosticMessages[code];\n if (!data) {\n return str;\n }\n\n return str.replace(/\\${(.*?)}/g, (_, g) => data[g]?.toString() ?? \"\");\n}\nexport class ErrorHandler {\n readonly errors: Error[] = [];\n\n constructor(public tolerant = false) {}\n\n recordError(error: Error): void {\n this.errors.push(error);\n }\n\n tolerate(error: Error): void {\n if (this.tolerant) {\n this.recordError(error);\n } else {\n throw error;\n }\n }\n\n throwError(errorData: DiagnosticApi): never {\n errorData.description = errorData.description ?? formatErrorDescription(errorData.code, errorData.data);\n throw new Diagnostic(errorData);\n }\n\n tolerateError(errorData: DiagnosticApi): void | never {\n errorData.description = errorData.description ?? formatErrorDescription(errorData.code, errorData.data);\n const error = new Diagnostic(errorData);\n if (this.tolerant) {\n this.recordError(error);\n } else {\n throw error;\n }\n }\n}\n","// Ensure the condition is true, otherwise throw an error.\n// This is only to have a better contract semantic, i.e. another safety net\n// to catch a logic error. The condition shall be fulfilled in normal case.\n// Do NOT use this to enforce a certain condition on any user input.\n\nexport function assert(condition: boolean, message: string): void {\n if (!condition) {\n throw new Error(\"ASSERT: \" + message);\n }\n}\n","// See also tools/generate-unicode-regex.js.\nconst Regex = {\n // Unicode v12.1.0 NonAsciiIdentifierStart:\n NonAsciiIdentifierStart:\n /[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0560-\\u0588\\u05D0-\\u05EA\\u05EF-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u0860-\\u086A\\u08A0-\\u08B4\\u08B6-\\u08BD\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u09FC\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u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u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F5\\u13F8-\\u13FD\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1878\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1C80-\\u1C88\\u1C90-\\u1CBA\\u1CBD-\\u1CBF\\u1CE9-\\u1CEC\\u1CEE-\\u1CF3\\u1CF5\\u1CF6\\u1CFA\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2118-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309B-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312F\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FEF\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA7BF\\uA7C2-\\uA7C6\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA8FD\\uA8FE\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\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|\\uD807[\\uDC00-\\uDC08\\uDC0A-\\uDC2E\\uDC40\\uDC72-\\uDC8F\\uDD00-\\uDD06\\uDD08\\uDD09\\uDD0B-\\uDD30\\uDD46\\uDD60-\\uDD65\\uDD67\\uDD68\\uDD6A-\\uDD89\\uDD98\\uDEE0-\\uDEF2]|\\uD808[\\uDC00-\\uDF99]|\\uD809[\\uDC00-\\uDC6E\\uDC80-\\uDD43]|[\\uD80C\\uD81C-\\uD820\\uD840-\\uD868\\uD86A-\\uD86C\\uD86F-\\uD872\\uD874-\\uD879][\\uDC00-\\uDFFF]|\\uD80D[\\uDC00-\\uDC2E]|\\uD811[\\uDC00-\\uDE46]|\\uD81A[\\uDC00-\\uDE38\\uDE40-\\uDE5E\\uDED0-\\uDEED\\uDF00-\\uDF2F\\uDF40-\\uDF43\\uDF63-\\uDF77\\uDF7D-\\uDF8F]|\\uD81B[\\uDE40-\\uDE7F\\uDF00-\\uDF4A\\uDF50\\uDF93-\\uDF9F\\uDFE0\\uDFE1\\uDFE3]|\\uD821[\\uDC00-\\uDFF7]|\\uD822[\\uDC00-\\uDEF2]|\\uD82C[\\uDC00-\\uDD1E\\uDD50-\\uDD52\\uDD64-\\uDD67\\uDD70-\\uDEFB]|\\uD82F[\\uDC00-\\uDC6A\\uDC70-\\uDC7C\\uDC80-\\uDC88\\uDC90-\\uDC99]|\\uD835[\\uDC00-\\uDC54\\uDC56-\\uDC9C\\uDC9E\\uDC9F\\uDCA2\\uDCA5\\uDCA6\\uDCA9-\\uDCAC\\uDCAE-\\uDCB9\\uDCBB\\uDCBD-\\uDCC3\\uDCC5-\\uDD05\\uDD07-\\uDD0A\\uDD0D-\\uDD14\\uDD16-\\uDD1C\\uDD1E-\\uDD39\\uDD3B-\\uDD3E\\uDD40-\\uDD44\\uDD46\\uDD4A-\\uDD50\\uDD52-\\uDEA5\\uDEA8-\\uDEC0\\uDEC2-\\uDEDA\\uDEDC-\\uDEFA\\uDEFC-\\uDF14\\uDF16-\\uDF34\\uDF36-\\uDF4E\\uDF50-\\uDF6E\\uDF70-\\uDF88\\uDF8A-\\uDFA8\\uDFAA-\\uDFC2\\uDFC4-\\uDFCB]|\\uD838[\\uDD00-\\uDD2C\\uDD37-\\uDD3D\\uDD4E\\uDEC0-\\uDEEB]|\\uD83A[\\uDC00-\\uDCC4\\uDD00-\\uDD43\\uDD4B]|\\uD83B[\\uDE00-\\uDE03\\uDE05-\\uDE1F\\uDE21\\uDE22\\uDE24\\uDE27\\uDE29-\\uDE32\\uDE34-\\uDE37\\uDE39\\uDE3B\\uDE42\\uDE47\\uDE49\\uDE4B\\uDE4D-\\uDE4F\\uDE51\\uDE52\\uDE54\\uDE57\\uDE59\\uDE5B\\uDE5D\\uDE5F\\uDE61\\uDE62\\uDE64\\uDE67-\\uDE6A\\uDE6C-\\uDE72\\uDE74-\\uDE77\\uDE79-\\uDE7C\\uDE7E\\uDE80-\\uDE89\\uDE8B-\\uDE9B\\uDEA1-\\uDEA3\\uDEA5-\\uDEA9\\uDEAB-\\uDEBB]|\\uD869[\\uDC00-\\uDED6\\uDF00-\\uDFFF]|\\uD86D[\\uDC00-\\uDF34\\uDF40-\\uDFFF]|\\uD86E[\\uDC00-\\uDC1D\\uDC20-\\uDFFF]|\\uD873[\\uDC00-\\uDEA1\\uDEB0-\\uDFFF]|\\uD87A[\\uDC00-\\uDFE0]|\\uD87E[\\uDC00-\\uDE1D]/,\n\n // Unicode v12.1.0 NonAsciiIdentifierPart:\n NonAsciiIdentifierPart:\n // eslint-disable-next-line no-misleading-character-class\n /[\\xAA\\xB5\\xB7\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0560-\\u0588\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05EF-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u07FD\\u0800-\\u082D\\u0840-\\u085B\\u0860-\\u086A\\u08A0-\\u08B4\\u08B6-\\u08BD\\u08D3-\\u08E1\\u08E3-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u09FC\\u09FE\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0AF9-\\u0AFF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0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u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1369-\\u1371\\u1380-\\u138F\\u13A0-\\u13F5\\u13F8-\\u13FD\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1878\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19DA\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1C80-\\u1C88\\u1C90-\\u1CBA\\u1CBD-\\u1CBF\\u1CD0-\\u1CD2\\u1CD4-\\u1CFA\\u1D00-\\u1DF9\\u1DFB-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2118-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312F\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FEF\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA7BF\\uA7C2-\\uA7C6\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\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DC00-\\uDC06\\uDC08-\\uDC18\\uDC1B-\\uDC21\\uDC23\\uDC24\\uDC26-\\uDC2A\\uDD00-\\uDD2C\\uDD30-\\uDD3D\\uDD40-\\uDD49\\uDD4E\\uDEC0-\\uDEF9]|\\uD83A[\\uDC00-\\uDCC4\\uDCD0-\\uDCD6\\uDD00-\\uDD4B\\uDD50-\\uDD59]|\\uD83B[\\uDE00-\\uDE03\\uDE05-\\uDE1F\\uDE21\\uDE22\\uDE24\\uDE27\\uDE29-\\uDE32\\uDE34-\\uDE37\\uDE39\\uDE3B\\uDE42\\uDE47\\uDE49\\uDE4B\\uDE4D-\\uDE4F\\uDE51\\uDE52\\uDE54\\uDE57\\uDE59\\uDE5B\\uDE5D\\uDE5F\\uDE61\\uDE62\\uDE64\\uDE67-\\uDE6A\\uDE6C-\\uDE72\\uDE74-\\uDE77\\uDE79-\\uDE7C\\uDE7E\\uDE80-\\uDE89\\uDE8B-\\uDE9B\\uDEA1-\\uDEA3\\uDEA5-\\uDEA9\\uDEAB-\\uDEBB]|\\uD869[\\uDC00-\\uDED6\\uDF00-\\uDFFF]|\\uD86D[\\uDC00-\\uDF34\\uDF40-\\uDFFF]|\\uD86E[\\uDC00-\\uDC1D\\uDC20-\\uDFFF]|\\uD873[\\uDC00-\\uDEA1\\uDEB0-\\uDFFF]|\\uD87A[\\uDC00-\\uDFE0]|\\uD87E[\\uDC00-\\uDE1D]|\\uDB40[\\uDD00-\\uDDEF]/\n};\n\nexport const Character = {\n fromCodePoint(cp: number): string {\n return cp < 0x10000\n ? String.fromCharCode(cp)\n : String.fromCharCode(0xd800 + ((cp - 0x10000) >> 10)) + String.fromCharCode(0xdc00 + ((cp - 0x10000) & 1023));\n },\n\n // https://tc39.github.io/ecma262/#sec-white-space\n isWhiteSpace(cp: number): boolean {\n return (\n cp === 0x20 ||\n cp === 0x09 ||\n cp === 0x0b ||\n cp === 0x0c ||\n cp === 0xa0 ||\n (cp >= 0x1680 &&\n [\n 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200a, 0x202f,\n 0x205f, 0x3000, 0xfeff\n ].includes(cp))\n );\n },\n\n // https://tc39.github.io/ecma262/#sec-line-terminators\n\n isLineTerminator(cp: number): boolean {\n return cp === 0x0a || cp === 0x0d || cp === 0x2028 || cp === 0x2029;\n },\n\n // https://tc39.github.io/ecma262/#sec-names-and-keywords\n\n isIdentifierStart(cp: number): boolean {\n return (\n cp === 0x24 ||\n cp === 0x5f || // $ (dollar) and _ (underscore)\n (cp >= 0x41 && cp <= 0x5a) || // A..Z\n (cp >= 0x61 && cp <= 0x7a) || // a..z\n cp === 0x5c || // \\ (backslash)\n (cp >= 0x80 && Regex.NonAsciiIdentifierStart.test(Character.fromCodePoint(cp)))\n );\n },\n\n isIdentifierPart(cp: number): boolean {\n return (\n cp === 0x24 ||\n cp === 0x5f || // $ (dollar) and _ (underscore)\n (cp >= 0x41 && cp <= 0x5a) || // A..Z\n (cp >= 0x61 && cp <= 0x7a) || // a..z\n (cp >= 0x30 && cp <= 0x39) || // 0..9\n cp === 0x5c || // \\ (backslash)\n (cp >= 0x80 && Regex.NonAsciiIdentifierPart.test(Character.fromCodePoint(cp)))\n );\n },\n\n // https://tc39.github.io/ecma262/#sec-literals-numeric-literals\n\n isDecimalDigit(cp: number): boolean {\n return cp >= 0x30 && cp <= 0x39; // 0..9\n },\n\n isHexDigit(cp: number): boolean {\n return (\n (cp >= 0x30 && cp <= 0x39) || // 0..9\n (cp >= 0x41 && cp <= 0x46) || // A..F\n (cp >= 0x61 && cp <= 0x66)\n ); // a..f\n },\n\n isOctalDigit(cp: number): boolean {\n return cp >= 0x30 && cp <= 0x37; // 0..7\n }\n};\n","// esri.arcade.lib\nimport { assert } from \"./assert\";\nimport { Character } from \"./character\";\nimport type { ErrorHandler } from \"./error-handler\";\nimport { Keywords, Literals, SourceLocation } from \"./types\";\nimport {\n TokenType,\n DiagnosticCodes,\n UpdateOperators,\n UnaryOperators,\n LogicalOperators,\n AssignmentOperators,\n BinaryOperators\n} from \"./types\";\n\nfunction hexValue(ch: string): number {\n return \"0123456789abcdef\".indexOf(ch.toLowerCase());\n}\n\nfunction octalValue(ch: string): number {\n return \"01234567\".indexOf(ch);\n}\nexport interface ScannerComment {\n multiLine: boolean;\n start: number;\n end: number;\n range: [number, number];\n loc: SourceLocation;\n}\n\nexport interface RawTokenLocation {\n lineNumber: number;\n lineStart: number;\n start: number;\n end: number;\n}\n\nexport interface StringRawToken extends RawTokenLocation {\n type:\n | TokenType.BooleanLiteral\n | TokenType.EOF\n | TokenType.Identifier\n | TokenType.Keyword\n | TokenType.NullLiteral\n | TokenType.Punctuator\n | TokenType.StringLiteral;\n value: string;\n}\n\nexport interface NumericRawToken extends RawTokenLocation {\n type: TokenType.NumericLiteral;\n value: number;\n}\n\nexport interface TemplateRawToken extends RawTokenLocation {\n type: TokenType.Template;\n value: string;\n cooked?: string;\n head?: boolean;\n tail?: boolean;\n}\n\nexport type RawToken = StringRawToken | NumericRawToken | TemplateRawToken;\n\ninterface ScannerState {\n index: number;\n lineNumber: number;\n lineStart: number;\n curlyStack: string[];\n}\n\n// 0-index based Operators by tuple length\n// - Index 0 -> Punctuators with 1 character\n// - Index 1 -> Punctuators with 2 character\n// - Index 2 -> Punctuators with 3 character\nconst OperatorsByLength: [string[], string[], string[]] = [[], [], []];\n\nUpdateOperators.forEach((op) => OperatorsByLength[op.length - 1].push(op));\nUnaryOperators.forEach((op) => OperatorsByLength[op.length - 1].push(op));\nLogicalOperators.forEach((op) => OperatorsByLength[op.length - 1].push(op));\nAssignmentOperators.forEach((op) => OperatorsByLength[op.length - 1].push(op));\nBinaryOperators.forEach((op) => OperatorsByLength[op.length - 1].push(op));\n\nexport class Scanner {\n readonly source: string;\n readonly errorHandler: ErrorHandler;\n\n index: number;\n lineNumber: number;\n lineStart: number;\n curlyStack: string[];\n\n private readonly _length: number;\n\n constructor(code: string, handler: ErrorHandler) {\n this.source = code;\n this.errorHandler = handler;\n\n this._length = code.length;\n this.index = 0;\n this.lineNumber = 1;\n this.lineStart = 0;\n this.curlyStack = [];\n }\n\n saveState(): ScannerState {\n return {\n index: this.index,\n lineNumber: this.lineNumber,\n lineStart: this.lineStart,\n curlyStack: this.curlyStack.slice()\n };\n }\n\n restoreState(state: ScannerState): void {\n this.index = state.index;\n this.lineNumber = state.lineNumber;\n this.lineStart = state.lineStart;\n this.curlyStack = state.curlyStack;\n }\n\n eof(): boolean {\n return this.index >= this._length;\n }\n\n throwUnexpectedToken(code = DiagnosticCodes.UnexpectedToken): never {\n this.errorHandler.throwError({\n code,\n index: this.index,\n line: this.lineNumber,\n column: this.index - this.lineStart + 1,\n data: { value: this.source.charAt(this.index) }\n });\n }\n\n private tolerateUnexpectedToken(code = DiagnosticCodes.UnexpectedToken): void {\n this.errorHandler.tolerateError({\n code,\n index: this.index,\n line: this.lineNumber,\n column: this.index - this.lineStart + 1\n });\n }\n\n private skipSingleLineComment(offset: number): ScannerComment[] {\n const comments: ScannerComment[] = [];\n const start = this.index - offset;\n const loc: SourceLocation = {\n start: {\n line: this.lineNumber,\n column: this.index - this.lineStart - offset\n },\n end: { line: 0, column: 0 } // Fake for now\n };\n\n while (!this.eof()) {\n const ch = this.source.charCodeAt(this.index);\n ++this.index;\n if (Character.isLineTerminator(ch)) {\n if (loc) {\n loc.end = {\n line: this.lineNumber,\n column: this.index - this.lineStart - 1\n };\n const entry: ScannerComment = {\n multiLine: false,\n start: start + offset,\n end: this.index - 1,\n range: [start, this.index - 1],\n loc\n };\n comments.push(entry);\n }\n if (ch === 13 && this.source.charCodeAt(this.index) === 10) {\n ++this.index;\n }\n ++this.lineNumber;\n this.lineStart = this.index;\n return comments;\n }\n }\n\n if (loc) {\n loc.end = {\n line: this.lineNumber,\n column: this.index - this.lineStart\n };\n const entry: ScannerComment = {\n multiLine: false,\n start: start + offset,\n end: this.index,\n range: [start, this.index],\n loc\n };\n comments.push(entry);\n }\n\n return comments;\n }\n\n private skipMultiLineComment(): ScannerComment[] {\n const comments: ScannerComment[] = [];\n const start = this.index - 2;\n const loc = {\n start: {\n line: this.lineNumber,\n column: this.index - this.lineStart - 2\n },\n end: { line: 0, column: 0 } // Fake for now\n };\n\n while (!this.eof()) {\n const ch = this.source.charCodeAt(this.index);\n if (Character.isLineTerminator(ch)) {\n if (ch === 0x0d && this.source.charCodeAt(this.index + 1) === 0x0a) {\n ++this.index;\n }\n ++this.lineNumber;\n ++this.index;\n this.lineStart = this.index;\n } else if (ch === 0x2a) {\n // Block comment ends with '*/'.\n if (this.source.charCodeAt(this.index + 1) === 0x2f) {\n this.index += 2;\n if (loc) {\n loc.end = {\n line: this.lineNumber,\n column: this.index - this.lineStart\n };\n const entry: ScannerComment = {\n multiLine: true,\n start: start + 2,\n end: this.index - 2,\n range: [start, this.index],\n loc\n };\n comments.push(entry);\n }\n return comments;\n }\n ++this.index;\n } else {\n ++this.index;\n }\n }\n\n // Ran off the end of the file - the whole thing is a comment\n if (loc) {\n loc.end = {\n line: this.lineNumber,\n column: this.index - this.lineStart\n };\n const entry: ScannerComment = {\n multiLine: true,\n start: start + 2,\n end: this.index,\n range: [start, this.index],\n loc\n };\n comments.push(entry);\n }\n\n this.tolerateUnexpectedToken();\n return comments;\n }\n\n scanComments(): ScannerComment[] {\n let comments: ScannerComment[] = [];\n while (!this.eof()) {\n let ch = this.source.charCodeAt(this.index);\n\n if (Character.isWhiteSpace(ch)) {\n ++this.index;\n } else if (Character.isLineTerminator(ch)) {\n ++this.index;\n if (ch === 0x0d && this.source.charCodeAt(this.index) === 0x0a) {\n ++this.index;\n }\n ++this.lineNumber;\n this.lineStart = this.index;\n } else if (ch === 0x2f) {\n // U+002F is '/'\n ch = this.source.charCodeAt(this.index + 1);\n if (ch === 0x2f) {\n this.index += 2;\n const singleLineComments = this.skipSingleLineComment(2);\n comments = [...comments, ...singleLineComments];\n } else if (ch === 0x2a) {\n // U+002A is '*'\n this.index += 2;\n const multilineComments = this.skipMultiLineComment();\n comments = [...comments, ...multilineComments];\n } else {\n break;\n }\n } else {\n break;\n }\n }\n\n return comments;\n }\n\n private isKeyword(id: string): boolean {\n id = id.toLowerCase();\n switch (id.length) {\n case 2:\n return id === Keywords.If || id === Keywords.In;\n case 3:\n return id === Keywords.Var || id === Keywords.For;\n case 4:\n return id === Keywords.Else;\n case 5:\n return id === Keywords.Break || id === Keywords.While;\n case 6:\n return id === Keywords.Return || id === Keywords.Import || id === Keywords.Export;\n case 8:\n return id === Keywords.Function || id === Keywords.Continue;\n default:\n return false;\n }\n }\n\n private codePointAt(i: number): number {\n let cp = this.source.charCodeAt(i);\n\n if (cp >= 0xd800 && cp <= 0xdbff) {\n const second = this.source.charCodeAt(i + 1);\n if (second >= 0xdc00 && second <= 0xdfff) {\n const first = cp;\n cp = (first - 0xd800) * 0x400 + second - 0xdc00 + 0x10000;\n }\n }\n\n return cp;\n }\n\n private scanHexEscape(prefix: string): string | null {\n const len = prefix === \"u\" ? 4 : 2;\n let code = 0;\n\n for (let i = 0; i < len; ++i) {\n if (!this.eof() && Character.isHexDigit(this.source.charCodeAt(this.index))) {\n code = code * 16 + hexValue(this.source[this.index++]);\n } else {\n return null;\n }\n }\n return String.fromCharCode(code);\n }\n\n private scanUnicodeCodePointEscape(): string {\n let ch = this.source[this.index];\n let code = 0;\n\n // At least, one hex digit is required.\n if (ch === \"}\") {\n this.throwUnexpectedToken();\n }\n\n while (!this.eof()) {\n ch = this.source[this.index++];\n if (!Character.isHexDigit(ch.charCodeAt(0))) {\n break;\n }\n code = code * 16 + hexValue(ch);\n }\n\n if (code > 0x10ffff || ch !== \"}\") {\n this.throwUnexpectedToken();\n }\n\n return Character.fromCodePoint(code);\n }\n\n private getIdentifier(): string {\n const start = this.index++;\n while (!this.eof()) {\n const ch = this.source.charCodeAt(this.index);\n if (ch === 0x5c) {\n // Blackslash (U+005C) marks Unicode escape sequence.\n this.index = start;\n return this.getComplexIdentifier();\n }\n if (ch >= 0xd800 && ch < 0xdfff) {\n // Need to handle surrogate pairs.\n this.index = start;\n return this.getComplexIdentifier();\n }\n if (Character.isIdentifierPart(ch)) {\n ++this.index;\n } else {\n break;\n }\n }\n\n return this.source.slice(start, this.index);\n }\n\n private getComplexIdentifier(): string {\n let cp = this.codePointAt(this.index);\n let id = Character.fromCodePoint(cp);\n this.index += id.length;\n\n // '\\u' (U+005C, U+0075) denotes an escaped character.\n let ch: string | null;\n if (cp === 0x5c) {\n if (this.source.charCodeAt(this.index) !== 0x75) {\n this.throwUnexpectedToken();\n }\n ++this.index;\n if (this.source[this.index] === \"{\") {\n ++this.index;\n ch = this.scanUnicodeCodePointEscape();\n } else {\n ch = this.scanHexEscape(\"u\");\n if (ch === null || ch === \"\\\\\" || !Character.isIdentifierStart(ch.charCodeAt(0))) {\n this.throwUnexpectedToken();\n }\n }\n id = ch;\n }\n\n while (!this.eof()) {\n cp = this.codePointAt(this.index);\n if (!Character.isIdentifierPart(cp)) {\n break;\n }\n ch = Character.fromCodePoint(cp);\n id += ch;\n this.index += ch.length;\n\n // '\\u' (U+005C, U+0075) denotes an escaped character.\n if (cp === 0x5c) {\n id = id.substring(0, id.length - 1);\n if (this.source.charCodeAt(this.index) !== 0x75) {\n this.throwUnexpectedToken();\n }\n ++this.index;\n if (this.source[this.index] === \"{\") {\n ++this.index;\n ch = this.scanUnicodeCodePointEscape();\n } else {\n ch = this.scanHexEscape(\"u\");\n if (ch === null || ch === \"\\\\\" || !Character.isIdentifierPart(ch.charCodeAt(0))) {\n this.throwUnexpectedToken();\n }\n }\n id += ch;\n }\n }\n\n return id;\n }\n\n private octalToDecimal(ch: string): { code: number; octal: boolean } {\n // \\0 is not octal escape sequence\n let octal = ch !== \"0\";\n let code = octalValue(ch);\n\n if (!this.eof() && Character.isOctalDigit(this.source.charCodeAt(this.index))) {\n octal = true;\n code = code * 8 + octalValue(this.source[this.index++]);\n\n // 3 digits are only allowed when string starts\n // with 0, 1, 2, 3\n if (\"0123\".includes(ch) && !this.eof() && Character.isOctalDigit(this.source.charCodeAt(this.index))) {\n code = code * 8 + octalValue(this.source[this.index++]);\n }\n }\n\n return { code, octal };\n }\n\n // https://tc39.github.io/ecma262/#sec-names-and-keywords\n\n private scanIdentifier(): StringRawToken {\n let type: TokenType;\n const start = this.index;\n\n // Backslash (U+005C) starts an escaped character.\n const id = this.source.charCodeAt(start) === 0x5c ? this.getComplexIdentifier() : this.getIdentifier();\n\n // There is no keyword or literal with only one character.\n // Thus, it must be an identifier.\n if (id.length === 1) {\n type = TokenType.Identifier;\n } else if (this.isKeyword(id)) {\n type = TokenType.Keyword;\n } else if (id.toLowerCase() === Literals.Null) {\n type = TokenType.NullLiteral;\n } else if (id.toLowerCase() === Literals.True || id.toLowerCase() === Literals.False) {\n type = TokenType.BooleanLiteral;\n } else {\n type = TokenType.Identifier;\n }\n\n if (type !== TokenType.Identifier && start + id.length !== this.index) {\n const restore = this.index;\n this.index = start;\n this.tolerateUnexpectedToken(DiagnosticCodes.InvalidEscapedReservedWord);\n this.index = restore;\n }\n\n return {\n type,\n value: id,\n lineNumber: this.lineNumber,\n lineStart: this.lineStart,\n start,\n end: this.index\n };\n }\n\n // https://tc39.github.io/ecma262/#sec-punctuators\n\n private scanPunctuator(): StringRawToken {\n const start = this.index;\n\n // Check for most common single-character punctuators.\n // Then try the operators\n let str = this.source[this.index];\n switch (str) {\n case \"(\":\n case \"{\":\n if (str === \"{\") {\n this.curlyStack.push(\"{\");\n }\n ++this.index;\n break;\n\n case \".\":\n ++this.index;\n break;\n\n case \"}\":\n ++this.index;\n this.curlyStack.pop();\n break;\n case \")\":\n case \";\":\n case \",\":\n case \"[\":\n case \"]\":\n case \":\":\n case \"?\":\n case \"~\":\n ++this.index;\n break;\n\n default:\n // Operators. Go by length. Careful, the OperatorsByLength is zero based. Some funky math here.\n for (let characterLength = OperatorsByLength.length; characterLength > 0; characterLength--) {\n str = this.source.substring(this.index, this.index + characterLength);\n if (OperatorsByLength[characterLength - 1].includes(str)) {\n this.index += characterLength;\n break;\n }\n }\n }\n\n if (this.index === start) {\n this.throwUnexpectedToken();\n }\n\n return {\n type: TokenType.Punctuator,\n value: str,\n lineNumber: this.lineNumber,\n lineStart: this.lineStart,\n start,\n end: this.index\n };\n }\n\n // https://tc39.github.io/ecma262/#sec-literals-numeric-literals\n\n private scanHexLiteral(start: number): NumericRawToken {\n let num = \"\";\n\n while (!this.eof()) {\n if (!Character.isHexDigit(this.source.charCodeAt(this.index))) {\n break;\n }\n num += this.source[this.index++];\n }\n\n if (num.length === 0) {\n this.throwUnexpectedToken();\n }\n\n if (Character.isIdentifierStart(this.source.charCodeAt(this.index))) {\n this.throwUnexpectedToken();\n }\n\n return {\n type: TokenType.NumericLiteral,\n value: parseInt(\"0x\" + num, 16),\n lineNumber: this.lineNumber,\n lineStart: this.lineStart,\n start,\n end: this.index\n };\n }\n\n private scanBinaryLiteral(start: number): NumericRawToken {\n let num = \"\";\n\n while (!this.eof()) {\n const ch = this.source[this.index];\n if (ch !== \"0\" && ch !== \"1\") {\n break;\n }\n num += this.source[this.index++];\n }\n\n if (num.length === 0) {\n // only 0b or 0B\n this.throwUnexpectedToken();\n }\n\n if (!this.eof()) {\n const ch = this.source.charCodeAt(this.index);\n if (Character.isIdentifierStart(ch) || Character.isDecimalDigit(ch)) {\n this.throwUnexpectedToken();\n }\n }\n\n return {\n type: TokenType.NumericLiteral,\n value: parseInt(num, 2),\n lineNumber: this.lineNumber,\n lineStart: this.lineStart,\n start,\n end: this.index\n };\n }\n\n private scanOctalLiteral(prefix: string, start: number): NumericRawToken {\n let num = \"\";\n let octal = false;\n\n if (Character.isOctalDigit(prefix.charCodeAt(0))) {\n octal = true;\n num = \"0\" + this.source[this.index++];\n } else {\n ++this.index;\n }\n\n while (!this.eof()) {\n if (!Character.isOctalDigit(this.source.charCodeAt(this.index))) {\n break;\n }\n num += this.source[this.index++];\n }\n\n if (!octal && num.length === 0) {\n // only 0o or 0O\n this.throwUnexpectedToken();\n }\n\n if (\n Character.isIdentifierStart(this.source.charCodeAt(this.index)) ||\n Character.isDecimalDigit(this.source.charCodeAt(this.index))\n ) {\n this.throwUnexpectedToken();\n }\n\n return {\n type: TokenType.NumericLiteral,\n value: parseInt(num, 8),\n lineNumber: this.lineNumber,\n lineStart: this.lineStart,\n start,\n end: this.index\n };\n }\n\n private scanNumericLiteral(): NumericRawToken {\n const start = this.index;\n let ch = this.source[start];\n assert(\n Character.isDecimalDigit(ch.charCodeAt(0)) || ch === \".\",\n \"Numeric literal must start with a decimal digit or a decimal point\"\n );\n\n let num = \"\";\n if (ch !== \".\") {\n num = this.source[this.index++];\n ch = this.source[this.index];\n\n // Hex number starts with '0x'.\n // Octal number starts with '0'.\n // Octal number in ES6 starts with '0o'.\n // Binary number in ES6 starts with '0b'.\n if (num === \"0\") {\n if (ch === \"x\" || ch === \"X\") {\n ++this.index;\n return this.scanHexLiteral(start);\n }\n if (ch === \"b\" || ch === \"B\") {\n ++this.index;\n return this.scanBinaryLiteral(start);\n }\n if (ch === \"o\" || ch === \"O\") {\n return this.scanOctalLiteral(ch, start);\n }\n }\n\n while (Character.isDecimalDigit(this.source.charCodeAt(this.index))) {\n num += this.source[this.index++];\n }\n ch = this.source[this.index];\n }\n\n if (ch === \".\") {\n num += this.source[this.index++];\n while (Character.isDecimalDigit(this.source.charCodeAt(this.index))) {\n num += this.source[this.index++];\n }\n ch = this.source[this.index];\n }\n\n if (ch === \"e\" || ch === \"E\") {\n num += this.source[this.index++];\n\n ch = this.source[this.index];\n if (ch === \"+\" || ch === \"-\") {\n num += this.source[this.index++];\n }\n if (Character.isDecimalDigit(this.source.charCodeAt(this.index))) {\n while (Character.isDecimalDigit(this.source.charCodeAt(this.index))) {\n num += this.source[this.index++];\n }\n } else {\n this.throwUnexpectedToken();\n }\n }\n\n if (Character.isIdentifierStart(this.source.charCodeAt(this.index))) {\n this.throwUnexpectedToken();\n }\n\n return {\n type: TokenType.NumericLiteral,\n value: parseFloat(num),\n lineNumber: this.lineNumber,\n lineStart: this.lineStart,\n start,\n end: this.index\n };\n }\n\n private scanStringLiteral(): StringRawToken {\n const start = this.index;\n let quote = this.source[start];\n assert(quote === \"'\" || quote === '\"', \"String literal must starts with a quote\");\n\n ++this.index;\n let octal = false;\n let str = \"\";\n\n while (!this.eof()) {\n let ch = this.source[this.index++];\n\n if (ch === quote) {\n quote = \"\";\n break;\n }\n if (ch === \"\\\\\") {\n ch = this.source[this.index++];\n if (!ch || !Character.isLineTerminator(ch.charCodeAt(0))) {\n switch (ch) {\n case \"u\":\n if (this.source[this.index] === \"{\") {\n ++this.index;\n str += this.scanUnicodeCodePointEscape();\n } else {\n const unescapedChar = this.scanHexEscape(ch);\n if (unescapedChar === null) {\n this.throwUnexpectedToken();\n }\n str += unescapedChar;\n }\n break;\n case \"x\": {\n const unescaped = this.scanHexEscape(ch);\n if (unescaped === null) {\n this.throwUnexpectedToken(DiagnosticCodes.InvalidHexEscapeSequence);\n }\n str += unescaped;\n break;\n }\n case \"n\":\n str += \"\\n\";\n break;\n case \"r\":\n str += \"\\r\";\n break;\n case \"t\":\n str += \"\\t\";\n break;\n case \"b\":\n str += \"\\b\";\n break;\n case \"f\":\n str += \"\\f\";\n break;\n case \"v\":\n str += \"\\x0B\";\n break;\n case \"8\":\n case \"9\":\n str += ch;\n this.tolerateUnexpectedToken();\n break;\n\n default:\n if (ch && Character.isOctalDigit(ch.charCodeAt(0))) {\n const octToDec = this.octalToDecimal(ch);\n\n octal = octToDec.octal || octal;\n str += String.fromCharCode(octToDec.code);\n } else {\n str += ch;\n }\n break;\n }\n } else {\n ++this.lineNumber;\n if (ch === \"\\r\" && this.source[this.index] === \"\\n\") {\n ++this.index;\n }\n this.lineStart = this.index;\n }\n } else if (Character.isLineTerminator(ch.charCodeAt(0))) {\n break;\n } else {\n str += ch;\n }\n }\n\n if (quote !== \"\") {\n this.index = start;\n this.throwUnexpectedToken();\n }\n\n return {\n type: TokenType.StringLiteral,\n value: str,\n lineNumber: this.lineNumber,\n lineStart: this.lineStart,\n start,\n end: this.index\n };\n }\n\n private scanTemplate(): TemplateRawToken {\n let cooked = \"\";\n let terminated = false;\n const start = this.index;\n\n const head = this.source[start] === \"`\";\n let tail = false;\n let rawOffset = 2;\n\n ++this.index;\n\n while (!this.eof()) {\n let ch = this.source[this.index++];\n\n // End of the template\n if (ch === \"`\") {\n rawOffset = 1;\n tail = true;\n terminated = true;\n break;\n }\n\n // Potentially an expression or just the $ character\n if (ch === \"$\") {\n // Expression found\n if (this.source[this.index] === \"{\") {\n this.curlyStack.push(\"${\");\n ++this.index;\n terminated = true;\n break;\n }\n\n // Just the $ character, continue\n cooked += ch;\n continue;\n }\n\n // Escaping\n if (ch === \"\\\\\") {\n ch = this.source[this.index++];\n if (!Character.isLineTerminator(ch.charCodeAt(0))) {\n switch (ch) {\n case \"n\":\n cooked += \"\\n\";\n break;\n case \"r\":\n cooked += \"\\r\";\n break;\n case \"t\":\n cooked += \"\\t\";\n break;\n case \"u\":\n if (this.source[this.index] === \"{\") {\n ++this.index;\n cooked += this.scanUnicodeCodePointEscape();\n } else {\n const restore = this.index;\n const unescapedChar = this.scanHexEscape(ch);\n if (unescapedChar !== null) {\n cooked += unescapedChar;\n } else {\n this.index = restore;\n cooked += ch;\n }\n }\n break;\n case \"x\": {\n const unescaped = this.scanHexEscape(ch);\n if (unescaped === null) {\n this.throwUnexpectedToken(DiagnosticCodes.InvalidHexEscapeSequence);\n }\n cooked += unescaped;\n break;\n }\n case \"b\":\n cooked += \"\\b\";\n break;\n case \"f\":\n cooked += \"\\f\";\n break;\n case \"v\":\n cooked += \"\\v\";\n break;\n\n default:\n if (ch === \"0\") {\n if (Character.isDecimalDigit(this.source.charCodeAt(this.index))) {\n // Illegal: \\01 \\02 and so on\n this.throwUnexpectedToken(DiagnosticCodes.TemplateOctalLiteral);\n }\n cooked += \"\\0\";\n } else if (Character.isOctalDigit(ch.charCodeAt(0))) {\n // Illegal: \\1 \\2\n this.throwUnexpectedToken(DiagnosticCodes.TemplateOctalLiteral);\n } else {\n cooked += ch;\n }\n break;\n }\n } else {\n ++this.lineNumber;\n if (ch === \"\\r\" && this.source[this.index] === \"\\n\") {\n ++this.index;\n }\n this.lineStart = this.index;\n }\n continue;\n }\n\n // End of a line\n if (Character.isLineTerminator(ch.charCodeAt(0))) {\n ++this.lineNumber;\n if (ch === \"\\r\" && this.source[this.index] === \"\\n\") {\n ++this.index;\n }\n this.lineStart = this.index;\n cooked += \"\\n\";\n continue;\n }\n\n // Just a character\n cooked += ch;\n }\n\n if (!terminated) {\n this.throwUnexpectedToken();\n }\n\n if (!head) {\n this.curlyStack.pop();\n }\n\n return {\n type: TokenType.Template,\n value: this.source.slice(start + 1, this.index - rawOffset),\n cooked,\n head,\n tail,\n lineNumber: this.lineNumber,\n lineStart: this.lineStart,\n start,\n end: this.index\n };\n }\n\n lex(): RawToken {\n if (this.eof()) {\n return {\n type: TokenType.EOF,\n value: \"\",\n lineNumber: this.lineNumber,\n lineStart: this.lineStart,\n start: this.index,\n end: this.index\n };\n }\n\n const cp = this.source.charCodeAt(this.index);\n\n if (Character.isIdentifierStart(cp)) {\n return this.scanIdentifier();\n }\n\n // Very common: ( and ) and ;\n if (cp === 0x28 || cp === 0x29 || cp === 0x3b) {\n return this.scanPunctuator();\n }\n\n // String literal starts with single quote (U+0027) or double quote (U+0022).\n if (cp === 0x27 || cp === 0x22) {\n return this.scanStringLiteral();\n }\n\n // Dot (.) U+002E can also start a floating-point number, hence the need\n // to check the next character.\n if (cp === 0x2e) {\n if (Character.isDecimalDigit(this.source.charCodeAt(this.index + 1))) {\n return this.scanNumericLiteral();\n }\n return this.scanPunctuator();\n }\n\n if (Character.isDecimalDigit(cp)) {\n return this.scanNumericLiteral();\n }\n\n // Template literals start with ` (U+0060) for template head\n // or } (U+007D) for template middle or template tail.\n if (cp === 0x60 || (cp === 0x7d && this.curlyStack[this.curlyStack.length - 1] === \"${\")) {\n return this.scanTemplate();\n }\n\n // Possible identifier start in a surrogate pair.\n if (cp >= 0xd800 && cp < 0xdfff) {\n if (Character.isIdentifierStart(this.codePointAt(this.index))) {\n return this.scanIdentifier();\n }\n }\n\n return this.scanPunctuator();\n }\n}\n","// esri.arcade.lib\nimport { CommentHandler } from \"./comment-handler\";\nimport { ErrorHandler, formatErrorDescription } from \"./error-handler\";\nimport type { RawToken, ScannerComment } from \"./scanner\";\nimport { Scanner } from \"./scanner\";\nimport * as Types from \"./types\";\n\nenum BlockContext {\n None = 0,\n Function = 1 << 0,\n IfClause = 1 << 1,\n ForLoop = 1 << 2,\n WhileLoop = 1 << 3\n}\n\nenum CurlyParsingType {\n AsObject,\n Automatic\n}\n\ninterface Context {\n isAssignmentTarget: boolean;\n curlyParsingType: CurlyParsingType;\n blockContext: BlockContext;\n}\n\nfunction extractMarkerFromRawToken(rawToken: RawToken, lastLineStart = 0): Types.Marker {\n // Extract the marker from a token\n let column = rawToken.start - rawToken.lineStart;\n let line = rawToken.lineNumber;\n if (column < 0) {\n column += lastLineStart;\n line--;\n }\n return { index: rawToken.start, line, column };\n}\n\nfunction extractStartEndMarkersFromNode(node: Types.Node): [Types.Marker, Types.Marker] {\n return [\n { index: node.range[0], ...node.loc.start },\n { index: node.range[1], ...node.loc.end }\n ];\n}\n\nexport function binaryOperatorPrecedence(value: string): number {\n // @ts-expect-error\n return Types.OperatorPrecedence[value] ?? 0;\n}\n\n// Parsing process can be a bit confusing at first in the way it uses the scanner.\n// A first token is read from the scaner.\n// The parser will try to figure out what type of node to create.\n// For this it needs to drill down and read all the parts that composed a statement or an\n// expression. It does this by capturing scanner markers (line, column, index) at each step.\n// Then it will composed from inside out the various node using the correct end marker.\nexport class Parser {\n readonly options: Types.ParseOptions;\n readonly errorHandler: ErrorHandler;\n readonly commentHandler: CommentHandler | undefined;\n readonly scanner: Scanner;\n\n /**\n * Context used to control the parsing process\n */\n context: Context;\n\n /**\n * The collection of tokens read\n */\n tokens: Types.Token[];\n\n /**\n * The next raw token in the scanner.\n */\n rawToken: RawToken;\n\n /**\n * The marker that delimits the start location of the upcoming token (Inclusive)\n */\n startMarker: Types.Marker;\n\n /**\n * The marker that delimits the end location of the last read token (Exclusive).\n * It is used by the finilize function to create the node location.\n */\n endMarker: Types.Marker;\n\n hasLineTerminator = false;\n\n constructor(\n code: string,\n options: Types.ParseOptions = {},\n readonly delegate?: Types.Delegate\n ) {\n this.options = {\n tokens: typeof options.tokens === \"boolean\" && options.tokens,\n comments: typeof options.comments === \"boolean\" && options.comments,\n tolerant: typeof options.tolerant === \"boolean\" && options.tolerant\n };\n\n if (this.options.comments) {\n this.commentHandler = new CommentHandler();\n }\n\n this.errorHandler = new ErrorHandler(this.options.tolerant);\n this.scanner = new Scanner(code, this.errorHandler);\n\n this.context = {\n isAssignmentTarget: false,\n blockContext: BlockContext.None,\n curlyParsingType: CurlyParsingType.AsObject\n };\n\n // Bootstrap the scanner and the dependent objects\n this.rawToken = {\n type: Types.TokenType.EOF,\n value: \"\",\n lineNumber: this.scanner.lineNumber,\n lineStart: 0,\n start: 0,\n end: 0\n };\n this.tokens = [];\n this.startMarker = {\n index: 0,\n line: this.scanner.lineNumber,\n column: 0\n };\n this.endMarker = {\n index: 0,\n line: this.scanner.lineNumber,\n column: 0\n };\n this.readNextRawToken();\n this.endMarker = {\n index: this.scanner.index,\n line: this.scanner.lineNumber,\n column: this.scanner.index - this.scanner.lineStart\n };\n }\n\n throwIfInvalidType(\n node: Types.Expression,\n startMarker: Types.Marker,\n {\n validTypes,\n invalidTypes\n }: {\n validTypes?: Types.NodeType[];\n invalidTypes?: Types.NodeType[];\n }\n ): void | never {\n if (validTypes?.some((type) => node.type === type)) {\n return;\n }\n if (!invalidTypes?.some((type) => node.type === type)) {\n return;\n }\n\n this.throwError(Types.DiagnosticCodes.InvalidExpression, startMarker);\n }\n\n throwError(code: Types.DiagnosticCodes, startMarker: Types.Marker, endMarker = this.endMarker): never {\n const { index, line, column } = startMarker;\n const len = endMarker.index - index - 1;\n this.errorHandler.throwError({ code, index, line, column: column + 1, len });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n tolerateError(_code: Types.DiagnosticCodes, _startMarker: Types.Marker): void {\n throw new Error(\"######################################### !!!\");\n // const { index, line, column } = startMarker;\n // const len = this.endMarker.index - index;\n // this.errorHandler.tolerateError({ code, index, line, column: column + 1, len });\n }\n\n // Throw an exception because of the token.\n unexpectedTokenError(\n errorData: {\n rawToken?: RawToken;\n code?: Types.DiagnosticCodes;\n data?: Types.DiagnosticData;\n } = {}\n ): Types.Diagnostic {\n // If we have a token, we will use it for two purpose\n // - generate a code if not porvided based in the type of token\n // - extract the code data if not already provided\n const { rawToken } = errorData;\n let { code, data } = errorData;\n let value: string;\n if (rawToken) {\n if (!code) {\n switch (rawToken.type) {\n case Types.TokenType.EOF:\n code = Types.DiagnosticCodes.UnexpectedEndOfScript;\n break;\n case Types.TokenType.Identifier:\n code = Types.DiagnosticCodes.UnexpectedIdentifier;\n break;\n case Types.TokenType.NumericLiteral:\n code = Types.DiagnosticCodes.UnexpectedNumber;\n break;\n case Types.TokenType.StringLiteral:\n code = Types.DiagnosticCodes.UnexpectedString;\n break;\n case Types.TokenType.Template:\n code = Types.DiagnosticCodes.UnexpectedTemplate;\n break;\n }\n }\n value = rawToken.value.toString();\n } else {\n value = \"ILLEGAL\";\n }\n\n code = code ?? Types.DiagnosticCodes.UnexpectedToken;\n\n // If we don't have code data then default it\n if (!data) {\n data = { value };\n }\n\n // Manufacture the description\n const description = formatErrorDescription(code, data);\n\n // Use the token for position\n if (rawToken) {\n const index = rawToken.start;\n const line = rawToken.lineNumber;\n const column = rawToken.start - rawToken.lineStart + 1;\n // const currentEndMarkerLineStart = this.endMarker.index - this.endMarker.column;\n // const column = rawToken.start - currentEndMarkerLineStart + 1;\n return new Types.Diagnostic({\n code,\n index,\n line,\n column,\n len: rawToken.end - rawToken.start - 1,\n data,\n description\n });\n }\n\n const { index, line } = this.endMarker;\n return new Types.Diagnostic({ code, index, line, column: this.endMarker.column + 1, data, description });\n }\n\n throwUnexpectedToken(\n errorData: { rawToken?: RawToken; code?: Types.DiagnosticCodes; data?: Types.DiagnosticData } = {}\n ): never {\n errorData.rawToken = errorData.rawToken ?? this.rawToken;\n throw this.unexpectedTokenError(errorData);\n }\n\n collectComments(scannerComments: ScannerComment[]): void {\n const { commentHandler } = this;\n if (!commentHandler || !scannerComments.length) {\n return;\n }\n\n scannerComments.forEach((scannerComment) => {\n const comment: Types.Comment = {\n type: scannerComment.multiLine ? Types.Syntax.BlockComment : Types.Syntax.LineComment,\n value: this.getSourceValue(scannerComment),\n range: scannerComment.range,\n loc: scannerComment.loc\n };\n commentHandler.collectComment(comment);\n });\n }\n\n peekAhead<T>(callbackFn: (nextFn: () => RawToken) => T): T {\n const next = (): RawToken => {\n this.scanner.scanComments();\n return this.scanner.lex();\n };\n const state = this.scanner.saveState();\n const result = callbackFn.call(this, next);\n this.scanner.restoreState(state);\n return result;\n }\n\n getSourceValue(item: RawToken | ScannerComment): string {\n return this.scanner.source.slice(item.start, item.end);\n }\n\n convertToToken(rawToken: RawToken): Types.Token {\n return {\n type: Types.TokenNames[rawToken.type],\n value: this.getSourceValue(rawToken),\n range: [rawToken.start, rawToken.end],\n loc: {\n start: {\n line: this.startMarker.line,\n column: this.startMarker.column\n },\n end: {\n line: this.scanner.lineNumber,\n column: this.scanner.index - this.scanner.lineStart\n }\n }\n };\n }\n\n readNextRawToken(): void {\n // A parsing function will usually capture the start marker and then follow up with a readRawToken.\n // The property endMarker represents the marker that delimits the previous token. It has to be\n // used with the capture marker at a given point in time.\n // It can be confusing to compare endMarker and startMarker because a parsing function\n // capture the start marker at a given point in time and will call readRawToken to actually move the\n // endMarker to correct place. It means that the startMarker could be already pointing at the future.\n this.endMarker.index = this.scanner.index;\n this.endMarker.line = this.scanner.lineNumber;\n this.endMarker.column = this.scanner.index - this.scanner.lineStart;\n\n // Use the next token as the current token\n const rawToken = this.rawToken;\n\n // Scan for comments and collect them\n this.collectComments(this.scanner.scanComments());\n\n // If we moved then remember the new position\n if (this.scanner.index !== this.startMarker.index) {\n this.startMarker.index = this.scanner.index;\n this.startMarker.line = this.scanner.lineNumber;\n this.startMarker.column = this.scanner.index - this.scanner.lineStart;\n }\n\n // Scan for the next token\n this.rawToken = this.scanner.lex();\n\n // Check if we moved to a new line number\n this.hasLineTerminator = rawToken.lineNumber !== this.rawToken.lineNumber;\n\n // Store the token if requested\n if (this.options.tokens && this.rawToken.type !== Types.TokenType.EOF) {\n this.tokens.push(this.convertToToken(this.rawToken));\n }\n }\n\n captureStartMarker(): Types.Marker {\n // Capture the current start marker before reading more tokens\n return {\n index: this.startMarker.index,\n line: this.startMarker.line,\n column: this.startMarker.column\n };\n }\n\n getItemLocation(startMarker: Types.Marker): Types.ItemLocation {\n return {\n range: [startMarker.index, this.endMarker.index],\n loc: {\n start: {\n line: startMarker.line,\n column: startMarker.column\n },\n end: {\n line: this.endMarker.line,\n column: this.endMarker.column\n }\n }\n };\n }\n\n finalize<T extends Types.Node>(node: T): T {\n if (this.delegate || this.commentHandler) {\n this.commentHandler?.attachComments(node);\n this.delegate?.(node);\n }\n return node;\n }\n\n expectPunctuator(value: string): void | never {\n // Read the next token and expect it to match the specified punctuator.\n // If not, an exception will be thrown.\n const rawToken = this.rawToken;\n if (this.matchPunctuator(value)) {\n this.readNextRawToken();\n return;\n }\n\n this.throwUnexpectedToken({ rawToken, code: Types.DiagnosticCodes.PunctuatorExpected, data: { value } });\n }\n\n expectKeyword(keyword: Types.Keywords): void | never {\n // Analyze the token and expect it to be a keyword that match the specified keyword.\n // ARCADE Case Insensitive\n if (this.rawToken.type === Types.TokenType.Keyword && this.rawToken.value.toLowerCase() === keyword) {\n this.readNextRawToken();\n return;\n }\n\n this.throwUnexpectedToken({ rawToken: this.rawToken });\n }\n\n expectContextualKeyword(keyword: string): void | never {\n // Analyze the token and expect it to be an identifier that match the specified keyword.\n // ARCADE Case Insensitive\n if (this.rawToken.type === Types.TokenType.Identifier && this.rawToken.value.toLowerCase() === keyword) {\n this.readNextRawToken();\n return;\n }\n\n this.throwUnexpectedToken({ rawToken: this.rawToken });\n }\n\n matchKeyword(keyword: string): boolean {\n // Return true if the next token matches the specified keyword\n // ARCADE Case Insensitive\n return this.rawToken.type === Types.TokenType.Keyword && this.rawToken.value.toLowerCase() === keyword;\n }\n\n matchContextualKeyword(keyword: string): boolean {\n // Return true if the token matches the specified contextual keyword\n // (where an identifier is sometimes a keyword depending on the context)\n return this.rawToken.type === Types.TokenType.Identifier && this.rawToken.value === keyword;\n }\n\n matchPunctuator(value: string | undefined): boolean {\n // Return true if the token matches the specified punctuator.\n return this.rawToken.type === Types.TokenType.Punctuator && this.rawToken.value === value;\n }\n\n getMatchingPunctuator(punctuators: readonly string[] | string): string | undefined {\n if (typeof punctuators === \"string\") {\n punctuators = punctuators.split(\"\");\n }\n\n if (this.rawToken.type !== Types.TokenType.Punctuator || !punctuators?.length) {\n return;\n }\n\n return punctuators.find(this.matchPunctuator, this);\n }\n\n // Cover grammar support.\n //\n // When an assignment expression position starts with an left parenthesis, the determination of the type\n // of the syntax is to be deferred arbitrarily long until the end of the parentheses pair (plus a lookahead)\n // or the first comma. This situation also defers the determination of all the expressions nested in the pair.\n //\n // There are two productions that can be parsed in a parentheses pair that needs to be determined\n // after the outermost pair is closed. They are:\n //\n // 1. AssignmentExpression\n // 2. AssignmentTargets\n //\n // In order to avoid exponential backtracking, we use two flags to denote if the production can be\n // assignment target.\n //\n // The two productions have the relationship:\n //\n // AssignmentTargets ⊆ AssignmentExpression\n //\n // with a single exception that CoverInitializedName when used directly in an Expression, generates\n // an early error.\n //\n // isolateCoverGrammar function runs the given parser function with a new cover grammar context, and it does not\n // effect the current flags. This means the production the parser parses is only used as an expression. Therefore\n // the CoverInitializedName check is conducted.\n //\n // inheritCoverGrammar function runs the given parse function with a new cover grammar context, and it propagates\n // the flags outside of the parser. This means the production the parser parses is used as a part of a potential\n // pattern. The CoverInitializedName check is deferred.\n\n isolateCoverGrammar<T>(parseFunction: () => T): T | never {\n const previousIsAssignmentTarget = this.context.isAssignmentTarget;\n this.context.isAssignmentTarget = true;\n\n const result = parseFunction.call(this);\n\n this.context.isAssignmentTarget = previousIsAssignmentTarget;\n\n return result;\n }\n\n inheritCoverGrammar<T>(parseFunction: () => T): T {\n const previousIsAssignmentTarget = this.context.isAssignmentTarget;\n this.context.isAssignmentTarget = true;\n\n const result = parseFunction.call(this);\n\n this.context.isAssignmentTarget = this.context.isAssignmentTarget && previousIsAssignmentTarget;\n\n return result;\n }\n\n withBlockContext<T>(blockContext: BlockContext, parseFunction: () => T): T {\n const previousBlockContext = this.context.blockContext;\n this.context.blockContext = this.context.blockContext | blockContext;\n const previousCurlyParsing = this.context.curlyParsingType;\n this.context.curlyParsingType = CurlyParsingType.Automatic;\n const result = parseFunction.call(this);\n this.context.blockContext = previousBlockContext;\n this.context.curlyParsingType = previousCurlyParsing;\n return result;\n }\n\n consumeSemicolon(): void | never {\n if (this.matchPunctuator(\";\")) {\n this.readNextRawToken();\n return;\n }\n\n // Accept line return as semicolon\n if (this.hasLineTerminator) {\n return;\n }\n\n // Accept end of file and closing curly as semicolon\n if (this.rawToken.type === Types.TokenType.EOF || this.matchPunctuator(\"}\")) {\n // Adjust the marker\n this.endMarker.index = this.startMarker.index;\n this.endMarker.line = this.startMarker.line;\n this.endMarker.column = this.startMarker.column;\n return;\n }\n\n this.throwUnexpectedToken({ rawToken: this.rawToken });\n }\n\n parsePrimaryExpression(): Types.Expression | never {\n const startMarker = this.captureStartMarker();\n\n const rawToken = this.rawToken;\n switch (rawToken.type) {\n case Types.TokenType.Identifier:\n this.readNextRawToken();\n return this.finalize({\n type: Types.Syntax.Identifier,\n name: rawToken.value,\n ...this.getItemLocation(startMarker)\n });\n\n case Types.TokenType.NumericLiteral:\n case Types.TokenType.StringLiteral:\n this.context.isAssignmentTarget = false;\n this.readNextRawToken();\n return this.finalize({\n type: Types.Syntax.Literal,\n value: rawToken.value,\n raw: this.getSourceValue(rawToken),\n isString: typeof rawToken.value === \"string\",\n ...this.getItemLocation(startMarker)\n });\n\n case Types.TokenType.BooleanLiteral:\n this.context.isAssignmentTarget = false;\n this.readNextRawToken();\n // ARCADE Case Insensitive\n return this.finalize({\n type: Types.Syntax.Literal,\n value: rawToken.value.toLowerCase() === Types.Literals.True,\n raw: this.getSourceValue(rawToken),\n isString: false,\n ...this.getItemLocation(startMarker)\n });\n\n case Types.TokenType.NullLiteral:\n this.context.isAssignmentTarget = false;\n this.readNextRawToken();\n return this.finalize({\n type: Types.Syntax.Literal,\n value: null,\n raw: this.getSourceValue(rawToken),\n isString: false,\n ...this.getItemLocation(startMarker)\n });\n\n case Types.TokenType.Template:\n return this.parseTemplateLiteral();\n\n case Types.TokenType.Punctuator:\n switch (rawToken.value) {\n case \"(\":\n return this.inheritCoverGrammar(this.parseGroupExpression);\n\n case \"[\":\n return this.inheritCoverGrammar(this.parseArrayInitializer);\n\n case \"{\":\n return this.inheritCoverGrammar(this.parseObjectExpression);\n\n default:\n return this.throwUnexpectedToken({ rawToken: this.rawToken });\n }\n\n case Types.TokenType.Keyword:\n this.context.isAssignmentTarget = false;\n return this.throwUnexpectedToken({ rawToken: this.rawToken });\n\n default:\n return this.throwUnexpectedToken({ rawToken: this.rawToken });\n }\n }\n\n parseArrayInitializer(): Types.ArrayExpression {\n const startMarker = this.captureStartMarker();\n\n this.expectPunctuator(\"[\");\n const elements: (Types.Expression | null)[] = [];\n while (!this.matchPunctuator(\"]\")) {\n const elementMarker = this.captureStartMarker();\n if (this.matchPunctuator(\",\")) {\n this.readNextRawToken();\n this.throwError(Types.DiagnosticCodes.InvalidExpression, elementMarker);\n } else {\n elements.push(this.inheritCoverGrammar(this.parseAssignmentExpression));\n if (!this.matchPunctuator(\"]\")) {\n this.expectPunctuator(\",\");\n }\n }\n }\n this.expectPunctuator(\"]\");\n\n return this.finalize({ type: Types.Syntax.ArrayExpression, elements, ...this.getItemLocation(startMarker) });\n }\n\n parseObjectPropertyKey(): Types.Literal | Types.Identifier | never {\n const startMarker = this.captureStartMarker();\n\n const rawToken = this.rawToken;\n switch (rawToken.type) {\n case Types.TokenType.StringLiteral:\n this.readNextRawToken();\n return this.finalize({\n type: Types.Syntax.Literal,\n value: rawToken.value,\n raw: this.getSourceValue(rawToken),\n isString: true,\n ...this.getItemLocation(startMarker)\n });\n\n case Types.TokenType.Identifier:\n case Types.TokenType.BooleanLiteral:\n case Types.TokenType.NullLiteral:\n case Types.TokenType.Keyword:\n this.readNextRawToken();\n return this.finalize({\n type: Types.Syntax.Identifier,\n name: rawToken.value,\n ...this.getItemLocation(startMarker)\n });\n\n default:\n this.throwError(Types.DiagnosticCodes.KeyMustBeString, startMarker);\n }\n }\n\n parseObjectProperty(): Types.Property | never {\n const token = this.rawToken;\n const startMarker = this.captureStartMarker();\n\n const key = this.parseObjectPropertyKey();\n let shorthand = false;\n let value: Types.Expression | null = null;\n if (this.matchPunctuator(\":\")) {\n this.readNextRawToken();\n value = this.inheritCoverGrammar(this.parseAssignmentExpression);\n } else if (token.type === Types.TokenType.Identifier) {\n shorthand = true;\n value = this.finalize({ type: Types.Syntax.Identifier, name: token.value, ...this.getItemLocation(startMarker) });\n } else {\n this.throwUnexpectedToken({ rawToken: this.rawToken });\n }\n\n return this.finalize({\n type: Types.Syntax.Property,\n kind: \"init\",\n key,\n value,\n shorthand,\n ...this.getItemLocation(startMarker)\n });\n }\n\n parseObjectExpression(): Types.ObjectExpression {\n const startMarker = this.captureStartMarker();\n\n this.expectPunctuator(\"{\");\n const properties: Types.Property[] = [];\n while (!this.matchPunctuator(\"}\")) {\n properties.push(this.parseObjectProperty());\n if (!this.matchPunctuator(\"}\")) {\n this.expectPunctuator(\",\");\n }\n }\n this.expectPunctuator(\"}\");\n\n return this.finalize({ type: Types.Syntax.ObjectExpression, properties, ...this.getItemLocation(startMarker) });\n }\n\n parseTemplateElement(head = false): Types.TemplateElement | never {\n const rawToken = this.rawToken;\n if (rawToken.type !== Types.TokenType.Template) {\n this.throwUnexpectedToken({ rawToken });\n }\n\n if (head && !rawToken.head) {\n this.throwUnexpectedToken({ code: Types.DiagnosticCodes.InvalidTemplateHead, rawToken });\n }\n\n const startMarker = this.captureStartMarker();\n this.readNextRawToken();\n\n const { value: raw, cooked, tail } = rawToken;\n const node = this.finalize({\n type: Types.Syntax.TemplateElement,\n value: { raw, cooked },\n tail,\n ...this.getItemLocation(startMarker)\n });\n\n // Correct the node location to not include the back tick, ${, and }\n node.loc.start.column++; // ` or }\n node.loc.end.column = node.loc.end.column - (tail ? 1 : 2); // ` or ${\n\n return node;\n }\n\n parseTemplateLiteral(): Types.TemplateLiteral | never {\n const startMarker = this.captureStartMarker();\n\n const expressions: Types.Expression[] = [];\n const quasis: Types.TemplateElement[] = [];\n\n // Always have one quasi for empty template\n let quasi = this.parseTemplateElement(true);\n quasis.push(quasi);\n while (!quasi.tail) {\n expressions.push(this.parseExpression());\n quasi = this.parseTemplateElement();\n quasis.push(quasi);\n }\n\n return this.finalize({\n type: Types.Syntax.TemplateLiteral,\n quasis,\n expressions,\n ...this.getItemLocation(startMarker)\n });\n }\n\n parseGroupExpression(): Types.Expression {\n this.expectPunctuator(\"(\");\n const expr = this.inheritCoverGrammar(this.parseAssignmentExpression);\n this.expectPunctuator(\")\");\n return expr;\n }\n\n parseArguments(): Types.Expression[] {\n this.expectPunctuator(\"(\");\n const args: Types.Expression[] = [];\n if (!this.matchPunctuator(\")\")) {\n /* eslint-disable-next-line */\n while (true) {\n const expr = this.isolateCoverGrammar(this.parseAssignmentExpression);\n args.push(expr);\n if (this.matchPunctuator(\")\")) {\n break;\n }\n this.expectPunctuator(\",\");\n if (this.matchPunctuator(\")\")) {\n break;\n }\n }\n }\n this.expectPunctuator(\")\");\n\n return args;\n }\n\n parseMemberName(): Types.Identifier | never {\n const rawToken = this.rawToken;\n const startMarker = this.captureStartMarker();\n\n this.readNextRawToken();\n if (\n rawToken.type !== Types.TokenType.NullLiteral &&\n rawToken.type !== Types.TokenType.Identifier &&\n rawToken.type !== Types.TokenType.Keyword &&\n rawToken.type !== Types.TokenType.BooleanLiteral\n ) {\n this.throwUnexpectedToken({ rawToken });\n }\n\n return this.finalize({ type: Types.Syntax.Identifier, name: rawToken.value, ...this.getItemLocation(startMarker) });\n }\n\n parseLeftHandSideExpression(): Types.Expression {\n const startMarker = this.captureStartMarker();\n\n // Read the expression\n let expr = this.inheritCoverGrammar(this.parsePrimaryExpression);\n\n const endMarker = this.captureStartMarker();\n\n // Check if we have a function call or a member expression\n let punctuator: string | undefined;\n while ((punctuator = this.getMatchingPunctuator(\"([.\"))) {\n switch (punctuator) {\n case \"(\": {\n this.context.isAssignmentTarget = false;\n // Change to allow Module calling\n if (expr.type !== Types.Syntax.Identifier && expr.type !== Types.Syntax.MemberExpression) {\n this.throwError(Types.DiagnosticCodes.IdentiferExpected, startMarker, endMarker);\n }\n const args = this.parseArguments();\n expr = this.finalize({\n type: Types.Syntax.CallExpression,\n callee: expr,\n arguments: args,\n ...this.getItemLocation(startMarker)\n });\n continue;\n }\n\n case \"[\": {\n this.context.isAssignmentTarget = true;\n this.expectPunctuator(\"[\");\n const property = this.isolateCoverGrammar(this.parseExpression);\n this.expectPunctuator(\"]\");\n expr = this.finalize({\n type: Types.Syntax.MemberExpression,\n computed: true,\n object: expr,\n property,\n ...this.getItemLocation(startMarker)\n });\n continue;\n }\n\n case \".\": {\n this.context.isAssignmentTarget = true;\n this.expectPunctuator(\".\");\n const property = this.parseMemberName();\n expr = this.finalize({\n type: Types.Syntax.MemberExpression,\n computed: false,\n object: expr,\n property,\n ...this.getItemLocation(startMarker)\n });\n continue;\n }\n\n default:\n break;\n }\n }\n\n return expr;\n }\n\n parseUpdateExpression(): Types.Expression {\n const startMarker = this.captureStartMarker();\n\n // Prefixed Update Expression: ++expression --expression\n let operator = this.getMatchingPunctuator(Types.UpdateOperators);\n if (operator) {\n // Read the Right Hand Side Expression\n this.readNextRawToken();\n const argumentMarker = this.captureStartMarker();\n const argument = this.inheritCoverGrammar(this.parseUnaryExpression);\n\n // Only allow Call Expression to support Modules\n if (\n argument.type !== Types.Syntax.Identifier &&\n argument.type !== Types.Syntax.MemberExpression &&\n argument.type !== Types.Syntax.CallExpression\n ) {\n this.throwError(Types.DiagnosticCodes.InvalidExpression, argumentMarker);\n }\n\n if (!this.context.isAssignmentTarget) {\n this.tolerateError(Types.DiagnosticCodes.InvalidLeftHandSideInAssignment, startMarker);\n }\n\n this.context.isAssignmentTarget = false;\n return this.finalize({\n type: Types.Syntax.UpdateExpression,\n operator,\n argument,\n prefix: true,\n ...this.getItemLocation(startMarker)\n });\n }\n\n // Parse Left hand Side Expression\n const startExprMarker = this.captureStartMarker();\n const expr = this.inheritCoverGrammar(this.parseLeftHandSideExpression);\n const endExprMarker = this.captureStartMarker();\n\n // Nothing else\n if (this.hasLineTerminator) {\n return expr;\n }\n\n // Postfix Update Expression\n operator = this.getMatchingPunctuator(Types.UpdateOperators);\n if (!operator) {\n return expr;\n }\n\n if (expr.type !== Types.Syntax.Identifier && expr.type !== Types.Syntax.MemberExpression) {\n this.throwError(Types.DiagnosticCodes.InvalidExpression, startExprMarker, endExprMarker);\n }\n\n if (!this.context.isAssignmentTarget) {\n this.tolerateError(Types.DiagnosticCodes.InvalidLeftHandSideInAssignment, startMarker);\n }\n\n this.readNextRawToken();\n\n this.context.isAssignmentTarget = false;\n return this.finalize({\n type: Types.Syntax.UpdateExpression,\n operator,\n argument: expr,\n prefix: false,\n ...this.getItemLocation(startMarker)\n });\n }\n\n parseUnaryExpression(): Types.Expression {\n // Prefixed Unary Expression\n const operator = this.getMatchingPunctuator(Types.UnaryOperators);\n if (operator) {\n const startMarker = this.captureStartMarker();\n this.readNextRawToken();\n\n // Read the Right Hand Side Expression\n const argument = this.inheritCoverGrammar(this.parseUnaryExpression);\n\n this.context.isAssignmentTarget = false;\n return this.finalize({\n type: Types.Syntax.UnaryExpression,\n operator,\n argument,\n prefix: true,\n ...this.getItemLocation(startMarker)\n });\n }\n\n // Fallback to Update Expression\n return this.parseUpdateExpression();\n }\n\n parseBinaryExpression(): Types.Expression {\n const startRawToken = this.rawToken;\n\n // Parse the LHS Expression\n let expr = this.inheritCoverGrammar(this.parseUnaryExpression);\n\n // Things have moved, check if the next token is a punctuator\n if (this.rawToken.type !== Types.TokenType.Punctuator) {\n return expr;\n }\n\n // Check if the operator is a binary or logical operator and get its precedence;\n const operator = this.rawToken.value;\n let prec = binaryOperatorPrecedence(operator);\n if (prec === 0) {\n return expr;\n }\n\n // Move to the next token\n this.readNextRawToken();\n\n this.context.isAssignmentTarget = false;\n\n // Stack the start raw token and the current raw token\n const rawTokens = [startRawToken, this.rawToken];\n\n // Start with the LHS expression for the left\n let left: string | number | Types.Expression | undefined = expr;\n\n // Read the RHS\n let right: string | number | Types.Expression | undefined = this.inheritCoverGrammar(this.parseUnaryExpression);\n\n // Stack the structure [LHS, operator, RHS]\n const stack = [left, operator, right];\n const precedences: number[] = [prec];\n\n // Check if we have a new logical or binary operator as the current traw token\n while (\n this.rawToken.type === Types.TokenType.Punctuator &&\n (prec = binaryOperatorPrecedence(this.rawToken.value)) > 0\n ) {\n // Reduce: make a binary or logical expression from the three topmost entries.\n while (stack.length > 2 && prec <= precedences[precedences.length - 1]) {\n right = stack.pop() as Types.Expression;\n const operator = stack.pop() as string;\n precedences.pop();\n left = stack.pop() as Types.Expression;\n rawTokens.pop();\n const lastRawToken = rawTokens[rawTokens.length - 1];\n const marker = extractMarkerFromRawToken(lastRawToken, lastRawToken.lineStart);\n stack.push(this.finalize(this.createBinaryOrLogicalExpression(marker, operator, left, right)));\n }\n\n // Shift.\n stack.push(this.rawToken.value);\n precedences.push(prec);\n rawTokens.push(this.rawToken);\n this.readNextRawToken();\n stack.push(this.inheritCoverGrammar(this.parseUnaryExpression));\n }\n\n // Final reduce to clean-up the stack.\n let i = stack.length - 1;\n expr = stack[i] as Types.Expression;\n\n let lastRawToken = rawTokens.pop();\n while (i > 1) {\n const rawToken = rawTokens.pop();\n if (!rawToken) {\n break;\n }\n const lastLineStart = lastRawToken?.lineStart;\n const marker = extractMarkerFromRawToken(rawToken, lastLineStart);\n const operator = stack[i - 1] as string;\n expr = this.finalize(\n this.createBinaryOrLogicalExpression(marker, operator, stack[i - 2] as Types.Expression, expr)\n );\n i -= 2;\n lastRawToken = rawToken;\n }\n\n return expr;\n }\n\n createBinaryOrLogicalExpression(\n marker: Types.Marker,\n operator: Types.BinaryOperator | Types.LogicalOperator,\n left: Types.Expression,\n right: Types.Expression\n ): Types.BinaryExpression | Types.LogicalExpression {\n const type = Types.LogicalOperators.includes(operator)\n ? Types.Syntax.LogicalExpression\n : Types.Syntax.BinaryExpression;\n if (type === Types.Syntax.BinaryExpression) {\n return { type, operator, left, right, ...this.getItemLocation(marker) };\n }\n\n if (left.type === Types.Syntax.AssignmentExpression || left.type === Types.Syntax.UpdateExpression) {\n this.throwError(Types.DiagnosticCodes.InvalidExpression, ...extractStartEndMarkersFromNode(left));\n }\n\n if (right.type === Types.Syntax.AssignmentExpression || right.type === Types.Syntax.UpdateExpression) {\n this.throwError(Types.DiagnosticCodes.InvalidExpression, ...extractStartEndMarkersFromNode(left));\n }\n\n return { type, operator, left, right, ...this.getItemLocation(marker) };\n }\n\n parseAssignmentExpression(): Types.Expression {\n const startMarker = this.captureStartMarker();\n\n // Parse the LHS\n const left = this.inheritCoverGrammar(this.parseBinaryExpression);\n\n const endMarker = this.captureStartMarker();\n\n // If we have an assigment operator then return an assignement expression\n const operator = this.getMatchingPunctuator(Types.AssignmentOperators);\n if (!operator) {\n return left;\n }\n\n if (left.type !== Types.Syntax.Identifier && left.type !== Types.Syntax.MemberExpression) {\n this.throwError(Types.DiagnosticCodes.InvalidExpression, startMarker, endMarker);\n }\n\n if (!this.context.isAssignmentTarget) {\n this.tolerateError(Types.DiagnosticCodes.InvalidLeftHandSideInAssignment, startMarker);\n }\n\n if (!this.matchPunctuator(\"=\")) {\n this.context.isAssignmentTarget = false;\n }\n\n this.readNextRawToken();\n\n const right = this.isolateCoverGrammar(this.parseAssignmentExpression);\n\n return this.finalize({\n type: Types.Syntax.AssignmentExpression,\n left,\n operator,\n right,\n ...this.getItemLocation(startMarker)\n });\n }\n\n parseExpression(): Types.Expression {\n return this.isolateCoverGrammar(this.parseAssignmentExpression);\n }\n\n parseStatements(terminator?: string): Types.Statement[] {\n const statements: Types.Statement[] = [];\n while (this.rawToken.type !== Types.TokenType.EOF && !this.matchPunctuator(terminator)) {\n const statement = this.parseStatementListItem();\n if (Types.isEmptyStatement(statement)) {\n // Skip Empty Statement\n continue;\n }\n statements.push(statement);\n }\n return statements;\n }\n\n parseStatementListItem(): Types.Statement {\n this.context.isAssignmentTarget = true;\n if (this.matchKeyword(Types.Keywords.Function)) {\n return this.parseFunctionDeclaration();\n }\n if (this.matchKeyword(Types.Keywords.Export)) {\n return this.parseExportDeclaration();\n }\n if (this.matchKeyword(Types.Keywords.Import)) {\n return this.parseImportDeclaration();\n }\n return this.parseStatement();\n }\n\n parseBlock(): Types.BlockStatement {\n const startMarker = this.captureStartMarker();\n\n this.expectPunctuator(\"{\");\n const block: Types.Statement[] = this.parseStatements(\"}\");\n this.expectPunctuator(\"}\");\n\n return this.finalize({ type: Types.Syntax.BlockStatement, body: block, ...this.getItemLocation(startMarker) });\n }\n\n parseObjectStatement(): Types.ExpressionStatement {\n const startMarker = this.captureStartMarker();\n const expression = this.parseObjectExpression();\n return this.finalize({ type: Types.Syntax.ExpressionStatement, expression, ...this.getItemLocation(startMarker) });\n }\n\n parseBlockOrObjectStatement(): Types.BlockStatement | Types.ExpressionStatement {\n if (this.context.curlyParsingType === CurlyParsingType.AsObject) {\n return this.parseObjectStatement();\n }\n\n // Look ahead to determine if we could parse as an Object or we should parse as a Block\n const parseAsObject = this.peekAhead((nextToken: () => RawToken) => {\n // Try to see if the structure ahead looks like an object structure { i: 1 }\n let next = nextToken();\n if (next.type !== Types.TokenType.Identifier && next.type !== Types.TokenType.StringLiteral) {\n return false; // Parse as Block\n }\n next = nextToken();\n if (next.type !== Types.TokenType.Punctuator || next.value !== \":\") {\n return false; // Parse as Block\n }\n return true; // Parse as Object\n });\n\n if (parseAsObject) {\n return this.parseObjectStatement();\n }\n\n return this.parseBlock();\n }\n\n parseIdentifier(): Types.Identifier | null {\n const rawToken = this.rawToken;\n if (rawToken.type !== Types.TokenType.Identifier) {\n return null;\n }\n\n const startMarker = this.captureStartMarker();\n this.readNextRawToken();\n\n return this.finalize({ type: Types.Syntax.Identifier, name: rawToken.value, ...this.getItemLocation(startMarker) });\n }\n\n parseVariableDeclarator(): Types.VariableDeclarator | never {\n const startMarker = this.captureStartMarker();\n\n const id = this.parseIdentifier();\n if (!id) {\n this.throwUnexpectedToken({ code: Types.DiagnosticCodes.IdentiferExpected });\n }\n\n let init: Types.Expression | null = null;\n if (this.matchPunctuator(\"=\")) {\n this.readNextRawToken();\n const rawToken = this.rawToken;\n try {\n init = this.isolateCoverGrammar(this.parseAssignmentExpression);\n } catch (e) {\n this.throwUnexpectedToken({ rawToken, code: Types.DiagnosticCodes.InvalidVariableAssignment });\n }\n }\n\n return this.finalize({ type: Types.Syntax.VariableDeclarator, id, init, ...this.getItemLocation(startMarker) });\n }\n\n parseVariableDeclarationList(): Types.VariableDeclarator[] {\n const list = [this.parseVariableDeclarator()];\n while (this.matchPunctuator(\",\")) {\n this.readNextRawToken();\n list.push(this.parseVariableDeclarator());\n }\n return list;\n }\n\n parseVariableDeclaration(): Types.VariableDeclaration {\n const startMarker = this.captureStartMarker();\n\n this.expectKeyword(Types.Keywords.Var);\n const declarations = this.parseVariableDeclarationList();\n this.consumeSemicolon();\n\n return this.finalize({\n type: Types.Syntax.VariableDeclaration,\n declarations,\n kind: \"var\",\n ...this.getItemLocation(startMarker)\n });\n }\n\n parseEmptyStatement(): Types.EmptyStatement {\n const startMarker = this.captureStartMarker();\n this.expectPunctuator(\";\");\n return this.finalize({ type: Types.Syntax.EmptyStatement, ...this.getItemLocation(startMarker) });\n }\n\n parseExpressionStatement(): Types.ExpressionStatement {\n const startMarker = this.captureStartMarker();\n const expression = this.parseExpression();\n this.consumeSemicolon();\n return this.finalize({ type: Types.Syntax.ExpressionStatement, expression, ...this.getItemLocation(startMarker) });\n }\n\n parseIfClause(): Types.Statement {\n return this.withBlockContext(BlockContext.IfClause, this.parseStatement);\n }\n\n parseIfStatement(): Types.IfStatement {\n const startMarker = this.captureStartMarker();\n\n this.expectKeyword(Types.Keywords.If);\n\n this.expectPunctuator(\"(\");\n const startTestMarker = this.captureStartMarker();\n const test = this.parseExpression();\n const endTestMarker = this.captureStartMarker();\n this.expectPunctuator(\")\");\n\n if (test.type === Types.Syntax.AssignmentExpression || test.type === Types.Syntax.UpdateExpression) {\n this.throwError(Types.DiagnosticCodes.InvalidExpression, startTestMarker, endTestMarker);\n }\n\n const consequent = this.parseIfClause();\n\n let alternate: Types.Statement | null = null;\n if (this.matchKeyword(Types.Keywords.Else)) {\n this.readNextRawToken();\n alternate = this.parseIfClause();\n }\n\n return this.finalize({\n type: Types.Syntax.IfStatement,\n test,\n consequent,\n alternate,\n ...this.getItemLocation(startMarker)\n });\n }\n\n parseWhileStatement(): Types.WhileStatement {\n const startMarker = this.captureStartMarker();\n\n this.expectKeyword(Types.Keywords.While);\n\n this.expectPunctuator(\"(\");\n const startTestMarker = this.captureStartMarker();\n const test = this.parseExpression();\n const endTestMarker = this.captureStartMarker();\n this.expectPunctuator(\")\");\n\n if (test.type === Types.Syntax.AssignmentExpression || test.type === Types.Syntax.UpdateExpression) {\n this.throwError(Types.DiagnosticCodes.InvalidExpression, startTestMarker, endTestMarker);\n }\n\n const body = this.withBlockContext(BlockContext.WhileLoop, this.parseStatement);\n\n return this.finalize({\n type: Types.Syntax.WhileStatement,\n test,\n body,\n ...this.getItemLocation(startMarker)\n });\n }\n\n parseForStatement(): Types.ForStatement | Types.ForInStatement {\n let init: Types.Expression | Types.VariableDeclaration | null = null;\n let test: Types.Expression | null = null;\n let update: Types.Expression | null = null;\n let left: Types.Identifier | Types.VariableDeclaration | null = null;\n let right: Types.Expression | null = null;\n\n const startMarker = this.captureStartMarker();\n\n this.expectKeyword(Types.Keywords.For);\n this.expectPunctuator(\"(\");\n\n if (this.matchPunctuator(\";\")) {\n // Empty LHS\n this.readNextRawToken();\n } else {\n // Variable declaration or identifier?\n if (this.matchKeyword(Types.Keywords.Var)) {\n const initMarker = this.captureStartMarker();\n this.readNextRawToken();\n\n const declarations = this.parseVariableDeclarationList();\n if (declarations.length === 1 && this.matchKeyword(Types.Keywords.In)) {\n // For-in loop\n const decl = declarations[0];\n if (decl.init) {\n this.throwError(Types.DiagnosticCodes.ForInOfLoopInitializer, initMarker);\n }\n\n left = this.finalize({\n type: Types.Syntax.VariableDeclaration,\n declarations,\n kind: \"var\",\n ...this.getItemLocation(initMarker)\n });\n\n this.readNextRawToken();\n right = this.parseExpression();\n } else {\n // Classic for loop\n if (this.matchKeyword(Types.Keywords.In)) {\n this.throwError(Types.DiagnosticCodes.InvalidLeftHandSideInForIn, initMarker);\n }\n\n init = this.finalize({\n type: Types.Syntax.VariableDeclaration,\n declarations,\n kind: \"var\",\n ...this.getItemLocation(initMarker)\n });\n this.expectPunctuator(\";\");\n }\n } else {\n const previousIsAssignmentTarget = this.context.isAssignmentTarget;\n\n const initMarker = this.captureStartMarker();\n init = this.inheritCoverGrammar(this.parseAssignmentExpression);\n\n if (this.matchKeyword(Types.Keywords.In)) {\n // For-in loop\n if (!this.context.isAssignmentTarget) {\n this.tolerateError(Types.DiagnosticCodes.InvalidLeftHandSideInForIn, initMarker);\n }\n\n if (init.type !== Types.Syntax.Identifier) {\n this.throwError(Types.DiagnosticCodes.InvalidLeftHandSideInForIn, initMarker);\n }\n\n this.readNextRawToken();\n left = init;\n right = this.parseExpression();\n init = null;\n } else {\n // Classic for loop\n this.context.isAssignmentTarget = previousIsAssignmentTarget;\n this.expectPunctuator(\";\");\n }\n }\n }\n\n if (!left) {\n if (!this.matchPunctuator(\";\")) {\n test = this.isolateCoverGrammar(this.parseExpression);\n }\n this.expectPunctuator(\";\");\n if (!this.matchPunctuator(\")\")) {\n update = this.isolateCoverGrammar(this.parseExpression);\n }\n }\n\n this.expectPunctuator(\")\");\n\n const body = this.withBlockContext(BlockContext.ForLoop, () => this.isolateCoverGrammar(this.parseStatement));\n\n return left && right\n ? this.finalize({ type: Types.Syntax.ForInStatement, left, right, body, ...this.getItemLocation(startMarker) })\n : this.finalize({\n type: Types.Syntax.ForStatement,\n init,\n test,\n update,\n body,\n ...this.getItemLocation(startMarker)\n });\n }\n\n parseContinueStatement(): Types.ContinueStatement {\n const startMarker = this.captureStartMarker();\n\n this.expectKeyword(Types.Keywords.Continue);\n this.consumeSemicolon();\n\n return this.finalize({ type: Types.Syntax.ContinueStatement, ...this.getItemLocation(startMarker) });\n }\n\n parseBreakStatement(): Types.BreakStatement {\n const startMarker = this.captureStartMarker();\n\n this.expectKeyword(Types.Keywords.Break);\n this.consumeSemicolon();\n\n return this.finalize({ type: Types.Syntax.BreakStatement, ...this.getItemLocation(startMarker) });\n }\n\n parseReturnStatement(): Types.ReturnStatement {\n const startMarker = this.captureStartMarker();\n\n this.expectKeyword(Types.Keywords.Return);\n const hasArgument =\n (!this.matchPunctuator(\";\") &&\n !this.matchPunctuator(\"}\") &&\n !this.hasLineTerminator &&\n this.rawToken.type !== Types.TokenType.EOF) ||\n this.rawToken.type === Types.TokenType.StringLiteral ||\n this.rawToken.type === Types.TokenType.Template;\n\n const argument = hasArgument ? this.parseExpression() : null;\n this.consumeSemicolon();\n\n return this.finalize({ type: Types.Syntax.ReturnStatement, argument, ...this.getItemLocation(startMarker) });\n }\n\n parseStatement(): Types.Statement | never {\n switch (this.rawToken.type) {\n case Types.TokenType.BooleanLiteral:\n case Types.TokenType.NullLiteral:\n case Types.TokenType.NumericLiteral:\n case Types.TokenType.StringLiteral:\n case Types.TokenType.Template:\n case Types.TokenType.Identifier:\n return this.parseExpressionStatement();\n\n case Types.TokenType.Punctuator:\n if (this.rawToken.value === \"{\") {\n // CHANGED TO SUPPORT ORIGINAL ARCADE\n // ALLOWING IF (0==0) {x:0} else {x:1}\n return this.parseBlockOrObjectStatement();\n }\n if (this.rawToken.value === \"(\") {\n return this.parseExpressionStatement();\n }\n if (this.rawToken.value === \";\") {\n return this.parseEmptyStatement();\n }\n return this.parseExpressionStatement();\n\n case Types.TokenType.Keyword:\n switch (this.rawToken.value.toLowerCase()) {\n case Types.Keywords.Break:\n return this.parseBreakStatement();\n case Types.Keywords.Continue:\n return this.parseContinueStatement();\n case Types.Keywords.For:\n return this.parseForStatement();\n case Types.Keywords.Function:\n return this.parseFunctionDeclaration();\n case Types.Keywords.If:\n return this.parseIfStatement();\n case Types.Keywords.Return:\n return this.parseReturnStatement();\n case Types.Keywords.Var:\n return this.parseVariableDeclaration();\n case Types.Keywords.While:\n return this.parseWhileStatement();\n default:\n return this.parseExpressionStatement();\n }\n\n default:\n return this.throwUnexpectedToken({ rawToken: this.rawToken });\n }\n }\n\n parseFormalParameters(): Types.Identifier[] | never {\n const params: Types.Identifier[] = [];\n\n this.expectPunctuator(\"(\");\n if (!this.matchPunctuator(\")\")) {\n while (this.rawToken.type !== Types.TokenType.EOF) {\n const id = this.parseIdentifier();\n if (!id) {\n this.throwUnexpectedToken({ rawToken: this.rawToken, code: Types.DiagnosticCodes.IdentiferExpected });\n }\n params.push(id);\n if (this.matchPunctuator(\")\")) {\n break;\n }\n this.expectPunctuator(\",\");\n if (this.matchPunctuator(\")\")) {\n break;\n }\n }\n }\n this.expectPunctuator(\")\");\n\n return params;\n }\n\n parseFunctionDeclaration(): Types.FunctionDeclaration | never {\n if ((this.context.blockContext & BlockContext.Function) === BlockContext.Function) {\n this.throwUnexpectedToken({ code: Types.DiagnosticCodes.NoFunctionInsideFunction });\n }\n if (\n (this.context.blockContext & BlockContext.WhileLoop) === BlockContext.WhileLoop ||\n (this.context.blockContext & BlockContext.IfClause) === BlockContext.IfClause\n ) {\n // Cannot change legacy support inside of for loops\n // But can block while loops as new structure\n this.throwUnexpectedToken({ code: Types.DiagnosticCodes.NoFunctionInsideBlock });\n }\n\n const startMarker = this.captureStartMarker();\n\n this.expectKeyword(Types.Keywords.Function);\n\n const id = this.parseIdentifier();\n if (!id) {\n this.throwUnexpectedToken({ code: Types.DiagnosticCodes.InvalidFunctionIdentifier });\n }\n\n const params = this.parseFormalParameters();\n\n const previousContainerType = this.context.blockContext;\n this.context.blockContext = this.context.blockContext | BlockContext.Function;\n const body = this.parseBlock();\n this.context.blockContext = previousContainerType;\n\n return this.finalize({\n type: Types.Syntax.FunctionDeclaration,\n id,\n params,\n body,\n ...this.getItemLocation(startMarker)\n });\n }\n\n parseScript(): Types.Program {\n const startMarker = this.captureStartMarker();\n\n const body: Types.Statement[] = this.parseStatements();\n\n const program = this.finalize<Types.Program>({\n type: Types.Syntax.Program,\n body,\n ...this.getItemLocation(startMarker)\n });\n\n if (this.options.tokens) {\n program.tokens = this.tokens;\n }\n\n if (this.options.tolerant) {\n program.errors = this.errorHandler.errors;\n }\n\n return program;\n }\n\n parseExportDeclaration(): Types.ExportNamedDeclaration | never {\n if (this.context.blockContext !== BlockContext.None) {\n this.throwUnexpectedToken({ code: Types.DiagnosticCodes.ModuleExportRootOnly });\n }\n\n let declaration: Types.FunctionDeclaration | Types.VariableDeclaration | null = null;\n const startMarker = this.captureStartMarker();\n this.expectKeyword(Types.Keywords.Export);\n\n if (this.matchKeyword(Types.Keywords.Var)) {\n declaration = this.parseVariableDeclaration();\n } else if (this.matchKeyword(\"function\")) {\n declaration = this.parseFunctionDeclaration();\n } else {\n this.throwUnexpectedToken({ code: Types.DiagnosticCodes.InvalidExpression });\n }\n return this.finalize({\n type: Types.Syntax.ExportNamedDeclaration,\n declaration,\n specifiers: [],\n source: null,\n ...this.getItemLocation(startMarker)\n });\n }\n\n // The module specified part of a import XX from 'MODULESPECIFIER'\n parseModuleSpecifier(): Types.Literal {\n const startMarker = this.captureStartMarker();\n\n const rawToken = this.rawToken;\n if (rawToken.type === Types.TokenType.StringLiteral) {\n this.readNextRawToken();\n return this.finalize({\n type: Types.Syntax.Literal,\n value: rawToken.value,\n raw: this.getSourceValue(rawToken),\n isString: true,\n ...this.getItemLocation(startMarker)\n });\n }\n this.throwError(Types.DiagnosticCodes.InvalidModuleUri, startMarker);\n }\n\n parseDefaultSpecifier(): Types.ImportDefaultSpecifier {\n const startMarker = this.captureStartMarker();\n const id = this.parseIdentifier();\n if (!id) {\n this.throwUnexpectedToken({ code: Types.DiagnosticCodes.IdentiferExpected });\n }\n return this.finalize({\n type: Types.Syntax.ImportDefaultSpecifier,\n local: id,\n ...this.getItemLocation(startMarker)\n });\n }\n\n parseImportDeclaration(): Types.ImportDeclaration | never {\n if (this.context.blockContext !== BlockContext.None) {\n this.throwUnexpectedToken({ code: Types.DiagnosticCodes.ModuleImportRootOnly });\n }\n\n const startMarker = this.captureStartMarker();\n\n this.expectKeyword(Types.Keywords.Import);\n const id = this.parseDefaultSpecifier();\n this.expectContextualKeyword(Types.Keywords.From);\n const modulesource = this.parseModuleSpecifier();\n\n return this.finalize({\n type: Types.Syntax.ImportDeclaration,\n specifiers: [id],\n source: modulesource,\n ...this.getItemLocation(startMarker)\n });\n }\n}\n","// esri.arcade.lib\nimport { ErrorHandler } from \"./error-handler\";\nimport { Scanner } from \"./scanner\";\nimport { TokenNames, Syntax } from \"./types\";\nimport type { Token, TokenizeOptions } from \"./types\";\n\nexport class Tokenizer {\n readonly errorHandler: ErrorHandler;\n readonly scanner: Scanner;\n readonly buffer: Token[];\n readonly trackComments: boolean;\n\n constructor(code: string, config?: TokenizeOptions) {\n this.errorHandler = new ErrorHandler();\n this.errorHandler.tolerant = config ? typeof config.tolerant === \"boolean\" && config.tolerant : false;\n\n this.scanner = new Scanner(code, this.errorHandler);\n this.trackComments = config ? typeof config.comment === \"boolean\" && config.comment : false;\n\n this.buffer = [];\n }\n\n errors(): Error[] {\n return this.errorHandler.errors;\n }\n\n /**\n * Used by the exposed method 'tokenize'\n */\n getNextToken(): Token | undefined {\n if (this.buffer.length === 0) {\n const scanerComments = this.scanner.scanComments();\n if (this.trackComments) {\n scanerComments.forEach((scannerComment) => {\n const value = this.scanner.source.slice(scannerComment.start, scannerComment.end);\n const commentToken: Token = {\n type: scannerComment.multiLine ? Syntax.BlockComment : Syntax.LineComment,\n value,\n range: scannerComment.range,\n loc: scannerComment.loc\n };\n this.buffer.push(commentToken);\n });\n }\n\n if (!this.scanner.eof()) {\n const start = {\n line: this.scanner.lineNumber,\n column: this.scanner.index - this.scanner.lineStart\n };\n\n const rawToken = this.scanner.lex();\n\n const end = {\n line: this.scanner.lineNumber,\n column: this.scanner.index - this.scanner.lineStart\n };\n\n const entry: Token = {\n type: TokenNames[rawToken.type],\n value: this.scanner.source.slice(rawToken.start, rawToken.end),\n range: [rawToken.start, rawToken.end],\n loc: { start, end }\n };\n\n this.buffer.push(entry);\n }\n }\n\n return this.buffer.shift();\n }\n}\n","// esri.arcade.lib\nimport { Parser } from \"./parser\";\nimport { Tokenizer } from \"./tokenizer\";\nimport type { ParseOptions, Program, Token, TokenizeOptions, Delegate } from \"./types\";\n\nexport * from \"./types\";\n\nexport function parse(code: string, options?: ParseOptions, delegate?: Delegate): Program {\n const parser = new Parser(code, options, delegate);\n const ast = parser.parseScript();\n\n return ast;\n}\n\nexport function tokenize(\n code: string,\n options?: TokenizeOptions,\n delegate?: (entry: Token) => Token\n): { tokens: Token[]; errors?: Error[] } {\n const tokenizer = new Tokenizer(code, options);\n\n const tokens: Token[] = [];\n let errors: Error[] | undefined = undefined;\n try {\n let token: Token | undefined;\n while ((token = tokenizer.getNextToken())) {\n if (delegate) {\n token = delegate(token);\n }\n tokens.push(token);\n }\n } catch (e) {\n tokenizer.errorHandler.tolerate(e);\n }\n\n if (tokenizer.errorHandler.tolerant) {\n errors = tokenizer.errors();\n }\n\n return { tokens, errors };\n}\n","import * as Parser from \"@arcgis/arcade-parser\";\nimport { DiagnosticSeverity, Range } from \"vscode-languageserver-types\";\n\nexport { DiagnosticSeverity };\n\n/**\n * Represents the data associated with a diagnostic.\n * For example in case of an error associated to an identifier,\n * the DiagnosticData will contain a key 'identifier' and its value.\n */\nexport type DiagnosticData = Record<string, number | string>;\n\n/**\n * The combined diagnostic codes\n */\nexport type DiagnosticCodes = Parser.DiagnosticCodes | ValidationDiagnosticCodes;\n\n/**\n * Represents a diagnostic, such as a parsing error or warning.\n */\nexport interface Diagnostic {\n /**\n * The range at which the message applies\n */\n range: Range;\n\n /**\n * The diagnostic's severity. Can be omitted. If omitted it is up to the\n * client to interpret diagnostics as error, warning, info or hint.\n */\n severity?: DiagnosticSeverity;\n\n /**\n * The diagnostic's code.\n */\n code: DiagnosticCodes;\n\n /**\n * The diagnostic's message. It usually appears in the user interface\n */\n message: string;\n\n /**\n * A data entry field that is preserved between a `textDocument/publishDiagnostics`\n * notification and `textDocument/codeAction` request.\n */\n data?: DiagnosticData | null;\n}\n\nexport enum ValidationDiagnosticCodes {\n AlreadyDefined = \"AlreadyDefined\",\n ApiConflict = \"ApiConflict\",\n AssignedNeverUsed = \"AssignedNeverUsed\",\n DefinedNeverAssigned = \"DefinedNeverAssigned\",\n DefinedNeverUsed = \"DefinedNeverUsed\",\n EmptyBlockStatement = \"EmptyBlockStatement\",\n ExecutionError = \"ExecutionError\",\n InvalidApiFunctionUsage = \"InvalidApiFunctionUsage\",\n InvalidConstantIdentifier = \"InvalidConstantIdentifier\",\n InvalidPropertyIdentifier = \"InvalidPropertyIdentifier\",\n NoArgumentExpected = \"NoArgumentExpected\",\n NotADictionary = \"NotADictionary\",\n NotDefined = \"NotDefined\",\n NotEnoughArguments = \"NotEnoughArguments\",\n ProfileVariablesAreImmutable = \"ProfileVariablesAreImmutable\",\n ProfileVariablesConflict = \"ProfileVariablesConflict\",\n ReservedKeyword = \"ReservedKeyword\",\n TooManyArguments = \"TooManyArguments\",\n UnexpectedEmptyFunction = \"UnexpectedEmptyFunction\",\n UnexpectedPropertyIdentifier = \"UnexpectedPropertyIdentifier\",\n UnknownPropertyIdentifier = \"UnknownPropertyIdentifier\"\n}\n\nexport const DiagnosticMessages: { [key in ValidationDiagnosticCodes & Parser.DiagnosticCodes]: string } = {\n [ValidationDiagnosticCodes.AlreadyDefined]: \"'${identifier}' is already defined.\",\n [ValidationDiagnosticCodes.ApiConflict]: \"'${identifier}' is already defined as an Arcade constant or function.\",\n [ValidationDiagnosticCodes.AssignedNeverUsed]: \"'${identifier}' is assigned but never used.\",\n [ValidationDiagnosticCodes.DefinedNeverAssigned]: \"'${identifier}' is defined but never assigned.\",\n [ValidationDiagnosticCodes.DefinedNeverUsed]: \"'${identifier}' is defined but never used.\",\n [ValidationDiagnosticCodes.EmptyBlockStatement]: \"Empty block statement.\",\n [ValidationDiagnosticCodes.ExecutionError]: \"Execution Error: '${stack}'\",\n [ValidationDiagnosticCodes.InvalidApiFunctionUsage]: \"Arcade function '${identifier}' not used in a call expression.\",\n [ValidationDiagnosticCodes.InvalidConstantIdentifier]: \"Invalid constant identifier, expecting ${list}.\",\n [ValidationDiagnosticCodes.InvalidPropertyIdentifier]: \"Invalid property identifier, expecting ${list}.\",\n [ValidationDiagnosticCodes.NoArgumentExpected]: \"Expecting no argument.\",\n [ValidationDiagnosticCodes.NotADictionary]: \"'${identifier}' doesn't have properties.\",\n [ValidationDiagnosticCodes.NotDefined]: \"'${identifier}' is not defined.\",\n [ValidationDiagnosticCodes.NotEnoughArguments]: \"Expecting at least ${min} argument(s).\",\n [ValidationDiagnosticCodes.ProfileVariablesAreImmutable]: \"Profile variables cannot be modified.\",\n [ValidationDiagnosticCodes.ProfileVariablesConflict]: \"'${identifier}' is already defined as a profile variable.\",\n [ValidationDiagnosticCodes.ReservedKeyword]: \"'${identifier}' is a reserved keyword.\",\n [ValidationDiagnosticCodes.TooManyArguments]: \"Too many arguments, expecting ${max}.\",\n [ValidationDiagnosticCodes.UnexpectedEmptyFunction]: \"Unexpected empty function '${identifier}'.\",\n [ValidationDiagnosticCodes.UnexpectedPropertyIdentifier]: \"Unexpected property identifier.\",\n [ValidationDiagnosticCodes.UnknownPropertyIdentifier]: \"Unknown property identifier '${identifier}'.\",\n ...Parser.DiagnosticMessages\n} as const;\n","import { Keywords, Literals } from \"@arcgis/arcade-parser\";\nexport const ArcadeKeywords = Object.values(Keywords);\nexport const ArcadeLiterals = Object.values(Literals);\n\nexport const ArcadeReservedKeywords = [\"case\", \"catch\", \"debugger\", \"switch\", \"try\"];\n","import type {\n SdkItem,\n SdkConstant as ApiConstant,\n SdkFunction as ApiFunction,\n BundleType,\n SdkCategory\n} from \"@arcgis/arcade-sdk\";\nimport {\n CompletionItem,\n CompletionItemKind,\n InsertTextFormat,\n InsertTextMode,\n MarkupKind\n} from \"vscode-languageserver-types\";\nimport { ApiContext } from \"../api-context\";\nimport { ApiCategory, ApiItem } from \"../api-types\";\nimport { ArcadeLanguageServiceSettings } from \"../settings\";\n\n//#region Module level caching\nconst sdkCategoriesCache = new Map<string, Promise<SdkCategory[]>>();\n//#endregion\n\n//#region Internal types\ninterface ApiVersion {\n major: number;\n minor?: number;\n}\n//#endregion\n\nexport type ApiConstantNamespace = {\n type: \"namespace\";\n key: string;\n members: ApiConstant[];\n completion: CompletionItem;\n};\n\nexport type ApiConstantDefinition = ApiConstant | ApiConstantNamespace;\n\nexport type ApiFunctionDefinition = {\n type: \"functionDefinition\";\n key: string;\n overloads: ApiFunction[];\n};\n\n/**\n * Describes the Arcade API properties\n */\nexport interface ApiDatabase {\n categories: ApiCategory[];\n functionDefinitions: Map<string, ApiFunctionDefinition>;\n constantDefinitions: Map<string, ApiConstantDefinition>;\n}\n\ninterface TestArcadeSettings extends ArcadeLanguageServiceSettings {\n testSdkCategories: SdkCategory[];\n}\n\nfunction isTestSettings(settings: ArcadeLanguageServiceSettings): settings is TestArcadeSettings {\n return Array.isArray((settings as TestArcadeSettings)?.testSdkCategories);\n}\n\nfunction getApiDefinitionPath(assetsPath: string, locale: string) {\n return `${assetsPath}/api/arcade-api.t9n.${locale}.json`;\n}\n\nexport class ArcadeApiService {\n constructor(private _settings: ArcadeLanguageServiceSettings = {}) {}\n\n /**\n * Returns the Arcade API defintions for the given settings: definitions, constant definitions, and function definitons\n */\n public async getApiDatabase(context: ApiContext): Promise<ApiDatabase> {\n const { locale = \"en\" } = context;\n let sdkCategoriesPromise = sdkCategoriesCache.get(locale);\n if (!sdkCategoriesPromise) {\n const { assetsPath } = this._settings;\n if (!assetsPath) {\n return {\n categories: [],\n functionDefinitions: new Map<string, ApiFunctionDefinition>(),\n constantDefinitions: new Map<string, ApiConstantDefinition>()\n };\n }\n sdkCategoriesPromise = this.loadSdkApiLibrary(locale, assetsPath);\n sdkCategoriesCache.set(locale, sdkCategoriesPromise);\n }\n\n return this.filterApi(sdkCategoriesPromise, context);\n }\n\n /**\n * Returns the Arcade API definitions\n */\n public async getApiLibrary(context: ApiContext): Promise<ApiCategory[]> {\n const { categories } = await this.getApiDatabase(context);\n return categories;\n }\n\n private async filterApi(sdkCategoriesPromise: Promise<SdkCategory[]>, context: ApiContext): Promise<ApiDatabase> {\n try {\n const sdkCategories = await sdkCategoriesPromise;\n\n // Creates the various Maps used for validation\n const functionDefinitions = new Map<string, ApiFunctionDefinition>();\n const constantDefinitions = new Map<string, ApiConstantDefinition>();\n const documentationLibrary: ApiCategory[] = [];\n const isApiItemSupportedFn = filterApiItemFn(context);\n\n sdkCategories.forEach((sdkApiCategory: SdkCategory) => {\n const items: ApiItem[] = [];\n sdkApiCategory.items.forEach((sdkApiItem) =>\n processSdkApiItem(items, constantDefinitions, functionDefinitions, isApiItemSupportedFn, sdkApiItem)\n );\n if (!items.length) {\n return;\n }\n documentationLibrary.push({ ...sdkApiCategory, items });\n });\n\n return { categories: documentationLibrary, functionDefinitions, constantDefinitions };\n } catch (e) {\n return { categories: [], functionDefinitions: new Map(), constantDefinitions: new Map() };\n }\n }\n\n private async loadSdkApiLibrary(locale = \"en\", assetsPath = \"\"): Promise<SdkCategory[]> {\n if (isTestSettings(this._settings)) {\n return this._settings.testSdkCategories;\n }\n\n assetsPath = assetsPath.replace(/\\/$/, \"\");\n if (!assetsPath) {\n return [];\n }\n\n try {\n const response = await fetch(getApiDefinitionPath(assetsPath, locale));\n if (response.ok) {\n return response.json();\n }\n if (locale === \"en\") {\n return [];\n }\n return this.loadSdkApiLibrary(\"en\", assetsPath);\n } catch (e) {\n return [];\n }\n }\n}\n\n//#region private support functions\nfunction filterApiItemFn(context: ApiContext): (apiItem: ApiItem) => boolean {\n const { profile: { apiVersion, bundles, hiddenApiItems = [] } = {} } = context;\n\n // Extract the target version properties\n const apiVersionProps = extractApiVersionProperties(apiVersion);\n\n // Build the target bundle list\n // Core is always here\n const bundleSet: Set<BundleType> | undefined =\n Array.isArray(bundles) && bundles.length > 0 ? new Set<BundleType>([\"core\", ...bundles]) : undefined;\n\n return (apiItem: ApiItem): boolean => {\n return (\n matchTargetApiVersion(apiVersionProps, apiItem.sinceVersion) &&\n (!bundleSet || bundleSet.has(apiItem.bundle)) &&\n !hiddenApiItems.includes(apiItem.name)\n );\n };\n}\n\nfunction processSdkApiItem(\n apiItems: ApiItem[],\n constantDefinitions: Map<string, ApiConstantDefinition>,\n functionDefinitions: Map<string, ApiFunctionDefinition>,\n isApiItemSupportedFn: (apiItem: ApiConstant | ApiFunction) => boolean,\n sdkApiItem: SdkItem\n): void {\n // The api item is a collection of functions\n if (Array.isArray(sdkApiItem)) {\n sdkApiItem.forEach((apiFunction) =>\n processApiFunction(apiItems, functionDefinitions, isApiItemSupportedFn, apiFunction)\n );\n return;\n }\n\n // Analyse constants for constants in namespace\n if (sdkApiItem.type === \"constant\") {\n return processApiConstant(apiItems, constantDefinitions, isApiItemSupportedFn, sdkApiItem);\n }\n\n // Add the function to the dictionary of function definitions.\n processApiFunction(apiItems, functionDefinitions, isApiItemSupportedFn, sdkApiItem);\n}\n\nfunction processApiFunction(\n apiItems: ApiItem[],\n functionDefinitions: Map<string, ApiFunctionDefinition>,\n isApiItemSupportedFn: (apiItem: ApiItem) => boolean,\n apiItem: ApiFunction\n) {\n if (!isApiItemSupportedFn(apiItem)) {\n return;\n }\n\n // Push the item in the collection if not disabled\n if (!apiItem.disableDocumentation) {\n apiItems.push(apiItem);\n }\n\n // Extract the key\n const {\n completion: { label }\n } = apiItem;\n const key = label.toLowerCase();\n\n let functionOverloadDefinition = functionDefinitions.get(key);\n if (!functionOverloadDefinition) {\n functionOverloadDefinition = {\n type: \"functionDefinition\",\n key,\n overloads: []\n };\n functionDefinitions.set(key, functionOverloadDefinition);\n }\n\n functionOverloadDefinition.overloads.push(apiItem);\n}\n\nfunction processApiConstant(\n apiItems: ApiItem[],\n constantDefinitions: Map<string, ApiConstantDefinition>,\n isApiItemSupportedFn: (apiItem: ApiItem) => boolean,\n apiItem: ApiConstant\n): void {\n // Before processing validate the item is supported based on version and bundle\n if (!isApiItemSupportedFn(apiItem)) {\n return;\n }\n\n // Push the item in the collection\n apiItems.push(apiItem);\n\n // Extract the key\n const {\n completion: { label }\n } = apiItem;\n const key = label.toLowerCase();\n\n // Add the definition to the constant definition collection. A constant could be defined as:\n // - foo\n // or\n // - namespace.foo\n // Additional steps necessary for namespaced constants\n constantDefinitions.set(key, apiItem);\n\n // Are we dealing with a namespaced constant: xxx.yyy?\n const [namespaceName, propertyName] = apiItem.completion.label.split(\".\");\n if (!propertyName) {\n return;\n }\n\n // Make sure the namespace is also registered and that we record the constant a property of the namespace\n const namespaceKey = namespaceName.toLowerCase();\n let namespaceDefinition = constantDefinitions.get(namespaceKey) as ApiConstantNamespace;\n if (!namespaceDefinition) {\n // Create a constant namespace object, members will be the individual constants of the namespace\n namespaceDefinition = {\n type: \"namespace\",\n key: namespaceKey,\n members: [],\n completion: {\n label: namespaceName,\n detail: namespaceName,\n insertText: namespaceName,\n insertTextMode: InsertTextMode.adjustIndentation,\n insertTextFormat: InsertTextFormat.PlainText,\n kind: CompletionItemKind.Enum\n }\n };\n constantDefinitions.set(namespaceKey, namespaceDefinition);\n }\n\n // Clone the original constant definition,\n // transform it into a property definition,\n // and add it to the constant namespace\n const propertyDefinition = JSON.parse(JSON.stringify(apiItem));\n propertyDefinition.key = propertyName.toLowerCase();\n propertyDefinition.name = propertyName;\n propertyDefinition.completion.label = propertyName;\n propertyDefinition.completion.insertText = propertyName;\n propertyDefinition.completion.kind = CompletionItemKind.Constant;\n namespaceDefinition.members.push(propertyDefinition);\n\n // Assemble the documentation for the namespace\n /* eslint-disable-next-line no-useless-escape */\n namespaceDefinition.completion.documentation = namespaceDefinition.members.reduce(\n (previous, m) => {\n previous.value = `${previous.value}${previous.value ? \"\\n\\n\" : \"\"}**${m.completion.label}**: ${m.description}`;\n return previous;\n },\n { kind: MarkupKind.Markdown, value: \"\" }\n );\n}\n\nfunction extractApiVersionProperties(apiVersion: string | undefined): ApiVersion | null {\n if (!apiVersion || typeof apiVersion !== \"string\") {\n return null;\n }\n\n const parts = apiVersion.split(\".\").map((n) => parseInt(n));\n if (parts.some(isNaN)) {\n console.error(\"Arcade: invalid API version string\", apiVersion);\n return null;\n }\n\n const [major, minor] = parts.slice(0, 2);\n return { major, minor };\n}\n\nfunction matchTargetApiVersion(\n targetApiVersionProps: ApiVersion | null | undefined,\n apiVersion: string | undefined\n): boolean {\n if (!targetApiVersionProps) {\n return true;\n }\n\n const apiVersionProps = extractApiVersionProperties(apiVersion);\n if (!apiVersionProps) {\n return true;\n }\n\n if (targetApiVersionProps.major > apiVersionProps.major) {\n return false;\n }\n\n if (targetApiVersionProps.minor === undefined || apiVersionProps.minor === undefined) {\n return true;\n }\n\n return apiVersionProps.minor <= targetApiVersionProps.minor;\n}\n//#endregion\n","import {\n Position,\n CompletionList,\n CompletionItemKind,\n InsertTextFormat,\n InsertTextMode,\n CompletionItem\n} from \"vscode-languageserver-types\";\nimport { TextDocument } from \"vscode-languageserver-textdocument\";\nimport * as Parser from \"@arcgis/arcade-parser\";\nimport { ApiDatabase } from \"../arcade-api\";\nimport { isDictionaryVariable, ApiVariable, ApiContext } from \"../api-context\";\nimport { statementsSnippets, keywordCompletions, literalCompletions } from \"./snippets\";\nimport { formatString, isPositionInsideLocation, sanitizingExp } from \"./utils\";\n\ninterface CompletionContext {\n variables: ApiVariable[];\n additionalCompletionItems: CompletionItem[];\n apiDatabase: ApiDatabase;\n}\n\nenum SuggestionType {\n None = 0,\n Keywords = 1 << 0,\n All = 255,\n NoKeywords = SuggestionType.All & ~SuggestionType.Keywords\n}\n\nconst sortTextValues = {\n identifiers: \"a\",\n profileVariables: \"aa\",\n constants: \"ab\",\n literals: \"ab\",\n functions: \"ac\",\n snippets: \"b\",\n keywords: \"c\"\n};\n\nexport async function arcadeComplete(\n document: TextDocument,\n documentPosition: Position,\n apiDatabase: ApiDatabase,\n context: ApiContext = {}\n): Promise<CompletionList> {\n // We need to analyze the code up to the position.\n // We are using the tokenizer to collect all the tokens up to the position.\n // With the tokens we will first analyze if the completion is possible and\n // if so what the kind of completion. The particular case we are trying\n // to also solve is the dot completion that is for now only applicable to\n // the API constants.\n // If it is not an constant completion, then we will continue with the other\n // completions. We will need to collect all the identifiers in the code up\n // to the position. We will need to handle if we are inside or after/outside\n // a function declaration. If we are inside a function declaration then\n // we should also provide the function attributes.\n // Known limitations:\n // - we cannot provide completions for user defined object properties.\n\n // Tokenized up to the position\n const code = document.getText({ start: { line: 0, character: 0 }, end: documentPosition });\n const { tokens, errors = [] } = Parser.tokenize(code, { loc: true, tolerant: true });\n\n // In case of errors, there isn't much we can do\n if (errors.length) {\n return { isIncomplete: false, items: [] };\n }\n\n // If our last token is an identifier and it is at the position\n // then collect it as the suggestion word and move to the previous token\n let lastToken = tokens[tokens.length - 1];\n let triggeringWord = \"\";\n const triggerPosition = toParserPosition(documentPosition);\n if (lastToken?.type === \"Identifier\" && isPositionInsideLocation(triggerPosition, lastToken.loc)) {\n // This is the word that triggered the completion process.\n // Remove it from the tokens\n triggeringWord = lastToken.value ?? \"\";\n tokens.pop();\n lastToken = tokens[tokens.length - 1];\n }\n\n // Regroup what we need into a specialized context\n const completionContext: CompletionContext = {\n variables: context.profile?.variables ?? [],\n additionalCompletionItems: (context.snippets ?? []).map((externalSnippet) => ({\n kind: CompletionItemKind.Snippet,\n insertTextMode: InsertTextMode.adjustIndentation,\n insertTextFormat: InsertTextFormat.Snippet,\n ...externalSnippet\n })),\n apiDatabase\n };\n\n // If the current token is a '.' then we are dealing with an object completion.\n if (lastToken?.type === \"Punctuator\" && lastToken.value === \".\") {\n return objectCompletion(tokens, triggeringWord, completionContext);\n }\n\n return normalCompletion(tokens, triggeringWord, triggerPosition, completionContext);\n}\n\nasync function normalCompletion(\n tokens: Parser.Token[],\n suggestionWord: string,\n triggerPosition: Parser.Position,\n context: CompletionContext\n): Promise<CompletionList> {\n // Verifiy that we can actually suggest\n const suggestionType = getSuggestionTypeAtPosition(tokens, triggerPosition);\n if (suggestionType === SuggestionType.None) {\n return { isIncomplete: false, items: [] };\n }\n\n // Scan for identifiers\n const identifiersMap = extractIdentifiers(tokens);\n const items: CompletionItem[] = [];\n const wordRegEx = new RegExp(suggestionWord.replaceAll(sanitizingExp, \"\\\\$&\"), \"i\");\n\n // Add the identifiers\n identifiersMap.forEach((identifierRecord, key) => {\n if (!wordRegEx.test(key)) {\n return;\n }\n items.push({ ...identifierRecord, sortText: sortTextValues.identifiers });\n });\n\n // Filter profile variables\n context.variables.forEach((p) => {\n if (wordRegEx.test(p.name) && p.completion) {\n items.push({ ...p.completion, sortText: sortTextValues.profileVariables });\n }\n });\n\n // Filter built-in snippets, should start with the suggestion word\n includeKeywords(suggestionType) &&\n statementsSnippets.forEach((item) => {\n if (item.label.startsWith(suggestionWord)) {\n items.push({ ...item, sortText: sortTextValues.snippets });\n }\n });\n\n // Filter snippets\n context.additionalCompletionItems.forEach((item) => {\n if (!wordRegEx.test(item.label)) {\n return;\n }\n items.push({ ...item, sortText: sortTextValues.snippets });\n });\n\n // Filter keyword completions\n includeKeywords(suggestionType) &&\n keywordCompletions.forEach((item) => {\n if (!wordRegEx.test(item.label)) {\n return;\n }\n items.push({ ...item, sortText: sortTextValues.keywords });\n });\n\n // Filter literals\n literalCompletions.forEach((item) => {\n if (!wordRegEx.test(item.label)) {\n return;\n }\n items.push({ ...item, sortText: sortTextValues.literals });\n });\n\n // Filter API Contants\n context.apiDatabase.constantDefinitions.forEach((constantDefinition, key) => {\n if ((constantDefinition.type === \"constant\" && constantDefinition.disableDocumentation) || !wordRegEx.test(key)) {\n return;\n }\n items.push({ ...constantDefinition.completion, sortText: sortTextValues.constants });\n });\n\n // Filter API Functions\n context.apiDatabase.functionDefinitions.forEach((functionDefinition, key) => {\n if (!wordRegEx.test(key)) {\n return;\n }\n functionDefinition.overloads.forEach((functionDefinition) => {\n if (functionDefinition.disableDocumentation) {\n return;\n }\n items.push({ ...functionDefinition.completion, sortText: sortTextValues.functions });\n });\n });\n\n return { isIncomplete: false, items };\n}\n\nasync function objectCompletion(\n tokens: Parser.Token[],\n suggestionWord: string,\n context: CompletionContext\n): Promise<CompletionList> {\n // Walk the tokens backward and try to assemble the longest member expression keys x.y.z.a\n const _tokens = [...tokens];\n let currentToken = _tokens.pop();\n const dotToken = currentToken;\n let memberExpressionKeys: string[] = [];\n while (currentToken) {\n // If the current token is not a '.' then we are done\n if (currentToken?.type !== \"Punctuator\" || currentToken.value !== \".\") {\n break;\n }\n\n // Move to the previous token\n currentToken = _tokens.pop();\n\n // Validate that the current token is an identifier, if not then we are done\n if (currentToken?.type !== \"Identifier\") {\n break;\n }\n\n // Push the identifier in the member expression\n memberExpressionKeys = [currentToken.value.toLowerCase(), ...memberExpressionKeys];\n\n // Move to the previous token\n currentToken = _tokens.pop();\n }\n\n // No root keys or not dot token, there is something wrong with the syntax\n if (memberExpressionKeys.length === 0 || !dotToken) {\n return { isIncomplete: false, items: [] };\n }\n\n let result = await constantNamespaceCompletion(memberExpressionKeys, suggestionWord, context);\n if (result) {\n return result;\n }\n\n result = profileVariablesCompletion(memberExpressionKeys, suggestionWord, dotToken, context);\n if (result) {\n return result;\n }\n\n return { isIncomplete: false, items: [] };\n}\n\nasync function constantNamespaceCompletion(\n memberExpressionKeys: string[],\n suggestionWord: string,\n context: CompletionContext\n): Promise<CompletionList | null> {\n // Constant completion only works with one object key: `constantNameSpace.constant`\n if (memberExpressionKeys.length > 1) {\n return null;\n }\n\n // Check if the object key is a known constant namespace\n // Note that member expression keys are already lower case.\n const constant = context.apiDatabase.constantDefinitions.get(memberExpressionKeys[0]);\n if (!constant) {\n return null;\n }\n\n // The key exists but it is not an namespace. We cannot complete.\n if (constant.type !== \"namespace\") {\n return { isIncomplete: false, items: [] };\n }\n\n // Find in the namespace a matching property\n const items: CompletionItem[] = [];\n const wordRegEx = new RegExp(suggestionWord.replaceAll(sanitizingExp, \"\\\\$&\"), \"i\");\n constant.members.forEach((constantDefinition) => {\n if (constantDefinition.disableDocumentation || !wordRegEx.test(constantDefinition.name)) {\n return;\n }\n items.push(constantDefinition.completion);\n });\n\n return { isIncomplete: false, items };\n}\n\nfunction profileVariablesCompletion(\n memberExpressionKeys: string[],\n suggestionWord: string,\n dotToken: Parser.Token,\n context: CompletionContext\n): CompletionList | null {\n if (!context.variables?.length || !memberExpressionKeys.length) {\n return null;\n }\n\n // We have a collection of keys [a,b,c] coming from a member expression a.b.c\n // We need to find in the profile variables a dictionary that match 'a'.\n // The dictionary 'a' must have a property that is also a dictionary 'b', and so on.\n // If at any point a key doesn't match a property, we can stop.\n // Start with the profile variables\n let key = memberExpressionKeys.shift();\n let variables = context.variables;\n while (key) {\n // We got a key, find the the variable in the variables array\n const variable = variables?.find((v) => v.name.toLowerCase() === key);\n\n // No variable matching or it's not a dictionary.\n if (!isDictionaryVariable(variable)) {\n return null;\n }\n\n // Prepare the next level\n variables = variable.properties;\n key = memberExpressionKeys.shift();\n }\n\n // If we got there, the whole path a.b.c is matching a profile variable dictionary\n // and its sub-properties. Match the last level for the propertyRegEx.\n const items: CompletionItem[] = [];\n const wordRegEx = new RegExp(suggestionWord.replaceAll(sanitizingExp, \"\\\\$&\"), \"i\");\n const dotLocation = toDocumentPosition(dotToken.loc.start);\n variables.forEach((v) => {\n if (wordRegEx.test(v.name) && v.completion) {\n items.push(adjustComputedPropertyCompletion(dotLocation, v.completion));\n }\n });\n\n return { isIncomplete: false, items };\n}\n\nfunction includeKeywords(suggestionType: SuggestionType): boolean {\n return (suggestionType & SuggestionType.Keywords) === SuggestionType.Keywords;\n}\n\nfunction getSuggestionTypeAtPosition(tokens: Parser.Token[], triggerPosition: Parser.Position): SuggestionType {\n // The suggested identifier has already been removed from the stack\n // No token means we reached the beginning of the script and we can suggest.\n\n // Empty script\n if (!tokens.length) {\n return SuggestionType.All;\n }\n\n // Start processing patterns\n const lastToken = tokens[tokens.length - 1];\n switch (lastToken.type) {\n case \"Identifier\":\n // - 'for in' case.\n // The 'in' would be in front of an identifier.\n // TODO: refine suggestion for 'in' case.\n return SuggestionType.All;\n\n case \"Keyword\":\n // In front of a keyword, we should not suggest except for: 'return', 'in', and 'else'\n // TODO: export?\n return [\"return\", \"in\", \"else\"].includes(lastToken.value) ? SuggestionType.NoKeywords : SuggestionType.None;\n\n case \"Punctuator\":\n return getSuggestionTypeInFrontOfPunctuator(tokens);\n\n case \"Template\":\n return lastToken.value.endsWith(\"${\") ? SuggestionType.NoKeywords : SuggestionType.All;\n\n default:\n // All the other cases, we will suggest only if the trigger position is after the last token.\n return isPositionInsideLocation(triggerPosition, lastToken.loc) ? SuggestionType.None : SuggestionType.All;\n }\n}\n\nfunction getSuggestionTypeInFrontOfPunctuator(tokens: Parser.Token[]): SuggestionType {\n const _tokens = [...tokens];\n let currentToken = _tokens.pop();\n if (!currentToken) {\n // Beginning of script\n return SuggestionType.All;\n }\n\n if (currentToken.type !== \"Punctuator\") {\n // Safe guard\n return SuggestionType.None;\n }\n\n // We are only interested in the patterns:\n // - is this a function declaration like: function foo(a, <here> )\n // - is this a function declaration like: function foo(<here>)\n // - is this a function call like: foo(a,<here>)\n // - is this a function call like: foo(<here>)\n // - is this an array declaration like: [a,<here>]\n // - is this an object declaration like: {a:1,<here>}\n // All the other cases are valid for suggestions.\n if (currentToken.value !== \"(\" && currentToken.value !== \",\") {\n return SuggestionType.All;\n }\n\n if (currentToken.value === \"(\") {\n return getSuggestionTypeIfFrontOfParenthesis(_tokens);\n }\n\n // We are at a punctuator ','.\n // Walk the token backwards and assess the kind of statement:\n // - array declaration?\n // - a function call?\n let openedClosedCount = 0;\n currentToken = _tokens.pop();\n while (currentToken) {\n if (currentToken.type === \"Keyword\") {\n // Found a keyword when walking backward from the ','.\n // This is a deal breaker.\n return SuggestionType.None;\n }\n\n if (currentToken.type !== \"Punctuator\") {\n // When walking backward, we are interested to find either another ',' or a '('\n currentToken = _tokens.pop();\n continue;\n }\n\n if (currentToken.value === \")\" || currentToken.value === \"]\") {\n // As we are walking backward we found a closing parenthesis.\n // Update the parenthis count and continue.\n openedClosedCount--;\n currentToken = _tokens.pop();\n continue;\n }\n\n if (currentToken.value === \"[\") {\n // We found an opening bracket.\n // If the the number of opened/closed parenthesis is zero then\n // we found an array declaration.\n // Otherwise keep moving.\n if (openedClosedCount === 0) {\n return SuggestionType.NoKeywords;\n }\n\n openedClosedCount++;\n currentToken = _tokens.pop();\n continue;\n }\n\n if (currentToken.value === \"(\") {\n // We found an opening parenthesis.\n // If the number of opened/closed parenthesis is zero then\n // we could be in a function call or declaration. Further validate.\n if (openedClosedCount === 0) {\n // We are left bound by an open bracket or parenthesis\n return getSuggestionTypeIfFrontOfParenthesis(_tokens);\n }\n\n openedClosedCount++;\n currentToken = _tokens.pop();\n continue;\n }\n\n // Other punctuators are ignored.\n currentToken = _tokens.pop();\n }\n\n return SuggestionType.None;\n}\n\nfunction getSuggestionTypeIfFrontOfParenthesis(tokens: Parser.Token[]): SuggestionType {\n // A function call is made of `<identifier>(...)`.\n // The parenthesis has already been removed.\n const _tokens = [...tokens];\n let currentToken = _tokens.pop();\n if (!currentToken) {\n // We have a pattern that is `<something>()`. We should suggest.\n return SuggestionType.All;\n }\n\n if (currentToken.type === \"Keyword\") {\n // We have a pattern that is `<keyword>()`. We should suggest.\n return currentToken.value.toLowerCase() === \"for\" ? SuggestionType.All : SuggestionType.NoKeywords;\n }\n\n if (currentToken.type !== \"Identifier\") {\n return SuggestionType.All;\n }\n\n // However, we need to distinguish it from `function <identifier>(...)`.\n currentToken = _tokens.pop();\n if (currentToken?.type === \"Keyword\" && currentToken.value.toLowerCase() === \"function\") {\n return SuggestionType.None;\n }\n\n return SuggestionType.NoKeywords;\n}\n\nclass TokenScanner {\n public currentIndex = 0;\n constructor(private tokens: Parser.Token[]) {}\n increment(): Parser.Token | undefined {\n if (this.currentIndex >= this.tokens.length) {\n return undefined;\n }\n return this.tokens[++this.currentIndex];\n }\n get next(): Parser.Token | undefined {\n return this.tokens[this.currentIndex + 1];\n }\n get previous(): Parser.Token | undefined {\n return this.tokens[this.currentIndex - 1];\n }\n get current(): Parser.Token | undefined {\n return this.tokens[this.currentIndex];\n }\n}\n\n// interface IdentifierRecord extends CompletionItem {\n// position: Parser.Position; // Used to rollback the identifier\n// previousVersion?: IdentifierRecord; // Keep the previous version, used when rolling back the identifier\n// }\nconst SnippetFormats = {\n parameterFormat: \"(parameter) ${name}\",\n variableFormat: \"var ${name}\",\n functionFormat: \"function ${name} (${paramsDetail})\"\n};\n\nfunction extractIdentifiers(tokens: Parser.Token[]): Map<string, CompletionItem> {\n const identiferMap = new Map<string, CompletionItem>();\n if (!tokens.length) {\n return identiferMap;\n }\n\n const tokenScanner = new TokenScanner(tokens);\n while (tokenScanner.current) {\n if (tokenScanner.current.type === \"Keyword\") {\n // Var and Function keywords are source of identifiers\n if (tokenScanner.current.value.toLowerCase() === \"var\") {\n tokenScanner.increment();\n extractIdentifiersFromVarDeclaration(tokenScanner, identiferMap);\n continue;\n }\n if (tokenScanner.current.value.toLowerCase() === \"function\") {\n tokenScanner.increment();\n extractIdentifiersFromFunctionDeclaration(tokenScanner, identiferMap);\n continue;\n }\n }\n tokenScanner.increment();\n }\n\n return identiferMap;\n}\n\nfunction extractIdentifiersFromVarDeclaration(\n tokenScanner: TokenScanner,\n identifierMap: Map<string, CompletionItem>\n): void {\n while (tokenScanner.current) {\n // variable declarator starts with an identifier\n if (tokenScanner.current?.type !== \"Identifier\") {\n return;\n }\n\n const label = tokenScanner.current.value;\n const key = label.toLowerCase();\n identifierMap.set(key, {\n label,\n kind: CompletionItemKind.Variable,\n detail: formatString(SnippetFormats.variableFormat, { name: label })\n });\n const nextToken = tokenScanner.increment();\n\n // After the first identifer we are looking for a punctuator:\n // - if '=' then it's an assignment. We will skip it and try to find a \",\"\n // - if ',' then extract the next identifier\n if (nextToken?.type !== \"Punctuator\") {\n return;\n }\n\n // If it's a comma then we are done with this variable declarator, move to the next one\n if (nextToken.value === \",\") {\n tokenScanner.increment(); // Absorb the ','\n continue;\n }\n\n // If it is an assignement then skip the assigment expression until the\n // end of the variable declarator and continue to the next declarator\n if (nextToken.value === \"=\") {\n tokenScanner.increment(); // Absorb the '='\n skipVariableAssignment(tokenScanner);\n continue;\n }\n\n // Any other form punctuator is stoping the process\n }\n}\n\nfunction extractIdentifiersFromFunctionDeclaration(\n tokenScanner: TokenScanner,\n identifierMap: Map<string, CompletionItem>\n): void {\n while (tokenScanner.current) {\n // Function declaration starts with an identifier\n if (tokenScanner.current?.type !== \"Identifier\") {\n return;\n }\n\n const label = tokenScanner.current.value;\n const key = label.toLowerCase();\n\n // Create the function completion item.\n // Delay the detail and snippet until we got the params.\n // Provides default in case of an issue.\n const functionCompletionItem = {\n label,\n kind: CompletionItemKind.Function,\n detail: formatString(SnippetFormats.functionFormat, { name: label, paramsDetail: \"\" }),\n insertText: `${label}()`,\n insertTextMode: InsertTextMode.adjustIndentation,\n insertTextFormat: InsertTextFormat.Snippet\n };\n identifierMap.set(key, functionCompletionItem);\n let nextToken = tokenScanner.increment();\n\n // The next part is the function parameters. It should be:\n // - opening parenthesis\n // - potential collection of parameters separated by comma\n // - closing parenthesis\n // Collect all the parameter identifiers\n if (!matchPunctuator(nextToken, \"(\")) {\n return;\n }\n nextToken = tokenScanner.increment();\n\n // Should be a series of identifiers and comma bound\n // Don't directly add the parameters to the identifier colleciton.\n // We need to validate the suggestion position is inside the function\n const paramIdentifiers: string[] = [];\n while (nextToken) {\n if (nextToken.type !== \"Identifier\") {\n break;\n }\n paramIdentifiers.push(nextToken.value);\n nextToken = tokenScanner.increment();\n if (!matchPunctuator(nextToken, \",\")) {\n break;\n }\n nextToken = tokenScanner.increment();\n }\n\n // Update the function completion item with the params indentifiers\n if (paramIdentifiers.length) {\n functionCompletionItem.detail = formatString(SnippetFormats.functionFormat, {\n name: functionCompletionItem.label,\n paramsDetail: paramIdentifiers.join(\", \")\n });\n const snippetParamsString = paramIdentifiers.map((name, idx) => `$\\{${idx + 1}:${name}}`).join(\", \");\n functionCompletionItem.insertText = `${functionCompletionItem.label}(${snippetParamsString})`;\n }\n\n if (!matchPunctuator(nextToken, \")\")) {\n // Syntax error\n return;\n }\n nextToken = tokenScanner.increment();\n\n if (!matchPunctuator(nextToken, \"{\")) {\n // Syntax error\n return;\n }\n nextToken = tokenScanner.increment();\n\n // We have the beginning of the function block.\n // Find the matching closing curly bracket.\n // If we find it, it means that the suggestion is not inside the function block and we can skip it.\n // If we cannot find the closing bracket then the suggestion is inside the function block or there\n // is a syntax error. If this is the case then we will add the params identifiers and\n // let the rest of the process scan the interior of the function block for additional identifiers.\n // Remember our position in the token scanner in case we have to rollback.\n const blockStartingPosition = tokenScanner.currentIndex;\n let blockOpeners = 1;\n while (nextToken && blockOpeners > 0) {\n if (matchPunctuator(nextToken, \"{\")) {\n blockOpeners++;\n } else if (matchPunctuator(nextToken, \"}\")) {\n blockOpeners--;\n }\n nextToken = tokenScanner.increment();\n }\n\n if (blockOpeners === 0) {\n // If we passed the end of the function block then we don't need the params\n // The function shouldn't be scanned.\n return;\n }\n\n // The suggestion is inside the function block.\n // Add the params as variables and rewind the token scanner\n tokenScanner.currentIndex = blockStartingPosition;\n paramIdentifiers.forEach((label) => {\n const key = label.toLowerCase();\n identifierMap.set(key, {\n label,\n kind: CompletionItemKind.Variable,\n detail: formatString(SnippetFormats.parameterFormat, { name: label })\n });\n });\n }\n}\n\nfunction matchPunctuator(token: Parser.Token | undefined, punctuator: string): boolean {\n return token?.type === \"Punctuator\" && token.value === punctuator;\n}\n\nfunction skipVariableAssignment(tokenScanner: TokenScanner): void {\n // Skip everything until we\n // - find a keyword: it means we finished the assignement\n // - find a comma: that is not inside an array, object, function call, string, or templated string\n // - find a semicolon\n\n // We will skip commas when they are inside:\n // - function call foo(a,b,c)\n // - array [a,b,c]\n // - object {a:1,b:2}\n // - inside templated string\n let wrapperCount = 0;\n while (tokenScanner.current) {\n if (tokenScanner.current.type === \"Keyword\") {\n // Keyword indicates we potentially reached the end of variable assignment\n // If the keyword is preceeded by a dot, we can assume it's an object property\n if (matchPunctuator(tokenScanner.previous, \".\")) {\n tokenScanner.increment();\n continue;\n }\n return;\n }\n if (tokenScanner.current.type === \"Punctuator\" && tokenScanner.current.value === \";\") {\n // Semicolon are definitely the end of variable declaration\n return;\n }\n if (tokenScanner.current.type === \"Template\" && tokenScanner.current.value.startsWith(\"`\")) {\n // First template\n wrapperCount++;\n tokenScanner.increment();\n continue;\n }\n if (tokenScanner.current.type === \"Punctuator\" && [\"(\", \"[\", \"{\"].includes(tokenScanner.current.value)) {\n // Opening brakets or parenthesis\n wrapperCount++;\n tokenScanner.increment();\n continue;\n }\n if (tokenScanner.current.type === \"Template\" && tokenScanner.current.value.endsWith(\"`\")) {\n // Closing template\n wrapperCount--;\n tokenScanner.increment();\n continue;\n }\n if (tokenScanner.current.type === \"Punctuator\" && [\")\", \"]\", \"}\"].includes(tokenScanner.current.value)) {\n // Closing brakets or parenthesis\n wrapperCount--;\n tokenScanner.increment();\n continue;\n }\n if (!wrapperCount && tokenScanner.current.type === \"Punctuator\" && tokenScanner.current.value === \",\") {\n // No inside wrappers anymore and we found a comma\n tokenScanner.increment();\n return;\n }\n\n // Skip that token\n tokenScanner.increment();\n }\n}\n\nfunction adjustComputedPropertyCompletion(dotPosition: Position, item: CompletionItem): CompletionItem {\n // Some of the object properties could be in a computed style [\"foo\"].\n // If this is the case we need to add an additional text edit to remove the dot.\n if (item.insertText && item.insertText.startsWith(\"[\")) {\n item.additionalTextEdits = [\n {\n newText: \"\",\n range: {\n start: { ...dotPosition },\n end: {\n line: dotPosition.line,\n character: dotPosition.character + 1\n }\n }\n }\n ];\n }\n\n return item;\n}\n\nfunction toParserPosition(position: Position): Parser.Position {\n return { line: position.line + 1, column: position.character };\n}\n\nfunction toDocumentPosition(position: Parser.Position): Position {\n return { line: position.line - 1, character: position.column };\n}\n","import { CompletionItem, CompletionItemKind, InsertTextFormat, InsertTextMode } from \"vscode-languageserver-types\";\nimport { ArcadeKeywords, ArcadeLiterals } from \"../languageKeywords\";\n\nexport const literalCompletions = ArcadeLiterals.map((label) => ({ label, kind: CompletionItemKind.Constant }));\nexport const keywordCompletions = ArcadeKeywords.map((label) => ({ label, kind: CompletionItemKind.Keyword }));\n\nexport const statementsSnippets: CompletionItem[] = [\n {\n label: \"exportfunction\",\n kind: CompletionItemKind.Snippet,\n detail: \"Export Function Statement\",\n insertText: \"export function ${1:functionName} ($2) {\\n\\t$0\\n}\",\n insertTextMode: InsertTextMode.adjustIndentation,\n insertTextFormat: InsertTextFormat.Snippet\n },\n {\n label: \"exportvar\",\n kind: CompletionItemKind.Snippet,\n detail: \"Export Variable Statement\",\n insertText: \"export var ${0:variableName}\\n\",\n insertTextMode: InsertTextMode.adjustIndentation,\n insertTextFormat: InsertTextFormat.Snippet\n },\n {\n label: \"for\",\n kind: CompletionItemKind.Snippet,\n detail: \"For Loop Statement\",\n insertText: \"for (var ${1:i} = 0; ${1:i} < ${2:array.length}; ${1:i}++) {\\n\\t$0\\n}\",\n insertTextMode: InsertTextMode.adjustIndentation,\n insertTextFormat: InsertTextFormat.Snippet\n },\n {\n label: \"forin\",\n kind: CompletionItemKind.Snippet,\n detail: \"For-In Loop Statement\",\n insertText: \"for (var ${1:i} in ${2:arrayOrObject}) {\\n\\t$0\\n}\",\n insertTextMode: InsertTextMode.adjustIndentation,\n insertTextFormat: InsertTextFormat.Snippet\n },\n {\n label: \"function\",\n kind: CompletionItemKind.Snippet,\n detail: \"Function Statement\",\n insertText: \"function ${1:functionName} ($2) {\\n\\t$0\\n}\",\n insertTextMode: InsertTextMode.adjustIndentation,\n insertTextFormat: InsertTextFormat.Snippet\n },\n {\n label: \"if\",\n kind: CompletionItemKind.Snippet,\n detail: \"If Statement\",\n insertText: \"if (${1:1==1}) {\\n\\t$0\\n}\",\n insertTextMode: InsertTextMode.adjustIndentation,\n insertTextFormat: InsertTextFormat.Snippet\n },\n {\n label: \"ifelse\",\n kind: CompletionItemKind.Snippet,\n detail: \"If-Else Statement\",\n insertText: \"if (${1:1==1}) {\\n\\t$0\\n} else {\\n\\t\\n}\",\n insertTextMode: InsertTextMode.adjustIndentation,\n insertTextFormat: InsertTextFormat.Snippet\n },\n {\n label: \"else\",\n kind: CompletionItemKind.Snippet,\n detail: \"Else Statement\",\n insertText: \"else {\\n\\t$0\\n}\",\n insertTextMode: InsertTextMode.adjustIndentation,\n insertTextFormat: InsertTextFormat.Snippet\n },\n {\n label: \"import\",\n kind: CompletionItemKind.Snippet,\n detail: \"Import Statement\",\n insertText: 'import ${1:namespace} from \"${0:uri}\"',\n insertTextMode: InsertTextMode.adjustIndentation,\n insertTextFormat: InsertTextFormat.Snippet\n },\n {\n label: \"while\",\n kind: CompletionItemKind.Snippet,\n detail: \"While Loop Statement\",\n insertText: \"while (${1:false}) {\\n\\t$0\\n}\",\n insertTextMode: InsertTextMode.adjustIndentation,\n insertTextFormat: InsertTextFormat.Snippet\n }\n];\n","import {\n CompletionItem,\n CompletionItemKind,\n InsertTextFormat,\n InsertTextMode,\n Position\n} from \"vscode-languageserver-types\";\nimport * as Parser from \"@arcgis/arcade-parser\";\nimport { formatString } from \"../utils\";\n\nexport { formatString };\n\nexport const sanitizingExp = /[-[\\]/{}()*+?.\\\\^$|]/g;\n\nconst IntlStrings = {\n constantFormat: \"${name} Constant\",\n propertyFormat: \"(property) ${name}\",\n parameterFormat: \"(parameter) ${name}\",\n variableFormat: \"var ${name}\",\n functionFormat: \"function ${name} (${paramsDetail})\"\n};\n\ndeclare type IdentifierMap = Map<string, IdentifierCompletionItem>;\n\ninterface IdentifierCompletionItem extends CompletionItem {\n isLiteral?: boolean; // Influence how the completion is inserted\n position: Parser.Position; // Used to rollback the identifier\n objectPropertiesMap?: IdentifierMap; // Note that null means the object is not an object expression\n previousVersion?: IdentifierCompletionItem; // Keep the previous version, used when rolling back the identifier\n}\n\ninterface IdentifierParsingResult {\n identifierMap: IdentifierMap;\n error: boolean;\n suggest: {\n snippetsAndKeywords: boolean;\n api: boolean;\n };\n}\n\n//#region Parsing Helpers\nfunction isPositionAfterLocationEndLine(position: Parser.Position, loc: Parser.SourceLocation): boolean {\n return position.line > loc.end.line;\n}\n\nfunction isPositionBeforeLocationStartLine(position: Parser.Position, loc: Parser.SourceLocation): boolean {\n return position.line < loc.start.line;\n}\n\nexport function isPositionInsideLocation(position: Parser.Position, location: Parser.SourceLocation): boolean {\n if (!location) {\n return false;\n }\n if (isPositionBeforeLocationStartLine(position, location) || isPositionAfterLocationEndLine(position, location)) {\n return false;\n }\n if (position.line === location.start.line && position.column < location.start.column) {\n return false;\n }\n if (position.line === location.end.line && position.column > location.end.column) {\n return false;\n }\n return true;\n}\n\nfunction getIdentifierLabels(node: Parser.Node): string[] {\n if (node.type === Parser.Syntax.Literal) {\n return [(node.value ?? \"\").toString()];\n }\n if (node.type === Parser.Syntax.Identifier) {\n return [node.name];\n }\n if (node.type === Parser.Syntax.MemberExpression) {\n return [...getIdentifierLabels(node.object), ...getIdentifierLabels(node.property)];\n }\n return [];\n}\n\nfunction recordIdentifierVersion(\n identifierMap: IdentifierMap,\n key: string,\n record: IdentifierCompletionItem,\n initNode?: Parser.Node | null\n): void {\n // Get the previous identifier record and keep it in case we have to restore it\n record.previousVersion = identifierMap.get(key);\n\n // Collect the object properties if the initNode is an object expression\n record.objectPropertiesMap = recordObjectProperties(identifierMap, key, initNode);\n\n // Record the identifier\n identifierMap.set(key, record);\n}\n\nfunction recordObjectProperties(\n objectPropertyMap: IdentifierMap,\n rootkey: string,\n node?: Parser.Node | null\n): IdentifierMap | undefined {\n if (!node || node.type !== Parser.Syntax.ObjectExpression) {\n return;\n }\n\n const objectProperties = new Map<string, IdentifierCompletionItem>();\n node.properties.forEach((e) => {\n if (e.key.type !== Parser.Syntax.Identifier && e.key.type !== Parser.Syntax.Literal) {\n return;\n }\n\n if (e.key.type === Parser.Syntax.Literal && typeof e.key.value !== \"string\") {\n return;\n }\n\n const label = e.key.type === Parser.Syntax.Literal ? (e.key.value as string) : e.key.name;\n const key = label.toLowerCase();\n\n const record: IdentifierCompletionItem = {\n position: e.loc.start,\n label,\n detail: formatString(IntlStrings.propertyFormat, { name: label }),\n kind: CompletionItemKind.Property,\n isLiteral: e.key.type === Parser.Syntax.Literal\n };\n\n objectProperties.set(key, record);\n\n const storingkey = `${rootkey}.${key}`;\n recordIdentifierVersion(objectPropertyMap, storingkey, record, e.value);\n });\n\n return objectProperties;\n}\n\nfunction rollbackIdentifierMap(identifierMap: IdentifierMap | undefined, exclusionLoc: Parser.SourceLocation): void {\n if (!identifierMap) {\n return;\n }\n\n identifierMap.forEach((identifierRecord, key) => {\n // Also rollback record that have object properties\n rollbackIdentifierMap(identifierRecord.objectPropertiesMap, exclusionLoc);\n\n // The record itself is not in the exclusion node\n if (!isPositionInsideLocation(identifierRecord.position, exclusionLoc)) {\n return;\n }\n\n // The identifier is inside the exclusion, delete it\n identifierMap.delete(key);\n\n // Walkback the previous versions until we find one that is not inside the exclusion node or there is no more version.\n let record = identifierRecord.previousVersion;\n while (record && isPositionInsideLocation(record.position, exclusionLoc)) {\n record = record.previousVersion;\n }\n\n // No more version\n if (!record) {\n return;\n }\n\n // Re-add the previous valid record\n identifierMap.set(key, record);\n });\n}\n\nexport function parseIdentifiers(code: string, position: Position): IdentifierParsingResult {\n //\n const suggest = {\n snippetsAndKeywords: true,\n api: true\n };\n let parsingError = false;\n const identifierMap = new Map<string, IdentifierCompletionItem>();\n\n // Note: An identifier with the same name could appear more than once in a script.\n // For example, the variable 'foo' could be defined in the global scope, then a function\n // declaration could declare 'foo' as a parameter, and finally the variable 'foo' could be\n // redeclared inside the function declaration block as well.\n // If it turns out that the suggestion is happening inside a function declaration then\n // we need the latest identifier collection with all the override. However, if the suggestion\n // is after the function declaration then we don't want any override from the function declaration.\n // The way the parser works is that we don't know that varaible declarations are happening inside\n // a function declaration. Because of this, when we find an override for a variable we will keep the\n // previous declaration related to the one in case we have to rollback (see VaraibleDeclarator and\n // FunctionDeclaration code).\n try {\n // Compute the script location\n const caretPosition: Parser.Position = {\n line: position.line + 1, // One based\n column: position.character\n };\n\n // Parse the script and use the delegate to collect identifiers and also validate\n // that we have to provide suggestions.\n Parser.parse(code, { tolerant: true }, (node: Parser.Node) => {\n // Stop if we passed the the position. The parser works in an 'inside-out' way, but\n // eventually it will pass the caret position.\n if (isPositionBeforeLocationStartLine(caretPosition, node.loc)) {\n throw new Error(\"BreakParsing\");\n }\n\n // Collect Identifier from variable declator, function declaration, and function declaration params\n switch (node.type) {\n case Parser.Syntax.VariableDeclarator:\n {\n // If the caret is actually for the identifier of the variable declarator then abort.\n // We will not make suggestions for a new identifier\n if (isPositionInsideLocation(caretPosition, node.id.loc)) {\n throw new Error();\n }\n\n // If the caret is in the init part then disable keywords and snippets\n // Don't abort yet as we need to know if we are inside a function declaration and more\n // identifiers need to be collected. We don't need to record this identifier.\n // The parser will stop when the last node of the block has been processed.\n if (node.init && isPositionInsideLocation(caretPosition, node.init.loc)) {\n suggest.snippetsAndKeywords = false;\n break;\n }\n\n // Record the identifier\n recordIdentifierVersion(\n identifierMap,\n node.id.name.toLowerCase(),\n {\n label: node.id.name,\n position: node.loc.start,\n kind: CompletionItemKind.Variable,\n detail: formatString(IntlStrings.variableFormat, { name: node.id.name })\n },\n node.init\n );\n }\n\n break;\n\n case Parser.Syntax.FunctionDeclaration:\n // If the current word is actually the identifier of the function declaration then abort\n if (isPositionInsideLocation(caretPosition, node.id.loc)) {\n throw new Error();\n }\n\n // If the function declaration is before the position\n // then record the function identifier and clean up any variable identifier\n // defined inside the scope of the function. Just step thru the identifiers and restore\n // the previous identifier if the new identifier had been defined inside the function\n // declaration\n if (!isPositionInsideLocation(caretPosition, node.loc)) {\n // if the function declaration is before the position then we need to remove all the\n // the variables that where declared inside\n rollbackIdentifierMap(identifierMap, node.loc);\n\n // Record the identifier\n const paramNames = node.params.map((param) => param.name);\n const paramsDetail = paramNames.join(\", \");\n const snippetParamsString = paramNames.map((name, idx) => `$\\{${idx + 1}:${name}}`).join(\", \");\n\n recordIdentifierVersion(identifierMap, node.id.name.toLowerCase(), {\n label: node.id.name,\n detail: formatString(IntlStrings.functionFormat, { name: node.id.name, paramsDetail }),\n position: node.loc.start,\n kind: CompletionItemKind.Function,\n insertText: `${node.id.name}(${snippetParamsString})`,\n insertTextMode: InsertTextMode.adjustIndentation,\n insertTextFormat: InsertTextFormat.Snippet\n });\n\n break;\n }\n\n // Record the parameters as identifiers\n node.params.forEach((param) => {\n if (param.type !== Parser.Syntax.Identifier) {\n return;\n }\n recordIdentifierVersion(identifierMap, param.name.toLowerCase(), {\n label: param.name,\n detail: formatString(IntlStrings.parameterFormat, { name: param.name }),\n position: param.loc.start,\n kind: CompletionItemKind.Variable\n });\n });\n\n break;\n\n case Parser.Syntax.AssignmentExpression:\n {\n // We have an assignment expression try to see if this is changing one of the recorded identifier record\n const identifierLabels = getIdentifierLabels(node.left);\n const identifierKeys = identifierLabels.map((i) => i.toLowerCase());\n if (identifierKeys.length === 0) {\n // No keys, it's over\n break;\n }\n\n if (identifierKeys.length === 1 && !identifierMap.has(identifierKeys[0])) {\n // It's a single key. Validate that it's already recorded\n break;\n }\n\n // Get the root key, it could be empty if this is not a path assignment.\n // The root key will be reused further below is a new property record was created\n const rootKey = identifierKeys.slice(0, -1).join(\".\");\n\n if (rootKey) {\n // It's a path. We need to validate that the root exists and it is a object expression\n const rootIdentifierRecord = identifierMap.get(rootKey);\n if (!rootIdentifierRecord || !rootIdentifierRecord.objectPropertiesMap) {\n break;\n }\n }\n\n // Gets the existing identifier or creates anew one\n const identifierKey = identifierKeys.join(\".\");\n const knownIdentifierRecord = identifierMap.get(identifierKey);\n let newIdentifierRecord: IdentifierCompletionItem;\n if (knownIdentifierRecord) {\n // The record already exists, duplicate it and adjust rolling back position\n newIdentifierRecord = Object.assign({}, knownIdentifierRecord);\n newIdentifierRecord.position = node.left.loc.start;\n } else {\n // The record doesn't exist, then create a new property\n const label = identifierKeys[identifierKeys.length - 1];\n newIdentifierRecord = {\n label,\n position: node.left.loc.start,\n kind: CompletionItemKind.Property,\n detail: formatString(IntlStrings.propertyFormat, { name: label })\n };\n\n // At this point we established that the parent is an object.\n // Add the new property to the parent properties\n identifierMap\n .get(rootKey)\n ?.objectPropertiesMap?.set(identifierKeys[identifierKeys.length - 1], newIdentifierRecord);\n }\n\n // The identifier init is being updated, record a new version\n recordIdentifierVersion(identifierMap, identifierKey, newIdentifierRecord, node.right);\n }\n break;\n\n case Parser.Syntax.Property:\n if (isPositionInsideLocation(caretPosition, node.key.loc)) {\n suggest.snippetsAndKeywords = false;\n suggest.api = false;\n if (!node.shorthand) {\n throw new Error();\n }\n }\n break;\n }\n });\n } catch (e: any) {\n // Multiple reasons why we ended up here:\n // - The script is partially valid and the parser has crashed. One example would be that a '.' was entered.\n // - The parsing process has established that no suggestions should be made.\n // - The parser has passed the caret. No need to continue parsing the script.\n parsingError = e.message !== \"BreakParsing\";\n }\n\n return {\n identifierMap,\n error: parsingError,\n suggest\n };\n}\n//#endregion\n","export function formatString(str: string, data?: Record<string, number | string> | null): string {\n return data ? str.replace(/\\${(.*?)}/g, (_, g) => data[g]?.toString() ?? \"\") : str;\n}\n","import { Node, Position, SourceLocation, TreeItem } from \"@arcgis/arcade-parser\";\nimport { Lines } from \"./lines\";\n\nexport function isTreeItem(item: TreeItem | unknown): item is TreeItem {\n return (item as TreeItem)?.type !== undefined;\n}\n\nexport function comparePosition(pos1: Position, pos2: Position): number {\n return pos1.line - pos2.line || pos1.column - pos2.column;\n}\n\nexport function getTrueLocation(node: Node, lines: Lines): SourceLocation {\n const result = {\n start: node.loc.start,\n end: node.loc.end\n };\n\n function include(node: any) {\n expandLoc(result, node.loc);\n }\n\n if (comparePosition(result.start, result.end) < 0) {\n // Trim leading whitespace.\n result.start = { ...result.start };\n lines.skipSpaces(result.start);\n\n if (comparePosition(result.start, result.end) < 0) {\n // Trim trailing whitespace, if the end location is not already the\n // same as the start location.\n result.end = { ...result.end };\n lines.skipSpaces(result.end, true);\n }\n }\n\n // If the node has any comments, their locations might contribute to\n // the true start/end positions of the node.\n node.leadingComments?.forEach(include);\n node.trailingComments?.forEach(include);\n\n return result;\n}\n\nfunction expandLoc(parentLoc: SourceLocation, childLoc: SourceLocation): void {\n if (parentLoc && childLoc) {\n if (comparePosition(childLoc.start, parentLoc.start) < 0) {\n parentLoc.start = childLoc.start;\n }\n\n if (comparePosition(parentLoc.end, childLoc.end) < 0) {\n parentLoc.end = childLoc.end;\n }\n }\n}\n\nexport function isOnlyWhitespace(string: string): boolean {\n return !/\\S/.test(string ?? \"\");\n}\n","/**\n * Describes the formatting options\n */\nexport interface FormattingOptions {\n /**\n * Number of spaces the formatter should use for indentation.\n * If you do not pass this option explicitly, it will be\n * (quite reliably!) inferred from the original code.\n * @default 2\n */\n indentWidth?: number;\n\n /**\n * Some of the formatter code (such as that for printing function\n * parameter lists) makes a valiant attempt to prevent really long\n * lines. You can adjust the limit by changing this option; however,\n * there is no guarantee that line length will fit inside this limit.\n * @default 80\n */\n wrapColumn?: number;\n\n /**\n * If you want to override the quotes used in string literals, specify\n * either \"single\", \"double\", or \"auto\" here (\"auto\" will select the one\n * which results in the shorter literal) Otherwise, use double quotes.\n * @default null\n */\n quote?: \"single\" | \"double\" | \"auto\" | null;\n}\n\nconst DefaultFormattingOptions: Required<FormattingOptions> = {\n indentWidth: 2,\n wrapColumn: 80,\n quote: null\n} as const;\n\n// Copy options and fill in default values.\nexport function normalizeFormattingOptions(options?: FormattingOptions): Required<FormattingOptions> {\n return {\n indentWidth: options?.indentWidth ?? DefaultFormattingOptions.indentWidth,\n wrapColumn: options?.wrapColumn ?? DefaultFormattingOptions.wrapColumn,\n quote: options?.quote ?? DefaultFormattingOptions.quote\n };\n}\n","import { Position } from \"@arcgis/arcade-parser\";\nimport { FormattingOptions } from \"./options\";\nimport { isOnlyWhitespace } from \"./utils\";\n\nexport type LinesLike = string | Lines;\n\n// Goals:\n// 1. Minimize new string creation.\n// 2. Keep (de)identation O(lines) time.\n// 3. Permit negative indentations.\n// 4. Enforce immutability.\n// 5. No newline characters.\n\ninterface LineRecord {\n line: string;\n indentation: number;\n sliceStart: number;\n sliceEnd: number;\n}\n\nconst leadingSpaceExp = /^\\s*/;\n\n// As specified here: http://www.ecma-international.org/ecma-262/6.0/#sec-line-terminators\n/* eslint-disable-next-line no-control-regex */\nconst lineTerminatorSeqExp = /\\u000D\\u000A|\\u000D(?!\\u000A)|\\u000A|\\u2028|\\u2029/;\n\nexport class Lines {\n public readonly length: number;\n // private cachedIndentWidth: number | void = void 0;\n\n constructor(private lineRecords: Readonly<LineRecord>[]) {\n this.length = lineRecords.length;\n }\n\n // private static emptyLines = this.fromString(\"\");\n\n static fromString(string: LinesLike, options?: FormattingOptions): Lines {\n if (typeof string !== \"string\") {\n return string;\n }\n\n const indentWitdth = options?.indentWidth;\n const lines = new Lines(\n string.split(lineTerminatorSeqExp).map(function (line) {\n const spaces = leadingSpaceExp.exec(line)?.[0] ?? \"\";\n return {\n line: line,\n indentation: countSpaces(spaces, indentWitdth),\n // Boolean indicating whether this line can be reindented.\n locked: false,\n sliceStart: spaces.length,\n sliceEnd: line.length\n };\n })\n );\n\n return lines;\n }\n\n toString(): string {\n return this.sliceString(this.firstPos(), this.lastPos());\n }\n\n private charAt(pos: Position): string {\n const { line, column } = pos;\n const lineRecord = this.lineRecords[line - 1];\n if (typeof lineRecord === \"undefined\" || column < 0) {\n return \"\";\n }\n\n const indentation = this.getIndentationAt(line);\n if (column < indentation) {\n return \" \";\n }\n\n const index = column + lineRecord.sliceStart - indentation;\n if (index === lineRecord.sliceEnd && line < this.length) {\n return \"\\n\";\n }\n if (index >= lineRecord.sliceEnd) {\n return \"\";\n }\n\n return lineRecord.line.charAt(index);\n }\n\n private getIndentationAt(lineIndex: number): number {\n return Math.max(this.lineRecords[lineIndex - 1].indentation, 0);\n }\n\n private getLineLength(lineNumber: number): number {\n const lineRecord = this.lineRecords[lineNumber - 1];\n return this.getIndentationAt(lineNumber) + lineRecord.sliceEnd - lineRecord.sliceStart;\n }\n\n getStatementLineSeparators(endPosition: Position): string[] {\n const trailingSpace = this.slice(endPosition, this.skipSpaces({ ...endPosition }) || this.lastPos());\n if (trailingSpace.length === 1 || !isOnlyWhitespace(trailingSpace.lineRecords[1].line)) {\n return [\"\\n\"];\n }\n return [\"\\n\", \"\\n\"];\n }\n\n getLeadingCommentSeparators(endPosition: Position): string[] {\n const trailingSpace = this.slice(endPosition, this.skipSpaces({ ...endPosition }) || this.lastPos());\n if (trailingSpace.length === 1) {\n return [\" \"];\n }\n\n if (!isOnlyWhitespace(trailingSpace.lineRecords[1].line)) {\n return [\"\\n\"];\n }\n return [\"\\n\", \"\\n\"];\n }\n\n private nextPos(pos: Position, skipSpaces = false): boolean {\n const lineIndex = Math.max(pos.line, 0),\n columnIndex = Math.max(pos.column, 0);\n\n if (columnIndex < this.getLineLength(lineIndex)) {\n pos.column += 1;\n return skipSpaces ? !!this.skipSpaces(pos) : true;\n }\n\n if (lineIndex < this.length) {\n pos.line += 1;\n pos.column = 0;\n return skipSpaces ? !!this.skipSpaces(pos) : true;\n }\n\n return false;\n }\n\n private prevPos(pos: Position, skipSpaces = false): boolean {\n let lineIndex = pos.line,\n columnIndex = pos.column;\n\n if (columnIndex < 1) {\n lineIndex -= 1;\n if (lineIndex < 1) {\n return false;\n }\n\n columnIndex = this.getLineLength(lineIndex);\n } else {\n columnIndex = Math.min(columnIndex - 1, this.getLineLength(lineIndex));\n }\n\n pos.line = lineIndex;\n pos.column = columnIndex;\n\n return skipSpaces ? !!this.skipSpaces(pos, true) : true;\n }\n\n private firstPos(): Position {\n // Trivial, but provided for completeness.\n return { line: 1, column: 0 };\n }\n\n private lastPos(): Position {\n return {\n line: this.length,\n column: this.getLineLength(this.length)\n };\n }\n\n skipSpaces(pos: Position, backward = false): Position | null {\n if (!pos) {\n pos = backward ? this.lastPos() : this.firstPos();\n }\n\n if (backward) {\n while (this.prevPos(pos)) {\n if (!isOnlyWhitespace(this.charAt(pos)) && this.nextPos(pos)) {\n return pos;\n }\n }\n\n return null;\n } else {\n while (isOnlyWhitespace(this.charAt(pos))) {\n if (!this.nextPos(pos)) {\n return null;\n }\n }\n\n return pos;\n }\n }\n\n private slice(start?: Position, end?: Position): Lines | never {\n if (!end && !start) {\n return this;\n }\n\n // Slice to the end if no end position was provided.\n end = end ?? this.lastPos();\n\n if (!start) {\n throw new Error(\"cannot slice with end but not start\");\n }\n\n const slicedLineRecords = this.lineRecords.slice(start.line - 1, end.line);\n if (start.line === end.line) {\n slicedLineRecords[0] = sliceLineRecord(slicedLineRecords[0], start.column, end.column);\n } else {\n slicedLineRecords[0] = sliceLineRecord(slicedLineRecords[0], start.column);\n slicedLineRecords.push(sliceLineRecord(slicedLineRecords.pop() ?? slicedLineRecords[0], 0, end.column));\n }\n\n return new Lines(slicedLineRecords);\n }\n\n private sliceString(start = this.firstPos(), end = this.lastPos()): string {\n const parts: string[] = [];\n for (let line = start.line; line <= end.line; ++line) {\n let lineRecord = this.lineRecords[line - 1];\n if (line === start.line) {\n if (line === end.line) {\n lineRecord = sliceLineRecord(lineRecord, start.column, end.column);\n } else {\n lineRecord = sliceLineRecord(lineRecord, start.column);\n }\n } else if (line === end.line) {\n lineRecord = sliceLineRecord(lineRecord, 0, end.column);\n }\n\n let result = \"\";\n\n const indentation = Math.max(lineRecord.indentation, 0);\n if (indentation > 0) {\n result += new Array(indentation + 1).join(\" \");\n }\n\n result += lineRecord.line.slice(lineRecord.sliceStart, lineRecord.sliceEnd);\n\n parts.push(result);\n }\n\n return parts.join(\"\\n\");\n }\n}\n\nfunction countSpaces(spaces: string, indentWidth = 2): number {\n let count = 0;\n const len = spaces.length;\n\n for (let i = 0; i < len; ++i) {\n switch (spaces.charCodeAt(i)) {\n case 9: {\n // '\\t'\n const next = Math.ceil(count / indentWidth) * indentWidth;\n if (next === count) {\n count += indentWidth;\n } else {\n count = next;\n }\n\n break;\n }\n\n case 11: // '\\v'\n case 12: // '\\f'\n case 13: // '\\r'\n case 0xfeff: // zero-width non-breaking space\n // These characters contribute nothing to indentation.\n break;\n\n case 32: // ' '\n default:\n // Treat all other whitespace like ' '.\n count += 1;\n break;\n }\n }\n\n return count;\n}\n\nfunction sliceLineRecord(lineRecord: LineRecord, startCol: number, endCol?: number): LineRecord {\n let sliceStart = lineRecord.sliceStart;\n let sliceEnd = lineRecord.sliceEnd;\n let indentation = Math.max(lineRecord.indentation, 0);\n let lineLength = indentation + sliceEnd - sliceStart;\n\n endCol = endCol ?? lineLength;\n startCol = Math.max(startCol, 0);\n endCol = Math.min(endCol, lineLength);\n endCol = Math.max(endCol, startCol);\n\n if (endCol < indentation) {\n indentation = endCol;\n sliceEnd = sliceStart;\n } else {\n sliceEnd -= lineLength - endCol;\n }\n\n lineLength = endCol;\n lineLength -= startCol;\n\n if (startCol < indentation) {\n indentation -= startCol;\n } else {\n startCol -= indentation;\n indentation = 0;\n sliceStart += startCol;\n }\n\n if (\n lineRecord.indentation === indentation &&\n lineRecord.sliceStart === sliceStart &&\n lineRecord.sliceEnd === sliceEnd\n ) {\n return lineRecord;\n }\n\n return {\n line: lineRecord.line,\n indentation: indentation,\n sliceStart: sliceStart,\n sliceEnd: sliceEnd\n };\n}\n","import * as Parser from \"@arcgis/arcade-parser\";\nimport { FormattingOptions, normalizeFormattingOptions } from \"./options\";\n\n//#region FormattedLines classes\nfunction join(left: string, separator: string, right: string): string {\n if (!left && !right) {\n return \"\";\n }\n if (!left) {\n return right;\n }\n if (!right) {\n return left;\n }\n\n return left + (separator ?? \"\") + right;\n}\n\n/* eslint-disable-next-line no-control-regex */\nconst lineTerminatorSeqExp = /\\u000D\\u000A|\\u000D(?!\\u000A)|\\u000A|\\u2028|\\u2029/;\n\nexport class FormattedLines {\n constructor(private lines: string[] = []) {}\n\n static fromString(string: string): FormattedLines {\n return new FormattedLines(string.split(lineTerminatorSeqExp));\n }\n\n /**\n * Append the elements lines together into a new FormattedLines.\n * [ [a, b], c, [ d, e]] => [a, b, c, d, e]\n * @param elements\n * @returns\n */\n static appendLines(elements: (string | FormattedLines | null | undefined)[] = []): FormattedLines {\n const result = new FormattedLines();\n elements.forEach((element) => {\n if (element === null || element === undefined) {\n return;\n }\n if (typeof element === \"string\") {\n result.lines.push(element);\n } else {\n result.lines.push(...element.lines);\n }\n });\n return result;\n }\n\n /**\n * Join the last line of each element to the first line of the next element.\n * [ [a, b], c, [ d, e]] => [a, bcd, e]\n * With separator:\n * [ [a, b], c, [ d, e]] => [a, b<sep>c<sep>d, e]\n * @param elements\n * @returns\n */\n static joinLines(elements: (string | FormattedLines | null | undefined)[] = [], separator = \"\"): FormattedLines {\n const result = new FormattedLines();\n\n elements.forEach((element) => {\n if (element === null || element === undefined) {\n return;\n }\n const concatLine = result.lines.pop() ?? \"\";\n if (typeof element === \"string\") {\n result.lines.push(join(concatLine, separator, element));\n } else {\n result.lines.push(join(concatLine, separator, element.lines.slice(0)[0]));\n result.lines.push(...element.lines.slice(1));\n }\n });\n return result;\n }\n\n /**\n * Aggregates formatted lines coming from two expressions, statements, or commments.\n * Use the location of each to figure out if they are on the same line or different lines.\n * Also reduce the number of empty lines.\n * @param previousFormattedLines\n * @param previousLocation\n * @param formattedLines\n * @param location\n * @param indentation\n * @returns\n */\n static aggregateLines(\n previousFormattedLines: FormattedLines,\n previousLocation: Parser.SourceLocation | undefined,\n formattedLines: FormattedLines,\n location: Parser.SourceLocation,\n indentation: string\n ): FormattedLines {\n if (!formattedLines || formattedLines.isEmpty) {\n return previousFormattedLines;\n }\n\n if (!previousLocation || !previousFormattedLines || previousFormattedLines.isEmpty) {\n return formattedLines.indentFirstLine(indentation);\n }\n\n const inBetweenEmptyLinesCount = location.start.line - previousLocation.end.line;\n if (inBetweenEmptyLinesCount === 0) {\n // Items on the same line, join the lines with a space\n return FormattedLines.joinLines([previousFormattedLines, \" \", formattedLines]);\n }\n\n // Items on different lines, the spacer will reduce the unecessary empty lines\n const spacer = inBetweenEmptyLinesCount === 1 ? undefined : \"\";\n return FormattedLines.appendLines([previousFormattedLines, spacer, formattedLines.indentFirstLine(indentation)]);\n }\n\n get isEmpty(): boolean {\n return this.lines.length === 0 || (this.lines.length === 1 && this.lines[0].length === 0);\n }\n\n get maxLineLength(): number {\n return this.lines.reduce((length, line) => Math.max(length, line.length), 0);\n }\n\n get firstLinelength(): number {\n return (this.lines[0] ?? \"\").length;\n }\n\n get lastLinelength(): number {\n return (this.lines[this.lines.length - 1] ?? \"\").length;\n }\n\n surroundWith(prefix = \"\", suffix = \"\"): FormattedLines {\n if (!prefix && !suffix) {\n return this;\n }\n\n if (this.isEmpty) {\n return new FormattedLines([prefix + suffix]);\n }\n\n if (this.lines.length === 1) {\n return new FormattedLines([prefix + this.lines[0] + suffix]);\n }\n\n return FormattedLines.joinLines([prefix, this, suffix]);\n }\n\n indentFirstLine(indentation = \"\"): FormattedLines {\n if (this.isEmpty) {\n return this;\n }\n this.lines[0] = indentation + this.lines[0];\n return this;\n }\n\n suffixWith(suffix: string): FormattedLines {\n return this.surroundWith(\"\", suffix);\n }\n\n toString(separator = \"\\n\"): string {\n return this.lines.join(separator);\n }\n}\n//#endregion\n\n//#region Helpers\nexport function indentLength(level: number, options: FormattingOptions): number {\n return level * (options.indentWidth ?? 2);\n}\n\nexport function getIndent(level = 0, options?: FormattingOptions): string {\n const { indentWidth = 2 } = normalizeFormattingOptions(options);\n return new Array(level * indentWidth + 1).join(\" \");\n}\n\nfunction swapQuotes(str: string): string {\n return str.replace(/['\"]/g, (m) => (m === '\"' ? \"'\" : '\"'));\n}\n\nfunction needsParentheses(node: Parser.Node, parent: Parser.Node): boolean {\n if (!node || !parent) {\n return false;\n }\n\n switch (node.type) {\n case Parser.Syntax.UnaryExpression:\n return Parser.isMemberExpression(parent) && parent.object === node;\n\n case Parser.Syntax.BinaryExpression:\n case Parser.Syntax.LogicalExpression:\n switch (parent.type) {\n case Parser.Syntax.UnaryExpression:\n return true;\n\n case Parser.Syntax.MemberExpression:\n return parent.object === node;\n\n case Parser.Syntax.BinaryExpression:\n case Parser.Syntax.LogicalExpression:\n // @ts-expect-error\n return Parser.OperatorPrecedence[parent.operator] > Parser.OperatorPrecedence[node.operator];\n\n default:\n return false;\n }\n\n case Parser.Syntax.Literal:\n return Parser.isMemberExpression(parent) && typeof node.value === \"number\" && parent.object === node;\n\n case Parser.Syntax.AssignmentExpression:\n switch (parent.type) {\n case Parser.Syntax.UnaryExpression:\n case Parser.Syntax.BinaryExpression:\n case Parser.Syntax.LogicalExpression:\n case Parser.Syntax.ReturnStatement:\n return true;\n\n case Parser.Syntax.MemberExpression:\n return parent.object === node;\n\n default:\n return false;\n }\n\n default:\n return false;\n }\n}\n//#endregion\n\n//#region Factory\nexport function createExpressionPrinter(\n node: Parser.Expression | Parser.VariableDeclaration | null | undefined,\n parent: Parser.Node,\n options: Required<FormattingOptions>\n): Printer | never {\n switch (node?.type) {\n case Parser.Syntax.BinaryExpression:\n case Parser.Syntax.LogicalExpression:\n return createBinaryLogicalExpressionPrinter(node, parent, options);\n\n case Parser.Syntax.AssignmentExpression:\n return new OperationPrinter(node, parent, options);\n\n case Parser.Syntax.MemberExpression:\n return new MemberExpressionPrinter(node, parent, options);\n\n case Parser.Syntax.Identifier:\n return new StringPrinter(node, parent, options);\n\n case Parser.Syntax.CallExpression:\n return new CallExpressionPrinter(node, parent, options);\n\n case Parser.Syntax.ObjectExpression:\n return createCollectionPrinter(node, parent, options);\n\n case Parser.Syntax.ArrayExpression:\n return createCollectionPrinter(node, parent, options);\n\n case Parser.Syntax.Literal:\n return new StringPrinter(node, parent, options);\n\n case Parser.Syntax.UpdateExpression:\n case Parser.Syntax.UnaryExpression:\n return new SingleExpressionPrinter(node, parent, options);\n\n case Parser.Syntax.TemplateLiteral:\n return new TemplateLiteralPrinter(node, parent, options);\n\n case Parser.Syntax.VariableDeclaration:\n // Special case. We need to treat the variable declaration as a specialized expression\n return new VariableDeclaratorsPrinter(node, parent, options);\n\n default:\n throw new Error(\"unknown type: \" + JSON.stringify(node));\n }\n}\n\ntype CollectionTypes =\n | Parser.ArrayExpression\n | Parser.ForStatement\n | Parser.ForInStatement\n | Parser.FunctionDeclaration\n | Parser.IfStatement\n | Parser.ObjectExpression\n | Parser.VariableDeclaration\n | Parser.WhileStatement;\n\nexport function createCollectionPrinter(\n node: CollectionTypes,\n parent: Parser.Node,\n options: Required<FormattingOptions>\n): CollectionPrinter {\n const collectionPrinter = new CollectionPrinter(node, parent, options);\n switch (node?.type) {\n case Parser.Syntax.ArrayExpression:\n collectionPrinter.setupCollection(\n node.elements.map((expression) => createExpressionPrinter(expression, node, options)),\n \"SquareBrackets\"\n );\n return collectionPrinter;\n\n case Parser.Syntax.ObjectExpression:\n collectionPrinter.setupCollection(\n node.properties?.map((property) => new PropertyPrinter(property, node, options)),\n \"CurlyBrackets\"\n );\n return collectionPrinter;\n\n case Parser.Syntax.VariableDeclaration:\n collectionPrinter.prefix = \"var \";\n collectionPrinter.setupCollection(\n node.declarations?.map((declaration) => createVariableDeclaratorPrinter(declaration, node, options)),\n \"None\"\n );\n return collectionPrinter;\n\n case Parser.Syntax.FunctionDeclaration:\n collectionPrinter.prefix = `function ${node.id.name}`;\n collectionPrinter.setupCollection(\n node.params.map((param) => createExpressionPrinter(param, node, options)),\n \"Parentheses\"\n );\n return collectionPrinter;\n\n case Parser.Syntax.ForStatement:\n collectionPrinter.prefix = \"for \";\n collectionPrinter.setupCollection(\n [\n createExpressionPrinter(node.init, node, options),\n createExpressionPrinter(node.test, node, options),\n createExpressionPrinter(node.update, node, options)\n ],\n \"Parentheses\",\n \";\"\n );\n return collectionPrinter;\n\n case Parser.Syntax.ForInStatement:\n collectionPrinter.prefix = \"for \";\n collectionPrinter.setupCollection([new OperationPrinter(node, parent, options)], \"Parentheses\", \"\");\n return collectionPrinter;\n\n case Parser.Syntax.IfStatement:\n collectionPrinter.prefix = \"if \";\n collectionPrinter.setupCollection([createExpressionPrinter(node.test, node, options)], \"Parentheses\", \"\");\n return collectionPrinter;\n\n case Parser.Syntax.WhileStatement:\n collectionPrinter.prefix = \"while \";\n collectionPrinter.setupCollection([createExpressionPrinter(node.test, node, options)], \"Parentheses\", \"\");\n return collectionPrinter;\n\n default:\n return collectionPrinter;\n }\n}\n\nfunction createVariableDeclaratorPrinter(\n node: Parser.VariableDeclarator,\n parent: Parser.VariableDeclaration,\n options: Required<FormattingOptions>\n): StringPrinter | OperationPrinter {\n if (!node.init) {\n return new StringPrinter(node.id, parent, options);\n }\n return new OperationPrinter(node, parent, options);\n}\n\nfunction createBinaryLogicalExpressionPrinter(\n node: Parser.BinaryExpression | Parser.LogicalExpression,\n parent: Parser.Node,\n options: Required<FormattingOptions>\n) {\n // // If both left and right are not Logical or Binary expressions then fallback to a single\n // // operation printer otherwise use a collection printer after regrouping all the same level\n // const leftIsLogicalOrBinary = Parser.isBinaryExpression(node.left) || Parser.isLogicalExpression(node.left);\n // const rightIsLogicalOrBinary = Parser.isBinaryExpression(node.right) || Parser.isLogicalExpression(node.right);\n // if (!leftIsLogicalOrBinary && !rightIsLogicalOrBinary) {\n // return new OperationPrinter(node, parent, options);\n // }\n\n // Binary or Logical expression are always starting from the\n // lower order of precedence of operators. Try to regroup all the same operators\n // together\n const regroupedExpressions = [\n ...regroupSameOperatorExpressions(node.left, node.operator),\n ...regroupSameOperatorExpressions(node.right, node.operator)\n ];\n\n // Make sure the parent is this node\n const printers = regroupedExpressions.map((expression) => createExpressionPrinter(expression, node, options));\n\n const printer = new CollectionPrinter(node, parent, options);\n printer.setupCollection(printers, \"None\", \" \" + node.operator);\n return printer;\n}\n\nfunction regroupSameOperatorExpressions(node: Parser.Expression, operator: string): Parser.Expression[] {\n if (node.type !== Parser.Syntax.BinaryExpression && node.type !== Parser.Syntax.LogicalExpression) {\n return [node];\n }\n\n if (node.operator !== operator) {\n return [node];\n }\n\n return [\n ...regroupSameOperatorExpressions(node.left, operator),\n ...regroupSameOperatorExpressions(node.right, operator)\n ];\n}\n\n//#endregion\n\n//#region Expression Printers\ntype PrintStyle = \"singleLine\" | \"multiline\";\n\ninterface FormattingInterface {\n format(style?: PrintStyle, level?: number): FormattedLines;\n}\n\nexport abstract class Printer implements FormattingInterface {\n prefix = \"\";\n suffix = \"\";\n\n private groupingParentheses = false;\n\n constructor(\n public node: Parser.Node,\n public parent: Parser.Node,\n public options: FormattingOptions\n ) {\n this.groupingParentheses = needsParentheses(node, parent);\n }\n\n protected get openingParenthesis(): string {\n return this.groupingParentheses ? \"(\" : \"\";\n }\n\n protected get closingParenthesis(): string {\n return this.groupingParentheses ? \")\" : \"\";\n }\n\n protected get leadingString(): string {\n return [this.prefix, this.openingParenthesis].join(\"\");\n }\n\n protected get trailingString(): string {\n return [this.closingParenthesis, this.suffix].join(\"\");\n }\n\n protected finalize(formattedLines: FormattedLines | string): FormattedLines {\n if (typeof formattedLines === \"string\") {\n formattedLines = FormattedLines.fromString(formattedLines);\n }\n return formattedLines.surroundWith(this.leadingString, this.trailingString);\n }\n\n abstract format(style?: PrintStyle, level?: number): FormattedLines;\n}\n\ntype BracketsType = \"Parentheses\" | \"SquareBrackets\" | \"CurlyBrackets\" | \"None\";\n\n/**\n * Many of the expressions can be represented as a collection with a prefix and some brackets.\n * For example a Function Declaration is a prefix, parentheses and a collection of identifiers.\n * A Call Expression, or a Variable Declaration are also collection.\n */\nexport class CollectionPrinter extends Printer {\n type = \"CollectionPrinter\" as const;\n\n private bracketsType: BracketsType = \"None\";\n private separator = \",\";\n private printers: Printer[] = [];\n\n constructor(\n override node: Parser.Node,\n override parent: Parser.Node,\n override options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n }\n\n public setupCollection(\n printers: Printer[] = [],\n bracketsType: BracketsType = \"None\",\n separator?: string\n ): CollectionPrinter {\n this.bracketsType = bracketsType ?? this.bracketsType;\n this.separator = separator ?? this.separator;\n this.printers = printers;\n return this;\n }\n\n private getOpeningBracket(isEmpty = false, style: PrintStyle = \"singleLine\"): string {\n if (this.bracketsType === \"None\") {\n return \"\";\n }\n\n if (this.bracketsType === \"CurlyBrackets\") {\n const space = isEmpty || style === \"multiline\" ? \"\" : \" \";\n return \"{\" + space;\n }\n\n switch (this.bracketsType) {\n case \"Parentheses\":\n return \"(\";\n\n case \"SquareBrackets\":\n return \"[\";\n\n default:\n return \"\";\n }\n }\n\n private getClosingBracket(isEmpty = false, style: PrintStyle = \"singleLine\"): string {\n if (this.bracketsType === \"None\") {\n return \"\";\n }\n\n if (this.bracketsType === \"CurlyBrackets\") {\n const space = isEmpty || style === \"multiline\" ? \"\" : \" \";\n return space + \"}\";\n }\n\n switch (this.bracketsType) {\n case \"Parentheses\":\n return \")\";\n\n case \"SquareBrackets\":\n return \"]\";\n\n default:\n return \"\";\n }\n }\n\n private getLinesLevel(level = 0): number {\n // When we have brackets, the line level is always incremented\n if (this.bracketsType !== \"None\") {\n return level + 1;\n }\n\n // We are in the case of no brackets. This is valid for\n // - Variable Declaration\n // - Logical and Binary Expressions\n // There are few cases for which we need to increment the level.\n // Collections with no brackets never indent the first line of the collection.\n // It's up to the parent to indent.\n\n // If this is a collection directly owned by an Expression Statement then\n // we need to increment the level.\n if (Parser.isExpressionStatement(this.parent) || Parser.isVariableDeclarator(this.parent)) {\n return level + 1;\n }\n\n // If the collection is a child of another Logical or Binary Expression\n if (\n (Parser.isLogicalExpression(this.node) || Parser.isBinaryExpression(this.node)) &&\n (Parser.isLogicalExpression(this.parent) || Parser.isBinaryExpression(this.parent))\n ) {\n return level + 1;\n }\n\n return level;\n }\n\n override finalize(formattedLines: FormattedLines, style: PrintStyle = \"singleLine\", level = 0): FormattedLines {\n if (this.bracketsType === \"None\") {\n return super.finalize(formattedLines);\n }\n\n const openingBracket = this.getOpeningBracket(formattedLines.isEmpty, style);\n const closingBracket = this.getClosingBracket(formattedLines.isEmpty, style);\n if (style === \"singleLine\") {\n return super.finalize(formattedLines.surroundWith(openingBracket, closingBracket));\n }\n\n const indentation = getIndent(level, this.options);\n return super.finalize(FormattedLines.appendLines([openingBracket, formattedLines, indentation + closingBracket]));\n }\n\n private singleLineFormat(level = 0): FormattedLines {\n const lastIndex = this.printers.length - 1;\n return FormattedLines.joinLines(\n this.printers.map((printer, i) =>\n printer.format(\"singleLine\", level).suffixWith(i < lastIndex ? this.separator : \"\")\n ),\n \" \"\n );\n }\n\n private optimizedPrinterFormat(printer: Printer, index: number, collectionLevel = 0): FormattedLines {\n // In multiline mode, items are normally indented by 1, however there are sepcial rules for\n // collection without brackets\n const lineLevel = this.getLinesLevel(collectionLevel);\n\n // The line indentation represents the normal indentation for the level.\n // There is an exception for collections without brackets (see below)\n const lineIndentation = getIndent(lineLevel, this.options);\n\n // If we have no brackets, then we don't indent the first line. This is the case for\n // expressions such as Variable Declaration, Logical or Binary Expressions.\n const indentation = this.bracketsType === \"None\" && index === 0 ? \"\" : lineIndentation;\n\n // The last line doesn't have a spearator\n const separator = index < this.printers.length - 1 ? this.separator : \"\";\n\n // Try to see if the single line would fit\n const singleLine = printer.format(\"singleLine\", lineLevel).suffixWith(separator);\n if (singleLine.maxLineLength + lineIndentation.length <= this.options.wrapColumn) {\n return singleLine.indentFirstLine(indentation);\n }\n\n // Single line doesn't fit, request the line to be multiline.\n return printer.format(\"multiline\", lineLevel).suffixWith(separator).indentFirstLine(indentation);\n }\n\n private multilineFormat(level = 0): FormattedLines {\n return FormattedLines.appendLines(\n this.printers.map((printer, i) => this.optimizedPrinterFormat(printer, i, level))\n );\n }\n\n format(style: PrintStyle = \"singleLine\", level = 0): FormattedLines {\n if (this.printers.length === 0) {\n const openingBracket = this.getOpeningBracket(true, style);\n const closingBracket = this.getClosingBracket(true, style);\n return super.finalize(FormattedLines.fromString(openingBracket + closingBracket));\n }\n\n if (style === \"singleLine\") {\n const formattedLines = this.singleLineFormat(level);\n return this.finalize(formattedLines, style, level);\n }\n\n const formattedLines = this.multilineFormat(level);\n return this.finalize(formattedLines, style, level);\n }\n}\n\nconst validIndentifer = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;\n\nexport class StringPrinter extends Printer {\n type = \"StringPrinter\" as const;\n\n constructor(\n override node: Parser.Identifier | Parser.Literal,\n override parent: Parser.Node,\n override options: FormattingOptions\n ) {\n super(node, parent, options);\n }\n\n format(): FormattedLines {\n if (Parser.isIdentifier(this.node)) {\n return this.finalize(this.node.name ?? \"\");\n }\n\n if (typeof this.node.value !== \"string\") {\n return this.finalize(this.node.raw ?? \"\");\n }\n\n if (\n Parser.isProperty(this.parent) &&\n this.parent.key == this.node &&\n Parser.isLiteral(this.node) &&\n typeof this.node.value === \"string\" &&\n validIndentifer.test(this.node.value)\n ) {\n return this.finalize(this.node.value);\n }\n\n switch (this.options.quote) {\n case \"auto\": {\n const doubleQuoted = JSON.stringify(this.node.value);\n const singleQuoted = swapQuotes(JSON.stringify(swapQuotes(this.node.value)));\n return this.finalize(doubleQuoted.length > singleQuoted.length ? singleQuoted : doubleQuoted);\n }\n case \"single\":\n return this.finalize(swapQuotes(JSON.stringify(swapQuotes(this.node.value))));\n\n default:\n return this.finalize(JSON.stringify(this.node.value));\n }\n }\n}\n\nexport class SingleExpressionPrinter extends Printer {\n type = \"SingleExpressionPrinter\" as const;\n private printer: Printer;\n\n constructor(\n override node: Parser.Expression,\n override parent: Parser.Node,\n override options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n\n const isUnary = Parser.isUnaryExpression(node);\n const isUpdate = Parser.isUpdateExpression(node);\n if (isUnary || isUpdate) {\n this.prefix = isUnary && node.prefix ? node.operator : \"\";\n this.suffix = isUpdate && !node.prefix ? node.operator : \"\";\n\n this.printer = createExpressionPrinter(node.argument, node, this.options);\n return;\n }\n\n this.printer = createExpressionPrinter(node, parent, this.options);\n }\n\n format(style: PrintStyle = \"singleLine\", level = 0): FormattedLines {\n if (!this.printer) {\n return new FormattedLines();\n }\n return this.finalize(this.printer.format(style, level));\n }\n}\n\nexport class VariableDeclaratorsPrinter extends Printer {\n type = \"VariableDeclaratorsPrinter\" as const;\n private printer: StringPrinter | OperationPrinter | CollectionPrinter;\n\n constructor(\n override node: Parser.VariableDeclaration,\n override parent: Parser.Node,\n override options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n\n if (node.declarations.length === 1) {\n this.printer = createVariableDeclaratorPrinter(node.declarations[0], node, this.options);\n this.printer.prefix = \"var \";\n } else {\n this.printer = createCollectionPrinter(node, parent, this.options);\n }\n }\n\n format(style: PrintStyle = \"singleLine\", level = 0): FormattedLines {\n return this.finalize(this.printer.format(style, level));\n }\n}\n\nexport class CallExpressionPrinter extends Printer {\n type = \"CallExpressionPrinter\" as const;\n private argumentsPrinter: CollectionPrinter;\n private memberExpressionPrinter: MemberExpressionPrinter | undefined;\n\n constructor(\n override node: Parser.CallExpression,\n override parent: Parser.Node,\n override options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n\n // For both case, arguments will be a collection printer\n this.argumentsPrinter = new CollectionPrinter(node, parent, options);\n this.argumentsPrinter.setupCollection(\n node.arguments?.map((expression) => createExpressionPrinter(expression, node, options)),\n \"Parentheses\"\n );\n\n if (Parser.isIdentifier(node.callee)) {\n // If the callee is an identifier, we can simplify the formatting by using the collection prefix\n this.argumentsPrinter.prefix = node.callee.name;\n } else {\n // Create a printer for the member expression\n this.memberExpressionPrinter = new MemberExpressionPrinter(node.callee, parent, options);\n }\n }\n\n format(style: PrintStyle = \"singleLine\", level = 0): FormattedLines {\n if (!this.memberExpressionPrinter) {\n return this.finalize(this.argumentsPrinter.format(style, level));\n }\n\n let memberExpression = this.memberExpressionPrinter.format(\"singleLine\", level);\n let callArguments = this.argumentsPrinter.format(\"singleLine\", level);\n if (style === \"singleLine\") {\n return this.finalize(FormattedLines.joinLines([memberExpression, callArguments]));\n }\n\n // Multiline is requested\n\n // Multiline the arguments if the member expression fits on a single line\n let memberExpressionLength =\n indentLength(level, this.options) + this.leadingString.length + memberExpression.firstLinelength;\n if (memberExpressionLength + 1 < this.options.wrapColumn) {\n callArguments = this.argumentsPrinter.format(\"multiline\", level);\n return this.finalize(FormattedLines.joinLines([memberExpression, callArguments]));\n }\n\n // Multiline the member expression\n memberExpression = this.memberExpressionPrinter.format(\"multiline\", level);\n\n // Check if we should also multiline the arguments\n memberExpressionLength = memberExpression.lastLinelength;\n if (memberExpressionLength + callArguments.maxLineLength > this.options.wrapColumn) {\n // The member expression property will be indented by +1\n callArguments = this.argumentsPrinter.format(\"multiline\", level + 1);\n }\n\n return this.finalize(FormattedLines.joinLines([memberExpression, callArguments]));\n }\n}\n\nexport class MemberExpressionPrinter extends Printer {\n type = \"MemberExpressionPrinter\" as const;\n private objectPrinter: Printer;\n private propertyPrinter: CollectionPrinter | SingleExpressionPrinter;\n\n constructor(\n override node: Parser.MemberExpression,\n override parent: Parser.Node,\n override options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n\n this.objectPrinter = createExpressionPrinter(node.object, node, this.options);\n\n if (node.computed) {\n // Don't use the factory, otherwise it would interpret the node.property\n const propertyPrinter = new CollectionPrinter(node.property, node, this.options);\n propertyPrinter.setupCollection([createExpressionPrinter(node.property, node, this.options)], \"SquareBrackets\");\n this.propertyPrinter = propertyPrinter;\n } else {\n const propertyPrinter = new SingleExpressionPrinter(node.property, node, this.options);\n propertyPrinter.prefix = \".\";\n this.propertyPrinter = propertyPrinter;\n }\n }\n\n format(style: PrintStyle = \"singleLine\", level = 0): FormattedLines {\n let object = this.objectPrinter.format(\"singleLine\", level);\n let property = this.propertyPrinter.format(\"singleLine\", level);\n if (style === \"singleLine\") {\n return this.finalize(FormattedLines.joinLines([object, property]));\n }\n\n // If the object side is too long then request it as multiline\n let objectLength = indentLength(level, this.options) + this.leadingString.length + object.firstLinelength;\n if (objectLength > this.options.wrapColumn) {\n object = this.objectPrinter.format(\"multiline\", level);\n // Since it's multiline, get the length of the last line\n objectLength = object.lastLinelength;\n }\n\n // Check if we can fit object and property on the \"same\" line\n let propertyLength = property.firstLinelength + this.trailingString.length;\n if (objectLength + propertyLength < this.options.wrapColumn) {\n return this.finalize(FormattedLines.joinLines([object, property]));\n }\n\n if (this.node.computed) {\n // Computed case\n // Object is multiline, try with property as multiline\n return this.finalize(FormattedLines.joinLines([object, this.propertyPrinter.format(\"multiline\", level)]));\n }\n\n // For .property expression, we will break to a new line. Figure out if the property has to be multiline or not\n const propertyLevel = level + 1;\n const indentation = getIndent(propertyLevel, this.options);\n property = this.propertyPrinter.format(\"singleLine\", level);\n propertyLength = indentation.length + property.lastLinelength + this.trailingString.length;\n if (propertyLength > this.options.wrapColumn) {\n property = this.propertyPrinter.format(\"multiline\", propertyLevel);\n }\n\n return this.finalize(FormattedLines.appendLines([object, property.indentFirstLine(indentation)]));\n }\n}\n\nexport class PropertyPrinter extends Printer {\n type = \"PropertyPrinter\" as const;\n\n private key: Printer;\n private value: Printer | undefined;\n\n constructor(\n override node: Parser.Property,\n override parent: Parser.Node,\n override options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n\n this.key = createExpressionPrinter(node.key, node, this.options);\n if (!node.shorthand) {\n this.key.suffix = \":\";\n this.value = createExpressionPrinter(node.value, node, this.options);\n }\n return;\n }\n\n format(style: PrintStyle = \"singleLine\", level = 0): FormattedLines {\n if (this.node.shorthand || !this.value) {\n return this.finalize(this.key.format(style, level));\n }\n\n const key = this.key.format(\"singleLine\", level);\n if (style === \"singleLine\") {\n // xxxx operator yyyy\n const value = this.value.format(\"singleLine\", level);\n return this.finalize(FormattedLines.joinLines([key, value], \" \"));\n }\n\n if (Parser.isArrayExpression(this.node.value) || Parser.isArrayExpression(this.node.value)) {\n const value = this.value.format(\"multiline\", level);\n return this.finalize(FormattedLines.joinLines([key, value], \" \"));\n }\n\n const indentation = getIndent(level + 1, this.options);\n let value = this.value.format(\"singleLine\", level + 1).indentFirstLine(indentation);\n const valueLength = value.maxLineLength + this.trailingString.length + 1;\n if (valueLength <= this.options.wrapColumn) {\n return this.finalize(FormattedLines.appendLines([key, value]));\n }\n\n value = this.value.format(\"multiline\", level + 1).indentFirstLine(indentation);\n return this.finalize(FormattedLines.appendLines([key, value]));\n }\n}\n\nexport class OperationPrinter extends Printer {\n type = \"OperationPrinter\" as const;\n\n private leftPrinter: Printer;\n private operator = \"\";\n private rightPrinter: Printer | undefined;\n private noNewLineWrapping = false;\n\n constructor(\n override node:\n | Parser.AssignmentExpression\n | Parser.VariableDeclarator\n | Parser.ForInStatement\n | Parser.BinaryExpression\n | Parser.LogicalExpression,\n override parent: Parser.Node,\n override options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n\n switch (node?.type) {\n case Parser.Syntax.AssignmentExpression:\n this.leftPrinter = createExpressionPrinter(node.left, node, this.options);\n this.operator = \" \" + node.operator;\n this.rightPrinter = createExpressionPrinter(node.right, node, this.options);\n this.noNewLineWrapping =\n (Parser.isIdentifier(node.left) || Parser.isLiteral(node.left)) &&\n (Parser.isArrayExpression(node.right) || Parser.isObjectExpression(node.right));\n return;\n\n case Parser.Syntax.VariableDeclarator:\n this.leftPrinter = createExpressionPrinter(node.id, node, this.options);\n if (node.init) {\n this.operator = \" =\";\n this.rightPrinter = createExpressionPrinter(node.init, node, this.options);\n }\n this.noNewLineWrapping = Parser.isArrayExpression(node.init) || Parser.isObjectExpression(node.init);\n return;\n\n case Parser.Syntax.ForInStatement:\n this.leftPrinter = createExpressionPrinter(node.left, node, this.options);\n this.operator = \" in\";\n this.rightPrinter = createExpressionPrinter(node.right, node, this.options);\n return;\n\n case Parser.Syntax.BinaryExpression:\n case Parser.Syntax.LogicalExpression:\n this.leftPrinter = createExpressionPrinter(node.left, node, this.options);\n this.operator = \" \" + node.operator;\n this.rightPrinter = createExpressionPrinter(node.right, node, this.options);\n return;\n }\n }\n\n format(style: PrintStyle = \"singleLine\", level = 0): FormattedLines {\n // Potentially for VariableDeclarator.\n if (!this.rightPrinter) {\n return this.finalize(this.leftPrinter.format(style, level));\n }\n\n // xxxx operator yyyy\n let left = this.leftPrinter.format(\"singleLine\", level).suffixWith(this.operator);\n let right = this.rightPrinter.format(\"singleLine\", level);\n if (style === \"singleLine\") {\n return this.finalize(FormattedLines.joinLines([left, right], \" \"));\n }\n\n // If the left side is too long then request it as multiline\n let leftLength = indentLength(level, this.options) + this.leadingString.length + left.maxLineLength + 1;\n if (leftLength > this.options.wrapColumn) {\n left = this.leftPrinter.format(\"multiline\", level).suffixWith(this.operator);\n // Since left is multiline, get the length of the last line\n leftLength = left.lastLinelength + 1;\n }\n\n // Check if the left and right parts can fit on 1 line (left could eventually be multiline)\n // xxxx op yyyy\n // or\n // xxxx[\n // zzzz\n // ] op yyyy\n const rightLength = right.firstLinelength + this.trailingString.length + 1;\n if (leftLength + rightLength < this.options.wrapColumn) {\n return this.finalize(FormattedLines.joinLines([left, right], \" \"));\n }\n\n // If this is still too long try to request the right as multiline\n const multilineRight = this.rightPrinter.format(\"multiline\", level);\n // Get the length of the first line of the right side now that it has been set to multiline\n const multilineRightLength = multilineRight.firstLinelength + this.trailingString.length + 1;\n if (multilineRightLength + leftLength < this.options.wrapColumn || this.noNewLineWrapping) {\n // It can fit or we have a special case (like assignement) that don't want further optimization\n return this.finalize(FormattedLines.joinLines([left, multilineRight], \" \"));\n }\n\n // We tried multiple combinations with the operator still on the same line of the\n // last left side line and the first right side line. We will break a new line after the operator.\n // Try to see if the right side on one line could fit or not.\n if (rightLength > this.options.wrapColumn) {\n right = this.rightPrinter.format(\"multiline\", level + 1);\n }\n\n right = right.indentFirstLine(getIndent(level + 1));\n\n // left =\n // right\n return this.finalize(FormattedLines.appendLines([left, right]));\n }\n}\n\nexport class TemplateLiteralPrinter extends Printer {\n type = \"TemplateLiteralPrinter\" as const;\n private parts: (string | Printer)[];\n\n constructor(\n override node: Parser.TemplateLiteral,\n override parent: Parser.Node,\n override options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n\n this.parts = [];\n\n const expressionsPrinters =\n node.expressions?.map((expression) => createExpressionPrinter(expression, node, this.options)) ?? [];\n\n this.parts.push(\"`\");\n node.quasis?.forEach((quasiNode, i) => {\n this.parts.push(quasiNode.value.raw);\n if (i < expressionsPrinters.length) {\n this.parts.push(\"${\");\n this.parts.push(expressionsPrinters[i]);\n this.parts.push(\"}\");\n }\n });\n this.parts.push(\"`\");\n }\n\n format(style: PrintStyle = \"singleLine\", level = 0): FormattedLines {\n return this.finalize(\n FormattedLines.joinLines(this.parts.map((part) => (typeof part === \"string\" ? part : part.format(style, level))))\n );\n }\n}\n//#endregion\n","import * as Parser from \"@arcgis/arcade-parser\";\nimport { FormattingOptions, normalizeFormattingOptions } from \"./options\";\nimport {\n getIndent,\n Printer,\n VariableDeclaratorsPrinter,\n createCollectionPrinter,\n CollectionPrinter,\n createExpressionPrinter,\n FormattedLines\n} from \"./expression-printers\";\n\n//#region Helpers\nfunction getTrueLocation(node: Parser.Node): Parser.SourceLocation {\n const start: Parser.Position = { ...(node.leadingComments?.slice(0, 1)[0]?.loc.start ?? node.loc.start) };\n const end: Parser.Position = { ...(node.trailingComments?.slice(-1)[0]?.loc.end ?? node.loc.end) };\n\n return { start, end };\n}\n\nfunction endsWithLineComment(node: Parser.Node): boolean {\n return node.trailingComments?.slice(-1)[0]?.type === Parser.Syntax.LineComment;\n}\n\n// function startWithLineComment(node: Parser.Node): boolean {\n// return node.leadingComments?.slice(-1)[0]?.type === Parser.Syntax.LineComment;\n// }\n//#endregion\n\ntype StatementPrintingStyle = \"singleLine\" | \"optimized\" | \"multiline\";\n\nabstract class StatementPrinter {\n /**\n * The only case when a statement is used by another statement if for the\n * If Statement (consequent and alternate). We need to disable the automatic\n * indentation that normally happened for when formatting a statement.\n * This property controls if the\n */\n public indentStatementFirstLine = true;\n\n /**\n * When a statement is used as alternate in an If Statement,\n * we need to account for the offset generated by the 'else' keyword\n * and also as well if the 'else' will be on a new line or inlined\n * with the consequent statement\n */\n public externalOffset = 0;\n\n private cachedBody: { body: FormattedLines; level: number } | undefined;\n\n constructor(\n public node: Parser.Program | Parser.Statement,\n public parent: Parser.Node | null | undefined,\n public options: Required<FormattingOptions>\n ) {\n this.options = normalizeFormattingOptions(this.options);\n }\n\n createStatementPrinter(node: Parser.Statement | Parser.Program): StatementPrinter | never {\n switch (node.type) {\n case Parser.Syntax.Program:\n return new BlockStatementPrinter(node, this.node, this.options);\n\n case Parser.Syntax.ImportDeclaration:\n return new ImportStatementPrinter(node, this.node, this.options);\n\n case Parser.Syntax.ExpressionStatement:\n return new ExpressionStatementPrinter(node, this.node, this.options);\n\n case Parser.Syntax.FunctionDeclaration:\n return new FunctionDeclarationPrinter(node, this.node, this.options);\n\n case Parser.Syntax.ExportNamedDeclaration:\n if (Parser.isVariableDeclaration(node)) {\n return new VariableDeclarationPrinter(node, this.node, this.options);\n } else {\n return new FunctionDeclarationPrinter(node, this.node, this.options);\n }\n\n case Parser.Syntax.BlockStatement:\n return new BlockStatementPrinter(node, this.node, this.options);\n\n case Parser.Syntax.ReturnStatement:\n return new ReturnStatementPrinter(node, this.node, this.options);\n\n case Parser.Syntax.VariableDeclaration:\n return new VariableDeclarationPrinter(node, this.node, this.options);\n\n case Parser.Syntax.IfStatement:\n return new IfStatementPrinter(node, this.node, this.options);\n\n case Parser.Syntax.ForStatement:\n case Parser.Syntax.ForInStatement:\n case Parser.Syntax.WhileStatement:\n return new LoopStatementPrinter(node, this.node, this.options);\n\n case Parser.Syntax.EmptyStatement:\n case Parser.Syntax.BreakStatement:\n case Parser.Syntax.ContinueStatement:\n return new KeywordStatementPrinter(node, this.node, this.options);\n\n default:\n throw new Error(\"unknown type: \" + JSON.stringify(node));\n }\n }\n\n /**\n * We don't to reprint over and over the body that is usually stable for a given level.\n * Uses a cache to optimize the formatting.\n * @param bodyPrinter\n * @param level\n * @returns\n */\n protected getFormattedBody(bodyPrinter: StatementPrinter, level = 0): FormattedLines {\n if (this.cachedBody && this.cachedBody.level === level) {\n return this.cachedBody.body;\n }\n\n const body = bodyPrinter.format(level);\n this.cachedBody = { body, level };\n return body;\n }\n\n private getStatementIndentation(level = 0): string {\n return this.indentStatementFirstLine ? getIndent(level, this.options) : \"\";\n }\n\n private getStatementIndentationLength(level = 0): number {\n return this.indentStatementFirstLine ? level * (this.options.indentWidth ?? 2) : 0;\n }\n\n /**\n * Gets the indentation string for the corresponding level\n * @param level\n * @returns\n */\n protected getIndentation(level = 0): string {\n return getIndent(level, this.options);\n }\n\n /**\n * Format the statement following a style:\n * - Single Line: Force the statement to format itself as a single line\n * - Multiline: Force the statement to format itself on multiple lines. The goal\n * being that the statement fits the maximum line length.\n * - Optimized: Let the statement decide the best way to format its content\n * The level is the actual indentation.\n * @param level\n * @param style\n */\n abstract format(level?: number, style?: StatementPrintingStyle): FormattedLines;\n\n /**\n * Once the statement has been formatted, we need to wrap the leading and the\n * trailing comments.\n * @param formattedLines\n * @param level\n * @returns\n */\n protected addComments(formattedLines: FormattedLines, level = 0): FormattedLines {\n //\n const statementIndentation = this.getStatementIndentation(level);\n if (!this.node.leadingComments?.length && !this.node.trailingComments?.length) {\n return formattedLines.indentFirstLine(statementIndentation);\n }\n\n // Leading comments. Either lines in front of the statement or eventually a block\n // comment on the same line as the statement\n const leadingCommentsResult = (this.node.leadingComments ?? []).reduce<{\n formattedLines: FormattedLines;\n location?: Parser.SourceLocation;\n }>(\n (previous, comment) => {\n const formattedComment = this.formatComment(comment);\n return {\n formattedLines: FormattedLines.aggregateLines(\n previous.formattedLines,\n previous.location,\n formattedComment,\n comment.loc,\n statementIndentation\n ),\n location: comment.loc\n };\n },\n { formattedLines: new FormattedLines() }\n );\n\n // Start assembling the leading comments with the statement\n const aggregatedFormattedLines = FormattedLines.aggregateLines(\n leadingCommentsResult.formattedLines,\n leadingCommentsResult?.location,\n formattedLines,\n this.node.loc,\n statementIndentation\n );\n\n // Trailing comments. Normally on the same line as the statement.\n const result = this.node.trailingComments?.reduce<{\n formattedLines: FormattedLines;\n location?: Parser.SourceLocation;\n }>(\n (previous, comment) => {\n const formattedComment = this.formatComment(comment);\n return {\n formattedLines: FormattedLines.aggregateLines(\n previous?.formattedLines,\n previous?.location,\n formattedComment,\n comment.loc,\n statementIndentation\n ),\n location: comment.loc\n };\n },\n { formattedLines: aggregatedFormattedLines, location: this.node.loc }\n ) ?? { formattedLines: aggregatedFormattedLines };\n\n return result.formattedLines;\n }\n\n protected formatInnerComments(level = 0): FormattedLines {\n if (\n !Parser.isBlockStatement(this.node) ||\n !Array.isArray(this.node.innerComments) ||\n !this.node.innerComments.length\n ) {\n return new FormattedLines();\n }\n\n const indentation = this.getIndentation(level);\n const innerCommentsResult = this.node.innerComments?.reduce<{\n formattedLines: FormattedLines;\n location?: Parser.SourceLocation;\n }>(\n (previous, comment) => {\n const formattedComment = this.formatComment(comment);\n return {\n formattedLines: FormattedLines.aggregateLines(\n previous.formattedLines,\n previous.location,\n formattedComment,\n comment.loc,\n indentation\n ),\n location: comment.loc\n };\n },\n { formattedLines: new FormattedLines() }\n );\n\n return innerCommentsResult.formattedLines;\n }\n\n private formatComment(comment: Parser.Comment): FormattedLines {\n switch (comment.type) {\n case Parser.Syntax.BlockComment:\n return FormattedLines.fromString(comment.value).surroundWith(\"/*\", \"*/\");\n\n default:\n // Line Comment.\n return FormattedLines.fromString(comment.value.trimEnd()).surroundWith(\"//\");\n }\n }\n\n /**\n * Invoked for a single line format. Measure is the length of the statement would fit\n * the available space\n * @param formattedLines\n * @param level\n * @param offset\n * @returns\n */\n protected canFitSingleLine(formattedLines: FormattedLines, level = 0, offset = 0): boolean {\n return (\n this.externalOffset + offset + this.getStatementIndentationLength(level) + formattedLines.lastLinelength <=\n this.options.wrapColumn\n );\n }\n}\n\nexport class BlockStatementPrinter extends StatementPrinter {\n private printers: StatementPrinter[] = [];\n\n constructor(\n override node: Parser.BlockStatement | Parser.Program,\n parent: Parser.Node | null | undefined,\n options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n this.printers = node.body.map((node) => this.createStatementPrinter(node));\n }\n\n format(level = 0): FormattedLines {\n if (this.printers.length === 0) {\n return this.formatEmptyBlock(level);\n }\n\n const result: (string | FormattedLines)[] = [];\n\n const isBlockStatement = Parser.isBlockStatement(this.node);\n if (isBlockStatement) {\n result.push(\"{\");\n }\n\n const childrenLevel = isBlockStatement ? level + 1 : level;\n let previousLocation: Parser.SourceLocation;\n this.printers.forEach((printer) => {\n if (Parser.isEmptyStatement(printer.node)) {\n return;\n }\n\n // Deal with empty lines\n const trueLocation = getTrueLocation(printer.node);\n if (previousLocation) {\n const inBetweenEmptyLinesCount = trueLocation.start.line - previousLocation.end.line;\n if (inBetweenEmptyLinesCount > 1) {\n result.push(\"\");\n }\n }\n previousLocation = trueLocation;\n\n result.push(printer.format(childrenLevel));\n });\n\n if (isBlockStatement) {\n result.push(this.getIndentation(level) + \"}\");\n }\n\n return this.addComments(FormattedLines.appendLines(result), level);\n }\n\n private formatEmptyBlock(level = 0): FormattedLines {\n if (!Parser.isBlockStatement(this.node)) {\n // Empty program\n return this.addComments(FormattedLines.fromString(\"\"), level);\n }\n\n // Block statements can have inner comments.\n // Havinf inner comments will change the way we format empty block\n const innerComments = this.formatInnerComments(level + 1);\n\n const openingPunctuator = \"{\";\n const closingPunctuator = this.getIndentation(level) + \"}\";\n if (!innerComments.isEmpty) {\n // We have inner comments. Assemble the block.\n return this.addComments(FormattedLines.appendLines([openingPunctuator, innerComments, closingPunctuator]), level);\n }\n\n // No inner comments then return the empty block\n if (Parser.isIfStatement(this.parent)) {\n // Special formatting for empty if statement blocks\n return this.addComments(FormattedLines.appendLines([openingPunctuator, closingPunctuator]), level);\n }\n\n return this.addComments(FormattedLines.fromString(\"{}\"), level);\n }\n}\n\nclass KeywordStatementPrinter extends StatementPrinter {\n private keyword = \"\";\n\n constructor(\n override node: Parser.EmptyStatement | Parser.ContinueStatement | Parser.BreakStatement,\n parent: Parser.Node,\n options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n\n switch (this.node.type) {\n case Parser.Syntax.ContinueStatement:\n this.keyword = \"continue;\";\n break;\n\n case Parser.Syntax.BreakStatement:\n this.keyword = \"break;\";\n break;\n\n default:\n this.keyword = \";\";\n }\n }\n\n format(level = 0): FormattedLines {\n return this.addComments(FormattedLines.fromString(this.keyword), level);\n }\n}\n\nclass VariableDeclarationPrinter extends StatementPrinter {\n private printer: Printer;\n\n constructor(\n override node: Parser.VariableDeclaration | Parser.ExportNamedDeclaration,\n parent: Parser.Node,\n options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n if (Parser.isVariableDeclaration(node)) {\n this.printer = new VariableDeclaratorsPrinter(node, parent, options);\n } else if (Parser.isVariableDeclaration(node.declaration)) {\n this.printer = new VariableDeclaratorsPrinter(node.declaration, parent, options);\n this.printer.prefix = \"export \";\n } else {\n throw new Error(\"invalid type: \" + JSON.stringify(node));\n }\n }\n\n format(level = 0, style: StatementPrintingStyle = \"optimized\"): FormattedLines {\n if (style === \"singleLine\" || style === \"optimized\") {\n const declaration = this.printer.format(\"singleLine\", level).suffixWith(\";\");\n if (style === \"singleLine\" || this.canFitSingleLine(declaration, level)) {\n return this.addComments(declaration, level);\n }\n }\n\n return this.addComments(this.printer.format(\"multiline\", level).suffixWith(\";\"), level);\n }\n}\n\nclass FunctionDeclarationPrinter extends StatementPrinter {\n private header: CollectionPrinter;\n private body: BlockStatementPrinter;\n\n constructor(\n override node: Parser.FunctionDeclaration | Parser.ExportNamedDeclaration,\n parent: Parser.Node,\n options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n if (Parser.isFunctionDeclaration(node)) {\n this.header = createCollectionPrinter(node, parent, options);\n this.body = new BlockStatementPrinter(node.body, node, options);\n } else if (Parser.isFunctionDeclaration(node.declaration)) {\n this.header = createCollectionPrinter(node.declaration, parent, options);\n this.header.prefix = \"export \";\n this.body = new BlockStatementPrinter(node.declaration.body, node, options);\n } else {\n throw new Error(\"invalid type: \" + JSON.stringify(node));\n }\n }\n\n format(level = 0, style: StatementPrintingStyle = \"optimized\"): FormattedLines {\n this.body.indentStatementFirstLine = false;\n const body = this.getFormattedBody(this.body, level);\n\n if (style === \"singleLine\" || style === \"optimized\") {\n const header = this.header.format(\"singleLine\", level);\n if (style === \"singleLine\" || this.canFitSingleLine(header, level, body.firstLinelength + 1)) {\n return this.addComments(FormattedLines.joinLines([header, body], \" \"), level);\n }\n }\n\n const header = this.header.format(\"multiline\", level);\n return this.addComments(FormattedLines.joinLines([header, body], \" \"), level);\n }\n}\n\nclass IfStatementPrinter extends StatementPrinter {\n private header: CollectionPrinter;\n private consequent: StatementPrinter;\n private alternate?: StatementPrinter;\n\n constructor(\n override node: Parser.IfStatement,\n parent: Parser.Node,\n options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n\n this.header = createCollectionPrinter(node, parent, options);\n\n this.consequent = this.createStatementPrinter(node.consequent);\n this.consequent.indentStatementFirstLine = false;\n\n if (node.alternate) {\n this.alternate = this.createStatementPrinter(node.alternate);\n this.alternate.indentStatementFirstLine = false;\n }\n }\n\n format(level = 0, style: StatementPrintingStyle = \"optimized\"): FormattedLines {\n let isHeaderMultiline = false;\n let header: FormattedLines | undefined;\n if (style === \"singleLine\" || style === \"optimized\") {\n const singleLineHeader = this.header.format(\"singleLine\", level);\n const headerOffset = Parser.isBlockStatement(this.node.consequent) ? 2 : 0;\n if (style === \"singleLine\" || this.canFitSingleLine(singleLineHeader, level, headerOffset)) {\n header = singleLineHeader;\n }\n }\n\n if (!header) {\n isHeaderMultiline = true;\n header = this.header.format(\"multiline\", level);\n }\n\n let result: FormattedLines;\n if (Parser.isBlockStatement(this.node.consequent)) {\n // No matter what happened to the header, BlockStatement will always be joined\n // with the header\n const consequent = this.consequent.format(level, \"optimized\");\n result = FormattedLines.joinLines([header, \" \", consequent]);\n } else if (isHeaderMultiline || Parser.isIfStatement(this.node.consequent)) {\n // The consequent is not a BlockStatement.\n // The header was too long. We already established that we need to append the consequent\n // on a new line\n this.consequent.indentStatementFirstLine = true;\n let consequent = this.consequent.format(level + 1, \"singleLine\");\n if (!this.canFitSingleLine(consequent, level + 1)) {\n consequent = this.consequent.format(level + 1, \"multiline\");\n }\n result = FormattedLines.appendLines([header, consequent]);\n } else {\n // The consequent is not a BlockStatement.\n // The header is not multiline. Try to fit the statement on the same line\n this.consequent.indentStatementFirstLine = false;\n let consequent = this.consequent.format(level, \"singleLine\");\n if (this.canFitSingleLine(consequent, 0, header.lastLinelength + 1)) {\n // It can fit on one line wiht the header\n result = FormattedLines.joinLines([header, \" \", consequent]);\n } else {\n // It cannot fit on the same line, append it on a new line\n // and let the statement optimized itself\n this.consequent.indentStatementFirstLine = true;\n consequent = this.consequent.format(level + 1, \"optimized\");\n result = FormattedLines.appendLines([header, consequent]);\n }\n }\n\n if (!this.alternate) {\n return this.addComments(result, level);\n }\n\n const elseOnNewLine = endsWithLineComment(this.node.consequent) || !Parser.isBlockStatement(this.node.consequent);\n let alternate: FormattedLines;\n this.alternate.externalOffset = 0;\n if (Parser.isBlockStatement(this.node.alternate) || Parser.isIfStatement(this.node.alternate)) {\n // BlockStatements and IfStatements will be joined with the else\n this.alternate.indentStatementFirstLine = false;\n this.alternate.externalOffset = elseOnNewLine ? 5 : result.lastLinelength + 6;\n alternate = this.alternate.format(level, \"optimized\");\n alternate = FormattedLines.joinLines([\"else \", alternate]);\n } else {\n // We need to determine if we can fit the statement on the same line as the 'else'\n const elseOffset = elseOnNewLine ? 4 : result.lastLinelength + 4;\n this.alternate.indentStatementFirstLine = false;\n alternate = this.alternate.format(level, \"singleLine\");\n if (this.canFitSingleLine(alternate, level, elseOffset + 1)) {\n // It all fits\n alternate = FormattedLines.joinLines([\"else \", alternate]);\n } else {\n // The alternate has to be moved to a new level\n this.alternate.indentStatementFirstLine = true;\n alternate = this.alternate.format(level + 1, \"optimized\");\n alternate = FormattedLines.appendLines([\"else\", alternate]);\n }\n }\n\n if (elseOnNewLine) {\n result = FormattedLines.appendLines([result, alternate.indentFirstLine(this.getIndentation(level))]);\n } else {\n result = FormattedLines.joinLines([result, alternate], \" \");\n }\n\n return this.addComments(result, level);\n }\n}\n\nclass LoopStatementPrinter extends StatementPrinter {\n private header: CollectionPrinter;\n private body: StatementPrinter;\n\n constructor(\n override node: Parser.ForStatement | Parser.ForInStatement | Parser.WhileStatement,\n parent: Parser.Node,\n options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n\n this.header = createCollectionPrinter(node, parent, options);\n this.body = this.createStatementPrinter(node.body);\n }\n\n format(level = 0, style: StatementPrintingStyle = \"optimized\"): FormattedLines {\n this.body.indentStatementFirstLine = false;\n const body = this.getFormattedBody(this.body, level);\n\n if (style === \"singleLine\" || style === \"optimized\") {\n const header = this.header.format(\"singleLine\", level);\n if (style === \"singleLine\" || this.canFitSingleLine(header, level, body.firstLinelength + 1)) {\n return this.addComments(FormattedLines.joinLines([header, body], \" \"), level);\n }\n }\n const header = this.header.format(\"multiline\", level);\n return this.addComments(FormattedLines.joinLines([header, body], \" \"), level);\n }\n}\n\nclass ExpressionStatementPrinter extends StatementPrinter {\n private expression: Printer;\n\n constructor(\n override node: Parser.ExpressionStatement,\n parent: Parser.Node,\n options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n this.expression = createExpressionPrinter(node.expression, node, options);\n }\n\n format(level = 0, style: StatementPrintingStyle = \"optimized\"): FormattedLines {\n if (style === \"singleLine\" || style === \"optimized\") {\n const expression = this.expression.format(\"singleLine\", level).suffixWith(\";\");\n if (style === \"singleLine\" || this.canFitSingleLine(expression, level)) {\n return this.addComments(expression, level);\n }\n }\n\n return this.addComments(this.expression.format(\"multiline\", level).suffixWith(\";\"), level);\n }\n}\n\nclass ReturnStatementPrinter extends StatementPrinter {\n private argument: Printer;\n\n constructor(\n override node: Parser.ReturnStatement,\n parent: Parser.Node,\n options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n this.argument = createExpressionPrinter(node.argument, node, options);\n }\n\n format(level = 0, style: StatementPrintingStyle = \"optimized\"): FormattedLines {\n if (!this.argument) {\n return this.addComments(FormattedLines.fromString(\"return;\"), level);\n }\n\n if (style === \"singleLine\" || style === \"optimized\") {\n const result = this.argument.format(\"singleLine\", level).surroundWith(\"return \", \";\");\n if (style === \"singleLine\" || this.canFitSingleLine(result, level)) {\n return this.addComments(result, level);\n }\n }\n\n if (!Parser.isLogicalExpression(this.node.argument) && !Parser.isBinaryExpression(this.node.argument)) {\n const formattedArgument = this.argument.format(\"multiline\", level).surroundWith(\"return \", \";\");\n return this.addComments(formattedArgument, level);\n }\n\n // For Binary and Logical expressions we need to add a specialized grouping\n const argumentIndentation = this.getIndentation(level + 1);\n const formattedArgument = this.argument.format(\"multiline\", level + 1).indentFirstLine(argumentIndentation);\n const indentation = this.getIndentation(level);\n return this.addComments(FormattedLines.appendLines([\"return (\", formattedArgument, indentation + \");\"]), level);\n }\n}\n\nclass ImportStatementPrinter extends StatementPrinter {\n private libname: Printer;\n private libsource: Printer;\n constructor(\n override node: Parser.ImportDeclaration,\n parent: Parser.Node,\n options: Required<FormattingOptions>\n ) {\n super(node, parent, options);\n this.libname = createExpressionPrinter(node.specifiers[0].local, node, options);\n this.libsource = createExpressionPrinter(node.source, node, options);\n }\n\n format(level = 0): FormattedLines {\n return this.addComments(\n FormattedLines.joinLines([\n \"import\",\n \" \",\n this.libname.format(\"singleLine\", level),\n \" from \",\n this.libsource.format(\"singleLine\")\n ]).suffixWith(\";\"),\n level\n );\n }\n}\n","import * as Parser from \"@arcgis/arcade-parser\";\nimport { TextDocument } from \"vscode-languageserver-textdocument\";\nimport { TextEdit } from \"vscode-languageserver-types\";\nimport { ApiContext } from \"../api-context\";\nimport { getTrueLocation } from \"./utils\";\nimport { FormattingOptions, normalizeFormattingOptions } from \"./options\";\nimport { Lines } from \"./lines\";\nimport { BlockStatementPrinter } from \"./statement-printers\";\n\nconst DefaultOptions: FormattingOptions = { quote: \"auto\" };\n\nexport function arcadeFormat(document: TextDocument, context: ApiContext = {}): TextEdit[] {\n try {\n // Get the original document\n const code = document.getText();\n\n // We will reformat the whole document\n const end = document.positionAt(code.length);\n const range = { start: { line: 0, character: 0 }, end };\n\n // Prettify\n const options: FormattingOptions = { ...DefaultOptions, ...(context.formattingOptions ?? {}) };\n // options.wrapColumn = 40;\n const newText = format(code, options);\n\n // Return the result\n return [{ range, newText }];\n } catch (e) {\n console.error(\"Arcade Formatting Error:\", e);\n return [];\n }\n}\n\n/**\n * Format code using options.\n */\nexport function format(script: string, options?: FormattingOptions): string {\n if (!script) {\n return \"\";\n }\n\n const normalizedOptions = normalizeFormattingOptions(options);\n\n // Convert the script to lines\n const sourceLines = Lines.fromString(script, normalizedOptions);\n\n // AST\n const sourceWithoutTabs = sourceLines.toString();\n const tree = Parser.parse(sourceWithoutTabs, {\n tolerant: true,\n comments: true\n });\n\n // Expand the tree .loc to include all comments (not just those\n // attached to the Program node, as its children may have comments as\n // well), since sometimes program.loc.{start,end} will coincide with the\n // .loc.{start,end} of the first and last *statements*, mistakenly\n // excluding comments that fall outside that region.\n const trueProgramLoc = getTrueLocation(tree, sourceLines);\n tree.loc.start = trueProgramLoc.start;\n tree.loc.end = trueProgramLoc.end;\n\n // Format the tree\n // options.wrapColumn = 40;\n const printer = new BlockStatementPrinter(tree, null, normalizedOptions);\n return printer.format().toString();\n}\n","import * as Parser from \"@arcgis/arcade-parser\";\nimport { ApiFunctionDefinition, ApiDatabase } from \"../arcade-api\";\nimport { ApiVariable, isValueVariable } from \"../api-context\";\nimport { ArcadeReservedKeywords } from \"../languageKeywords\";\nimport {\n DiagnosticData,\n DiagnosticMessages,\n Diagnostic,\n ValidationDiagnosticCodes,\n DiagnosticSeverity\n} from \"../api-diagnostic\";\nimport { formatString } from \"../utils\";\n\ntype PartialDiagnostic = Partial<Diagnostic> & {\n code: ValidationDiagnosticCodes | Parser.DiagnosticCodes;\n data?: DiagnosticData | null;\n};\n\ninterface IdentifierInfo {\n node: Parser.Identifier;\n used: boolean;\n initialized: boolean;\n scope: \"script\" | \"function\" | \"block\";\n}\n\ninterface UndeclaredIdentifierInFunction {\n identifier: string;\n node: Parser.Identifier;\n}\n\nexport class ArcadeValidationService {\n private _isInBlock = false;\n private _isInCallExpression = false;\n private _identifierBeingAssigned: string | undefined = undefined;\n private _assignmentValidationMode: \"disabled\" | \"left\" | \"right\" = \"disabled\";\n private _scriptScopeIdentifiers = new Map<string, IdentifierInfo>();\n private _functionScopeIdentifiers: Map<string, IdentifierInfo> | undefined;\n private _diagnostics: Diagnostic[] = [];\n private _undeclaredIdentifiersInFunctions = new Map<string, UndeclaredIdentifierInFunction[]>();\n\n constructor(\n private _apiDefinitions?: ApiDatabase,\n private _profileVariables: ApiVariable[] = []\n ) {}\n\n validateScript(script: string): { diagnostics: Diagnostic[]; program: Parser.Program | null } {\n if (!script) {\n return { diagnostics: [], program: null };\n }\n\n this._isInBlock = false;\n this._identifierBeingAssigned = undefined;\n this._assignmentValidationMode = \"disabled\";\n this._diagnostics = [];\n this._scriptScopeIdentifiers.clear();\n this._undeclaredIdentifiersInFunctions.clear();\n this._functionScopeIdentifiers = undefined;\n\n let program: Parser.Program | null = null;\n try {\n program = Parser.parse(script, { tolerant: true });\n\n // Log the tolerated errors\n this.handleErrors(program.errors);\n\n // The body of the script is a collection of statements\n program.body.forEach((statement) => this.validateStatement(statement));\n\n // Some identifiers may have been defined but not used, report them\n this.diagnoseIdentifiers();\n\n // Have used globals in functions that have never been declared or used\n if (this._undeclaredIdentifiersInFunctions.size > 0) {\n this._undeclaredIdentifiersInFunctions.forEach((value: UndeclaredIdentifierInFunction[]) => {\n for (const badnode of value) {\n this.logDiagnostic(badnode.node.loc, {\n code: ValidationDiagnosticCodes.NotDefined,\n data: { identifier: badnode.node.name }\n });\n }\n });\n }\n } catch (e: any) {\n this.handleException(e);\n }\n\n return { diagnostics: this._diagnostics, program };\n }\n\n private disableRecordIdentifierAssignment<T>(func: (node: T) => void, node: T): void {\n // We just need to disable the mode\n const previousMode = this._assignmentValidationMode;\n this._assignmentValidationMode = \"disabled\";\n func.call(this, node);\n this._assignmentValidationMode = previousMode;\n }\n\n private inBlock<T>(func: (node: T) => void, node: T): void {\n const previous = this._isInBlock;\n this._isInBlock = true;\n func.call(this, node);\n this._isInBlock = previous;\n }\n\n private get _isInFunctionScope(): boolean {\n return !!this._functionScopeIdentifiers;\n }\n\n private inFunctionScope(func: () => void): void {\n // For identifier conflict\n // Separate the variable declarations found inside the function\n // from the variable/function declarations at the script level.\n // Functions are scoping variables.\n this._functionScopeIdentifiers = new Map();\n\n func.call(this);\n\n // Diagnose all the unused function scope variables\n this.diagnoseIdentifiers();\n\n // Ends the function scoping.\n this._functionScopeIdentifiers = undefined;\n }\n\n private logDiagnostic(loc: Parser.SourceLocation, diagnostic: PartialDiagnostic): void {\n // SourceLocation line is 1-based and Diagnostics line is 0-based.\n // We need to shift the line location by one.\n const fullDiagnostic: Diagnostic = {\n severity: DiagnosticSeverity.Error,\n ...diagnostic,\n message: formatString(\n //@ts-expect-error\n DiagnosticMessages[diagnostic.code] ?? Parser.DiagnosticMessages[diagnostic.code],\n diagnostic.data\n ),\n range: {\n start: { line: loc.start.line - 1, character: loc.start.column },\n end: { line: loc.end.line - 1, character: loc.end.column }\n }\n };\n this._diagnostics.push(fullDiagnostic);\n }\n\n private handleErrors(errors: Error[] | undefined): void {\n (errors ?? []).forEach(this.handleException, this);\n }\n\n private handleException(error: any): void {\n if (isParsingDiagnostic(error)) {\n // Check if the exception error is a parsing error\n // Error lineNumber and column are 1-based\n // Adjust the error position to be compatible with the diagnostic logging\n const { range, code, data } = error;\n this.logDiagnostic(range, { code, data });\n } else {\n // This is a fatal error. Log the stack\n this.logDiagnostic(\n { start: { line: 1, column: 0 }, end: { line: 1, column: 0 } },\n { code: ValidationDiagnosticCodes.ExecutionError, data: { stack: (error as Error).stack ?? \"\" } }\n );\n }\n }\n\n private getIdentifierInfo(id: string): IdentifierInfo | undefined {\n return this._functionScopeIdentifiers?.get(id) ?? this._scriptScopeIdentifiers.get(id);\n }\n\n private setIdentiferInfo(idName: string, identifierInfo: IdentifierInfo): void {\n // If in a function scope, record the variable name in that scope or record the variable in the script scope\n if (this._functionScopeIdentifiers) {\n this._functionScopeIdentifiers.set(idName, identifierInfo);\n return;\n }\n (this._functionScopeIdentifiers ?? this._scriptScopeIdentifiers).set(idName, identifierInfo);\n if (!this._functionScopeIdentifiers) {\n // Check if the variable has been used in a function declared prior to this variable declaration.\n // If it has, then mark it is as used.\n if (this._undeclaredIdentifiersInFunctions.has(idName)) {\n this._undeclaredIdentifiersInFunctions.delete(idName);\n identifierInfo.used = true;\n }\n }\n }\n\n private isProfileVariable(name: string): boolean {\n return (this._profileVariables ?? []).some((p: any) => p.name.toLowerCase() === name);\n }\n\n private isApiConstant(idName: string): boolean {\n return !!this._apiDefinitions?.constantDefinitions?.get(idName);\n }\n\n private isApiFunction(idName: string): boolean {\n return !!this._apiDefinitions?.functionDefinitions?.get(idName);\n }\n\n private isApiItem(idName: string): boolean {\n return this.isApiConstant(idName) || this.isApiFunction(idName);\n }\n\n private validateStatement(node: Parser.Statement | null | undefined): void {\n if (!node) {\n return;\n }\n\n // On the top of the switch are all the statements that we support\n // Each of them have a different logic\n switch (node.type) {\n case Parser.Syntax.BlockStatement:\n // We just have to validate each node in the block statement\n node.body.forEach((s) => this.validateStatement(s));\n return;\n\n case Parser.Syntax.VariableDeclaration:\n // Validate each declarator\n node.declarations.forEach((v) => this.validateVariableDeclarator(v));\n return;\n\n case Parser.Syntax.FunctionDeclaration:\n this.validateFunctionDeclaration(node);\n return;\n case Parser.Syntax.ExportNamedDeclaration:\n this.validateExportDeclaration(node);\n return;\n case Parser.Syntax.ImportDeclaration:\n this.validateImportDeclaration(node);\n return;\n\n case Parser.Syntax.WhileStatement:\n this.validateWhileStatement(node);\n return;\n\n case Parser.Syntax.ForStatement:\n this.validateForStatement(node);\n return;\n\n case Parser.Syntax.ForInStatement:\n this.validateForInStatement(node);\n return;\n\n case Parser.Syntax.IfStatement:\n this.validateIfStatement(node);\n return;\n\n case Parser.Syntax.ReturnStatement:\n this.validateExpression(node.argument);\n return;\n\n case Parser.Syntax.ExpressionStatement:\n this.validateExpression(node.expression);\n return;\n\n // No issue statement\n case Parser.Syntax.BreakStatement:\n case Parser.Syntax.ContinueStatement:\n case Parser.Syntax.EmptyStatement:\n return;\n }\n }\n\n private validateVariableDeclarator(node: Parser.VariableDeclarator): void {\n this.validateExpression(node.init);\n this.recordVariableIdentifier(node.id, { initialized: !!node.init });\n }\n\n private validateFunctionDeclaration(node: Parser.FunctionDeclaration): void {\n // Record the function in the identifier map\n this.recordFunctionIdentifier(node);\n\n // For identifier conflict\n // Separate the variable declarations found inside the function\n // from the variable/function declarations at the script level.\n // Functions are scoping variables.\n this.inFunctionScope(() => {\n // Validate each param and record them as function scope variables\n node.params.forEach((p) => this.recordParamAsIdentifier(p));\n\n // Validate that we have a body with statements\n if (isBlockStatementEmpty(node.body)) {\n this.logDiagnostic(node.body.loc, {\n code: ValidationDiagnosticCodes.UnexpectedEmptyFunction,\n data: { identifier: node.id.name },\n severity: DiagnosticSeverity.Warning\n });\n }\n\n // Validate the function body\n this.validateStatement(node.body);\n });\n }\n\n private validateExportDeclaration(node: Parser.ExportNamedDeclaration): void {\n // Record the function in the identifier map\n this.validateStatement(node.declaration);\n }\n\n private validateImportDeclaration(node: Parser.ImportDeclaration): void {\n // Record the function in the identifier map\n this.recordImportIdentifier(node);\n }\n\n private validateForStatement(node: Parser.ForStatement): void {\n // We only support:\n // - empty init\n // - variable declaration: var x = 1\n // - assignment expression: x = 1\n if (Parser.isVariableDeclaration(node.init)) {\n this.inBlock(this.validateStatement, node.init);\n } else {\n this.validateExpression(node.init);\n }\n\n this.validateExpression(node.update);\n this.validateExpression(node.test);\n\n // Empty block is bad practice\n if (isBlockStatementEmpty(node.body)) {\n this.logDiagnostic(node.body.loc, {\n code: ValidationDiagnosticCodes.EmptyBlockStatement,\n severity: DiagnosticSeverity.Warning\n });\n }\n\n // Surround the body validation with inBlock. This is used when recording variables to know\n // if they have been declared in a block that could lead to bad coding\n this.inBlock(this.validateStatement, node.body);\n }\n\n private validateWhileStatement(node: Parser.WhileStatement): void {\n this.validateExpression(node.test);\n\n // Empty block is bad practice\n if (isBlockStatementEmpty(node.body)) {\n this.logDiagnostic(node.body.loc, {\n code: ValidationDiagnosticCodes.EmptyBlockStatement,\n severity: DiagnosticSeverity.Warning\n });\n }\n\n // Surround the body validation with inBlock. This is used when recording variables to know\n // if they have been declared in a block that could lead to bad coding\n this.inBlock(this.validateStatement, node.body);\n }\n\n private validateForInStatement(node: Parser.ForInStatement): void {\n // Validate the left side. We only support Identifier or VariableDeclaration\n if (Parser.isIdentifier(node.left)) {\n this.validateExpression(node.left);\n } else {\n // We need to bypass the statement validation and directly record the identifier and\n // force its init state to true\n this.recordVariableIdentifier(node.left.declarations[0].id, { initialized: true, inBlock: true });\n }\n\n this.validateExpression(node.right);\n\n if (isBlockStatementEmpty(node.body)) {\n this.logDiagnostic(node.body.loc, {\n code: ValidationDiagnosticCodes.EmptyBlockStatement,\n severity: DiagnosticSeverity.Warning\n });\n }\n this.validateStatement(node.body);\n }\n\n private validateIfStatement(node: Parser.IfStatement): void {\n this.validateExpression(node.test);\n\n if (isBlockStatementEmpty(node.consequent)) {\n this.logDiagnostic(node.consequent.loc, {\n code: ValidationDiagnosticCodes.EmptyBlockStatement,\n severity: DiagnosticSeverity.Warning\n });\n }\n if (node.alternate && isBlockStatementEmpty(node.alternate)) {\n this.logDiagnostic(node.alternate.loc, {\n code: ValidationDiagnosticCodes.EmptyBlockStatement,\n severity: DiagnosticSeverity.Warning\n });\n }\n\n // Validate the consequent and alternate statements for bad variable decalration practices\n this.inBlock(this.validateStatement, node.consequent);\n this.inBlock(this.validateStatement, node.alternate);\n }\n\n private validateExpression(node: Parser.Expression | null | undefined): void {\n if (!node) {\n return;\n }\n\n // The top of the switch statement are all the supported expressions\n switch (node.type) {\n case Parser.Syntax.AssignmentExpression:\n this.validateAssignmentExpression(node);\n return;\n\n case Parser.Syntax.CallExpression:\n this.validateCallExpression(node);\n return;\n\n case Parser.Syntax.Identifier:\n this.validateIdentifier(node);\n return;\n\n case Parser.Syntax.Literal:\n this.validateLiteral(node);\n return;\n\n case Parser.Syntax.ArrayExpression:\n node.elements.forEach((e) => this.validateExpression(e));\n return;\n\n case Parser.Syntax.ObjectExpression:\n this.validateObjectExpression(node);\n return;\n\n case Parser.Syntax.UnaryExpression:\n this.validateUnaryExpression(node);\n return;\n\n case Parser.Syntax.UpdateExpression:\n this.validateUpdateExpression(node);\n return;\n\n case Parser.Syntax.BinaryExpression:\n case Parser.Syntax.LogicalExpression:\n this.validateBinaryAndLogicalExpression(node);\n return;\n\n case Parser.Syntax.MemberExpression:\n this.validateMemberExpression(node);\n return;\n\n case Parser.Syntax.TemplateLiteral:\n node.expressions.forEach((e) => this.validateExpression(e));\n return;\n\n default:\n return;\n }\n }\n\n private validateAssignmentExpression(node: Parser.AssignmentExpression): void {\n // Only set the _identifierBeingAssigned if the left hand side is an identifier\n const previousIdentifier = this._identifierBeingAssigned;\n const previousMode = this._assignmentValidationMode;\n if (Parser.isIdentifier(node.left)) {\n this._identifierBeingAssigned = node.left.name.toLowerCase();\n this._assignmentValidationMode = \"left\";\n }\n\n // We want to mark a identifier used only is used on the right hanside\n // and not being the identifier on the left hand side.\n // For example `foo = foo + 1`, foo should not being marked as used in this example.\n this.validateExpression(node.left);\n\n if (Parser.isIdentifier(node.left)) {\n this._assignmentValidationMode = \"right\";\n }\n this.validateExpression(node.right);\n\n // Restore\n this._identifierBeingAssigned = previousIdentifier;\n this._assignmentValidationMode = previousMode;\n }\n\n private validateCallExpression(node: Parser.CallExpression): void {\n // Validate the callee\n const previousInCallExpression = this._isInCallExpression;\n this._isInCallExpression = true;\n this.validateExpression(node.callee);\n\n // If callee is an identifier and from the API then validate the arguments count\n if (Parser.isIdentifier(node.callee)) {\n // Check if the identifier as been declared in the script.\n // We have to do it before checking if it's an api function\n // in case the identifier overrides the api function.\n const idName = node.callee.name.toLowerCase();\n const identifierInfo = this.getIdentifierInfo(idName);\n const apiFunctionDefinition = this._apiDefinitions?.functionDefinitions?.get(idName);\n if (!identifierInfo && apiFunctionDefinition) {\n const diagnosticMessage = validateArgumentCount(apiFunctionDefinition, node.arguments.length);\n if (diagnosticMessage) {\n this.logDiagnostic(node.loc, diagnosticMessage);\n }\n }\n }\n\n node.arguments.forEach((e) => this.validateExpression(e));\n this._isInCallExpression = previousInCallExpression;\n }\n\n private validateIdentifier(node: Parser.Identifier): void {\n // Check if the Identifier is already defined\n const idName = node.name.toLowerCase();\n const identifierInfo = this.getIdentifierInfo(idName);\n if (identifierInfo) {\n // If the identifier we are validating is the one being assigned in\n // an assignment expression on the left handside then mark is as initialized\n if (this._assignmentValidationMode === \"left\" && this._identifierBeingAssigned === idName) {\n identifierInfo.initialized = true;\n return;\n }\n\n // If the identifier we are validating is the one being assigned in\n // an assignment expression on the left handside and the mode is right hanside\n // then skip the tagging of 'used'\n if (this._assignmentValidationMode === \"right\" && this._identifierBeingAssigned === idName) {\n return;\n }\n\n identifierInfo.used = true;\n return;\n }\n\n // We could not find a pre-defined identifier\n // Check if the identifier is a profile variable or a api constant\n if (this.isProfileVariable(idName) || this.isApiConstant(idName)) {\n return;\n }\n\n // Check if the identifier is an api function\n if (this.isApiFunction(idName)) {\n if (this._isInCallExpression) {\n return;\n }\n this.logDiagnostic(node.loc, {\n code: ValidationDiagnosticCodes.InvalidApiFunctionUsage,\n data: { identifier: node.name }\n });\n return;\n }\n\n // Check if the variable is being used inside of Function scope,\n // then it maybe a root scope variable that has not yet been declared, but will be\n // before the function is called.\n // Add it to the undeclared list\n if (this._isInFunctionScope) {\n let undeclaredVariableRecord = this._undeclaredIdentifiersInFunctions.get(idName);\n if (!undeclaredVariableRecord) {\n undeclaredVariableRecord = [];\n this._undeclaredIdentifiersInFunctions.set(idName, undeclaredVariableRecord);\n }\n undeclaredVariableRecord.push({ node, identifier: idName });\n\n // This will error at the end, if the undeclared identifier has not been removed.\n return;\n }\n\n this.logDiagnostic(node.loc, { code: ValidationDiagnosticCodes.NotDefined, data: { identifier: node.name } });\n }\n\n private validateLiteral(node: Parser.Literal): void {\n // This is for the special case of sql paramters\n // var foo = 1\n // Filter($layer, \"field = @foo\")\n // We need to parse literals for words starting with the @ sign\n // We then need to register the corresponding identifiers as used\n getSqlParameters(node.raw).forEach((p) => {\n const identifierInfo = this.getIdentifierInfo(p.toLowerCase());\n if (!identifierInfo) {\n return;\n }\n identifierInfo.used = true;\n });\n }\n\n private logProfileOrApiConflict(node: Parser.Identifier): void {\n const idName = node.name.toLowerCase();\n const isProfileVariable = this.isProfileVariable(idName);\n const isApiItem = this.isApiItem(idName);\n if (!isProfileVariable && !isApiItem) {\n return;\n }\n\n this.logDiagnostic(node.loc, {\n code: isProfileVariable\n ? ValidationDiagnosticCodes.ProfileVariablesConflict\n : ValidationDiagnosticCodes.ApiConflict,\n severity: DiagnosticSeverity.Warning,\n data: {\n identifier: node.name\n }\n });\n }\n\n private logReservedKeywordsConflict(node: Parser.Identifier): void {\n const idName = node.name.toLowerCase();\n if (!ArcadeReservedKeywords.includes(idName)) {\n return;\n }\n\n this.logDiagnostic(node.loc, {\n code: ValidationDiagnosticCodes.ReservedKeyword,\n severity: DiagnosticSeverity.Warning,\n data: {\n identifier: node.name\n }\n });\n }\n\n private validateObjectExpression(node: Parser.ObjectExpression): void {\n node.properties.forEach((e) => {\n this.validateExpression(e.value);\n });\n }\n\n private validateUnaryExpression(node: Parser.UnaryExpression): void {\n this.validateExpression(node.argument);\n }\n\n private validateUpdateExpression(node: Parser.UpdateExpression): void {\n this.validateExpression(node.argument);\n }\n\n private validateBinaryAndLogicalExpression(node: Parser.BinaryExpression | Parser.LogicalExpression): void {\n this.validateExpression(node.left);\n this.validateExpression(node.right);\n }\n\n private validateMemberExpression(node: Parser.MemberExpression): void {\n // MemberExpressions are tricky.\n // In some cases they could be:\n // - namespaced api constants: TextFormatting.BackwardSlash\n // - feature profile variables: $feature.field1\n // - none of the above: foo()['a'].bar\n // In addition, the member expression could be computed or not: foo['a'] or foo.a.\n // By its structure, member expressions have to be walked up to validate the various\n // parts.\n const path = this.flattenMemberExpressionAndValidate(node);\n\n // Validate the root expression\n const root = path[0].object;\n this.disableRecordIdentifierAssignment(this.validateExpression, root);\n\n // The beginning of the tree has to be an identifier. If not then it's all we can do.\n // Each object/property has already being validated in the previous step.\n if (!Parser.isIdentifier(root)) {\n return;\n }\n\n // Is it a known identifier, user could have overwritten the constant/profile variable\n if (this.getIdentifierInfo(root.name.toLowerCase())) {\n return;\n }\n\n // Validate with the profile before the constants in case the profile overwrites a constant\n if (this.validateMemberExpressionWithProfile(path)) {\n return;\n }\n\n // Validate as a constant\n if (this.validateConstantMemberExpression(path)) {\n return;\n }\n }\n\n private flattenMemberExpressionAndValidate(node: Parser.Expression): Parser.MemberExpression[] {\n switch (node.type) {\n case Parser.Syntax.MemberExpression:\n // Tricky case we want to validate `a[f]` but not `a.f` and we want to validate all the other\n // kind of property like `a[foo()]`\n if (!Parser.isIdentifier(node.property) || node.computed) {\n this.validateExpression(node.property);\n }\n // Walk the tree up\n return [...this.flattenMemberExpressionAndValidate(node.object), node];\n\n default:\n return [];\n }\n }\n\n private extractAndValidatePropertyName(node: Parser.Expression): string | null {\n switch (node.type) {\n case \"Identifier\":\n return node.name.toLowerCase();\n\n case \"Literal\":\n if (typeof node.value !== \"string\") {\n this.logDiagnostic(node.loc, { code: ValidationDiagnosticCodes.UnexpectedPropertyIdentifier });\n return null;\n }\n return node.value.toLowerCase();\n\n default:\n this.logDiagnostic(node.loc, { code: ValidationDiagnosticCodes.UnexpectedPropertyIdentifier });\n return null;\n }\n }\n\n private validateConstantMemberExpression(path: Parser.MemberExpression[]): boolean {\n const root = path[0];\n if (!Parser.isIdentifier(root.object)) {\n return false;\n }\n\n // Is the root matching a constant\n const idName = root.object.name.toLowerCase();\n const constantObject = this._apiDefinitions?.constantDefinitions?.get(idName);\n if (!constantObject) {\n return false;\n }\n\n // The root matches a constant but the constant is not a namespace, this is an issue\n if (constantObject.type !== \"namespace\") {\n this.logDiagnostic(root.property.loc, {\n code: ValidationDiagnosticCodes.NotADictionary,\n data: { identifier: idName }\n });\n return true;\n }\n\n // Try to match the property to a name\n const propertyName = this.extractAndValidatePropertyName(root.property);\n if (!propertyName) {\n return true;\n }\n\n // The property must be defined in the constant namespace\n if (!constantObject.members.some((p: any) => p.key === propertyName)) {\n const message = constantObject.members.reduce(\n (previous: any, p: any) => `${previous}${previous ? \" | \" : \"\"}${p.completion.label.split(\".\").pop()}`,\n \"\"\n );\n this.logDiagnostic(root.property.loc, {\n code: ValidationDiagnosticCodes.InvalidConstantIdentifier,\n data: { list: message }\n });\n }\n\n // Constant have only one level, there should be no other expression in the path\n if (path.length > 1) {\n this.logDiagnostic(path[1].property.loc, { code: ValidationDiagnosticCodes.UnexpectedPropertyIdentifier });\n }\n\n return true;\n }\n\n private validateMemberExpressionWithProfile(path: Parser.MemberExpression[]): boolean {\n const root = path[0];\n if (root.object.type !== Parser.Syntax.Identifier) {\n return false;\n }\n\n // Is the path matching a profile variable dictionary or feature?\n const idName = root.object.name.toLowerCase();\n const profileVariable = this._profileVariables?.find((g: any) => g.key === idName);\n if (!profileVariable) {\n return false;\n }\n\n if (isValueVariable(profileVariable)) {\n this.logDiagnostic(root.object.loc, {\n code: ValidationDiagnosticCodes.NotADictionary,\n data: { identifier: profileVariable.name }\n });\n return true;\n }\n\n // Profile variable dictionaries/features are immutable\n if (this._identifierBeingAssigned === idName) {\n this.logDiagnostic(root.loc, { code: ValidationDiagnosticCodes.ProfileVariablesAreImmutable });\n return true;\n }\n\n // Validate the property path\n let currentDictionaryLevel: ApiVariable = profileVariable;\n for (let i = 0; i < path.length; i++) {\n // If one of the path is computed then we can stop the validation of the path.\n // We cannot validate anything\n if (path[i].computed) {\n return true;\n }\n\n // The level has to be a dictionary\n if (isValueVariable(currentDictionaryLevel)) {\n this.logDiagnostic(path[i - 1]?.property.loc ?? path[i].object.loc, {\n code: ValidationDiagnosticCodes.NotADictionary,\n data: { identifier: currentDictionaryLevel.name }\n });\n return true;\n }\n\n const propertyName = this.extractAndValidatePropertyName(path[i].property);\n if (!propertyName) {\n return true;\n }\n\n if (currentDictionaryLevel.properties.length === 0) {\n // It's declared as a dictionary but there are no properties.\n // We will log a warning but accept the property\n this.logDiagnostic(path[i].property.loc, {\n code: ValidationDiagnosticCodes.UnknownPropertyIdentifier,\n data: { identifier: propertyName },\n severity: DiagnosticSeverity.Warning\n });\n return true;\n }\n\n const dictionaryProperty: ApiVariable | undefined = currentDictionaryLevel.properties.find(\n (p) => p.name.toLowerCase() === propertyName\n );\n if (!dictionaryProperty) {\n const message = currentDictionaryLevel.properties.reduce(\n (previous: any, p: any) => `${previous}${previous ? \" | \" : \"\"}${p.name.split(\".\").pop()}`,\n \"\"\n );\n this.logDiagnostic(path[i].property.loc, {\n code: ValidationDiagnosticCodes.InvalidPropertyIdentifier,\n data: { list: message }\n });\n return true;\n }\n\n currentDictionaryLevel = dictionaryProperty;\n }\n\n return true;\n }\n\n private recordVariableIdentifier(\n node: Parser.Identifier,\n props: { initialized: boolean; inBlock?: boolean }\n ): boolean {\n // Check if we have a conflict with reserved keywords\n this.logReservedKeywordsConflict(node);\n\n // Check if we have a conflict with profile, api constants, and api functions\n // In general it is not a good idea to redifine a api or profile\n // variable. It leads to confusion and errors\n this.logProfileOrApiConflict(node);\n\n // Find if we have an existing identifier\n const idName = node.name.toLowerCase();\n let identifierInfo = this.getIdentifierInfo(idName);\n\n // If we found an identifier, we need to validate that it's not a redefinition,\n // The logic is:\n // - if the scope is a function then it's fine to redefine profile variables or script scope identifiers.\n // - if the scope is a function then we will warn if there is a redefinition inside the function\n // - if the scope is not a function, then:\n // - if the identifier conflict with a profile variable we will warn\n // - if the identifier is already defined at the script level we will warn\n // - if the identifer has only be defined in a block then we will not warn\n const functionScopeIssue = identifierInfo && this._isInFunctionScope && identifierInfo.scope === \"function\";\n const scriptScopeIssue = identifierInfo && !this._isInFunctionScope && identifierInfo.scope === \"script\";\n if (functionScopeIssue || scriptScopeIssue) {\n this.logDiagnostic(node.loc, {\n code: ValidationDiagnosticCodes.AlreadyDefined,\n data: { identifier: node.name },\n severity: DiagnosticSeverity.Warning\n });\n }\n\n const inBlock = props.inBlock ?? this._isInBlock;\n const { initialized } = props;\n\n // If we have no idenifier or if this is redefinition of a script scope variable in a function scope\n // then create a new record\n if (!identifierInfo || (this._isInFunctionScope && identifierInfo.scope !== \"function\")) {\n // Either we don't a identifier then we need to create a new record\n // Or we are under\n const scope = this._isInFunctionScope ? \"function\" : inBlock ? \"block\" : \"script\";\n identifierInfo = {\n node,\n used: false,\n initialized,\n scope\n };\n } else {\n // Redefinition, we need to reset some of the props\n identifierInfo.node = node;\n identifierInfo.used = false;\n identifierInfo.initialized = initialized;\n }\n\n // If the identifier was up to now in a block and now it is redeclared\n // outside a block then we should warn\n if (identifierInfo.scope === \"block\" && !inBlock) {\n identifierInfo.scope = \"script\";\n this.logDiagnostic(node.loc, {\n code: ValidationDiagnosticCodes.AlreadyDefined,\n data: { identifier: node.name },\n severity: DiagnosticSeverity.Warning\n });\n }\n\n // Update the map\n this.setIdentiferInfo(idName, identifierInfo);\n\n return false;\n }\n\n private recordImportIdentifier(node: Parser.ImportDeclaration): void {\n // We only support import foo from 'uri'. Basically, we are only support one identifier\n const idNode = node.specifiers[0].local;\n\n // Avoid conflict with profile and api identifiers\n this.logProfileOrApiConflict(idNode);\n\n // Validate the function id is not already defined\n const idName = idNode.name.toLowerCase();\n let identifierInfo = this.getIdentifierInfo(idName);\n\n if (identifierInfo?.scope) {\n this.logDiagnostic(node.specifiers[0].local.loc, {\n code: ValidationDiagnosticCodes.AlreadyDefined,\n data: { identifier: node.specifiers[0].local.name },\n severity: DiagnosticSeverity.Warning\n });\n }\n\n identifierInfo = {\n node: node.specifiers[0].local,\n used: false,\n ...identifierInfo,\n scope: \"script\",\n initialized: true\n };\n\n // Update the map\n this.setIdentiferInfo(idName, identifierInfo);\n }\n\n private recordFunctionIdentifier(node: Parser.FunctionDeclaration): void {\n // Avoid conflict with profile and api identifiers\n this.logProfileOrApiConflict(node.id);\n\n // Validate the function id is not already defined\n const idName = node.id.name.toLowerCase();\n let identifierInfo = this.getIdentifierInfo(idName);\n\n if (identifierInfo?.scope) {\n this.logDiagnostic(node.id.loc, {\n code: ValidationDiagnosticCodes.AlreadyDefined,\n data: { identifier: node.id.name },\n severity: DiagnosticSeverity.Warning\n });\n }\n\n identifierInfo = {\n node: node.id,\n used: false,\n ...identifierInfo,\n scope: \"script\",\n initialized: true\n };\n\n // Update the map\n this.setIdentiferInfo(idName, identifierInfo);\n }\n\n private recordParamAsIdentifier(node: Parser.Identifier): boolean {\n return this.recordVariableIdentifier(node, { initialized: true });\n }\n\n private diagnoseIdentifiers(): void {\n (this._functionScopeIdentifiers ?? this._scriptScopeIdentifiers).forEach((identifierInfo) => {\n if (!identifierInfo.node) {\n // Profile variables\n return;\n }\n\n if (!identifierInfo.used) {\n this.logDiagnostic(identifierInfo.node.loc, {\n code: identifierInfo.initialized\n ? ValidationDiagnosticCodes.AssignedNeverUsed\n : ValidationDiagnosticCodes.DefinedNeverUsed,\n data: { identifier: identifierInfo.node.name },\n severity: DiagnosticSeverity.Warning\n });\n } else if (!identifierInfo.initialized) {\n this.logDiagnostic(identifierInfo.node.loc, {\n code: ValidationDiagnosticCodes.DefinedNeverAssigned,\n data: { identifier: identifierInfo.node.name },\n severity: DiagnosticSeverity.Warning\n });\n }\n });\n }\n}\n\nfunction isParsingDiagnostic(error: any): error is Parser.Diagnostic {\n return (error as Error)?.name === \"ParsingError\";\n}\n\nfunction isBlockStatementEmpty(node: Parser.Statement | null | undefined): boolean {\n return Parser.isEmptyStatement(node) || (Parser.isBlockStatement(node) && !node?.body.length);\n}\n\nfunction validateArgumentCount(\n functionDefinition: ApiFunctionDefinition,\n argumentCount: number\n): PartialDiagnostic | null {\n if (!functionDefinition || argumentCount === undefined || argumentCount === null || argumentCount < 0) {\n return null;\n }\n const { min, max } = functionDefinition.overloads.reduce(\n (result, overload) => {\n const { min, max } = overload.parametersInfo;\n if (result.min >= 0) {\n result.min = Math.min(min, result.min);\n }\n if (result.max >= 0) {\n result.max = max < 0 ? max : Math.max(max, result.max);\n }\n\n return result;\n },\n { min: Infinity, max: 0 }\n );\n\n if (argumentCount < min) {\n if (min > 0) {\n return { code: ValidationDiagnosticCodes.NotEnoughArguments, data: { min } };\n }\n return { code: ValidationDiagnosticCodes.NoArgumentExpected };\n }\n\n if (max >= 0 && argumentCount > max) {\n return { code: ValidationDiagnosticCodes.TooManyArguments, data: { max } };\n }\n\n // If it matches this overload then we are good\n return null;\n}\n\nconst sqlParametersExp = new RegExp(/\\B@\\w+/g);\n\nfunction getSqlParameters(literal: string): string[] {\n return Array.from((literal ?? \"\").matchAll(sqlParametersExp), (i) => i[0].slice(1));\n}\n","import { TextDocument } from \"vscode-languageserver-textdocument\";\nimport { CompletionList, Position, TextEdit } from \"vscode-languageserver-types\";\nimport { ArcadeApiService } from \"./services/arcade-api\";\nimport { arcadeComplete } from \"./services/arcade-completetion\";\nimport { arcadeFormat } from \"./services/arcade-formatting\";\nimport { ArcadeValidationService } from \"./services/arcade-validation\";\nimport { ApiContext } from \"./services/api-context\";\nimport { ArcadeLanguageServiceSettings } from \"./services/settings\";\nimport { ApiCategory } from \"./services/api-types\";\nimport { Diagnostic } from \"./services/api-diagnostic\";\n\nexport class ArcadeLanguageService {\n private languageOptions: ArcadeLanguageServiceSettings = {};\n private apiService: ArcadeApiService | undefined;\n\n public configure(languageOptions: ArcadeLanguageServiceSettings = {}): void {\n this.languageOptions = languageOptions ?? {};\n this.apiService = new ArcadeApiService(this.languageOptions);\n }\n\n public async doValidation(document: TextDocument, context: ApiContext): Promise<Diagnostic[]> {\n if (!this.apiService) {\n return [];\n }\n\n const apiDefinitions = await this.apiService.getApiDatabase(context);\n\n const { profile: { variables = [] } = {} } = context;\n const { diagnostics } = new ArcadeValidationService(apiDefinitions, variables).validateScript(document.getText());\n\n return diagnostics;\n }\n\n public async doComplete(document: TextDocument, position: Position, context: ApiContext): Promise<CompletionList> {\n if (!this.apiService) {\n return { isIncomplete: false, items: [] };\n }\n\n const apiDefinitions = await this.apiService.getApiDatabase(context);\n const completionList = await arcadeComplete(document, position, apiDefinitions, context);\n return completionList ?? { isIncomplete: false, items: [] };\n }\n\n public doFormat(document: TextDocument, context: ApiContext): TextEdit[] {\n return arcadeFormat(document, context);\n }\n\n public async getApiLibrary(context: ApiContext): Promise<ApiCategory[]> {\n if (!this.apiService) {\n return [];\n }\n\n const apiDefinitions = await this.apiService.getApiDatabase(context);\n return apiDefinitions.categories ?? [];\n }\n}\n"],"mappings":";AA6IO,SAAS,gBAAgB,UAAwE;AACtG,SAAO,CAAC,CAAC,YAAY,SAAS,SAAS;AACzC;AAKO,SAAS,qBAAqB,UAA6E;AAChH,SAAO,UAAU,SAAS;AAC5B;;;ACrJO,IAAK,WAAL,kBAAKA,cAAL;AACLA,YAAA,OAAA,IAAQ;AACRA,YAAA,MAAA,IAAO;AACPA,YAAA,MAAA,IAAO;AAHG,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;AAML,IAAK,WAAL,kBAAKC,cAAL;AACLA,YAAA,OAAA,IAAQ;AACRA,YAAA,UAAA,IAAW;AACXA,YAAA,MAAA,IAAO;AACPA,YAAA,KAAA,IAAM;AACNA,YAAA,MAAA,IAAO;AACPA,YAAA,UAAA,IAAW;AACXA,YAAA,IAAA,IAAK;AACLA,YAAA,QAAA,IAAS;AACTA,YAAA,QAAA,IAAS;AACTA,YAAA,IAAA,IAAK;AACLA,YAAA,QAAA,IAAS;AACTA,YAAA,KAAA,IAAM;AACNA,YAAA,OAAA,IAAQ;AAbE,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;AAkBL,IAAW,SAAX,kBAAWC,YAAX;AACLA,UAAA,sBAAA,IAAuB;AACvBA,UAAA,iBAAA,IAAkB;AAClBA,UAAA,cAAA,IAAe;AACfA,UA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U,gBAAgB,OAAO;AACvF,WAAO,kBAAkB,EAAE,cAAc,OAAO,OAAO,CAAC,EAAE;AAAA,EAC5D;AAAA,EAEO,SAAS,UAAwB,SAAiC;AACvE,WAAO,aAAa,UAAU,OAAO;AAAA,EACvC;AAAA,EAEA,MAAa,cAAc,SAA6C;AACtE,QAAI,CAAC,KAAK,YAAY;AACpB,aAAO,CAAC;AAAA,IACV;AAEA,UAAM,iBAAiB,MAAM,KAAK,WAAW,eAAe,OAAO;AACnE,WAAO,eAAe,cAAc,CAAC;AAAA,EACvC;AACF;","names":["Literals","Keywords","Syntax","index","line","operator","lastRawToken","ValidationDiagnosticCodes","DiagnosticMessages","CompletionItemKind","InsertTextFormat","InsertTextMode","CompletionItemKind","InsertTextFormat","InsertTextMode","CompletionItemKind","InsertTextMode","InsertTextFormat","CompletionItemKind","InsertTextFormat","InsertTextMode","CompletionItemKind","InsertTextMode","InsertTextFormat","functionDefinition","label","key","node","lineTerminatorSeqExp","formattedLines","value","getTrueLocation","node","isBlockStatement","header","formattedArgument","DiagnosticMessages","min","max"]}