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

Custom Project View: runRebuildAction failes with NullPointerException #901

Closed
arimer opened this issue Jul 30, 2024 · 3 comments
Closed

Comments

@arimer
Copy link
Collaborator

arimer commented Jul 30, 2024

In MPS 2022.2 this exceptions appears frequently:

java.lang.NullPointerException: Cannot invoke "jetbrains.mps.ide.ui.tree.MPSTree.runRebuildAction(java.lang.Runnable, boolean)" because the return value of "jetbrains.mps.ide.ui.tree.MPSTreeNode.getTree()" is null
    at jetbrains.mps.ide.ui.tree.MPSTreeNode.updateSubTree(MPSTreeNode.java:201)
    at com.mbeddr.mpsutil.projectview.runtime.tree.CustomTreeNodesUpdater.updateChildren(CustomTreeNodesUpdater.java:119)
    at com.mbeddr.mpsutil.projectview.runtime.tree.CustomTreeNodesUpdater$3.visit(CustomTreeNodesUpdater.java:111)
    at com.mbeddr.mpsutil.projectview.runtime.tree.CustomTreeNodesUpdater$3.visit(CustomTreeNodesUpdater.java:109)
    at jetbrains.mps.internal.collections.runtime.IVisitor.invoke(IVisitor.java:12)
    at jetbrains.mps.internal.collections.runtime.IterableUtils.visitAll(IterableUtils.java:16)
    at jetbrains.mps.internal.collections.runtime.AbstractSequence.visitAll(AbstractSequence.java:80)
    at com.mbeddr.mpsutil.projectview.runtime.tree.CustomTreeNodesUpdater.updateChildrens(CustomTreeNodesUpdater.java:109)
    at com.mbeddr.mpsutil.projectview.runtime.tree.CustomTreeNodesUpdater.doUpdate(CustomTreeNodesUpdater.java:79)
    at com.mbeddr.mpsutil.projectview.runtime.tree.CustomTreeNodesUpdater.lambda$update$0(CustomTreeNodesUpdater.java:57)
    at jetbrains.mps.smodel.WorkbenchModelAccess.runReadAction(WorkbenchModelAccess.java:80)
    at jetbrains.mps.smodel.ModelAccessBase.runReadAction(ModelAccessBase.java:56)
    at jetbrains.mps.smodel.ModelReadRunnable.run(ModelReadRunnable.java:46)
    at jetbrains.mps.ide.ThreadUtils$LogExceptionsRunnable.run(ThreadUtils.java:80)
    at jetbrains.mps.ide.ThreadUtils.runInUIThreadNoWait(ThreadUtils.java:57)
    at com.mbeddr.mpsutil.projectview.runtime.tree.CustomTreeNodesUpdater.update(CustomTreeNodesUpdater.java:57)
    at com.mbeddr.mpsutil.projectview.runtime.tree.CustomTreeNodesUpdater$1.eventsHappened(CustomTreeNodesUpdater.java:35)
    at com.mbeddr.mpsutil.projectview.runtime.tree.GlobalModelsEventsCollector$1.commandFinished(GlobalModelsEventsCollector.java:34)
    at jetbrains.mps.extapi.module.SRepositoryEventsDispatcher.fireCommandFinished(SRepositoryEventsDispatcher.java:119)
    at jetbrains.mps.extapi.module.SRepositoryBase.fireCommandFinished(SRepositoryBase.java:122)
    at jetbrains.mps.smodel.MPSModuleRepository.access$100(MPSModuleRepository.java:54)
    at jetbrains.mps.smodel.MPSModuleRepository$1.commandFinished(MPSModuleRepository.java:105)
    at java.base/java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:807)
    at jetbrains.mps.smodel.ActionDispatcher.onExit(ActionDispatcher.java:222)
    at jetbrains.mps.smodel.ActionDispatcher.dispatch(ActionDispatcher.java:114)
    at jetbrains.mps.smodel.ActionDispatcher.lambda$wrap$0(ActionDispatcher.java:135)
    at jetbrains.mps.smodel.ActionDispatcher.dispatch(ActionDispatcher.java:98)
    at jetbrains.mps.smodel.ActionDispatcher.lambda$wrap$0(ActionDispatcher.java:135)
    at jetbrains.mps.smodel.LockRunnable.run(LockRunnable.java:60)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1023)
    at jetbrains.mps.smodel.TryRunPlatformWriteHelper.runWrite(TryRunPlatformWriteHelper.java:103)
    at jetbrains.mps.smodel.TryRunPlatformWriteHelper.lambda$withPlatformWrite$1(TryRunPlatformWriteHelper.java:96)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:219)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:174)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:164)
    at jetbrains.mps.smodel.WorkbenchModelAccess.executeCommand(WorkbenchModelAccess.java:302)
    at jetbrains.mps.smodel.ProjectModelAccess2.executeCommand(ProjectModelAccess2.java:35)
    at jetbrains.mps.nodeEditor.actions.CellActionExecuter.lambda$execute$2(CellActionExecuter.java:57)
    at jetbrains.mps.nodeEditor.EditorContext.lambda$runWithContextCell$3(EditorContext.java:253)
    at jetbrains.mps.nodeEditor.EditorContext.runWithContextCell(EditorContext.java:264)
    at jetbrains.mps.nodeEditor.EditorContext.runWithContextCell(EditorContext.java:252)
    at jetbrains.mps.nodeEditor.actions.CellActionExecuter.execute(CellActionExecuter.java:53)
    at jetbrains.mps.nodeEditor.actions.ActionHandlerImpl.executeAction(ActionHandlerImpl.java:41)
    at jetbrains.mps.nodeEditor.selection.EditorCellSelection.executeAction(EditorCellSelection.java:169)
    at jetbrains.mps.nodeEditor.selection.EditorCellLabelSelection.performDeleteAction(EditorCellLabelSelection.java:199)
    at jetbrains.mps.nodeEditor.selection.EditorCellLabelSelection.executeAction(EditorCellLabelSelection.java:164)
    at jetbrains.mps.ide.editor.actions.Delete_Action.doExecute(Delete_Action.java:58)
    at jetbrains.mps.workbench.action.BaseAction.lambda$actionPerformed$2(BaseAction.java:208)
    at jetbrains.mps.workbench.action.ActionAccess$EmptyAccess.runWithAccess(ActionAccess.java:58)
    at jetbrains.mps.workbench.action.BaseAction.actionPerformed(BaseAction.java:200)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.doPerformActionOrShowPopup(ActionUtil.java:315)
    at com.intellij.openapi.keymap.impl.ActionProcessor.performAction(ActionProcessor.java:47)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:595)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$doPerformActionInner$9(IdeKeyEventDispatcher.java:717)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
    at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:94)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$doPerformActionInner$10(IdeKeyEventDispatcher.java:717)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:337)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.doPerformActionInner(IdeKeyEventDispatcher.java:714)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:658)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:606)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processActionOrWaitSecondStroke(IdeKeyEventDispatcher.java:489)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:478)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:229)
    at com.intellij.ide.IdeEventQueue.dispatchKeyEvent(IdeEventQueue.java:824)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:760)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:450)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:791)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:449)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113)
    at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:624)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:447)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:881)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:493)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)```
@arimer
Copy link
Collaborator Author

arimer commented Aug 5, 2024

Steps to reproduce the issue inside the mps-extensions project:

  1. build the LogicalViewClone
  2. Switch from the logical view to the the LogicalViewClone (Only direct after the swtich the error appears)
  3. Create a model inside a solution
  4. Create a root node (ex. BaseLanauge Class) inside the newly created model

@arimer
Copy link
Collaborator Author

arimer commented Aug 5, 2024

What I've seen so far during debugging is that:

  • during creation of new root nodes via a custom view, the CustomTreeNodesUpdater tries to calculate the required CustomTreeNodes that need to be updated
  • as part of this update it asks the myChildrenRecorder.getDependOn(changedModel) for a set of CustomTreeNodes (and their children) that should be updated
  • However this imlementation delivers CustomTreeNodes that do not belong to any Tree: Meaning their treeNode.myTree is not set
  • This leads to a NPE in the MPSTreeNode.updateSubTree() because no tree is associated with the current CustomerTreeNode

@arimer
Copy link
Collaborator Author

arimer commented Aug 6, 2024

Conclusion:

It looks like old treeNodes that do not longer belong to any tree but were still in the list of treenodes for update. Adding a condition to filter out those no longer required nodes works bests here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants