Skip to content

Commit 9c0cb9c

Browse files
committed
reporting callback merged into compiler callback
1 parent 3b8efbc commit 9c0cb9c

File tree

5 files changed

+23
-35
lines changed

5 files changed

+23
-35
lines changed

src/dotty/tools/dotc/Driver.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dotty.tools.dotc
22

33
import config.CompilerCommand
44
import core.Contexts.{Context, ContextBase}
5-
import dotty.tools.dotc.callbacks.{ReportingCallback, CompilerCallback}
5+
import callbacks.CompilerCallback
66
import util.DotClass
77
import reporting._
88
import scala.util.control.NonFatal
@@ -37,7 +37,7 @@ abstract class Driver extends DotClass {
3737
val summary = CompilerCommand.distill(args)(rootCtx)
3838
// FIXME: We should reuse rootCtx instead of creating newCtx, but this
3939
// makes some tests fail with "denotation module _root_ invalid in run 2."
40-
val newCtx = initCtx.setCompilerCallback(rootCtx.compilerCallback).setReportingCallback(rootCtx.reportingCallback)
40+
val newCtx = initCtx.setCompilerCallback(rootCtx.compilerCallback)
4141
implicit val ctx: Context = newCtx.fresh.setSettings(summary.sstate)
4242
val fileNames = CompilerCommand.checkUsage(summary, sourcesRequired)
4343
(fileNames, ctx)
@@ -48,8 +48,8 @@ abstract class Driver extends DotClass {
4848
doCompile(newCompiler(), fileNames)(ctx)
4949
}
5050

51-
def process(args: Array[String], callback: CompilerCallback, reportingCallback: ReportingCallback): Reporter = {
52-
process(args, initCtx.setCompilerCallback(callback).setReportingCallback(reportingCallback))
51+
def process(args: Array[String], callback: CompilerCallback): Reporter = {
52+
process(args, initCtx.setCompilerCallback(callback))
5353
}
5454

5555
// We overload `process` instead of using a default argument so that we

src/dotty/tools/dotc/callbacks/CompilerCallback.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,16 @@ public interface CompilerCallback {
5151
/** Called to show progress of the compilation process
5252
*/
5353
void advance(int currentProgress, int totalProgress);
54+
55+
//Methods to pass compiler and debug messages and exceptions
56+
57+
void info(String msg, Position pos);
58+
59+
void warning(String msg, Position pos);
60+
61+
void error(String msg, Position pos);
62+
63+
void debug(String msg);
64+
65+
void trace(Throwable exception);
5466
}

src/dotty/tools/dotc/callbacks/ReportingCallback.java

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import NameOps._
1313
import Uniques._
1414
import SymDenotations._
1515
import Flags.ParamAccessor
16-
import dotty.tools.dotc.callbacks.{CompilerCallback, ReportingCallback}
16+
import callbacks.CompilerCallback
1717
import util.Positions._
1818
import ast.Trees._
1919
import ast.untpd
@@ -78,11 +78,6 @@ object Contexts {
7878
base.compilerCallback = callback; this
7979
}
8080

81-
/** Set the reporting callback, shared by all contexts with the same `base` */
82-
def setReportingCallback(callback: ReportingCallback): this.type = {
83-
base.reportingCallback = callback; this
84-
}
85-
8681
/** The outer context */
8782
private[this] var _outer: Context = _
8883
protected def outer_=(outer: Context) = _outer = outer
@@ -546,8 +541,6 @@ object Contexts {
546541
/** The compiler callback implementation, or null if unset */
547542
var compilerCallback: CompilerCallback = _
548543

549-
var reportingCallback: ReportingCallback = _
550-
551544
// Symbols state
552545

553546
/** A counter for unique ids */

src/dotty/tools/dotc/reporting/Reporter.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,14 @@ abstract class Reporter {
268268
}
269269

270270
private def doCallbackReport(d: Diagnostic)(implicit ctx: Context): Unit = {
271-
val reportingCallback = ctx.reportingCallback
272-
if (reportingCallback != null) {
271+
val callback = ctx.compilerCallback
272+
if (callback != null) {
273273
val position = if (d.pos.exists) new CallbackPositionAdapter(d.pos) else null
274274
d match {
275-
case d: ConditionalWarning if d.enablingOption.value => reportingCallback.warning(d.msg, position)
276-
case d: Warning => reportingCallback.warning(d.msg, position)
277-
case d: Error => reportingCallback.error(d.msg, position)
278-
case d: Info => reportingCallback.info(d.msg, position)
275+
case d: ConditionalWarning if d.enablingOption.value => callback.warning(d.msg, position)
276+
case d: Warning => callback.warning(d.msg, position)
277+
case d: Error => callback.error(d.msg, position)
278+
case d: Info => callback.info(d.msg, position)
279279
}
280280
}
281281
}

0 commit comments

Comments
 (0)