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