diff --git a/koala-wrapper/native/src/bridges.cc b/koala-wrapper/native/src/bridges.cc index 440bb5ba44bbf6a3650255987243ab0a6a630099..5153413a12ce37fe8ecd2e027f7be3a3d8000293 100644 --- a/koala-wrapper/native/src/bridges.cc +++ b/koala-wrapper/native/src/bridges.cc @@ -657,3 +657,41 @@ void impl_LogDiagnosticWithSuggestion(KNativePointer context, KNativePointer dia GetImpl()->LogDiagnosticWithSuggestion(_context, _diagnosticInfo, _suggestionInfo, _range); } KOALA_INTEROP_V4(LogDiagnosticWithSuggestion, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +static KNativePointer impl_ClassDefinitionJsDocInformation(KNativePointer contextPtr, KNativePointer nodePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + std::size_t source_len = 0; + auto jsdoc_infos = GetImpl()->ClassDefinitionJsDocInformation(context, node, &source_len); + return new std::vector(jsdoc_infos, jsdoc_infos + source_len); +} +KOALA_INTEROP_2(ClassDefinitionJsDocInformation, KNativePointer, KNativePointer, KNativePointer); + +static KNativePointer impl_JsDocInfoJsDocRecords(KNativePointer instancePtr) +{ + auto jsdoc_info = reinterpret_cast(instancePtr); + return new std::vector(jsdoc_info->jsDocRecords, jsdoc_info->jsDocRecords + jsdoc_info->len); +} +KOALA_INTEROP_1(JsDocInfoJsDocRecords, KNativePointer, KNativePointer); + +static KNativePointer impl_JsDocRecordName(KNativePointer instancePtr) +{ + auto jsdoc_record = reinterpret_cast(instancePtr); + return jsdoc_record->name; +} +KOALA_INTEROP_1(JsDocRecordName, KNativePointer, KNativePointer); + +static KNativePointer impl_JsDocRecordParam(KNativePointer instancePtr) +{ + auto jsdoc_record = reinterpret_cast(instancePtr); + return jsdoc_record->param; +} +KOALA_INTEROP_1(JsDocRecordParam, KNativePointer, KNativePointer); + +static KNativePointer impl_JsDocRecordComment(KNativePointer instancePtr) +{ + auto jsdoc_record = reinterpret_cast(instancePtr); + return jsdoc_record->comment; +} +KOALA_INTEROP_1(JsDocRecordComment, KNativePointer, KNativePointer); diff --git a/koala-wrapper/src/Es2pandaNativeModule.ts b/koala-wrapper/src/Es2pandaNativeModule.ts index 83a90fea2e5988d44f46bd413e381d7504e33271..d83859d226f3208e999b023a408b4e75fa26f40a 100644 --- a/koala-wrapper/src/Es2pandaNativeModule.ts +++ b/koala-wrapper/src/Es2pandaNativeModule.ts @@ -15,6 +15,7 @@ import { KNativePointer as KPtr, + KStringPtr, KInt, KBoolean, KNativePointer, @@ -934,6 +935,26 @@ export class Es2pandaNativeModule { _SetUpSoPath(soPath: string): void { throw new Error('Not implemented'); } + + _ClassDefinitionJsDocInformation(context: KNativePointer, instance: KNativePointer): KNativePointer { + throw new Error('Not implemented'); + } + + _JsDocInfoJsDocRecords(instance: KNativePointer): KNativePointer { + throw new Error('Not implemented'); + } + + _JsDocRecordName(instance: KNativePointer): KStringPtr { + throw new Error('Not implemented'); + } + + _JsDocRecordParam(instance: KNativePointer): KStringPtr { + throw new Error('Not implemented'); + } + + _JsDocRecordComment(instance: KNativePointer): KStringPtr { + throw new Error('Not implemented'); + } } export function initEs2panda(): Es2pandaNativeModule { diff --git a/koala-wrapper/src/arkts-api/index.ts b/koala-wrapper/src/arkts-api/index.ts index f0a9a91d143027d46b4a4f793c0adf8cdf5b838c..eb10294b9fd3aadd1257f0f78baa39c22c26486b 100644 --- a/koala-wrapper/src/arkts-api/index.ts +++ b/koala-wrapper/src/arkts-api/index.ts @@ -63,6 +63,7 @@ export * from "../generated/peers/TSArrayType" export * from "../generated/peers/ArrayExpression" export * from "../generated/peers/TryStatement" export * from "../generated/peers/ETSNullType" +export * from "../generated/peers/JsDoc"; export * from "./types" export * from "./utilities/private" diff --git a/koala-wrapper/src/generated/index.ts b/koala-wrapper/src/generated/index.ts index 0416a06912d49fe13ddd404bbe71562bca49a235..d096350b573c1e4ae52f49dde14513cbf68335d8 100644 --- a/koala-wrapper/src/generated/index.ts +++ b/koala-wrapper/src/generated/index.ts @@ -189,3 +189,4 @@ export * from "./peers/ETSDynamicFunctionType" export * from "./peers/InterfaceDecl" export * from "./peers/FunctionDecl" export * from "./peers/Context" +export * from "./peers/JsDoc" diff --git a/koala-wrapper/src/generated/peers/JsDoc.ts b/koala-wrapper/src/generated/peers/JsDoc.ts new file mode 100644 index 0000000000000000000000000000000000000000..e5f787072191c496506bc69ceaaf270d3814a867 --- /dev/null +++ b/koala-wrapper/src/generated/peers/JsDoc.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + KNativePointer, + ArktsObject, + unpackString, +} from '../../reexport-for-generated'; +import { ClassDefinition } from '../../generated'; +import { acceptNativeObjectArrayResult } from '../../arkts-api/utilities/private'; + +export class JsDocInfo extends ArktsObject { + constructor(peer: KNativePointer) { + super(peer); + } + + get records(): JsDocRecord[] { + return acceptNativeObjectArrayResult( + global.es2panda._JsDocInfoJsDocRecords(this.peer), + (instance: KNativePointer) => new JsDocRecord(instance) + ); + } +} + +export class JsDocRecord extends ArktsObject { + constructor(peer: KNativePointer) { + super(peer); + } + + get name(): string { + return unpackString(global.es2panda._JsDocRecordName(this.peer)); + } + + get param(): string { + return unpackString(global.es2panda._JsDocRecordParam(this.peer)); + } + + get comment(): string { + return unpackString(global.es2panda._JsDocRecordComment(this.peer)); + } +} + +export function classDefinitionJsDocInformation(node: ClassDefinition): JsDocInfo[] { + return acceptNativeObjectArrayResult( + global.es2panda._ClassDefinitionJsDocInformation(global.context, node.peer), + (instance: KNativePointer) => new JsDocInfo(instance) + ); +} \ No newline at end of file