[Cuis-dev] Fix for Extract Method parameter order
Nicolás Papagna Maldonado
nicolas.papagna at gmail.com
Wed Sep 10 14:38:05 PDT 2025
Hi folks,
Attached is a fix for the order in which the parameters of the extract
method refactoring
*Actual behavior*: when extracting a method using the Extract Method
refactoring, the order of the parameters is non-deterministic.
Trying to extract a + b from the following example multiple times might
suggest to the user the message keyword1: a keyword2: b or keyword1: b
keyword2: a randomly.
a := 1.
b := 2.
^ a + b
This bug has two causes:
- Encoder>>#initializeCompleteSourceRangesBasedOn: uses a Dictionary to
store source ranges.
- Even if this is fixed, Encoder itself uses a Dictionary to store
source ranges (used in the method above).
This use of Dictionary makes enumeration order non-deterministic.
*Expected behavior*: parameters should be suggested in the order they
appear in the source code.
*Proposed solution*: the bug was fixed by sorting the parameter nodes for
the method to be extracted by the position they appear in the source code.
Cheers!
Nico PM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250910/8b04cc4a/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 7540-FixOrderOfParametersWhenExtractingAMethod-NicolasPapagnaMaldonado-2025Sep10-17h55m-NPM.001.cs.st
Type: application/octet-stream
Size: 1876 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250910/8b04cc4a/attachment.obj>
More information about the Cuis-dev
mailing list