Lua 无强制类型。当 LuaDebug 无法推断变量类型时,用标签辅助解析。
标签格式
- 形式:
[文件名#类型名]。#前是所属文件,后面是 table / 类型名。 - 在注释区域输入
[会自动提示;非注释区域不会弹出。 - 数组:类型后加
<>,如[Model.TestModel#TestModel<>]。
标签类型
@RefType— 变量引用类型@SuperType— 父类型@return— 返回值类型@参数名 : [xx#xx]— 参数类型
示例
--@RefType [Model2#MM_]
local data = cl1
--@SuperType [Base#BaseView]
local M = class("LoginView")
---@return [Model.Player#Player]
function createPlayer()
end
--@name : [Model.Player#Player]
function foo(name)
end
与设置的关系
luadebug.tagIsShowFileName:习惯local M_ = {}时标签易都显示 M_;true 时显示「文件名/M_」。luadebug.moduleNames:哪些名字当作模块返回表(默认 M_ / _M / M)。luadebug.defineModule:哪些函数表示定义模块/类(如 class、this)。luadebug.ctorNames:构造函数名;其中对 self.xxx 的赋值用于跳转优先。