add access methods generator for ValueHolder with change notification
authorJakub Nesveda <jakubnesveda@seznam.cz>
Sun, 13 Jul 2014 17:25:15 +0200
changeset 613 9bb8c8bebb10
parent 612 deb04cc2370d
child 614 66a50b63a877
add access methods generator for ValueHolder with change notification
CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator.st
CustomValueHolderWithChangeNotificationAccessMethodsCodeGeneratorTests.st
Make.proto
Make.spec
abbrev.stc
bc.mak
jn_refactoring_custom.st
libInit.cc
refactoring_custom.rc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator.st	Sun Jul 13 17:25:15 2014 +0200
@@ -0,0 +1,44 @@
+"{ Package: 'jn:refactoring_custom' }"
+
+CustomAccessMethodsCodeGenerator subclass:#CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Interface-Refactoring-Custom'
+!
+
+!CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator class methodsFor:'accessing-presentation'!
+
+description
+    "Returns more detailed description of the receiver"
+    
+    ^ 'Access Method(s) for ValueHolder with Change Notification for selected instance variables'
+
+    "Modified: / 13-07-2014 / 17:13:46 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
+label
+    "Returns show label describing the receiver. This label
+     is used in UI as menu item/tree item label."
+    
+    ^ 'Access Method(s) for ValueHolder with Change Notification'
+
+    "Modified: / 13-07-2014 / 17:13:33 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+! !
+
+!CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator methodsFor:'executing'!
+
+buildInContext: aCustomContext
+    "Creates access methods XX for given context"
+
+    self
+        executeSubGeneratorClasses: (
+            Array
+                with: CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator
+                with: CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator
+        ) 
+        inContext: aCustomContext
+
+    "Modified: / 13-07-2014 / 17:12:58 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+! !
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CustomValueHolderWithChangeNotificationAccessMethodsCodeGeneratorTests.st	Sun Jul 13 17:25:15 2014 +0200
@@ -0,0 +1,101 @@
+"{ Package: 'jn:refactoring_custom' }"
+
+CustomCodeGeneratorTestCase subclass:#CustomValueHolderWithChangeNotificationAccessMethodsCodeGeneratorTests
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Interface-Refactoring-Custom-Tests'
+!
+
+!CustomValueHolderWithChangeNotificationAccessMethodsCodeGeneratorTests methodsFor:'accessing'!
+
+generator
+    ^ CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator new
+! !
+
+!CustomValueHolderWithChangeNotificationAccessMethodsCodeGeneratorTests methodsFor:'tests'!
+
+test_value_holder_access_methods_generated_with_comments
+    | expectedGetterSource expectedSetterSource |
+
+    userPreferences
+        generateCommentsForGetters: true;
+        generateCommentsForSetters: true.
+
+    expectedGetterSource := 'instanceVariable
+    "return/create the ''instanceVariable'' value holder with change notification (automatically generated)"
+
+    instanceVariable isNil ifTrue:[
+        instanceVariable := ValueHolder new.
+        instanceVariable addDependent:self.
+    ].
+    ^ instanceVariable'. 
+
+    expectedSetterSource := 'instanceVariable:something
+    "set the ''instanceVariable'' value holder (automatically generated)"
+
+    |oldValue newValue|
+
+    instanceVariable notNil ifTrue:[
+        oldValue := instanceVariable value.
+        instanceVariable removeDependent:self.
+    ].
+    instanceVariable := something.
+    instanceVariable notNil ifTrue:[
+        instanceVariable addDependent:self.
+    ].
+    newValue := instanceVariable value.
+    oldValue ~~ newValue ifTrue:[
+        self
+            update:#value
+            with:newValue
+            from:instanceVariable.
+    ].'.
+
+    self executeGeneratorInContext: #classWithInstanceVariable.
+    self assertMethodSource: expectedGetterSource atSelector: #instanceVariable.
+    self assertMethodSource: expectedSetterSource atSelector: #instanceVariable:
+
+    "Created: / 13-07-2014 / 17:16:44 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
+test_value_holder_access_methods_generated_without_comments
+    | expectedGetterSource expectedSetterSource |
+
+    userPreferences
+        generateCommentsForGetters: false;
+        generateCommentsForSetters: false.
+
+    expectedGetterSource := 'instanceVariable
+    instanceVariable isNil ifTrue:[
+        instanceVariable := ValueHolder new.
+        instanceVariable addDependent:self.
+    ].
+    ^ instanceVariable'. 
+
+    expectedSetterSource := 'instanceVariable:something
+    |oldValue newValue|
+
+    instanceVariable notNil ifTrue:[
+        oldValue := instanceVariable value.
+        instanceVariable removeDependent:self.
+    ].
+    instanceVariable := something.
+    instanceVariable notNil ifTrue:[
+        instanceVariable addDependent:self.
+    ].
+    newValue := instanceVariable value.
+    oldValue ~~ newValue ifTrue:[
+        self
+            update:#value
+            with:newValue
+            from:instanceVariable.
+    ].'.
+
+    self executeGeneratorInContext: #classWithInstanceVariable.
+    self assertMethodSource: expectedGetterSource atSelector: #instanceVariable.
+    self assertMethodSource: expectedSetterSource atSelector: #instanceVariable:
+
+    "Created: / 13-07-2014 / 17:23:09 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+! !
+
--- a/Make.proto	Sun Jul 13 17:11:05 2014 +0200
+++ b/Make.proto	Sun Jul 13 17:25:15 2014 +0200
@@ -173,6 +173,7 @@
 $(OUTDIR)CustomSimpleTestCaseCodeGenerator.$(O) CustomSimpleTestCaseCodeGenerator.$(H): CustomSimpleTestCaseCodeGenerator.st $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomTestCaseCodeGenerator.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libtool/CodeGeneratorTool.$(H) $(STCHDR)
 $(OUTDIR)CustomValueHolderAccessMethodsCodeGenerator.$(O) CustomValueHolderAccessMethodsCodeGenerator.$(H): CustomValueHolderAccessMethodsCodeGenerator.st $(INCLUDE_TOP)/jn/refactoring_custom/CustomAccessMethodsCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libtool/CodeGeneratorTool.$(H) $(STCHDR)
 $(OUTDIR)CustomValueHolderGetterMethodsCodeGenerator.$(O) CustomValueHolderGetterMethodsCodeGenerator.$(H): CustomValueHolderGetterMethodsCodeGenerator.st $(INCLUDE_TOP)/jn/refactoring_custom/CustomAccessMethodsCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libtool/CodeGeneratorTool.$(H) $(STCHDR)
+$(OUTDIR)CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator.$(O) CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator.$(H): CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator.st $(INCLUDE_TOP)/jn/refactoring_custom/CustomAccessMethodsCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libtool/CodeGeneratorTool.$(H) $(STCHDR)
 $(OUTDIR)CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator.$(O) CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator.$(H): CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator.st $(INCLUDE_TOP)/jn/refactoring_custom/CustomAccessMethodsCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libtool/CodeGeneratorTool.$(H) $(STCHDR)
 $(OUTDIR)CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator.$(O) CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator.$(H): CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator.st $(INCLUDE_TOP)/jn/refactoring_custom/CustomAccessMethodsCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libtool/CodeGeneratorTool.$(H) $(STCHDR)
 $(OUTDIR)CustomVisitorCodeGeneratorAcceptVisitor.$(O) CustomVisitorCodeGeneratorAcceptVisitor.$(H): CustomVisitorCodeGeneratorAcceptVisitor.st $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomVisitorCodeGenerator.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libtool/CodeGeneratorTool.$(H) $(STCHDR)
--- a/Make.spec	Sun Jul 13 17:11:05 2014 +0200
+++ b/Make.spec	Sun Jul 13 17:25:15 2014 +0200
@@ -91,6 +91,7 @@
 	CustomSimpleTestCaseCodeGenerator \
 	CustomValueHolderAccessMethodsCodeGenerator \
 	CustomValueHolderGetterMethodsCodeGenerator \
+	CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator \
 	CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator \
 	CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator \
 	CustomVisitorCodeGeneratorAcceptVisitor \
@@ -140,6 +141,7 @@
     $(OUTDIR_SLASH)CustomSimpleTestCaseCodeGenerator.$(O) \
     $(OUTDIR_SLASH)CustomValueHolderAccessMethodsCodeGenerator.$(O) \
     $(OUTDIR_SLASH)CustomValueHolderGetterMethodsCodeGenerator.$(O) \
+    $(OUTDIR_SLASH)CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator.$(O) \
     $(OUTDIR_SLASH)CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator.$(O) \
     $(OUTDIR_SLASH)CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator.$(O) \
     $(OUTDIR_SLASH)CustomVisitorCodeGeneratorAcceptVisitor.$(O) \
--- a/abbrev.stc	Sun Jul 13 17:11:05 2014 +0200
+++ b/abbrev.stc	Sun Jul 13 17:25:15 2014 +0200
@@ -43,6 +43,7 @@
 CustomUserDialog CustomUserDialog jn:refactoring_custom 'Interface-Refactoring-Custom' 0
 CustomValueHolderAccessMethodsCodeGeneratorTests CustomValueHolderAccessMethodsCodeGeneratorTests jn:refactoring_custom 'Interface-Refactoring-Custom-Tests' 1
 CustomValueHolderGetterMethodsCodeGeneratorTests CustomValueHolderGetterMethodsCodeGeneratorTests jn:refactoring_custom 'Interface-Refactoring-Custom-Tests' 1
+CustomValueHolderWithChangeNotificationAccessMethodsCodeGeneratorTests CustomValueHolderWithChangeNotificationAccessMethodsCodeGeneratorTests jn:refactoring_custom 'Interface-Refactoring-Custom-Tests' 1
 CustomValueHolderWithChangeNotificationGetterMethodsCodeGeneratorTests CustomValueHolderWithChangeNotificationGetterMethodsCodeGeneratorTests jn:refactoring_custom 'Interface-Refactoring-Custom-Tests' 1
 CustomValueHolderWithChangeNotificationSetterMethodsCodeGeneratorTests CustomValueHolderWithChangeNotificationSetterMethodsCodeGeneratorTests jn:refactoring_custom 'Interface-Refactoring-Custom-Tests' 1
 CustomAccessGeneratorClassCodeGenerator CustomAccessGeneratorClassCodeGenerator jn:refactoring_custom '' 0
@@ -66,6 +67,7 @@
 CustomSimpleTestCaseCodeGenerator CustomSimpleTestCaseCodeGenerator jn:refactoring_custom 'Interface-Refactoring-Custom' 0
 CustomValueHolderAccessMethodsCodeGenerator CustomValueHolderAccessMethodsCodeGenerator jn:refactoring_custom 'Interface-Refactoring-Custom' 0
 CustomValueHolderGetterMethodsCodeGenerator CustomValueHolderGetterMethodsCodeGenerator jn:refactoring_custom 'Interface-Refactoring-Custom' 0
+CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator jn:refactoring_custom 'Interface-Refactoring-Custom' 0
 CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator jn:refactoring_custom 'Interface-Refactoring-Custom' 0
 CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator jn:refactoring_custom 'Interface-Refactoring-Custom' 0
 CustomVisitorCodeGeneratorAcceptVisitor CustomVisitorCodeGeneratorAcceptVisitor jn:refactoring_custom 'Interface-Refactoring-Custom' 0
--- a/bc.mak	Sun Jul 13 17:11:05 2014 +0200
+++ b/bc.mak	Sun Jul 13 17:25:15 2014 +0200
@@ -119,6 +119,7 @@
 $(OUTDIR)CustomSimpleTestCaseCodeGenerator.$(O) CustomSimpleTestCaseCodeGenerator.$(H): CustomSimpleTestCaseCodeGenerator.st $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomTestCaseCodeGenerator.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libtool\CodeGeneratorTool.$(H) $(STCHDR)
 $(OUTDIR)CustomValueHolderAccessMethodsCodeGenerator.$(O) CustomValueHolderAccessMethodsCodeGenerator.$(H): CustomValueHolderAccessMethodsCodeGenerator.st $(INCLUDE_TOP)\jn\refactoring_custom\CustomAccessMethodsCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libtool\CodeGeneratorTool.$(H) $(STCHDR)
 $(OUTDIR)CustomValueHolderGetterMethodsCodeGenerator.$(O) CustomValueHolderGetterMethodsCodeGenerator.$(H): CustomValueHolderGetterMethodsCodeGenerator.st $(INCLUDE_TOP)\jn\refactoring_custom\CustomAccessMethodsCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libtool\CodeGeneratorTool.$(H) $(STCHDR)
+$(OUTDIR)CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator.$(O) CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator.$(H): CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator.st $(INCLUDE_TOP)\jn\refactoring_custom\CustomAccessMethodsCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libtool\CodeGeneratorTool.$(H) $(STCHDR)
 $(OUTDIR)CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator.$(O) CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator.$(H): CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator.st $(INCLUDE_TOP)\jn\refactoring_custom\CustomAccessMethodsCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libtool\CodeGeneratorTool.$(H) $(STCHDR)
 $(OUTDIR)CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator.$(O) CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator.$(H): CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator.st $(INCLUDE_TOP)\jn\refactoring_custom\CustomAccessMethodsCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libtool\CodeGeneratorTool.$(H) $(STCHDR)
 $(OUTDIR)CustomVisitorCodeGeneratorAcceptVisitor.$(O) CustomVisitorCodeGeneratorAcceptVisitor.$(H): CustomVisitorCodeGeneratorAcceptVisitor.st $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomVisitorCodeGenerator.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libtool\CodeGeneratorTool.$(H) $(STCHDR)
--- a/jn_refactoring_custom.st	Sun Jul 13 17:11:05 2014 +0200
+++ b/jn_refactoring_custom.st	Sun Jul 13 17:25:15 2014 +0200
@@ -112,6 +112,7 @@
         CustomUserDialog
         (CustomValueHolderAccessMethodsCodeGeneratorTests autoload)
         (CustomValueHolderGetterMethodsCodeGeneratorTests autoload)
+        (CustomValueHolderWithChangeNotificationAccessMethodsCodeGeneratorTests autoload)
         (CustomValueHolderWithChangeNotificationGetterMethodsCodeGeneratorTests autoload)
         (CustomValueHolderWithChangeNotificationSetterMethodsCodeGeneratorTests autoload)
         CustomAccessGeneratorClassCodeGenerator
@@ -135,6 +136,7 @@
         CustomSimpleTestCaseCodeGenerator
         CustomValueHolderAccessMethodsCodeGenerator
         CustomValueHolderGetterMethodsCodeGenerator
+        CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator
         CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator
         CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator
         CustomVisitorCodeGeneratorAcceptVisitor
--- a/libInit.cc	Sun Jul 13 17:11:05 2014 +0200
+++ b/libInit.cc	Sun Jul 13 17:25:15 2014 +0200
@@ -68,6 +68,7 @@
 _CustomSimpleTestCaseCodeGenerator_Init(pass,__pRT__,snd);
 _CustomValueHolderAccessMethodsCodeGenerator_Init(pass,__pRT__,snd);
 _CustomValueHolderGetterMethodsCodeGenerator_Init(pass,__pRT__,snd);
+_CustomValueHolderWithChangeNotificationAccessMethodsCodeGenerator_Init(pass,__pRT__,snd);
 _CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator_Init(pass,__pRT__,snd);
 _CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator_Init(pass,__pRT__,snd);
 _CustomVisitorCodeGeneratorAcceptVisitor_Init(pass,__pRT__,snd);
--- a/refactoring_custom.rc	Sun Jul 13 17:11:05 2014 +0200
+++ b/refactoring_custom.rc	Sun Jul 13 17:25:15 2014 +0200
@@ -25,7 +25,7 @@
       VALUE "LegalCopyright", "My CopyRight or CopyLeft\0"
       VALUE "ProductName", "ProductName\0"
       VALUE "ProductVersion", "6.2.4.1259\0"
-      VALUE "ProductDate", "Sun, 13 Jul 2014 15:05:03 GMT\0"
+      VALUE "ProductDate", "Sun, 13 Jul 2014 15:24:07 GMT\0"
     END
 
   END