-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit deprecation warnings when referencing a rewrite by old name.
This change allows rewrites to change their names without breaking compatibility. Users using the old name will receive deprecation warnings and have opportunity to switch to the new name.
- Loading branch information
Showing
11 changed files
with
64 additions
and
24 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
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
24 changes: 24 additions & 0 deletions
24
scalafix-core/shared/src/main/scala/scalafix/internal/config/LazySemanticCtx.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,24 @@ | ||
package scalafix.internal.config | ||
|
||
import scalafix.SemanticCtx | ||
|
||
// The challenge when loading a rewrite is that 1) if it's semantic it needs a | ||
// semanticCtx constructor argument and 2) we don't know upfront if it's semantic. | ||
// For example, to know if a classloaded rewrites is semantic or syntactic | ||
// we have to test against it's Class[_]. For default rewrites, the interface | ||
// to detect if a rewrite is semantic is different. | ||
// LazySemanticCtx allows us to delay the computation of a semanticCtx right up until | ||
// the moment we instantiate the rewrite. | ||
//type LazySemanticCtx = RewriteKind => Option[SemanticCtx] | ||
class LazySemanticCtx( | ||
f: RewriteKind => Option[SemanticCtx], | ||
val reporter: ScalafixReporter) | ||
extends Function[RewriteKind, Option[SemanticCtx]] { | ||
override def apply(v1: RewriteKind): Option[SemanticCtx] = f(v1) | ||
} | ||
|
||
object LazySemanticCtx { | ||
lazy val empty = new LazySemanticCtx(_ => None, ScalafixReporter.default) | ||
def apply(f: RewriteKind => Option[SemanticCtx]): LazySemanticCtx = | ||
new LazySemanticCtx(f, ScalafixReporter.default) | ||
} |
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
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
4 changes: 4 additions & 0 deletions
4
scalafix-core/shared/src/main/scala/scalafix/util/Deprecated.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,4 @@ | ||
package scalafix.util | ||
|
||
/** Identical to scala.deprecated except it's a case class. */ | ||
final case class Deprecated(message: String, since: String) |
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