[debugger] IDEA-358371 Hotswap should include all modified files even after compilation error

(cherry picked from commit 240ee34eba159e66c4ac235f4b43a0b1a3183876)

IJ-CR-147930

GitOrigin-RevId: 4d044a371864323f4728c7cd2caa67ab03d233ad
This commit is contained in:
Maksim Zuev
2024-10-28 11:28:51 +01:00
committed by intellij-monorepo-bot
parent 96cf4c153e
commit 044d678968
4 changed files with 27 additions and 3 deletions

View File

@@ -77,8 +77,8 @@ private class HotSwapStatusListenerAdapter(private val originalSession: Debugger
}
override fun onFailure(sessions: MutableList<DebuggerSession>?) {
sessions?.createListeners(originalSession)?.forEach { it.onFinish() }
listener.onFinish()
sessions?.createListeners(originalSession)?.forEach { it.onFailure() }
listener.onFailure()
}
override fun onCancel(sessions: MutableList<DebuggerSession>?) {

View File

@@ -174,6 +174,10 @@ class HotSwapSession<T> internal constructor(val project: Project, internal val
completeHotSwap(true, HotSwapVisibleStatus.NO_CHANGES)
}
override fun onFailure() {
completeHotSwap(resetChanges = false, HotSwapVisibleStatus.NO_CHANGES)
}
override fun onCanceled() {
completeHotSwap(false, statusBefore)
}

View File

@@ -48,11 +48,17 @@ interface HotSwapResultListener {
fun onSuccessfulReload()
/**
* Hot swap completed, a notification or error message is shown by a [HotSwapProvider].
* Hot swap completed with no result, a notification or error message is shown by a [HotSwapProvider].
* Previous modifications are considered obsolete.
*/
fun onFinish()
/**
* Hot swap failed (compilation error or hot swap is not possible), an error message is shown by a [HotSwapProvider].
* Previous modifications are considered active.
*/
fun onFailure()
/**
* Hot swap was canceled, previous modifications are still actual.
*/

View File

@@ -137,6 +137,20 @@ class HotSwapSessionManagerTest : HeavyPlatformTestCase() {
assertEquals(HotSwapVisibleStatus.CHANGES_READY, list.last())
assertEquals(1, hotSwapSession.getChanges().size)
}
run {
val start = 9
assertEquals(1, hotSwapSession.getChanges().size)
assertEquals(start, list.size)
assertEquals(HotSwapVisibleStatus.CHANGES_READY, list.last())
val listener = provider.performHotSwap(hotSwapSession)
assertEquals(start + 1, list.size)
assertEquals(HotSwapVisibleStatus.IN_PROGRESS, list.last())
listener.onFailure()
assertEquals(start + 2, list.size)
assertEquals(HotSwapVisibleStatus.NO_CHANGES, list.last())
assertEquals(1, hotSwapSession.getChanges().size)
}
}
finally {
Disposer.dispose(disposable)