mirror of https://github.com/sbt/sbt.git
Adds backticks to class/trait/object name.
Adapts tests to changed specs2 dependency. Tiny fixes. Removes Scala IDE compiler clues.
This commit is contained in:
parent
73b0034cfc
commit
452e97e41d
|
|
@ -132,7 +132,6 @@ object Defaults extends BuildCommon {
|
|||
Seq(
|
||||
managedDirectory := baseDirectory.value / "lib_managed"
|
||||
))
|
||||
import Keys.test
|
||||
private[sbt] lazy val globalCore: Seq[Setting[_]] = globalDefaults(
|
||||
defaultTestTasks(test) ++ defaultTestTasks(testOnly) ++ defaultTestTasks(testQuick) ++ Seq(
|
||||
excludeFilter :== HiddenFileFilter
|
||||
|
|
@ -645,7 +644,6 @@ object Defaults extends BuildCommon {
|
|||
testResultLogger :== TestResultLogger.Default,
|
||||
testFilter in testOnly :== (selectedFilter _)
|
||||
))
|
||||
import Configurations.Test
|
||||
lazy val testTasks
|
||||
: Seq[Setting[_]] = testTaskOptions(test) ++ testTaskOptions(testOnly) ++ testTaskOptions(
|
||||
testQuick) ++ testDefaults ++ Seq(
|
||||
|
|
@ -1035,7 +1033,6 @@ object Defaults extends BuildCommon {
|
|||
art.value)).asFile
|
||||
}
|
||||
|
||||
import Configurations._
|
||||
def artifactSetting: Initialize[Artifact] =
|
||||
Def.setting {
|
||||
val a = artifact.value
|
||||
|
|
@ -1394,7 +1391,6 @@ object Defaults extends BuildCommon {
|
|||
}
|
||||
analysisResult.analysis
|
||||
}
|
||||
|
||||
def compileIncrementalTask = Def.task {
|
||||
// TODO - Should readAnalysis + saveAnalysis be scoped by the compile task too?
|
||||
compileIncrementalTaskImpl(streams.value, (compileInputs in compile).value)
|
||||
|
|
@ -1679,7 +1675,6 @@ object Classpaths {
|
|||
}
|
||||
|
||||
def defaultPackageKeys = Seq(packageBin, packageSrc, packageDoc)
|
||||
import Configurations.Test
|
||||
lazy val defaultPackages: Seq[TaskKey[File]] =
|
||||
for (task <- defaultPackageKeys; conf <- Seq(Compile, Test)) yield (task in conf)
|
||||
lazy val defaultArtifactTasks: Seq[TaskKey[File]] = makePom +: defaultPackages
|
||||
|
|
@ -1713,7 +1708,6 @@ object Classpaths {
|
|||
pkgTasks: Seq[TaskKey[_]]): Initialize[Seq[T]] =
|
||||
pkgTasks.map(pkg => key in pkg.scope in pkg).join
|
||||
|
||||
import Configurations.Test
|
||||
private[this] def publishGlobalDefaults =
|
||||
Defaults.globalDefaults(
|
||||
Seq(
|
||||
|
|
@ -3207,7 +3201,6 @@ trait BuildExtra extends BuildCommon with DefExtra {
|
|||
* Disables post-compilation hook for determining tests for tab-completion (such as for 'test-only').
|
||||
* This is useful for reducing test:compile time when not running test.
|
||||
*/
|
||||
import Configurations.Test
|
||||
def noTestCompletion(config: Configuration = Test): Setting[_] =
|
||||
inConfig(config)(Seq(definedTests := detectTests.value)).head
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import scala.util.matching.Regex.MatchIterator
|
|||
import java.nio.file.{ Files, Paths }
|
||||
import sbt.StandardMain
|
||||
|
||||
object Definition {
|
||||
private[sbt] object Definition {
|
||||
import java.net.URI
|
||||
import Keys._
|
||||
import sbt.internal.inc.Analysis
|
||||
|
|
@ -55,8 +55,33 @@ object Definition {
|
|||
}
|
||||
}
|
||||
|
||||
def identifier(line: String, point: Int): Option[String] = {
|
||||
val whiteSpaceReg = "\\s+".r
|
||||
private def findInBackticks(line: String, point: Int): Option[String] = {
|
||||
val (even, odd) = line.zipWithIndex
|
||||
.collect {
|
||||
case (char, backtickIndex) if char == '`' =>
|
||||
backtickIndex
|
||||
}
|
||||
.zipWithIndex
|
||||
.partition { bs =>
|
||||
val (_, index) = bs
|
||||
index % 2 == 0
|
||||
}
|
||||
even
|
||||
.collect {
|
||||
case (backtickIndex, _) => backtickIndex
|
||||
}
|
||||
.zip {
|
||||
odd.collect {
|
||||
case (backtickIndex, _) => backtickIndex + 1
|
||||
}
|
||||
}
|
||||
.collectFirst {
|
||||
case (from, to) if from <= point && point < to => line.slice(from, to)
|
||||
}
|
||||
}
|
||||
|
||||
def identifier(line: String, point: Int): Option[String] = findInBackticks(line, point).orElse {
|
||||
val whiteSpaceReg = "(\\s|\\.)+".r
|
||||
val (zero, end) = fold(Seq.empty)(whiteSpaceReg.findAllIn(line))
|
||||
.collect {
|
||||
case (white, ind) => (ind, ind + white.length)
|
||||
|
|
@ -94,7 +119,10 @@ object Definition {
|
|||
Seq(s".$sym", s".$sym$$", s"$$$sym", s"$$$sym$$")
|
||||
def potentialClsOrTraitOrObj(sym: String): PartialFunction[String, String] = {
|
||||
import scala.reflect.NameTransformer
|
||||
val encodedSym = NameTransformer.encode(sym)
|
||||
val encodedSym = NameTransformer.encode(sym.toSeq match {
|
||||
case '`' +: body :+ '`' => body.mkString
|
||||
case noBackticked => noBackticked.mkString
|
||||
})
|
||||
val action: PartialFunction[String, String] = {
|
||||
case potentialClassOrTraitOrObject
|
||||
if asClassObjectIdentifier(encodedSym).exists(potentialClassOrTraitOrObject.endsWith) ||
|
||||
|
|
@ -114,9 +142,9 @@ object Definition {
|
|||
def classTraitObjectInLine(sym: String)(line: String): Seq[(String, Int)] = {
|
||||
import scala.util.matching.Regex.quote
|
||||
val potentials =
|
||||
Seq(s"object +${quote(sym)}".r,
|
||||
s"trait +${quote(sym)} *\\[?".r,
|
||||
s"class +${quote(sym)} *\\[?".r)
|
||||
Seq(s"object\\s+${quote(sym)}".r,
|
||||
s"trait\\s+${quote(sym)} *\\[?".r,
|
||||
s"class\\s+${quote(sym)} *\\[?".r)
|
||||
potentials
|
||||
.flatMap { reg =>
|
||||
fold(Seq.empty)(reg.findAllIn(line))
|
||||
|
|
|
|||
|
|
@ -127,61 +127,51 @@ class DefinitionTest extends org.specs2.mutable.Specification {
|
|||
}
|
||||
}
|
||||
"definition" should {
|
||||
import scalacache.caffeine._
|
||||
import scalacache.modes.sync._
|
||||
"cache data in cache" in {
|
||||
import scalacache.caffeine._
|
||||
val cache = CaffeineCache[Any]
|
||||
val cacheFile = "Test.scala"
|
||||
val useBinary = true
|
||||
|
||||
import scalacache.modes.scalaFuture._
|
||||
val actual = Definition
|
||||
.updateCache(cache)(cacheFile, useBinary)
|
||||
.flatMap(_ => cache.get(Definition.AnalysesKey))
|
||||
Definition.updateCache(cache)(cacheFile, useBinary)
|
||||
|
||||
val actual = cache.get(Definition.AnalysesKey)
|
||||
|
||||
actual.collect {
|
||||
case Some(s) => s.asInstanceOf[Set[((String, Boolean), Option[Analysis])]]
|
||||
} should contain[((String, Boolean), Option[Analysis])]("Test.scala" -> true -> None).await
|
||||
case s => s.asInstanceOf[Set[((String, Boolean), Option[Analysis])]]
|
||||
}.get should contain("Test.scala" -> true -> None)
|
||||
}
|
||||
"replace cache data in cache" in {
|
||||
import scalacache.caffeine._
|
||||
val cache = CaffeineCache[Any]
|
||||
val cacheFile = "Test.scala"
|
||||
val useBinary = true
|
||||
val falseUseBinary = false
|
||||
|
||||
import scalacache.modes.scalaFuture._
|
||||
val actual = Definition
|
||||
.updateCache(cache)(cacheFile, falseUseBinary)
|
||||
.flatMap { _ =>
|
||||
Definition.updateCache(cache)(cacheFile, useBinary)
|
||||
}
|
||||
.flatMap(_ => cache.get(Definition.AnalysesKey))
|
||||
Definition.updateCache(cache)(cacheFile, falseUseBinary)
|
||||
Definition.updateCache(cache)(cacheFile, useBinary)
|
||||
|
||||
val actual = cache.get(Definition.AnalysesKey)
|
||||
|
||||
actual.collect {
|
||||
case Some(s) => s.asInstanceOf[Set[((String, Boolean), Option[Analysis])]]
|
||||
} should contain[((String, Boolean), Option[Analysis])]("Test.scala" -> true -> None).await
|
||||
case s => s.asInstanceOf[Set[((String, Boolean), Option[Analysis])]]
|
||||
}.get should contain("Test.scala" -> true -> None)
|
||||
}
|
||||
"cache more data in cache" in {
|
||||
import scalacache.caffeine._
|
||||
val cache = CaffeineCache[Any]
|
||||
val cacheFile = "Test.scala"
|
||||
val useBinary = true
|
||||
val otherCacheFile = "OtherTest.scala"
|
||||
val otherUseBinary = false
|
||||
|
||||
import scalacache.modes.scalaFuture._
|
||||
val actual = Definition
|
||||
.updateCache(cache)(otherCacheFile, otherUseBinary)
|
||||
.flatMap { _ =>
|
||||
Definition.updateCache(cache)(cacheFile, useBinary)
|
||||
}
|
||||
.flatMap(_ => cache.get(Definition.AnalysesKey))
|
||||
Definition.updateCache(cache)(otherCacheFile, otherUseBinary)
|
||||
Definition.updateCache(cache)(cacheFile, useBinary)
|
||||
|
||||
val actual = cache.get(Definition.AnalysesKey)
|
||||
|
||||
actual.collect {
|
||||
case Some(s) => s.asInstanceOf[Set[((String, Boolean), Option[Analysis])]]
|
||||
} should contain[((String, Boolean), Option[Analysis])](
|
||||
"Test.scala" -> true -> None,
|
||||
"OtherTest.scala" -> false -> None).await
|
||||
case s => s.asInstanceOf[Set[((String, Boolean), Option[Analysis])]]
|
||||
}.get should contain("Test.scala" -> true -> None, "OtherTest.scala" -> false -> None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,11 +161,11 @@ object SettingQueryTest extends org.specs2.mutable.Specification {
|
|||
|
||||
val settings: Seq[Setting[_]] = finalTransforms(
|
||||
buildConfigurations(loadedBuild, getRootProject(units), config.injectSettings))
|
||||
val delegates = defaultDelegates(loadedBuild)
|
||||
val delegates: Scope => Seq[Scope] = defaultDelegates(loadedBuild)
|
||||
val scopeLocal: ScopeLocal = EvaluateTask.injectStreams
|
||||
val display: Show[ScopedKey[_]] = Project showLoadingKey loadedBuild
|
||||
|
||||
val data = Def.make(settings)(delegates, scopeLocal, display)
|
||||
val data: Settings[Scope] = Def.make(settings)(delegates, scopeLocal, display)
|
||||
val extra: KeyIndex => BuildUtil[_] = index => BuildUtil(baseUri, units, index, data)
|
||||
|
||||
val index: StructureIndex = structureIndex(data, settings, extra, units)
|
||||
|
|
|
|||
Loading…
Reference in New Issue