Parser.st
changeset 2098 a03891b6fc30
parent 2093 b6b27c9c4d26
child 2100 fae3bbf851e0
--- a/Parser.st	Mon May 26 10:35:35 2008 +0200
+++ b/Parser.st	Wed May 28 11:42:30 2008 +0200
@@ -2737,10 +2737,41 @@
             ].
         ].
         (classToGenerateCode includesSelector:aSelectorString asSymbol) ifFalse:[
+            |code category wantSetter wantGetter|
+
+            wantSetter := wantGetter := false.
+
+            (aSelectorString isKeywordSelector 
+            and:[aSelectorString numArgs == 1
+            and:[classToGenerateCode instVarNames includes:(aSelectorString copyWithoutLast:1)]]) ifTrue:[
+                "/ want a setter ?
+                wantSetter := Dialog confirmWithCancel:('Create a setter for %1 ?' bindWith:(aSelectorString copyWithoutLast:1) allBold).
+                wantSetter isNil ifTrue:[^ aSelectorString].                 
+            ] ifFalse:[
+                (aSelectorString isUnarySelector 
+                and:[classToGenerateCode instVarNames includes:aSelectorString]) ifTrue:[
+                    "/ want a getter ?
+                    wantGetter := Dialog confirmWithCancel:('Create a getter for %1 ?' bindWith:aSelectorString allBold).
+                    wantGetter isNil ifTrue:[^ aSelectorString].                 
+                ]
+            ].
+            wantSetter ifTrue:[
+                code := ('%1:something\    %1 := something.' bindWith:(aSelectorString copyWithoutLast:1)) withCRs.
+                category := 'accessing'.
+            ] ifFalse:[
+                wantGetter ifTrue:[
+                    code := ('%1\    ^ %1.' bindWith:aSelectorString) withCRs.
+                    category := 'accessing'.
+                ] ifFalse:[
+                    code := (self class methodSpecificationForSelector:aSelectorString) , '\    self shouldImplement' withCRs.
+                    category := Compiler defaultMethodCategory.
+                ].
+            ].
+
             "do not overwrite an already existant (deprecated) method"
             classToGenerateCode
-                compile:((self class methodSpecificationForSelector:aSelectorString) , '\    self shouldImplement' withCRs)
-                classified:(Compiler defaultMethodCategory).
+                compile:code
+                classified:category.
         ].
         correctIt := false.
     ].
@@ -9296,7 +9327,7 @@
 !Parser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.572 2008-05-26 08:32:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.573 2008-05-28 09:42:30 cg Exp $'
 ! !
 
 Parser initialize!