eclipse / xtext

Eclipse Xtext™ is a language development framework
http://www.eclipse.org/Xtext
Eclipse Public License 2.0
768 stars 321 forks source link

NPE in RenameRefactoringPopup #2481

Open tivervac opened 1 year ago

tivervac commented 1 year ago

I see that the popup is set to null during close() and only created during open() so it definitely seems possible that this variable is null.

Relevant part of the automated bug report stack trace we received:

java.lang.NullPointerException:Cannot invoke "org.eclipse.swt.widgets.Shell.pack()" because "this.popup" is null
    at org.eclipse.xtext.ui.refactoring.ui.RenameRefactoringPopup.packPopup(RenameRefactoringPopup.java:383)
    at org.eclipse.xtext.ui.refactoring.ui.RenameRefactoringPopup.updatePopupLocation(RenameRefactoringPopup.java:372)
    at org.eclipse.xtext.ui.refactoring.ui.RenameRefactoringPopup$PopupVisibilityManager.controlResized(RenameRefactoringPopup.java:546)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:239)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4243)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1063)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1087)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1068)
    at org.eclipse.swt.widgets.Control.WM_SIZE(Control.java:5448)
    at org.eclipse.swt.widgets.Scrollable.WM_SIZE(Scrollable.java:360)
    at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1725)
    at org.eclipse.swt.widgets.Canvas.WM_SIZE(Canvas.java:444)
    at org.eclipse.swt.widgets.Decorations.WM_SIZE(Decorations.java:1646)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4823)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340)
    at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1480)
    at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2286)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5015)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(Native Method)
    at org.eclipse.swt.widgets.Shell.callWindowProc(Shell.java:508)
    at org.eclipse.swt.widgets.Control.WM_WINDOWPOSCHANGED(Control.java:5678)
    at org.eclipse.swt.widgets.Canvas.WM_WINDOWPOSCHANGED(Canvas.java:451)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4836)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340)
    at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1480)
    at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2286)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5015)
    at org.eclipse.swt.internal.win32.OS.PeekMessage(Native Method)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3627)
tivervac commented 1 year ago

This stacktrace is likely related. Seems like the editor was disposed while the popup was open.

java.lang.NullPointerException:Cannot invoke "org.eclipse.ui.IWorkbenchWindow.getPartService()" because the return value of "org.eclipse.ui.IWorkbenchPartSite.getWorkbenchWindow()" is null
    at org.eclipse.xtext.ui.refactoring.ui.RenameRefactoringPopup$PopupVisibilityManager$1.widgetDisposed(RenameRefactoringPopup.java:483)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:127)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4243)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1063)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1087)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1068)
    at org.eclipse.swt.widgets.Widget.release(Widget.java:811)
    at org.eclipse.swt.widgets.Widget.dispose(Widget.java:425)
    at org.eclipse.swt.widgets.Decorations.dispose(Decorations.java:392)
    at org.eclipse.swt.widgets.Decorations.closeWidget(Decorations.java:270)
    at org.eclipse.swt.widgets.Shell.close(Shell.java:548)
    at org.eclipse.xtext.ui.refactoring.ui.RenameRefactoringPopup.close(RenameRefactoringPopup.java:457)
    at org.eclipse.xtext.ui.refactoring.ui.RenameLinkedMode.linkedModeLeft(RenameLinkedMode.java:148)
    at org.eclipse.xtext.ui.refactoring.ui.RenameRefactoringController.cancelLinkedMode(RenameRefactoringController.java:191)
    at org.eclipse.xtext.ui.refactoring.ui.RenameLinkedMode$EditorSynchronizer.left(RenameLinkedMode.java:170)
    at org.eclipse.jface.text.link.LinkedModeModel.exit(LinkedModeModel.java:338)
    at org.eclipse.jface.text.link.LinkedModeUI.lambda$2(LinkedModeUI.java:1172)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:185)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4035)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3635)

I tried removing the given file with native polling on and the rename popup open, that works fine.

Instead I tried removing a second file (not the one where I started renaming). That also worked fine until I pressed OK which triggered another stacktrace

org.eclipse.swt.SWTException: Invalid thread access
    at org.eclipse.swt.SWT.error(SWT.java:4918)
    at org.eclipse.swt.SWT.error(SWT.java:4833)
    at org.eclipse.swt.SWT.error(SWT.java:4804)
    at org.eclipse.swt.widgets.Display.error(Display.java:1518)
    at org.eclipse.swt.widgets.Display.checkDevice(Display.java:969)
    at org.eclipse.swt.widgets.Display.getShells(Display.java:2786)
    at org.eclipse.ui.internal.progress.ProgressManagerUtil.getModalShellExcluding(ProgressManagerUtil.java:431)
    at org.eclipse.ui.internal.progress.ProgressManagerUtil.getDefaultParent(ProgressManagerUtil.java:485)
    at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.performSaveAs(AbstractDecoratedTextEditor.java:1509)
    at org.eclipse.ui.texteditor.AbstractTextEditor.doSave(AbstractTextEditor.java:4783)
    at org.eclipse.xtext.ui.editor.XtextEditor.doSave(XtextEditor.java:326)
    at org.eclipse.xtext.ui.refactoring.impl.EditorDocumentChange.commit(EditorDocumentChange.java:91)
    at org.eclipse.ltk.core.refactoring.TextChange.perform(TextChange.java:242)
    at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:281)
    org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:281)
    at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:281)
    at org.eclipse.ltk.core.refactoring.PerformChangeOperation.lambda$0(PerformChangeOperation.java:258)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2315)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2340)
    at org.eclipse.ltk.core.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:295)
    at org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation.executeChange(UIPerformChangeOperation.java:94)
    at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:224)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2315)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2340)
    at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:89)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
cdietrich commented 1 year ago

for the first stacktrace i wonder how to popup can be resized @tivervac from which os is the trace?

LorenzoBettini commented 1 year ago

It depends on the pop-up: for example, the ones of content assist or hovering can be resized and focused with F2. But I don't understand which kind of popup this is.

cdietrich commented 1 year ago

i assume its this Bildschirmfoto vom 2023-03-24 15-45-05

LorenzoBettini commented 1 year ago

Then I think that pressing the dropdown arrow triggers a resize

cdietrich commented 1 year ago

in my mint it opens a popup. and no resize

tivervac commented 1 year ago

for the first stacktrace i wonder how to popup can be resized @tivervac from which os is the trace?

@cdietrich Windows