Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guard if no editor is associated with the hover #396

Merged
merged 1 commit into from
May 16, 2023

Conversation

ddscharfe
Copy link
Contributor

To implement cdt-lsp/issues/70, we need to delegate to the cdt debug hover mechanism. This leads to a NPE in AbstractDebugTextHover

java.lang.NullPointerException: Cannot invoke "org.eclipse.ui.IEditorPart.getEditorInput()" because the return value of "org.eclipse.cdt.debug.ui.editors.AbstractDebugTextHover.getEditor()" is null
	at org.eclipse.cdt.debug.ui.editors.AbstractDebugTextHover.getExpressionTextFromAST(AbstractDebugTextHover.java:242)
	at org.eclipse.cdt.debug.ui.editors.AbstractDebugTextHover.getExpressionText(AbstractDebugTextHover.java:217)
	at org.eclipse.cdt.debug.ui.editors.AbstractDebugTextHover.getHoverInfo(AbstractDebugTextHover.java:164)
	at org.eclipse.cdt.dsf.debug.ui.AbstractDsfDebugTextHover.getHoverInfo2(AbstractDsfDebugTextHover.java:220)
	at org.eclipse.cdt.lsp.editor.DebugHoverProvider.lambda$3(DebugHoverProvider.java:35)
	at java.base/java.util.Optional.map(Optional.java:260)
	at org.eclipse.cdt.lsp.editor.DebugHoverProvider.getHoverInfo2(DebugHoverProvider.java:35)
	at org.eclipse.ui.internal.genericeditor.hover.CompositeTextHover.getHoverInfo2(CompositeTextHover.java:59)
	at org.eclipse.jface.text.TextViewerHoverManager$1.run(TextViewerHoverManager.java:155)

This PR fixes the NPE.

debug hover is used from a non cdt-editor, e.g. the cdt-lsp editor.
Copy link
Contributor

@ghentschke ghentschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ghentschke ghentschke merged commit 75d962a into eclipse-cdt:main May 16, 2023
@jonahgraham jonahgraham added this to the 11.2.0 milestone Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants