Refactoring of NavigatorModel's environment.
The environment is taken from an environmentHolder (if provided) or defaults
to Smalltalk (if holder is not provided)
--- a/Tools__GenericToolbox.st Tue Feb 25 11:41:22 2014 +0100
+++ b/Tools__GenericToolbox.st Tue Feb 25 11:41:28 2014 +0100
@@ -35,13 +35,55 @@
"
! !
+!GenericToolbox methodsFor:'accessing-methods'!
+
+globalsReferencedByMethods: methods
+ "Returns a list of globals (classes) referenced by given methods"
+
+ | detector globals |
+
+ detector := [ :literal :method :recurse |
+ literal isSymbol ifTrue:[
+ | cls ns |
+
+ ns := method mclass nameSpace.
+ (ns notNil and:[ (cls := environment at: literal) notNil]) ifTrue:[
+ globals add: cls.
+ ] ifFalse:[
+ (cls := environment at: literal) notNil ifTrue:[
+ globals add: cls.
+ ].
+ ].
+ ] ifFalse:[
+ (recurse and:[ literal isArray ]) ifTrue:[
+ literal do:[:each | detector value: each value: method value: recurse ].
+ ].
+ ].
+ ].
+
+ globals := Set new.
+ methods do:[:m |
+ | recurse |
+
+ "/ If the method is method spec, the do recurse into
+ "/ literal array when searching for globals, otherwise
+ "/ do not.
+ recurse := m resourceType == #canvas.
+ m literalsDo:[:each | detector value: each value: m value: recurse ].
+ ].
+
+ ^ globals.
+
+ "Created: / 24-02-2014 / 16:25:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!GenericToolbox class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/Tools__GenericToolbox.st,v 1.1 2014-02-24 16:10:46 vrany Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/Tools__GenericToolbox.st,v 1.2 2014-02-25 10:41:28 vrany Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libtool/Tools__GenericToolbox.st,v 1.1 2014-02-24 16:10:46 vrany Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/Tools__GenericToolbox.st,v 1.2 2014-02-25 10:41:28 vrany Exp $'
! !