-
-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* . * . * . * wip * update travis * tweak appveyor * mill 041 * wrap-lines * Fix already added deps file generation Must have been broken by bumping the coursier version in the build via mill. * 2.13.0-M5 -> 2.13.0 in .travis.yml * bump scalatags version * fix-tests * fix * fix * tweak * readme * workaround for scala/bug#11564 * 1.6.8 .
- Loading branch information
Showing
35 changed files
with
276 additions
and
222 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
82 changes: 0 additions & 82 deletions
82
amm/interp/src/main/scala-2.11/ammonite/interp/GlobalInitCompat.scala
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion
3
...13/ammonite/interp/GlobalInitCompat.scala → ...12/ammonite/interp/GlobalInitCompat.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
21 changes: 11 additions & 10 deletions
21
...monite/interp/CompilerCompatibility.scala → ...monite/interp/CompilerCompatibility.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 |
---|---|---|
@@ -1,32 +1,33 @@ | ||
package ammonite.interp | ||
|
||
|
||
import scala.tools.nsc.Global | ||
import scala.tools.nsc.interactive.{ Global => InteractiveGlobal } | ||
import scala.tools.nsc.interactive.{Global => InteractiveGlobal} | ||
import scala.tools.nsc.plugins.Plugin | ||
import scala.tools.nsc.typechecker.Analyzer | ||
|
||
object CompilerCompatibility extends ExtraCompilerCompatibility { | ||
def newUnitParser(compiler: Global, line: String, fileName: String) = { | ||
compiler.newUnitParser(line, fileName) | ||
} | ||
def analyzer(g: Global, cl: ClassLoader): Analyzer { val global: g.type } = | ||
def analyzer(g: Global, cl: ClassLoader): Analyzer { val global: g.type } = { | ||
new { val global: g.type = g } with Analyzer { | ||
override def findMacroClassLoader() = cl | ||
override def defaultMacroClassloader = global.findMacroClassLoader | ||
} | ||
} | ||
|
||
type InteractiveAnalyzer = scala.tools.nsc.interactive.InteractiveAnalyzer | ||
|
||
def interactiveAnalyzer(g: InteractiveGlobal, cl: ClassLoader) | ||
: InteractiveAnalyzer { val global: g.type } = | ||
def interactiveAnalyzer(g: InteractiveGlobal, | ||
cl: ClassLoader): InteractiveAnalyzer { val global: g.type } = { | ||
new { val global: g.type = g } with InteractiveAnalyzer { | ||
override def findMacroClassLoader() = cl | ||
} | ||
} | ||
|
||
def trees(g: Global)(parser: g.syntaxAnalyzer.UnitParser): Seq[Global#Tree] = | ||
def trees(g: Global)(parser: g.syntaxAnalyzer.UnitParser): Seq[Global#Tree] = { | ||
parser.parseStatsOrPackages() | ||
} | ||
|
||
def pluginInit(plugin: Plugin, options: List[String], error: String => Unit): Boolean = | ||
def pluginInit(plugin: Plugin, options: List[String], error: String => Unit): Boolean = { | ||
plugin.init(options, error) | ||
|
||
} | ||
} |
112 changes: 112 additions & 0 deletions
112
amm/interp/src/main/scala-2.13/ammonite/interp/GlobalInitCompat.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,112 @@ | ||
package ammonite.interp | ||
|
||
import ammonite.runtime.Classpath | ||
import scala.reflect.io.{AbstractFile, FileZipArchive, VirtualDirectory} | ||
import scala.tools.nsc | ||
import scala.tools.nsc.classpath._ | ||
import scala.tools.nsc.{CustomZipAndJarFileLookupFactory, Global, Settings} | ||
import scala.tools.nsc.interactive.{Global => InteractiveGlobal} | ||
import scala.tools.nsc.plugins.Plugin | ||
import scala.tools.nsc.reporters.AbstractReporter | ||
|
||
object GlobalInitCompat{ | ||
|
||
def initInteractiveGlobal(settings: Settings, | ||
reporter: AbstractReporter, | ||
jcp: AggregateClassPath, | ||
evalClassloader: ClassLoader): InteractiveGlobal = { | ||
new nsc.interactive.Global(settings, reporter) { g => | ||
// Actually jcp, avoiding a path-dependent type issue in 2.10 here | ||
override def classPath = jcp | ||
|
||
override lazy val platform: ThisPlatform = new GlobalPlatform { | ||
override val global = g | ||
override val settings = g.settings | ||
override val classPath = jcp | ||
} | ||
|
||
override lazy val analyzer = CompilerCompatibility.interactiveAnalyzer(g, evalClassloader) | ||
} | ||
} | ||
|
||
def initGlobal(settings: Settings, | ||
reporter: AbstractReporter, | ||
jcp: AggregateClassPath, | ||
evalClassloader: ClassLoader, | ||
createPlugins: Global => List[Plugin]): Global = { | ||
|
||
new nsc.Global(settings, reporter) { g => | ||
override lazy val plugins = createPlugins(g) | ||
|
||
// Actually jcp, avoiding a path-dependent type issue in 2.10 here | ||
override def classPath = jcp | ||
override def findMacroClassLoader() = evalClassloader | ||
override lazy val platform: ThisPlatform = new GlobalPlatform { | ||
override val global = g | ||
override val settings = g.settings | ||
override val classPath = jcp | ||
} | ||
|
||
override lazy val analyzer = CompilerCompatibility.analyzer(g, evalClassloader) | ||
} | ||
} | ||
|
||
/** | ||
* Code to initialize random bits and pieces that are needed | ||
* for the Scala compiler to function, common between the | ||
* normal and presentation compiler | ||
*/ | ||
def initGlobalClasspath(dirDeps: Seq[java.io.File], | ||
jarDeps: Seq[java.net.URL], | ||
dynamicClasspath: VirtualDirectory, | ||
settings: Settings) = { | ||
|
||
val jarCP = | ||
jarDeps.filter(x => x.getPath.endsWith(".jar") || Classpath.canBeOpenedAsJar(x)) | ||
.map { x => | ||
if (x.getProtocol == "file") { | ||
val arc = new FileZipArchive(java.nio.file.Paths.get(x.toURI).toFile) | ||
ZipAndJarClassPathFactory.create(arc, settings, new scala.tools.nsc.CloseableRegistry()) | ||
} else { | ||
val arc = new internal.CustomURLZipArchive(x) | ||
CustomZipAndJarFileLookupFactory.create(arc, settings) | ||
} | ||
} | ||
.toVector | ||
|
||
val dirCP = dirDeps.map(x => new DirectoryClassPath(x)) | ||
val dynamicCP = new VirtualDirectoryClassPath(dynamicClasspath){ | ||
|
||
override def getSubDir(packageDirName: String): Option[AbstractFile] = { | ||
val pathParts = packageDirName.split('/') | ||
var file: AbstractFile = dir | ||
for (dirPart <- pathParts) { | ||
file = file.lookupName(dirPart, directory = true) | ||
if (file == null) return None | ||
} | ||
Some(file) | ||
|
||
} | ||
override def findClassFile(className: String): Option[AbstractFile] = { | ||
val relativePath = FileUtils.dirPath(className) | ||
val pathParts = relativePath.split('/') | ||
var file: AbstractFile = dir | ||
for (dirPart <- pathParts.init) { | ||
file = file.lookupName(dirPart, directory = true) | ||
if (file == null) return None | ||
} | ||
|
||
file.lookupName(pathParts.last + ".class", directory = false) match { | ||
case null => None | ||
case file => Some(file) | ||
} | ||
} | ||
|
||
} | ||
|
||
val jcp = new AggregateClassPath(jarCP ++ dirCP ++ Seq(dynamicCP)) | ||
|
||
|
||
jcp | ||
} | ||
} |
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
Oops, something went wrong.