Do not pop up dialogs on PackageRedefinitions when doing a fileIn
authorStefan Vogel <sv@exept.de>
Mon, 25 Apr 2005 16:31:26 +0200
changeset 8867 436f86af36df
parent 8866 a3a1c586310f
child 8868 12ac754138b2
Do not pop up dialogs on PackageRedefinitions when doing a fileIn (for Methods and Classes). These Notifications should be and are handled by the GUI-Applications (Filebrowsers).
PeekableStream.st
--- a/PeekableStream.st	Mon Apr 25 15:46:24 2005 +0200
+++ b/PeekableStream.st	Mon Apr 25 16:31:26 2005 +0200
@@ -167,54 +167,143 @@
 
 !PeekableStream methodsFor:'fileIn'!
 
-askForDebug:message
-    "launch a box asking if a debugger is wanted - used when an error
-     occurs while filing in"
+fileIn
+    "file in from the receiver, i.e. read chunks and evaluate them -
+     return the value of the last chunk."
+
+    |notifiedLoader|
+
+    SourceFileLoader notNil ifTrue:[
+        notifiedLoader := SourceFileLoader on:self.
+    ].
+
+    ^ self fileInNotifying:notifiedLoader passChunk:true.
+!
+
+fileInBinary
+    "file in from the receiver, i.e. read binary stored classes and/or objects.
+     Return the last object."
+
+    |bos obj|
+
+    bos := BinaryObjectStorage onOld:self.
+    Class nameSpaceQuerySignal 
+	answer:Smalltalk
+	do:[
+	    [self atEnd] whileFalse:[
+		obj := bos next.
+	    ]
+	].
+    bos close.
+    ^ obj
 
-    ^ self askForDebug:message canContinueForAll:false
+    "Created: / 13.11.2001 / 10:12:30 / cg"
+    "Modified: / 13.11.2001 / 10:14:04 / cg"
+! !
+
+!PeekableStream methodsFor:'positioning'!
+
+skipAny:skipCollection
+    "skip all characters included in the argument-set.
+     returns the next peeked element or nil, if the end-of-stream was reached."
+
+    |nextOne|
+
+    nextOne := self peekOrNil.
+    [nextOne notNil and:[skipCollection includes:nextOne]] whileTrue:[
+        self next.
+        nextOne := self peekOrNil
+    ].
+    ^ nextOne
+
+    "
+     |s skipChars|
+
+     s := ReadStream on:'some numbers1234with\in other99 stuff' withCRs.
+     skipChars := 'abcdefghijklmnopqrstuvwxyz\ ' withCRs.
+     s skipAny:skipChars.
+     Transcript showCR:(Integer readFrom:s).
+     s skipAny:skipChars.
+     Transcript showCR:(Integer readFrom:s).
+    "
 !
 
-askForDebug:message canContinueForAll:canContinueForAll
-    "launch a box asking if a debugger is wanted - used when an error
-     occurs while filing in"
+skipSeparators
+    "skip all whitespace; returns the next peeked element or
+     nil, if the end-of-stream was reached.
+     The streams elements should be characters.
+     Notice: compare this method to skipSpaces"
+
+    |nextOne|
 
-    |labels values|
+    nextOne := self peekOrNil.
+    [nextOne notNil and:[nextOne isSeparator]] whileTrue:[
+        self next.
+        nextOne := self peekOrNil
+    ].
+    ^ nextOne
+
+    "
+     |s|
 
-    Smalltalk isInitialized ifFalse:[
-        'PositionableStream [warning]: fileIn error during startup: ' errorPrint. message errorPrintCR.
-        ^ #debug
-    ].
-    "/
-    "/ are we in the startup sequence of an image restart ?
-    "/
-    Processor activeProcessIsSystemProcess ifTrue:[
-        'PositionableStream [warning]: fileIn error during startup: ' errorPrint. message errorPrintCR.
-        ^ #continue
-    ].
+     s := ReadStream on:'one      two\three' withCRs.
+     s skipSeparators.
+     Transcript showCR:(s nextWord).
+     s skipSeparators.
+     Transcript showCR:(s nextWord).
+     s skipSeparators.
+     Transcript showCR:(s next displayString).
+    "
+!
+
+skipSeparatorsExceptCR
+    "skip all whitespace except carriage return; returns the 
+     next peeked element or nil, if the end-of-stream was reached.
+     The streams elements should be characters.
+     Notice: compare this method to skipSpaces and skipSeparators"
+
+    |nextOne|
 
-    canContinueForAll ifTrue:[
-          labels := #('Cancel' 'Skip' 'Debug' 'Dont ask again' 'Continue').
-          values := #(#abort   #skip  #debug  #continueForAll #continue).
-    ] ifFalse:[
-          labels := #('Cancel' 'Skip' 'Debug' 'Continue').
-          values := #(#abort  #skip   #debug #continue).
+    nextOne := self peekOrNil.
+    [nextOne notNil 
+     and:[nextOne isSeparator
+     and:[nextOne ~~ Character cr]]] whileTrue:[
+        self next.
+        nextOne := self peekOrNil
     ].
-    AbortAllSignal isHandled ifTrue:[
-      labels := #('Cancel All') , labels.
-      values := #(#cancelAll) , values.
-    ].
+    ^ nextOne
+!
+
+skipSpaces
+    "skip all spaces; returns the next peeked element or
+     nil, if the end-of-stream was reached.
+     The streams elements should be characters.
+     Notice: this one skips only spaces (i.e. no cr, tabs etc)
+             usually, skipSeparators is what you want."
+
+    |nextOne|
 
-    ^ OptionBox 
-          request:message 
-          label:'Error in fileIn'
-          image:(WarningBox iconBitmap)
-          buttonLabels:labels
-          values:values
-          default:#continue
-          onCancel:#abort.
+    nextOne := self peekOrNil.
+    [nextOne notNil and:[nextOne == Character space]] whileTrue:[
+        self next.
+        nextOne := self peekOrNil
+    ].
+    ^ nextOne
+
+    "
+     |s|
 
-    "Modified: 10.1.1997 / 18:00:56 / cg"
-!
+     s := ReadStream on:'one      two\three' withCRs.
+     s skipSpaces.
+     Transcript showCR:(s nextWord).
+     s skipSpaces.
+     Transcript showCR:(s nextWord).
+     s skipSpaces.
+     Transcript showCR:(s next displayString).
+    "
+! !
+
+!PeekableStream methodsFor:'private fileIn'!
 
 basicFileInNotifying:someone passChunk:passChunk
     "central method to file in from the receiver, i.e. read chunks and evaluate them -
@@ -225,13 +314,12 @@
      packageQuerySignal nameSpaceQuerySignal usedNameSpaceQuerySignal
      changeDefaultApplicationNotificationSignal
      defaultApplicationQuerySignal defaultApplication
-     confirmationQuerySignal handledSignals passedSignals
-     dontAskSignals askSomeoneForPackage redef outerContext|
+     confirmationQuerySignal handledSignals passedSignals askSomeoneForPackage outerContext|
 
     self skipSeparators.
     lastValue := self peek.
     lastValue == $< ifTrue:[
-        "/ assume, its an xml file
+        "/ assume, it's an xml file
         ^ self fileInXMLNotifying:someone passChunk:passChunk.
     ].
     lastValue == $# ifTrue:[
@@ -287,8 +375,8 @@
 
     confirmationQuerySignal := Metaclass confirmationQuerySignal.
 
+    handledSignals := SignalSet new.
     passedSignals := IdentitySet new.
-    handledSignals := SignalSet new.
 
     handledSignals add:changeDefaultApplicationNotificationSignal.
     passedSignals add:changeDefaultApplicationNotificationSignal.
@@ -299,20 +387,13 @@
     handledSignals add:usedNameSpaceQuerySignal.
     handledSignals add:nameSpaceQuerySignal.
 
-    handledSignals add:Error.
-    passedSignals add:Error.
-
-    handledSignals add:(Class methodRedefinitionSignal).
-    passedSignals add:(Class methodRedefinitionSignal).
-    handledSignals add:(Class classRedefinitionSignal).
-    passedSignals add:(Class classRedefinitionSignal).
     handledSignals add:confirmationQuerySignal.
     passedSignals add:confirmationQuerySignal.
 
     outerContext := thisContext.
 
     handledSignals handle:[:ex |
-        |sig action what sender msg proceedValue canContinueForAll|
+        |sig|
 
         sig := ex signal.
         ((passedSignals includes:sig) and:[sig isHandledIn:outerContext]) ifTrue:[
@@ -351,127 +432,6 @@
             "don't pop up dialogs"
             ex proceedWith:false
         ].
-
-        sig == Stream endOfStreamSignal ifTrue:[
-            "pass premature end of stream signal"
-            ex reject
-        ].
-
-        sig == NoHandlerError ifTrue:[
-            ex parameter rejected ifTrue:[
-                ex reject
-            ].
-        ].
-
-        (dontAskSignals notNil and:[dontAskSignals includesKey:sig]) ifTrue:[
-            ex proceedWith:(dontAskSignals at:sig)
-        ].
-
-        canContinueForAll := false.
-        redef := false.
-
-        "/ for your convenience ...
-        (sig == Class methodRedefinitionSignal) ifTrue:[
-            msg := 'trying to overwrite method:\\    ' , ex oldMethod whoString , '\\in package ''' 
-                   , ex oldPackage , ''' with method from package ''' , ex newPackage , ''''.
-            canContinueForAll := true.
-        ] ifFalse:[
-            (sig == Class classRedefinitionSignal) ifTrue:[
-                msg := 'trying to redefine class: ' , ex oldClass name allBold , '\\in package ''' 
-                       , ex oldPackage , ''' with new definition from package ''' , ex newPackage , ''''.
-                canContinueForAll := true.
-                redef := true.
-            ] ifFalse:[
-                msg := 'error in fileIn: %1'
-            ]
-        ].
-
-        what := ex description.
-        what isNil ifTrue:[
-            what := ex signal notifierString.
-        ].
-
-        msg := msg bindWith:what.
-
-        "/ handle the case where no GUI has been built in,
-        "/ just abort the fileIn with a notification
-
-        (Screen isNil or:[Screen current isNil]) ifTrue:[
-            sender := ex suspendedContext sender.
-            msg := (msg , '\\in ' , sender receiver class name , '>>' , sender selector) withCRs.
-            "/ self notify:msg.
-	    MiniDebugger enterWithMessage:msg mayProceed:true.
-            ex return
-        ].
-
-        sig == HaltInterrupt ifTrue:[
-            sender := ex suspendedContext.
-            msg := (msg , '\\in ' , sender receiver class name , '>>' , sender selector) withCRs
-        ].
-
-        "/ otherwise ask what should be done now and either
-        "/ continue or abort the fileIn
-
-        redef ifTrue:[
-            action := OptionBox 
-                          request:(msg withCRs) 
-                          label:'Class redefinition in fileIn'
-                          image:(WarningBox iconBitmap)
-"/ cg: now always keep the old packageID
-"/                          buttonLabels:#('cancel' 'skip' 'debug' 'keep' 'keep all' 'continue' 'continue all')
-"/                          values:#(#abort #skip #debug #keep #keepAll #continue #continueForAll)
-                          buttonLabels:#('Cancel' 'Skip' 'Debug' 'Continue' 'Continue All')
-                          values:#(#abort #skip #debug #keep #keepAll)
-                          default:#keep
-                          onCancel:#abort.
-        ] ifFalse:[
-            action := self askForDebug:msg withCRs canContinueForAll:canContinueForAll.
-        ].
-        action == #continueForAll ifTrue:[
-            dontAskSignals isNil ifTrue:[
-                dontAskSignals := IdentityDictionary new.
-            ].
-            dontAskSignals at:sig put:#continue.
-            action := proceedValue := #continue.
-        ] ifFalse:[
-            action == #keepForAll ifTrue:[
-                dontAskSignals isNil ifTrue:[
-                    dontAskSignals := IdentityDictionary new.
-                ].
-                dontAskSignals at:sig put:#keep.
-                action := #continue.
-                proceedValue := #keep.
-            ] ifFalse:[
-                action == #keep ifTrue:[
-                    action := #continue.
-                    proceedValue := #keep.
-                ].
-            ].
-        ].
-
-        action == #continue ifTrue:[
-            ex proceedWith:proceedValue
-        ].
-        action == #abort ifTrue:[
-            AbortOperationRequest raise.
-            ex return
-        ].
-        action == #cancelAll ifTrue:[
-            AbortAllOperationRequest raise.
-            ex return
-        ].
-        action == #skip ifTrue:[
-            ex proceedWith:nil
-        ].
-        action == #debug ifTrue:[
-            Debugger enter:ex suspendedContext 
-                     withMessage:ex description 
-                     mayProceed:true.
-            ex proceedWith:proceedValue
-        ].
-
-        "/ (ex signal) enterDebuggerWith:ex message:what.
-        ex reject
     ] do:[
         [self atEnd] whileFalse:[
             lastValue := self fileInNextChunkNotifying:someone passChunk:passChunk
@@ -483,40 +443,6 @@
     "Modified: / 16.11.2001 / 16:21:28 / cg"
 !
 
-fileIn
-    "file in from the receiver, i.e. read chunks and evaluate them -
-     return the value of the last chunk."
-
-    |notifiedLoader|
-
-    SourceFileLoader notNil ifTrue:[
-        notifiedLoader := SourceFileLoader on:self.
-    ].
-
-    ^ self fileInNotifying:notifiedLoader passChunk:true.
-!
-
-fileInBinary
-    "file in from the receiver, i.e. read binary stored classes and/or objects.
-     Return the last object."
-
-    |bos obj|
-
-    bos := BinaryObjectStorage onOld:self.
-    Class nameSpaceQuerySignal 
-	answer:Smalltalk
-	do:[
-	    [self atEnd] whileFalse:[
-		obj := bos next.
-	    ]
-	].
-    bos close.
-    ^ obj
-
-    "Created: / 13.11.2001 / 10:12:30 / cg"
-    "Modified: / 13.11.2001 / 10:14:04 / cg"
-!
-
 fileInNextChunkNotifying:someone
     "read next chunk, evaluate it and return the result;
      someone (which is usually some codeView) is notified of errors.
@@ -683,108 +609,6 @@
     "/ self halt.
 ! !
 
-!PeekableStream methodsFor:'positioning'!
-
-skipAny:skipCollection
-    "skip all characters included in the argument-set.
-     returns the next peeked element or nil, if the end-of-stream was reached."
-
-    |nextOne|
-
-    nextOne := self peekOrNil.
-    [nextOne notNil and:[skipCollection includes:nextOne]] whileTrue:[
-        self next.
-        nextOne := self peekOrNil
-    ].
-    ^ nextOne
-
-    "
-     |s skipChars|
-
-     s := ReadStream on:'some numbers1234with\in other99 stuff' withCRs.
-     skipChars := 'abcdefghijklmnopqrstuvwxyz\ ' withCRs.
-     s skipAny:skipChars.
-     Transcript showCR:(Integer readFrom:s).
-     s skipAny:skipChars.
-     Transcript showCR:(Integer readFrom:s).
-    "
-!
-
-skipSeparators
-    "skip all whitespace; returns the next peeked element or
-     nil, if the end-of-stream was reached.
-     The streams elements should be characters.
-     Notice: compare this method to skipSpaces"
-
-    |nextOne|
-
-    nextOne := self peekOrNil.
-    [nextOne notNil and:[nextOne isSeparator]] whileTrue:[
-        self next.
-        nextOne := self peekOrNil
-    ].
-    ^ nextOne
-
-    "
-     |s|
-
-     s := ReadStream on:'one      two\three' withCRs.
-     s skipSeparators.
-     Transcript showCR:(s nextWord).
-     s skipSeparators.
-     Transcript showCR:(s nextWord).
-     s skipSeparators.
-     Transcript showCR:(s next displayString).
-    "
-!
-
-skipSeparatorsExceptCR
-    "skip all whitespace except carriage return; returns the 
-     next peeked element or nil, if the end-of-stream was reached.
-     The streams elements should be characters.
-     Notice: compare this method to skipSpaces and skipSeparators"
-
-    |nextOne|
-
-    nextOne := self peekOrNil.
-    [nextOne notNil 
-     and:[nextOne isSeparator
-     and:[nextOne ~~ Character cr]]] whileTrue:[
-        self next.
-        nextOne := self peekOrNil
-    ].
-    ^ nextOne
-!
-
-skipSpaces
-    "skip all spaces; returns the next peeked element or
-     nil, if the end-of-stream was reached.
-     The streams elements should be characters.
-     Notice: this one skips only spaces (i.e. no cr, tabs etc)
-             usually, skipSeparators is what you want."
-
-    |nextOne|
-
-    nextOne := self peekOrNil.
-    [nextOne notNil and:[nextOne == Character space]] whileTrue:[
-        self next.
-        nextOne := self peekOrNil
-    ].
-    ^ nextOne
-
-    "
-     |s|
-
-     s := ReadStream on:'one      two\three' withCRs.
-     s skipSpaces.
-     Transcript showCR:(s nextWord).
-     s skipSpaces.
-     Transcript showCR:(s nextWord).
-     s skipSpaces.
-     Transcript showCR:(s next displayString).
-    "
-! !
-
 !PeekableStream methodsFor:'reading'!
 
 nextDecimalInteger
@@ -932,7 +756,7 @@
 !PeekableStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/PeekableStream.st,v 1.27 2005-01-27 10:32:31 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/PeekableStream.st,v 1.28 2005-04-25 14:31:26 stefan Exp $'
 ! !
 
 PeekableStream initialize!