CodeGeneratorTool.st
changeset 10466 4b42e5a1f395
parent 10319 c374ffaf0ec3
child 10553 7ff71943e4b4
equal deleted inserted replaced
10465:7bb5a6157330 10466:4b42e5a1f395
    11 "
    11 "
    12 "{ Package: 'stx:libtool' }"
    12 "{ Package: 'stx:libtool' }"
    13 
    13 
    14 Object subclass:#CodeGeneratorTool
    14 Object subclass:#CodeGeneratorTool
    15 	instanceVariableNames:'compositeChangeCollector compositeChangeNesting userPreferences
    15 	instanceVariableNames:'compositeChangeCollector compositeChangeNesting userPreferences
    16 		generateComments'
    16 		generateComments confirmChanges'
    17 	classVariableNames:'GenerateCommentsForGetters GenerateCommentsForSetters
    17 	classVariableNames:'GenerateCommentsForGetters GenerateCommentsForSetters
    18 		CopyrightTemplate'
    18 		CopyrightTemplate'
    19 	poolDictionaries:''
    19 	poolDictionaries:''
    20 	category:'Interface-Browsers'
    20 	category:'Interface-Browsers'
    21 !
    21 !
   826         ]
   826         ]
   827     ].
   827     ].
   828     ^ requiredSelectors
   828     ^ requiredSelectors
   829 ! !
   829 ! !
   830 
   830 
   831 !CodeGeneratorTool methodsFor:'buld changes'!
   831 !CodeGeneratorTool methodsFor:'bulk changes'!
   832 
   832 
   833 addChange:aChange
   833 addChange:aChange
   834     compositeChangeCollector addChange:aChange
   834     compositeChangeCollector addChange:aChange
   835 !
   835 !
   836 
   836 
   837 executeCollectedChangesNamed:name
   837 executeCollectedChangesNamed:name
       
   838     "if both the compositeChangeCollector and I myself think, that it should be confirmed,
       
   839      the let user do it - I am not sure, if the heuristics here is useful;
       
   840      it might be better to let the generator decide (for example, if it does high-impact
       
   841      changes, as opposed to simple ones)"
   838 
   842 
   839     | changes |
   843     | changes |
   840 
   844 
   841     compositeChangeCollector notNil ifTrue:[
   845     compositeChangeCollector notNil ifTrue:[
   842         compositeChangeNesting := compositeChangeNesting - 1.
   846         compositeChangeNesting := compositeChangeNesting - 1.
   843         compositeChangeNesting == 0 ifTrue:[
   847         compositeChangeNesting == 0 ifTrue:[
   844             compositeChangeCollector name:name.
   848             compositeChangeCollector name:name.
   845             compositeChangeCollector changesSize == 0 ifTrue:[
   849             compositeChangeCollector changesSize == 0 ifTrue:[
   846                 self information:'Nothing generated.'.
   850                 self information:'Nothing generated.'.
   847             ] ifFalse:[
   851             ] ifFalse:[
   848                 compositeChangeCollector shouldBeConfimed                 
   852                 (compositeChangeCollector shouldBeConfimed and:[self confirmChanges])
   849                     ifFalse: [
   853                     ifFalse: [
   850                         RefactoryChangeManager instance performChange: compositeChangeCollector
   854                         RefactoryChangeManager instance performChange: compositeChangeCollector
   851                     ] ifTrue: [                        
   855                     ] ifTrue: [                        
   852                         changes := Tools::ChangeSetBrowser2 confirmChanges:
   856                         changes := Tools::ChangeSetBrowser2 confirmChanges:(ChangeSet with:compositeChangeCollector).
   853                                 (ChangeSet with:compositeChangeCollector).
   857                         changes do:[:chg | RefactoryChangeManager instance performChange: chg].
   854                         changes do:[:chg|RefactoryChangeManager instance performChange: chg].
       
   855                     ].
   858                     ].
   856             ].
   859             ].
   857             compositeChangeCollector := nil.
   860             compositeChangeCollector := nil.
   858         ]
   861         ]
   859     ]
   862     ]
   860 
   863 
   861     "Modified: / 08-07-2011 / 11:03:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   864     "Modified: / 08-07-2011 / 11:03:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   865     "Modified (comment): / 04-08-2011 / 17:30:27 / cg"
   862 !
   866 !
   863 
   867 
   864 startCollectChanges
   868 startCollectChanges
   865     (self canUseRefactoringSupport) ifTrue:[
   869     (self canUseRefactoringSupport) ifTrue:[
   866         compositeChangeCollector isNil ifTrue:[
   870         compositeChangeCollector isNil ifTrue:[
  1520     "Modified: / 21-08-2006 / 18:39:06 / cg"
  1524     "Modified: / 21-08-2006 / 18:39:06 / cg"
  1521 ! !
  1525 ! !
  1522 
  1526 
  1523 !CodeGeneratorTool methodsFor:'initialization'!
  1527 !CodeGeneratorTool methodsFor:'initialization'!
  1524 
  1528 
       
  1529 confirmChanges
       
  1530     "if true, let user confirm complicated changes; if false, just do it"
       
  1531 
       
  1532     ^ confirmChanges ? true
       
  1533 
       
  1534     "Created: / 04-08-2011 / 17:31:45 / cg"
       
  1535 !
       
  1536 
       
  1537 confirmChanges:aBoolean
       
  1538     "if true, let user confirm complicated changes; if false, just do it"
       
  1539 
       
  1540     confirmChanges := aBoolean
       
  1541 
       
  1542     "Created: / 04-08-2011 / 17:26:47 / cg"
       
  1543 !
       
  1544 
  1525 initialize
  1545 initialize
  1526     userPreferences := UserPreferences current.
  1546     userPreferences := UserPreferences current.
  1527     generateComments := userPreferences generateComments.
  1547     generateComments := userPreferences generateComments.
  1528 ! !
  1548 ! !
  1529 
  1549 
  1558 ! !
  1578 ! !
  1559 
  1579 
  1560 !CodeGeneratorTool class methodsFor:'documentation'!
  1580 !CodeGeneratorTool class methodsFor:'documentation'!
  1561 
  1581 
  1562 version_CVS
  1582 version_CVS
  1563     ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.91 2011-07-14 14:44:50 cg Exp $'
  1583     ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.92 2011-08-04 19:39:05 cg Exp $'
  1564 ! !
  1584 ! !