Automatically downgrade responses in order to match client capabilities

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

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

Đánh giá

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

Hướng nghiên cứu

Issue không nêu tên tệp, bài kiểm thử hoặc entry point cụ thể nào; hãy bắt đầu bằng việc xác định các kiểu response và phần xử lý capability của client trong thư viện Haskell. Xác định phạm vi của một downgrader tổng quát, bao gồm các trường không được hỗ trợ, các phép chuyển đổi như từ InsertReplaceTextEdit sang TextEdit và các cảnh báo khi không thể thực hiện chuyển đổi.

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

Mô tả

Many specification features take the form of optional additional fields on responses. This means that so long as clients ignore fields they don't recognize or handle, servers can be fairly lax about checking the client capabilities when they return responses.

However:

  1. Sometimes you can't do this at all. An InsertReplaceTextEdit is not a subclass of a TextEdit, so a client that doesn't support InsertReplaceTextEdits will probably just fail if you send it one.
  2. Sometimes you lose information this way. If you have populated the labelDetails field for a CompletionItem, you might lose useful information for the user if it is just dropped, which otherwise you might have put into the label.
  3. It's just a bit ugly to send stuff that the client doesn't understand, and we it's not easy to notice this (previously: https://github.com/haskell/lsp/issues/306).

But doing better currently relies a lot of discipline to check the client capabilities everywhere and have lots of branching logic.

So here's an idea: provide a way to automatically downgrade a response to match the client capabilities. In many cases this will be trivial: drop the unsupported fields. But in other cases we can do a translation that does its best to carry on as much information as possible: turn an InsertReplaceTextEdit into a TextEdit by taking the insertion edit; drop labelDetails by adding it to the label, etc. And if we can't do anything we can perhaps emit a warning.

Take that, stick it in a typeclass, and then we can give people a generic downgrader that they can stick onto the end of their handlers to ensure they get appropriate output.

Ngôn ngữ chính
Haskell
Star
426
Fork
107
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

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.

Issue khác của haskell/lsp

Tất cả issue của haskell/lsp

Issue tương tự

Thêm issue về Haskell

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.