-
-
Notifications
You must be signed in to change notification settings - Fork 351
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
feature: add support for Coccinelle-like semantic patches mixing matching (TemplateMatcher) and transformation (Template) together #1918
Comments
I am not sure if I understood you well. But have a look at There are two patterns, first is matching (founds a code location and takes current parameters) and second generates new code (using own template and current parameters) and then old code is replaced by new code. |
Have a look at https://github.com/pvojtechovsky/spoon/blob/5919ed784e5fde86e4b9246c0ea24c989f269a45/src/main/java/spoon/pattern/node/RootNode.java too public interface RootNode extends Matchers {
/**
* Generates zero, one or more target depending on kind of this {@link RootNode}, expected `result` and input `parameters`
* @param generator {@link Generator} which drives generation process
* @param result holder for the generated objects
* @param parameters a {@link ParameterValueProvider} holding parameters
*/
<T> void generateTargets(Generator generator, ResultHolder<T> result, ParameterValueProvider parameters);
/**
* @param targets to be matched target nodes and input parameters
* @param nextMatchers Chain of matchers which has to be processed after this {@link RootNode}
* @return new parameters and container with remaining targets
*/
TobeMatched matchTargets(TobeMatched targets, Matchers nextMatchers); |
Patterns (#1686) are almost this. The final step is to given then a Coccinelle look'n'feel. |
Documentation about SmPL: http://coccinelle.lip6.fr/documentation.php |
See also |
FYI new version of @JuliaLawall's paper: Semantic Patches for Java Program Transformation |
FYI, a paper on that topic "Semantic Patches for Adaptation of JavaScript Programs to Evolving Libraries." https://cs.au.dk/~amoeller/papers/jsfix/paper.pdf |
Imagine that you want to match a code location and transform it at the same time, this is sometimes called a "semantic patch" (as opposed to a line-based patch).
In the C world, there is an excellent tool for this, called Coccinelle, see http://coccinelle.lip6.fr/.
In Spoon, it would mean creating an abstraction that would gather a
TemplateMatcher
andTemplate
in a same object. In other terms, we are really close to have "semantic patches" in Spoon.@pvojtechovsky since you're extensively working on this part, what do you think?
The text was updated successfully, but these errors were encountered: