From 9b2a1add754c84c825846edae6a6ec35adb59f95 Mon Sep 17 00:00:00 2001 From: Mehmet Emin Karaman Date: Thu, 25 Jul 2024 10:29:48 +0200 Subject: [PATCH] Fixed NPE when code minings are enabled and the editor is going to be closed/is closed and the worker is asking for the document see https://github.com/eclipse/xtext/issues/3110 --- .../ui/codemining/AbstractXtextCodeMiningProvider.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/org.eclipse.xtext.ui.codemining/src/org/eclipse/xtext/ui/codemining/AbstractXtextCodeMiningProvider.java b/org.eclipse.xtext.ui.codemining/src/org/eclipse/xtext/ui/codemining/AbstractXtextCodeMiningProvider.java index c8535c5a19d..35027c18d2c 100644 --- a/org.eclipse.xtext.ui.codemining/src/org/eclipse/xtext/ui/codemining/AbstractXtextCodeMiningProvider.java +++ b/org.eclipse.xtext.ui.codemining/src/org/eclipse/xtext/ui/codemining/AbstractXtextCodeMiningProvider.java @@ -27,6 +27,7 @@ import org.eclipse.jface.text.codemining.LineHeaderCodeMining; import org.eclipse.swt.events.MouseEvent; import org.eclipse.xtext.resource.XtextResource; +import org.eclipse.xtext.ui.editor.model.IXtextDocument; import org.eclipse.xtext.ui.editor.model.XtextDocumentUtil; import org.eclipse.xtext.util.CancelIndicator; import org.eclipse.xtext.util.IAcceptor; @@ -87,7 +88,11 @@ public List exec(XtextResource resource, CancelIndicator uowCancelI } }; - return xtextDocumentUtil.getXtextDocument(viewer).tryReadOnly(uow, () -> Collections.emptyList()); + IXtextDocument xtextDocument = xtextDocumentUtil.getXtextDocument(viewer); + if (xtextDocument == null) { + return Collections.emptyList(); + } + return xtextDocument.tryReadOnly(uow, () -> Collections.emptyList()); }); return future; }