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

Allow model listeners on interfaces 693 #694

Conversation

alamqadem
Copy link
Contributor

This pull request adds the possibility to create model listeners on InterfaceConcepts.

@alamqadem alamqadem self-assigned this Nov 17, 2023
@alamqadem alamqadem linked an issue Nov 17, 2023 that may be closed by this pull request
@alamqadem alamqadem marked this pull request as draft November 17, 2023 14:09
@alamqadem
Copy link
Contributor Author

alamqadem commented Nov 17, 2023

I've verified and now a ModelListener on an Interface builds and the listener is triggered correctly.

I've marked it as draft because I'm getting runtime errors (in the red error balloon in the corner) when building.
Somewhere it seems to still be calling the old constructor, I looked in the generator of modellisteners, but the calls to the constructors look fine to me.

Here is the stacktrace that I get.

Caught exception from the listener com.mbeddr.mpsutil.modellisteners.runtime.GlobalListener@5f296354. Will continue.

java.lang.NoSuchMethodError:
  'void com.mbeddr.mpsutil.modellisteners.runtime.ChildListener.<init>(
      org.jetbrains.mps.openapi.language.SConcept,
      org.jetbrains.mps.openapi.language.SContainmentLink)'
	at org.iets3.core.expr.toplevel.listeners.ModelListenersDescriptor$1
      .<init>(ModelListenersDescriptor.java:28)
	at org.iets3.core.expr.toplevel.listeners.ModelListenersDescriptor
      .getListeners(ModelListenersDescriptor.java:28)
	at com.mbeddr.mpsutil.modellisteners.runtime.GlobalListener
      .updateListeners(GlobalListener.java:113)
	at com.mbeddr.mpsutil.modellisteners.runtime.GlobalListener
      .onUnloaded(GlobalListener.java:82)
	at jetbrains.mps.classloading.ClassLoadingBroadCaster
      .onUnload(ClassLoadingBroadCaster.java:97)
	at jetbrains.mps.classloading.ClassLoaderManager
      .lambda$unloadModules$5(ClassLoaderManager.java:458)
	at jetbrains.mps.classloading.ClassLoaderManager
      .runTransaction(ClassLoaderManager.java:323)
	at jetbrains.mps.classloading.ClassLoaderManager
      .unloadModules(ClassLoaderManager.java:447)
	at jetbrains.mps.classloading.ClassLoaderManager
      .doReloadModules(ClassLoaderManager.java:551)
	at jetbrains.mps.classloading.ClassLoaderManager
      .reloadModules(ClassLoaderManager.java:492)
	at jetbrains.mps.classloading.ClassLoaderManager
      .reloadModules(ClassLoaderManager.java:580)
	at jetbrains.mps.make.facets.ReloadClasses_Facet$Target_reloadClasses$1
      .lambda$execute$0(ReloadClasses_Facet.java:76)
	at jetbrains.mps.smodel.ActionDispatcher.dispatch(ActionDispatcher.java:99)
	at jetbrains.mps.smodel.ActionDispatcher.lambda$wrap$0(ActionDispatcher.java:136)
	at jetbrains.mps.smodel.LockRunnable.run(LockRunnable.java:60)
	at com.intellij.openapi.application.impl.ApplicationImpl
      .runReadAction(ApplicationImpl.java:839)
	at jetbrains.mps.smodel.WorkbenchModelAccess
      .runWriteAction(WorkbenchModelAccess.java:100)
	at jetbrains.mps.smodel.ModelAccessBase.runWriteAction(ModelAccessBase.java:66)
	at jetbrains.mps.make.facets.ReloadClasses_Facet$Target_reloadClasses$1
      .execute(ReloadClasses_Facet.java:76)
	at jetbrains.mps.internal.make.runtime.script.Script
      .lambda$executeTargets$0(Script.java:309)
	at jetbrains.mps.ide.make.WorkbenchMakeService$Controller
      .runJobWithMonitor(WorkbenchMakeService.java:314)
	at jetbrains.mps.internal.make.runtime.script.Script
      .executeTargets(Script.java:254)
	at jetbrains.mps.internal.make.runtime.script.Script
      .execute(Script.java:232)
	at jetbrains.mps.make.service.CoreMakeTask.lambda$doRun$0(CoreMakeTask.java:101)
	at jetbrains.mps.make.dependencies.MakeSequence.iterate(MakeSequence.java:54)
	at jetbrains.mps.make.service.CoreMakeTask.doRun(CoreMakeTask.java:75)
	at jetbrains.mps.ide.make.MakeTask$WorkbenchMakeTask.doRun(MakeTask.java:148)
	at jetbrains.mps.make.service.CoreMakeTask.run(CoreMakeTask.java:54)
	at jetbrains.mps.ide.make.MakeTask$2.run(MakeTask.java:68)
	at java.base/java.lang.Thread.run(Thread.java:829)

@alexanderpann
Copy link
Collaborator

alexanderpann commented Nov 21, 2023

I think that's fine. While unloading it already calls the newly compiled methods, that's why you get the errors. When you restart MPS everything works.
Don't forget to update the changelog and the checking rule. Small refactoring possibility: It would also be nice to not log to System.out in the demo language but use the log or message statement.

@alamqadem
Copy link
Contributor Author

alamqadem commented Nov 21, 2023

I made the changes that you suggested, if you can have a look.

I'm still getting the error if I open a project using modellisteners, even if I open it in the same instance alongside this mps-extensions branch, restarting mps doesn't solve it.
To me it's still not clear what is going on 🤔 .

Edit:
I would like to add that I see the error also when it loads the classes
image

@alamqadem alamqadem marked this pull request as ready for review November 21, 2023 13:42
@alexanderpann
Copy link
Collaborator

alexanderpann commented Nov 22, 2023

Did you rebuild the listener aspect in the second project and also reload the project so that the listeners get unregistered and registered again?

Copy link
Collaborator

@alexanderpann alexanderpann left a comment

Choose a reason for hiding this comment

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

The changes are fine. We noticed that the existing listener descriptors don't get rebuilt even when you rebuild the full language that contains the listener aspect. You have to delete the gen folders of the language first and then the rebuilding of the descriptor will succeed.

@alexanderpann alexanderpann merged commit 6b97e51 into maintenance/mps20213 Dec 7, 2023
1 check passed
@alexanderpann alexanderpann deleted the feature/model-listeners-support-interfaces-693 branch December 7, 2023 16:38
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.

Modellistener: No support for interfaces only concepts
2 participants