Automatically downgrade responses in order to match client capabilities

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

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

評価

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

調査の方向性

この issue では具体的なファイル、テスト、エントリポイントが指定されていません。まず、Haskell ライブラリ内のレスポンスタイプとクライアント能力の処理箇所を特定してください。未対応フィールド、InsertReplaceTextEdit から TextEdit への変換のような変換、および変換できない場合の警告を含め、汎用ダウングレーダーの範囲を定義してください。

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

説明

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.

主要言語
Haskell
スター
426
フォーク
107
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

haskell/lsp のほかの issue

haskell/lsp の issue をすべて見る

似ている issue

Haskell の issue をもっと見る

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

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