1# NAPI框架生成工具IntelliJ插件说明 2 3## 简介 4 5NAPI框架代码生成工具,它可以根据用户指定路径下的ts(typescript)接口文件一键生成NAPI框架代码、业务代码框架、GN文件等。目前工具支持可执行文件、VS Code插件、DevEco Studio上使用的IntelliJ插件三种入口,本文主要介绍IntelliJ插件使用说明。 6 7## 目录 8 9 ├── napi_generator/src/intellij_plugin/dts2cpp # NAPI框架代码生成工具 10 │ ├── napi_IntelliJ_plugin 11 │ │ ├── docs # IntelliJ插件说明 12 │ │ ├── resources # IntelliJ插件所需资源文件 13 │ │ ├── src # IntelliJ插件源码 14 │ │ └── README_zh # IntelliJ插件说明 15 16## 约束 17 18系统:建议Windows 10 19 20依赖版本:JDK 11 21 22开发工具:DevEco stdio、IDEA Community 2021.3.3 23 24## 使用方法 25 26### 使用对象 27 28系统开发者 29 30### 使用场景 31 321) 系统框架层新增子系统,需对应用层提供接口。 332) 系统框架层子系统能力增强后,需对应用层提供新接口。 34 35### 工具使用 36 37插件下载路径如下,选择新版本下载。 38 39[DevEco Studio上使用的IntelliJ插件下载链接](https://plugins.jetbrains.com/plugin/19593-napi-generator/versions) 40 41 42 43具体的工具使用步骤,可以左键单击以下链接了解: 44 45[工具使用说明](https://gitee.com/openharmony/napi_generator/tree/master/src/intellij_plugin/dts2cpp/napi_IntelliJ_plugin/docs/usage/INSTRUCTION_ZH.md) 46 47### 工具输出 48 49根据使用者指定的typescript文件,工具会输出NAPI框架代码、业务代码框架、GN脚本等文件。 50 51为了方便使用者快速上手工具,可供测试的typescript文件存放在DevEco Studio中以下路径: 52 53``` 54entry/src 55``` 56 57在window环境下的,根据输入文件@ohos.napitest.d.ts和basic.d.ts生成的输出文件,如下所示: 58 59 60 61 62 63其中CMakeLists.txt为编译构建需要的文件,cfg.json为生成的业务代码配置文件,若用户不进行业务代码配置,则不会生成该文件;生成的"napitest.h"文件,定义了框架代码的接口,生成的部分接口如下所示: 64 65``` 66... 67class NodeISayHello { 68public: 69 bool addSayHelloListener(NodeISayHelloListener& listener); 70 static NodeISayHelloListener listener_; 71 bool removeSayHelloListener(NodeISayHelloListener& listener); 72 bool registerCallbackfunc(); 73 // 供业务调用的回调接口 74 void CallbackfuncCallback(NUMBER_TYPE_2& wid); 75 76 bool unRegisterCallbackfunc(); 77 bool sayHello(std::string& from, std::string& to, NUMBER_TYPE_9& sayType); 78 bool sayHi(std::string& from, std::string& to, NUMBER_TYPE_10& sayType); 79 bool sayHelloWithResponse(std::string& from, std::string& to, NUMBER_TYPE_11& sayType, uint32_t& outErrCode, AUTO_INTERFACE_5& out); 80 static AUTO_INTERFACE_5 auto_interface_5OutRes; 81 void auto_interface_5SetCbValue(NUMBER_TYPE_6 result, std::string errMsg, std::string response); 82}; 83... 84``` 85 86## 开发说明 87 88### 对象 89 90工具的开发者 91 92### 开发场景 93 94若当前工具的功能已经不能满足开发者的全部需求,则开发者可以基于已有的源码对工具进行二次开发,来增强工具的能力,编译打包生成自定义的可执行文件和插件。 95 96### 开发步骤 97 98开发者可以根据如下的步骤来完成对DevEco Studio上使用的工具IntelliJ插件的开发: 99 100 [工具开发说明](https://gitee.com/openharmony/napi_generator/tree/master/src/intellij_plugin/dts2cpp/napi_IntelliJ_plugin/docs/guide/DEVELOP_ZH.md) 101 102## 版本说明 103 104当前版本已支持的特性和待开发的特性,如下所示: 105 106 [已支持特性](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/dts2cpp/docs/release-notes) 107 108 [待支持特性](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/dts2cpp/docs/requirement/ROADMAP_ZH.md) 109 110## FAQ 111 112对于常见问题解决方法指导如下: 113 114 [FAQ](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/dts2cpp/docs/guide/FAQ.md) 115 116## 相关仓 117 118暂无