SmallSense__SmalltalkEditSupport.st
changeset 444 a47f43af21d6
parent 396 015297b155fe
child 445 783f2a4af9c2
--- a/SmallSense__SmalltalkEditSupport.st	Sat Feb 21 22:54:44 2015 +0000
+++ b/SmallSense__SmalltalkEditSupport.st	Wed Mar 04 09:51:20 2015 +0000
@@ -196,22 +196,15 @@
                     (#( #do #select #reject #detect #contains #allSatisfy #anySatisfy )
                         includes:lastValue0)
                             ifTrue:[
-                                | collectionName  eachName  space  part1  part2 |
+                                | collectionName iterationVariableName space part1 part2 |
 
-                                space := RBFormatter spaceAfterKeywordSelector ifTrue:[
-                                        ' '
-                                    ] ifFalse:[ '' ].
-                                eachName := 'each'.
+                                space := RBFormatter spaceAfterKeywordSelector ifTrue:[' '] ifFalse:[ '' ].
+                                iterationVariableName := 'each'.
                                 tokens size > 4 ifTrue:[
-                                    ((collectionName := tokens at:tokens size - 6) last = $s) ifTrue:[
-                                        (collectionName endsWith:'ses') ifTrue:[
-                                            eachName := collectionName copyButLast:2
-                                        ] ifFalse:[
-                                            eachName := collectionName copyButLast:1
-                                        ].
-                                    ].
+                                    collectionName := tokens at:tokens size - 6.
+                                    iterationVariableName := self iterationVariableNameForCollectionNamed: collectionName.
                                 ].
-                                part1 := ':' , space , '[:' , eachName , ' | '.
+                                part1 := ':' , space , '[:' , iterationVariableName , ' | '.
                                 part2 := ' ]'.
                                 self electricInsert:part1 , part2 advanceCursorBy:part1 size.
                                 ^ true.
@@ -225,7 +218,7 @@
     ^ false.
 
     "Created: / 22-10-2013 / 03:05:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 12-02-2015 / 00:02:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (format): / 04-03-2015 / 07:54:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 electricInsertSnippetAfterSpace
@@ -565,6 +558,28 @@
 
 !SmalltalkEditSupport methodsFor:'private'!
 
+iterationVariableNameForCollectionNamed: collectionName
+    | eachName |
+
+    eachName := 'each'.
+    ((collectionName) last = $s) ifTrue:[
+        (collectionName endsWith:'ses') ifTrue:[
+            eachName := collectionName copyButLast:2
+        ] ifFalse:[
+            eachName := collectionName copyButLast:1
+        ].
+        UserPreferences current smallSenseSmalltalkIterationVariableNamePrefixWithEach ifTrue:[ 
+            eachName := 'each' , eachName capitalized.
+        ].
+        eachName size > UserPreferences current smallSenseSmalltalkIterationVariableNameMaxLength ifTrue:[ 
+            eachName := 'each'.
+        ].
+    ].
+    ^ eachName
+
+    "Created: / 04-03-2015 / 07:52:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 tokensAtCursorLine
     | line scanner token |