Workspace.st
changeset 5066 8ed2ee897fbe
parent 5065 8297b68f9fe1
child 5072 69124555bf22
--- a/Workspace.st	Sun Jun 15 14:01:49 2014 +0200
+++ b/Workspace.st	Mon Jun 16 14:06:35 2014 +0200
@@ -1765,7 +1765,7 @@
 browseReferencesToIt
     "open a browser on all references to the selected global, poolvar or namespace class"
 
-    |nameOfVariable browserClass|
+    |nameOfVariable browserClass sym|
 
     nameOfVariable := self selectedTextOrSyntaxElement.
     nameOfVariable notEmptyOrNil ifTrue:[
@@ -1773,48 +1773,53 @@
         self windowGroup withWaitCursorDo:[
             |cls privateClass|
 
-            "/ is it a class variable?
-            ((cls := self editedClass) notNil
-            and:[ (cls theNonMetaclass allClassVarNames includes:nameOfVariable) ]) ifTrue:[
-                browserClass
-                    browseRefsTo:nameOfVariable
-                    classVars:true
-                    in:(cls whichClassDefinesClassVar:nameOfVariable) withAllSubclasses
-                    modificationsOnly:false.
+            (nameOfVariable startsWith:'#') ifTrue:[
+                sym := (nameOfVariable copyFrom:2) asSymbolIfInterned.
+                browserClass browseForSymbol:sym.
             ] ifFalse:[
-                "/ is it a private class?
-                (cls notNil
-                and:[ (privateClass := cls theNonMetaclass privateClassNamed:nameOfVariable) notNil ]) ifTrue:[
-                    browserClass browseReferendsOf:(privateClass name)
+                "/ is it a class variable?
+                ((cls := self editedClass) notNil
+                and:[ (cls theNonMetaclass allClassVarNames includes:nameOfVariable) ]) ifTrue:[
+                    browserClass
+                        browseRefsTo:nameOfVariable
+                        classVars:true
+                        in:(cls whichClassDefinesClassVar:nameOfVariable) withAllSubclasses
+                        modificationsOnly:false.
                 ] ifFalse:[
-                    |pool nsClass|
-
-                    "/ is it a pool variable?
-                    cls notNil ifTrue:[
-                        pool := cls theNonMetaclass sharedPools
-                                detect:[:pool | pool classVarNames includes:nameOfVariable]
-                                ifNone:nil.
-                    ].
-                    pool notNil ifTrue:[
-                        browserClass browseReferendsOf:(pool name,':',nameOfVariable)
+                    "/ is it a private class?
+                    (cls notNil
+                    and:[ (privateClass := cls theNonMetaclass privateClassNamed:nameOfVariable) notNil ]) ifTrue:[
+                        browserClass browseReferendsOf:(privateClass name)
                     ] ifFalse:[
-                        (cls notNil
-                          and:[ cls nameSpace notNil
-                          and:[ nameOfVariable knownAsSymbol
-                          and:[ (nsClass := cls nameSpace at:nameOfVariable asSymbol) notNil
-                        ]]]) ifTrue:[
-                            "/ a namespace class?
-                            browserClass browseReferendsOf:nsClass name
+                        |pool nsClass|
+
+                        "/ is it a pool variable?
+                        cls notNil ifTrue:[
+                            pool := cls theNonMetaclass sharedPools
+                                    detect:[:pool | pool classVarNames includes:nameOfVariable]
+                                    ifNone:nil.
+                        ].
+                        pool notNil ifTrue:[
+                            browserClass browseReferendsOf:(pool name,':',nameOfVariable)
                         ] ifFalse:[
-                            "/ an instvar?
-                            (cls allInstVarNames includes:nameOfVariable) ifTrue:[
-                                browserClass 
-                                    browseInstRefsTo:nameOfVariable 
-                                    under:(cls whichClassDefinesInstVar:nameOfVariable) 
-                                    modificationsOnly:false
+                            (cls notNil
+                              and:[ cls nameSpace notNil
+                              and:[ nameOfVariable knownAsSymbol
+                              and:[ (nsClass := cls nameSpace at:nameOfVariable asSymbol) notNil
+                            ]]]) ifTrue:[
+                                "/ a namespace class?
+                                browserClass browseReferendsOf:nsClass name
                             ] ifFalse:[
-                                "/ no, assume global
-                                browserClass browseReferendsOf:nameOfVariable
+                                "/ an instvar?
+                                (cls allInstVarNames includes:nameOfVariable) ifTrue:[
+                                    browserClass 
+                                        browseInstRefsTo:nameOfVariable 
+                                        under:(cls whichClassDefinesInstVar:nameOfVariable) 
+                                        modificationsOnly:false
+                                ] ifFalse:[
+                                    "/ no, assume global
+                                    browserClass browseReferendsOf:nameOfVariable
+                                ]
                             ]
                         ]
                     ]
@@ -1966,36 +1971,40 @@
             sel isNil ifTrue:[
                 sub disable:#browseReferencesToIt.
             ] ifFalse:[
-                selectedSymbol := sel asSymbolIfInterned.
-                (selectedSymbol notNil
-                 and:[(Smalltalk includesKey:selectedSymbol)
-                      or:[(NameSpace allNameSpaces contains:[:ns | ns includesKey:selectedSymbol]) ]]
-                ) ifTrue:[
-                    "/ a global or namespace var selected
+                (sel startsWith:'#') ifTrue:[
+                    "/ a symbol selected - can search references
                 ] ifFalse:[
-                    |cls|
-
-                    cls := self editedClass.
-                    cls notNil ifTrue:[
-                        cls := cls theNonMetaclass.
-                        ((cls allClassVarNames includes:sel)
-                          or:[ (cls theNonMetaclass privateClassNamed:sel) notNil]) ifTrue:[
-                            "/ a classvar or private class
-                        ] ifFalse:[
-                            |pool|
-                            "/ is it a pool variable?
-                            pool := cls sharedPools
-                                    detect:[:pool | pool classVarNames includes:sel]
-                                    ifNone:nil.
-                            pool isNil ifTrue:[
-                                "/ todo: an instvar selected?
-                                (cls allInstVarNames includes:sel) ifFalse:[
-                                    sub disable:#browseReferencesToIt.
+                    selectedSymbol := sel asSymbolIfInterned.
+                    (selectedSymbol notNil
+                     and:[(Smalltalk includesKey:selectedSymbol)
+                          or:[(NameSpace allNameSpaces contains:[:ns | ns includesKey:selectedSymbol]) ]]
+                    ) ifTrue:[
+                        "/ a global or namespace var selected
+                    ] ifFalse:[
+                        |cls|
+
+                        cls := self editedClass.
+                        cls notNil ifTrue:[
+                            cls := cls theNonMetaclass.
+                            ((cls allClassVarNames includes:sel)
+                              or:[ (cls theNonMetaclass privateClassNamed:sel) notNil]) ifTrue:[
+                                "/ a classvar or private class
+                            ] ifFalse:[
+                                |pool|
+                                "/ is it a pool variable?
+                                pool := cls sharedPools
+                                        detect:[:pool | pool classVarNames includes:sel]
+                                        ifNone:nil.
+                                pool isNil ifTrue:[
+                                    "/ todo: an instvar selected?
+                                    (cls allInstVarNames includes:sel) ifFalse:[
+                                        sub disable:#browseReferencesToIt.
+                                    ].
                                 ].
                             ].
+                        ] ifFalse:[
+                            sub disable:#browseReferencesToIt.
                         ].
-                    ] ifFalse:[
-                        sub disable:#browseReferencesToIt.
                     ].
                 ].
             ].
@@ -2308,10 +2317,10 @@
 !Workspace class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.331 2014-06-15 12:01:49 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.332 2014-06-16 12:06:35 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.331 2014-06-15 12:01:49 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.332 2014-06-16 12:06:35 cg Exp $'
 ! !