Skip to content

Commit

Permalink
Fixed NPE when code minings are enabled and the editor is going to be
Browse files Browse the repository at this point in the history
closed/is closed and the worker is asking for the document

see #3110
  • Loading branch information
mehmet-karaman committed Jul 25, 2024
1 parent 34a6e3b commit 9b2a1ad
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -87,7 +88,11 @@ public List<ICodeMining> 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;
}
Expand Down

0 comments on commit 9b2a1ad

Please sign in to comment.