|
12 | 12 | *******************************************************************************/ |
13 | 13 | package org.eclipse.lsp4e.operations.codeactions; |
14 | 14 |
|
15 | | -import static org.eclipse.lsp4e.internal.NullSafetyHelper.*; |
| 15 | +import static org.eclipse.lsp4e.internal.NullSafetyHelper.lateNonNull; |
16 | 16 |
|
17 | 17 | import java.util.Collections; |
18 | 18 | import java.util.List; |
|
39 | 39 | import org.eclipse.lsp4j.Command; |
40 | 40 | import org.eclipse.lsp4j.Range; |
41 | 41 | import org.eclipse.lsp4j.ServerCapabilities; |
| 42 | +import org.eclipse.lsp4j.TextDocumentIdentifier; |
42 | 43 | import org.eclipse.lsp4j.jsonrpc.messages.Either; |
43 | 44 | import org.eclipse.swt.SWT; |
44 | 45 | import org.eclipse.swt.events.SelectionAdapter; |
@@ -79,15 +80,20 @@ public void initialize(IServiceLocator serviceLocator) { |
79 | 80 |
|
80 | 81 | @Override |
81 | 82 | 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 | + |
82 | 89 | final var item = new MenuItem(menu, SWT.NONE, index); |
83 | 90 | item.setEnabled(false); |
84 | 91 |
|
85 | 92 | item.setText(Messages.computing); |
86 | | - final IDocument document = this.document; |
87 | 93 |
|
88 | 94 | final var context = new CodeActionContext(Collections.emptyList()); |
89 | 95 | final var params = new CodeActionParams(); |
90 | | - params.setTextDocument(castNonNull(LSPEclipseUtils.toTextDocumentIdentifier(document))); |
| 96 | + params.setTextDocument(textDocumentIdentifier); |
91 | 97 | params.setRange(this.range); |
92 | 98 | params.setContext(context); |
93 | 99 |
|
|
0 commit comments