CodeGeneratorTool.st
changeset 6938 6cf52649971c
parent 6937 490dab626876
child 6972 81a87b7dc932
equal deleted inserted replaced
6937:490dab626876 6938:6cf52649971c
  1843                 inCategory:'documentation'.
  1843                 inCategory:'documentation'.
  1844         ]
  1844         ]
  1845     ].
  1845     ].
  1846 ! !
  1846 ! !
  1847 
  1847 
       
  1848 !CodeGeneratorTool methodsFor:'compilation'!
       
  1849 
       
  1850 compile:theCode forClass:aClass inCategory:cat 
       
  1851     "install some code for a class.
       
  1852      If refactory browser stuff is avaliable the refactory tools are used to support undo"
       
  1853 
       
  1854     |change compiler oldMthd|
       
  1855 
       
  1856     "/ skip if same
       
  1857     compiler := aClass compilerClass new.
       
  1858     compiler parseMethod:theCode in:aClass ignoreErrors:true ignoreWarnings:true.
       
  1859 
       
  1860     compiler selector notNil ifTrue:[
       
  1861         oldMthd := aClass compiledMethodAt:compiler selector.
       
  1862         (oldMthd notNil and:[oldMthd source = theCode]) ifTrue:[
       
  1863             ^ self.
       
  1864         ].
       
  1865     ].
       
  1866 
       
  1867     self canUseRefactoringSupport ifFalse:[
       
  1868         "/ compile immediately
       
  1869         aClass compile:theCode classified:cat.
       
  1870         ^ self.
       
  1871     ].
       
  1872 
       
  1873     change := InteractiveAddMethodChange compile:(theCode asString) in:aClass classified:cat.
       
  1874 
       
  1875     "/ if collecting, add to changes (to be executed as one change at the end,
       
  1876     "/ in order to have only one change in the undo-list (instead of many)
       
  1877     compositeChangeCollector notNil ifTrue:[
       
  1878         compositeChangeCollector addChange:change
       
  1879     ] ifFalse:[
       
  1880         RefactoryChangeManager instance performChange:change.
       
  1881     ]
       
  1882 
       
  1883     "Modified: / 21-08-2006 / 18:39:06 / cg"
       
  1884 ! !
  1848 
  1885 
  1849 !CodeGeneratorTool methodsFor:'private'!
  1886 !CodeGeneratorTool methodsFor:'private'!
  1850 
  1887 
  1851 canUseRefactoringSupport
  1888 canUseRefactoringSupport
  1852     "check if refactory browser stuff is avaliable"
  1889     "check if refactory browser stuff is avaliable"
  1908 ! !
  1945 ! !
  1909 
  1946 
  1910 !CodeGeneratorTool class methodsFor:'documentation'!
  1947 !CodeGeneratorTool class methodsFor:'documentation'!
  1911 
  1948 
  1912 version
  1949 version
  1913     ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.43 2006-08-21 16:38:07 cg Exp $'
  1950     ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.44 2006-08-21 16:38:59 cg Exp $'
  1914 ! !
  1951 ! !