Skip to content

Commit 67a16fb

Browse files
committed
fix: avoid casting a null value to NonNull.
1 parent ca8736e commit 67a16fb

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/codeactions/LSPCodeActionsMenu.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*******************************************************************************/
1313
package org.eclipse.lsp4e.operations.codeactions;
1414

15-
import static org.eclipse.lsp4e.internal.NullSafetyHelper.*;
15+
import static org.eclipse.lsp4e.internal.NullSafetyHelper.lateNonNull;
1616

1717
import java.util.Collections;
1818
import java.util.List;
@@ -39,6 +39,7 @@
3939
import org.eclipse.lsp4j.Command;
4040
import org.eclipse.lsp4j.Range;
4141
import org.eclipse.lsp4j.ServerCapabilities;
42+
import org.eclipse.lsp4j.TextDocumentIdentifier;
4243
import org.eclipse.lsp4j.jsonrpc.messages.Either;
4344
import org.eclipse.swt.SWT;
4445
import org.eclipse.swt.events.SelectionAdapter;
@@ -79,15 +80,20 @@ public void initialize(IServiceLocator serviceLocator) {
7980

8081
@Override
8182
public void fill(final Menu menu, int index) {
83+
final IDocument document = this.document;
84+
TextDocumentIdentifier textDocumentIdentifier = LSPEclipseUtils.toTextDocumentIdentifier(document);
85+
if (textDocumentIdentifier == null) {
86+
return;
87+
}
88+
8289
final var item = new MenuItem(menu, SWT.NONE, index);
8390
item.setEnabled(false);
8491

8592
item.setText(Messages.computing);
86-
final IDocument document = this.document;
8793

8894
final var context = new CodeActionContext(Collections.emptyList());
8995
final var params = new CodeActionParams();
90-
params.setTextDocument(castNonNull(LSPEclipseUtils.toTextDocumentIdentifier(document)));
96+
params.setTextDocument(textDocumentIdentifier);
9197
params.setRange(this.range);
9298
params.setContext(context);
9399

0 commit comments

Comments
 (0)