A few weeks ago there was a post showing how to do code rewriting.
| env rewriter changes | env := RBBrowserEnvironment default forPackages: (RPackageOrganizer default packages ). rewriter := RBParseTreeRewriter new. rewriter replace:'`@receiver detect: `@arg1 ifFound: [ :`arg2 | `arg2 ] ifNone: `@arg3' with: '`@receiver detect: `@arg1 ifNone: `@arg3'. changes := Array with: (RBSmalllintChecker runRule: (RBTransformationRule new rewriteRule: rewriter; yourself) onEnvironment: env ) builder. (ChangesBrowser changes: changes) open. We haven't had a GUI for that for a long time in Pharo. And most developers don't seem to be aware that we have this powerful tool. Nor are they aware of how to use it. It seems difficult to learn, seeing that it needs classes from: - Refactoring-Environment - RPackage-Core-Base - AST-Core-Matching - Refactoring-Critics - NautilusRefactoring-Utilities It is also not easy to find out how to just do a match, instead of a rewrite. Also, the patterns recognized are not the same as those in SmaCC, which is more powerful. When googling for code rewriting, I found - Smacc: https://www.slideshare.net/pharoproject/smack-behind-the-refactorings - The original rewrite tool: https://refactory.com/rewrite-tool/ - RewriteTool: https://github.com/jordanmontt/RewriteTool-Spec2 - MatchTool: https://github.com/jordanmontt/MatchTool-Spec2 I'd prefer to have the rewrite tools integrated in the standard Pharo image, as that makes it much more likely that they are used systematically. The original rewrite tool is not for Pharo, and RewriteTool and MatchTool can a.t.m. not be used to do the actual rewrites. I think porting the GUI from the original rewrite tool to Spec2, and then applying the improvements from MatchTool and RewriteTool is more likely to be effective, as it allows starting from working code. And also to do the development directly in pharo-project/pharo, not in a separate project, as that is unlikely to be kept up-to-date Stephan |
I agree :)
And we are working with Sebastian Jordan and Juan-Pablo Sandoval to propose a nice tool for this. S.
-------------------------------------------- Stéphane Ducasse 03 59 35 87 52 Assistant: Aurore Dalle FAX 03 59 57 78 50 TEL 03 59 35 86 16 S. Ducasse - Inria 40, avenue Halley, Parc Scientifique de la Haute Borne, Bât.A, Park Plaza Villeneuve d'Ascq 59650 France |
In reply to this post by Stephan Eggermont-3
|
Free forum by Nabble | Edit this page |