@named注解(enumerated注解)

发布时间:2024-04-04
本文主要介绍@命名注释(枚举注释),下面一起看看@命名注释(枚举注释)相关资讯。
前言#在线配置emmylua的方法有很多,所以我赢了 这里就不赘述了(所以前提是你已经安装并配置了emmylua)。
本文只是emmylua插件中注释函数使用的代码演示。因为这部分在大部分网上emmylua配置教程中都没有讲解,而emmylua的注释功能在实际lua开发中几乎是必不可少的,所以我假装这篇文章。
注释的目的#当我们在编写c#脚本时,ide的相关插件可以提示各种方法或成员,并描述:
但是在lua中,即使安装了emmylua,如果你不 t写注释,不会有提示(灰色提示只表示参数刚刚写完,你没有 我根本不知道它是成员变量还是方法):
所以emmylua注释函数就是为了解决这个问题:模拟实现代码提示。
用法# class #基本格式声明:-@ class my _ type[echo 1-@ . parent _ type][@ comment]
-@ class person person = { };-@ class gam:人gamer = { };一个类的附加属性#即使该类没有持有某个属性,也可以通过添加注释的出现在提示中(ps:其实emmylua s提示实现unityapi也是基于此)。
基本格式:-@ field[public | protected | private]field _ name field _ type[| other _ type][@ comment]
-@ class person person-@ field public name string name-@ field private m _ a number age person = { name = ,};变量类型#基本格式:-@ type my _ type[| other _ type][@ comment]
标签数组:-@ typemy _ type []
注释字典:-@ typetablekey _ type,value _ type。
ps:按照上面官方的用法,评论的描述应该放在最后,但是我尝试了这个。类型不大,可以放在最上面。
-我的id-@ type number myid = 1;-gamer的一个例子-@ type gamer gamera = gamer : create;-玩家阵列-@ type gamer[]gamers arr = { };-播放器和播放器;;s字典-@ typetablenumber,gamer stable = { };function #表示函数定义参数的类型:-@ param param _ name my _ type[| other _ type][@ comment]
批注函数返回值的类型:-@ return my _ type[| other _ type][@ comment]
标签函数的不定参数:-@ varargtype
-get lines-@ paramiscn boolean是中文-@ paramid # lines字典id-@ returnstring lines函数getlines (iscn,id)local str = -做一些事情返回strend -累积和-@ varargnumber累积数-@返回数和函数addnum(...)局部合计= 0;对于_,v成对{...} do total = total v;最终退货总额;end type的别名#对于变量类型的注释,通常可以使用上面提到的- @type(常用的类型有string|number|boolean|table|...或者- @class声明的用户自定义类型),但是如果遇到复杂类型(比如闭包函数),可以使用alias annotation将一些复杂且难以输入的类型注册为新的别名:
基本格式:-@ aliasn:字符串): void返回函数(logmsg) if(logl: ..logmsg);: ..logmsg);endended-@ type logprinterlocal lp = genlog printer(1);-@ type logprinterlocal lp _ warning = g:一个正常日志。lp _ warning( 警告日志。 );-警告:一个警告日志。嵌入式语言#用于标记某一段代码格式的文本(json、xml、java等。)这样才能突出。
基本格式:-@ languagelanguage _ id
-@ language json local jsontext =[[{ 姓名和名称: 小丑 、;ag: 18 }]-@ language xml local xmltext =[[person name value = 小丑 /age value = 18 //person]]备注#在这个思路下,对目标使用alt enter快捷键(或者点亮一个小灯泡),这样更容易自动完成评论:
具体例子#现有的person基类,gamer类继承自person,两个类的创建和使用都在main.lua中实现(贴在本地运行即可):
main.lua:
要求( 人与自然);要求( 游戏玩家 );-@ type person local pa = person : create( 小丑 , 18);pae cho 1-@ . comshowinfo;pa: rename( 小丑 );pae cho 1-@ . com show info-@ type gamer local ga = gamer : create( 福克斯 ,19,零,零);gae cho 1-@ . comshowinfo;gae cho 1-@ . com rename( 福克斯 );gae cho 1-@ . comregamerinfo( 一23 , 456 );gae cho 1-@ . comshowinfo;person.lua:
-@ classperson人类型-@ field public name string name-@ field private m _ age number age person = { name = ,m_age = 0,};人。__index =人;-create-@ param name string-@ param age number function person : create(name,age)-@ type person local t = { };s:r:reage(年龄);return t;end-rename-@ param newname string-@ public function person : rename(newname)self。name = newnameend-reage-@ param new age number-@ private function person : reage(new age)self . m _ age = new age;end-showinfo-@ public function person : showinfoprint( name = ..自我。名字.. ,年龄= ..self . m _ age);endgamer.lua:
要求( 人与自然)-@ class gam:个人玩家-@ field private sw string sw cod:create(姓名,年龄,sw,steamid)-@ type gamer local t = { };t = p:cr:regamerinfo(sw,steamid);return t;end-rega merinfo-@ param sw string-@ param steamid string-@ public function gamer: rega merinfo(sw,steamid) self。sw = sw或 0 自我。steamid = steamid或 0 end-showinfo-@ public function gamer:showinfoprint( nam——模拟类,继承,多态性-马三 的代码实践。
参考文章# emmyloua标签:
注释功能
了解更多@命名注释(枚举注释)相关内容请关注本站点。
上一个:为什么10000毫安的充电宝额定是6000(充电宝一万毫安的好还是两万毫安的好)
下一个:mysql获取字段长度(数据库获取字符串长度)

全自动酸值测定仪的特点介绍
粉针剂分装机保养维护是需要一定技巧的
使用美国binmaster SPL-200激光液位传感器有哪些好处
智慧用电安全管理系统,让用户买到满意为止
wind10安全模式进不去(win10安全模式进不去怎么办)
保温材料养护箱
影像金相显微镜景深的原因
oppor9plus应用怎么锁
TS系列分光测色仪应该怎么使用?
多种污水处理工艺介绍