// Code generated by _scripts/generate-encoder.ts. DO NOT EDIT. package encoder import ( "fmt" "github.com/microsoft/typescript-go/internal/ast" ) func (d *astDecoder) createStringNode(kind ast.Kind, data uint32, commonData uint8) (*ast.Node, error) { strIdx := data & NodeDataStringIndexMask text := d.getString(strIdx) switch kind { case ast.KindIdentifier: return d.factory.NewIdentifier(text), nil case ast.KindPrivateIdentifier: return d.factory.NewPrivateIdentifier(text), nil case ast.KindJsxText: containsOnlyTriviaWhiteSpaces := commonData&1 != 0 return d.factory.NewJsxText(text, containsOnlyTriviaWhiteSpaces), nil case ast.KindJSDocText: return d.factory.NewJSDocText([]string{text}), nil case ast.KindJSDocLink: return d.factory.NewJSDocLink(nil, []string{text}), nil case ast.KindJSDocLinkPlain: return d.factory.NewJSDocLinkPlain(nil, []string{text}), nil case ast.KindJSDocLinkCode: return d.factory.NewJSDocLinkCode(nil, []string{text}), nil default: return nil, fmt.Errorf("unknown string node kind %v", kind) } } func (d *astDecoder) createExtendedNode(kind ast.Kind, data uint32, childIndices []int, commonData uint8) (*ast.Node, error) { switch kind { case ast.KindStringLiteral: return d.decodeExtendedData_StringLiteral(data, childIndices, commonData) case ast.KindNumericLiteral: return d.decodeExtendedData_NumericLiteral(data, childIndices, commonData) case ast.KindBigIntLiteral: return d.decodeExtendedData_BigIntLiteral(data, childIndices, commonData) case ast.KindRegularExpressionLiteral: return d.decodeExtendedData_RegularExpressionLiteral(data, childIndices, commonData) case ast.KindNoSubstitutionTemplateLiteral: return d.decodeExtendedData_NoSubstitutionTemplateLiteral(data, childIndices, commonData) case ast.KindTemplateHead: return d.decodeExtendedData_TemplateHead(data, childIndices, commonData) case ast.KindTemplateMiddle: return d.decodeExtendedData_TemplateMiddle(data, childIndices, commonData) case ast.KindTemplateTail: return d.decodeExtendedData_TemplateTail(data, childIndices, commonData) case ast.KindSourceFile: return d.decodeExtendedData_SourceFile(data, childIndices, commonData) default: return nil, fmt.Errorf("unknown extended data node kind %v", kind) } } func (d *astDecoder) createChildrenNode(kind ast.Kind, data uint32, childIndices []int, commonData uint8) (*ast.Node, error) { mask := uint8(data & NodeDataChildMask) switch kind { case ast.KindUnknown, ast.KindEndOfFile, ast.KindSingleLineCommentTrivia, ast.KindMultiLineCommentTrivia, ast.KindNewLineTrivia, ast.KindWhitespaceTrivia, ast.KindConflictMarkerTrivia, ast.KindNonTextFileMarkerTrivia, ast.KindNumericLiteral, ast.KindBigIntLiteral, ast.KindStringLiteral, ast.KindJsxText, ast.KindJsxTextAllWhiteSpaces, ast.KindRegularExpressionLiteral, ast.KindNoSubstitutionTemplateLiteral, ast.KindTemplateHead, ast.KindTemplateMiddle, ast.KindTemplateTail, ast.KindOpenBraceToken, ast.KindCloseBraceToken, ast.KindOpenParenToken, ast.KindCloseParenToken, ast.KindOpenBracketToken, ast.KindCloseBracketToken, ast.KindDotToken, ast.KindDotDotDotToken, ast.KindSemicolonToken, ast.KindCommaToken, ast.KindQuestionDotToken, ast.KindLessThanToken, ast.KindLessThanSlashToken, ast.KindGreaterThanToken, ast.KindLessThanEqualsToken, ast.KindGreaterThanEqualsToken, ast.KindEqualsEqualsToken, ast.KindExclamationEqualsToken, ast.KindEqualsEqualsEqualsToken, ast.KindExclamationEqualsEqualsToken, ast.KindEqualsGreaterThanToken, ast.KindPlusToken, ast.KindMinusToken, ast.KindAsteriskToken, ast.KindAsteriskAsteriskToken, ast.KindSlashToken, ast.KindPercentToken, ast.KindPlusPlusToken, ast.KindMinusMinusToken, ast.KindLessThanLessThanToken, ast.KindGreaterThanGreaterThanToken, ast.KindGreaterThanGreaterThanGreaterThanToken, ast.KindAmpersandToken, ast.KindBarToken, ast.KindCaretToken, ast.KindExclamationToken, ast.KindTildeToken, ast.KindAmpersandAmpersandToken, ast.KindBarBarToken, ast.KindQuestionToken, ast.KindColonToken, ast.KindAtToken, ast.KindQuestionQuestionToken, ast.KindBacktickToken, ast.KindHashToken, ast.KindEqualsToken, ast.KindPlusEqualsToken, ast.KindMinusEqualsToken, ast.KindAsteriskEqualsToken, ast.KindAsteriskAsteriskEqualsToken, ast.KindSlashEqualsToken, ast.KindPercentEqualsToken, ast.KindLessThanLessThanEqualsToken, ast.KindGreaterThanGreaterThanEqualsToken, ast.KindGreaterThanGreaterThanGreaterThanEqualsToken, ast.KindAmpersandEqualsToken, ast.KindBarEqualsToken, ast.KindBarBarEqualsToken, ast.KindAmpersandAmpersandEqualsToken, ast.KindQuestionQuestionEqualsToken, ast.KindCaretEqualsToken, ast.KindIdentifier, ast.KindPrivateIdentifier, ast.KindJSDocCommentTextToken, ast.KindBreakKeyword, ast.KindCaseKeyword, ast.KindCatchKeyword, ast.KindClassKeyword, ast.KindConstKeyword, ast.KindContinueKeyword, ast.KindDebuggerKeyword, ast.KindDefaultKeyword, ast.KindDeleteKeyword, ast.KindDoKeyword, ast.KindElseKeyword, ast.KindEnumKeyword, ast.KindExportKeyword, ast.KindExtendsKeyword, ast.KindFinallyKeyword, ast.KindForKeyword, ast.KindFunctionKeyword, ast.KindIfKeyword, ast.KindInKeyword, ast.KindInstanceOfKeyword, ast.KindNewKeyword, ast.KindReturnKeyword, ast.KindSwitchKeyword, ast.KindThrowKeyword, ast.KindTryKeyword, ast.KindTypeOfKeyword, ast.KindVarKeyword, ast.KindWhileKeyword, ast.KindWithKeyword, ast.KindImplementsKeyword, ast.KindInterfaceKeyword, ast.KindLetKeyword, ast.KindPackageKeyword, ast.KindPrivateKeyword, ast.KindProtectedKeyword, ast.KindPublicKeyword, ast.KindStaticKeyword, ast.KindYieldKeyword, ast.KindAbstractKeyword, ast.KindAccessorKeyword, ast.KindAsKeyword, ast.KindAssertsKeyword, ast.KindAssertKeyword, ast.KindAsyncKeyword, ast.KindAwaitKeyword, ast.KindConstructorKeyword, ast.KindDeclareKeyword, ast.KindGetKeyword, ast.KindImmediateKeyword, ast.KindInferKeyword, ast.KindIsKeyword, ast.KindKeyOfKeyword, ast.KindModuleKeyword, ast.KindNamespaceKeyword, ast.KindOutKeyword, ast.KindReadonlyKeyword, ast.KindRequireKeyword, ast.KindSatisfiesKeyword, ast.KindSetKeyword, ast.KindTypeKeyword, ast.KindUniqueKeyword, ast.KindUsingKeyword, ast.KindFromKeyword, ast.KindGlobalKeyword, ast.KindOverrideKeyword, ast.KindOfKeyword, ast.KindDeferKeyword: return d.factory.NewToken(kind), nil case ast.KindQualifiedName: it := newChildIter(childIndices) left := d.nodeAt(it.nextIf(mask, 0)) right := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewQualifiedName(left, right), nil case ast.KindComputedPropertyName: return d.factory.NewComputedPropertyName(d.singleChild(childIndices)), nil case ast.KindDecorator: return d.factory.NewDecorator(d.singleChild(childIndices)), nil case ast.KindEmptyStatement: return d.factory.NewEmptyStatement(), nil case ast.KindIfStatement: it := newChildIter(childIndices) expression := d.nodeAt(it.nextIf(mask, 0)) thenStatement := d.nodeAt(it.nextIf(mask, 1)) elseStatement := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewIfStatement(expression, thenStatement, elseStatement), nil case ast.KindDoStatement: it := newChildIter(childIndices) statement := d.nodeAt(it.nextIf(mask, 0)) expression := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewDoStatement(statement, expression), nil case ast.KindWhileStatement: it := newChildIter(childIndices) expression := d.nodeAt(it.nextIf(mask, 0)) statement := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewWhileStatement(expression, statement), nil case ast.KindForStatement: it := newChildIter(childIndices) initializer := d.nodeAt(it.nextIf(mask, 0)) condition := d.nodeAt(it.nextIf(mask, 1)) incrementor := d.nodeAt(it.nextIf(mask, 2)) statement := d.nodeAt(it.nextIf(mask, 3)) return d.factory.NewForStatement(initializer, condition, incrementor, statement), nil case ast.KindForInStatement, ast.KindForOfStatement: it := newChildIter(childIndices) awaitModifier := d.nodeAt(it.nextIf(mask, 0)) initializer := d.nodeAt(it.nextIf(mask, 1)) expression := d.nodeAt(it.nextIf(mask, 2)) statement := d.nodeAt(it.nextIf(mask, 3)) return d.factory.NewForInOrOfStatement(kind, awaitModifier, initializer, expression, statement), nil case ast.KindBreakStatement: return d.factory.NewBreakStatement(d.singleChild(childIndices)), nil case ast.KindContinueStatement: return d.factory.NewContinueStatement(d.singleChild(childIndices)), nil case ast.KindReturnStatement: return d.factory.NewReturnStatement(d.singleChild(childIndices)), nil case ast.KindWithStatement: it := newChildIter(childIndices) expression := d.nodeAt(it.nextIf(mask, 0)) statement := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewWithStatement(expression, statement), nil case ast.KindSwitchStatement: it := newChildIter(childIndices) expression := d.nodeAt(it.nextIf(mask, 0)) caseBlock := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewSwitchStatement(expression, caseBlock), nil case ast.KindCaseBlock: return d.factory.NewCaseBlock(d.singleNodeListChild(childIndices)), nil case ast.KindCaseClause, ast.KindDefaultClause: it := newChildIter(childIndices) expression := d.nodeAt(it.nextIf(mask, 0)) statements := d.nodeListAt(it.nextIf(mask, 1)) return d.factory.NewCaseOrDefaultClause(kind, expression, statements), nil case ast.KindThrowStatement: return d.factory.NewThrowStatement(d.singleChild(childIndices)), nil case ast.KindTryStatement: it := newChildIter(childIndices) tryBlock := d.nodeAt(it.nextIf(mask, 0)) catchClause := d.nodeAt(it.nextIf(mask, 1)) finallyBlock := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewTryStatement(tryBlock, catchClause, finallyBlock), nil case ast.KindCatchClause: it := newChildIter(childIndices) variableDeclaration := d.nodeAt(it.nextIf(mask, 0)) block := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewCatchClause(variableDeclaration, block), nil case ast.KindDebuggerStatement: return d.factory.NewDebuggerStatement(), nil case ast.KindLabeledStatement: it := newChildIter(childIndices) label := d.nodeAt(it.nextIf(mask, 0)) statement := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewLabeledStatement(label, statement), nil case ast.KindExpressionStatement: return d.factory.NewExpressionStatement(d.singleChild(childIndices)), nil case ast.KindBlock: multiLine := commonData&1 != 0 var list *ast.NodeList if len(childIndices) > 0 { list = d.nodeListAt(childIndices[0]) } return d.factory.NewBlock(list, multiLine), nil case ast.KindVariableStatement: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) declarationList := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewVariableStatement(modifiers, declarationList), nil case ast.KindVariableDeclaration: it := newChildIter(childIndices) name := d.nodeAt(it.nextIf(mask, 0)) exclamationToken := d.nodeAt(it.nextIf(mask, 1)) typeNode := d.nodeAt(it.nextIf(mask, 2)) initializer := d.nodeAt(it.nextIf(mask, 3)) return d.factory.NewVariableDeclaration(name, exclamationToken, typeNode, initializer), nil case ast.KindVariableDeclarationList: return d.factory.NewVariableDeclarationList(d.singleNodeListChild(childIndices), 0), nil case ast.KindObjectBindingPattern, ast.KindArrayBindingPattern: return d.factory.NewBindingPattern(kind, d.singleNodeListChild(childIndices)), nil case ast.KindParameter: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) dotDotDotToken := d.nodeAt(it.nextIf(mask, 1)) name := d.nodeAt(it.nextIf(mask, 2)) questionToken := d.nodeAt(it.nextIf(mask, 3)) typeNode := d.nodeAt(it.nextIf(mask, 4)) initializer := d.nodeAt(it.nextIf(mask, 5)) return d.factory.NewParameterDeclaration(modifiers, dotDotDotToken, name, questionToken, typeNode, initializer), nil case ast.KindBindingElement: it := newChildIter(childIndices) dotDotDotToken := d.nodeAt(it.nextIf(mask, 0)) propertyName := d.nodeAt(it.nextIf(mask, 1)) name := d.nodeAt(it.nextIf(mask, 2)) initializer := d.nodeAt(it.nextIf(mask, 3)) return d.factory.NewBindingElement(dotDotDotToken, propertyName, name, initializer), nil case ast.KindMissingDeclaration: var mods *ast.ModifierList if len(childIndices) > 0 { mods = d.modifierListAt(childIndices[0]) } return d.factory.NewMissingDeclaration(mods), nil case ast.KindFunctionDeclaration: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) asteriskToken := d.nodeAt(it.nextIf(mask, 1)) name := d.nodeAt(it.nextIf(mask, 2)) typeParameters := d.nodeListAt(it.nextIf(mask, 3)) parameters := d.nodeListAt(it.nextIf(mask, 4)) typeNode := d.nodeAt(it.nextIf(mask, 5)) body := d.nodeAt(it.nextIf(mask, 6)) return d.factory.NewFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, typeNode, nil, body), nil case ast.KindClassDeclaration: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) typeParameters := d.nodeListAt(it.nextIf(mask, 2)) heritageClauses := d.nodeListAt(it.nextIf(mask, 3)) members := d.nodeListAt(it.nextIf(mask, 4)) return d.factory.NewClassDeclaration(modifiers, name, typeParameters, heritageClauses, members), nil case ast.KindClassExpression: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) typeParameters := d.nodeListAt(it.nextIf(mask, 2)) heritageClauses := d.nodeListAt(it.nextIf(mask, 3)) members := d.nodeListAt(it.nextIf(mask, 4)) return d.factory.NewClassExpression(modifiers, name, typeParameters, heritageClauses, members), nil case ast.KindHeritageClause: token := ast.KindExtendsKeyword if commonData&1 != 0 { token = ast.KindImplementsKeyword } return d.factory.NewHeritageClause(token, d.singleNodeListChild(childIndices)), nil case ast.KindInterfaceDeclaration: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) typeParameters := d.nodeListAt(it.nextIf(mask, 2)) heritageClauses := d.nodeListAt(it.nextIf(mask, 3)) members := d.nodeListAt(it.nextIf(mask, 4)) return d.factory.NewInterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, members), nil case ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) typeParameters := d.nodeListAt(it.nextIf(mask, 2)) typeNode := d.nodeAt(it.nextIf(mask, 3)) if kind == ast.KindJSTypeAliasDeclaration { return d.factory.NewJSTypeAliasDeclaration(modifiers, name, typeParameters, typeNode), nil } return d.factory.NewTypeAliasDeclaration(modifiers, name, typeParameters, typeNode), nil case ast.KindEnumMember: it := newChildIter(childIndices) name := d.nodeAt(it.nextIf(mask, 0)) initializer := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewEnumMember(name, initializer), nil case ast.KindEnumDeclaration: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) members := d.nodeListAt(it.nextIf(mask, 2)) return d.factory.NewEnumDeclaration(modifiers, name, members), nil case ast.KindModuleBlock: return d.factory.NewModuleBlock(d.singleNodeListChild(childIndices)), nil case ast.KindNotEmittedStatement: return d.factory.NewNotEmittedStatement(), nil case ast.KindNotEmittedTypeElement: return d.factory.NewNotEmittedTypeElement(), nil case ast.KindImportDeclaration, ast.KindJSImportDeclaration: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) importClause := d.nodeAt(it.nextIf(mask, 1)) moduleSpecifier := d.nodeAt(it.nextIf(mask, 2)) attributes := d.nodeAt(it.nextIf(mask, 3)) if kind == ast.KindJSImportDeclaration { return d.factory.NewJSImportDeclaration(modifiers, importClause, moduleSpecifier, attributes), nil } return d.factory.NewImportDeclaration(modifiers, importClause, moduleSpecifier, attributes), nil case ast.KindExternalModuleReference: return d.factory.NewExternalModuleReference(d.singleChild(childIndices)), nil case ast.KindNamespaceImport: return d.factory.NewNamespaceImport(d.singleChild(childIndices)), nil case ast.KindNamedImports: return d.factory.NewNamedImports(d.singleNodeListChild(childIndices)), nil case ast.KindExportAssignment: isExportEquals := commonData&1 != 0 it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) typeNode := d.nodeAt(it.nextIf(mask, 1)) expression := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewExportAssignment(modifiers, isExportEquals, typeNode, expression), nil case ast.KindNamespaceExportDeclaration: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewNamespaceExportDeclaration(modifiers, name), nil case ast.KindNamespaceExport: return d.factory.NewNamespaceExport(d.singleChild(childIndices)), nil case ast.KindNamedExports: return d.factory.NewNamedExports(d.singleNodeListChild(childIndices)), nil case ast.KindExportSpecifier: isTypeOnly := commonData&1 != 0 it := newChildIter(childIndices) propertyName := d.nodeAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewExportSpecifier(isTypeOnly, propertyName, name), nil case ast.KindCallSignature: it := newChildIter(childIndices) typeParameters := d.nodeListAt(it.nextIf(mask, 0)) parameters := d.nodeListAt(it.nextIf(mask, 1)) typeNode := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewCallSignatureDeclaration(typeParameters, parameters, typeNode), nil case ast.KindConstructSignature: it := newChildIter(childIndices) typeParameters := d.nodeListAt(it.nextIf(mask, 0)) parameters := d.nodeListAt(it.nextIf(mask, 1)) typeNode := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewConstructSignatureDeclaration(typeParameters, parameters, typeNode), nil case ast.KindConstructor: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) typeParameters := d.nodeListAt(it.nextIf(mask, 1)) parameters := d.nodeListAt(it.nextIf(mask, 2)) typeNode := d.nodeAt(it.nextIf(mask, 3)) body := d.nodeAt(it.nextIf(mask, 4)) return d.factory.NewConstructorDeclaration(modifiers, typeParameters, parameters, typeNode, nil, body), nil case ast.KindGetAccessor: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) typeParameters := d.nodeListAt(it.nextIf(mask, 2)) parameters := d.nodeListAt(it.nextIf(mask, 3)) typeNode := d.nodeAt(it.nextIf(mask, 4)) body := d.nodeAt(it.nextIf(mask, 5)) return d.factory.NewGetAccessorDeclaration(modifiers, name, typeParameters, parameters, typeNode, nil, body), nil case ast.KindSetAccessor: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) typeParameters := d.nodeListAt(it.nextIf(mask, 2)) parameters := d.nodeListAt(it.nextIf(mask, 3)) typeNode := d.nodeAt(it.nextIf(mask, 4)) body := d.nodeAt(it.nextIf(mask, 5)) return d.factory.NewSetAccessorDeclaration(modifiers, name, typeParameters, parameters, typeNode, nil, body), nil case ast.KindIndexSignature: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) parameters := d.nodeListAt(it.nextIf(mask, 1)) typeNode := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewIndexSignatureDeclaration(modifiers, parameters, typeNode), nil case ast.KindMethodSignature: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) postfixToken := d.nodeAt(it.nextIf(mask, 2)) typeParameters := d.nodeListAt(it.nextIf(mask, 3)) parameters := d.nodeListAt(it.nextIf(mask, 4)) typeNode := d.nodeAt(it.nextIf(mask, 5)) return d.factory.NewMethodSignatureDeclaration(modifiers, name, postfixToken, typeParameters, parameters, typeNode), nil case ast.KindMethodDeclaration: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) asteriskToken := d.nodeAt(it.nextIf(mask, 1)) name := d.nodeAt(it.nextIf(mask, 2)) postfixToken := d.nodeAt(it.nextIf(mask, 3)) typeParameters := d.nodeListAt(it.nextIf(mask, 4)) parameters := d.nodeListAt(it.nextIf(mask, 5)) typeNode := d.nodeAt(it.nextIf(mask, 6)) body := d.nodeAt(it.nextIf(mask, 7)) return d.factory.NewMethodDeclaration(modifiers, asteriskToken, name, postfixToken, typeParameters, parameters, typeNode, nil, body), nil case ast.KindPropertySignature: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) postfixToken := d.nodeAt(it.nextIf(mask, 2)) typeNode := d.nodeAt(it.nextIf(mask, 3)) initializer := d.nodeAt(it.nextIf(mask, 4)) return d.factory.NewPropertySignatureDeclaration(modifiers, name, postfixToken, typeNode, initializer), nil case ast.KindPropertyDeclaration: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) postfixToken := d.nodeAt(it.nextIf(mask, 2)) typeNode := d.nodeAt(it.nextIf(mask, 3)) initializer := d.nodeAt(it.nextIf(mask, 4)) return d.factory.NewPropertyDeclaration(modifiers, name, postfixToken, typeNode, initializer), nil case ast.KindSemicolonClassElement: return d.factory.NewSemicolonClassElement(), nil case ast.KindClassStaticBlockDeclaration: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) body := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewClassStaticBlockDeclaration(modifiers, body), nil case ast.KindOmittedExpression: return d.factory.NewOmittedExpression(), nil case ast.KindFalseKeyword, ast.KindImportKeyword, ast.KindNullKeyword, ast.KindSuperKeyword, ast.KindThisKeyword, ast.KindTrueKeyword: return d.factory.NewKeywordExpression(kind), nil case ast.KindBinaryExpression: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) left := d.nodeAt(it.nextIf(mask, 1)) typeNode := d.nodeAt(it.nextIf(mask, 2)) operatorToken := d.nodeAt(it.nextIf(mask, 3)) right := d.nodeAt(it.nextIf(mask, 4)) return d.factory.NewBinaryExpression(modifiers, left, typeNode, operatorToken, right), nil case ast.KindPrefixUnaryExpression: var operator ast.Kind switch commonData & 7 { case 0: operator = ast.KindPlusToken case 1: operator = ast.KindMinusToken case 2: operator = ast.KindTildeToken case 3: operator = ast.KindExclamationToken case 4: operator = ast.KindPlusPlusToken case 5: operator = ast.KindMinusMinusToken } return d.factory.NewPrefixUnaryExpression(operator, d.singleChild(childIndices)), nil case ast.KindPostfixUnaryExpression: operator := ast.KindPlusPlusToken if commonData&1 != 0 { operator = ast.KindMinusMinusToken } return d.factory.NewPostfixUnaryExpression(d.singleChild(childIndices), operator), nil case ast.KindYieldExpression: it := newChildIter(childIndices) asteriskToken := d.nodeAt(it.nextIf(mask, 0)) expression := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewYieldExpression(asteriskToken, expression), nil case ast.KindArrowFunction: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) typeParameters := d.nodeListAt(it.nextIf(mask, 1)) parameters := d.nodeListAt(it.nextIf(mask, 2)) typeNode := d.nodeAt(it.nextIf(mask, 3)) equalsGreaterThanToken := d.nodeAt(it.nextIf(mask, 4)) body := d.nodeAt(it.nextIf(mask, 5)) return d.factory.NewArrowFunction(modifiers, typeParameters, parameters, typeNode, nil, equalsGreaterThanToken, body), nil case ast.KindFunctionExpression: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) asteriskToken := d.nodeAt(it.nextIf(mask, 1)) name := d.nodeAt(it.nextIf(mask, 2)) typeParameters := d.nodeListAt(it.nextIf(mask, 3)) parameters := d.nodeListAt(it.nextIf(mask, 4)) typeNode := d.nodeAt(it.nextIf(mask, 5)) body := d.nodeAt(it.nextIf(mask, 6)) return d.factory.NewFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, typeNode, nil, body), nil case ast.KindAsExpression: it := newChildIter(childIndices) expression := d.nodeAt(it.nextIf(mask, 0)) typeNode := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewAsExpression(expression, typeNode), nil case ast.KindSatisfiesExpression: it := newChildIter(childIndices) expression := d.nodeAt(it.nextIf(mask, 0)) typeNode := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewSatisfiesExpression(expression, typeNode), nil case ast.KindConditionalExpression: it := newChildIter(childIndices) condition := d.nodeAt(it.nextIf(mask, 0)) questionToken := d.nodeAt(it.nextIf(mask, 1)) whenTrue := d.nodeAt(it.nextIf(mask, 2)) colonToken := d.nodeAt(it.nextIf(mask, 3)) whenFalse := d.nodeAt(it.nextIf(mask, 4)) return d.factory.NewConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse), nil case ast.KindPropertyAccessExpression: it := newChildIter(childIndices) expression := d.nodeAt(it.nextIf(mask, 0)) questionDotToken := d.nodeAt(it.nextIf(mask, 1)) name := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewPropertyAccessExpression(expression, questionDotToken, name, 0), nil case ast.KindElementAccessExpression: it := newChildIter(childIndices) expression := d.nodeAt(it.nextIf(mask, 0)) questionDotToken := d.nodeAt(it.nextIf(mask, 1)) argumentExpression := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewElementAccessExpression(expression, questionDotToken, argumentExpression, 0), nil case ast.KindCallExpression: it := newChildIter(childIndices) expression := d.nodeAt(it.nextIf(mask, 0)) questionDotToken := d.nodeAt(it.nextIf(mask, 1)) typeArguments := d.nodeListAt(it.nextIf(mask, 2)) arguments := d.nodeListAt(it.nextIf(mask, 3)) return d.factory.NewCallExpression(expression, questionDotToken, typeArguments, arguments, 0), nil case ast.KindNewExpression: it := newChildIter(childIndices) expression := d.nodeAt(it.nextIf(mask, 0)) typeArguments := d.nodeListAt(it.nextIf(mask, 1)) arguments := d.nodeListAt(it.nextIf(mask, 2)) return d.factory.NewNewExpression(expression, typeArguments, arguments), nil case ast.KindMetaProperty: keywordToken := ast.KindImportKeyword if commonData&1 != 0 { keywordToken = ast.KindNewKeyword } return d.factory.NewMetaProperty(keywordToken, d.singleChild(childIndices)), nil case ast.KindNonNullExpression: return d.factory.NewNonNullExpression(d.singleChild(childIndices), 0), nil case ast.KindSpreadElement: return d.factory.NewSpreadElement(d.singleChild(childIndices)), nil case ast.KindTemplateExpression: it := newChildIter(childIndices) head := d.nodeAt(it.nextIf(mask, 0)) templateSpans := d.nodeListAt(it.nextIf(mask, 1)) return d.factory.NewTemplateExpression(head, templateSpans), nil case ast.KindTemplateSpan: it := newChildIter(childIndices) expression := d.nodeAt(it.nextIf(mask, 0)) literal := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewTemplateSpan(expression, literal), nil case ast.KindTaggedTemplateExpression: it := newChildIter(childIndices) tag := d.nodeAt(it.nextIf(mask, 0)) questionDotToken := d.nodeAt(it.nextIf(mask, 1)) typeArguments := d.nodeListAt(it.nextIf(mask, 2)) template := d.nodeAt(it.nextIf(mask, 3)) return d.factory.NewTaggedTemplateExpression(tag, questionDotToken, typeArguments, template, 0), nil case ast.KindParenthesizedExpression: return d.factory.NewParenthesizedExpression(d.singleChild(childIndices)), nil case ast.KindArrayLiteralExpression: multiLine := commonData&1 != 0 var list *ast.NodeList if len(childIndices) > 0 { list = d.nodeListAt(childIndices[0]) } return d.factory.NewArrayLiteralExpression(list, multiLine), nil case ast.KindObjectLiteralExpression: multiLine := commonData&1 != 0 var list *ast.NodeList if len(childIndices) > 0 { list = d.nodeListAt(childIndices[0]) } return d.factory.NewObjectLiteralExpression(list, multiLine), nil case ast.KindSpreadAssignment: return d.factory.NewSpreadAssignment(d.singleChild(childIndices)), nil case ast.KindPropertyAssignment: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) postfixToken := d.nodeAt(it.nextIf(mask, 2)) typeNode := d.nodeAt(it.nextIf(mask, 3)) initializer := d.nodeAt(it.nextIf(mask, 4)) return d.factory.NewPropertyAssignment(modifiers, name, postfixToken, typeNode, initializer), nil case ast.KindShorthandPropertyAssignment: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) postfixToken := d.nodeAt(it.nextIf(mask, 2)) typeNode := d.nodeAt(it.nextIf(mask, 3)) equalsToken := d.nodeAt(it.nextIf(mask, 4)) objectAssignmentInitializer := d.nodeAt(it.nextIf(mask, 5)) return d.factory.NewShorthandPropertyAssignment(modifiers, name, postfixToken, typeNode, equalsToken, objectAssignmentInitializer), nil case ast.KindDeleteExpression: return d.factory.NewDeleteExpression(d.singleChild(childIndices)), nil case ast.KindTypeOfExpression: return d.factory.NewTypeOfExpression(d.singleChild(childIndices)), nil case ast.KindVoidExpression: return d.factory.NewVoidExpression(d.singleChild(childIndices)), nil case ast.KindAwaitExpression: return d.factory.NewAwaitExpression(d.singleChild(childIndices)), nil case ast.KindTypeAssertionExpression: it := newChildIter(childIndices) typeNode := d.nodeAt(it.nextIf(mask, 0)) expression := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewTypeAssertion(typeNode, expression), nil case ast.KindVoidKeyword, ast.KindAnyKeyword, ast.KindBooleanKeyword, ast.KindIntrinsicKeyword, ast.KindNeverKeyword, ast.KindNumberKeyword, ast.KindObjectKeyword, ast.KindStringKeyword, ast.KindSymbolKeyword, ast.KindUndefinedKeyword, ast.KindUnknownKeyword, ast.KindBigIntKeyword: return d.factory.NewKeywordTypeNode(kind), nil case ast.KindUnionType: return d.factory.NewUnionTypeNode(d.singleNodeListChild(childIndices)), nil case ast.KindIntersectionType: return d.factory.NewIntersectionTypeNode(d.singleNodeListChild(childIndices)), nil case ast.KindConditionalType: it := newChildIter(childIndices) checkType := d.nodeAt(it.nextIf(mask, 0)) extendsType := d.nodeAt(it.nextIf(mask, 1)) trueType := d.nodeAt(it.nextIf(mask, 2)) falseType := d.nodeAt(it.nextIf(mask, 3)) return d.factory.NewConditionalTypeNode(checkType, extendsType, trueType, falseType), nil case ast.KindTypeOperator: var operator ast.Kind switch commonData & 3 { case 0: operator = ast.KindKeyOfKeyword case 1: operator = ast.KindReadonlyKeyword case 2: operator = ast.KindUniqueKeyword } return d.factory.NewTypeOperatorNode(operator, d.singleChild(childIndices)), nil case ast.KindInferType: return d.factory.NewInferTypeNode(d.singleChild(childIndices)), nil case ast.KindArrayType: return d.factory.NewArrayTypeNode(d.singleChild(childIndices)), nil case ast.KindIndexedAccessType: it := newChildIter(childIndices) objectType := d.nodeAt(it.nextIf(mask, 0)) indexType := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewIndexedAccessTypeNode(objectType, indexType), nil case ast.KindTypeReference: it := newChildIter(childIndices) typeName := d.nodeAt(it.nextIf(mask, 0)) typeArguments := d.nodeListAt(it.nextIf(mask, 1)) return d.factory.NewTypeReferenceNode(typeName, typeArguments), nil case ast.KindExpressionWithTypeArguments: it := newChildIter(childIndices) expression := d.nodeAt(it.nextIf(mask, 0)) typeArguments := d.nodeListAt(it.nextIf(mask, 1)) return d.factory.NewExpressionWithTypeArguments(expression, typeArguments), nil case ast.KindLiteralType: return d.factory.NewLiteralTypeNode(d.singleChild(childIndices)), nil case ast.KindThisType: return d.factory.NewThisTypeNode(), nil case ast.KindTypePredicate: it := newChildIter(childIndices) assertsModifier := d.nodeAt(it.nextIf(mask, 0)) parameterName := d.nodeAt(it.nextIf(mask, 1)) typeNode := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewTypePredicateNode(assertsModifier, parameterName, typeNode), nil case ast.KindImportAttribute: it := newChildIter(childIndices) name := d.nodeAt(it.nextIf(mask, 0)) value := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewImportAttribute(name, value), nil case ast.KindImportAttributes: multiLine := commonData&1 != 0 token := ast.KindWithKeyword if (commonData>>1)&1 != 0 { token = ast.KindAssertKeyword } var list *ast.NodeList if len(childIndices) > 0 { list = d.nodeListAt(childIndices[0]) } return d.factory.NewImportAttributes(token, list, multiLine), nil case ast.KindTypeQuery: it := newChildIter(childIndices) exprName := d.nodeAt(it.nextIf(mask, 0)) typeArguments := d.nodeListAt(it.nextIf(mask, 1)) return d.factory.NewTypeQueryNode(exprName, typeArguments), nil case ast.KindMappedType: it := newChildIter(childIndices) readonlyToken := d.nodeAt(it.nextIf(mask, 0)) typeParameter := d.nodeAt(it.nextIf(mask, 1)) nameType := d.nodeAt(it.nextIf(mask, 2)) questionToken := d.nodeAt(it.nextIf(mask, 3)) typeNode := d.nodeAt(it.nextIf(mask, 4)) members := d.nodeListAt(it.nextIf(mask, 5)) return d.factory.NewMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, typeNode, members), nil case ast.KindTypeLiteral: return d.factory.NewTypeLiteralNode(d.singleNodeListChild(childIndices)), nil case ast.KindTupleType: return d.factory.NewTupleTypeNode(d.singleNodeListChild(childIndices)), nil case ast.KindNamedTupleMember: it := newChildIter(childIndices) dotDotDotToken := d.nodeAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) questionToken := d.nodeAt(it.nextIf(mask, 2)) typeNode := d.nodeAt(it.nextIf(mask, 3)) return d.factory.NewNamedTupleMember(dotDotDotToken, name, questionToken, typeNode), nil case ast.KindOptionalType: return d.factory.NewOptionalTypeNode(d.singleChild(childIndices)), nil case ast.KindRestType: return d.factory.NewRestTypeNode(d.singleChild(childIndices)), nil case ast.KindParenthesizedType: return d.factory.NewParenthesizedTypeNode(d.singleChild(childIndices)), nil case ast.KindFunctionType: it := newChildIter(childIndices) typeParameters := d.nodeListAt(it.nextIf(mask, 0)) parameters := d.nodeListAt(it.nextIf(mask, 1)) typeNode := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewFunctionTypeNode(typeParameters, parameters, typeNode), nil case ast.KindConstructorType: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) typeParameters := d.nodeListAt(it.nextIf(mask, 1)) parameters := d.nodeListAt(it.nextIf(mask, 2)) typeNode := d.nodeAt(it.nextIf(mask, 3)) return d.factory.NewConstructorTypeNode(modifiers, typeParameters, parameters, typeNode), nil case ast.KindTemplateLiteralType: it := newChildIter(childIndices) head := d.nodeAt(it.nextIf(mask, 0)) templateSpans := d.nodeListAt(it.nextIf(mask, 1)) return d.factory.NewTemplateLiteralTypeNode(head, templateSpans), nil case ast.KindTemplateLiteralTypeSpan: it := newChildIter(childIndices) typeNode := d.nodeAt(it.nextIf(mask, 0)) literal := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewTemplateLiteralTypeSpan(typeNode, literal), nil case ast.KindSyntheticExpression: typeNode, isSpread := decodeNodeCommonData_SyntheticExpression(commonData) return d.factory.NewSyntheticExpression(typeNode, isSpread, d.singleChild(childIndices)), nil case ast.KindPartiallyEmittedExpression: return d.factory.NewPartiallyEmittedExpression(d.singleChild(childIndices)), nil case ast.KindJsxElement: it := newChildIter(childIndices) openingElement := d.nodeAt(it.nextIf(mask, 0)) children := d.nodeListAt(it.nextIf(mask, 1)) closingElement := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewJsxElement(openingElement, children, closingElement), nil case ast.KindJsxAttributes: return d.factory.NewJsxAttributes(d.singleNodeListChild(childIndices)), nil case ast.KindJsxNamespacedName: it := newChildIter(childIndices) namespace := d.nodeAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewJsxNamespacedName(namespace, name), nil case ast.KindJsxOpeningElement: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) typeArguments := d.nodeListAt(it.nextIf(mask, 1)) attributes := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewJsxOpeningElement(tagName, typeArguments, attributes), nil case ast.KindJsxSelfClosingElement: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) typeArguments := d.nodeListAt(it.nextIf(mask, 1)) attributes := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewJsxSelfClosingElement(tagName, typeArguments, attributes), nil case ast.KindJsxFragment: it := newChildIter(childIndices) openingFragment := d.nodeAt(it.nextIf(mask, 0)) children := d.nodeListAt(it.nextIf(mask, 1)) closingFragment := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewJsxFragment(openingFragment, children, closingFragment), nil case ast.KindJsxOpeningFragment: return d.factory.NewJsxOpeningFragment(), nil case ast.KindJsxClosingFragment: return d.factory.NewJsxClosingFragment(), nil case ast.KindJsxAttribute: it := newChildIter(childIndices) name := d.nodeAt(it.nextIf(mask, 0)) initializer := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewJsxAttribute(name, initializer), nil case ast.KindJsxSpreadAttribute: return d.factory.NewJsxSpreadAttribute(d.singleChild(childIndices)), nil case ast.KindJsxClosingElement: return d.factory.NewJsxClosingElement(d.singleChild(childIndices)), nil case ast.KindJsxExpression: it := newChildIter(childIndices) dotDotDotToken := d.nodeAt(it.nextIf(mask, 0)) expression := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewJsxExpression(dotDotDotToken, expression), nil case ast.KindSyntaxList: nodes := d.allocNodeSlice(len(childIndices)) for i, ci := range childIndices { nodes[i] = d.nodes[ci] } return d.factory.NewSyntaxList(nodes), nil case ast.KindJSDoc: it := newChildIter(childIndices) comment := d.nodeListAt(it.nextIf(mask, 0)) tags := d.nodeListAt(it.nextIf(mask, 1)) return d.factory.NewJSDoc(comment, tags), nil case ast.KindJSDocTypeExpression: return d.factory.NewJSDocTypeExpression(d.singleChild(childIndices)), nil case ast.KindJSDocNonNullableType: return d.factory.NewJSDocNonNullableType(d.singleChild(childIndices)), nil case ast.KindJSDocNullableType: return d.factory.NewJSDocNullableType(d.singleChild(childIndices)), nil case ast.KindJSDocAllType: return d.factory.NewJSDocAllType(), nil case ast.KindJSDocVariadicType: return d.factory.NewJSDocVariadicType(d.singleChild(childIndices)), nil case ast.KindJSDocOptionalType: return d.factory.NewJSDocOptionalType(d.singleChild(childIndices)), nil case ast.KindJSDocTypeTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) typeExpression := d.nodeAt(it.nextIf(mask, 1)) comment := d.nodeListAt(it.nextIf(mask, 2)) return d.factory.NewJSDocTypeTag(tagName, typeExpression, comment), nil case ast.KindJSDocUnknownTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) comment := d.nodeListAt(it.nextIf(mask, 1)) return d.factory.NewJSDocUnknownTag(tagName, comment), nil case ast.KindJSDocTemplateTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) constraint := d.nodeAt(it.nextIf(mask, 1)) typeParameters := d.nodeListAt(it.nextIf(mask, 2)) comment := d.nodeListAt(it.nextIf(mask, 3)) return d.factory.NewJSDocTemplateTag(tagName, constraint, typeParameters, comment), nil case ast.KindJSDocReturnTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) typeExpression := d.nodeAt(it.nextIf(mask, 1)) comment := d.nodeListAt(it.nextIf(mask, 2)) return d.factory.NewJSDocReturnTag(tagName, typeExpression, comment), nil case ast.KindJSDocPublicTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) comment := d.nodeListAt(it.nextIf(mask, 1)) return d.factory.NewJSDocPublicTag(tagName, comment), nil case ast.KindJSDocPrivateTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) comment := d.nodeListAt(it.nextIf(mask, 1)) return d.factory.NewJSDocPrivateTag(tagName, comment), nil case ast.KindJSDocProtectedTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) comment := d.nodeListAt(it.nextIf(mask, 1)) return d.factory.NewJSDocProtectedTag(tagName, comment), nil case ast.KindJSDocReadonlyTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) comment := d.nodeListAt(it.nextIf(mask, 1)) return d.factory.NewJSDocReadonlyTag(tagName, comment), nil case ast.KindJSDocOverrideTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) comment := d.nodeListAt(it.nextIf(mask, 1)) return d.factory.NewJSDocOverrideTag(tagName, comment), nil case ast.KindJSDocDeprecatedTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) comment := d.nodeListAt(it.nextIf(mask, 1)) return d.factory.NewJSDocDeprecatedTag(tagName, comment), nil case ast.KindJSDocSeeTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) nameExpression := d.nodeAt(it.nextIf(mask, 1)) comment := d.nodeListAt(it.nextIf(mask, 2)) return d.factory.NewJSDocSeeTag(tagName, nameExpression, comment), nil case ast.KindJSDocImplementsTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) className := d.nodeAt(it.nextIf(mask, 1)) comment := d.nodeListAt(it.nextIf(mask, 2)) return d.factory.NewJSDocImplementsTag(tagName, className, comment), nil case ast.KindJSDocAugmentsTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) className := d.nodeAt(it.nextIf(mask, 1)) comment := d.nodeListAt(it.nextIf(mask, 2)) return d.factory.NewJSDocAugmentsTag(tagName, className, comment), nil case ast.KindJSDocSatisfiesTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) typeExpression := d.nodeAt(it.nextIf(mask, 1)) comment := d.nodeListAt(it.nextIf(mask, 2)) return d.factory.NewJSDocSatisfiesTag(tagName, typeExpression, comment), nil case ast.KindJSDocThrowsTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) typeExpression := d.nodeAt(it.nextIf(mask, 1)) comment := d.nodeListAt(it.nextIf(mask, 2)) return d.factory.NewJSDocThrowsTag(tagName, typeExpression, comment), nil case ast.KindJSDocThisTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) typeExpression := d.nodeAt(it.nextIf(mask, 1)) comment := d.nodeListAt(it.nextIf(mask, 2)) return d.factory.NewJSDocThisTag(tagName, typeExpression, comment), nil case ast.KindJSDocImportTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) importClause := d.nodeAt(it.nextIf(mask, 1)) moduleSpecifier := d.nodeAt(it.nextIf(mask, 2)) attributes := d.nodeAt(it.nextIf(mask, 3)) comment := d.nodeListAt(it.nextIf(mask, 4)) return d.factory.NewJSDocImportTag(tagName, importClause, moduleSpecifier, attributes, comment), nil case ast.KindJSDocCallbackTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) typeExpression := d.nodeAt(it.nextIf(mask, 1)) name := d.nodeAt(it.nextIf(mask, 2)) comment := d.nodeListAt(it.nextIf(mask, 3)) return d.factory.NewJSDocCallbackTag(tagName, typeExpression, name, comment), nil case ast.KindJSDocOverloadTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) typeExpression := d.nodeAt(it.nextIf(mask, 1)) comment := d.nodeListAt(it.nextIf(mask, 2)) return d.factory.NewJSDocOverloadTag(tagName, typeExpression, comment), nil case ast.KindJSDocTypedefTag: it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) typeExpression := d.nodeAt(it.nextIf(mask, 1)) name := d.nodeAt(it.nextIf(mask, 2)) comment := d.nodeListAt(it.nextIf(mask, 3)) return d.factory.NewJSDocTypedefTag(tagName, typeExpression, name, comment), nil case ast.KindJSDocSignature: it := newChildIter(childIndices) typeParameters := d.nodeListAt(it.nextIf(mask, 0)) parameters := d.nodeListAt(it.nextIf(mask, 1)) typeNode := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewJSDocSignature(typeParameters, parameters, typeNode), nil case ast.KindJSDocNameReference: return d.factory.NewJSDocNameReference(d.singleChild(childIndices)), nil case ast.KindModuleDeclaration: keyword := ast.KindModuleKeyword if commonData&1 != 0 { keyword = ast.KindNamespaceKeyword } it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) body := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewModuleDeclaration(modifiers, keyword, name, body), nil case ast.KindImportEqualsDeclaration: isTypeOnly := commonData&1 != 0 it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) moduleReference := d.nodeAt(it.nextIf(mask, 2)) return d.factory.NewImportEqualsDeclaration(modifiers, isTypeOnly, name, moduleReference), nil case ast.KindExportDeclaration: isTypeOnly := commonData&1 != 0 it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) exportClause := d.nodeAt(it.nextIf(mask, 1)) moduleSpecifier := d.nodeAt(it.nextIf(mask, 2)) attributes := d.nodeAt(it.nextIf(mask, 3)) return d.factory.NewExportDeclaration(modifiers, isTypeOnly, exportClause, moduleSpecifier, attributes), nil case ast.KindImportType: isTypeOf := commonData&1 != 0 it := newChildIter(childIndices) argument := d.nodeAt(it.nextIf(mask, 0)) attributes := d.nodeAt(it.nextIf(mask, 1)) qualifier := d.nodeAt(it.nextIf(mask, 2)) typeArguments := d.nodeListAt(it.nextIf(mask, 3)) return d.factory.NewImportTypeNode(isTypeOf, argument, attributes, qualifier, typeArguments), nil case ast.KindImportClause: var phaseModifier ast.Kind switch commonData & 3 { case 1: phaseModifier = ast.KindTypeKeyword case 2: phaseModifier = ast.KindDeferKeyword } it := newChildIter(childIndices) name := d.nodeAt(it.nextIf(mask, 0)) namedBindings := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewImportClause(phaseModifier, name, namedBindings), nil case ast.KindImportSpecifier: isTypeOnly := commonData&1 != 0 it := newChildIter(childIndices) propertyName := d.nodeAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewImportSpecifier(isTypeOnly, propertyName, name), nil case ast.KindTypeParameter: it := newChildIter(childIndices) modifiers := d.modifierListAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) constraint := d.nodeAt(it.nextIf(mask, 2)) expression := d.nodeAt(it.nextIf(mask, 3)) defaultType := d.nodeAt(it.nextIf(mask, 4)) return d.factory.NewTypeParameterDeclaration(modifiers, name, constraint, expression, defaultType), nil case ast.KindSyntheticReferenceExpression: it := newChildIter(childIndices) expression := d.nodeAt(it.nextIf(mask, 0)) thisArg := d.nodeAt(it.nextIf(mask, 1)) return d.factory.NewSyntheticReferenceExpression(expression, thisArg), nil case ast.KindJSDocTypeLiteral: isArrayType := commonData&1 != 0 nodes := d.allocNodeSlice(len(childIndices)) for i, ci := range childIndices { nodes[i] = d.nodes[ci] } return d.factory.NewJSDocTypeLiteral(nodes, isArrayType), nil case ast.KindJSDocParameterTag, ast.KindJSDocPropertyTag: isBracketed := commonData&1 != 0 isNameFirst := commonData&2 != 0 it := newChildIter(childIndices) tagName := d.nodeAt(it.nextIf(mask, 0)) name := d.nodeAt(it.nextIf(mask, 1)) typeExpression := d.nodeAt(it.nextIf(mask, 2)) comment := d.nodeListAt(it.nextIf(mask, 3)) return d.factory.NewJSDocParameterOrPropertyTag(kind, tagName, name, isBracketed, typeExpression, isNameFirst, comment), nil default: return nil, fmt.Errorf("unhandled node kind %v with %d children", kind, len(childIndices)) } }