LuaLS / LuaLS/lua-language-server

[Feature request] Annotation for referring to superclass

Đang mở
#2,490 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.

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'm trying to add annotations to classic, but encounter a few problems when doing so.

For example, the super field refers to the superclass. If I were to annotate super like this

---@class Object
---@field protected super Object

then subclasses will have a super field, but it will always refer to Object, instead of their superclass. The best solution I can come up with the current implementation is to set the super field each time a class is created.

---@class Animal : Object
---@field super Object
local Animal = Object:extend()

---@class Bird : Animal
---@field super Animal
local Bird = Object:extend()

This is a repetition of steps, which tells me DRY. I suggest something like a super annotation, which always refers to the superclass relative to which class it is being used.

---@class Object
---@field protected super super

---@class Animal : Object
local Animal = Object:extend()
-- Animal.super refers to Object

---@class Bird: Object
local Bird = Animal:extend()
-- Bird.super refers to Animal

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 xem xét các ví dụ về annotation và mô hình kế thừa của classic.lua được tham chiếu trong issue. Xác định nơi các annotation cho trường của lớp được phân giải và định nghĩa cách một annotation tương đối với lớp cha nên hoạt động đối với Object, Animal và Bird; issue không nêu tệp hay test nào của LuaLS, vì vậy cần thiết lập tiêu chí hoàn thành trước khi triển khai.

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