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
Sort by
Date
Votes

for example, in the following event listener,

the code in 'child added' and 'child removed' should be the same

but given that the methods' headers are pregenerated



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?

You can extract the common logic into a separate class with a (static) method and call that method.

but that method needs to know the type of instance

as well as child

So pass that info to it as parameters

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

experiantially, instance is the interface child of an InterafceChunk concept

try typing `instance`, selecting it and pressing Ctrl+Shift+P

thanks! that worked

now there's another problem. Copy pasting does not work from the listener into the class

the code has to be manually type in again

you need to be careful about what you are pasting. copy-pasting a list of statements should work fine

copy-pasting the whole function won't work

because they are different, incompatible concepts, whereas statements are compatible.

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
Post is closed for comments.