72
72
import org .eclipse .lsp4j .jsonrpc .messages .Either ;
73
73
import org .eclipse .lsp4j .jsonrpc .messages .Either3 ;
74
74
import org .netbeans .modules .java .lsp .server .protocol .ShowStatusMessageParams ;
75
+ import org .openide .util .NbBundle ;
75
76
import org .openide .util .lookup .ServiceProvider ;
76
77
77
78
/**
78
79
*
79
80
* @author atalati
80
81
*/
81
82
@ ServiceProvider (service = NotebookDocumentServiceHandler .class )
83
+ @ NbBundle .Messages ({"kernel.initializing=Intializing Java kernel for notebook." ,
84
+ "kernel.initialize.success=Java kernel initialized successfully." ,
85
+ "kernel.initialize.failed=Error could not initialize Java kernel for the notebook." })
82
86
public class NotebookDocumentServiceHandlerImpl implements NotebookDocumentServiceHandler {
83
87
84
88
private static final Logger LOG = Logger .getLogger (NotebookDocumentServiceHandler .class .getName ());
@@ -93,13 +97,13 @@ public void didOpen(DidOpenNotebookDocumentParams params) {
93
97
if (client == null ) {
94
98
return ;
95
99
}
96
- client .showStatusBarMessage (new ShowStatusMessageParams (MessageType .Info , "Intializing Java kernel for notebook." ));
100
+ client .showStatusBarMessage (new ShowStatusMessageParams (MessageType .Info , Bundle . kernel_initializing () ));
97
101
NotebookSessionManager .getInstance ().createSession (params .getNotebookDocument ()).whenComplete ((JShell jshell , Throwable t ) -> {
98
102
if (t == null ) {
99
- client .showStatusBarMessage (new ShowStatusMessageParams (MessageType .Info , "Java kernel initialized successfully" ));
103
+ client .showStatusBarMessage (new ShowStatusMessageParams (MessageType .Info , Bundle . kernel_initialize_success () ));
100
104
} else {
101
105
// if package import fails user is not informed ?
102
- client .showMessage (new MessageParams (MessageType .Error , "Error could not initialize Java kernel for the notebook." ));
106
+ client .showMessage (new MessageParams (MessageType .Error , Bundle . kernel_initialize_failed () ));
103
107
LOG .log (Level .SEVERE , "Error could not initialize Java kernel for the notebook. : {0}" , t .getMessage ());
104
108
}
105
109
});
@@ -130,12 +134,7 @@ public void didClose(DidCloseNotebookDocumentParams params) {
130
134
String notebookUri = params .getNotebookDocument ().getUri ();
131
135
NotebookSessionManager .getInstance ().closeSession (notebookUri );
132
136
notebookStateMap .remove (notebookUri );
133
-
134
- // notebookCellMap.forEach((k,v) ->{
135
- // if(params.getNotebookDocument().getUri().equals(v)){
136
- // notebookCellMap.remove(k);
137
- // }
138
- // });
137
+ notebookCellMap .entrySet ().removeIf (entry -> notebookUri .equals (entry .getValue ()));
139
138
}
140
139
141
140
@ Override
@@ -252,5 +251,5 @@ public CompletableFuture<List<InlayHint>> inlayHint(InlayHintParams params) {
252
251
@ Override
253
252
public CompletableFuture <List <InlineValue >> inlineValue (InlineValueParams params ) {
254
253
return CompletableFuture .completedFuture (new ArrayList <>());
255
- }
254
+ }
256
255
}
0 commit comments