[Cuis-dev] Fix in ExtractMethod
Joel Camera
joel.camera at 10pines.com
Thu Jul 30 16:41:39 PDT 2026
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 self foo, 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ámeraAgile Software Development
Alem 896, Floor 6, Buenos Aires, Argentina
+54 9 011 6091 3125
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20260730/26049f9c/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 8095-CuisCore-JoelEstebanCamera-2026Jul27-21h01m-JEC.001.cs.st
Type: application/octet-stream
Size: 666 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20260730/26049f9c/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: UnsavedChangesTo-BaseImageTests-JEC.001.cs.st
Type: application/octet-stream
Size: 516 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20260730/26049f9c/attachment-0001.obj>
More information about the Cuis-dev
mailing list