@@ -414,6 +414,18 @@ func (n *Node) Expression() *Node {
414414 panic ("Unhandled case in Node.Expression: " + n .Kind .String ())
415415}
416416
417+ func (n * Node ) RawText () string {
418+ switch n .Kind {
419+ case KindTemplateHead :
420+ return n .AsTemplateHead ().RawText
421+ case KindTemplateMiddle :
422+ return n .AsTemplateMiddle ().RawText
423+ case KindTemplateTail :
424+ return n .AsTemplateTail ().RawText
425+ }
426+ panic ("Unhandled case in Node.RawText: " + n .Kind .String ())
427+ }
428+
417429func (m * MutableNode ) SetExpression (expr * Node ) {
418430 n := (* Node )(m )
419431 switch n .Kind {
@@ -2059,59 +2071,63 @@ type NodeBase struct {
20592071// Aliases for Node unions
20602072
20612073type (
2062- Statement = Node // Node with StatementBase
2063- Declaration = Node // Node with DeclarationBase
2064- Expression = Node // Node with ExpressionBase
2065- TypeNode = Node // Node with TypeNodeBase
2066- TypeElement = Node // Node with TypeElementBase
2067- ClassElement = Node // Node with ClassElementBase
2068- NamedMember = Node // Node with NamedMemberBase
2069- ObjectLiteralElement = Node // Node with ObjectLiteralElementBase
2070- BlockOrExpression = Node // Block | Expression
2071- AccessExpression = Node // PropertyAccessExpression | ElementAccessExpression
2072- DeclarationName = Node // Identifier | PrivateIdentifier | StringLiteral | NumericLiteral | BigIntLiteral | NoSubstitutionTemplateLiteral | ComputedPropertyName | BindingPattern | ElementAccessExpression
2073- ModuleName = Node // Identifier | StringLiteral
2074- ModuleExportName = Node // Identifier | StringLiteral
2075- PropertyName = Node // Identifier | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier | BigIntLiteral
2076- ModuleBody = Node // ModuleBlock | ModuleDeclaration
2077- ForInitializer = Node // Expression | MissingDeclaration | VariableDeclarationList
2078- ModuleReference = Node // Identifier | QualifiedName | ExternalModuleReference
2079- NamedImportBindings = Node // NamespaceImport | NamedImports
2080- NamedExportBindings = Node // NamespaceExport | NamedExports
2081- MemberName = Node // Identifier | PrivateIdentifier
2082- EntityName = Node // Identifier | QualifiedName
2083- BindingName = Node // Identifier | BindingPattern
2084- ModifierLike = Node // Modifier | Decorator
2085- JsxChild = Node // JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment
2086- JsxAttributeLike = Node // JsxAttribute | JsxSpreadAttribute
2087- JsxAttributeName = Node // Identifier | JsxNamespacedName
2088- JsxAttributeValue = Node // StringLiteral | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment
2089- JsxTagNameExpression = Node // IdentifierReference | KeywordExpression | JsxTagNamePropertyAccess | JsxNamespacedName
2090- ClassLikeDeclaration = Node // ClassDeclaration | ClassExpression
2091- AccessorDeclaration = Node // GetAccessorDeclaration | SetAccessorDeclaration
2092- LiteralLikeNode = Node // StringLiteral | NumericLiteral | BigIntLiteral | RegularExpressionLiteral | TemplateLiteralLikeNode | JsxText
2093- LiteralExpression = Node // StringLiteral | NumericLiteral | BigIntLiteral | RegularExpressionLiteral | NoSubstitutionTemplateLiteral
2094- UnionOrIntersectionTypeNode = Node // UnionTypeNode | IntersectionTypeNode
2095- TemplateLiteralLikeNode = Node // TemplateHead | TemplateMiddle | TemplateTail
2096- TemplateMiddleOrTail = Node // TemplateMiddle | TemplateTail
2097- TemplateLiteral = Node // TemplateExpression | NoSubstitutionTemplateLiteral
2098- TypePredicateParameterName = Node // Identifier | ThisTypeNode
2099- ImportAttributeName = Node // Identifier | StringLiteral
2100- LeftHandSideExpression = Node // subset of Expression
2101- JSDocComment = Node // JSDocText | JSDocLink | JSDocLinkCode | JSDocLinkPlain;
2102- JSDocTag = Node // Node with JSDocTagBase
2103- SignatureDeclaration = Node // CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction;
2104- StringLiteralLike = Node // StringLiteral | NoSubstitutionTemplateLiteral
2105- AnyValidImportOrReExport = Node // (ImportDeclaration | ExportDeclaration | JSDocImportTag) & { moduleSpecifier: StringLiteral } | ImportEqualsDeclaration & { moduleReference: ExternalModuleReference & { expression: StringLiteral }} | RequireOrImportCall | ValidImportTypeNode
2106- ValidImportTypeNode = Node // ImportTypeNode & { argument: LiteralTypeNode & { literal: StringLiteral } }
2107- NumericOrStringLikeLiteral = Node // StringLiteralLike | NumericLiteral
2108- TypeOnlyImportDeclaration = Node // ImportClause | ImportEqualsDeclaration | ImportSpecifier | NamespaceImport with isTypeOnly: true
2109- ObjectLiteralLike = Node // ObjectLiteralExpression | ObjectBindingPattern
2110- ObjectTypeDeclaration = Node // ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode
2111- JsxOpeningLikeElement = Node // JsxOpeningElement | JsxSelfClosingElement
2112- NamedImportsOrExports = Node // NamedImports | NamedExports
2113- BreakOrContinueStatement = Node // BreakStatement | ContinueStatement
2114- CallLikeExpression = Node // CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxCallLike | InstanceofExpression
2074+ Statement = Node // Node with StatementBase
2075+ Declaration = Node // Node with DeclarationBase
2076+ Expression = Node // Node with ExpressionBase
2077+ TypeNode = Node // Node with TypeNodeBase
2078+ TypeElement = Node // Node with TypeElementBase
2079+ ClassElement = Node // Node with ClassElementBase
2080+ NamedMember = Node // Node with NamedMemberBase
2081+ ObjectLiteralElement = Node // Node with ObjectLiteralElementBase
2082+ BlockOrExpression = Node // Block | Expression
2083+ AccessExpression = Node // PropertyAccessExpression | ElementAccessExpression
2084+ DeclarationName = Node // Identifier | PrivateIdentifier | StringLiteral | NumericLiteral | BigIntLiteral | NoSubstitutionTemplateLiteral | ComputedPropertyName | BindingPattern | ElementAccessExpression
2085+ ModuleName = Node // Identifier | StringLiteral
2086+ ModuleExportName = Node // Identifier | StringLiteral
2087+ PropertyName = Node // Identifier | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier | BigIntLiteral
2088+ ModuleBody = Node // ModuleBlock | ModuleDeclaration
2089+ ForInitializer = Node // Expression | MissingDeclaration | VariableDeclarationList
2090+ ModuleReference = Node // Identifier | QualifiedName | ExternalModuleReference
2091+ NamedImportBindings = Node // NamespaceImport | NamedImports
2092+ NamedExportBindings = Node // NamespaceExport | NamedExports
2093+ MemberName = Node // Identifier | PrivateIdentifier
2094+ EntityName = Node // Identifier | QualifiedName
2095+ BindingName = Node // Identifier | BindingPattern
2096+ ModifierLike = Node // Modifier | Decorator
2097+ JsxChild = Node // JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment
2098+ JsxAttributeLike = Node // JsxAttribute | JsxSpreadAttribute
2099+ JsxAttributeName = Node // Identifier | JsxNamespacedName
2100+ JsxAttributeValue = Node // StringLiteral | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment
2101+ JsxTagNameExpression = Node // IdentifierReference | KeywordExpression | JsxTagNamePropertyAccess | JsxNamespacedName
2102+ ClassLikeDeclaration = Node // ClassDeclaration | ClassExpression
2103+ AccessorDeclaration = Node // GetAccessorDeclaration | SetAccessorDeclaration
2104+ LiteralLikeNode = Node // StringLiteral | NumericLiteral | BigIntLiteral | RegularExpressionLiteral | TemplateLiteralLikeNode | JsxText
2105+ LiteralExpression = Node // StringLiteral | NumericLiteral | BigIntLiteral | RegularExpressionLiteral | NoSubstitutionTemplateLiteral
2106+ UnionOrIntersectionTypeNode = Node // UnionTypeNode | IntersectionTypeNode
2107+ TemplateLiteralLikeNode = Node // TemplateHead | TemplateMiddle | TemplateTail
2108+ TemplateMiddleOrTail = Node // TemplateMiddle | TemplateTail
2109+ TemplateLiteral = Node // TemplateExpression | NoSubstitutionTemplateLiteral
2110+ TypePredicateParameterName = Node // Identifier | ThisTypeNode
2111+ ImportAttributeName = Node // Identifier | StringLiteral
2112+ LeftHandSideExpression = Node // subset of Expression
2113+ JSDocComment = Node // JSDocText | JSDocLink | JSDocLinkCode | JSDocLinkPlain;
2114+ JSDocTag = Node // Node with JSDocTagBase
2115+ SignatureDeclaration = Node // CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction;
2116+ StringLiteralLike = Node // StringLiteral | NoSubstitutionTemplateLiteral
2117+ AnyValidImportOrReExport = Node // (ImportDeclaration | ExportDeclaration | JSDocImportTag) & { moduleSpecifier: StringLiteral } | ImportEqualsDeclaration & { moduleReference: ExternalModuleReference & { expression: StringLiteral }} | RequireOrImportCall | ValidImportTypeNode
2118+ ValidImportTypeNode = Node // ImportTypeNode & { argument: LiteralTypeNode & { literal: StringLiteral } }
2119+ NumericOrStringLikeLiteral = Node // StringLiteralLike | NumericLiteral
2120+ TypeOnlyImportDeclaration = Node // ImportClause | ImportEqualsDeclaration | ImportSpecifier | NamespaceImport with isTypeOnly: true
2121+ ObjectLiteralLike = Node // ObjectLiteralExpression | ObjectBindingPattern
2122+ ObjectTypeDeclaration = Node // ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode
2123+ JsxOpeningLikeElement = Node // JsxOpeningElement | JsxSelfClosingElement
2124+ NamedImportsOrExports = Node // NamedImports | NamedExports
2125+ BreakOrContinueStatement = Node // BreakStatement | ContinueStatement
2126+ CallLikeExpression = Node // CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxCallLike | InstanceofExpression
2127+ FunctionLikeDeclaration = Node // FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction
2128+ VariableOrParameterDeclaration = Node // VariableDeclaration | ParameterDeclaration
2129+ VariableOrPropertyDeclaration = Node // VariableDeclaration | PropertyDeclaration
2130+ CallOrNewExpression = Node // CallExpression | NewExpression
21152131)
21162132
21172133// Aliases for node singletons
@@ -2162,6 +2178,7 @@ type (
21622178 LiteralType = Node
21632179 JSDocNode = Node
21642180 BindingPatternNode = Node
2181+ TypePredicateNodeNode = Node
21652182)
21662183
21672184type (
0 commit comments