Giter Site home page Giter Site logo

jordanmontt / rewritetoolsset Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 3.0 564 KB

A set of tools that allows to do complex searches and code transformations using the refactoring engine in Pharo!

License: MIT License

Smalltalk 100.00%
refactoring-tools refactoring refactor pharo-smalltalk rewrite-rules pharo transformation-rules tool

rewritetoolsset's Introduction

Build status Coverage Status License Pharo version

This is Rewrite Tools Set


This repo is no longer maintened. I have migrated the code to NewTools. The tools are now included in Pharo from Pharo 11 or greater. You can load them from here if you use a lowest Pharo version, Pharo 10 or lower.


RewriteToolsSet is a set of Pharo modular tools that can be used together or separately. This set of tools allow you to do complex code transformations, searches and refactors using the rewrite engine of Pharo! You can create custom code transformation rules and transform the code of a set of classes (or the whole image) with them.

These tools allow you to create, store, load, test, match and apply custom transformations rules and do complex code searches. As well, you can apply the custom transformation rules to a specific set of classes or to the entire Pharo image. You can refactor or replace deprecated methods (or any method) with this tool!

This set of tools includes Yuriy Tymchuk's MatchTool. I migrated it to the ner version of Spec.

Installation

In order to install this tool, perform the following code in a Playground:

Metacello new
    repository: 'github://jordanmontt/RewriteToolsSet/src';
    baseline: 'RewriteToolsSet';
    load

How to open it

When you have downloaded the tool using the above code, it will be added to the Tools menu. You just have to click it.

Capture d’écran 2022-11-06 à 13 56 20

rewritetoolsset's People

Contributors

ducasse avatar jordanmontt avatar sonibla avatar stephaneggermont avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rewritetoolsset's Issues

Add more tests

As the tool code change quite a lot, more tested are needed. For example, the new classes of the core are not tested. Also more test for the tools are needed

Update baseline and README script

To not load the master version but the version from the release.

Another solution will be to only push changes on the development branch

RTRuleEditorPresenter(Object)>>doesNotUnderstand: #isForMethod

RTRuleEditorPresenter(Object)>>doesNotUnderstand: #isForMethod
ApplyRuleOnAllClassesCommand>>execute
SpCommand(CmCommandDecorator)>>execute
[ specCommand execute ] in [ :specCommand |
aButtonClass new
label: specCommand name;
help: specCommand description;
in: [ :button |
specCommand hasIcon
ifTrue: [ button icon: specCommand icon ] ];
action: [ specCommand execute ];
yourself ] in SpCommand>>configureAsButtonOfClass: in Block: [ specCommand execute ]
SpButtonPresenter>>performAction
SpMorphicButtonAdapter>>action
SpPluggableButtonMorph(PluggableButtonMorph)>>performAction:
[:m |
(m containsPoint: evt cursorPoint) ifTrue: [m enabled ifTrue: [ m performAction: evt ]]] in SpPluggableButtonMorph(PluggableButtonMorph)>>mouseUp: in Block: [:m |...
Array(SequenceableCollection)>>do:
SpPluggableButtonMorph(PluggableButtonMorph)>>mouseUp:
SpPluggableButtonMorph(Morph)>>handleMouseUp:
MouseButtonEvent>>sentTo:
SpPluggableButtonMorph(Morph)>>handleEvent:
SpPluggableButtonMorph(Morph)>>handleFocusEvent:
[
result := focusHolder handleFocusEvent: transformedEvent.
] in HandMorph>>sendFocusEvent:to:clear: in Block: [...
FullBlockClosure(BlockClosure)>>on:do:
WorldMorph>>becomeActiveDuring:
HandMorph>>sendFocusEvent:to:clear:
HandMorph>>sendEvent:focus:clear:
HandMorph>>sendMouseEvent:
HandMorph>>handleEvent:
[
(morphicWorld activeHand isNotNil and: [ anEvent hand isNotNil ]) ifTrue: [
morphicWorld activeHand handleEvent: anEvent
]
] in OSWindowMorphicEventHandler>>dispatchMorphicEvent: in Block: [...
WorldState>>runStepMethodsIn:
WorldMorph>>runStepMethods
WorldState>>doOneCycleFor:
WorldMorph>>doOneCycleNow
WorldMorph>>doOneCycle
[
| extraWorldsToDraw |
extraWorldsToDraw := ExtraWorldListMutex critical: [
self extraWorldList ].
extraWorldsToDraw do: [ :world | world doOneCycle ].

	(self currentWorld isNotNil and: [ 
		 (extraWorldsToDraw includes: self currentWorld) not ]) ifTrue: [ 
		self currentWorld doOneCycle ] ] in WorldMorph class>>doOneCycle in Block: [ ...

FullBlockClosure(BlockClosure)>>ensure:
WorldState class>>doDrawCycleWith:

Problem with caches?

When applying a rewrite rule on some code, previously applied rules could be undone.
What I did:

  • created a rule
  • opened rule transformer tool
  • select the rule and apply it to some code
    Now, without closing any window I continued
  • create a second rule (in the first window)
  • select the new rule in the rule transformer tool and apply it

=> the new rule was applied, but its application was undoing changes of rule 1

This only happened in methods where both rules applied of course.

[Usability] Filtering application scope is strange

  • The Find Occurrences tool has no way to set a filter or scope of search
  • The rewrite basic editor by default allows to apply everywhere, but not to filter, and to filter we need to open a separate window. But the separate window is not to edit a filter, it is a dialog to customise rule running. That was odd.

Browsing rules doesn't work

#fullOnClass; is renamed to #openOnClass:

RewriteRuleBrowser>>#browseRule
Smalltalk tools browser fullOnClass: (Smalltalk globals at: self rules selectedItem)

Change MatchTool UI

  • Move the Match button
  • Add a label to the matches list that says "Matches"

browse method found

it'll be nice if the RTOccurrencesBrowserPresenter let you browse each method found. something like right click on the method found and then select browse it, and it open the browser with that method. it's just an enhancement

DNU when rewriting a variable assignment

I had a rewrite rule

x => self x

and some piece of code

x := foo

However, when the rewrite tool tried to rewrite that it produced

self x := foo

which is invalid. I had a DNU when doing that (the formatter expecting that the left hand side of the assignment is always a variable). But to me the rewriter produced a wrong AST...

It’s not clear to me what should happen.
My guts tell me that not all places where an expression matches, the rewrite applies, and that you may want to know it (like, this is the list of the things I could not apply…).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.