Skip to content

Commit

Permalink
fix: java.lang.NullPointerException: Parameter specified as non-null is
Browse files Browse the repository at this point in the history
null: method
com.intellij.codeInsight.hints.presentation.PresentationFactory.smallText,
parameter text #1036

Fixes (#1036)

Signed-off-by: azerr <azerr@redhat.com>
  • Loading branch information
angelozerr committed Jul 21, 2023
1 parent 8291649 commit 387b3de
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,14 @@ private CompletableFuture<Void> collect(Document document, Project project, Code
.thenAcceptAsync(codeLenses -> {
// textDocument/codeLens may return null
if (codeLenses != null) {
codeLenses.stream().filter(Objects::nonNull)
.forEach(codeLens -> pairs.add(new Pair(codeLens, languageServer.getSecond())));
codeLenses.stream()
.filter(Objects::nonNull)
.forEach(codeLens -> {
if (getCodeLensContent(codeLens) != null) {
// The codelens content is filled, display it
pairs.add(new Pair(codeLens, languageServer.getSecond()));
}
});
}
}))
.toArray(CompletableFuture[]::new)));
Expand All @@ -138,7 +144,7 @@ private InlayPresentation toPresentation(
elements.forEach(p -> {
CodeLens codeLens = p.second.first;
LanguageServer languageServer = p.second.second;
InlayPresentation text = factory.smallText(getCodeLensString(codeLens));
InlayPresentation text = factory.smallText(getCodeLensContent(codeLens));
if (!hasCommand(codeLens)) {
// No command, create a simple text inlay hint
presentations.add(text);
Expand Down Expand Up @@ -171,7 +177,7 @@ private static boolean hasCommand(CodeLens codeLens) {
return (command != null && command.getCommand() != null && !command.getCommand().isEmpty());
}

private static String getCodeLensString(CodeLens codeLens) {
private static String getCodeLensContent(CodeLens codeLens) {
Command command = codeLens.getCommand();
if (command == null || command.getTitle().isEmpty()) {
return null;
Expand Down

0 comments on commit 387b3de

Please sign in to comment.