From cf8d7fbdff562f7c365c90ceab9cd0bf38100909 Mon Sep 17 00:00:00 2001 From: fkorotkov Date: Thu, 10 Sep 2015 16:35:09 -0700 Subject: [PATCH] Use getPosition method to get an offset position instead of using line number --- .../scala/sbt/compiler/javac/DiagnosticsReporter.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compile/src/main/scala/sbt/compiler/javac/DiagnosticsReporter.scala b/compile/src/main/scala/sbt/compiler/javac/DiagnosticsReporter.scala index 49c3fb54a..bb1b144e6 100644 --- a/compile/src/main/scala/sbt/compiler/javac/DiagnosticsReporter.scala +++ b/compile/src/main/scala/sbt/compiler/javac/DiagnosticsReporter.scala @@ -76,11 +76,12 @@ final class DiagnosticsReporter(reporter: Reporter) extends DiagnosticListener[J val diagnostic = d.getClass.getField("d").get(d) // See com.sun.tools.javac.util.JCDiagnostic#getDiagnosticSource val getDiagnosticSourceMethod = diagnostic.getClass.getDeclaredMethod("getDiagnosticSource") - Option(getDiagnosticSourceMethod.invoke(diagnostic)) match { - case Some(diagnosticSource) => + val getPositionMethod = diagnostic.getClass.getDeclaredMethod("getPosition") + (Option(getDiagnosticSourceMethod.invoke(diagnostic)), Option(getPositionMethod.invoke(diagnostic))) match { + case (Some(diagnosticSource), Some(position: java.lang.Long)) => // See com.sun.tools.javac.util.DiagnosticSource val getLineMethod = diagnosticSource.getClass.getMethod("getLine", Integer.TYPE) - Option(getLineMethod.invoke(diagnosticSource, line.get())).map(_.toString) + Option(getLineMethod.invoke(diagnosticSource, new Integer(position.intValue()))).map(_.toString) case _ => None } } catch {