LuaLS / LuaLS/lua-language-server

@constraint Annotation for types/aliases

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

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

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

説明

I was working with Annotations for documenting my code and wanted to add a warning if the user used a function that didn't fall under a specific pattern ("0x%x%x%x%x%x%x%x%x") and tried finding a workaround. I'm not 100% fluent with .lua and don't have the confidence to PR, so take my idea instead.

My idea for the annotation would be as follows:

--- @constraint con_color (string.find(T , "^0x%x%x%x%x%x%x%x%x$") or string.find(T , "^%x%x%x%x%x%x$"))
--- @alias color string<con_color>
--- @param col1 color
--- @param col2 color
local function set_col(col1, col2)
    ...
end

Obviously syntax could use work, but the basic idea would be to add a constraint, and have T or whatever variable name be the entry. This way you can give a warning to users about unsupported string or a number being too low/high being used. If there is already something like this please enlighten me as I couldn't find anything

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

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

はじめの一歩

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

調査の方向性

issue では具体的なファイルやテストが指定されていないため、まず language server における @alias と @param の既存のアノテーション処理を確認します。提案された @constraint 構文でエイリアスを検証し、警告を生成する方法を検討してから、実装前に構文と期待される動作を定義します。完了とは、色の例で文書化された制約が機能し、無効な値が診断されることを意味します。

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

評価

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

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

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