1911 ! |
1911 ! |
1912 |
1912 |
1913 basicFileOutDefinitionOn:aStream withNameSpace:forceNameSpace withPackage:showPackage |
1913 basicFileOutDefinitionOn:aStream withNameSpace:forceNameSpace withPackage:showPackage |
1914 "append an expression on aStream, which defines myself." |
1914 "append an expression on aStream, which defines myself." |
1915 |
1915 |
1916 |s owner ns nsName fullName superName cls topOwner |
1916 |s owner ns nsName fullName superNameWithoutNameSpacePrefix cls topOwner |
1917 syntaxHilighting| |
1917 syntaxHilighting superclassNamespace| |
1918 |
1918 |
1919 UserPreferences isNil ifTrue:[ |
1919 UserPreferences isNil ifTrue:[ |
1920 syntaxHilighting := false |
1920 syntaxHilighting := false |
1921 ] ifFalse:[ |
1921 ] ifFalse:[ |
1922 syntaxHilighting := UserPreferences current syntaxColoring. |
1922 syntaxHilighting := UserPreferences current syntaxColoring. |
1923 ]. |
1923 ]. |
1924 |
1924 |
|
1925 fullName := FileOutNameSpaceQuerySignal query == true. |
|
1926 |
1925 owner := self owningClass. |
1927 owner := self owningClass. |
1926 |
|
1927 owner isNil ifTrue:[ |
1928 owner isNil ifTrue:[ |
1928 ns := self nameSpace. |
1929 ns := self nameSpace. |
1929 ] ifFalse:[ |
1930 ] ifFalse:[ |
1930 ns := self topOwningClass nameSpace |
1931 ns := self topOwningClass nameSpace. |
1931 ]. |
1932 ]. |
1932 fullName := FileOutNameSpaceQuerySignal query == true. |
|
1933 |
1933 |
1934 (showPackage and:[owner isNil]) ifTrue:[ |
1934 (showPackage and:[owner isNil]) ifTrue:[ |
1935 aStream nextPutAll:'"{ Package: '''. |
1935 aStream nextPutAll:'"{ Package: '''. |
1936 aStream nextPutAll:self package asString. |
1936 aStream nextPutAll:self package asString. |
1937 aStream nextPutAll:''' }"'; cr; cr. |
1937 aStream nextPutAll:''' }"'; cr; cr. |
1938 ]. |
1938 ]. |
1939 |
1939 |
1940 ((owner isNil and:[fullName not]) |
1940 "/ the backward compatible namespace directive is only used |
1941 or:[owner notNil and:[forceNameSpace and:[fullName not]]]) ifTrue:[ |
1941 "/ for non-private classes. |
1942 (ns notNil and:[ns ~~ Smalltalk]) ifTrue:[ |
1942 "/ Private classes cannot be filed into another smalltalk anyway, |
1943 nsName := ns name. |
1943 "/ and there is no need to complicate global lookup in stc... |
1944 (nsName includes:$:) ifTrue:[ |
1944 |
1945 nsName := '''' , nsName , '''' |
1945 owner notNil ifTrue:[ |
1946 ]. |
1946 fullName := true. |
1947 "/ aStream nextPutLine:'"{ NameSpace: ' , nsName , ' }"'; cr. |
1947 ]. |
1948 aStream nextPutAll:'"{ NameSpace: '. |
1948 |
1949 syntaxHilighting ifTrue:[aStream bold]. |
1949 fullName ifFalse:[ |
1950 aStream nextPutAll:nsName. |
1950 (owner isNil or:[forceNameSpace]) ifTrue:[ |
1951 syntaxHilighting ifTrue:[aStream normal]. |
1951 (ns notNil and:[ns ~~ Smalltalk]) ifTrue:[ |
1952 aStream nextPutAll:' }"'; cr; cr. |
1952 nsName := ns name. |
1953 ] |
1953 (nsName includes:$:) ifTrue:[ |
|
1954 nsName := '''' , nsName , '''' |
|
1955 ]. |
|
1956 aStream nextPutAll:'"{ NameSpace: '. |
|
1957 syntaxHilighting ifTrue:[aStream bold]. |
|
1958 aStream nextPutAll:nsName. |
|
1959 syntaxHilighting ifTrue:[aStream normal]. |
|
1960 aStream nextPutAll:' }"'; cr; cr. |
|
1961 ] |
|
1962 ]. |
1954 ]. |
1963 ]. |
1955 |
1964 |
1956 "take care of nil-superclass" |
1965 "take care of nil-superclass" |
1957 superclass isNil ifTrue:[ |
1966 superclass isNil ifTrue:[ |
1958 s := 'nil' |
1967 s := 'nil' |
1959 ] ifFalse:[ |
1968 ] ifFalse:[ |
|
1969 superclassNamespace := superclass nameSpace. |
|
1970 |
1960 fullName ifTrue:[ |
1971 fullName ifTrue:[ |
1961 superclass == owner ifTrue:[ |
1972 s := superclass name. |
1962 s := superclass nameWithoutNameSpacePrefix |
1973 "/ superclass == owner ifTrue:[ |
1963 ] ifFalse:[ |
1974 "/ s := superclass nameWithoutNameSpacePrefix |
1964 s := superclass name |
1975 "/ ] |
1965 ] |
|
1966 ] ifFalse:[ |
1976 ] ifFalse:[ |
1967 (ns == superclass nameSpace |
1977 (ns == superclassNamespace |
1968 and:[superclass owningClass isNil]) ifTrue:[ |
1978 and:[superclass owningClass isNil]) ifTrue:[ |
1969 "/ superclass is in the same namespace; |
1979 "/ superclass is in the same namespace; |
1970 "/ still prepend namespace prefix, to avoid |
1980 "/ still prepend namespace prefix, to avoid |
1971 "/ confusing stc, which needs that information ... |
1981 "/ confusing stc, which needs that information ... |
1972 s := superclass nameWithoutPrefix |
1982 s := superclass nameWithoutPrefix |
1974 "/ a very special (rare) situation: |
1984 "/ a very special (rare) situation: |
1975 "/ my superclass resides in another nameSpace, |
1985 "/ my superclass resides in another nameSpace, |
1976 "/ but there is something else named like this |
1986 "/ but there is something else named like this |
1977 "/ to be found in my nameSpace (or a private class) |
1987 "/ to be found in my nameSpace (or a private class) |
1978 |
1988 |
1979 superName := superclass nameWithoutNameSpacePrefix asSymbol. |
1989 superNameWithoutNameSpacePrefix := superclass nameWithoutNameSpacePrefix asSymbol. |
1980 cls := self privateClassesAt:superName. |
1990 cls := self privateClassesAt:superNameWithoutNameSpacePrefix. |
1981 cls isNil ifTrue:[ |
1991 cls isNil ifTrue:[ |
1982 (topOwner := self topOwningClass) isNil ifTrue:[ |
1992 (topOwner := self topOwningClass) isNil ifTrue:[ |
1983 ns := self nameSpace. |
1993 ns := self nameSpace. |
1984 ns notNil ifTrue:[ |
1994 ns notNil ifTrue:[ |
1985 cls := ns privateClassesAt:superName |
1995 cls := ns privateClassesAt:superNameWithoutNameSpacePrefix |
1986 ] ifFalse:[ |
1996 ] ifFalse:[ |
1987 "/ self error:'unexpected nil namespace' |
1997 "/ self error:'unexpected nil namespace' |
1988 ] |
1998 ] |
1989 ] ifFalse:[ |
1999 ] ifFalse:[ |
1990 cls := topOwner nameSpace at:superName. |
2000 cls := topOwner nameSpace at:superNameWithoutNameSpacePrefix. |
1991 ] |
2001 ] |
1992 ]. |
2002 ]. |
1993 (cls notNil and:[cls ~~ superclass]) ifTrue:[ |
2003 (cls notNil and:[cls ~~ superclass]) ifTrue:[ |
1994 s := superclass nameSpace name , '::' , superName |
2004 s := superclassNamespace name , '::' , superNameWithoutNameSpacePrefix |
1995 ] ifFalse:[ |
2005 ] ifFalse:[ |
1996 "/ no class with that name found in my namespace ... |
2006 "/ no class with that name found in my namespace ... |
1997 "/ if the superclass resides in Smalltalk, |
2007 "/ if the superclass resides in Smalltalk, |
1998 "/ suppress prefix; otherwise, use full prefix. |
2008 "/ suppress prefix; otherwise, use full prefix. |
1999 (superclass nameSpace notNil |
2009 (superclassNamespace notNil |
2000 and:[superclass nameSpace ~~ Smalltalk]) ifTrue:[ |
2010 and:[superclassNamespace ~~ Smalltalk]) ifTrue:[ |
2001 (owner notNil |
2011 (owner notNil |
2002 and:[owner nameSpace == superclass owningClass nameSpace]) |
2012 and:[owner nameSpace == superclass owningClass nameSpace]) |
2003 ifTrue:[ |
2013 ifTrue:[ |
2004 s := superclass nameWithoutNameSpacePrefix |
2014 s := superNameWithoutNameSpacePrefix |
2005 ] ifFalse:[ |
2015 ] ifFalse:[ |
2006 s := superclass name |
2016 s := superclass name |
2007 ] |
2017 ] |
2008 ] ifFalse:[ |
2018 ] ifFalse:[ |
2009 s := superName |
2019 s := superNameWithoutNameSpacePrefix |
2010 ] |
2020 ] |
2011 ] |
2021 ] |
2012 ] |
2022 ] |
2013 ] |
2023 ] |
2014 ]. |
2024 ]. |
2282 "/ the same as the written one AND the new files directory |
2286 "/ the same as the written one AND the new files directory |
2283 "/ is along the sourcePath, we also need a temporary file |
2287 "/ is along the sourcePath, we also need a temporary file |
2284 "/ first, to avoid accessing the newly written file. |
2288 "/ first, to avoid accessing the newly written file. |
2285 |
2289 |
2286 anySourceRef := false. |
2290 anySourceRef := false. |
2287 self methodDictionary do:[:m| |
2291 self instAndClassMethodsDo:[:m | |
2288 |mSrc| |
|
2289 |
|
2290 (mSrc := m sourceFilename) notNil ifTrue:[ |
|
2291 mSrc asFilename baseName = fileName baseName ifTrue:[ |
|
2292 anySourceRef := true |
|
2293 ] |
|
2294 ] |
|
2295 ]. |
|
2296 self class methodDictionary do:[:m| |
|
2297 |mSrc| |
2292 |mSrc| |
2298 |
2293 |
2299 (mSrc := m sourceFilename) notNil ifTrue:[ |
2294 (mSrc := m sourceFilename) notNil ifTrue:[ |
2300 mSrc asFilename baseName = fileName baseName ifTrue:[ |
2295 mSrc asFilename baseName = fileName baseName ifTrue:[ |
2301 anySourceRef := true |
2296 anySourceRef := true |