1877 |
1877 |
1878 ^ self class canUseRefactoringSupport |
1878 ^ self class canUseRefactoringSupport |
1879 ! |
1879 ! |
1880 |
1880 |
1881 privCreateClassResponsibleProtocolFor:aClass |
1881 privCreateClassResponsibleProtocolFor:aClass |
1882 "create stubs for the required protocol aClass may be a a MetaClass |
1882 "create stubs for the required protocol. |
1883 or a NonMetaClass" |
1883 aClass may be a a MetaClass or a non-MetaClass" |
1884 |
1884 |
1885 |selectors| |
1885 |selectors| |
1886 |
1886 |
1887 selectors := IdentitySet new. |
1887 selectors := IdentitySet new. |
1888 aClass allSuperclassesDo:[:cls | |
1888 aClass allSuperclassesDo:[:eachSuperClass | |
1889 cls methodDictionary keysAndValuesDo:[:sel :mthd | |
1889 eachSuperClass methodDictionary keysAndValuesDo:[:eachSelector :eachMethod | |
1890 (mthd sends:#subclassResponsibility) ifTrue:[ |
1890 (eachMethod sends:#subclassResponsibility) ifTrue:[ |
1891 selectors add:sel. |
1891 selectors add:eachSelector. |
1892 ] |
1892 ] |
1893 ] |
1893 ] |
1894 ]. |
1894 ]. |
1895 |
1895 |
1896 selectors do:[:eachSelector | |
1896 selectors do:[:eachSelector | |
1897 |cat comment mthd implClass| |
1897 |mthd comment implClass methodBodyStream| |
1898 |
1898 |
1899 implClass := aClass whichClassImplements:eachSelector. |
1899 implClass := aClass whichClassIncludesSelector:eachSelector. |
1900 implClass ~~ aClass ifTrue:[ |
1900 implClass ~~ aClass ifTrue:[ |
1901 mthd := implClass compiledMethodAt:eachSelector. |
1901 mthd := implClass compiledMethodAt:eachSelector. |
1902 (mthd sends:#subclassResponsibility) ifTrue:[ |
1902 (mthd sends:#subclassResponsibility) ifTrue:[ |
1903 cat := mthd category. |
1903 methodBodyStream := '' writeStream. |
|
1904 methodBodyStream |
|
1905 nextPutAll:mthd methodDefinitionTemplate; cr; |
|
1906 nextPutAll:' "'. |
|
1907 |
1904 comment := mthd methodComment. |
1908 comment := mthd methodComment. |
1905 comment size == 0 ifTrue:[ |
1909 comment isEmptyOrNil ifTrue:[ |
1906 comment := 'Superclass says that I am responsible to implement this method' |
1910 methodBodyStream |
|
1911 nextPutAll:('Superclass <1s> says that I am responsible to implement this method' |
|
1912 expandMacrosWith:implClass name) |
|
1913 ] ifFalse:[ |
|
1914 comment asStringCollection do:[:eachLine| |
|
1915 methodBodyStream nextPutAll:eachLine. |
|
1916 ] separatedBy:[ |
|
1917 methodBodyStream cr; nextPutAll:' '. |
|
1918 ]. |
1907 ]. |
1919 ]. |
1908 |
1920 |
|
1921 methodBodyStream |
|
1922 nextPut:$"; cr; cr; |
|
1923 nextPutAll:' self shouldImplement'; cr. |
|
1924 |
1909 self |
1925 self |
1910 compile: |
1926 compile:methodBodyStream contents |
1911 (Method methodDefinitionTemplateForSelector:eachSelector), Character cr, ' "', comment, |
|
1912 '" |
|
1913 |
|
1914 self shouldImplement |
|
1915 ' |
|
1916 forClass:aClass |
1927 forClass:aClass |
1917 inCategory:cat. |
1928 inCategory:mthd category. |
1918 ]. |
1929 ]. |
1919 ]. |
1930 ]. |
1920 ]. |
1931 ]. |
1921 ! ! |
1932 ! ! |
1922 |
1933 |
1923 !CodeGeneratorTool class methodsFor:'documentation'! |
1934 !CodeGeneratorTool class methodsFor:'documentation'! |
1924 |
1935 |
1925 version |
1936 version |
1926 ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.37 2006-03-20 08:42:11 cg Exp $' |
1937 ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.38 2006-06-07 15:47:22 stefan Exp $' |
1927 ! ! |
1938 ! ! |