1. Editor
  2. 如何在ApiHug IDEA插件中使用快捷键和Live Templates

⚠️请及时更新您的IDEA插件保持先进⚠️

💝 官方插件: ApiHug - API design Copilot

快捷键

自ApiHug 插件: 0.2.7

先决条件

  1. 必须是 proto 类型文件;
  2. 必须有ApiHug 标识扩展 option, 比如: option (hope.domain.kind) = IDL 标识为 IDL类型文件(定义API);

由于各个版本IDEA(包括个人调整配置)快捷键被占用不一样,如快捷键失效,您可右击菜单选项调出:

快捷键备注提示支持类型
ctl + alt +shift + M添加 MessageM for MessageBEAN
ctl + alt +shift + F添加 FieldF for FieldBEAN
ctl + alt +shift + K添加 Field(Reference)K for ?BEAN
ctl + alt +shift + U添加 EnumU for Unique constantENUM
ctl + alt +shift + A添加 Enum FieldA for ?ENUM
ctl + alt +shift + X添加 ErrorX for X - wrongERROR
ctl + alt +shift + Z添加 Error FieldZ for ?ERROR
ctl + alt +shift + R添加 ServiceR for ResourceIDL
ctl + alt +shift + P添加 PathP for PathIDL
ctl + alt +shift + Y添加 EntityY for Yummy 😋?ENTITY
ctl + alt +shift + O添加 Entity FieldO for ?ENTITY

亦可参考 Editor Assistant

Live Template

自ApiHug 插件: 0.4.4 - 2024-06-14

  1. Settings > Editor > Live TemplatesApiHug 目录下,你可以查看预定义模版;
  2. 快捷键 CTL + J 将调出上下文可选模版列表,或者:
  3. 直接输入; 编辑器会自动提示的(和语法上下文提示稍不同,前面的ICON不一样);
类型备注条件文件类型
bean添加 Beanoutside the message blockBEAN
beef添加 Bean Fieldinside the message blockBEAN
svc添加 Serviceoutside the service blockIDL
path添加 Pathinside the service blockIDL
pas添加 Parametersinside the method option block(no duplicates detect)IDL
pa添加 Parameterinside the method option block(no duplicates detect)IDL
auth添加 Authinside the method option block(no duplicates detect)IDL
auth2添加 Auth(RBAC Base)inside the method option block(no duplicates detect)IDL
cst添加 Enumoutside the enum blockENUM
cit添加 Enum Fieldinside the enum blockENUM
err添加 Erroroutside the error blockERROR
eit添加 Error Fieldinside the error blockERROR
ety添加 Entityoutside the message blockENTITY
eit添加 Entity Fieldinside the message blockENTITY
eix添加 Entity Indexinside the message option block(no duplicates detect)ENTITY
eux添加 Entity Uniqueinside the message option block(no duplicates detect)ENTITY

参考 Jetbrains 官方: Live templates

视频教程

  1. ApiHug101-Bilibili
  2. ApiHug101 Youtube