1763 ! |
1763 ! |
1764 |
1764 |
1765 browseReferencesToIt |
1765 browseReferencesToIt |
1766 "open a browser on all references to the selected global, poolvar or namespace class" |
1766 "open a browser on all references to the selected global, poolvar or namespace class" |
1767 |
1767 |
1768 |nameOfVariable browserClass| |
1768 |nameOfVariable browserClass sym| |
1769 |
1769 |
1770 nameOfVariable := self selectedTextOrSyntaxElement. |
1770 nameOfVariable := self selectedTextOrSyntaxElement. |
1771 nameOfVariable notEmptyOrNil ifTrue:[ |
1771 nameOfVariable notEmptyOrNil ifTrue:[ |
1772 browserClass := UserPreferences systemBrowserClass. |
1772 browserClass := UserPreferences systemBrowserClass. |
1773 self windowGroup withWaitCursorDo:[ |
1773 self windowGroup withWaitCursorDo:[ |
1774 |cls privateClass| |
1774 |cls privateClass| |
1775 |
1775 |
1776 "/ is it a class variable? |
1776 (nameOfVariable startsWith:'#') ifTrue:[ |
1777 ((cls := self editedClass) notNil |
1777 sym := (nameOfVariable copyFrom:2) asSymbolIfInterned. |
1778 and:[ (cls theNonMetaclass allClassVarNames includes:nameOfVariable) ]) ifTrue:[ |
1778 browserClass browseForSymbol:sym. |
1779 browserClass |
|
1780 browseRefsTo:nameOfVariable |
|
1781 classVars:true |
|
1782 in:(cls whichClassDefinesClassVar:nameOfVariable) withAllSubclasses |
|
1783 modificationsOnly:false. |
|
1784 ] ifFalse:[ |
1779 ] ifFalse:[ |
1785 "/ is it a private class? |
1780 "/ is it a class variable? |
1786 (cls notNil |
1781 ((cls := self editedClass) notNil |
1787 and:[ (privateClass := cls theNonMetaclass privateClassNamed:nameOfVariable) notNil ]) ifTrue:[ |
1782 and:[ (cls theNonMetaclass allClassVarNames includes:nameOfVariable) ]) ifTrue:[ |
1788 browserClass browseReferendsOf:(privateClass name) |
1783 browserClass |
|
1784 browseRefsTo:nameOfVariable |
|
1785 classVars:true |
|
1786 in:(cls whichClassDefinesClassVar:nameOfVariable) withAllSubclasses |
|
1787 modificationsOnly:false. |
1789 ] ifFalse:[ |
1788 ] ifFalse:[ |
1790 |pool nsClass| |
1789 "/ is it a private class? |
1791 |
1790 (cls notNil |
1792 "/ is it a pool variable? |
1791 and:[ (privateClass := cls theNonMetaclass privateClassNamed:nameOfVariable) notNil ]) ifTrue:[ |
1793 cls notNil ifTrue:[ |
1792 browserClass browseReferendsOf:(privateClass name) |
1794 pool := cls theNonMetaclass sharedPools |
|
1795 detect:[:pool | pool classVarNames includes:nameOfVariable] |
|
1796 ifNone:nil. |
|
1797 ]. |
|
1798 pool notNil ifTrue:[ |
|
1799 browserClass browseReferendsOf:(pool name,':',nameOfVariable) |
|
1800 ] ifFalse:[ |
1793 ] ifFalse:[ |
1801 (cls notNil |
1794 |pool nsClass| |
1802 and:[ cls nameSpace notNil |
1795 |
1803 and:[ nameOfVariable knownAsSymbol |
1796 "/ is it a pool variable? |
1804 and:[ (nsClass := cls nameSpace at:nameOfVariable asSymbol) notNil |
1797 cls notNil ifTrue:[ |
1805 ]]]) ifTrue:[ |
1798 pool := cls theNonMetaclass sharedPools |
1806 "/ a namespace class? |
1799 detect:[:pool | pool classVarNames includes:nameOfVariable] |
1807 browserClass browseReferendsOf:nsClass name |
1800 ifNone:nil. |
|
1801 ]. |
|
1802 pool notNil ifTrue:[ |
|
1803 browserClass browseReferendsOf:(pool name,':',nameOfVariable) |
1808 ] ifFalse:[ |
1804 ] ifFalse:[ |
1809 "/ an instvar? |
1805 (cls notNil |
1810 (cls allInstVarNames includes:nameOfVariable) ifTrue:[ |
1806 and:[ cls nameSpace notNil |
1811 browserClass |
1807 and:[ nameOfVariable knownAsSymbol |
1812 browseInstRefsTo:nameOfVariable |
1808 and:[ (nsClass := cls nameSpace at:nameOfVariable asSymbol) notNil |
1813 under:(cls whichClassDefinesInstVar:nameOfVariable) |
1809 ]]]) ifTrue:[ |
1814 modificationsOnly:false |
1810 "/ a namespace class? |
|
1811 browserClass browseReferendsOf:nsClass name |
1815 ] ifFalse:[ |
1812 ] ifFalse:[ |
1816 "/ no, assume global |
1813 "/ an instvar? |
1817 browserClass browseReferendsOf:nameOfVariable |
1814 (cls allInstVarNames includes:nameOfVariable) ifTrue:[ |
|
1815 browserClass |
|
1816 browseInstRefsTo:nameOfVariable |
|
1817 under:(cls whichClassDefinesInstVar:nameOfVariable) |
|
1818 modificationsOnly:false |
|
1819 ] ifFalse:[ |
|
1820 "/ no, assume global |
|
1821 browserClass browseReferendsOf:nameOfVariable |
|
1822 ] |
1818 ] |
1823 ] |
1819 ] |
1824 ] |
1820 ] |
1825 ] |
1821 ] |
1826 ] |
1822 ] |
1827 ] |
1964 ]. |
1969 ]. |
1965 "/ a global or namespace-var selected ? |
1970 "/ a global or namespace-var selected ? |
1966 sel isNil ifTrue:[ |
1971 sel isNil ifTrue:[ |
1967 sub disable:#browseReferencesToIt. |
1972 sub disable:#browseReferencesToIt. |
1968 ] ifFalse:[ |
1973 ] ifFalse:[ |
1969 selectedSymbol := sel asSymbolIfInterned. |
1974 (sel startsWith:'#') ifTrue:[ |
1970 (selectedSymbol notNil |
1975 "/ a symbol selected - can search references |
1971 and:[(Smalltalk includesKey:selectedSymbol) |
|
1972 or:[(NameSpace allNameSpaces contains:[:ns | ns includesKey:selectedSymbol]) ]] |
|
1973 ) ifTrue:[ |
|
1974 "/ a global or namespace var selected |
|
1975 ] ifFalse:[ |
1976 ] ifFalse:[ |
1976 |cls| |
1977 selectedSymbol := sel asSymbolIfInterned. |
1977 |
1978 (selectedSymbol notNil |
1978 cls := self editedClass. |
1979 and:[(Smalltalk includesKey:selectedSymbol) |
1979 cls notNil ifTrue:[ |
1980 or:[(NameSpace allNameSpaces contains:[:ns | ns includesKey:selectedSymbol]) ]] |
1980 cls := cls theNonMetaclass. |
1981 ) ifTrue:[ |
1981 ((cls allClassVarNames includes:sel) |
1982 "/ a global or namespace var selected |
1982 or:[ (cls theNonMetaclass privateClassNamed:sel) notNil]) ifTrue:[ |
1983 ] ifFalse:[ |
1983 "/ a classvar or private class |
1984 |cls| |
1984 ] ifFalse:[ |
1985 |
1985 |pool| |
1986 cls := self editedClass. |
1986 "/ is it a pool variable? |
1987 cls notNil ifTrue:[ |
1987 pool := cls sharedPools |
1988 cls := cls theNonMetaclass. |
1988 detect:[:pool | pool classVarNames includes:sel] |
1989 ((cls allClassVarNames includes:sel) |
1989 ifNone:nil. |
1990 or:[ (cls theNonMetaclass privateClassNamed:sel) notNil]) ifTrue:[ |
1990 pool isNil ifTrue:[ |
1991 "/ a classvar or private class |
1991 "/ todo: an instvar selected? |
1992 ] ifFalse:[ |
1992 (cls allInstVarNames includes:sel) ifFalse:[ |
1993 |pool| |
1993 sub disable:#browseReferencesToIt. |
1994 "/ is it a pool variable? |
|
1995 pool := cls sharedPools |
|
1996 detect:[:pool | pool classVarNames includes:sel] |
|
1997 ifNone:nil. |
|
1998 pool isNil ifTrue:[ |
|
1999 "/ todo: an instvar selected? |
|
2000 (cls allInstVarNames includes:sel) ifFalse:[ |
|
2001 sub disable:#browseReferencesToIt. |
|
2002 ]. |
1994 ]. |
2003 ]. |
1995 ]. |
2004 ]. |
|
2005 ] ifFalse:[ |
|
2006 sub disable:#browseReferencesToIt. |
1996 ]. |
2007 ]. |
1997 ] ifFalse:[ |
|
1998 sub disable:#browseReferencesToIt. |
|
1999 ]. |
2008 ]. |
2000 ]. |
2009 ]. |
2001 ]. |
2010 ]. |
2002 (selectedSymbol notNil |
2011 (selectedSymbol notNil |
2003 and:[SharedPool allSubclasses contains:[:pool | pool includesKey:selectedSymbol]]) ifFalse:[ |
2012 and:[SharedPool allSubclasses contains:[:pool | pool includesKey:selectedSymbol]]) ifFalse:[ |