LuaLS / LuaLS/lua-language-server

Difference in behavior between table literal, dictionary, and class in terms of completion

Đang mở
#2,217 0 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
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ả

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:

---@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

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

Issue không nêu tên tệp nguồn hay các bài kiểm thử; hãy bắt đầu bằng cách lần theo việc xử lý completion của language server đối với các trường lớp, bí danh từ điển và literal bảng, sử dụng ba ví dụ Lua. Công việc được xem là hoàn tất khi các biểu thức lập chỉ mục và biểu thức dùng dấu chấm tương đương cung cấp kiểu dự kiến và các gợi ý completion dự kiến.

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
developer-experience
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
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
35/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.