<div dir="ltr"><div>Hello folks!<br><br>Here's a small fix in Extract Method. The problem was that Extract Method was looking for code using the optimized AST (<font face="monospace">CompiledMethod>>#methodNode</font>) instead of the non-optimized AST (<font face="monospace">CompiledMethod>>#notOptimizedMethodNode</font>) as it should be.<br><br>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.<br><br>A concrete example: given the following method:<br><br><font face="monospace">m1<br>    self foo ifNil: [ ^1 ] ifNotNil: [ ^2 ]<br></font><br>If you try to extract <font face="monospace">self</font><font face="monospace"> foo</font>, the optimized AST transforms the #<font face="monospace">ifNil:ifNotNil:</font> send into a comparison node (<font face="monospace">self foo = nil</font>) 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.<br><br>The fix replaces the use of <font face="monospace">#methodNode</font> with <font face="monospace">#notOptimizedMethodNode</font> so that Extract Method always works on the AST that faithfully represents what the developer wrote.<br><br>Cheers</div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><br></div><a href="https://10pines.com/" style="font-family:Roboto,Helvetica,Arial,sans-serif;font-size:medium" target="_blank"><img width="108" src="https://10pines.github.io/email-signature/10pines-firma@2x.png" style="margin-bottom:0.5em"></a><h1 style="margin:0px;font-size:14px"><font color="#999999">Joel Cámera</font></h1><h2 style="color:rgb(100,100,100);margin:0px 0px 1em;font-size:14px">Agile Software Development</h2><h1 style="margin:0px;font-size:14px"><font style="font-weight:normal" color="#666666"><p style="margin:0px;font-size:12px">Alem 896, Floor 6, Buenos Aires, Argentina</p><p style="margin:0px;font-size:12px">+54 9 011 6091 3125</p></font></h1></div></div></div></div>