Account for exceptions while updating codeminings in opened editors

This commit is contained in:
aboyko
2023-02-06 16:05:36 -05:00
parent a67344c57e
commit 5d9eee9f8d

View File

@@ -415,17 +415,22 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La
for (IWorkbenchWindow ww : PlatformUI.getWorkbench().getWorkbenchWindows()) {
for (IWorkbenchPage page : ww.getPages()) {
for (IEditorReference editorRef : page.getEditorReferences()) {
IEditorPart editor = editorRef.getEditor(false);
if (editor != null) {
if (editor.getEditorInput() instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput)editor.getEditorInput()).getFile();
if (file != null && projects.contains(file.getProject())) {
ITextViewer viewer = editor.getAdapter(ITextViewer.class);
if (viewer instanceof ISourceViewerExtension5) {
((ISourceViewerExtension5)viewer).updateCodeMinings();
try {
IEditorPart editor = editorRef.getEditor(false);
if (editor != null) {
if (editor.getEditorInput() instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput)editor.getEditorInput()).getFile();
if (file != null && projects.contains(file.getProject())) {
ITextViewer viewer = editor.getAdapter(ITextViewer.class);
if (viewer instanceof ISourceViewerExtension5) {
((ISourceViewerExtension5)viewer).updateCodeMinings();
}
}
}
}
} catch (Exception e) {
// ignore, e.g. MavenPomEditor can throw NPE on getAdapter(...) call. Just log it and continue
LanguageServerCommonsActivator.logError(e, "Failed to refresh Code Minings for editor.");
}
}
}