Automatically downgrade responses in order to match client capabilities

Abierto
#367 1 comentario 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
haskell
Área
api

Línea de trabajo

El issue no menciona archivos, pruebas ni puntos de entrada específicos; empieza por localizar los tipos de respuesta y el manejo de las capacidades del cliente en la biblioteca de Haskell. Define el alcance de un downgrader genérico, incluidas las conversiones como de InsertReplaceTextEdit a TextEdit y las advertencias cuando no sea posible realizar ninguna conversión.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Haskell
Estrellas
426
Forks
107
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de haskell/lsp

Todos los issues de haskell/lsp

Issues similares

Más issues de Haskell

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.