@@ -9,6 +9,7 @@ import { dispose as disposeTelemetryWrapper, initializeFromJsonFile, instrumentO
99import * as commands from "./commands" ;
1010import { JavaDebugConfigurationProvider } from "./configurationProvider" ;
1111import { HCR_EVENT , JAVA_LANGID , USER_NOTIFICATION_EVENT } from "./constants" ;
12+ import { NotificationBar } from "./customWidget" ;
1213import { initializeCodeLensProvider , startDebugging } from "./debugCodeLensProvider" ;
1314import { handleHotCodeReplaceCustomEvent , initializeHotCodeReplace , NO_BUTTON , YES_BUTTON } from "./hotCodeReplace" ;
1415import { JavaDebugAdapterDescriptorFactory } from "./javaDebugAdapterDescriptorFactory" ;
@@ -50,7 +51,11 @@ function initializeExtension(operationId: string, context: vscode.ExtensionConte
5051 // tslint:disable-next-line
5152 return javaProcess ? String ( javaProcess . pid ) : "${command:PickJavaProcess}" ;
5253 } ) ) ;
53- context . subscriptions . push ( instrumentOperationAsVsCodeCommand ( "java.debug.hotCodeReplace" , applyHCR ) ) ;
54+ const hcrStatusBar : NotificationBar = new NotificationBar ( ) ;
55+ context . subscriptions . push ( hcrStatusBar ) ;
56+ context . subscriptions . push ( instrumentOperationAsVsCodeCommand ( "java.debug.hotCodeReplace" , async ( ) => {
57+ await applyHCR ( hcrStatusBar ) ;
58+ } ) ) ;
5459 context . subscriptions . push ( instrumentOperationAsVsCodeCommand ( "java.debug.runJavaFile" , async ( uri : vscode . Uri ) => {
5560 await runJavaFile ( uri , true ) ;
5661 } ) ) ;
@@ -145,7 +150,7 @@ function specifyProgramArguments(context: vscode.ExtensionContext): Thenable<str
145150 } ) ;
146151}
147152
148- async function applyHCR ( ) {
153+ async function applyHCR ( hcrStatusBar : NotificationBar ) {
149154 const debugSession : vscode . DebugSession = vscode . debug . activeDebugSession ;
150155 if ( ! debugSession ) {
151156 return ;
@@ -178,14 +183,22 @@ async function applyHCR() {
178183 }
179184 }
180185
181- return vscode . window . withProgress ( { location : vscode . ProgressLocation . Window } , async ( progress ) => {
182- progress . report ( { message : "Applying code changes..." } ) ;
186+ hcrStatusBar . show ( "$(sync~spin)Applying code changes..." ) ;
187+ const response = await debugSession . customRequest ( "redefineClasses" ) ;
188+ if ( response && response . errorMessage ) {
189+ // The detailed error message is handled by hotCodeReplace#handleHotCodeReplaceCustomEvent
190+ hcrStatusBar . clear ( ) ;
191+ return ;
192+ }
183193
184- const response = await debugSession . customRequest ( "redefineClasses" ) ;
185- if ( ! response || ! response . changedClasses || ! response . changedClasses . length ) {
186- vscode . window . showWarningMessage ( "Cannot find any changed classes for hot replace!" ) ;
187- }
188- } ) ;
194+ if ( ! response || ! response . changedClasses || ! response . changedClasses . length ) {
195+ hcrStatusBar . clear ( ) ;
196+ vscode . window . showWarningMessage ( "Cannot find any changed classes for hot replace!" ) ;
197+ return ;
198+ }
199+
200+ const changed = response . changedClasses . length ;
201+ hcrStatusBar . show ( "$(check)" + `${ changed } changed class${ changed > 1 ? "es are" : " is" } reloaded!` , 5 * 1000 ) ;
189202}
190203
191204async function runJavaFile ( uri : vscode . Uri , noDebug : boolean ) {
0 commit comments