diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-10-11 17:28:39 +0200 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2016-11-22 01:35:06 +0100 |
commit | 2d10c87ce537fb42fdb134efcae53dca7305a7b7 (patch) | |
tree | a3629c9a3ad6db3e9d07df8fa8621f8c8211076c /sbt-bridge/bridge/src/test/scala/xsbti/TestCallback.scala | |
parent | 34d64f381362b12a595fd26690c7c9b1c26d16f7 (diff) | |
download | dotty-2d10c87ce537fb42fdb134efcae53dca7305a7b7.tar.gz dotty-2d10c87ce537fb42fdb134efcae53dca7305a7b7.tar.bz2 dotty-2d10c87ce537fb42fdb134efcae53dca7305a7b7.zip |
Move sbt-bridge
Diffstat (limited to 'sbt-bridge/bridge/src/test/scala/xsbti/TestCallback.scala')
-rw-r--r-- | sbt-bridge/bridge/src/test/scala/xsbti/TestCallback.scala | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sbt-bridge/bridge/src/test/scala/xsbti/TestCallback.scala b/sbt-bridge/bridge/src/test/scala/xsbti/TestCallback.scala new file mode 100644 index 000000000..b849e1a80 --- /dev/null +++ b/sbt-bridge/bridge/src/test/scala/xsbti/TestCallback.scala @@ -0,0 +1,35 @@ +/** Copied from https://github.com/sbt/sbt/blob/0.13/interface/src/test/scala/xsbti/TestCallback.scala */ +package xsbti + +import java.io.File +import scala.collection.mutable.ArrayBuffer +import xsbti.api.SourceAPI +import xsbti.DependencyContext._ + +class TestCallback(override val nameHashing: Boolean = false) extends AnalysisCallback +{ + val sourceDependencies = new ArrayBuffer[(File, File, DependencyContext)] + val binaryDependencies = new ArrayBuffer[(File, String, File, DependencyContext)] + val products = new ArrayBuffer[(File, File, String)] + val usedNames = scala.collection.mutable.Map.empty[File, Set[String]].withDefaultValue(Set.empty) + val apis: scala.collection.mutable.Map[File, SourceAPI] = scala.collection.mutable.Map.empty + + def sourceDependency(dependsOn: File, source: File, inherited: Boolean): Unit = { + val context = if(inherited) DependencyByInheritance else DependencyByMemberRef + sourceDependency(dependsOn, source, context) + } + def sourceDependency(dependsOn: File, source: File, context: DependencyContext): Unit = { sourceDependencies += ((dependsOn, source, context)) } + def binaryDependency(binary: File, name: String, source: File, inherited: Boolean): Unit = { + val context = if(inherited) DependencyByInheritance else DependencyByMemberRef + binaryDependency(binary, name, source, context) + } + def binaryDependency(binary: File, name: String, source: File, context: DependencyContext): Unit = { binaryDependencies += ((binary, name, source, context)) } + def generatedClass(source: File, module: File, name: String): Unit = { products += ((source, module, name)) } + + def usedName(source: File, name: String): Unit = { usedNames(source) += name } + def api(source: File, sourceAPI: SourceAPI): Unit = { + assert(!apis.contains(source), s"The `api` method should be called once per source file: $source") + apis(source) = sourceAPI + } + def problem(category: String, pos: xsbti.Position, message: String, severity: xsbti.Severity, reported: Boolean): Unit = () +} |