access to struct replace possible via open api ?

trying my question here. is there currently access to
struct replace via open ape?

I'm thinking of a plugin called "replace by example": I mean you start some recorder, then modify e.g. one line
of code, then apply a generated struct replace on other lines to do the same modification on them.
Should it be possible by current open API to implement this? (then I would try to implement it.)


well, I guess the answer is no then.
So, new question:
Do you have any plans to create an open api for struct replace?



It will be for Irida but not in nearest timeframe.

Michael Damberger wrote:

well, I guess the answer is no then.
So, new question:
Do you have any plans to create an open api for struct replace?

Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
"Develop with pleasure!"


Thank you for the answer!

What do you think of the idea of "struct replace by
example"? While there is no open api my next plan is
that you might implement it :)


How it much you expect it to differ from:
select some code, open SR, insert the selection into replacement, edit it and run?


It could figure automatically the variables and propose some constraints.


Here is one very little/trivial example,
but it still shows why the "SR by example" would be useful:

Last time I did a very simple struct replace (but it is really a very cool feature, even for the simple cases!!!!,
it is fun to use it):

instead of
$instance$.addAttribute(new XyClass($name$, $val$));
I wanted to get
$instance$.setAttribute($name$, $val$);

but in my first try, I did write the search template like this:

addAttribute(new XyClass($name$, $val$));

As an SR expert you might say "sure, you must add the instance to invoke the method on" - well, but only if you are an SR expert ;)

SR by example could figure it out itself and it would
make SR much more foolproof :)

I surely can think of much more complex example,
which just scare you off while "hacking". When you
are heavily coding, sometimes you don't want to stop
messing with a complex SR template, it interrupts you
from your real coding problem.

If you compare the PSI of the statements before and
after editing, it should be easy to extract search and
replace template from it, right?


In your example I would prefer to know during editing that there is no matches found on given pattern (we have such request).


SSR could do simple introduction of template variables that should make the life easier, however, I deliberately not concerning now comparing the psi trees before and after the edit, this task is quite time consuming for the implementation.


I could try to write some PSI-Tree comparing myself,
but I also have the time problem :(

Well, maybe MPS could help with a PSI-Comparing-DSL ? ;)

Thanks anyway


Please sign in to leave a comment.