Handle compilation cancellation properly.

Incremental compiler didn't have any explicit logic to handle
cancelled compilation so it would go into inconsistent state.

Specifically, what would happen is that it would treat cancelled
compilation as a compilation that finished normally and try to
produce a new Analysis object out of partial information collected
in AnalysisCallback. The most obvious outcome would be that the
new Analysis would contain latest hashes for source files. The
next time incremental compiler was asked to recompile the same files
that it didn't recompile due to cancelled compilation it would think
they were already successfully compiled and would do nothing.

We fix that problem by following the same logic that handles compilation
errors, cleans up partial results (produced class files) and makes sure
that no Analysis is created out of broken state.

We do that by introducing a new exception `CompileCancelled`
and throwing it at the same spot as an exception signalizing compilation
errors is being thrown. We also modify `IncrementalCompile` to
catch that exception and gracefully return as there was no compilation
invoked.

NOTE: In case there were compilation errors reported _before_
compilation cancellations was requested we'll still report them
using an old mechanism so partial errors are not lost in case
of cancelled compilation.
This commit is contained in:
Grzegorz Kossakowski 2013-07-19 14:39:26 -07:00
parent 577424fe70
commit 66a48b08c7
1 changed files with 9 additions and 0 deletions

View File

@ -0,0 +1,9 @@
package xsbti;
/**
* An exception thrown when compilation cancellation has been requested during
* Scala compiler run.
*/
public abstract class CompileCancelled extends RuntimeException {
public abstract String[] arguments();
}