-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add textEdits method to ScalafixPatch
Add textEdits method to ScalafixPatch as an alternative way of obtaining the results of a Scalafix evaluation. The results of applying a patch are exposed as a set of LSP style 'text edits', which consists of a start position, end position, and insert text.
- Loading branch information
1 parent
f6b8c84
commit 285a014
Showing
6 changed files
with
106 additions
and
3 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
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
9 changes: 9 additions & 0 deletions
9
scalafix-cli/src/main/scala/scalafix/internal/interfaces/ScalafixTextEditImpl.scala
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,9 @@ | ||
package scalafix.internal.interfaces | ||
|
||
import scalafix.interfaces.ScalafixPosition | ||
import scalafix.interfaces.ScalafixTextEdit | ||
|
||
final case class ScalafixTextEditImpl( | ||
position: ScalafixPosition, | ||
newText: String | ||
) extends ScalafixTextEdit |
10 changes: 9 additions & 1 deletion
10
scalafix-interfaces/src/main/java/scalafix/interfaces/ScalafixPatch.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 |
---|---|---|
@@ -1,3 +1,11 @@ | ||
package scalafix.interfaces; | ||
|
||
public interface ScalafixPatch {} | ||
public interface ScalafixPatch { | ||
/** | ||
* | ||
* @return This patch as an array of text edits. | ||
*/ | ||
default ScalafixTextEdit[] textEdits() { | ||
throw new UnsupportedOperationException("textEdits() is not implemented"); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
scalafix-interfaces/src/main/java/scalafix/interfaces/ScalafixTextEdit.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,7 @@ | ||
package scalafix.interfaces; | ||
|
||
public interface ScalafixTextEdit { | ||
ScalafixPosition position(); | ||
|
||
String newText(); | ||
} |
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