Merge pull request #4270 from eed3si9n/wip/parser

Fix bimcompat breakages in complete
This commit is contained in:
eugene yokota 2018-07-15 23:26:52 -04:00 committed by GitHub
commit 43607b0c40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 3 deletions

View File

@ -192,7 +192,9 @@ val completeProj = (project in file("internal") / "util-complete")
name := "Completion",
libraryDependencies += jline,
mimaSettings,
mimaBinaryIssueFilters ++= Seq(
// Parser is used publicly, so we can't break bincompat.
mimaBinaryIssueFilters := Seq(
exclude[DirectMissingMethodProblem]("sbt.internal.util.complete.History.this"),
),
)
.configure(addSbtIO, addSbtUtilControl)

View File

@ -24,10 +24,12 @@ object EditDistance {
insertCost: Int = 1,
deleteCost: Int = 1,
subCost: Int = 1,
transposeCost: Int = 1,
matchCost: Int = 0,
caseCost: Int = 1,
transpositions: Boolean = false
): Int = {
val _ = transposeCost
val n = s.length
val m = t.length
if (n == 0) return m

View File

@ -48,6 +48,8 @@ final class History private (val lines: IndexedSeq[String], val path: Option[Fil
}
object History {
def apply(lines: Seq[String], path: Option[File], error: String => Unit): History =
new History(lines.toIndexedSeq, path)
def apply(lines: Seq[String], path: Option[File]): History =
new History(lines.toIndexedSeq, path)

View File

@ -387,7 +387,13 @@ trait ParserMain {
}
/** Presents a Char range as a Parser. A single Char is parsed only if it is in the given range.*/
implicit def range(r: collection.immutable.NumericRange[Char], label: String): Parser[Char] =
implicit def range(r: collection.immutable.NumericRange[Char]): Parser[Char] = {
val label = r.map(_.toString).toString
range(r, label)
}
/** Presents a Char range as a Parser. A single Char is parsed only if it is in the given range.*/
def range(r: collection.immutable.NumericRange[Char], label: String): Parser[Char] =
charClass(r contains _, label).examples(r.map(_.toString): _*)
/** Defines a Parser that parses a single character only if it is contained in `legal`.*/
@ -400,7 +406,7 @@ trait ParserMain {
* Defines a Parser that parses a single character only if the predicate `f` returns true for that character.
* If this parser fails, `label` is used as the failure message.
*/
def charClass(f: Char => Boolean, label: String): Parser[Char] =
def charClass(f: Char => Boolean, label: String = "<unspecified>"): Parser[Char] =
new CharacterClass(f, label)
/** Presents a single Char `ch` as a Parser that only parses that exact character. */