LuaLS / LuaLS/lua-language-server

Annotations `@enum` and `@enum (key)` in JSON output

未关闭
#2,530 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Lua
星标
4.4k
派生
442
PR 合并指标
30 天内没有已合并 PR

描述

Annotations `@enum` and `@enum (key)` produce very different JSON output.

# Annotation `@enum`

```lua
---@enum level1
---Description of enum level1.
local level1 = {
low = 1, --Low level.
high = 2, --High level.
}
```
This enum creates the following JSON output:

```json
{
"defines": [
{
"file": "file:///home/andreas/Projects/Code/luals2dox/test/./enum/enum-02.lua",
"finish": 15,
"start": 9,
"type": "doc.enum"
}
],
"desc": "```lua\n{\n low: integer = 1,\n high: integer = 2,\n}\n```",
"fields": [],
"name": "level1",
"rawdesc": "```lua\n{\n low: integer = 1,\n high: integer = 2,\n}\n```",
"type": "type"
},
{
"defines": [
{
"file": "file:///home/andreas/Projects/Code/luals2dox/test/./enum/enum-02.lua",
"finish": 40007,
"start": 40003,
"type": "tablefield"
}
],
"desc": "High level.",
"fields": [],
"name": "level1.high",
"rawdesc": "High level.",
"type": "type"
},
{
"defines": [
{
"file": "file:///home/andreas/Projects/Code/luals2dox/test/./enum/enum-02.lua",
"finish": 30006,
"start": 30003,
"type": "tablefield"
}
],
"desc": "Low level.",
"fields": [],
"name": "level1.low",
"rawdesc": "Low level.",
"type": "type"
},
```

Issues:
- First block: `start` and `finish` numbers are wrong.
- Description of enum `Description of enum level1.` is missing.

Just curious:
- Why are there 3 separate blocks for this enum? I'd expected block 2 and 3 (enum items) to be sub-blocks of block 1 (enum). This would make it easier reading/postprocessing the JSON file.

# Annotation `@enum (key)`

```lua
---@enum (key) level2
---Description of enum level2.
local level2 = {
low = 1, --Low level.
high = 2, --High level.
}
```
This enum create the following JSON output:

```json
{
"defines": [
{
"file": "file:///home/andreas/Projects/Code/luals2dox/test/./enum/enum-02.lua",
"finish": 70021,
"start": 70015,
"type": "doc.enum"
}
],
"desc": "```lua\n\"low\" | \"high\"\n```",
"fields": [],
"name": "level2",
"rawdesc": "```lua\n\"low\" | \"high\"\n```",
"type": "type"
},
```

Issues:
- Description of enum `Description of enum level2.` is missing.
- Description of enum items `Low level.` and `High level.` are missing.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

重现 issue 中带注解的两个 enum 示例,并检查 language server 的注解处理和 JSON 输出入口。比较 enum 及其项的源范围和传递的描述。完成的标准是两种形式都保留 enum 和项的描述,报告正确的开始/结束值,并且输出结构符合项目预期的行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
lua
领域
devtools
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。