15
15
package scala .tools
16
16
package xsbt
17
17
18
- import xsbti .{ AnalysisCallback , Logger , Problem , Reporter , VirtualFile }
18
+ import xsbti .{AnalysisCallback , AnalysisCallback2 , Logger , Problem , Reporter , VirtualFile }
19
19
import xsbti .compile ._
20
+
20
21
import scala .tools .nsc .Settings
21
22
import scala .collection .mutable
22
23
import scala .reflect .io .AbstractFile
23
24
import scala .tools .nsc .CompilerCommand
24
25
import Log .debug
25
26
import java .io .File
27
+ import java .util .{Collections , Optional }
26
28
27
29
/**
28
30
* This is the entry point for the compiler bridge (implementation of CompilerInterface)
@@ -154,6 +156,14 @@ private final class CachedCompiler0(
154
156
compileProgress : CompileProgress
155
157
): Unit = {
156
158
159
+ lazy val callback2 =
160
+ try callback.asInstanceOf [AnalysisCallback2 ]
161
+ catch { case _ : NoClassDefFoundError => null }
162
+
163
+ def callbackProblem (p : Problem ) =
164
+ if (callback2 != null ) callback2.problem2(p.category, p.position, p.message, p.severity, true , p.rendered, p.diagnosticCode, p.diagnosticRelatedInformation, p.actions)
165
+ else callback.problem(p.category, p.position, p.message, p.severity, true )
166
+
157
167
if (command.shouldStopWithInfo) {
158
168
underlyingReporter.info(null , command.getInfoMessage(compiler), true )
159
169
throw new InterfaceCompileFailed (args, Array (), StopInfoError )
@@ -165,10 +175,7 @@ private final class CachedCompiler0(
165
175
val run = new compiler.ZincRun (compileProgress)
166
176
167
177
run.compileFiles(sources)
168
- processUnreportedWarnings(run)
169
- underlyingReporter.problems.foreach(p =>
170
- callback.problem(p.category, p.position, p.message, p.severity, true )
171
- )
178
+ underlyingReporter.problems.foreach(callbackProblem)
172
179
}
173
180
174
181
underlyingReporter.printSummary()
@@ -192,18 +199,4 @@ private final class CachedCompiler0(
192
199
debug(log, " Compilation cancelled (CompilerInterface)" )
193
200
throw new InterfaceCompileCancelled (args, " Compilation has been cancelled" )
194
201
}
195
-
196
- def processUnreportedWarnings (run : compiler.Run ): Unit = {
197
- // allConditionalWarnings and the ConditionalWarning class are only in 2.10+
198
- final class CondWarnCompat (
199
- val what : String ,
200
- val warnings : mutable.ListBuffer [(compiler.Position , String )]
201
- )
202
- implicit def compat (run : AnyRef ): Compat = new Compat
203
- final class Compat { def allConditionalWarnings = List [CondWarnCompat ]() }
204
-
205
- val warnings = run.allConditionalWarnings
206
- if (warnings.nonEmpty)
207
- compiler.logUnreportedWarnings(warnings.map(cw => (" " /* cw.what*/ , cw.warnings.toList)))
208
- }
209
202
}
0 commit comments