@@ -35,11 +35,19 @@ public class CommandHandler {
3535 public static CompletableFuture <List <String >> openJshellInProjectContext (List <Object > args ) {
3636 LOG .log (Level .FINER , "Request received for opening Jshell instance with project context {0}" , args );
3737
38- String uri = NotebookUtils .getArgument (args , 0 , String .class );
39-
40- CompletableFuture <Project > prjFuture = uri == null ? ProjectContext .getProject ()
41- : CompletableFuture .completedFuture (ProjectContext .getProject (uri ));
42-
38+ String context = NotebookUtils .getArgument (args , 0 , String .class );
39+ String additionalContext = NotebookUtils .getArgument (args , 1 , String .class );
40+ CompletableFuture <Project > prjFuture ;
41+
42+ if (context != null ) {
43+ prjFuture = CompletableFuture .completedFuture (ProjectContext .getProject (context ));
44+ } else {
45+ Project editorPrj = additionalContext != null ? ProjectContext .getProject (additionalContext ) : null ;
46+ prjFuture = editorPrj != null
47+ ? ProjectContext .getProject (false , new ProjectContextInfo (editorPrj ))
48+ : ProjectContext .getProject ();
49+ }
50+
4351 return prjFuture .thenCompose (prj -> {
4452 if (prj == null ) {
4553 return CompletableFuture .completedFuture (new ArrayList <>());
@@ -48,7 +56,7 @@ public static CompletableFuture<List<String>> openJshellInProjectContext(List<Ob
4856 .thenCompose (isBuildSuccess -> {
4957 if (isBuildSuccess ) {
5058 List <String > vmOptions = ProjectConfigurationUtils .launchVMOptions (prj );
51- LOG .log (Level .INFO , "Opened Jshell instance with project context {0}" , uri );
59+ LOG .log (Level .INFO , "Opened Jshell instance with project context {0}" , context );
5260 return CompletableFuture .completedFuture (vmOptions );
5361 } else {
5462 CompletableFuture <List <String >> failed = new CompletableFuture <>();
0 commit comments