Skip to content

Commit

Permalink
refactor: Remove decoration protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Dec 5, 2024
1 parent 3aea43d commit fb1cc3d
Show file tree
Hide file tree
Showing 26 changed files with 29 additions and 854 deletions.
7 changes: 2 additions & 5 deletions architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,11 @@ Metals communicates with build server such as `bloop` and `sbt` using [Build Ser

For more details about sbt's BSP support in Metals, see [the blog post](https://scalameta.org/metals/blog/2020/11/06/sbt-BSP-support/).

## Worksheet
## Worksheets

Worksheet support is provided by [mdoc](https://github.com/scalameta/mdoc), which is able to typecheck and evaluate each line of the input. The main class responsible for worksheets is [WorksheetProvider.scala](https://github.com/scalameta/metals/blob/main/metals/src/main/scala/scala/meta/internal/worksheets/WorksheetProvider.scala). It is responsible for downloading mdoc instance for each Scala version that is supported and running the evaluation in the file input.

Later the evaluations are published using [decoration extension](https://scalameta.org/metals/docs/integrations/decoration-protocol) or via additional Text Edits for editors that do not support decorations. This is done in the two classes implementing [WorksheetPublisher.scala](https://github.com/scalameta/metals/blob/main/metals/src/main/scala/scala/meta/internal/worksheets/WorksheetPublisher.scala):

- [DecorationWorksheetPublisher.scala](https://github.com/scalameta/metals/blob/main/metals/src/main/scala/scala/meta/internal/worksheets/DecorationWorksheetPublisher.scala) for decoration publishing
- [WorkspaceEditWorksheetPublisher.scala](https://github.com/scalameta/metals/blob/main/metals/src/main/scala/scala/meta/internal/worksheets/WorkspaceEditWorksheetPublisher.scala) for publishing decorations as comments in the code
Later the evaluations are published using [inlay hints](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_inlayHint).

## Formatting

Expand Down
11 changes: 1 addition & 10 deletions docs/editors/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,7 @@ projects.

## Worksheets

****: Worksheets work via the Decoration protocol and are added as a
non-editable side decoration.

**Comments**: Worksheets work via `workspace/applyEdit` by adding comments to
the source code and support hover to show larger output. You can find more
information about worksheets under the editor specific worksheet section. For
example, [here for VS Code](vscode.md#worksheets).
****: Worksheets work via inlay hints.

By default there is a 30 second timeout on worksheet evaluation, this setting can be overridden by `-Dmetals.worksheet-timeout=<number of seconds>` server property.

Expand Down Expand Up @@ -448,9 +442,6 @@ website.

**Status bar**: Editor client implements the `metals/status` notification.

**Decoration protocol**: Editor client implements the
[Decoration Protocol](../integrations/decoration-protocol.md).

**Tree view**: Editor client implements the
[Tree View Protocol](../integrations/tree-view-protocol.md).

Expand Down
130 changes: 0 additions & 130 deletions docs/integrations/decoration-protocol.md

This file was deleted.

21 changes: 0 additions & 21 deletions docs/integrations/new-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ The currently available settings for `InitializationOptions` are listed below.
snippetAutoIndent?: boolean;
}
debuggingProvider?: boolean;
decorationProvider?: boolean;
inlineDecorationProvider?: boolean;
didFocusProvider?: boolean;
doctorProvider?: "json" | "html";
executeClientCommandProvider?: boolean;
Expand Down Expand Up @@ -230,13 +228,6 @@ Boolean value to signify that the client supports the

Default value: `false`

##### `decorationProvider`

Boolean value to signify that the client supports the
[Decoration Protocol](../integrations/decoration-protocol.md).

Default value: `false`

##### `didFocusProvider`

Boolean value to signify that the client supports the
Expand Down Expand Up @@ -289,13 +280,6 @@ Possible values:
For example, `C:\Users\IEUser\workspace\project/*.{scala,sbt,properties}`.
This mode is used by the VS Code client.

##### `inlineDecorationProvider`

If the client implements the Metals Decoration Protocol **and** supports
decorations to be shown inline and not only at the end of a line.

Default: `false`

##### `icons`

Possible values:
Expand Down Expand Up @@ -696,11 +680,6 @@ Metals implements several custom JSON-RPC endpoints related to rendering tree
views in the editor client, the
[Tree View Protocol](../integrations/tree-view-protocol.md).

### Decoration Protocol

Metals implements an LSP extension to display non-editable text in the editor,
see the [Decoration Protocol](../integrations/decoration-protocol.md).

### `metals/status`

The Metals status notification is sent from the server to the client to notify
Expand Down
4 changes: 2 additions & 2 deletions metals-docs/src/main/scala/docs/WorksheetModifier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class WorksheetModifier extends StringModifier {

val (howYouSeeEvaluations, howToHover) = info match {
case "vscode" =>
"as a decoration at the end of the line." ->
"hover on the decoration to expand the decoration."
"as a inlay hint at the end of the line." ->
"hover on the inlay hint to expand it."
case _ =>
"as a comment as the end of the line." -> "hover on the comment to expand."
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,6 @@ final class ClientConfiguration(
def isRunProvider(): Boolean =
initializationOptions.runProvider.getOrElse(false)

def isDecorationProvider(): Boolean =
extract(
initializationOptions.decorationProvider,
experimentalCapabilities.decorationProvider,
false,
)

def isInlineDecorationProvider(): Boolean =
initializationOptions.inlineDecorationProvider.getOrElse(false)

def isInlayHintsEnabled(): Boolean = {
for {
capabilities <- clientCapabilities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.eclipse.{lsp4j => l}
*/
final case class ClientExperimentalCapabilities(
debuggingProvider: Option[Boolean],
@deprecated("Decoration protocol is no longer used.")
decorationProvider: Option[Boolean],
didFocusProvider: Option[Boolean],
doctorProvider: Option[String],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ final case class InitializationOptions(
compilerOptions: CompilerInitializationOptions,
debuggingProvider: Option[Boolean],
runProvider: Option[Boolean],
@deprecated("Decoration protocol is no longer used.")
decorationProvider: Option[Boolean],
@deprecated("Decoration protocol is no longer used.")
inlineDecorationProvider: Option[Boolean],
didFocusProvider: Option[Boolean],
doctorProvider: Option[String],
Expand Down
Loading

0 comments on commit fb1cc3d

Please sign in to comment.