-
-
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.
- Loading branch information
1 parent
7548ac6
commit a0eee40
Showing
9 changed files
with
126 additions
and
24 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
File renamed without changes.
55 changes: 55 additions & 0 deletions
55
amm/interp/src/main/scala-2.12.13+/ammonite/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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package ammonite.interp | ||
|
||
import ammonite.runtime.Classpath | ||
|
||
import scala.reflect.internal.util.Position | ||
import scala.reflect.io.FileZipArchive | ||
import scala.tools.nsc | ||
import scala.tools.nsc.classpath.{AggregateClassPath, ZipAndJarClassPathFactory} | ||
import scala.tools.nsc.{Global, Settings} | ||
import scala.tools.nsc.interactive.{InteractiveAnalyzer, Global => InteractiveGlobal} | ||
import scala.tools.nsc.plugins.Plugin | ||
import scala.tools.nsc.reporters.Reporter | ||
import scala.tools.nsc.typechecker.Analyzer | ||
|
||
object CompilerCompatibility { | ||
|
||
def analyzer(g: Global, cl: ClassLoader): Analyzer { val global: g.type } = { | ||
new { val global: g.type = g } with Analyzer { | ||
override def findMacroClassLoader() = cl | ||
} | ||
} | ||
|
||
def interactiveAnalyzer(g: InteractiveGlobal, | ||
cl: ClassLoader): InteractiveAnalyzer { val global: g.type } = { | ||
new { val global: g.type = g } with InteractiveAnalyzer | ||
} | ||
|
||
def importInfo(g: Global)(t: g.Import) = | ||
new g.analyzer.ImportInfo(t, 0) | ||
|
||
def initGlobal(settings: Settings, | ||
reporter: Reporter, | ||
jcp: AggregateClassPath, | ||
evalClassloader: ClassLoader, | ||
createPlugins: Global => List[Plugin]): Global = { | ||
|
||
new nsc.Global(settings, reporter) { g => | ||
override lazy val plugins = createPlugins(g) | ||
|
||
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.analyzer(g, evalClassloader) | ||
} | ||
} | ||
|
||
def createZipJarFactory(arc: FileZipArchive, settings: Settings) = { | ||
ZipAndJarClassPathFactory.create(arc, settings, new scala.tools.nsc.CloseableRegistry()) | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
amm/interp/src/main/scala-2.12.13+/ammonite/interp/MakeReporter.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,43 @@ | ||
package ammonite.interp | ||
|
||
import ammonite.runtime.Classpath | ||
|
||
import scala.reflect.internal.util.Position | ||
import scala.reflect.io.FileZipArchive | ||
import scala.tools.nsc | ||
import scala.tools.nsc.classpath.{AggregateClassPath, ZipAndJarClassPathFactory} | ||
import scala.tools.nsc.{Global, Settings} | ||
import scala.tools.nsc.interactive.{InteractiveAnalyzer, Global => InteractiveGlobal} | ||
import scala.tools.nsc.plugins.Plugin | ||
import scala.tools.nsc.reporters.FilteringReporter | ||
import scala.tools.nsc.typechecker.Analyzer | ||
|
||
object MakeReporter { | ||
|
||
type Reporter = scala.tools.nsc.reporters.Reporter | ||
|
||
def makeReporter(errorLogger: (Position, String) => Unit, | ||
warningLogger: (Position, String) => Unit, | ||
infoLogger: (Position, String) => Unit, | ||
outerSettings: Settings): Reporter = | ||
new FilteringReporter { | ||
|
||
def doReport(pos: scala.reflect.internal.util.Position, | ||
msg: String, | ||
severity: Severity): Unit = | ||
display(pos, msg, severity) | ||
|
||
def display(pos: Position, msg: String, severity: Severity) = | ||
severity match{ | ||
case ERROR => | ||
Classpath.traceClasspathProblem(s"ERROR: $msg") | ||
errorLogger(pos, msg) | ||
case WARNING => | ||
warningLogger(pos, msg) | ||
case INFO => | ||
infoLogger(pos, msg) | ||
} | ||
|
||
def settings = outerSettings | ||
} | ||
} |
File renamed without changes.
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