LuaLS / LuaLS/lua-language-server

Feature Request: Hide a parameter from the annotation

オープン
#2,033 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

enhancement question
主要言語
Lua
スター
4.4k
フォーク
442
PR マージ指標
30日以内にマージされた PR はありません

説明

I have a table with a metatable assigned to it to implement inheritance. The metatable's `__index` metamethod intercepts a call to a function on the original table and gets the actual function from the "parent" table and then injects another parameter into the function call.

For example, the user would call the function like this: `tbl:Execute("hello", "world")` and the function would be implemented like this:

```lua
function ParentTable:Execute(data, hello, world)
-- data is a special parameter controlled by the metatable and is given a table value
-- hello is assigned "hello" and world is assigned "world"
end
```

The problem with this is that VS Code and LuaLS warns the user that they didn't provide a value to `data`. I have to use `@overload` to every single method to say you can call this method with just "hello" and "world" arguments provided.

I want to be able to tell LuaLS to completely hide/ignore the `data` parameter and pretend it doesn't exist; essentially moving all other parameter indexes down by 1 to fill the empty spot, so "hello" is recognized as parameter 1 and "world" as parameter 2.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、LuaLS が関数パラメーターのアノテーション、@overload 宣言、およびメタテーブルの __index メタメソッドを通じてインターセプトされる呼び出しをどのように処理しているかを追跡します。LuaLS が注入されたデータパラメーターを隠し、表示される引数をずらし、呼び出し側が hello と world だけを渡した場合に警告を出さなくなれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
lua
領域
devtools
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。