Skip to content

Commit

Permalink
Merge pull request #6444 from dbalek/dbalek/lsp-npe-fixes
Browse files Browse the repository at this point in the history
LSP: Modified to prevent NPEs.
  • Loading branch information
dbalek authored Sep 13, 2023
2 parents f48f91e + ff8747c commit f75da6e
Show file tree
Hide file tree
Showing 16 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public ConstructorGenerator() {
"DN_GenerateConstructor=Generate Constructor...",
})
public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeActionParams params) throws Exception {
CompilationController info = CompilationController.get(resultIterator.getParserResult());
CompilationController info = resultIterator.getParserResult() != null ? CompilationController.get(resultIterator.getParserResult()) : null;
if (info == null) {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeAction
if (only == null || !only.contains(CodeActionKind.Source)) {
return Collections.emptyList();
}
CompilationController info = CompilationController.get(resultIterator.getParserResult());
CompilationController info = resultIterator.getParserResult() != null ? CompilationController.get(resultIterator.getParserResult()) : null;
if (info == null) {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeAction
if (only == null || !only.contains(CodeActionKind.Source)) {
return Collections.emptyList();
}
CompilationController info = CompilationController.get(resultIterator.getParserResult());
CompilationController info = resultIterator.getParserResult() != null ? CompilationController.get(resultIterator.getParserResult()) : null;
if (info == null) {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public final class GetterSetterGenerator extends CodeActionsProvider {
"DN_GenerateGetterSetterFor=Generate Getter and Setter for \"{0}\"",
})
public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeActionParams params) throws Exception {
CompilationController info = CompilationController.get(resultIterator.getParserResult());
CompilationController info = resultIterator.getParserResult() != null ? CompilationController.get(resultIterator.getParserResult()) : null;
if (info == null) {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeAction
if (only == null || !only.contains(CodeActionKind.Source)) {
return Collections.emptyList();
}
CompilationController info = CompilationController.get(resultIterator.getParserResult());
CompilationController info = resultIterator.getParserResult() != null ? CompilationController.get(resultIterator.getParserResult()) : null;
if (info == null) {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeAction
if (only == null || !only.contains(CodeActionKind.Source)) {
return Collections.emptyList();
}
CompilationController info = CompilationController.get(resultIterator.getParserResult());
CompilationController info = resultIterator.getParserResult() != null ? CompilationController.get(resultIterator.getParserResult()) : null;
if (info == null) {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeAction
if (only == null || !only.contains(CodeActionKind.Source) && !only.contains(CodeActionKind.SourceOrganizeImports)) {
return Collections.emptyList();
}
CompilationController info = CompilationController.get(resultIterator.getParserResult());
CompilationController info = resultIterator.getParserResult() != null ? CompilationController.get(resultIterator.getParserResult()) : null;
if (info == null) {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public final class SurroundWithHint extends CodeActionsProvider {
"DN_SurroundWithAll=Surround with ...",
})
public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeActionParams params) throws Exception {
CompilationController info = CompilationController.get(resultIterator.getParserResult());
CompilationController info = resultIterator.getParserResult() != null ? CompilationController.get(resultIterator.getParserResult()) : null;
if (info == null) {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public final class TestClassGenerator extends CodeActionsProvider {
"DN_GenerateTestClass=Create Test Class [{0} in {1}]"
})
public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeActionParams params) throws Exception {
CompilationController info = CompilationController.get(resultIterator.getParserResult());
CompilationController info = resultIterator.getParserResult() != null ? CompilationController.get(resultIterator.getParserResult()) : null;
if (info == null) {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ public void run(ResultIterator resultIterator) throws Exception {
}
if (client.getNbCodeCapabilities().wantsJavaSupport()) {
//introduce hints:
CompilationController cc = CompilationController.get(resultIterator.getParserResult());
CompilationController cc = resultIterator.getParserResult() != null ? CompilationController.get(resultIterator.getParserResult()) : null;
if (cc != null) {
cc.toPhase(JavaSource.Phase.RESOLVED);
if (!range.getStart().equals(range.getEnd())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeAction
if (only == null || !only.contains(CodeActionKind.Source)) {
return Collections.emptyList();
}
CompilationController info = CompilationController.get(resultIterator.getParserResult());
CompilationController info = resultIterator.getParserResult() != null ? CompilationController.get(resultIterator.getParserResult()) : null;
if (info == null) {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeAction
if (only == null || !only.contains(CodeActionKind.Refactor)) {
return Collections.emptyList();
}
CompilationController info = CompilationController.get(resultIterator.getParserResult());
CompilationController info = resultIterator.getParserResult() != null ? CompilationController.get(resultIterator.getParserResult()) : null;
if (info == null || !JavaRefactoringUtils.isRefactorable(info.getFileObject())) {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeAction
if (only == null || !only.contains(CodeActionKind.Refactor)) {
return Collections.emptyList();
}
CompilationController info = CompilationController.get(resultIterator.getParserResult());
CompilationController info = resultIterator.getParserResult() != null ? CompilationController.get(resultIterator.getParserResult()) : null;
if (info == null || !JavaRefactoringUtils.isRefactorable(info.getFileObject())) {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeAction
if (only == null || !only.contains(CodeActionKind.Refactor)) {
return Collections.emptyList();
}
CompilationController info = CompilationController.get(resultIterator.getParserResult());
CompilationController info = resultIterator.getParserResult() != null ? CompilationController.get(resultIterator.getParserResult()) : null;
if (info == null || !JavaRefactoringUtils.isRefactorable(info.getFileObject())) {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeAction
if (only == null || !only.contains(CodeActionKind.Refactor)) {
return Collections.emptyList();
}
CompilationController info = CompilationController.get(resultIterator.getParserResult());
CompilationController info = resultIterator.getParserResult() != null ? CompilationController.get(resultIterator.getParserResult()) : null;
if (info == null || !JavaRefactoringUtils.isRefactorable(info.getFileObject())) {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeAction
if (only == null || !only.contains(CodeActionKind.Refactor)) {
return Collections.emptyList();
}
CompilationController info = CompilationController.get(resultIterator.getParserResult());
CompilationController info = resultIterator.getParserResult() != null ? CompilationController.get(resultIterator.getParserResult()) : null;
if (info == null || !JavaRefactoringUtils.isRefactorable(info.getFileObject())) {
return Collections.emptyList();
}
Expand Down

0 comments on commit f75da6e

Please sign in to comment.