These are chat archives for JnRouvignac/AutoRefactor

6th
Oct 2016
Luis Cruz
@luiscruz
Oct 06 2016 15:06
How can I visit a block starting from a specific statement?
I would like to visit a block starting from a variable assignment/declaration until the next assignment.
Jean-Noël Rouvignac
@JnRouvignac
Oct 06 2016 15:08
I do not know any way
I'd say you need to visit the whole parent block
Luis Cruz
@luiscruz
Oct 06 2016 15:10
ham, perhaps I will ignore the following case:
    public void testMultipleAssignment(Uri uri, ContentProvider provider){
        Cursor query = provider.query(uri, null, null, null, null);
        query = provider.query(uri, null, null, null, null);
        query.close();
    }
Jean-Noël Rouvignac
@JnRouvignac
Oct 06 2016 15:10
And wait until you visit the variable assignment / declaration of interest, then only start visiting from there
It would be better to use a decorator pattern for that
Luis Cruz
@luiscruz
Oct 06 2016 15:11
you mean creating somekinf od state machine, right?
Jean-Noël Rouvignac
@JnRouvignac
Oct 06 2016 15:11
Hmm dunno :)
As you wish
No state machine
Two visitors:
One implements the detection you want
Another accepts the first as a delegate and filters all calls to visit until the variable declaration / assignment is met and then it lets calls go through
Luis Cruz
@luiscruz
Oct 06 2016 15:17
I didn’t get how do I switch visitors
:\
Jean-Noël Rouvignac
@JnRouvignac
Oct 06 2016 15:20
I cannot code right now
Luis Cruz
@luiscruz
Oct 06 2016 15:20
no worries
Jean-Noël Rouvignac
@JnRouvignac
Oct 06 2016 15:20
I'll try to find an example online
Luis Cruz
@luiscruz
Oct 06 2016 15:21
I’m familiar with the decorator pattern but I’m not getting how to change a visitor during the visit flow
I’ll work on something else in the mean time. No rush ;)
Jean-Noël Rouvignac
@JnRouvignac
Oct 06 2016 15:25
You do not change the visitor
The filtering visitor takes the visitor doing the work as delegate (said otherwise it decorates it)
It does not forward any calls to visit until the node of interest is seen
From then on, it forwards all calls to the decorated visitor
Let me
know if this was clearer
Luis Cruz
@luiscruz
Oct 06 2016 15:29
it was
I get it
thanks!
Jean-Noël Rouvignac
@JnRouvignac
Oct 06 2016 15:38
Great! :)
Luis Cruz
@luiscruz
Oct 06 2016 16:44
done!
and working
:D