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 { Statement } from "./Statement" 33import { Expression } from "./Expression" 34import { Identifier } from "./Identifier" 35import { AnnotationUsage } from "./AnnotationUsage" 36export class AnnotationDeclaration extends Statement { 37 constructor(pointer: KNativePointer) { 38 assertValidPeer(pointer, 1) 39 super(pointer) 40 41 } 42 static createAnnotationDeclaration(expr?: Expression): AnnotationDeclaration { 43 return new AnnotationDeclaration(global.generatedEs2panda._CreateAnnotationDeclaration(global.context, passNode(expr))) 44 } 45 static updateAnnotationDeclaration(original?: AnnotationDeclaration, expr?: Expression): AnnotationDeclaration { 46 return new AnnotationDeclaration(global.generatedEs2panda._UpdateAnnotationDeclaration(global.context, passNode(original), passNode(expr))) 47 } 48 static create1AnnotationDeclaration(expr: Expression | undefined, properties: readonly AstNode[]): AnnotationDeclaration { 49 return new AnnotationDeclaration(global.generatedEs2panda._CreateAnnotationDeclaration1(global.context, passNode(expr), passNodeArray(properties), properties.length)) 50 } 51 static update1AnnotationDeclaration(original: AnnotationDeclaration | undefined, expr: Expression | undefined, properties: readonly AstNode[]): AnnotationDeclaration { 52 return new AnnotationDeclaration(global.generatedEs2panda._UpdateAnnotationDeclaration1(global.context, passNode(original), passNode(expr), passNodeArray(properties), properties.length)) 53 } 54 get internalName(): string { 55 return unpackString(global.generatedEs2panda._AnnotationDeclarationInternalNameConst(global.context, this.peer)) 56 } 57 /** @deprecated */ 58 setInternalName(internalName: string): this { 59 global.generatedEs2panda._AnnotationDeclarationSetInternalName(global.context, this.peer, internalName) 60 return this 61 } 62 get expr(): Expression | undefined { 63 return unpackNode(global.generatedEs2panda._AnnotationDeclarationExprConst(global.context, this.peer)) 64 } 65 get properties(): readonly AstNode[] { 66 return unpackNodeArray(global.generatedEs2panda._AnnotationDeclarationPropertiesConst(global.context, this.peer)) 67 } 68 get propertiesPtr(): readonly AstNode[] { 69 return unpackNodeArray(global.generatedEs2panda._AnnotationDeclarationPropertiesPtrConst(global.context, this.peer)) 70 } 71 /** @deprecated */ 72 addProperties(properties: readonly AstNode[]): this { 73 global.generatedEs2panda._AnnotationDeclarationAddProperties(global.context, this.peer, passNodeArray(properties), properties.length) 74 return this 75 } 76 get isSourceRetention(): boolean { 77 return global.generatedEs2panda._AnnotationDeclarationIsSourceRetentionConst(global.context, this.peer) 78 } 79 get isBytecodeRetention(): boolean { 80 return global.generatedEs2panda._AnnotationDeclarationIsBytecodeRetentionConst(global.context, this.peer) 81 } 82 get isRuntimeRetention(): boolean { 83 return global.generatedEs2panda._AnnotationDeclarationIsRuntimeRetentionConst(global.context, this.peer) 84 } 85 /** @deprecated */ 86 setSourceRetention(): this { 87 global.generatedEs2panda._AnnotationDeclarationSetSourceRetention(global.context, this.peer) 88 return this 89 } 90 /** @deprecated */ 91 setBytecodeRetention(): this { 92 global.generatedEs2panda._AnnotationDeclarationSetBytecodeRetention(global.context, this.peer) 93 return this 94 } 95 /** @deprecated */ 96 setRuntimeRetention(): this { 97 global.generatedEs2panda._AnnotationDeclarationSetRuntimeRetention(global.context, this.peer) 98 return this 99 } 100 get annotations(): readonly AnnotationUsage[] { 101 return unpackNodeArray(global.generatedEs2panda._AnnotationDeclarationAnnotationsConst(global.context, this.peer)) 102 } 103 /** @deprecated */ 104 setAnnotations(annotations: readonly AnnotationUsage[]): this { 105 global.generatedEs2panda._AnnotationDeclarationSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) 106 return this 107 } 108} 109export function isAnnotationDeclaration(node: AstNode): node is AnnotationDeclaration { 110 return node instanceof AnnotationDeclaration 111} 112if (!nodeByType.has(1)) { 113 nodeByType.set(1, AnnotationDeclaration) 114}