• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 { AnnotatedExpression } from "./AnnotatedExpression"
33import { Expression } from "./Expression"
34import { TypeNode } from "./TypeNode"
35export class TSAsExpression extends AnnotatedExpression {
36     constructor(pointer: KNativePointer) {
37        assertValidPeer(pointer, Es2pandaAstNodeType.AST_NODE_TYPE_TS_AS_EXPRESSION)
38        super(pointer)
39
40    }
41    static createTSAsExpression(expression: Expression | undefined, typeAnnotation: TypeNode | undefined, isConst: boolean): TSAsExpression {
42        return new TSAsExpression(global.generatedEs2panda._CreateTSAsExpression(global.context, passNode(expression), passNode(typeAnnotation), isConst))
43    }
44    static updateTSAsExpression(original: TSAsExpression | undefined, expression: Expression | undefined, typeAnnotation: TypeNode | undefined, isConst: boolean): TSAsExpression {
45        return new TSAsExpression(global.generatedEs2panda._UpdateTSAsExpression(global.context, passNode(original), passNode(expression), passNode(typeAnnotation), isConst))
46    }
47    get expr(): Expression | undefined {
48        return unpackNode(global.generatedEs2panda._TSAsExpressionExprConst(global.context, this.peer))
49    }
50    /** @deprecated */
51    setExpr(expr: Expression): this {
52        global.generatedEs2panda._TSAsExpressionSetExpr(global.context, this.peer, passNode(expr))
53        return this
54    }
55    get isConst(): boolean {
56        return global.generatedEs2panda._TSAsExpressionIsConstConst(global.context, this.peer)
57    }
58    /** @deprecated */
59    setUncheckedCast(isUncheckedCast: boolean): this {
60        global.generatedEs2panda._TSAsExpressionSetUncheckedCast(global.context, this.peer, isUncheckedCast)
61        return this
62    }
63    get typeAnnotation(): TypeNode | undefined {
64        return unpackNode(global.generatedEs2panda._TSAsExpressionTypeAnnotationConst(global.context, this.peer))
65    }
66    /** @deprecated */
67    setTsTypeAnnotation(typeAnnotation: TypeNode): this {
68        global.generatedEs2panda._TSAsExpressionSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation))
69        return this
70    }
71}
72export function isTSAsExpression(node: AstNode): node is TSAsExpression {
73    return node instanceof TSAsExpression
74}
75if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_AS_EXPRESSION)) {
76    nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_AS_EXPRESSION, TSAsExpression)
77}
78