Add total reset to repl history and state interfaces

This commit is contained in:
Ilya Chernikov
2017-03-25 14:31:59 +01:00
parent c746cae72d
commit 8cc576d44f
10 changed files with 68 additions and 11 deletions
@@ -37,10 +37,12 @@ class RemoteReplCompilerStateHistory(private val state: RemoteReplCompilerState)
throw NotImplementedError("pop from remote history is not supported")
}
override fun reset(): Iterable<ILineId> = state.replStateFacade.historyReset().apply {
currentGeneration.incrementAndGet()
}
override fun resetTo(id: ILineId): Iterable<ILineId> = state.replStateFacade.historyResetTo(id).apply {
if (isNotEmpty()) {
currentGeneration.incrementAndGet()
}
currentGeneration.incrementAndGet()
}
val currentGeneration = AtomicInteger(REPL_CODE_LINE_FIRST_GEN)
@@ -31,6 +31,9 @@ interface ReplStateFacade : Remote {
@Throws(RemoteException::class)
fun historyGet(index: Int): ILineId
@Throws(RemoteException::class)
fun historyReset(): List<ILineId>
@Throws(RemoteException::class)
fun historyResetTo(id: ILineId): List<ILineId>
}
@@ -35,5 +35,7 @@ class RemoteReplStateFacadeServer(val _id: Int,
override fun historyGet(index: Int): ILineId = state.history[index].id
override fun historyReset(): List<ILineId> = state.history.reset().toList()
override fun historyResetTo(id: ILineId): List<ILineId> = state.history.resetTo(id).toList()
}