LuaLS / LuaLS/lua-language-server
Difference in behavior between table literal, dictionary, and class in terms of completion
まだ誰も着手していません。
- 主要言語
- Lua
- スター
- 4.4k
- フォーク
- 442
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Maybe more of a feature request than a bug, but I noticed some interesting differences between classes, dictionaries, and table literals in terms of completions.
Using this code as a base:
```lua
---@class TestClass
---@field test_group TestGroup
---@class TestGroup
---@field test_field string
---@alias TestTableDictionary {["test_group"]: {["test_field"]: string}}
---@alias TestTableLiteral {test_group: {test_field: string}}
---@type TestClass
local test_class
local test_group = "test_group"
local test1 = test_class["test_group"].test_field
---@type TestTableDictionary
local test_table_dictionary
local test_group = "test_group"
local test2 = test_table_dictionary[test_group].test_field
---@type TestTableLiteral
local test_table_literal
local test_group = "test_group"
local test3 = test_table_literal[test_group].test_field
```
I would expect the completion for test1, test2, and test3 to be equivalent. However there are some interesting differences.
For test 1 if we do this `local test1 = test_class[test_group].test_field` the type of test1 is unknown and there is no completion suggestions for `test_class[test_group].` Both `test_class["test_group"].test_field` and `test_class.test_group.test_field` work correctly.
For test 2 `test_table_dictionary[test_group].test_field` works correctly. `test_table_dictionary.test_group.test_field` gives the right value but does not show any completion suggestions like the classes do.
For test 3 the table literal is the best of all worlds. You can do ` test_table_literal[test_group].test_field` as well as get completions on test_table_literal.test_group.test_field.
As I am using classes in a lot of places and they are useful as they can be spread across multiple lines and the fields can have longer descriptions it would be awesome to see the ability to do something like `test_class[test_group].test_field` for classes
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
この issue ではソースファイルやテストが指定されていないため、3 つの Lua の例を使って、class fields、dictionary aliases、table literals に対する language server の completion 処理を追跡することから始めてください。等価なインデックス式とドット式で、期待される型と completion の候補が提供されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua
- 領域
- developer-experience
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100