LuaLS / LuaLS/lua-language-server

Feature Request: Hide a parameter from the annotation

Đang mở
#2,033 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

enhancement question
Ngôn ngữ chính
Lua
Star
4.4k
Fork
442
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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:

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng việc theo dõi cách LuaLS xử lý các chú thích tham số hàm, các khai báo @overload và các lệnh gọi được chặn thông qua metamethod __index của một metatable. Công việc được hoàn tất khi LuaLS có thể ẩn tham số dữ liệu được chèn vào, dịch chuyển các đối số hiển thị và ngừng cảnh báo khi bên gọi chỉ cung cấp hello và world.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
lua
Lĩnh vực
devtools
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.