is there a way to get the type of pregenerated methods in mps?...

This is an auto-generated question from the MPS Slack community: is there a way to get the type of pregenerated methods in mps?
0
19 comments
for example, in the following event listener,
0
the code in 'child added' and 'child removed' should be the same
0
but given that the methods' headers are pregenerated
0
there's no way (to my knowledge) to write a helper function that deals with the logic. This results in ugly, needles, (but unavoidable?) code duplication. Is there a way around this?
0
You can extract the common logic into a separate class with a (static) method and call that method.
0
but that method needs to know the type of instance
0
as well as child
0
So pass that info to it as parameters
0
but what is the type of these arguments. The classes are pure java, right? but instance and child are two arguments whose type is not shown
0
experiantially, instance is the interface child of an InterafceChunk concept
0
try typing `instance`, selecting it and pressing Ctrl+Shift+P
0
thanks! that worked
0
now there's another problem. Copy pasting does not work from the listener into the class
0
the code has to be manually type in again
0
you need to be careful about what you are pasting. copy-pasting a list of statements should work fine
0
copy-pasting the whole function won't work
0
because they are different, incompatible concepts, whereas statements are compatible.
0
This is auto-generated question from the MPS Community Slack Workspace. If you want to comment on the question, do it from the Slack workspace
0

Post is closed for comments.