From ccf7f8ae4e09c1e5cbbc52d64ff0358203d29d5c Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Wed, 2 Dec 2015 16:26:12 +0100 Subject: Add initial CompilerCallback implementation for IntelliJ This adds some simple callbacks to Dotty that should be enough to get basic integration from IntelliJ. --- src/dotty/tools/backend/jvm/GenBCode.scala | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/dotty/tools/backend/jvm/GenBCode.scala') diff --git a/src/dotty/tools/backend/jvm/GenBCode.scala b/src/dotty/tools/backend/jvm/GenBCode.scala index feaae036b..e8d196ce7 100644 --- a/src/dotty/tools/backend/jvm/GenBCode.scala +++ b/src/dotty/tools/backend/jvm/GenBCode.scala @@ -23,6 +23,7 @@ import Symbols._ import Denotations._ import Phases._ import java.lang.AssertionError +import java.io.{ File => JFile } import scala.tools.asm import scala.tools.asm.tree._ import dotty.tools.dotc.util.{Positions, DotClass} @@ -47,6 +48,8 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter var tree: Tree = _ + val sourceJFile: JFile = ctx.compilationUnit.source.file.file + final class PlainClassBuilder(cunit: CompilationUnit) extends SyncAndTryBuilder(cunit) @@ -300,6 +303,9 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter bytecodeWriter.close() // Statistics.stopTimer(BackendStats.bcodeTimer, bcodeStart) + if (ctx.compilerCallback != null) + ctx.compilerCallback.onSourceCompiled(sourceJFile) + /* TODO Bytecode can be verified (now that all classfiles have been written to disk) * * (1) asm.util.CheckAdapter.verify() @@ -363,6 +369,11 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter if (outFolder == null) null else getFileForClassfile(outFolder, jclassName, ".class") bytecodeWriter.writeClass(jclassName, jclassName, jclassBytes, outFile) + + val outJFile = outFile.file + val className = jclassName.replace('/', '.') + if (ctx.compilerCallback != null) + ctx.compilerCallback.onClassGenerated(sourceJFile, outJFile, className) } catch { case e: FileConflictException => -- cgit v1.2.3