LuaLS / LuaLS/lua-language-server

Multiple return values for fields

未關閉
#2,357 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

feat/LuaCats Annotations
主要語言
Lua
星號
4.4k
分支
442
PR 合併指標
30 天內沒有已合併 PR

描述

### How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

### Which OS are you using?

Windows

### What is the issue affecting?

Annotations

### Expected Behaviour

The ability to define multiple return values for a field annotation.

### Actual Behaviour

Any non-identifier symbol following a type is treated as a comment or a break.

### Reproduction steps

1. Create a field with a comma separated return type.
2. See that anything following the comma is treated as a comment.

### Additional Notes

```lua
---@class Color
---@field [string] Color,string
Color = {}
```
`,string` is highlighted as a comment.
```lua
---@class Color
---@field [string] Color, string
Color = {}
```
`,` is highlighted as a symbol, ` string` is highlighted as a comment.

---
An example of fields with multiple return types are the named color lookups in the Tabletop Simulator API:
https://api.tabletopsimulator.com/color/#colorblue

```lua
local color, name = Color.Blue
print(color) -- Color: Blue { r = 0.118, g = 0.53, b = 1, a = 1 }
print(name) -- Blue

local color, name = Color.Red
print(color) -- Color: Red { r = 0.856, g = 0.1, b = 0.094, a = 1 }
print(name) -- Red
```

### Log File

_No response_

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

首先使用提供的 Lua 程式碼片段重現註解解析器的行為,重點關注 @field 宣告後以逗號分隔的型別是如何被分詞的。完成的標準是:Color,string 這樣的多個回傳型別會被辨識為註解型別,而不是將其餘部分視為註解;如果 repository 中有相關的解析器測試,請新增或更新涵蓋範圍。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
lua
領域
devtools
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。