-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cache verifier. Add classpath mappers. Add mapper for whole MiniSetup after setup os loaded. Fixes small problems with dependencies phase (e.g. reduce numbers of NoSymbol checked) and do treat refinement class as top-level class (since it does not have runtime representation.
- Loading branch information
1 parent
9c52239
commit 52aa327
Showing
12 changed files
with
168 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
internal/zinc-persist/src/main/scala/sbt/internal/inc/cached/CacheVerifier.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Zinc - The incremental compiler for Scala. | ||
* Copyright 2011 - 2017, Lightbend, Inc. | ||
* Copyright 2008 - 2010, Mark Harrah | ||
* This software is released under the terms written in LICENSE. | ||
*/ | ||
|
||
package sbt.internal.inc.cached | ||
|
||
import java.io.File | ||
|
||
import sbt.internal.inc.{ AnalysisMappers, ContextAwareMapper, Mapper, Stamp } | ||
import xsbti.compile.MiniSetup | ||
|
||
trait VerficationResults | ||
object NoVerification extends VerficationResults | ||
|
||
/** | ||
* Class used to verify data that will be exported using Exportable cache. | ||
* It is intended to create warnings if cache is not correctly mapped. | ||
*/ | ||
abstract class CacheVerifier { | ||
|
||
def verifingMappers(from: AnalysisMappers): AnalysisMappers = new AnalysisMappers { | ||
override val outputDirMapper: Mapper[File] = analyzed("outputDirMapper", from.outputDirMapper) | ||
override val sourceDirMapper: Mapper[File] = analyzed("sourceDirMapper", from.sourceDirMapper) | ||
override val scalacOptions: Mapper[String] = analyzed("scalacOptions", from.scalacOptions) | ||
override val javacOptions: Mapper[String] = analyzed("javacOptions", from.javacOptions) | ||
override val sourceMapper: Mapper[File] = analyzed("sourceMapper", from.sourceMapper) | ||
override val productMapper: Mapper[File] = analyzed("productMapper", from.productMapper) | ||
override val binaryMapper: Mapper[File] = analyzed("binaryMapper", from.binaryMapper) | ||
override val binaryStampMapper: ContextAwareMapper[File, Stamp] = | ||
analyzed("binaryStampMapper", from.binaryStampMapper) | ||
override val productStampMapper: ContextAwareMapper[File, Stamp] = | ||
analyzed("productStampMapper", from.productStampMapper) | ||
override val sourceStampMapper: ContextAwareMapper[File, Stamp] = | ||
analyzed("sourceStampMapper", from.sourceStampMapper) | ||
override val classpathMapper: Mapper[File] = analyzed("classpathMapper", from.classpathMapper) | ||
|
||
override def mapOptionsFromCache(fromCache: MiniSetup): MiniSetup = fromCache | ||
} | ||
|
||
def results: VerficationResults | ||
|
||
protected def analyzeValue(category: String, serializedValue: String, deserializedValue: Any): Unit | ||
|
||
private def analyzed[T](category: String, original: Mapper[T]): Mapper[T] = { | ||
def write(v: T): String = { | ||
val result = original.write(v) | ||
analyzeValue(category, result, v) | ||
result | ||
} | ||
Mapper(original.read, write) | ||
} | ||
|
||
private def analyzed[C, T](category: String, original: ContextAwareMapper[C, T]): ContextAwareMapper[C, T] = { | ||
def write(c: C, v: T): String = { | ||
val result = original.write(c, v) | ||
analyzeValue(category, result, v) | ||
result | ||
} | ||
|
||
ContextAwareMapper(original.read, write) | ||
} | ||
} | ||
|
||
object NoopVerifier extends CacheVerifier { | ||
override protected def analyzeValue(category: String, serializedValue: String, deserializedValue: Any): Unit = () | ||
|
||
override def verifingMappers(from: AnalysisMappers): AnalysisMappers = from | ||
override def results: VerficationResults = NoVerification | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters