1/* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { 17 global, 18 passNode, 19 passNodeArray, 20 unpackNonNullableNode, 21 unpackNode, 22 unpackNodeArray, 23 assertValidPeer, 24 AstNode, 25 Es2pandaAstNodeType, 26 KNativePointer, 27 nodeByType, 28 ArktsObject, 29 unpackString 30} from "../../reexport-for-generated" 31 32import { MaybeOptionalExpression } from "./MaybeOptionalExpression" 33import { Expression } from "./Expression" 34import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" 35import { BlockStatement } from "./BlockStatement" 36export class CallExpression extends MaybeOptionalExpression { 37 constructor(pointer: KNativePointer) { 38 assertValidPeer(pointer, Es2pandaAstNodeType.AST_NODE_TYPE_CALL_EXPRESSION) 39 super(pointer) 40 41 } 42 static createCallExpression(callee: Expression | undefined, _arguments: readonly Expression[], typeParams: TSTypeParameterInstantiation | undefined, optional_arg: boolean, trailingComma: boolean): CallExpression { 43 return new CallExpression(global.generatedEs2panda._CreateCallExpression(global.context, passNode(callee), passNodeArray(_arguments), _arguments.length, passNode(typeParams), optional_arg, trailingComma)) 44 } 45 static create1CallExpression(other?: CallExpression): CallExpression { 46 return new CallExpression(global.generatedEs2panda._CreateCallExpression1(global.context, passNode(other))) 47 } 48 static update1CallExpression(original?: CallExpression, other?: CallExpression): CallExpression { 49 return new CallExpression(global.generatedEs2panda._UpdateCallExpression1(global.context, passNode(original), passNode(other))) 50 } 51 get callee(): Expression | undefined { 52 return unpackNode(global.generatedEs2panda._CallExpressionCalleeConst(global.context, this.peer)) 53 } 54 /** @deprecated */ 55 setCallee(callee: Expression): this { 56 global.generatedEs2panda._CallExpressionSetCallee(global.context, this.peer, passNode(callee)) 57 return this 58 } 59 get typeParams(): TSTypeParameterInstantiation | undefined { 60 return unpackNode(global.generatedEs2panda._CallExpressionTypeParamsConst(global.context, this.peer)) 61 } 62 get arguments(): readonly Expression[] { 63 return unpackNodeArray(global.generatedEs2panda._CallExpressionArgumentsConst(global.context, this.peer)) 64 } 65 get hasTrailingComma(): boolean { 66 return global.generatedEs2panda._CallExpressionHasTrailingCommaConst(global.context, this.peer) 67 } 68 /** @deprecated */ 69 setTypeParams(typeParams: TSTypeParameterInstantiation): this { 70 global.generatedEs2panda._CallExpressionSetTypeParams(global.context, this.peer, passNode(typeParams)) 71 return this 72 } 73 /** @deprecated */ 74 setTrailingBlock(block: BlockStatement): this { 75 global.generatedEs2panda._CallExpressionSetTrailingBlock(global.context, this.peer, passNode(block)) 76 return this 77 } 78 get trailingBlock(): BlockStatement | undefined { 79 return unpackNode(global.generatedEs2panda._CallExpressionTrailingBlockConst(global.context, this.peer)) 80 } 81 /** @deprecated */ 82 setIsTrailingBlockInNewLine(isNewLine: boolean): this { 83 global.generatedEs2panda._CallExpressionSetIsTrailingBlockInNewLine(global.context, this.peer, isNewLine) 84 return this 85 } 86 get isTrailingBlockInNewLine(): boolean { 87 return global.generatedEs2panda._CallExpressionIsTrailingBlockInNewLineConst(global.context, this.peer) 88 } 89 get isETSConstructorCall(): boolean { 90 return global.generatedEs2panda._CallExpressionIsETSConstructorCallConst(global.context, this.peer) 91 } 92} 93export function isCallExpression(node: AstNode): node is CallExpression { 94 return node instanceof CallExpression 95} 96if (!nodeByType.has( Es2pandaAstNodeType.AST_NODE_TYPE_CALL_EXPRESSION)) { 97 nodeByType.set( Es2pandaAstNodeType.AST_NODE_TYPE_CALL_EXPRESSION, CallExpression) 98} 99