Skip to content

Commit a1c5c5e

Browse files
authored
Merge pull request #320 from shivam71/MoveRefactoring_Fix_Update
Patch Update Move Refactoring Null Fix
2 parents 1814a3e + aa8e6ab commit a1c5c5e

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

patches/7923_draft.diff

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,36 @@
11
diff --git a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/MoveRefactoring.java b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/MoveRefactoring.java
2-
index a72abd44ef..199ffad108 100644
2+
index a72abd44ef..72e8bd68ec 100644
33
--- a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/MoveRefactoring.java
44
+++ b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/MoveRefactoring.java
5-
@@ -423,7 +423,7 @@ public final class MoveRefactoring extends CodeRefactoring {
5+
@@ -420,18 +420,26 @@ public final class MoveRefactoring extends CodeRefactoring {
6+
}
7+
8+
private static Project getSelectedProject(NamedPath selectedProject) {
9+
+ String path = selectedProject == null ? null : selectedProject.getPath();
10+
+ if (path == null) {
11+
+ return null;
12+
+ }
13+
+ FileObject file;
614
try {
7-
String path = selectedProject.getPath();
8-
return path != null ? FileOwnerQuery.getOwner(Utils.fromUri(path)) : null;
9-
- } catch (MalformedURLException ex) {
10-
+ } catch (MalformedURLException | NullPointerException ex) {
11-
return null;
15+
- String path = selectedProject.getPath();
16+
- return path != null ? FileOwnerQuery.getOwner(Utils.fromUri(path)) : null;
17+
+ file = Utils.fromUri(path);
18+
} catch (MalformedURLException ex) {
19+
- return null;
20+
+ file = null;
1221
}
22+
+ return file == null ? null : FileOwnerQuery.getOwner(file);
1323
}
14-
@@ -432,7 +432,7 @@ public final class MoveRefactoring extends CodeRefactoring {
24+
25+
private static FileObject getSelectedRoot(NamedPath selectedRoot) {
26+
+ String path = selectedRoot == null ? null : selectedRoot.getPath();
27+
+ if (path == null) {
28+
+ return null;
29+
+ }
1530
try {
16-
String path = selectedRoot.getPath();
17-
return path != null ? Utils.fromUri(path) : null;
18-
- } catch (MalformedURLException ex) {
19-
+ } catch (MalformedURLException | NullPointerException ex) {
31+
- String path = selectedRoot.getPath();
32+
- return path != null ? Utils.fromUri(path) : null;
33+
+ return Utils.fromUri(path);
34+
} catch (MalformedURLException ex) {
2035
return null;
2136
}
22-
}

0 commit comments

Comments
 (0)