Skip to content

Commit

Permalink
Fix potential NPEs
Browse files Browse the repository at this point in the history
  • Loading branch information
BoykoAlex authored and mickaelistria committed Nov 10, 2022
1 parent 4faef9d commit 6905f41
Showing 1 changed file with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,32 +210,28 @@ private void reinvokeQuickfixProposalsIfNecessary(ITextViewer textViewer) {
// Quick assist proposals popup case
if (textViewer instanceof ISourceViewerExtension3) {
IQuickAssistAssistant quickAssistant = ((ISourceViewerExtension3)textViewer).getQuickAssistAssistant();
if (quickAssistant != null) {
Field f = QuickAssistAssistant.class.getDeclaredField("fQuickAssistAssistantImpl"); //$NON-NLS-1$
if (f != null) {
f.setAccessible(true);
ContentAssistant ca = (ContentAssistant) f.get(quickAssistant);
Method m = ContentAssistant.class.getDeclaredMethod("isProposalPopupActive"); //$NON-NLS-1$
if (m != null) {
m.setAccessible(true);
boolean isProposalPopupActive = (Boolean) m.invoke(ca);
if (isProposalPopupActive) {
quickAssistant.showPossibleQuickAssists();
}
}
f.setAccessible(true);
ContentAssistant ca = (ContentAssistant) f.get(quickAssistant);
Method m = ContentAssistant.class.getDeclaredMethod("isProposalPopupActive"); //$NON-NLS-1$
m.setAccessible(true);
boolean isProposalPopupActive = (Boolean) m.invoke(ca);
if (isProposalPopupActive) {
quickAssistant.showPossibleQuickAssists();
}
}
}
// Hover case
if (textViewer instanceof ITextViewerExtension2) {
ITextHover hover = ((ITextViewerExtension2) textViewer).getCurrentTextHover();
boolean hoverShowing = hover != null;
if (hoverShowing) {
Field f = TextViewer.class.getDeclaredField("fTextHoverManager"); //$NON-NLS-1$
if (f != null) {
f.setAccessible(true);
AbstractInformationControlManager manager = (AbstractInformationControlManager) f.get(textViewer);
if (manager != null) {
manager.showInformation();
}
f.setAccessible(true);
AbstractInformationControlManager manager = (AbstractInformationControlManager) f.get(textViewer);
if (manager != null) {
manager.showInformation();
}
}
}
Expand Down

0 comments on commit 6905f41

Please sign in to comment.