Parser.st
changeset 1323 34b29c93134b
parent 1322 da25e31f423c
child 1325 2a0700a4b505
--- a/Parser.st	Tue Oct 29 10:39:37 2002 +0100
+++ b/Parser.st	Thu Oct 31 14:41:45 2002 +0100
@@ -564,7 +564,7 @@
     ] ifFalse:[
         aClassOrNil withAllSuperclassesDo:[:cls |
             cls methodDictionary keysAndValuesDo:block.
-            cls class methodDictionary keysAndValuesDo:block.
+            "/ cls class methodDictionary keysAndValuesDo:block.
         ]
     ].
 
@@ -587,12 +587,12 @@
 
 findBestSelectorsFor:aString in:aClassOrNil
     "collect known selectors with their spelling distances to aString;
-     return the 10 best suggestions. If the argument, aClassOrNil is not nil,
+     return the 15 best suggestions. If the argument, aClassOrNil is not nil,
      the message is assumed to be sent to instances of that class (i.e. offer
      corrections from that hierarchy only)"
 
     ^ self
-        findBest:10 selectorsFor:aString in:aClassOrNil
+        findBest:15 selectorsFor:aString in:aClassOrNil
 ! !
 
 !Parser class methodsFor:'evaluating expressions'!
@@ -821,10 +821,13 @@
             value := tree evaluate.
             parser evalExitBlock:nil.
         ] ifFalse:[
-            aStringOrStream isStream ifTrue:[
-                s := parser collectedSource.  "/ does not work yet ...
-            ] ifFalse:[
-                s := aStringOrStream
+            s := parser correctedSource.
+            s isNil ifTrue:[    
+                aStringOrStream isStream ifTrue:[
+                    s := parser collectedSource.  "/ does not work yet ...
+                ] ifFalse:[
+                    s := aStringOrStream
+                ].
             ].
 
             "/ actually, its a block, to allow
@@ -2184,7 +2187,7 @@
     "launch a selection box, which allows user to enter correction.
      return newString or nil (for abort)"
 
-    |box|
+    |box rslt|
 
     "in systems without widgets ..."
     ListSelectionBox isNil ifTrue:[
@@ -2194,9 +2197,31 @@
     box initialText:(aList at:1).
     box list:aList.
     box okText:'Correct'.
-    box action:[:aString | ^ aString].
+    box action:[:aString | rslt := aString].
     box showAtPointer.
-    ^ nil
+    box destroy.
+    ^ rslt
+!
+
+askForCorrection:aString fromList:aList for:originalSelector
+    "launch a selection box, which allows user to enter correction.
+     return newString or nil (for abort)"
+
+    |box rslt|
+
+    "in systems without widgets ..."
+    ListSelectionBox isNil ifTrue:[
+        ^ self confirm:aString
+    ].
+    box := ListSelectionBox title:aString.
+    box initialText:(aList at:1).
+    box list:aList.
+    box okText:'Correct'.
+    box action:[:aString | rslt := aString].
+    box addButton:(Button label:'Keep Selector' action:[rslt := originalSelector. box hide]) after:(box okButton).
+    box showAtPointer.
+    box destroy.
+    ^ rslt
 !
 
 askForVariableTypeWhenDeclaringUndefined:varName
@@ -2472,7 +2497,7 @@
             "do not overwrite an already existant (deprecated) method"
             classToGenerateCode
                 compile:((self class methodSpecificationForSelector:aSelectorString) , '\    self error:''To be implemented'' mayProceed:true' withCRs)
-                classified:'** As yet uncategorized **'.
+                classified:(Compiler defaultMethodCategory).
         ].
         correctIt := false.
     ].
@@ -2483,8 +2508,8 @@
 
     suggestedNames := self findBestSelectorsFor:aSelectorString in:aClassOrNil.
     suggestedNames notNil ifTrue:[
-        newSelector := self askForCorrection:'correct selector to: ' fromList:suggestedNames.
-        newSelector isNil ifTrue:[^ aSelectorString].
+        newSelector := self askForCorrection:'Correct Selector to: ' fromList:suggestedNames for:aSelectorString.
+        newSelector isNil ifTrue:[AbortSignal raise "^ aSelectorString"].
     ] ifFalse:[
         self information:'no good correction found'.
         ^ aSelectorString
@@ -2494,7 +2519,6 @@
      tell requestor (i.e. CodeView) about the change
      this will update what the requestor shows.
     "
-
     requestor replaceSelectionBy:newSelector keepCursor:false.
     "
      get the updated source-string 
@@ -2502,7 +2526,7 @@
     "
     correctedSource := requestor currentSourceCode.
     source := (ReadStream on:correctedSource)
-                  position:(source position + newSelector size - aSelectorString size).
+                  position:(source position + 1 + (newSelector size - aSelectorString size)).
 
     ^ newSelector
 
@@ -6826,7 +6850,7 @@
 !Parser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.349 2002-10-29 09:39:37 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.350 2002-10-31 13:41:45 cg Exp $'
 ! !
 
 Parser initialize!