Le 22/09/2015 17:56, Yuriy Tymchuk a écrit :
Hi everyone,

I need someone who knows how RBParseTreeRewriter & co. work. May of
quality rules are implemented as rewrite rules which is cool. But
they don’t report the interval in source code which can be
highlighted to help with understanding of the issue.

Now… the check happens in RBTransformationRule>>#checkMethod:. Is it
possible to obtain the matched string there? Because in that case we
can get highlighting working which will be very useful.

Silly me. It's so simple:

| rw |
rw := RBParseTreeRewriter new.
rw
        replace: ' `#a `{:aNode | aNode value isCharacter}'
        with: '`#a newMessage'
        when: [:n | n logCr. false].

Use the when: block argument to trace all the matched nodes. Once you have the nodes, you can highlight them.

Thierry

Cheers! Uko



Reply via email to