[Cuis-dev] Fix in ExtractMethod
Juan Vuletich
juan at cuis.st
Mon Aug 3 07:05:31 PDT 2026
Thanks Joel.
This is integrated and now at GitHub.
Cheers,
On 2026-07-30 8:41 PM, Joel Camera via Cuis-dev wrote:
> Hello folks!
>
> Here's a small fix in Extract Method. The problem was that Extract
> Method was looking for code using the optimized AST
> (CompiledMethod>>#methodNode) instead of the non-optimized AST
> (CompiledMethod>>#notOptimizedMethodNode) as it should be.
>
> When visiting the optimized AST (using a visitor or `#nodesDo:`), some
> nodes appear that don't exist in the original source code and
> therefore have no valid source ranges. This makes them unusable for
> refactorings.
>
> A concrete example: given the following method:
>
> m1
> self foo ifNil: [ ^1 ] ifNotNil: [ ^2 ]
>
> If you try to extract selffoo, the optimized AST transforms the
> #ifNil:ifNotNil: send into a comparison node (self foo = nil) that
> doesn't exist in the actual source code and has no valid source range.
> When the Extract Method tries to work with that node, it breaks.
>
> The fix replaces the use of #methodNode with #notOptimizedMethodNode
> so that Extract Method always works on the AST that faithfully
> represents what the developer wrote.
>
> Cheers
>
> <https://10pines.com/>
>
>
> Joel Cámera
>
>
> Agile Software Development
>
>
> Alem 896, Floor 6, Buenos Aires, Argentina
>
> +54 9 011 6091 3125
>
>
--
Juan Vuletich
www.cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20260803/eaf29e29/attachment.htm>
More information about the Cuis-dev
mailing list