-
Notifications
You must be signed in to change notification settings - Fork 930
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a new field into `xsbti.Problem` allowing for the compiler to forward "actions" that can address diagnostics. The idea largely mimics a very minimal `CodeAction` that can be found in the [LSP Spec](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeAction) in order to ensure it will work with a variety of difference clients that use LSP, and those that don't. In the future the `WorkspaceEdit` that was created here could also be expanded to handle more advanced changes, aka resource operations, like creating/moving/deleting files. For now we only focus on a small subset of these features.
- Loading branch information
Showing
5 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* sbt | ||
* Copyright 2011 - 2018, Lightbend, Inc. | ||
* Copyright 2008 - 2010, Mark Harrah | ||
* Licensed under Apache License 2.0 (see LICENSE) | ||
*/ | ||
|
||
package xsbti; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* An Action is very miminal representation of a `CodeAction` in the LSP protocol. | ||
* | ||
* <p>However it only focuses on the actual title, description, and edit, leaving it up to the | ||
* language server to communicate with the client and put together a proper codeAction in accordance | ||
* to client capabilities. | ||
* | ||
* @see <a href= | ||
* "https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeAction">`CodeAction`</a> | ||
*/ | ||
public interface Action { | ||
|
||
/** Title of the action that will be shown to the user client side. */ | ||
String title(); | ||
|
||
/** Optional description that may be shown to the user client side to explain the action. */ | ||
Optional<String> description(); | ||
|
||
/** The actual edit contained in the action. */ | ||
WorkspaceEdit edit(); | ||
} |
21 changes: 21 additions & 0 deletions
21
internal/util-interface/src/main/java/xsbti/FileChanges.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* sbt | ||
* Copyright 2011 - 2018, Lightbend, Inc. | ||
* Copyright 2008 - 2010, Mark Harrah | ||
* Licensed under Apache License 2.0 (see LICENSE) | ||
*/ | ||
|
||
package xsbti; | ||
|
||
import java.net.URI; | ||
import java.util.List; | ||
|
||
/** A collection of TextEdits that belong to a given URI. */ | ||
public interface FileChanges { | ||
|
||
/** The URI that the edits belong to. */ | ||
URI uri(); | ||
|
||
/** The edits belonging to the URI. */ | ||
List<TextEdit> edits(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* sbt | ||
* Copyright 2011 - 2018, Lightbend, Inc. | ||
* Copyright 2008 - 2010, Mark Harrah | ||
* Licensed under Apache License 2.0 (see LICENSE) | ||
*/ | ||
|
||
package xsbti; | ||
|
||
/** | ||
* A representation of the `TextEdit` found in the LSP protocol. | ||
* | ||
* <p>NOTE: That instead of a `Range` we use the internal [[xsbti.Position]]. | ||
* | ||
* @see <a | ||
* href="https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textEdit">`TextEdit`</a> | ||
*/ | ||
public interface TextEdit { | ||
|
||
/** The position this edit will be applied to. */ | ||
Position position(); | ||
|
||
/** The next text that will be inserted into the given [[TextEdit.position]]. */ | ||
String newText(); | ||
} |
27 changes: 27 additions & 0 deletions
27
internal/util-interface/src/main/java/xsbti/WorkspaceEdit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* sbt | ||
* Copyright 2011 - 2018, Lightbend, Inc. | ||
* Copyright 2008 - 2010, Mark Harrah | ||
* Licensed under Apache License 2.0 (see LICENSE) | ||
*/ | ||
|
||
package xsbti; | ||
|
||
import java.net.URI; | ||
import java.util.List; | ||
|
||
/** | ||
* A minimal representatin of the `WorkspaceEdit` found in the LSP protocol. | ||
* | ||
* <p>However it only supports the minimal `changes` to ensure the fixes will work with all clients. | ||
* | ||
* <p>NOTE: In the future this may be expanded to handle resource operations via `documentChanges`. | ||
* | ||
* @see <a href= | ||
* "https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspaceEdit">`WorkspaceEdit`</a> | ||
*/ | ||
public interface WorkspaceEdit { | ||
|
||
/** List of [[xsbti.FileChanges]] that belong to this WorkspaceEdit. */ | ||
List<FileChanges> changes(); | ||
} |