File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
nbcode/notebooks/src/org/netbeans/modules/nbcode/java/notebook Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 1515 */
1616package org .netbeans .modules .nbcode .java .notebook ;
1717
18+ import com .google .gson .JsonElement ;
1819import com .google .gson .JsonObject ;
1920import java .net .URI ;
21+ import java .nio .file .Path ;
2022import java .nio .file .Paths ;
2123import java .util .ArrayList ;
2224import java .util .HashMap ;
@@ -252,11 +254,19 @@ public void closeSession(String notebookUri) {
252254
253255 private CompletableFuture <Project > getProjectContextForNotebook (String notebookUri ) {
254256 JsonObject mapping = NotebookConfigs .getInstance ().getNotebookProjectMapping ();
255- String notebookPath = URI .create (notebookUri ).getPath ();
256- String projectKey = mapping .has (notebookPath )
257- ? Paths .get (mapping .get (notebookPath ).getAsString ()).toUri ().toString ()
258- : notebookUri ;
259257
258+ URI uri = URI .create (notebookUri );
259+ String path = Path .of (uri ).toAbsolutePath ().toString ();
260+ JsonElement el = mapping .get (path );
261+
262+ String value = null ;
263+ if (el != null && el .isJsonPrimitive () && el .getAsJsonPrimitive ().isString ()) {
264+ value = Paths .get (el .getAsString ()).toUri ().toString ();
265+ }
266+
267+ String projectKey = value != null ? value : notebookUri ;
268+
269+ LOG .log (Level .FINE , "projectKey: {0}" , projectKey );
260270 Project prj = ProjectContext .getProject (projectKey );
261271
262272 if (prj == null ) {
You can’t perform that action at this time.
0 commit comments