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 |nameOfGlobal browserClass| |
1768 |nameOfVariable browserClass| |
1769 |
1769 |
1770 nameOfGlobal := self selectedTextOrSyntaxElement. |
1770 nameOfVariable := self selectedTextOrSyntaxElement. |
1771 nameOfGlobal 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 "/ is it a class variable? |
1777 ((cls := self editedClass) notNil |
1777 ((cls := self editedClass) notNil |
1778 and:[ (cls theNonMetaclass allClassVarNames includes:nameOfGlobal) ]) ifTrue:[ |
1778 and:[ (cls theNonMetaclass allClassVarNames includes:nameOfVariable) ]) ifTrue:[ |
1779 browserClass |
1779 browserClass |
1780 browseRefsTo:nameOfGlobal |
1780 browseRefsTo:nameOfVariable |
1781 classVars:true |
1781 classVars:true |
1782 in:(cls whichClassDefinesClassVar:nameOfGlobal) withAllSubclasses |
1782 in:(cls whichClassDefinesClassVar:nameOfVariable) withAllSubclasses |
1783 modificationsOnly:false. |
1783 modificationsOnly:false. |
1784 ] ifFalse:[ |
1784 ] ifFalse:[ |
1785 "/ is it a private class? |
1785 "/ is it a private class? |
1786 (cls notNil |
1786 (cls notNil |
1787 and:[ (privateClass := cls theNonMetaclass privateClassNamed:nameOfGlobal) notNil ]) ifTrue:[ |
1787 and:[ (privateClass := cls theNonMetaclass privateClassNamed:nameOfVariable) notNil ]) ifTrue:[ |
1788 browserClass browseReferendsOf:(privateClass name) |
1788 browserClass browseReferendsOf:(privateClass name) |
1789 ] ifFalse:[ |
1789 ] ifFalse:[ |
1790 |pool nsClass| |
1790 |pool nsClass| |
1791 |
1791 |
1792 "/ is it a pool variable? |
1792 "/ is it a pool variable? |
1793 cls notNil ifTrue:[ |
1793 cls notNil ifTrue:[ |
1794 pool := cls theNonMetaclass sharedPools |
1794 pool := cls theNonMetaclass sharedPools |
1795 detect:[:pool | pool classVarNames includes:nameOfGlobal] |
1795 detect:[:pool | pool classVarNames includes:nameOfVariable] |
1796 ifNone:nil. |
1796 ifNone:nil. |
1797 ]. |
1797 ]. |
1798 pool notNil ifTrue:[ |
1798 pool notNil ifTrue:[ |
1799 browserClass browseReferendsOf:(pool name,':',nameOfGlobal) |
1799 browserClass browseReferendsOf:(pool name,':',nameOfVariable) |
1800 ] ifFalse:[ |
1800 ] ifFalse:[ |
1801 (cls notNil |
1801 (cls notNil |
1802 and:[ cls nameSpace notNil |
1802 and:[ cls nameSpace notNil |
1803 and:[ nameOfGlobal knownAsSymbol |
1803 and:[ nameOfVariable knownAsSymbol |
1804 and:[ (nsClass := cls nameSpace at:nameOfGlobal asSymbol) notNil |
1804 and:[ (nsClass := cls nameSpace at:nameOfVariable asSymbol) notNil |
1805 ]]]) notNil ifTrue:[ |
1805 ]]]) ifTrue:[ |
1806 "/ a namespace class |
1806 "/ a namespace class? |
1807 browserClass browseReferendsOf:nsClass name |
1807 browserClass browseReferendsOf:nsClass name |
1808 ] ifFalse:[ |
1808 ] ifFalse:[ |
1809 "/ no, assume global |
1809 "/ an instvar? |
1810 browserClass browseReferendsOf:nameOfGlobal |
1810 (cls allInstVarNames includes:nameOfVariable) ifTrue:[ |
1811 ] |
1811 browserClass |
1812 ] |
1812 browseInstRefsTo:nameOfVariable |
1813 ] |
1813 under:(cls whichClassDefinesInstVar:nameOfVariable) |
1814 ] |
1814 modificationsOnly:false |
1815 ]. |
1815 ] ifFalse:[ |
|
1816 "/ no, assume global |
|
1817 browserClass browseReferendsOf:nameOfVariable |
|
1818 ] |
|
1819 ] |
|
1820 ] |
|
1821 ] |
|
1822 ] |
|
1823 ]. |
1816 ]. |
1824 ]. |
1817 |
1825 |
1818 "Created: / 5.11.2001 / 17:32:23 / cg" |
1826 "Created: / 5.11.2001 / 17:32:23 / cg" |
1819 "Modified: / 5.11.2001 / 17:32:38 / cg" |
1827 "Modified: / 5.11.2001 / 17:32:38 / cg" |
1820 ! |
1828 ! |
1872 editMenu |
1880 editMenu |
1873 "return my popUpMenu; thats the superclasses menu |
1881 "return my popUpMenu; thats the superclasses menu |
1874 PLUS st-evaluation items: doIt, printIt and inspectIt." |
1882 PLUS st-evaluation items: doIt, printIt and inspectIt." |
1875 |
1883 |
1876 <resource: #keyboard (#DoIt #PrintIt #InspectIt |
1884 <resource: #keyboard (#DoIt #PrintIt #InspectIt |
1877 #CommentSelection #UncommentSelection |
1885 #CommentSelection #UncommentSelection |
1878 #BrowseIt #ImplementorsOfIt |
1886 #BrowseIt #ImplementorsOfIt |
1879 )> |
1887 )> |
1880 <resource: #programMenu> |
1888 <resource: #programMenu> |
1881 |
1889 |
1882 |m sub subsub idx sensor sel2 sel selectedSymbol| |
1890 |m sub subsub idx sensor sel2 sel selectedSymbol| |
1883 |
1891 |
1884 m := super editMenu. |
1892 m := super editMenu. |
1885 ((sensor := self sensor) notNil and:[sensor ctrlDown and:[sensor shiftDown not]]) ifTrue:[ |
1893 ((sensor := self sensor) notNil and:[sensor ctrlDown and:[sensor shiftDown not]]) ifTrue:[ |
1886 sub := m. |
1894 sub := m. |
1887 m := nil. |
1895 m := nil. |
1888 ] ifFalse:[ |
1896 ] ifFalse:[ |
1889 sub := m subMenuAt:#others. |
1897 sub := m subMenuAt:#others. |
1890 ]. |
1898 ]. |
1891 |
1899 |
1892 sub notNil ifTrue:[ |
1900 sub notNil ifTrue:[ |
1893 " |
1901 " |
1894 workspaces support #browse, implementors etc. add them after paste. |
1902 workspaces support #browse, implementors etc. add them after paste. |
1895 " |
1903 " |
1896 sub |
1904 sub |
1897 addItemList:#( |
1905 addItemList:#( |
1898 ('-' ) |
1906 ('-' ) |
1899 ('Browse' browseIt BrowseIt ) |
1907 ('Browse' browseIt BrowseIt ) |
1900 ('Browse Pool' browseSharedPoolOfIt ) |
1908 ('Browse Pool' browseSharedPoolOfIt ) |
1901 ('Senders of It' browseSendersOfIt ) |
1909 ('Senders of It' browseSendersOfIt ) |
1902 ('Implementors of It' browseImplementorsOfIt ImplementorsOfIt ) |
1910 ('Implementors of It' browseImplementorsOfIt ImplementorsOfIt ) |
1903 ('References to It' browseReferencesToIt ) |
1911 ('References to It' browseReferencesToIt ) |
1904 "/ ('Classes Containing It in Name' browseClassesContainingItInName ) |
1912 "/ ('Classes Containing It in Name' browseClassesContainingItInName ) |
1905 "/ ('Methods Contaníning It in Name' browseMethodsContainingItInName ) |
1913 "/ ('Methods Contaníning It in Name' browseMethodsContainingItInName ) |
1906 "/ ('Methods Contaníning It in Source' browseMethodsContainingItInSource ) |
1914 "/ ('Methods Contaníning It in Source' browseMethodsContainingItInSource ) |
1907 ('-' ) |
1915 ('-' ) |
1908 ('TimeIt' timeIt ) |
1916 ('TimeIt' timeIt ) |
1909 ('SpyOnIt' spyOnIt )) |
1917 ('SpyOnIt' spyOnIt )) |
1910 resources:resources |
1918 resources:resources |
1911 after:#gotoLine. |
1919 after:#gotoLine. |
1912 |
1920 |
1913 subsub := sub subMenuAt:#tools. |
1921 subsub := sub subMenuAt:#tools. |
1914 subsub notNil ifTrue:[ |
1922 subsub notNil ifTrue:[ |
1915 subsub |
1923 subsub |
1916 addItemList:#( |
1924 addItemList:#( |
1917 ('-' ) |
1925 ('-' ) |
1918 ('CommentIt' commentSelection CommentSelection ) |
1926 ('CommentIt' commentSelection CommentSelection ) |
1919 ('UncommentIt' uncommentSelection UncommentSelection )) |
1927 ('UncommentIt' uncommentSelection UncommentSelection )) |
1920 resources:resources |
1928 resources:resources |
1921 after:#'indent'. |
1929 after:#'indent'. |
1922 ]. |
1930 ]. |
1923 |
1931 |
1924 self hasSelection ifFalse:[ |
1932 self hasSelection ifFalse:[ |
1925 sub disableAll:#(browseImplementorsOfIt browseSendersOfIt |
1933 sub disableAll:#(browseImplementorsOfIt browseSendersOfIt |
1926 browseReferencesToIt timeIt spyOnIt |
1934 browseReferencesToIt timeIt spyOnIt |
1927 browseSharedPoolOfIt browseIt). |
1935 browseSharedPoolOfIt browseIt). |
1928 self supportsSyntaxElements ifTrue:[ |
1936 self supportsSyntaxElements ifTrue:[ |
1929 self syntaxElementForSelectorUnderCursor notNil ifTrue:[ |
1937 self syntaxElementForSelectorUnderCursor notNil ifTrue:[ |
1930 sub enableAll:#(browseImplementorsOfIt browseSendersOfIt ) |
1938 sub enableAll:#(browseImplementorsOfIt browseSendersOfIt ) |
1931 ] ifFalse:[ |
1939 ] ifFalse:[ |
1932 |el| |
1940 |el| |
1933 |
1941 |
1934 (el := self syntaxElementForVariableUnderCursor) notNil ifTrue:[ |
1942 (el := self syntaxElementForVariableUnderCursor) notNil ifTrue:[ |
1935 el isGlobal ifTrue:[ |
1943 (el isGlobal or:[el isInstanceVariable]) ifTrue:[ |
1936 sub enable: #browseReferencesToIt |
1944 sub enable: #browseReferencesToIt |
1937 ]. |
1945 ]. |
1938 el isClass ifTrue:[ |
1946 el isClass ifTrue:[ |
1939 sub enable:#browseIt |
1947 sub enable:#browseIt |
1940 ] |
1948 ] |
1941 ] |
1949 ] |
1942 ] |
1950 ] |
1943 ]. |
1951 ]. |
1944 ] ifTrue:[ |
1952 ] ifTrue:[ |
1945 sel := self selectionAsString. |
1953 sel := self selectionAsString. |
1946 sel notNil ifTrue:[ |
1954 sel notNil ifTrue:[ |
1947 sel asSymbolIfInterned isNil ifTrue:[ |
1955 sel asSymbolIfInterned isNil ifTrue:[ |
1948 sel2 := SystemBrowser extractSelectorFrom:sel. |
1956 sel2 := SystemBrowser extractSelectorFrom:sel. |
1949 sel2 notNil ifTrue:[ |
1957 sel2 notNil ifTrue:[ |
1950 sel2 := sel2 asSymbolIfInterned. |
1958 sel2 := sel2 asSymbolIfInterned. |
1951 ]. |
1959 ]. |
1952 ]. |
1960 ]. |
1953 ]. |
1961 ]. |
1954 (sel2 isNil and:[sel isNil]) ifTrue:[ |
1962 (sel2 isNil and:[sel isNil]) ifTrue:[ |
1955 sub disableAll:#(browseImplementorsOfIt browseSendersOfIt). |
1963 sub disableAll:#(browseImplementorsOfIt browseSendersOfIt). |
1956 ]. |
1964 ]. |
1957 "/ a global or namespace-var selected ? |
1965 "/ a global or namespace-var selected ? |
1958 sel isNil ifTrue:[ |
1966 sel isNil ifTrue:[ |
1959 sub disable:#browseReferencesToIt. |
1967 sub disable:#browseReferencesToIt. |
1960 ] ifFalse:[ |
1968 ] ifFalse:[ |
1961 selectedSymbol := sel asSymbolIfInterned. |
1969 selectedSymbol := sel asSymbolIfInterned. |
1962 (selectedSymbol notNil |
1970 (selectedSymbol notNil |
1963 and:[(Smalltalk includesKey:selectedSymbol) |
1971 and:[(Smalltalk includesKey:selectedSymbol) |
1964 or:[(NameSpace allNameSpaces contains:[:ns | ns includesKey:selectedSymbol]) ]] |
1972 or:[(NameSpace allNameSpaces contains:[:ns | ns includesKey:selectedSymbol]) ]] |
1965 ) ifTrue:[ |
1973 ) ifTrue:[ |
1966 "/ a global or namespace var selected |
1974 "/ a global or namespace var selected |
1967 ] ifFalse:[ |
1975 ] ifFalse:[ |
1968 |cls| |
1976 |cls| |
1969 |
1977 |
1970 cls := self editedClass. |
1978 cls := self editedClass. |
1971 cls notNil ifTrue:[ |
1979 cls notNil ifTrue:[ |
1972 cls := cls theNonMetaclass. |
1980 cls := cls theNonMetaclass. |
1973 ((cls allClassVarNames includes:sel) |
1981 ((cls allClassVarNames includes:sel) |
1974 or:[ (cls theNonMetaclass privateClassNamed:sel) notNil]) ifTrue:[ |
1982 or:[ (cls theNonMetaclass privateClassNamed:sel) notNil]) ifTrue:[ |
1975 "/ a classvar or private class |
1983 "/ a classvar or private class |
1976 ] ifFalse:[ |
1984 ] ifFalse:[ |
1977 |pool| |
1985 |pool| |
1978 "/ is it a pool variable? |
1986 "/ is it a pool variable? |
1979 pool := cls sharedPools |
1987 pool := cls sharedPools |
1980 detect:[:pool | pool classVarNames includes:sel] |
1988 detect:[:pool | pool classVarNames includes:sel] |
1981 ifNone:nil. |
1989 ifNone:nil. |
1982 pool isNil ifTrue:[ |
1990 pool isNil ifTrue:[ |
1983 "/ todo: an instvar selected? |
1991 "/ todo: an instvar selected? |
1984 sub disable:#browseReferencesToIt. |
1992 (cls allInstVarNames includes:sel) ifFalse:[ |
1985 ]. |
1993 sub disable:#browseReferencesToIt. |
1986 ]. |
1994 ]. |
1987 ] ifFalse:[ |
1995 ]. |
1988 sub disable:#browseReferencesToIt. |
1996 ]. |
1989 ]. |
1997 ] ifFalse:[ |
1990 ]. |
1998 sub disable:#browseReferencesToIt. |
1991 ]. |
1999 ]. |
1992 (selectedSymbol notNil |
2000 ]. |
1993 and:[SharedPool allSubclasses contains:[:pool | pool includesKey:selectedSymbol]]) ifFalse:[ |
2001 ]. |
1994 sub disable:#browseSharedPoolOfIt. |
2002 (selectedSymbol notNil |
1995 ]. |
2003 and:[SharedPool allSubclasses contains:[:pool | pool includesKey:selectedSymbol]]) ifFalse:[ |
1996 ]. |
2004 sub disable:#browseSharedPoolOfIt. |
1997 self isReadOnly ifTrue:[ |
2005 ]. |
1998 sub disableAll:#(commentSelection uncommentSelection) |
2006 ]. |
1999 ]. |
2007 self isReadOnly ifTrue:[ |
|
2008 sub disableAll:#(commentSelection uncommentSelection) |
|
2009 ]. |
2000 ]. |
2010 ]. |
2001 |
2011 |
2002 m notNil ifTrue:[ |
2012 m notNil ifTrue:[ |
2003 " |
2013 " |
2004 workspaces support #doIt, #printIt and #inspectIt |
2014 workspaces support #doIt, #printIt and #inspectIt |
2005 add them after paste. |
2015 add them after paste. |
2006 " |
2016 " |
2007 idx := m indexOf:#paste. |
2017 idx := m indexOf:#paste. |
2008 idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
2018 idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
2009 idx ~~ 0 ifTrue:[ |
2019 idx ~~ 0 ifTrue:[ |
2010 m |
2020 m |
2011 addItemList:#( |
2021 addItemList:#( |
2012 ('-' ) |
2022 ('-' ) |
2013 ('DoIt' doIt DoIt ) |
2023 ('DoIt' doIt DoIt ) |
2014 ('PrintIt' printIt PrintIt ) |
2024 ('PrintIt' printIt PrintIt ) |
2015 ('InspectIt' inspectIt InspectIt)) |
2025 ('InspectIt' inspectIt InspectIt)) |
2016 resources:resources |
2026 resources:resources |
2017 after:idx. |
2027 after:idx. |
2018 |
2028 |
2019 ]. |
2029 ]. |
2020 |
2030 |
2021 (self hasSelectionOrTextInCursorLine) ifFalse:[ |
2031 (self hasSelectionOrTextInCursorLine) ifFalse:[ |
2022 |lNr line| |
2032 |lNr line| |
2023 |
2033 |
2024 lNr := self cursorLine. |
2034 lNr := self cursorLine. |
2025 line := self listAt:lNr. |
2035 line := self listAt:lNr. |
2026 line isEmptyOrNil ifTrue:[ |
2036 line isEmptyOrNil ifTrue:[ |
2027 m disableAll:#(printIt doIt inspectIt browseIt) |
2037 m disableAll:#(printIt doIt inspectIt browseIt) |
2028 ]. |
2038 ]. |
2029 ]. |
2039 ]. |
2030 self isReadOnly ifTrue:[ |
2040 self isReadOnly ifTrue:[ |
2031 m disable:#printIt |
2041 m disable:#printIt |
2032 ]. |
2042 ]. |
2033 ]. |
2043 ]. |
2034 |
2044 |
2035 ^ m ? sub. |
2045 ^ m ? sub. |
2036 |
2046 |
2037 "Modified: / 22-04-1998 / 21:49:06 / ca" |
2047 "Modified: / 22-04-1998 / 21:49:06 / ca" |