LuaLS / LuaLS/lua-language-server
[Question/Request] Can I recycle common params for differing functions without mass copy+paste?
还没有人认领这个 Issue。
- 主要语言
- Lua
- 星标
- 4.4k
- 派生
- 442
- PR 合并指标
- 30 天内没有已合并 PR
描述
I would like to be able to recycle a list of parameters (and types), sometimes with an extra parameter or a different set of return values. I only know how to do this via copy+paste of parameters from one function to the next, and edit as needed. However, I am trying to reduce the code volume, clarity, as well as make it easier to enact changes that should cascade to any function which uses those sets of parameters.
Here's an example:
---@param blah number
---@param barf function
---@param puke fun(boolean):number
---@param thanks table
function foo(blah, barf, puke, thanks)
end
---@param blah number
---@param barf function
---@param puke fun(boolean):number
---@param thanks table
---@return boolean
function bar(blah, barf, puke, thanks)
return true
end
I'd like to be able to define a 'defined parameter set' which would allow me to do something like this:
---@parameters hmmm
---@param blah number
---@param barf function
---@param puke fun(boolean):number
---@param thanks table
---@uses parameters hmmm
function foo(blah, barf, puke, thanks)
end
---@uses parameters hmmm
---@return boolean
function bar(blah, barf, puke, thanks)
return true
end
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
该 issue 没有指出实现文件、测试或入口点。首先定位 Lua 注解(例如 @param 和 @return)的解析方式,然后评估可复用的参数集声明及其使用方式如何适配这一语法。完成的标准是:共享参数可以只记录一次,由多个函数复用,能够与不同的返回值进行扩展或组合,并且有测试覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua
- 领域
- devtools
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100