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?
19 comments
Comment actions Permalink
for example, in the following event listener,
0
Comment actions Permalink
the code in 'child added' and 'child removed' should be the same
0
Comment actions Permalink
but given that the methods' headers are pregenerated
0
Comment actions Permalink
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
Comment actions Permalink
You can extract the common logic into a separate class with a (static) method and call that method.
0
Comment actions Permalink
but that method needs to know the type of instance
0
Comment actions Permalink
as well as child
0
Comment actions Permalink
So pass that info to it as parameters
0
Comment actions Permalink
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
Comment actions Permalink
experiantially, instance is the interface child of an InterafceChunk concept
0
Comment actions Permalink
try typing `instance`, selecting it and pressing Ctrl+Shift+P
0
Comment actions Permalink
thanks! that worked
0
Comment actions Permalink
now there's another problem. Copy pasting does not work from the listener into the class
0
Comment actions Permalink
the code has to be manually type in again
0
Comment actions Permalink
you need to be careful about what you are pasting. copy-pasting a list of statements should work fine
0
Comment actions Permalink
copy-pasting the whole function won't work
0
Comment actions Permalink
because they are different, incompatible concepts, whereas statements are compatible.
0
Comment actions Permalink
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.