Merge pull request #5417 from eed3si9n/wip/machine_vf

integrate with VirtualFile changes
This commit is contained in:
eugene yokota 2020-04-24 19:30:11 -04:00 committed by GitHub
commit 924d8e75cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
164 changed files with 559 additions and 409 deletions

1
.gitattributes vendored
View File

@ -1,3 +1,4 @@
# Exclude contraband generated files from diff (by default - you can see it if you want) # Exclude contraband generated files from diff (by default - you can see it if you want)
**/contraband-scala/**/* -diff merge=ours **/contraband-scala/**/* -diff merge=ours
**/contraband-scala/**/* linguist-generated=true **/contraband-scala/**/* linguist-generated=true
**/contraband-scala/**/* diff

View File

@ -828,6 +828,11 @@ lazy val zincLmIntegrationProj = (project in file("zinc-lm-integration"))
testOptions in Test += testOptions in Test +=
Tests.Argument(TestFrameworks.ScalaTest, s"-Dsbt.zinc.version=$zincVersion"), Tests.Argument(TestFrameworks.ScalaTest, s"-Dsbt.zinc.version=$zincVersion"),
mimaSettingsSince(sbt13Plus), mimaSettingsSince(sbt13Plus),
mimaBinaryIssueFilters ++= Seq(
exclude[IncompatibleMethTypeProblem]("sbt.internal.inc.ZincComponentCompiler*"),
exclude[IncompatibleSignatureProblem]("sbt.internal.inc.ZincComponentCompiler*"),
exclude[IncompatibleSignatureProblem]("sbt.internal.inc.ZincLMHelper.update"),
),
libraryDependencies += launcherInterface, libraryDependencies += launcherInterface,
) )
.configure(addSbtZincCompileCore, addSbtLmCore, addSbtLmIvyTest) .configure(addSbtZincCompileCore, addSbtLmCore, addSbtLmIvyTest)
@ -936,7 +941,8 @@ lazy val mainProj = (project in file("main"))
// signature, this does not break compatibility regardless of what // signature, this does not break compatibility regardless of what
// cast a compiler might have inserted based on the old signature // cast a compiler might have inserted based on the old signature
// since we're returning the same values as before. // since we're returning the same values as before.
exclude[IncompatibleSignatureProblem]("sbt.Classpaths.mkIvyConfiguration") exclude[IncompatibleSignatureProblem]("sbt.Classpaths.mkIvyConfiguration"),
exclude[IncompatibleMethTypeProblem]("sbt.internal.server.Definition*"),
) )
) )
.configure( .configure(

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -8,7 +8,7 @@
package sbt package sbt
import java.io.File import java.io.File
import sbt.internal.inc.AnalyzingCompiler import sbt.internal.inc.{ AnalyzingCompiler, PlainVirtualFile }
import sbt.internal.util.JLine import sbt.internal.util.JLine
import sbt.util.Logger import sbt.util.Logger
import xsbti.compile.{ Inputs, Compilers } import xsbti.compile.{ Inputs, Compilers }
@ -45,7 +45,12 @@ final class Console(compiler: AnalyzingCompiler) {
cleanupCommands: String cleanupCommands: String
)(loader: Option[ClassLoader], bindings: Seq[(String, Any)])(implicit log: Logger): Try[Unit] = { )(loader: Option[ClassLoader], bindings: Seq[(String, Any)])(implicit log: Logger): Try[Unit] = {
def console0() = def console0() =
compiler.console(classpath, options, initialCommands, cleanupCommands, log)(loader, bindings) compiler.console(classpath map { x =>
PlainVirtualFile(x.toPath)
}, options, initialCommands, cleanupCommands, log)(
loader,
bindings
)
JLine.usingTerminal { t => JLine.usingTerminal { t =>
t.init t.init
Run.executeTrapExit(console0, log) Run.executeTrapExit(console0, log)

View File

@ -8,15 +8,13 @@
package sbt package sbt
import java.io.File import java.io.File
import sbt.internal.inc.AnalyzingCompiler import sbt.internal.inc.{ AnalyzingCompiler, PlainVirtualFile }
import sbt.internal.util.ManagedLogger
import sbt.util.CacheStoreFactory import sbt.util.CacheStoreFactory
import sbt.util.Logger
import xsbti.Reporter import xsbti.Reporter
import xsbti.compile.JavaTools import xsbti.compile.JavaTools
import sbt.util.Logger
import sbt.internal.util.ManagedLogger
object Doc { object Doc {
import RawCompileLike._ import RawCompileLike._
@ -36,7 +34,23 @@ object Doc {
cached( cached(
cacheStoreFactory, cacheStoreFactory,
fileInputOptions, fileInputOptions,
prepare(label + " Scala API documentation", compiler.doc) prepare(
label + " Scala API documentation",
(sources, classpath, outputDirectory, options, maxErrors, log) => {
compiler.doc(
sources map { x =>
PlainVirtualFile(x.toPath)
},
classpath map { x =>
PlainVirtualFile(x.toPath)
},
outputDirectory.toPath,
options,
maxErrors,
log
)
}
)
) )
@deprecated("Going away", "1.1.1") @deprecated("Going away", "1.1.1")

View File

@ -9,50 +9,22 @@ package sbt
import java.io.File import java.io.File
import sbt.internal.inc.Relations import sbt.internal.inc.Relations
import sbt.internal.util.Relation import sbt.internal.util.Relation
import sbt.io.IO import sbt.io.IO
object DotGraph { object DotGraph {
private def fToString(roots: Iterable[File]): (File => String) = @deprecated("not used", "1.4.0")
(x: File) => sourceToString(roots, x) def sources(relations: Relations, outputDirectory: File, sourceRoots: Iterable[File]): Unit = ???
def sources(relations: Relations, outputDirectory: File, sourceRoots: Iterable[File]): Unit = { @deprecated("not used", "1.4.0")
val toString = fToString(sourceRoots) def packages(relations: Relations, outputDirectory: File, sourceRoots: Iterable[File]): Unit = ???
apply(relations, outputDirectory, toString, toString) @deprecated("not used", "1.4.0")
}
def packages(relations: Relations, outputDirectory: File, sourceRoots: Iterable[File]): Unit = {
val packageOnly = (path: String) => {
val last = path.lastIndexOf(File.separatorChar.toInt)
val packagePath = (if (last > 0) path.substring(0, last) else path).trim
if (packagePath.isEmpty) "" else packagePath.replace(File.separatorChar, '.')
}
val toString = packageOnly compose fToString(sourceRoots)
apply(relations, outputDirectory, toString, toString)
}
def apply( def apply(
relations: Relations, relations: Relations,
outputDir: File, outputDir: File,
sourceToString: File => String, sourceToString: File => String,
externalToString: File => String externalToString: File => String
): Unit = { ): Unit = ???
def file(name: String) = new File(outputDir, name)
IO.createDirectory(outputDir)
generateGraph(
file("int-class-deps"),
"dependencies",
relations.internalClassDep,
identity[String],
identity[String]
)
generateGraph(
file("binary-dependencies"),
"externalDependencies",
relations.libraryDep,
externalToString,
sourceToString
)
}
def generateGraph[K, V]( def generateGraph[K, V](
file: File, file: File,

View File

@ -9,22 +9,19 @@ package sbt
import scala.annotation.tailrec import scala.annotation.tailrec
import java.io.File import java.io.File
import sbt.internal.inc.{ RawCompiler, ScalaInstance }
import sbt.io.syntax._ import sbt.io.syntax._
import sbt.io.IO import sbt.io.IO
import sbt.internal.inc.{ PlainVirtualFile, RawCompiler, ScalaInstance }
import sbt.internal.util.Types.:+: import sbt.internal.util.Types.:+:
import sbt.internal.util.HListFormats._ import sbt.internal.util.HListFormats._
import sbt.internal.util.HNil
import sbt.internal.util.HListFormats._
import sbt.util.CacheImplicits._ import sbt.util.CacheImplicits._
import sbt.util.Tracked.inputChanged import sbt.util.Tracked.inputChanged
import sbt.util.{ CacheStoreFactory, FilesInfo, HashFileInfo, ModifiedFileInfo, PlainFileInfo } import sbt.util.{ CacheStoreFactory, FilesInfo, HashFileInfo, ModifiedFileInfo, PlainFileInfo }
import sbt.internal.util.HNil
import sbt.internal.util.HListFormats._
import sbt.util.FileInfo.{ exists, hash, lastModified } import sbt.util.FileInfo.{ exists, hash, lastModified }
import xsbti.compile.ClasspathOptions
import sbt.internal.util.ManagedLogger import sbt.internal.util.ManagedLogger
import xsbti.compile.ClasspathOptions
object RawCompileLike { object RawCompileLike {
type Gen = (Seq[File], Seq[File], File, Seq[String], Int, ManagedLogger) => Unit type Gen = (Seq[File], Seq[File], File, Seq[String], Int, ManagedLogger) => Unit
@ -91,7 +88,11 @@ object RawCompileLike {
def rawCompile(instance: ScalaInstance, cpOptions: ClasspathOptions): Gen = def rawCompile(instance: ScalaInstance, cpOptions: ClasspathOptions): Gen =
(sources, classpath, outputDirectory, options, _, log) => { (sources, classpath, outputDirectory, options, _, log) => {
val compiler = new RawCompiler(instance, cpOptions, log) val compiler = new RawCompiler(instance, cpOptions, log)
compiler(sources, classpath, outputDirectory, options) compiler(sources map { x =>
PlainVirtualFile(x.toPath)
}, classpath map { x =>
PlainVirtualFile(x.toPath)
}, outputDirectory.toPath, options)
} }
def compile( def compile(

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -7,6 +7,7 @@
package sbt package sbt
import java.nio.file.Paths
import sbt.util.Level import sbt.util.Level
import sbt.internal.util.{ AttributeKey, FullReader } import sbt.internal.util.{ AttributeKey, FullReader }
import sbt.internal.util.complete.{ import sbt.internal.util.complete.{
@ -20,7 +21,7 @@ import sbt.internal.util.complete.{
} }
import sbt.internal.util.Types.{ const, idFun } import sbt.internal.util.Types.{ const, idFun }
import sbt.internal.util.Util.{ AnyOps, nil, nilSeq, none } import sbt.internal.util.Util.{ AnyOps, nil, nilSeq, none }
import sbt.internal.inc.classpath.ClasspathUtilities.toLoader import sbt.internal.inc.classpath.ClasspathUtil.toLoader
import sbt.internal.inc.ModuleUtilities import sbt.internal.inc.ModuleUtilities
import sbt.internal.client.NetworkClient import sbt.internal.client.NetworkClient
import DefaultParsers._ import DefaultParsers._
@ -318,7 +319,7 @@ object BasicCommands {
def fromCpStr = if (cp.isEmpty) "" else s" from $cpStr" def fromCpStr = if (cp.isEmpty) "" else s" from $cpStr"
state.log info s"Applying State transformations $argsStr$fromCpStr" state.log info s"Applying State transformations $argsStr$fromCpStr"
val loader = val loader =
if (cp.isEmpty) parentLoader else toLoader(cp.map(f => new File(f)), parentLoader) if (cp.isEmpty) parentLoader else toLoader(cp.map(f => Paths.get(f)), parentLoader)
val loaded = val loaded =
args.map(arg => ModuleUtilities.getObject(arg, loader).asInstanceOf[State => State]) args.map(arg => ModuleUtilities.getObject(arg, loader).asInstanceOf[State => State])
loaded.foldLeft(state)((s, obj) => obj(s)) loaded.foldLeft(state)((s, obj) => obj(s))

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -9,6 +9,7 @@ package sbt
import java.io.{ File, PrintWriter } import java.io.{ File, PrintWriter }
import java.net.{ URI, URL, URLClassLoader } import java.net.{ URI, URL, URLClassLoader }
import java.nio.file.{ Path => NioPath, Paths }
import java.util.Optional import java.util.Optional
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -32,8 +33,8 @@ import sbt.internal.CommandStrings.ExportStream
import sbt.internal._ import sbt.internal._
import sbt.internal.classpath.AlternativeZincUtil import sbt.internal.classpath.AlternativeZincUtil
import sbt.internal.inc.JavaInterfaceUtil._ import sbt.internal.inc.JavaInterfaceUtil._
import sbt.internal.inc.classpath.{ ClassLoaderCache, ClasspathFilter } import sbt.internal.inc.classpath.{ ClassLoaderCache, ClasspathFilter, ClasspathUtil }
import sbt.internal.inc.{ ZincLmUtil, ZincUtil } import sbt.internal.inc.{ MappedFileConverter, PlainVirtualFile, Stamps, ZincLmUtil, ZincUtil }
import sbt.internal.io.{ Source, WatchState } import sbt.internal.io.{ Source, WatchState }
import sbt.internal.librarymanagement.mavenint.{ import sbt.internal.librarymanagement.mavenint.{
PomExtraDependencyAttributes, PomExtraDependencyAttributes,
@ -73,7 +74,7 @@ import sbt.nio.FileStamp.Formats.seqPathFileStampJsonFormatter
import sbt.nio.Keys._ import sbt.nio.Keys._
import sbt.nio.file.syntax._ import sbt.nio.file.syntax._
import sbt.nio.file.{ FileTreeView, Glob, RecursiveGlob } import sbt.nio.file.{ FileTreeView, Glob, RecursiveGlob }
import sbt.nio.{ FileChanges, Watch } import sbt.nio.Watch
import sbt.std.TaskExtra._ import sbt.std.TaskExtra._
import sbt.testing.{ AnnotatedFingerprint, Framework, Runner, SubclassFingerprint } import sbt.testing.{ AnnotatedFingerprint, Framework, Runner, SubclassFingerprint }
import sbt.util.CacheImplicits._ import sbt.util.CacheImplicits._
@ -81,8 +82,6 @@ import sbt.util.InterfaceUtil.{ toJavaFunction => f1 }
import sbt.util._ import sbt.util._
import sjsonnew._ import sjsonnew._
import sjsonnew.support.scalajson.unsafe.Converter import sjsonnew.support.scalajson.unsafe.Converter
import xsbti.CrossValue
import xsbti.compile.{ AnalysisContents, IncOptions, IncToolOptionsUtil }
import scala.collection.immutable.ListMap import scala.collection.immutable.ListMap
import scala.concurrent.duration.FiniteDuration import scala.concurrent.duration.FiniteDuration
@ -100,7 +99,9 @@ import sbt.internal.inc.{
MixedAnalyzingCompiler, MixedAnalyzingCompiler,
ScalaInstance ScalaInstance
} }
import xsbti.{ CrossValue, VirtualFile, VirtualFileRef }
import xsbti.compile.{ import xsbti.compile.{
AnalysisContents,
ClassFileManagerType, ClassFileManagerType,
ClasspathOptionsUtil, ClasspathOptionsUtil,
CompileAnalysis, CompileAnalysis,
@ -110,6 +111,8 @@ import xsbti.compile.{
CompilerCache, CompilerCache,
Compilers, Compilers,
DefinesClass, DefinesClass,
IncOptions,
IncToolOptionsUtil,
Inputs, Inputs,
MiniSetup, MiniSetup,
PerClasspathEntryLookup, PerClasspathEntryLookup,
@ -173,7 +176,33 @@ object Defaults extends BuildCommon {
apiMappings := Map.empty, apiMappings := Map.empty,
autoScalaLibrary :== true, autoScalaLibrary :== true,
managedScalaInstance :== true, managedScalaInstance :== true,
classpathEntryDefinesClass :== FileValueCache(Locate.definesClass _).get, classpathEntryDefinesClass := {
val converter = fileConverter.value
val f = FileValueCache({ x: NioPath =>
Locate.definesClass(converter.toVirtualFile(x))
}).get;
{ (x: File) =>
f(x.toPath)
}
},
allowMachinePath :== true,
rootPaths := {
val app = appConfiguration.value
val base = app.baseDirectory
val boot = app.provider.scalaProvider.launcher.bootDirectory
val ih = app.provider.scalaProvider.launcher.ivyHome
val coursierCache = csrCacheDirectory.value
val javaHome = Paths.get(sys.props("java.home"))
Vector(base.toPath, boot.toPath, coursierCache.toPath, ih.toPath, javaHome)
},
fileConverter := MappedFileConverter(rootPaths.value, allowMachinePath.value),
fullServerHandlers := {
(Vector(LanguageServerProtocol.handler(fileConverter.value))
++ serverHandlers.value
++ Vector(ServerHandler.fallback))
},
uncachedStamper := Stamps.uncachedStamps(fileConverter.value),
reusableStamper := Stamps.timeWrapLibraryStamps(uncachedStamper.value, fileConverter.value),
traceLevel in run :== 0, traceLevel in run :== 0,
traceLevel in runMain :== 0, traceLevel in runMain :== 0,
traceLevel in bgRun :== 0, traceLevel in bgRun :== 0,
@ -348,11 +377,7 @@ object Defaults extends BuildCommon {
else Set() else Set()
}, },
serverHandlers :== Nil, serverHandlers :== Nil,
fullServerHandlers := { fullServerHandlers := Nil,
(Vector(LanguageServerProtocol.handler)
++ serverHandlers.value
++ Vector(ServerHandler.fallback))
},
insideCI :== sys.env.contains("BUILD_NUMBER") || insideCI :== sys.env.contains("BUILD_NUMBER") ||
sys.env.contains("CI") || SysProp.ci, sys.env.contains("CI") || SysProp.ci,
// watch related settings // watch related settings
@ -576,7 +601,7 @@ object Defaults extends BuildCommon {
val compilers = ZincUtil.compilers( val compilers = ZincUtil.compilers(
instance = scalaInstance.value, instance = scalaInstance.value,
classpathOptions = classpathOptions.value, classpathOptions = classpathOptions.value,
javaHome = javaHome.value, javaHome = javaHome.value.map(_.toPath),
scalac scalac
) )
val classLoaderCache = state.value.classLoaderCache val classLoaderCache = state.value.classLoaderCache
@ -600,9 +625,12 @@ object Defaults extends BuildCommon {
) ++ configGlobal ++ defaultCompileSettings ++ compileAnalysisSettings ++ Seq( ) ++ configGlobal ++ defaultCompileSettings ++ compileAnalysisSettings ++ Seq(
compileOutputs := { compileOutputs := {
import scala.collection.JavaConverters._ import scala.collection.JavaConverters._
val c = fileConverter.value
val classFiles = val classFiles =
manipulateBytecode.value.analysis.readStamps.getAllProductStamps.keySet.asScala manipulateBytecode.value.analysis.readStamps.getAllProductStamps.keySet.asScala
classFiles.toSeq.map(_.toPath) :+ compileAnalysisFileTask.value.toPath (classFiles.toSeq map { x =>
c.toPath(x)
}) :+ compileAnalysisFileTask.value.toPath
}, },
compileOutputs := compileOutputs.triggeredBy(compile).value, compileOutputs := compileOutputs.triggeredBy(compile).value,
clean := (compileOutputs / clean).value, clean := (compileOutputs / clean).value,
@ -620,7 +648,11 @@ object Defaults extends BuildCommon {
else "" else ""
s"inc_compile$extra.zip" s"inc_compile$extra.zip"
}, },
/*
// Comment this out because Zinc now uses farm hash to invalidate the virtual paths.
// To use watch to detect initial changes, we need to revalidate using content hash.
externalHooks := { externalHooks := {
import sbt.nio.FileChanges
import sjsonnew.BasicJsonProtocol.mapFormat import sjsonnew.BasicJsonProtocol.mapFormat
val currentInputs = val currentInputs =
(unmanagedSources / inputFileStamps).value ++ (managedSourcePaths / outputFileStamps).value (unmanagedSources / inputFileStamps).value ++ (managedSourcePaths / outputFileStamps).value
@ -636,6 +668,8 @@ object Defaults extends BuildCommon {
.getOrElse(FileChanges.noPrevious(currentOutputs.map(_._1))) .getOrElse(FileChanges.noPrevious(currentOutputs.map(_._1)))
ExternalHooks.default.value(inputChanges, outputChanges, fileTreeView.value) ExternalHooks.default.value(inputChanges, outputChanges, fileTreeView.value)
}, },
*/
externalHooks := IncOptions.defaultExternal,
compileSourceFileInputs := { compileSourceFileInputs := {
import sjsonnew.BasicJsonProtocol.mapFormat import sjsonnew.BasicJsonProtocol.mapFormat
compile.value // ensures the inputFileStamps previous value is only set if compile succeeds. compile.value // ensures the inputFileStamps previous value is only set if compile succeeds.
@ -1656,6 +1690,7 @@ object Defaults extends BuildCommon {
val label = nameForSrc(configuration.value.name) val label = nameForSrc(configuration.value.name)
val fiOpts = fileInputOptions.value val fiOpts = fileInputOptions.value
val reporter = (compilerReporter in compile).value val reporter = (compilerReporter in compile).value
val converter = fileConverter.value
(hasScala, hasJava) match { (hasScala, hasJava) match {
case (true, _) => case (true, _) =>
val options = sOpts ++ Opts.doc.externalAPI(xapis) val options = sOpts ++ Opts.doc.externalAPI(xapis)
@ -1667,9 +1702,14 @@ object Defaults extends BuildCommon {
val javadoc = val javadoc =
sbt.inc.Doc.cachedJavadoc(label, s.cacheStoreFactory sub "java", cs.javaTools) sbt.inc.Doc.cachedJavadoc(label, s.cacheStoreFactory sub "java", cs.javaTools)
javadoc.run( javadoc.run(
srcs.toList, srcs.toList map { x =>
cp, converter.toVirtualFile(x.toPath)
out, },
cp.toList map { x =>
converter.toVirtualFile(x.toPath)
},
converter,
out.toPath,
javacOptions.value.toList, javacOptions.value.toList,
IncToolOptionsUtil.defaultIncToolOptions(), IncToolOptionsUtil.defaultIncToolOptions(),
s.log, s.log,
@ -1721,8 +1761,8 @@ object Defaults extends BuildCommon {
val s = streams.value val s = streams.value
val cpFiles = data((classpath in task).value) val cpFiles = data((classpath in task).value)
val fullcp = (cpFiles ++ si.allJars).distinct val fullcp = (cpFiles ++ si.allJars).distinct
val loader = sbt.internal.inc.classpath.ClasspathUtilities val tempDir = IO.createUniqueDirectory((taskTemporaryDirectory in task).value).toPath
.makeLoader(fullcp, si, IO.createUniqueDirectory((taskTemporaryDirectory in task).value)) val loader = ClasspathUtil.makeLoader(fullcp.map(_.toPath), si, tempDir)
val compiler = val compiler =
(compilers in task).value.scalac match { (compilers in task).value.scalac match {
case ac: AnalyzingCompiler => ac.onArgs(exported(s, "scala")) case ac: AnalyzingCompiler => ac.onArgs(exported(s, "scala"))
@ -1746,11 +1786,12 @@ object Defaults extends BuildCommon {
def compileTask: Initialize[Task[CompileAnalysis]] = Def.task { def compileTask: Initialize[Task[CompileAnalysis]] = Def.task {
val setup: Setup = compileIncSetup.value val setup: Setup = compileIncSetup.value
val useBinary: Boolean = enableBinaryCompileAnalysis.value val useBinary: Boolean = enableBinaryCompileAnalysis.value
val c = fileConverter.value
// TODO - expose bytecode manipulation phase. // TODO - expose bytecode manipulation phase.
val analysisResult: CompileResult = manipulateBytecode.value val analysisResult: CompileResult = manipulateBytecode.value
if (analysisResult.hasModified) { if (analysisResult.hasModified) {
val store = val store =
MixedAnalyzingCompiler.staticCachedStore(setup.cacheFile, !useBinary) MixedAnalyzingCompiler.staticCachedStore(setup.cacheFile.toPath, !useBinary)
val contents = AnalysisContents.create(analysisResult.analysis(), analysisResult.setup()) val contents = AnalysisContents.create(analysisResult.analysis(), analysisResult.setup())
store.set(contents) store.set(contents)
} }
@ -1758,8 +1799,8 @@ object Defaults extends BuildCommon {
val analysis = analysisResult.analysis val analysis = analysisResult.analysis
import scala.collection.JavaConverters._ import scala.collection.JavaConverters._
analysis.readStamps.getAllProductStamps.asScala.foreach { analysis.readStamps.getAllProductStamps.asScala.foreach {
case (f, s) => case (f: VirtualFileRef, s) =>
map.put(f.toPath, sbt.nio.FileStamp.LastModified(s.getLastModified.orElse(-1L))) map.put(c.toPath(f), sbt.nio.FileStamp.fromZincStamp(s))
} }
analysis analysis
} }
@ -1798,45 +1839,63 @@ object Defaults extends BuildCommon {
private def compileAnalysisFileTask: Def.Initialize[Task[File]] = private def compileAnalysisFileTask: Def.Initialize[Task[File]] =
Def.task(streams.value.cacheDirectory / compileAnalysisFilename.value) Def.task(streams.value.cacheDirectory / compileAnalysisFilename.value)
def compileIncSetupTask = Def.task { def compileIncSetupTask = Def.task {
val converter = fileConverter.value
val lookup = new PerClasspathEntryLookup { val lookup = new PerClasspathEntryLookup {
private val cachedAnalysisMap = analysisMap(dependencyClasspath.value) private val cachedAnalysisMap: File => Option[CompileAnalysis] =
private val cachedPerEntryDefinesClassLookup = Keys.classpathEntryDefinesClass.value analysisMap(dependencyClasspath.value)
private val cachedPerEntryDefinesClassLookup: File => DefinesClass =
Keys.classpathEntryDefinesClass.value
override def analysis(classpathEntry: File): Optional[CompileAnalysis] = override def analysis(classpathEntry: VirtualFile): Optional[CompileAnalysis] =
cachedAnalysisMap(classpathEntry).toOptional cachedAnalysisMap(converter.toPath(classpathEntry).toFile).toOptional
override def definesClass(classpathEntry: File): DefinesClass = override def definesClass(classpathEntry: VirtualFile): DefinesClass =
cachedPerEntryDefinesClassLookup(classpathEntry) cachedPerEntryDefinesClassLookup(converter.toPath(classpathEntry).toFile)
} }
Setup.of( Setup.of(
lookup, lookup,
(skip in compile).value, (skip in compile).value,
// TODO - this is kind of a bad way to grab the cache directory for streams... // TODO - this is kind of a bad way to grab the cache directory for streams...
compileAnalysisFileTask.value, compileAnalysisFileTask.value.toPath,
compilerCache.value, compilerCache.value,
incOptions.value, incOptions.value,
(compilerReporter in compile).value, (compilerReporter in compile).value,
None.toOptional, // TODO - task / setting for compile progress
None.toOptional: Optional[xsbti.compile.CompileProgress],
// TODO - task / setting for extra, // TODO - task / setting for extra,
Array.empty Array.empty: Array[xsbti.T2[String, String]],
) )
} }
def compileInputsSettings: Seq[Setting[_]] = { def compileInputsSettings: Seq[Setting[_]] = {
Seq( Seq(
compileOptions := CompileOptions.of( compileOptions := {
(classDirectory.value +: data(dependencyClasspath.value)).toArray, val c = fileConverter.value
sources.value.toArray, val cp0 = classDirectory.value +: data(dependencyClasspath.value)
classDirectory.value, val cp = cp0 map { x =>
scalacOptions.value.toArray, PlainVirtualFile(x.toPath)
javacOptions.value.toArray, }
maxErrors.value, val vs = sources.value.toVector map { x =>
f1(foldMappers(sourcePositionMappers.value)), c.toVirtualFile(x.toPath)
compileOrder.value }
), CompileOptions.of(
cp.toArray: Array[VirtualFile],
vs.toArray,
classDirectory.value.toPath,
scalacOptions.value.toArray,
javacOptions.value.toArray,
maxErrors.value,
f1(foldMappers(sourcePositionMappers.value)),
compileOrder.value,
None.toOptional: Optional[NioPath],
Some(fileConverter.value).toOptional,
Some(reusableStamper.value).toOptional
)
},
compilerReporter := { compilerReporter := {
new LanguageServerReporter( new LanguageServerReporter(
maxErrors.value, maxErrors.value,
streams.value.log, streams.value.log,
foldMappers(sourcePositionMappers.value) foldMappers(sourcePositionMappers.value),
fileConverter.value
) )
}, },
compileInputs := { compileInputs := {
@ -1867,7 +1926,7 @@ object Defaults extends BuildCommon {
previousCompile := { previousCompile := {
val setup = compileIncSetup.value val setup = compileIncSetup.value
val useBinary: Boolean = enableBinaryCompileAnalysis.value val useBinary: Boolean = enableBinaryCompileAnalysis.value
val store = MixedAnalyzingCompiler.staticCachedStore(setup.cacheFile, !useBinary) val store = MixedAnalyzingCompiler.staticCachedStore(setup.cacheFile.toPath, !useBinary)
store.get().toOption match { store.get().toOption match {
case Some(contents) => case Some(contents) =>
val analysis = Option(contents.getAnalysis).toOptional val analysis = Option(contents.getAnalysis).toOptional
@ -2112,7 +2171,7 @@ object Classpaths {
dependencyClasspathFiles := data(dependencyClasspath.value).map(_.toPath), dependencyClasspathFiles := data(dependencyClasspath.value).map(_.toPath),
dependencyClasspathFiles / outputFileStamps := { dependencyClasspathFiles / outputFileStamps := {
val cache = managedFileStampCache.value val cache = managedFileStampCache.value
val stamper = outputFileStamper.value val stamper = (managedSourcePaths / outputFileStamper).value
dependencyClasspathFiles.value.flatMap(p => cache.getOrElseUpdate(p, stamper).map(p -> _)) dependencyClasspathFiles.value.flatMap(p => cache.getOrElseUpdate(p, stamper).map(p -> _))
} }
) )
@ -3573,10 +3632,10 @@ object Classpaths {
internalPluginClasspath: Seq[File], internalPluginClasspath: Seq[File],
isDotty: Boolean isDotty: Boolean
): Seq[String] = { ): Seq[String] = {
import sbt.internal.inc.classpath.ClasspathUtil.compilerPlugins
val pluginClasspath = report.matching(configurationFilter(CompilerPlugin.name)) ++ internalPluginClasspath val pluginClasspath = report.matching(configurationFilter(CompilerPlugin.name)) ++ internalPluginClasspath
val plugins = val plugins = compilerPlugins(pluginClasspath.map(_.toPath), isDotty)
sbt.internal.inc.classpath.ClasspathUtilities.compilerPlugins(pluginClasspath, isDotty) plugins.map("-Xplugin:" + _.toAbsolutePath.toString).toSeq
plugins.map("-Xplugin:" + _.getAbsolutePath).toSeq
} }
private[this] lazy val internalCompilerPluginClasspath: Initialize[Task[Classpath]] = private[this] lazy val internalCompilerPluginClasspath: Initialize[Task[Classpath]] =

View File

@ -7,6 +7,7 @@
package sbt package sbt
import java.nio.file.{ Path => NioPath }
import java.io.File import java.io.File
import java.net.URL import java.net.URL
@ -33,7 +34,9 @@ import sbt.librarymanagement.ivy.{ Credentials, IvyConfiguration, IvyPaths, Upda
import sbt.nio.file.Glob import sbt.nio.file.Glob
import sbt.testing.Framework import sbt.testing.Framework
import sbt.util.{ Level, Logger } import sbt.util.{ Level, Logger }
import xsbti.FileConverter
import xsbti.compile._ import xsbti.compile._
import xsbti.compile.analysis.ReadStamps
import scala.concurrent.duration.{ Duration, FiniteDuration } import scala.concurrent.duration.{ Duration, FiniteDuration }
import scala.xml.{ NodeSeq, Node => XNode } import scala.xml.{ NodeSeq, Node => XNode }
@ -214,6 +217,11 @@ object Keys {
val aggregate = settingKey[Boolean]("Configures task aggregation.").withRank(BMinusSetting) val aggregate = settingKey[Boolean]("Configures task aggregation.").withRank(BMinusSetting)
val sourcePositionMappers = taskKey[Seq[xsbti.Position => Option[xsbti.Position]]]("Maps positions in generated source files to the original source it was generated from").withRank(DTask) val sourcePositionMappers = taskKey[Seq[xsbti.Position => Option[xsbti.Position]]]("Maps positions in generated source files to the original source it was generated from").withRank(DTask)
private[sbt] val externalHooks = taskKey[ExternalHooks]("The external hooks used by zinc.") private[sbt] val externalHooks = taskKey[ExternalHooks]("The external hooks used by zinc.")
val fileConverter = settingKey[FileConverter]("The file converter used to convert between Path and VirtualFile")
val allowMachinePath = settingKey[Boolean]("Allow machine-specific paths during conversion.")
val rootPaths = settingKey[Seq[NioPath]]("The root paths used to abstract machine-specific paths.")
private[sbt] val uncachedStamper = settingKey[ReadStamps]("The stamper to create timestamp or hash.")
private[sbt] val reusableStamper = settingKey[ReadStamps]("The stamper can be reused across subprojects and sessions.")
// package keys // package keys
val packageBin = taskKey[File]("Produces a main artifact, such as a binary jar.").withRank(ATask) val packageBin = taskKey[File]("Produces a main artifact, such as a binary jar.").withRank(ATask)

View File

@ -15,7 +15,7 @@ import sbt.Keys._
import sbt.nio.Keys._ import sbt.nio.Keys._
import sbt.Project._ import sbt.Project._
import sbt.internal.inc.ModuleUtilities import sbt.internal.inc.ModuleUtilities
import sbt.internal.inc.classpath.ClasspathUtilities import sbt.internal.inc.classpath.ClasspathUtil
import sbt.internal.util.complete.{ DefaultParsers, Parser } import sbt.internal.util.complete.{ DefaultParsers, Parser }
import sbt.io._ import sbt.io._
import sbt.io.syntax._ import sbt.io.syntax._
@ -92,7 +92,8 @@ object ScriptedPlugin extends AutoPlugin {
private[sbt] def scriptedTestsTask: Initialize[Task[AnyRef]] = private[sbt] def scriptedTestsTask: Initialize[Task[AnyRef]] =
Def.task { Def.task {
val loader = ClasspathUtilities.toLoader(scriptedClasspath.value, scalaInstance.value.loader) val cp = scriptedClasspath.value.get.map(_.toPath)
val loader = ClasspathUtil.toLoader(cp, scalaInstance.value.loader)
try { try {
ModuleUtilities.getObject("sbt.scriptedtest.ScriptedTests", loader) ModuleUtilities.getObject("sbt.scriptedtest.ScriptedTests", loader)
} catch { } catch {

View File

@ -8,6 +8,7 @@
package sbt package sbt
import java.lang.reflect.InvocationTargetException import java.lang.reflect.InvocationTargetException
import java.nio.file.Path
import java.io.File import java.io.File
import sbt.io._, syntax._ import sbt.io._, syntax._
@ -16,7 +17,7 @@ import sbt.internal.util.complete.{ DefaultParsers, Parser }, DefaultParsers._
import xsbti.AppConfiguration import xsbti.AppConfiguration
import sbt.librarymanagement._ import sbt.librarymanagement._
import sbt.librarymanagement.ivy.{ IvyConfiguration, IvyDependencyResolution } import sbt.librarymanagement.ivy.{ IvyConfiguration, IvyDependencyResolution }
import sbt.internal.inc.classpath.ClasspathUtilities import sbt.internal.inc.classpath.ClasspathUtil
import BasicCommandStrings._, BasicKeys._ import BasicCommandStrings._, BasicKeys._
private[sbt] object TemplateCommandUtil { private[sbt] object TemplateCommandUtil {
@ -106,7 +107,7 @@ private[sbt] object TemplateCommandUtil {
log: Logger log: Logger
): ClassLoader = { ): ClassLoader = {
val cp = classpathForInfo(info, ivyConf, globalBase, scalaModuleInfo, log) val cp = classpathForInfo(info, ivyConf, globalBase, scalaModuleInfo, log)
ClasspathUtilities.toLoader(cp, config.provider.loader) ClasspathUtil.toLoader(cp, config.provider.loader)
} }
private def call( private def call(
@ -134,13 +135,13 @@ private[sbt] object TemplateCommandUtil {
globalBase: File, globalBase: File,
scalaModuleInfo: Option[ScalaModuleInfo], scalaModuleInfo: Option[ScalaModuleInfo],
log: Logger log: Logger
): List[File] = { ): List[Path] = {
val lm = IvyDependencyResolution(ivyConf) val lm = IvyDependencyResolution(ivyConf)
val templatesBaseDirectory = new File(globalBase, "templates") val templatesBaseDirectory = new File(globalBase, "templates")
val templateId = s"${info.module.organization}_${info.module.name}_${info.module.revision}" val templateId = s"${info.module.organization}_${info.module.name}_${info.module.revision}"
val templateDirectory = new File(templatesBaseDirectory, templateId) val templateDirectory = new File(templatesBaseDirectory, templateId)
def jars = (templateDirectory ** -DirectoryFilter).get def jars = (templateDirectory ** -DirectoryFilter).get
if (!(info.module.revision endsWith "-SNAPSHOT") && jars.nonEmpty) jars.toList if (!(info.module.revision endsWith "-SNAPSHOT") && jars.nonEmpty) jars.toList.map(_.toPath)
else { else {
IO.createDirectory(templateDirectory) IO.createDirectory(templateDirectory)
val m = lm.wrapDependencyInModule(info.module, scalaModuleInfo) val m = lm.wrapDependencyInModule(info.module, scalaModuleInfo)
@ -148,7 +149,7 @@ private[sbt] object TemplateCommandUtil {
case Left(_) => sys.error(s"Retrieval of ${info.module} failed.") case Left(_) => sys.error(s"Retrieval of ${info.module} failed.")
case Right(files) => files.toList case Right(files) => files.toList
} }
xs xs.map(_.toPath)
} }
} }
} }

View File

@ -16,7 +16,7 @@ import sbt.ClassLoaderLayeringStrategy._
import sbt.Keys._ import sbt.Keys._
import sbt.internal.classpath.ClassLoaderCache import sbt.internal.classpath.ClassLoaderCache
import sbt.internal.inc.ScalaInstance import sbt.internal.inc.ScalaInstance
import sbt.internal.inc.classpath.ClasspathUtilities import sbt.internal.inc.classpath.ClasspathUtil
import sbt.internal.util.Attributed import sbt.internal.util.Attributed
import sbt.internal.util.Attributed.data import sbt.internal.util.Attributed.data
import sbt.io.IO import sbt.io.IO
@ -52,7 +52,7 @@ private[sbt] object ClassLoaders {
fullCP = fullCP, fullCP = fullCP,
allDependenciesSet = dependencyJars(dependencyClasspath).value.filterNot(exclude).toSet, allDependenciesSet = dependencyJars(dependencyClasspath).value.filterNot(exclude).toSet,
cache = extendedClassLoaderCache.value, cache = extendedClassLoaderCache.value,
resources = ClasspathUtilities.createClasspathResources(fullCP.map(_._1), si), resources = ClasspathUtil.createClasspathResources(fullCP.map(_._1.toPath), si),
tmp = IO.createUniqueDirectory(taskTemporaryDirectory.value), tmp = IO.createUniqueDirectory(taskTemporaryDirectory.value),
scope = resolvedScoped.value.scope, scope = resolvedScoped.value.scope,
logger = logger, logger = logger,
@ -94,6 +94,7 @@ private[sbt] object ClassLoaders {
val newLoader = val newLoader =
(classpath: Seq[File]) => { (classpath: Seq[File]) => {
val mappings = classpath.map(f => f.getName -> f).toMap val mappings = classpath.map(f => f.getName -> f).toMap
val cp = classpath.map(_.toPath)
val transformedDependencies = allDeps.map(f => mappings.getOrElse(f.getName, f)) val transformedDependencies = allDeps.map(f => mappings.getOrElse(f.getName, f))
buildLayers( buildLayers(
strategy = classLoaderLayeringStrategy.value: @sbtUnchecked, strategy = classLoaderLayeringStrategy.value: @sbtUnchecked,
@ -101,7 +102,7 @@ private[sbt] object ClassLoaders {
fullCP = classpath.map(f => f -> IO.getModifiedTimeOrZero(f)), fullCP = classpath.map(f => f -> IO.getModifiedTimeOrZero(f)),
allDependenciesSet = transformedDependencies.toSet, allDependenciesSet = transformedDependencies.toSet,
cache = extendedClassLoaderCache.value: @sbtUnchecked, cache = extendedClassLoaderCache.value: @sbtUnchecked,
resources = ClasspathUtilities.createClasspathResources(classpath, instance), resources = ClasspathUtil.createClasspathResources(cp, instance),
tmp = taskTemporaryDirectory.value: @sbtUnchecked, tmp = taskTemporaryDirectory.value: @sbtUnchecked,
scope = resolvedScope, scope = resolvedScope,
logger = logger, logger = logger,

View File

@ -14,18 +14,16 @@ import sbt.Def
import sbt.Keys._ import sbt.Keys._
import sbt.internal.inc.ExternalLookup import sbt.internal.inc.ExternalLookup
import sbt.internal.inc.Stamp.equivStamp.equiv import sbt.internal.inc.Stamp.equivStamp.equiv
import sbt.io.syntax._
import sbt.nio.Keys._ import sbt.nio.Keys._
import sbt.nio.file.syntax._ import sbt.nio.file.syntax._
import sbt.nio.file.{ FileAttributes, FileTreeView, RecursiveGlob } import sbt.nio.file.{ FileAttributes, FileTreeView, RecursiveGlob }
import sbt.nio.{ FileChanges, FileStamp, FileStamper } import sbt.nio.{ FileChanges, FileStamp, FileStamper }
import sbt.util.InterfaceUtil.jo2o
import xsbti.{ VirtualFile, VirtualFileRef }
import xsbti.compile._ import xsbti.compile._
import xsbti.compile.analysis.Stamp import xsbti.compile.analysis.Stamp
import scala.collection.JavaConverters._
private[sbt] object ExternalHooks { private[sbt] object ExternalHooks {
private val javaHome = Option(System.getProperty("java.home")).map(Paths.get(_))
private type Func = private type Func =
(FileChanges, FileChanges, FileTreeView[(Path, FileAttributes)]) => ExternalHooks (FileChanges, FileChanges, FileTreeView[(Path, FileAttributes)]) => ExternalHooks
def default: Def.Initialize[sbt.Task[Func]] = Def.task { def default: Def.Initialize[sbt.Task[Func]] = Def.task {
@ -34,13 +32,15 @@ private[sbt] object ExternalHooks {
val cp = dependencyClasspath.value.map(_.data) val cp = dependencyClasspath.value.map(_.data)
cp.foreach { file => cp.foreach { file =>
val path = file.toPath val path = file.toPath
managedCache.getOrElseUpdate(path, FileStamper.LastModified) managedCache.getOrElseUpdate(path, FileStamper.Hash)
} }
val classGlob = classDirectory.value.toGlob / RecursiveGlob / "*.class" val classGlob = classDirectory.value.toGlob / RecursiveGlob / "*.class"
val options = (compileOptions in compile).value val options = (compileOptions in compile).value
((inputFileChanges, outputFileChanges, fileTreeView) => { ((inputFileChanges, outputFileChanges, fileTreeView) => {
fileTreeView.list(classGlob).foreach { fileTreeView.list(classGlob).foreach {
case (path, _) => managedCache.update(path, FileStamper.LastModified) case (path, _) =>
s"updating $path"
managedCache.update(path, FileStamper.Hash)
} }
apply(inputFileChanges, outputFileChanges, options, unmanagedCache, managedCache) apply(inputFileChanges, outputFileChanges, options, unmanagedCache, managedCache)
}): Func }): Func
@ -52,34 +52,50 @@ private[sbt] object ExternalHooks {
unmanagedCache: FileStamp.Cache, unmanagedCache: FileStamp.Cache,
managedCache: FileStamp.Cache managedCache: FileStamp.Cache
): DefaultExternalHooks = { ): DefaultExternalHooks = {
val converter = jo2o(options.converter) getOrElse {
sys.error("file converter was expected")
}
val lookup = new ExternalLookup { val lookup = new ExternalLookup {
override def changedSources(previousAnalysis: CompileAnalysis): Option[Changes[File]] = Some { override def changedSources(
new Changes[File] { previousAnalysis: CompileAnalysis
val getAdded: java.util.Set[File] = new java.util.HashSet[File] ): Option[Changes[VirtualFileRef]] = Some {
val getRemoved: java.util.Set[File] = new java.util.HashSet[File] new Changes[VirtualFileRef] {
val getChanged: java.util.Set[File] = new java.util.HashSet[File] override val getAdded: java.util.Set[VirtualFileRef] =
val getUnmodified: java.util.Set[File] = new java.util.HashSet[File] new java.util.HashSet[VirtualFileRef]
private def add(p: Path, sets: java.util.Set[File]*): Unit = { override val getRemoved: java.util.Set[VirtualFileRef] =
sets.foreach(add(p.toFile, _)) new java.util.HashSet[VirtualFileRef]
override val getChanged: java.util.Set[VirtualFileRef] =
new java.util.HashSet[VirtualFileRef]
override val getUnmodified: java.util.Set[VirtualFileRef] =
new java.util.HashSet[VirtualFileRef]
override def toString: String =
s"""Changes(added = $getAdded, removed = $getRemoved, changed = $getChanged, unmodified = ...)"""
private def add(p: VirtualFileRef, sets: java.util.Set[VirtualFileRef]*): Unit = {
sets.foreach(add(p, _))
} }
private def add(f: File, set: java.util.Set[File]): Unit = { set.add(f); () } private def add(f: VirtualFileRef, set: java.util.Set[VirtualFileRef]): Unit = {
val allChanges = new java.util.HashSet[File] set.add(f); ()
}
val allChanges = new java.util.HashSet[VirtualFileRef]
inputFileChanges match { inputFileChanges match {
case FileChanges(c, d, m, _) => case FileChanges(c, d, m, _) =>
c.foreach(add(_, getAdded, allChanges)) c.map(converter.toVirtualFile).foreach(add(_, getAdded, allChanges))
d.foreach(add(_, getRemoved, allChanges)) d.map(converter.toVirtualFile).foreach(add(_, getRemoved, allChanges))
m.foreach(add(_, getChanged, allChanges)) m.map(converter.toVirtualFile).foreach(add(_, getChanged, allChanges))
case _ => case _ =>
} }
override def isEmpty: java.lang.Boolean = override def isEmpty: java.lang.Boolean =
getAdded.isEmpty && getRemoved.isEmpty && getChanged.isEmpty getAdded.isEmpty && getRemoved.isEmpty && getChanged.isEmpty
private val prevSources = previousAnalysis.readStamps().getAllSourceStamps private val prevSources = previousAnalysis.readStamps().getAllSourceStamps
prevSources.forEach { (file: File, s: Stamp) => prevSources.forEach { (file: VirtualFileRef, s: Stamp) =>
if (!allChanges.contains(file)) { if (!allChanges.contains(file)) {
val path = file.toPath val path: Path = converter.toPath(file)
unmanagedCache unmanagedCache
.get(path) .get(path)
.orElse(managedCache.getOrElseUpdate(file.toPath, FileStamper.Hash)) match { .orElse(managedCache.getOrElseUpdate(path, FileStamper.Hash)) match {
case None => add(file, getRemoved) case None => add(file, getRemoved)
case Some(stamp) => case Some(stamp) =>
if (equiv(stamp.stamp, s)) add(file, getUnmodified) if (equiv(stamp.stamp, s)) add(file, getUnmodified)
@ -97,34 +113,50 @@ private[sbt] object ExternalHooks {
): Boolean = true ): Boolean = true
// This could use the cache as well, but it would complicate the cache implementation. // This could use the cache as well, but it would complicate the cache implementation.
override def hashClasspath(files: Array[File]): Optional[Array[FileHash]] = override def hashClasspath(files: Array[VirtualFile]): Optional[Array[FileHash]] =
Optional.empty[Array[FileHash]] Optional.empty[Array[FileHash]]
override def changedBinaries(previousAnalysis: CompileAnalysis): Option[Set[File]] = { import scala.collection.JavaConverters._
val base = private val javaHome = Option(System.getProperty("java.home")).map(Paths.get(_))
override def changedBinaries(
previousAnalysis: CompileAnalysis
): Option[Set[VirtualFileRef]] = {
val base: Set[VirtualFileRef] =
(outputFileChanges.modified ++ outputFileChanges.created ++ outputFileChanges.deleted) (outputFileChanges.modified ++ outputFileChanges.created ++ outputFileChanges.deleted)
.map(_.toFile) .map(converter.toVirtualFile(_))
.toSet .toSet
Some(base ++ previousAnalysis.readStamps.getAllBinaryStamps.asScala.flatMap { Some(base ++ previousAnalysis.readStamps.getAllLibraryStamps.asScala.flatMap {
case (file, stamp) => case (file, stamp) =>
managedCache.getOrElseUpdate(file.toPath, FileStamper.LastModified) match { val path = converter.toPath(file)
case Some(cachedStamp) if equiv(cachedStamp.stamp, stamp) => None val stampOpt = managedCache.getOrElseUpdate(path, FileStamper.Hash)
stampOpt match {
case Some(s) if equiv(s.stamp, stamp) => None
case _ => case _ =>
javaHome match { javaHome match {
case Some(h) if file.toPath.startsWith(h) => None case Some(h) if path.startsWith(h) => None
case _ if file.getName == "rt.jar" => None case _ if file.name == "rt.jar" => None
case _ => Some(file) case _ =>
// stampOpt map { s => println(s"stamp changed for $file from ${s.stamp} to $stamp") }
Some(file)
} }
} }
}) })
} }
override def removedProducts(previousAnalysis: CompileAnalysis): Option[Set[File]] = { override def removedProducts(
previousAnalysis: CompileAnalysis
): Option[Set[VirtualFileRef]] = {
None
Some(previousAnalysis.readStamps.getAllProductStamps.asScala.flatMap { Some(previousAnalysis.readStamps.getAllProductStamps.asScala.flatMap {
case (file, stamp) => case (file, stamp) =>
managedCache.get(file.toPath) match { val path = converter.toPath(file)
managedCache.get(path) match {
case Some(s) if equiv(s.stamp, stamp) => None case Some(s) if equiv(s.stamp, stamp) => None
case _ => Some(file) case Some(s) => Some(file)
case _ =>
// This shouldn't be necessary
if (java.nio.file.Files.exists(path)) None
else Some(file)
} }
}.toSet) }.toSet)
} }

View File

@ -18,7 +18,7 @@ import sbt.Project.inScope
import sbt.Scope.GlobalScope import sbt.Scope.GlobalScope
import sbt.compiler.Eval import sbt.compiler.Eval
import sbt.internal.BuildStreams._ import sbt.internal.BuildStreams._
import sbt.internal.inc.classpath.ClasspathUtilities import sbt.internal.inc.classpath.ClasspathUtil
import sbt.internal.inc.{ ScalaInstance, ZincLmUtil, ZincUtil } import sbt.internal.inc.{ ScalaInstance, ZincLmUtil, ZincUtil }
import sbt.internal.util.Attributed.data import sbt.internal.util.Attributed.data
import sbt.internal.util.Types.const import sbt.internal.util.Types.const
@ -1285,7 +1285,7 @@ private[sbt] object Load {
// Load the definition classpath separately to avoid conflicts, see #511. // Load the definition classpath separately to avoid conflicts, see #511.
if (definitionClasspath.isEmpty) parentLoader if (definitionClasspath.isEmpty) parentLoader
else ClasspathUtilities.toLoader(data(definitionClasspath), parentLoader) else ClasspathUtil.toLoader(data(definitionClasspath).map(_.toPath), parentLoader)
} }
def buildPluginDefinition(dir: File, s: State, config: LoadBuildConfiguration): PluginData = { def buildPluginDefinition(dir: File, s: State, config: LoadBuildConfiguration): PluginData = {

View File

@ -9,7 +9,6 @@ package sbt
package internal package internal
package server package server
import java.io.File
import java.net.URI import java.net.URI
import java.nio.file._ import java.nio.file._
@ -27,7 +26,6 @@ import sjsonnew.support.scalajson.unsafe.{ CompactPrinter, Converter }
import scalacache._ import scalacache._
import sbt.io.IO
import sbt.internal.inc.{ Analysis, MixedAnalyzingCompiler } import sbt.internal.inc.{ Analysis, MixedAnalyzingCompiler }
import sbt.internal.inc.JavaInterfaceUtil._ import sbt.internal.inc.JavaInterfaceUtil._
import sbt.internal.protocol.JsonRpcResponseError import sbt.internal.protocol.JsonRpcResponseError
@ -36,6 +34,7 @@ import sbt.internal.langserver
import sbt.internal.langserver.{ ErrorCodes, Location, Position, Range, TextDocumentPositionParams } import sbt.internal.langserver.{ ErrorCodes, Location, Position, Range, TextDocumentPositionParams }
import sbt.util.Logger import sbt.util.Logger
import sbt.Keys._ import sbt.Keys._
import xsbti.{ FileConverter, VirtualFileRef }
private[sbt] object Definition { private[sbt] object Definition {
def send[A: JsonFormat](source: CommandSource, execId: String)(params: A): Unit = { def send[A: JsonFormat](source: CommandSource, execId: String)(params: A): Unit = {
@ -157,10 +156,10 @@ private[sbt] object Definition {
} }
} }
def markPosition(file: File, sym: String): Seq[(File, Long, Long, Long)] = { def markPosition(file: Path, sym: String): Seq[(URI, Long, Long, Long)] = {
val findInLine = classTraitObjectInLine(sym)(_) val findInLine = classTraitObjectInLine(sym)(_)
Files Files
.lines(file.toPath) .lines(file)
.iterator .iterator
.asScala .asScala
.zipWithIndex .zipWithIndex
@ -169,7 +168,7 @@ private[sbt] object Definition {
findInLine(line) findInLine(line)
.collect { .collect {
case (sym, from) => case (sym, from) =>
(file, lineNumber.toLong, from.toLong, from.toLong + sym.length) (file.toUri, lineNumber.toLong, from.toLong, from.toLong + sym.length)
} }
} }
.toSeq .toSeq
@ -200,7 +199,7 @@ private[sbt] object Definition {
cache.put(AnalysesKey)(value, ttl) cache.put(AnalysesKey)(value, ttl)
} }
private def storeAnalysis(cacheFile: File, useBinary: Boolean): Option[Analysis] = private def storeAnalysis(cacheFile: Path, useBinary: Boolean): Option[Analysis] =
MixedAnalyzingCompiler MixedAnalyzingCompiler
.staticCachedStore(cacheFile, !useBinary) .staticCachedStore(cacheFile, !useBinary)
.get .get
@ -225,7 +224,7 @@ private[sbt] object Definition {
} }
def collectAnalysesTask = Def.task { def collectAnalysesTask = Def.task {
val cacheFile = compileIncSetup.value.cacheFile.getAbsolutePath val cacheFile: String = compileIncSetup.value.cacheFile.getAbsolutePath
val useBinary = enableBinaryCompileAnalysis.value val useBinary = enableBinaryCompileAnalysis.value
val s = state.value val s = state.value
s.log.debug(s"analysis location ${cacheFile -> useBinary}") s.log.debug(s"analysis location ${cacheFile -> useBinary}")
@ -246,7 +245,7 @@ private[sbt] object Definition {
} }
val addToCache = uninitialized.collect { val addToCache = uninitialized.collect {
case (title @ (file, useBinary), _) if Files.exists(Paths.get(file)) => case (title @ (file, useBinary), _) if Files.exists(Paths.get(file)) =>
(title, storeAnalysis(Paths.get(file).toFile, !useBinary)) (title, storeAnalysis(Paths.get(file), !useBinary))
} }
val validCaches = working ++ addToCache val validCaches = working ++ addToCache
if (addToCache.nonEmpty) if (addToCache.nonEmpty)
@ -262,6 +261,7 @@ private[sbt] object Definition {
jsonDefinition: JValue, jsonDefinition: JValue,
requestId: String, requestId: String,
commandSource: CommandSource, commandSource: CommandSource,
converter: FileConverter,
log: Logger, log: Logger,
)(implicit ec: ExecutionContext): Future[Unit] = Future { )(implicit ec: ExecutionContext): Future[Unit] = Future {
val LspDefinitionLogHead = "lsp-definition" val LspDefinitionLogHead = "lsp-definition"
@ -297,11 +297,12 @@ private[sbt] object Definition {
analysis.relations.definesClass(className) ++ analysis.relations.definesClass(className) ++
analysis.relations.libraryDefinesClass(className) analysis.relations.libraryDefinesClass(className)
} }
.flatMap { classFile => .flatMap { classFile: VirtualFileRef =>
textProcessor.markPosition(classFile, sym).collect { val x = converter.toPath(classFile)
case (file, line, from, to) => textProcessor.markPosition(x, sym).collect {
case (uri, line, from, to) =>
Location( Location(
IO.toURI(file).toString, uri.toString,
Range(Position(line, from), Position(line, to)), Range(Position(line, from), Position(line, to)),
) )
} }

View File

@ -20,8 +20,8 @@ import sbt.internal.protocol.codec._
import sbt.internal.langserver._ import sbt.internal.langserver._
import sbt.internal.util.ObjectEvent import sbt.internal.util.ObjectEvent
import sbt.util.Logger import sbt.util.Logger
import scala.concurrent.ExecutionContext import scala.concurrent.ExecutionContext
import xsbti.FileConverter
private[sbt] final case class LangServerError(code: Long, message: String) private[sbt] final case class LangServerError(code: Long, message: String)
extends Throwable(message) extends Throwable(message)
@ -37,68 +37,69 @@ private[sbt] object LanguageServerProtocol {
) )
} }
lazy val handler: ServerHandler = ServerHandler({ def handler(converter: FileConverter): ServerHandler =
case callback: ServerCallback => ServerHandler({
import callback._ case callback: ServerCallback =>
ServerIntent( import callback._
{ ServerIntent(
import sbt.internal.langserver.codec.JsonProtocol._
import internalJsonProtocol._
def json(r: JsonRpcRequestMessage) =
r.params.getOrElse(
throw LangServerError(
ErrorCodes.InvalidParams,
s"param is expected on '${r.method}' method."
)
)
{ {
case r: JsonRpcRequestMessage if r.method == "initialize" => import sbt.internal.langserver.codec.JsonProtocol._
if (authOptions(ServerAuthentication.Token)) { import internalJsonProtocol._
val param = Converter.fromJson[InitializeParams](json(r)).get def json(r: JsonRpcRequestMessage) =
val optionJson = param.initializationOptions.getOrElse( r.params.getOrElse(
throw LangServerError( throw LangServerError(
ErrorCodes.InvalidParams, ErrorCodes.InvalidParams,
"initializationOptions is expected on 'initialize' param." s"param is expected on '${r.method}' method."
)
) )
val opt = Converter.fromJson[InitializeOption](optionJson).get )
val token = opt.token.getOrElse(sys.error("'token' is missing."))
if (authenticate(token)) ()
else throw LangServerError(ErrorCodes.InvalidRequest, "invalid token")
} else ()
setInitialized(true)
appendExec(Exec(s"collectAnalyses", None, Some(CommandSource(name))))
jsonRpcRespond(InitializeResult(serverCapabilities), Option(r.id))
case r: JsonRpcRequestMessage if r.method == "textDocument/definition" => {
implicit val executionContext: ExecutionContext = StandardMain.executionContext case r: JsonRpcRequestMessage if r.method == "initialize" =>
Definition.lspDefinition(json(r), r.id, CommandSource(name), log) if (authOptions(ServerAuthentication.Token)) {
val param = Converter.fromJson[InitializeParams](json(r)).get
val optionJson = param.initializationOptions.getOrElse(
throw LangServerError(
ErrorCodes.InvalidParams,
"initializationOptions is expected on 'initialize' param."
)
)
val opt = Converter.fromJson[InitializeOption](optionJson).get
val token = opt.token.getOrElse(sys.error("'token' is missing."))
if (authenticate(token)) ()
else throw LangServerError(ErrorCodes.InvalidRequest, "invalid token")
} else ()
setInitialized(true)
appendExec(Exec(s"collectAnalyses", None, Some(CommandSource(name))))
jsonRpcRespond(InitializeResult(serverCapabilities), Option(r.id))
case r: JsonRpcRequestMessage if r.method == "textDocument/definition" =>
implicit val executionContext: ExecutionContext = StandardMain.executionContext
Definition.lspDefinition(json(r), r.id, CommandSource(name), converter, log)
()
case r: JsonRpcRequestMessage if r.method == "sbt/exec" =>
val param = Converter.fromJson[SbtExecParams](json(r)).get
appendExec(Exec(param.commandLine, Some(r.id), Some(CommandSource(name))))
()
case r: JsonRpcRequestMessage if r.method == "sbt/setting" =>
import sbt.protocol.codec.JsonProtocol._
val param = Converter.fromJson[Q](json(r)).get
onSettingQuery(Option(r.id), param)
case r: JsonRpcRequestMessage if r.method == "sbt/cancelRequest" =>
import sbt.protocol.codec.JsonProtocol._
val param = Converter.fromJson[CRP](json(r)).get
onCancellationRequest(Option(r.id), param)
case r: JsonRpcRequestMessage if r.method == "sbt/completion" =>
import sbt.protocol.codec.JsonProtocol._
val param = Converter.fromJson[CP](json(r)).get
onCompletionRequest(Option(r.id), param)
}
}, {
case n: JsonRpcNotificationMessage if n.method == "textDocument/didSave" =>
appendExec(Exec(";Test/compile; collectAnalyses", None, Some(CommandSource(name))))
() ()
case r: JsonRpcRequestMessage if r.method == "sbt/exec" =>
val param = Converter.fromJson[SbtExecParams](json(r)).get
appendExec(Exec(param.commandLine, Some(r.id), Some(CommandSource(name))))
()
case r: JsonRpcRequestMessage if r.method == "sbt/setting" =>
import sbt.protocol.codec.JsonProtocol._
val param = Converter.fromJson[Q](json(r)).get
onSettingQuery(Option(r.id), param)
case r: JsonRpcRequestMessage if r.method == "sbt/cancelRequest" =>
import sbt.protocol.codec.JsonProtocol._
val param = Converter.fromJson[CRP](json(r)).get
onCancellationRequest(Option(r.id), param)
case r: JsonRpcRequestMessage if r.method == "sbt/completion" =>
import sbt.protocol.codec.JsonProtocol._
val param = Converter.fromJson[CP](json(r)).get
onCompletionRequest(Option(r.id), param)
} }
}, { )
case n: JsonRpcNotificationMessage if n.method == "textDocument/didSave" => })
appendExec(Exec(";Test/compile; collectAnalyses", None, Some(CommandSource(name))))
()
}
)
})
} }
/** Implements Language Server Protocol <https://github.com/Microsoft/language-server-protocol>. */ /** Implements Language Server Protocol <https://github.com/Microsoft/language-server-protocol>. */

View File

@ -12,7 +12,7 @@ package server
import java.io.File import java.io.File
import sbt.internal.inc.ManagedLoggedReporter import sbt.internal.inc.ManagedLoggedReporter
import sbt.internal.util.ManagedLogger import sbt.internal.util.ManagedLogger
import xsbti.{ Problem, Position => XPosition, Severity } import xsbti.{ FileConverter, Problem, Position => XPosition, Severity }
import xsbti.compile.CompileAnalysis import xsbti.compile.CompileAnalysis
import sbt.internal.langserver.{ import sbt.internal.langserver.{
PublishDiagnosticsParams, PublishDiagnosticsParams,
@ -24,7 +24,6 @@ import sbt.internal.langserver.{
import sbt.internal.inc.JavaInterfaceUtil._ import sbt.internal.inc.JavaInterfaceUtil._
import scala.collection.mutable import scala.collection.mutable
import scala.collection.JavaConverters._ import scala.collection.JavaConverters._
import sbt.io.IO
/** /**
* Defines a compiler reporter that uses event logging provided by a `ManagedLogger`. * Defines a compiler reporter that uses event logging provided by a `ManagedLogger`.
@ -36,7 +35,8 @@ import sbt.io.IO
class LanguageServerReporter( class LanguageServerReporter(
maximumErrors: Int, maximumErrors: Int,
logger: ManagedLogger, logger: ManagedLogger,
sourcePositionMapper: XPosition => XPosition = identity[XPosition] sourcePositionMapper: XPosition => XPosition = identity[XPosition],
converter: FileConverter
) extends ManagedLoggedReporter(maximumErrors, logger, sourcePositionMapper) { ) extends ManagedLoggedReporter(maximumErrors, logger, sourcePositionMapper) {
lazy val exchange = StandardMain.exchange lazy val exchange = StandardMain.exchange
@ -83,7 +83,8 @@ class LanguageServerReporter(
import sbt.internal.langserver.codec.JsonProtocol._ import sbt.internal.langserver.codec.JsonProtocol._
val files = analysis.readSourceInfos.getAllSourceInfos.keySet.asScala val files = analysis.readSourceInfos.getAllSourceInfos.keySet.asScala
files foreach { f => files foreach { f =>
val params = PublishDiagnosticsParams(IO.toURI(f).toString, Vector()) val p = converter.toPath(f)
val params = PublishDiagnosticsParams(p.toUri.toString, Vector())
exchange.notifyEvent("textDocument/publishDiagnostics", params) exchange.notifyEvent("textDocument/publishDiagnostics", params)
} }
} }
@ -95,7 +96,7 @@ class LanguageServerReporter(
problemsByFile.get(sourceFile) match { problemsByFile.get(sourceFile) match {
case Some(xs: mutable.ListBuffer[Problem]) => case Some(xs: mutable.ListBuffer[Problem]) =>
val ds = toDiagnostics(xs) val ds = toDiagnostics(xs)
val params = PublishDiagnosticsParams(IO.toURI(sourceFile).toString, ds) val params = PublishDiagnosticsParams(sbt.io.IO.toURI(sourceFile).toString, ds)
exchange.notifyEvent("textDocument/publishDiagnostics", params) exchange.notifyEvent("textDocument/publishDiagnostics", params)
case _ => case _ =>
} }

View File

@ -78,17 +78,22 @@ object FileStamp {
case e: IOException => Some(Error(e)) case e: IOException => Some(Error(e))
} }
private[sbt] def hash(string: String): Hash = private[sbt] def hash(string: String): Hash =
new FileHashImpl(sbt.internal.inc.Hash.unsafeFromString(string)) new FileHashImpl(try {
private[sbt] def hash(path: Path): Option[Hash] = Stamper.forHash(path.toFile) match { sbt.internal.inc.Stamp.fromString(string)
} catch {
case _: Throwable => EmptyStamp
})
private[sbt] def hash(path: Path): Option[Hash] = Stamper.forFarmHashP(path) match {
case EmptyStamp => None case EmptyStamp => None
case s => Some(new FileHashImpl(s)) case s => Some(new FileHashImpl(s))
} }
private[sbt] def fromZincStamp(stamp: XStamp): Hash = new FileHashImpl(stamp)
private[sbt] def lastModified(path: Path): Option[LastModified] = private[sbt] def lastModified(path: Path): Option[LastModified] =
IO.getModifiedTimeOrZero(path.toFile) match { IO.getModifiedTimeOrZero(path.toFile) match {
case 0 => None case 0 => None
case l => Some(LastModified(l)) case l => Some(LastModified(l))
} }
private[this] class FileHashImpl(val xstamp: XStamp) extends Hash(xstamp.getHash.orElse("")) private[this] class FileHashImpl(val xstamp: XStamp) extends Hash(xstamp.toString)
private[sbt] sealed abstract case class Hash private[sbt] (hex: String) extends FileStamp private[sbt] sealed abstract case class Hash private[sbt] (hex: String) extends FileStamp
private[sbt] final case class LastModified private[sbt] (time: Long) extends FileStamp private[sbt] final case class LastModified private[sbt] (time: Long) extends FileStamp
private[sbt] final case class Error(exception: IOException) extends FileStamp private[sbt] final case class Error(exception: IOException) extends FileStamp

View File

@ -14,7 +14,7 @@ object Dependencies {
private val ioVersion = nightlyVersion.getOrElse("1.4.0-M2") private val ioVersion = nightlyVersion.getOrElse("1.4.0-M2")
private val lmVersion = private val lmVersion =
sys.props.get("sbt.build.lm.version").orElse(nightlyVersion).getOrElse("1.3.0") sys.props.get("sbt.build.lm.version").orElse(nightlyVersion).getOrElse("1.3.0")
val zincVersion = nightlyVersion.getOrElse("1.3.1") val zincVersion = nightlyVersion.getOrElse("1.4.0-M3")
private val sbtIO = "org.scala-sbt" %% "io" % ioVersion private val sbtIO = "org.scala-sbt" %% "io" % ioVersion
@ -68,13 +68,13 @@ object Dependencies {
def addSbtLmIvy = addSbtModule(sbtLmPath, "lmIvy", libraryManagementIvy) def addSbtLmIvy = addSbtModule(sbtLmPath, "lmIvy", libraryManagementIvy)
def addSbtLmIvyTest = addSbtModule(sbtLmPath, "lmIvy", libraryManagementIvy, Some(Test)) def addSbtLmIvyTest = addSbtModule(sbtLmPath, "lmIvy", libraryManagementIvy, Some(Test))
def addSbtCompilerInterface = addSbtModule(sbtZincPath, "compilerInterface212", compilerInterface) def addSbtCompilerInterface = addSbtModule(sbtZincPath, "compilerInterfaceJVM", compilerInterface)
def addSbtCompilerClasspath = addSbtModule(sbtZincPath, "zincClasspath212", compilerClasspath) def addSbtCompilerClasspath = addSbtModule(sbtZincPath, "zincClasspathJVM2_12", compilerClasspath)
def addSbtCompilerApiInfo = addSbtModule(sbtZincPath, "zincApiInfo212", compilerApiInfo) def addSbtCompilerApiInfo = addSbtModule(sbtZincPath, "zincApiInfoJVM2_12", compilerApiInfo)
def addSbtCompilerBridge = addSbtModule(sbtZincPath, "compilerBridge212", compilerBridge) def addSbtCompilerBridge = addSbtModule(sbtZincPath, "compilerBridgeJVM2_12", compilerBridge)
def addSbtZinc = addSbtModule(sbtZincPath, "zinc", zinc) def addSbtZinc = addSbtModule(sbtZincPath, "zincJVM2_12", zinc)
def addSbtZincCompile = addSbtModule(sbtZincPath, "zincCompile", zincCompile) def addSbtZincCompile = addSbtModule(sbtZincPath, "zincCompileJVM2_12", zincCompile)
def addSbtZincCompileCore = addSbtModule(sbtZincPath, "zincCompileCore", zincCompileCore) def addSbtZincCompileCore = addSbtModule(sbtZincPath, "zincCompileCoreJVM2_12", zincCompileCore)
val lmCoursierShaded = "io.get-coursier" %% "lm-coursier-shaded" % "2.0.0-RC6-2" val lmCoursierShaded = "io.get-coursier" %% "lm-coursier-shaded" % "2.0.0-RC6-2"

View File

@ -4,7 +4,7 @@ addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.0.0")
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.6") addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.6")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0") addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.0") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.0")
addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.4.4") addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.4.6")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "3.0.2") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "3.0.2")
addSbtPlugin("com.lightbend" % "sbt-whitesource" % "0.1.14") addSbtPlugin("com.lightbend" % "sbt-whitesource" % "0.1.14")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

View File

@ -1,5 +1,5 @@
/** /**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
*/ */
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY

Some files were not shown because too many files have changed in this diff Show More