-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add callback object to Context capable of recording progress
- Loading branch information
1 parent
15033c7
commit 721888d
Showing
7 changed files
with
90 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
compiler/src/dotty/tools/dotc/sbt/interfaces/ProgressCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package dotty.tools.dotc.sbt.interfaces; | ||
|
||
import dotty.tools.dotc.CompilationUnit; | ||
|
||
public interface ProgressCallback { | ||
/** Record that the cancellation signal has been recieved during the Zinc run. */ | ||
default void cancel() {} | ||
|
||
/** Report on if there was a cancellation signal for the current Zinc run. */ | ||
default boolean isCancelled() { return false; } | ||
|
||
/** Record that a unit has started compiling in the given phase. */ | ||
default void informUnitStarting(String phase, CompilationUnit unit) {} | ||
|
||
/** Record the current compilation progress. | ||
* @param current `completedPhaseCount * totalUnits + completedUnitsInCurrPhase + completedLate` | ||
* @param total `totalPhases * totalUnits + totalLate` | ||
* @return true if the compilation should continue (if false, then subsequent calls to `isCancelled()` will return true) | ||
*/ | ||
default boolean progress(int current, int total, String currPhase, String nextPhase) { return true; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package dotty.tools.xsbt; | ||
|
||
import dotty.tools.dotc.sbt.interfaces.ProgressCallback; | ||
import dotty.tools.dotc.CompilationUnit; | ||
|
||
import xsbti.compile.CompileProgress; | ||
|
||
public final class ProgressCallbackImpl implements ProgressCallback { | ||
private boolean _cancelled = false; | ||
private final CompileProgress _progress; | ||
|
||
public ProgressCallbackImpl(CompileProgress progress) { | ||
_progress = progress; | ||
} | ||
|
||
@Override | ||
public void cancel() { | ||
_cancelled = true; | ||
} | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return _cancelled; | ||
} | ||
|
||
@Override | ||
public void informUnitStarting(String phase, CompilationUnit unit) { | ||
_progress.startUnit(phase, unit.source().file().path()); | ||
} | ||
|
||
@Override | ||
public boolean progress(int current, int total, String currPhase, String nextPhase) { | ||
boolean shouldAdvance = _progress.advance(current, total, currPhase, nextPhase); | ||
if (!shouldAdvance) cancel(); | ||
return shouldAdvance; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package xsbt | ||
|
||
import xsbti.compile.CompileProgress | ||
|
||
class TestCompileProgress extends CompileProgress |