SmalltalkCodeGeneratorTool.st
changeset 16779 288875950e56
parent 16672 d65bbfc8a2f7
child 16786 db6841c714f6
--- a/SmalltalkCodeGeneratorTool.st	Wed Aug 03 12:42:46 2016 +0200
+++ b/SmalltalkCodeGeneratorTool.st	Mon Aug 08 15:57:46 2016 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 2002 by eXept Software AG
               All Rights Reserved
@@ -156,7 +154,7 @@
     <resource: #canvas>
 
     ^ ',
-        self initialWindowSpecForApplications2 decodeAsLiteralArray prettyPrintString           
+        self initialWindowSpecForApplications2 decodeAsLiteralArray prettyPrintString
 .
 
     "
@@ -181,7 +179,7 @@
     <resource: #canvas>
 
     ^ ',
-        self initialWindowSpecForDialogs decodeAsLiteralArray prettyPrintString           
+        self initialWindowSpecForDialogs decodeAsLiteralArray prettyPrintString
 ! !
 
 !SmalltalkCodeGeneratorTool class methodsFor:'code generation-menus'!
@@ -263,7 +261,7 @@
 !SmalltalkCodeGeneratorTool class methodsFor:'compilation'!
 
 compile:theCode forClass:aClass inCategory:cat
-    "install some code for a class. 
+    "install some code for a class.
      Return the new method or nil.
      If refactory browser stuff is avaliable, the refactory tools are used to support undo"
 
@@ -342,7 +340,7 @@
 '"
  change the above template into real code;
  remove this comment.
- Then `accept'' either via the menu 
+ Then `accept'' either via the menu
  or via the keyboard (usually CMD-A).
 
  You do not need this template; you can also
@@ -385,7 +383,7 @@
     [class variables:]
         describe class variables
     [see also:]
-        
+
     [author:]
         %1
 "
@@ -571,7 +569,7 @@
     self startCollectChanges.
 
     (metaClass includesSelector:#examples) ifFalse:[
-        code := 
+        code :=
 'examples
 "
  Notice that everything between [exBegin] and [exEnd] is extracted by the html-doc generator
@@ -595,11 +593,11 @@
     top open
                                                         [exEnd]
 "
-' bindWith:className.    
-
-        self 
+' bindWith:className.
+
+        self
             compile:code
-            forClass:metaClass 
+            forClass:metaClass
             inCategory:#documentation.
     ].
 
@@ -1138,43 +1136,43 @@
     self createAcceptVisitorMethod:sel in:visitedClass.
 
     (visitorClass includesSelector:sel) ifFalse:[
-        self 
+        self
             compile:
-(('%1anObject 
+(('%1anObject
     "dispatched back from the visited %2-object (visitor pattern)"
 
     "fall back to general object-case - please change as required"
 
     ^ self visitObject:anObject
 ') bindWith:sel with:visitedClass nameWithoutPrefix asLowercaseFirst)
-            forClass:visitorClass 
+            forClass:visitorClass
             inCategory:#visiting.
     ].
 
     (visitorClass includesSelector:#visitObject:) ifFalse:[
-        self 
+        self
             compile:
-('visitObject:anObject 
+('visitObject:anObject
     "dispatched back from the visited objects (visitor pattern)"
 
     "general fallBack - please change as required"
 
     self halt:''not yet implemented''
 ')
-            forClass:visitorClass 
+            forClass:visitorClass
             inCategory:#visiting.
     ].
 
     (visitorClass includesSelector:#visit:) ifFalse:[
-        self 
+        self
             compile:
-('visit:anObject 
+('visit:anObject
     "visit anObject (visitor pattern).
      The object should call back one of my visitXXXX methods."
 
     ^ anObject acceptVisitor:self
 ')
-            forClass:visitorClass 
+            forClass:visitorClass
             inCategory:#visiting.
     ].
 
@@ -1460,7 +1458,7 @@
     metaClass := aClass theMetaclass.
     className := nonMetaClass name.
 
-    compileTemplateAction := 
+    compileTemplateAction :=
         [:selector :templateSelector :category |
             (nonMetaClass includesSelector:selector) ifFalse:[
                 |txt|
@@ -1468,7 +1466,7 @@
                 txt := self perform:templateSelector.
                 self
                     compile:txt
-                    forClass:nonMetaClass 
+                    forClass:nonMetaClass
                     inCategory:category.
             ]
         ].
@@ -1811,7 +1809,7 @@
     self assert:( aClass isMeta not ).
 
     (aClass includesSelector:#'acceptVisitor:') ifFalse:[
-        self 
+        self
             compile:
 (('acceptVisitor:visitor %2
     "Double dispatch back to the visitor, passing my type encoded in
@@ -1821,7 +1819,7 @@
 
     ^ visitor %1self %2
 ') bindWith:selector with:(withParameter ifTrue:[' with: parameter'] ifFalse:['']))
-            forClass:aClass 
+            forClass:aClass
             inCategory:#visiting.
     ]
 
@@ -2042,7 +2040,7 @@
     "return false here; to be redefined in subclass(es)"
 
     ^ false
-' 
+'
               forClass:aClass 
               inCategory:cat.
     ].
@@ -2064,16 +2062,16 @@
     self
         compile: ((sel,
             '\', comment,
-            '\\' , 
+            '\\' ,
             '    "\',
             '     self ' , sel , ' inspect\',
             '     ImageEditor openOnClass:self andSelector:#', sel, '\',
-            '     Icon flushCachedIcons', 
+            '     Icon flushCachedIcons',
             '\    "',
             '\\',
             '    <resource: #image>',
             '\\',
-            '    ^Icon\') withCRs, 
+            '    ^Icon\') withCRs,
             '        constantNamed:''', imageKey, '''\' withCRs,
             '        ifAbsentPut:[', imageStoreStream contents, ']')
         forClass:aClass
@@ -2407,7 +2405,7 @@
 
     ^
 'hasUnsavedChanges
-    "Return true, if any unsaved changes are present 
+    "Return true, if any unsaved changes are present
      (i.e. the contents needs to be saved or else will be lost)"
 
     "/ add real code as required (or remove the halt and always return false)...
@@ -2426,10 +2424,10 @@
 
     "/ change below as required... (see examples in Dialog class for more options)
     Dialog
-        requestSaveFileName:(resources string:''Save'') 
-        default:''foo.txt'' 
-        fromDirectory:nil 
-        action:[:fileName | self doSaveAs:fileName] 
+        requestSaveFileName:(resources string:''Save'')
+        default:''foo.txt''
+        fromDirectory:nil
+        action:[:fileName | self doSaveAs:fileName]
         appendAction:nil.
 '.
 
@@ -2480,7 +2478,7 @@
 'postBuildWith:aBuilder
     "This is a hook method generated by the Browser/CodeGeneratorTool.
      It will be invoked during the initialization of your app/dialog,
-     after all of the visual components have been built, 
+     after all of the visual components have been built,
      but BEFORE the top window is made visible.
      Add any app-specific actions here (reading files, setting up values etc.)
      See also #postOpenWith:, which is invoked after opening."
@@ -2529,13 +2527,13 @@
     generateComments ifFalse:[
         ^
 'applicationRegistryPath
-    ^ #(''stx'' ''%1'') 
+    ^ #(''stx'' ''%1'')
 ' bindWith:pkg.
     ].
 
     ^
 'applicationRegistryPath
-    "for windows only: 
+    "for windows only:
      the key under which this application stores its process ID in the registry
      as a collection of path-components.
      i.e. if #(''foo'' ''bar'' ''baz'') is returned here, the current application''s ID will be stored
@@ -2553,7 +2551,7 @@
     generateComments ifFalse:[
         ^
 'applicationUUID
-    ^ UUID fromString:''', UUID genUUID printString, ''' 
+    ^ UUID fromString:''', UUID genUUID printString, '''
 '.
     ].
 
@@ -2563,11 +2561,11 @@
      This is used as the name of some exclusive OS-resource, which is used to find out,
      if another instance of this application is already running.
      Under win32, a mutex is used; under unix, an exclusive file in the tempDir could be used.
-     If redefined, please return a real UUID (i.e. UUID fromString:''.....'') and not a string or 
+     If redefined, please return a real UUID (i.e. UUID fromString:''.....'') and not a string or
      similar possibly conflicting identifier.
      You can paste a fresh worldwide unique id via the editor''s more-misc-paste UUID menuFunction."
 
-    ^ UUID fromString:''', UUID genUUID printString, ''' 
+    ^ UUID fromString:''', UUID genUUID printString, '''
 '.
 
     "Created: / 19-08-2011 / 02:13:19 / cg"
@@ -2596,14 +2594,14 @@
 "/            put:[:opt | cOption := true];
         at:$h
             put:[:opt | helpOption := true];
-        at:$? 
+        at:$?
             put:[:arg | self usage. Smalltalk exitIfStandalone:0];
         default:[:arg | fileArgs add:arg];
         onError:[:msg | Stderr nextPutLine:msg. self usage];
         parse:argv.
 
-    helpOption ifTrue:[ 
-        self usage. 
+    helpOption ifTrue:[
+        self usage.
     ] ifFalse:[
         self realMain:argv.
     ].
@@ -2717,7 +2715,7 @@
         comment := '
     "called to redraw a part of the widgets area. x/y define the origin, w/h the size of
      that area. The clipping region has already been set by the caller, so even if the code
-     below draws outside the redraw-area, it will not affect what is on the screen. 
+     below draws outside the redraw-area, it will not affect what is on the screen.
      Therefore, the example below can fill the rectangle in the redraw area, but still draw
      the cross in the outside regions."
 
@@ -2747,7 +2745,7 @@
 
     ^
 'sizeChanged:how
-    "Invoked whenever the size of the view changes. 
+    "Invoked whenever the size of the view changes.
      Here, we force a full redraw, which might not be needed all the time"
 
     self invalidate.
@@ -2810,7 +2808,7 @@
     mthd := implClass compiledMethodAt:selector.
 
     methodBodyStream := '' writeStream.
-    methodBodyStream 
+    methodBodyStream
         nextPutAll:mthd methodDefinitionTemplate; cr;
         nextPutAll:'    "'.
 
@@ -2818,18 +2816,18 @@
 
     comment := mthd methodComment.
     comment isEmptyOrNil ifTrue:[
-        methodBodyStream 
-            nextPutAll:('superclass <1s> says that I am responsible to implement this method'  
+        methodBodyStream
+            nextPutAll:('superclass <1s> says that I am responsible to implement this method'
                         expandMacrosWith:implClass name)
     ] ifFalse:[
-        comment 
+        comment
             asStringCollection do:[:eachLine|
                 methodBodyStream nextPutAll:eachLine.
             ] separatedBy:[
                 methodBodyStream cr; nextPutAll:'     '.
             ].
     ].
-    methodBodyStream 
+    methodBodyStream
         nextPut:$"; cr; cr.
 
     "/ include the argument of the subclassResponsibility:-sending method
@@ -2838,7 +2836,7 @@
             searcher := ParseTreeSearcher new.
             searcher
                     matches: 'self subclassResponsibility: `''.*'''
-                    do:[:node :answer | 
+                    do:[:node :answer |
                         errorMessageString := node arguments first value.
                         true.
                     ].
@@ -2846,11 +2844,11 @@
         ].
     ].
     errorMessageString notEmptyOrNil ifTrue:[
-        methodBodyStream 
-            nextPutAll:'    ^ self shouldImplement:'; 
+        methodBodyStream
+            nextPutAll:'    ^ self shouldImplement:';
             nextPutLine:(errorMessageString storeString)
     ] ifFalse:[
-        methodBodyStream 
+        methodBodyStream
             nextPutLine:'    ^ self shouldImplement'.
     ].