From VisualWorks®, 7.6 of February 8, 2008 on March 3, 2008 at 9:43:11 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <class> <name>BrowserEnvironment</name> <environment>Refactory.Browser</environment> <super>Core.Object</super> <private>false</private> none label searchStrings <imports></imports> <category>Browser-Environments</category> <attributes> <package>Browser-Environments</package> </attributes> </class> <comment> Refactory.Browser.BrowserEnvironment
BrowserEnvironment represents the classes/methods that are to be browsed. Not only is this class the superclass of all environments, it also represents browsing everything. Instance Variables: label <String> a description of what we're looking at searchStrings <Collection of: String> strings to look for whenever we select a method
</comment> <class> <name>BrowserEnvironmentWrapper</name> <environment>Refactory.Browser</environment> <super>Refactory.Browser.BrowserEnvironment</super> <private>false</private> none environment <imports></imports> <category>Browser-Environments</category> <attributes> <package>Browser-Environments</package> </attributes> </class> <comment> Refactory.Browser.BrowserEnvironmentWrapper
BrowserEnvironmentWrapper is a wrapper for BrowserEnvironments that limits what is shown. While it does not have any #subclassResponsibility methods, it is an abstract class since it doesn't provide any useful behavior by itself Instance Variables: environment <BrowserEnvironment> the environment we're wrapping
</comment> <class> <name>PundleEnvironment</name> <environment>Refactory.Browser</environment> <super>Refactory.Browser.BrowserEnvironmentWrapper</super> <private>false</private> none bundleNames packageNames <imports></imports> <category>Browser-Environments</category> <attributes> <package>Browser-Environments</package> </attributes> </class> <comment> Refactory.Browser.PundleEnvironment
PundleEnvironment represents all of the classes and methods in a set of bundles and packages. Instance Variables: bundleNames <(SequenceableCollection of: String)> Bundles represented by this environment. packageNames <(Collection of: String)> Packages represented by this environment.
</comment> <class> <name>NotEnvironment</name> <environment>Refactory.Browser</environment> <super>Refactory.Browser.BrowserEnvironmentWrapper</super> <private>false</private> none <imports></imports> <category>Browser-Environments</category> <attributes> <package>Browser-Environments</package> </attributes> </class> <comment> Refactory.Browser.NotEnvironment
NotEnvironment represents the complement of its environment. It contains all of the methods and classes in the image that are NOT in its environment.
</comment> <class> <name>VariableEnvironment</name> <environment>Refactory.Browser</environment> <super>Refactory.Browser.BrowserEnvironmentWrapper</super> <private>false</private> none instanceVariables instanceVariableReaders instanceVariableWriters selectorCache <imports></imports> <category>Browser-Environments</category> <attributes> <package>Browser-Environments</package> </attributes> </class> <comment> Refactory.Browser.VariableEnvironment
VariableEnvironment represents a set of classes and methods that refer to a set of instance variables. Instance Variables: instanceVariables <Dictionary key: String value: (Set of: String)> Keys are the classes, values are the variables whose references are in this environment. instanceVariableReaders <Dictionary key: String value: (Set of: String)> Keys are the classes, values are the selectors that read these instance variables. instanceVariableWriters <Dictionary key: String value: (Set of: String)> Keys are the classes, values are the selectors that write to these instance variables. selectorCache <Dictionary key: String value: (Set of: String)> Keys are the classes, values are the selectors that refer to these instance variables.
</comment> <class> <name>ProtocolEnvironment</name> <environment>Refactory.Browser</environment> <super>Refactory.Browser.BrowserEnvironmentWrapper</super> <private>false</private> none class protocols <imports></imports> <category>Browser-Environments</category> <attributes> <package>Browser-Environments</package> </attributes> </class> <comment> Refactory.Browser.ProtocolEnvironment
ProtocolEnvironment represents a collection of protocols in a class to be browsed. Instance Variables: class <Behavior> the class that contains the protocols protocols <Collection of: Symbol> the protocols to be browsed
</comment> <class> <name>AndEnvironment</name> <environment>Refactory.Browser</environment> <super>Refactory.Browser.BrowserEnvironmentWrapper</super> <private>false</private> none andedEnvironment <imports></imports> <category>Browser-Environments</category> <attributes> <package>Browser-Environments</package> </attributes> </class> <comment> Refactory.Browser.AndEnvironment
AndEnvironment represents an environment that contains all of the classes in methods that occur in its environment AND andedEnvironment. Instance Variables: andedEnvironment <BrowserEnvironmentWrapper> The environment to AND with.
</comment> <class> <name>SelectorEnvironment</name> <environment>Refactory.Browser</environment> <super>Refactory.Browser.BrowserEnvironmentWrapper</super> <private>false</private> none classSelectors metaClassSelectors initializers <imports></imports> <category>Browser-Environments</category> <attributes> <package>Browser-Environments</package> </attributes> </class> <comment> Refactory.Browser.SelectorEnvironment
SelectorEnvironment represents a collection of methods to be browsed. Instance Variables: classSelectors <Dictionary key: Symbol value: (Collection of: Symbol)> selectors for the class side initializers <Collection> the binding references of all shared variable initializers in our environment metaClassSelectors <Dictionary key: Symbol value: (Collection of: Symbol)> selectors for the metaclass side
</comment> <class> <name>ClassEnvironment</name> <environment>Refactory.Browser</environment> <super>Refactory.Browser.BrowserEnvironmentWrapper</super> <private>false</private> none classes metaClasses <imports></imports> <category>Browser-Environments</category> <attributes> <package>Browser-Environments</package> </attributes> </class> <comment> Refactory.Browser.ClassEnvironment
ClassEnvironment represents a collection of classes to be browsed. Instance Variables: classes <Collection of: Symbol> the class names (not metaclasses) metaClasses <Collection of: Symbol> the class names for the metaclasses that are selected
</comment> <class> <name>UnparceledParcel</name> <environment>Refactory.Browser</environment> <super>Core.Object</super> <private>false</private> none <imports></imports> <category>Browser-Navigator Parts</category> <attributes> <package>Browser-Environments</package> </attributes> </class> <comment> Refactory.Browser.UnparceledParcel
UnparceledParcel is a fake parcel that represents all unparceled items in the image.
</comment> <class> <name>MethodDefinitionEnvironment</name> <environment>Refactory.Browser</environment> <super>Refactory.Browser.SelectorEnvironment</super> <private>false</private> none definitions <imports></imports> <category>Browser-Environments</category> <attributes> <package>Browser-Environments</package> </attributes> </class> <comment> Refactory.Browser.MethodDefinitionEnvironment
MethodDefinitionEnvironment provided compatibility with the previous browsers so that the extra text of a method definition can be displayed. Instance Variables: definitions <OrderedCollection of: GeneralMethodDefinition> all the method definitions
</comment> <class> <name>ParcelEnvironment</name> <environment>Refactory.Browser</environment> <super>Refactory.Browser.BrowserEnvironmentWrapper</super> <private>false</private> none parcelNames <imports></imports> <category>Browser-Environments</category> <attributes> <package>Browser-Environments</package> </attributes> </class> <comment> Refactory.Browser.ParcelEnvironment
ParcelEnvironment contains all of the Classes and Methods within a set of parcels. Instance Variables: parcelNames <(Collection of: String)> Parcels represented by this environment.
</comment> <methods> Refactory.Browser.BrowserEnvironment <category>environments</category>
& anEnvironment "If we or anEnvironment includes everything, then just include the other environment (optimization)" self isSystem ifTrue: [^anEnvironment]. anEnvironment isSystem ifTrue: [^self]. ^AndEnvironment onEnvironment: self and: anEnvironment
forClass: aClass protocols: protocolCollection ^ProtocolEnvironment onEnvironment: self class: aClass protocols: protocolCollection
forClass: aClass selectors: selectorCollection ^(SelectorEnvironment onMethods: selectorCollection forClass: aClass in: self) label: aClass fullName , '>>' , (selectorCollection detect: [:each | true] ifNone: ['']); yourself
forClasses: classCollection ^ClassEnvironment onEnvironment: self classes: classCollection
forParcels: parcelList ^ParcelEnvironment onEnvironment: self parcels: parcelList
forPundles: pundleList ^PundleEnvironment onEnvironment: self pundles: pundleList
implementorsMatching: aString ^SelectorEnvironment implementorsMatching: aString in: self
implementorsOf: aSelector ^SelectorEnvironment implementorsOf: aSelector in: self
instVarReadersTo: instVarName in: aClass ^VariableEnvironment on: self readersOfInstanceVariable: instVarName in: aClass
instVarRefsTo: instVarName in: aClass ^VariableEnvironment on: self referencesToInstanceVariable: instVarName in: aClass
instVarWritersTo: instVarName in: aClass ^VariableEnvironment on: self writersOfInstanceVariable: instVarName in: aClass
matches: aString ^SelectorEnvironment matches: aString in: self
not self isSystem ifTrue: [^SelectorEnvironment new]. ^NotEnvironment onEnvironment: self
referencesTo: aLiteral ^SelectorEnvironment referencesTo: aLiteral in: self
referencesTo: aLiteral in: aClass | classes | classes := aClass withAllSuperclasses asSet. classes addAll: aClass allSubclasses; addAll: aClass class withAllSuperclasses; addAll: aClass class allSubclasses. ^(self forClasses: classes) referencesTo: aLiteral
selectMethods: aBlock | env | env := SelectorEnvironment onEnvironment: self. self classesAndSelectorsDo: [:each :sel | (aBlock value: (each compiledMethodAt: sel)) ifTrue: [env addClass: each selector: sel]]. ^env
sourceCodeMatching: aString ^self selectMethods: [:each | | source | source := each getSource. source notNil and: [aString match: source]]
| anEnvironment "If we or anEnvironment includes everything, then return it instead of creating an or that will include everything." self isSystem ifTrue: [^self]. anEnvironment isSystem ifTrue: [^anEnvironment]. ^(self not & anEnvironment not) not
</methods> <methods> Refactory.Browser.BrowserEnvironment <category>accessing-classes</category>
allClassesDo: aBlock Root allBehaviorsDo: aBlock
classes | classes | classes := Set new. self classesDo: [:each | classes add: each]. ^classes
classesDo: aBlock self allClassesDo: [:each | (self includesClass: each) ifTrue: [aBlock value: each]]
classNames | names | names := Set new. self classesDo: [:each | names add: each instanceBehavior fullRootName]. ^names
nameSpaceObjectNames | names | names := Set new. Root withAllNameSpacesDo: [:each | each bindingsDo: [:binding | (self includesBinding: binding in: each) ifTrue: [names add: (binding isForGeneral ifTrue: [each fullRootName] ifFalse: [binding value fullRootName])]]]. ^names
nameSpacesDo: aBlock Root withAllNameSpacesDo: [:each | (self includesNameSpace: each) ifTrue: [aBlock value: each]]
</methods> <methods> Refactory.Browser.BrowserEnvironment <category>accessing</category>
addSearchString: aString searchStrings isNil ifTrue: [searchStrings := SortedCollection sortBlock: [:a :b | (a indexOf: $: ifAbsent: [a size]) > (b indexOf: $: ifAbsent: [b size])]]. searchStrings add: aString
bindingReferencesDo: aBlock Root withAllNameSpacesDo: [:ns | | ref | ref := ns fullyQualifiedReference. ns bindingsDo: [:each | (self includesBinding: each in: ns) ifTrue: [aBlock value: (ref append: each key)]]]. Root allBehaviorsDo: [:cls | cls isMeta ifFalse: [cls asNameSpace bindingsDo: [:each | (self includesBinding: each in: cls) ifTrue: [| ref | ref := cls fullyQualifiedReference. aBlock value: (ref append: each key)]]]]
bindingsFor: aCategoryName in: aNameSpace | bindings | bindings := OrderedCollection new. (aNameSpace organization listAtCategoryNamed: aCategoryName) do: [:each | | binding | binding := aNameSpace bindingFor: each. (binding notNil and: [self includesBinding: binding in: aNameSpace]) ifTrue: [bindings add: binding]]. ^bindings
classesAndSelectorsDo: aBlock self classesDo: [:class | self selectorsForClass: class do: [:sel | aBlock value: class value: sel]]
instanceVariablesFor: aClass ^aClass instVarNames
methodDefinitions | defs | defs := OrderedCollection new. self classesAndSelectorsDo: [:class :selector | defs add: (MethodDefinition class: class selector: selector)]. self sharedVariableReferencesDo: [:each | defs add: (InitializerDefinition nameSpace: each environment key: each name)]. ^defs
methodsDo: aBlock self classesAndSelectorsDo: [:class :selector | aBlock value: (class compiledMethodAt: selector)]
numberClasses ^self classNames size
numberSelectors | total | total := 0. self allClassesDo: [:each | self selectorsForClass: each do: [:sel | total := total + 1]]. ^total
protocolsFor: aClass ^aClass organization categories select: [:each | self includesProtocol: each in: aClass]
searchStrings ^searchStrings isNil ifTrue: [#()] ifFalse: [searchStrings]
searchStrings: aCollection searchStrings := aCollection
selectorsFor: aProtocol in: aClass ^(aClass organization listAtCategoryNamed: aProtocol) select: [:each | self includesSelector: each in: aClass]
selectorsForClass: aClass | selectors | selectors := Set new: 50. self selectorsForClass: aClass do: [:each | selectors add: each]. ^selectors
selectorsForClass: aClass do: aBlock aClass selectorsAndMethodsDo: [:each :meth | (self includesSelector: each in: aClass) ifTrue: [aBlock value: each]]
sharedVariableProtocolsFor: aClass ^aClass asNameSpace organization sharedVariableCategories select: [:each | self includesDataProtocol: each in: aClass]
sharedVariableReferencesDo: aBlock self bindingReferencesDo: [:each | | binding | binding := each bindingOrNil. (binding notNil and: [binding isForGeneral]) ifTrue: [aBlock value: each]]
sharedVariablesFor: aProtocol in: aClassOrNameSpace ^(aClassOrNameSpace asNameSpace organization listAtCategoryNamed: aProtocol) select: [:each | | binding | binding := aClassOrNameSpace bindingFor: each. binding isForGeneral and: [self includesBinding: binding in: aClassOrNameSpace]]
sharedVariablesForClass: aClass | vars | vars := Set new. aClass asNameSpace bindingsDo: [:each | (each isForGeneral and: [self includesBinding: each in: aClass]) ifTrue: [vars add: each key]]. ^vars
whichProtocolIncludes: aSelector in: aClass ^aClass organization categoryOfElement: aSelector
whichProtocolIncludesVariable: aSymbol in: aClass ^aClass asNameSpace organization categoryOfElement: aSymbol
</methods> <methods> Refactory.Browser.BrowserEnvironment <category>copying</category>
copyEmpty ^self class new
</methods> <methods> Refactory.Browser.BrowserEnvironment <category>testing</category>
definesClass: aClass ^true
includesBinding: aBinding in: aNameSpace ^true
includesClass: aClass ^true
includesDataProtocol: aProtocol in: aClass ^true
includesNameSpace: aNameSpace ^true
includesProtocol: aProtocol in: aClass ^true
includesSelector: aSelector in: aClass ^true
isClassContainer ^self isSystem
isClassEnvironment ^false
isEmpty ^false
isSelector ^false
isSystem ^true
notEmpty ^self isEmpty not
</methods> <methods> Refactory.Browser.BrowserEnvironment <category>initialize-release</category>
initialize
label: aString label := aString
</methods> <methods> Refactory.Browser.BrowserEnvironment <category>printing</category>
printOn: aStream aStream nextPutAll: self label
storeOn: aStream aStream nextPutAll: self class fullName; nextPutAll: ' new'
</methods> <methods> Refactory.Browser.BrowserEnvironment <category>private</category>
defaultLabel ^''
label ^label isNil ifTrue: [self defaultLabel] ifFalse: [label]
</methods> <methods> Refactory.Browser.BrowserEnvironment class <category>instance creation</category>
new ^(super new) initialize; yourself
</methods> <methods> Refactory.Browser.BrowserEnvironmentWrapper <category>private</category>
environment ^environment
</methods> <methods> Refactory.Browser.BrowserEnvironmentWrapper <category>testing</category>
definesClass: aClass ^environment definesClass: aClass
includesBinding: aBinding in: aNameSpace ^environment includesBinding: aBinding in: aNameSpace
includesClass: aClass ^environment includesClass: aClass
includesDataProtocol: aProtocol in: aClass ^(aClass isBehavior not or: [self includesClass: aClass]) and: [environment includesDataProtocol: aProtocol in: aClass]
includesNameSpace: aNameSpace ^environment includesNameSpace: aNameSpace
includesProtocol: aProtocol in: aClass ^(self includesClass: aClass) and: [environment includesProtocol: aProtocol in: aClass]
includesSelector: aSelector in: aClass ^(self includesClass: aClass) and: [environment includesSelector: aSelector in: aClass]
isEmpty self classesDo: [:each | ^false]. ^true
isSystem ^false
</methods> <methods> Refactory.Browser.BrowserEnvironmentWrapper <category>initialize-release</category>
onEnvironment: anEnvironment environment := anEnvironment
</methods> <methods> Refactory.Browser.BrowserEnvironmentWrapper <category>printing</category>
storeOn: aStream aStream nextPutAll: '('; nextPutAll: self class fullName; nextPutAll: ' onEnvironment: '. environment storeOn: aStream. aStream nextPut: $)
</methods> <methods> Refactory.Browser.BrowserEnvironmentWrapper class <category>instance creation</category>
new ^self onEnvironment: BrowserEnvironment new
onEnvironment: anEnvironment ^(self basicNew) initialize; onEnvironment: anEnvironment; yourself
</methods> <methods> Refactory.Browser.PundleEnvironment <category>accessing-classes</category>
classesDo: aBlock | classes block | classes := Set new: 100. block := [:each | | class | class := each actual. class notNil ifTrue: [(classes includes: class) ifFalse: [classes add: class. aBlock value: class]]]. self packages do: [:each | each classesDefinedInPackage do: block. each classesExtendedInPackage do: block. each metaclassesDefinedInPackage do: block. each metaclassesExtendedInPackage do: block]
</methods> <methods> Refactory.Browser.PundleEnvironment <category>copying</category>
postCopy super postCopy. bundleNames := bundleNames copy. packageNames := packageNames copy
</methods> <methods> Refactory.Browser.PundleEnvironment <category>initialize-release</category>
bundleNames: bundleCollection packageNames: packageCollection bundleNames := bundleCollection. packageNames := packageCollection
pundles: aCollection bundleNames := OrderedCollection new. packageNames := OrderedCollection new. aCollection do: [:each | (each isPackage ifTrue: [packageNames] ifFalse: [bundleNames]) add: each name]
</methods> <methods> Refactory.Browser.PundleEnvironment <category>printing</category>
storeOn: aStream aStream nextPut: $(. super storeOn: aStream. aStream nextPutAll: ' bundleNames: '. bundleNames asArray storeOn: aStream. aStream nextPutAll: ' packageNames: '. packageNames asArray storeOn: aStream. aStream nextPut: $)
</methods> <methods> Refactory.Browser.PundleEnvironment <category>testing</category>
definesClass: aBehavior ^self packages anySatisfy: [:each | each definesClass: aBehavior]
includesBinding: aBinding in: aNameSpace (super includesBinding: aBinding in: aNameSpace) ifFalse: [^false]. aBinding isForClass ifTrue: [^(self includesClass: aBinding value) or: [self includesClass: aBinding value class]]. aBinding isForNameSpace ifTrue: [^self includesNameSpace: aBinding value]. ^self packages anySatisfy: [:each | each definesName: aBinding key in: aNameSpace]
includesClass: aClass (super includesClass: aClass) ifFalse: [^false]. ^self packages anySatisfy: [:each | (each definesClass: aClass) or: [each extendsClass: aClass]]
includesNameSpace: aNameSpace ^self packages anySatisfy: [:each | each definesClassOrNameSpace: aNameSpace]
includesProtocol: aProtocol in: aClass ^(super includesProtocol: aProtocol in: aClass) and: [(environment selectorsFor: aProtocol in: aClass) anySatisfy: [:aSelector | self includesSelector: aSelector in: aClass]]
includesSelector: aSelector in: aClass ^(environment includesSelector: aSelector in: aClass) and: [self packages anySatisfy: [:each | each definesSelector: aSelector forClass: aClass]]
isClassContainer ^true
</methods> <methods> Refactory.Browser.PundleEnvironment <category>accessing</category>
numberSelectors "do not use PackageModel methods method, it includes overriden methods" | count | count := 0. self packages do: [:each | each classModelsDo: [:cm | count := count + cm methods size]]. ^count
packages | packages todo each | packages := OrderedCollection new. todo := self pundles. [todo isEmpty] whileFalse: [each := todo removeFirst. each isBundle ifTrue: [todo addAll: each containedItems] ifFalse: [packages add: each]]. ^packages
pundles | pundles | pundles := OrderedCollection new: packageNames size + bundleNames size. bundleNames do: [:each | | bundle | bundle := Store.Registry bundleNamed: each. bundle notNil ifTrue: [pundles add: bundle]]. packageNames do: [:each | | package | package := Store.Registry packageNamed: each. package notNil ifTrue: [pundles add: package]]. ^pundles
selectorsForClass: aClass do: aBlock self packages do: [:each | (each definedSelectorsFor: aClass) do: [:sel | ((aClass includesSelector: sel) and: [environment includesSelector: sel in: aClass]) ifTrue: [aBlock value: sel]]]
sharedVariableReferencesDo: aBlock | refs | refs := Set new. self packages do: [:package | package data do: [:each | refs add: each fullName asQualifiedReference]]. refs do: [:each | each isDefined ifTrue: [aBlock value: each]]
</methods> <methods> Refactory.Browser.PundleEnvironment <category>private</category>
defaultLabel | stream | stream := String new writeStream. bundleNames , packageNames do: [:each | stream nextPutAll: each] separatedBy: [stream nextPut: $ ]. ^stream contents
</methods> <methods> Refactory.Browser.PundleEnvironment class <category>instance creation</category>
onEnvironment: aBrowserEnvironment bundleNames: bundleCollection packageNames: packageCollection ^(self onEnvironment: aBrowserEnvironment) bundleNames: bundleCollection packageNames: packageCollection; yourself
onEnvironment: aBrowserEnvironment pundles: aCollection ^(self onEnvironment: aBrowserEnvironment) pundles: aCollection; yourself
</methods> <methods> Refactory.Browser.NotEnvironment <category>testing</category>
includesBinding: aBinding in: aNameSpace ^aBinding isForClass ifTrue: [(self includesClass: aBinding value) or: [self includesClass: aBinding value class]] ifFalse: [(super includesBinding: aBinding in: aNameSpace) not]
includesClass: aClass (environment includesClass: aClass) ifFalse: [^true]. aClass selectorsAndMethodsDo: [:each :meth | (environment includesSelector: each in: aClass) ifFalse: [^true]]. ^false
includesNameSpace: aNameSpace ^(environment includesNameSpace: aNameSpace) not
includesProtocol: aProtocol in: aClass ^(self selectorsFor: aProtocol in: aClass) notEmpty
includesSelector: aSelector in: aClass ^(environment includesSelector: aSelector in: aClass) not
</methods> <methods> Refactory.Browser.NotEnvironment <category>environments</category>
not ^environment
</methods> <methods> Refactory.Browser.NotEnvironment <category>printing</category>
storeOn: aStream environment storeOn: aStream. aStream nextPutAll: ' not'
</methods> <methods> Refactory.Browser.VariableEnvironment <category>private</category>
accessorMethods ^#(#instanceVariables #instanceVariableReaders #instanceVariableWriters)
allClassesDo: aBlock | classes instVarBlock | classes := Set new. instVarBlock := [:each | | class | class := self classForName: each. classes addAll: class allSuperclasses; addAll: class withAllSubclasses]. instanceVariables keysDo: instVarBlock. instanceVariableReaders keysDo: instVarBlock. instanceVariableWriters keysDo: instVarBlock. classes do: aBlock
classForName: aString | name isMeta class | isMeta := aString includes: $ . name := (isMeta ifTrue: [aString copyFrom: 1 to: (aString size - 6 max: 1)] ifFalse: [aString]) asSymbol. class := name asQualifiedReference valueOrDo: [nil]. ^class notNil & isMeta ifTrue: [class class] ifFalse: [class]
computeSelectorCacheFor: aClass ^self instanceVariableSelectorsFor: aClass
flushCachesFor: aClass | nonMetaClass | selectorCache isNil ifTrue: [^self]. nonMetaClass := aClass instanceBehavior. nonMetaClass withAllSubclasses do: [:each | selectorCache removeKey: each ifAbsent: []; removeKey: each class ifAbsent: []]
instanceVariableReaders ^instanceVariableReaders
instanceVariableReaders: anObject instanceVariableReaders := anObject
instanceVariables ^instanceVariables
instanceVariables: anObject instanceVariables := anObject
instanceVariableSelectorsFor: aClass | selectors | selectors := Set new. #(#instanceVariables #instanceVariableReaders #instanceVariableWriters) with: #(#whichSelectorsAccess: #whichSelectorsRead: #whichSelectorsAssign:) do: [:var :sel | | instVars | instVars := Set new. (self perform: var) keysDo: [:each | | cls | cls := self classForName: each. (cls notNil and: [(aClass includesBehavior: cls) or: [cls includesBehavior: aClass]]) ifTrue: [instVars addAll: ((self perform: var) at: each)]]. instVars do: [:each | selectors addAll: (aClass perform: sel with: each)]]. ^selectors
instanceVariableWriters ^instanceVariableWriters
instanceVariableWriters: anObject instanceVariableWriters := anObject
selectorCache ^selectorCache isNil ifTrue: [selectorCache := Dictionary new] ifFalse: [selectorCache]
selectorCacheFor: aClass ^self selectorCache at: aClass ifAbsentPut: [self computeSelectorCacheFor: aClass]
</methods> <methods> Refactory.Browser.VariableEnvironment <category>accessing</category>
addClass: aClass instanceVariable: aString (instanceVariables at: aClass fullRootName ifAbsentPut: [Set new]) add: aString. self flushCachesFor: aClass. self addSearchString: aString
addClass: aClass instanceVariableReader: aString (instanceVariableReaders at: aClass fullRootName ifAbsentPut: [Set new]) add: aString. self flushCachesFor: aClass. self addSearchString: aString
addClass: aClass instanceVariableWriter: aString (instanceVariableWriters at: aClass fullRootName ifAbsentPut: [Set new]) add: aString. self flushCachesFor: aClass. self addSearchString: aString
classNamesWithVariables | classNames | classNames := Set new. classNames addAll: instanceVariables keys; addAll: instanceVariableReaders keys; addAll: instanceVariableWriters keys. ^classNames
environmentForInstanceVariable: aString in: aClass | selectorEnvironment isReader isWriter | selectorEnvironment := SelectorEnvironment onEnvironment: self. selectorEnvironment addSearchString: aString. isReader := isWriter := false. ((instanceVariables at: aClass fullRootName ifAbsent: [#()]) includes: aString) ifTrue: [isReader := true. isWriter := true]. ((instanceVariableWriters at: aClass fullRootName ifAbsent: [#()]) includes: aString) ifTrue: [isWriter := true]. ((instanceVariableReaders at: aClass fullRootName ifAbsent: [#()]) includes: aString) ifTrue: [isReader := true]. aClass allSuperclasses , aClass withAllSubclasses do: [:each | isWriter ifTrue: [(each whichSelectorsAssign: aString) do: [:sel | selectorEnvironment addClass: each selector: sel]]. isReader ifTrue: [(each whichSelectorsRead: aString) do: [:sel | selectorEnvironment addClass: each selector: sel]]]. ^selectorEnvironment
instanceVariablesFor: aClass | vars name | vars := Set new. name := aClass fullRootName. vars addAll: (instanceVariables at: name ifAbsent: [#()]); addAll: (instanceVariableReaders at: name ifAbsent: [#()]); addAll: (instanceVariableWriters at: name ifAbsent: [#()]). ^vars
numberVariables ^self accessorMethods inject: 0 into: [:sum :each | sum + ((self perform: each) inject: 0 into: [:s :e | s + e size])]
removeClass: aClass instanceVariable: aString | vars | vars := instanceVariables at: aClass fullRootName ifAbsent: [Set new]. vars remove: aString ifAbsent: []. vars isEmpty ifTrue: [instanceVariables removeKey: aClass fullRootName ifAbsent: []]. self flushCachesFor: aClass
removeClass: aClass instanceVariableReader: aString | vars | vars := instanceVariableReaders at: aClass fullRootName ifAbsent: [Set new]. vars remove: aString ifAbsent: []. vars isEmpty ifTrue: [instanceVariableReaders removeKey: aClass fullRootName ifAbsent: []]. self flushCachesFor: aClass
removeClass: aClass instanceVariableWriter: aString | vars | vars := instanceVariableWriters at: aClass fullRootName ifAbsent: [Set new]. vars remove: aString ifAbsent: []. vars isEmpty ifTrue: [instanceVariableWriters removeKey: aClass fullRootName ifAbsent: []]. self flushCachesFor: aClass
</methods> <methods> Refactory.Browser.VariableEnvironment <category>copying</category>
copyDictionary: aDictionary | copy | copy := Dictionary new: aDictionary size. aDictionary keysAndValuesDo: [:key :value | copy at: key put: value]. ^copy
postCopy super postCopy. instanceVariables := self copyDictionary: instanceVariables. instanceVariableReaders := self copyDictionary: instanceVariableReaders. instanceVariableWriters := self copyDictionary: instanceVariableWriters. selectorCache := nil
</methods> <methods> Refactory.Browser.VariableEnvironment <category>testing</category>
includesBinding: aBinding in: aNameSpace ^(super includesBinding: aBinding in: aNameSpace) and: [aBinding isForClass and: [(self includesClass: aBinding value) or: [self includesClass: aBinding value class]]]
includesClass: aClass (super includesClass: aClass) ifFalse: [^false]. (instanceVariables includesKey: aClass name) ifTrue: [^true]. ^(self selectorCacheFor: aClass) anySatisfy: [:each | self includesSelector: each in: aClass]
includesProtocol: aProtocol in: aClass ^(self selectorsFor: aProtocol in: aClass) notEmpty
includesSelector: aSymbol in: aClass ^(environment includesSelector: aSymbol in: aClass) and: [(self selectorCacheFor: aClass) includes: aSymbol]
isEmpty ^self accessorMethods allSatisfy: [:each | (self perform: each) isEmpty]
</methods> <methods> Refactory.Browser.VariableEnvironment <category>initialize-release</category>
initialize super initialize. instanceVariables := Dictionary new. instanceVariableReaders := Dictionary new. instanceVariableWriters := Dictionary new
</methods> <methods> Refactory.Browser.VariableEnvironment <category>printing</category>
storeOn: aStream aStream nextPut: $(; nextPutAll: self class fullRootName; nextPutAll: ' new '. self accessorMethods do: [:each | aStream nextPutAll: each; nextPutAll: ': '. (self perform: each) storeOn: aStream. aStream nextPutAll: '; ']. aStream nextPutAll: ' yourself)'
</methods> <methods> Refactory.Browser.VariableEnvironment class <category>instance creation</category>
on: anEnvironment readersOfInstanceVariable: aString in: aClass ^(self onEnvironment: anEnvironment) label: ((#ReadersOf1sIn2s << #browser >> 'Readers of ''<1s>'' in <2s>') expandMacrosWith: aString with: aClass fullName); addClass: aClass instanceVariableReader: aString; yourself
on: anEnvironment referencesToInstanceVariable: aString in: aClass ^(self onEnvironment: anEnvironment) label: ((#ReferencesTo1sIn2s << #browser >> 'References to ''<1s>'' in <2s>') expandMacrosWith: aString with: aClass fullName); addClass: aClass instanceVariable: aString; yourself
on: anEnvironment writersOfInstanceVariable: aString in: aClass ^(self onEnvironment: anEnvironment) label: ((#WritersOf1sIn2s << #browser >> 'Writers of ''<1s>'' in <2s>') expandMacrosWith: aString with: aClass fullName); addClass: aClass instanceVariableWriter: aString; yourself
readersOfInstanceVariable: aString in: aClass ^self on: BrowserEnvironment new readersOfInstanceVariable: aString in: aClass
referencesToInstanceVariable: aString in: aClass ^self on: BrowserEnvironment new referencesToInstanceVariable: aString in: aClass
writersOfInstanceVariable: aString in: aClass ^self on: BrowserEnvironment new writersOfInstanceVariable: aString in: aClass
</methods> <methods> Refactory.Browser.ProtocolEnvironment <category>initialize-release</category>
class: aClass protocols: aCollection class := aClass. protocols := aCollection
</methods> <methods> Refactory.Browser.ProtocolEnvironment <category>private</category>
defaultLabel | stream | stream := String new writeStream. stream nextPutAll: class fullName; nextPut: $>. protocols do: [:each | stream nextPutAll: each; nextPut: $ ]. ^stream contents
</methods> <methods> Refactory.Browser.ProtocolEnvironment <category>testing</category>
includesBinding: aBinding in: aNameSpace ^(super includesBinding: aBinding in: aNameSpace) and: [(aBinding isForClass and: [(self includesClass: aBinding value) or: [self includesClass: aBinding value class]]) or: [aNameSpace = class and: [aBinding isForGeneral and: [protocols includes: aBinding category]]]]
includesClass: aClass ^aClass == class and: [super includesClass: aClass]
includesNameSpace: aNameSpace ^false
includesProtocol: aProtocol in: aClass ^aClass == class and: [(super includesProtocol: aProtocol in: aClass) and: [protocols includes: aProtocol]]
includesSelector: aSelector in: aClass ^(super includesSelector: aSelector in: aClass) and: [protocols includes: (environment whichProtocolIncludes: aSelector in: aClass)]
isEmpty ^protocols isEmpty
</methods> <methods> Refactory.Browser.ProtocolEnvironment <category>copying</category>
postCopy protocols := protocols copy. ^super postCopy
</methods> <methods> Refactory.Browser.ProtocolEnvironment <category>printing</category>
storeOn: aStream aStream nextPut: $(. super storeOn: aStream. aStream nextPutAll: ' class: '; nextPutAll: class fullRootName; nextPutAll: ' protocols: '. protocols asArray storeOn: aStream. aStream nextPut: $)
</methods> <methods> Refactory.Browser.ProtocolEnvironment class <category>instance creation</category>
onEnvironment: anEnvironment class: aClass protocols: aCollection ^(self onEnvironment: anEnvironment) class: aClass protocols: aCollection; yourself
</methods> <methods> Refactory.Browser.AndEnvironment <category>private</category>
andedEnvironment ^andedEnvironment
</methods> <methods> Refactory.Browser.AndEnvironment <category>initialize-release</category>
andedEnvironment: aBrowserEnvironment andedEnvironment := aBrowserEnvironment
</methods> <methods> Refactory.Browser.AndEnvironment <category>accessing</category>
classesDo: aBlock environment classesDo: [:each | (self includesClass: each) ifTrue: [aBlock value: each]]
numberSelectors | total | total := 0. environment classesAndSelectorsDo: [:each :sel | (andedEnvironment includesSelector: sel in: each) ifTrue: [total := total + 1]]. ^total
selectorsForClass: aClass do: aBlock environment selectorsForClass: aClass do: [:each | (andedEnvironment includesSelector: each in: aClass) ifTrue: [aBlock value: each]]
</methods> <methods> Refactory.Browser.AndEnvironment <category>testing</category>
includesBinding: aBinding in: aNameSpace ^aBinding isForClass ifTrue: [(self includesClass: aBinding value) or: [self includesClass: aBinding value class]] ifFalse: [(super includesBinding: aBinding in: aNameSpace) and: [andedEnvironment includesBinding: aBinding in: aNameSpace]]
includesClass: aClass | doesntHaveSelectors | (environment includesClass: aClass) ifFalse: [^false]. (andedEnvironment includesClass: aClass) ifFalse: [^false]. doesntHaveSelectors := true. environment selectorsForClass: aClass do: [:each | doesntHaveSelectors := false. (andedEnvironment includesSelector: each in: aClass) ifTrue: [^true]]. ^doesntHaveSelectors
includesNameSpace: aNameSpace ^(super includesNameSpace: aNameSpace) and: [andedEnvironment includesNameSpace: aNameSpace]
includesProtocol: aProtocol in: aClass ^(self selectorsFor: aProtocol in: aClass) notEmpty
includesSelector: aSelector in: aClass ^(environment includesSelector: aSelector in: aClass) and: [andedEnvironment includesSelector: aSelector in: aClass]
</methods> <methods> Refactory.Browser.AndEnvironment <category>printing</category>
storeOn: aStream aStream nextPut: $(. environment storeOn: aStream. aStream nextPutAll: ' & '. andedEnvironment storeOn: aStream. aStream nextPut: $)
</methods> <methods> Refactory.Browser.AndEnvironment class <category>instance creation</category>
onEnvironment: anEnvironment and: anotherEnvironment ^(self onEnvironment: anEnvironment) andedEnvironment: anotherEnvironment; yourself
</methods> <methods> Refactory.Browser.SelectorEnvironment <category>initialize-release</category>
classes: classArray metaClasses: metaArray "Used to recreate an environment from its storeString" classSelectors := Dictionary new. metaClassSelectors := Dictionary new. classArray do: [:each | classSelectors at: each first put: each last asSet]. metaArray do: [:each | metaClassSelectors at: each first put: each last asSet]
classSelectors: classSelectorDictionary metaClassSelectors: metaClassSelectorDictionary classSelectors := classSelectorDictionary. metaClassSelectors := metaClassSelectorDictionary
initialize super initialize. classSelectors := Dictionary new. metaClassSelectors := Dictionary new. initializers := Set new.
initializers: initializerCollection initializers := initializerCollection
on: aDict aDict keysAndValuesDo: [:class :selectors | class isMeta ifTrue: [metaClassSelectors at: class soleInstance fullRootName put: selectors] ifFalse: [classSelectors at: class fullRootName put: (selectors select: [:each | each isSymbol])]]
</methods> <methods> Refactory.Browser.SelectorEnvironment <category>accessing-classes</category>
classesDo: aBlock classSelectors keysDo: [:each | | class | class := each asQualifiedReference valueOrDo: [nil]. class notNil ifTrue: [(self includesClass: class) ifTrue: [aBlock value: class]]]. metaClassSelectors keysDo: [:each | | class | class := each asQualifiedReference valueOrDo: [nil]. class notNil ifTrue: [(self includesClass: class class) ifTrue: [aBlock value: class class]]]
classNames | names | names := Set new: classSelectors size + metaClassSelectors size. names addAll: classSelectors keys; addAll: metaClassSelectors keys. initializers do: [:each | | env | env := each environment. env isBehavior ifTrue: [names add: each environment fullRootName]]. ^names asOrderedCollection
nameSpaceObjectNames | names | names := Set new. self classesDo: [:each | names add: each instanceBehavior fullRootName]. initializers do: [:each | names add: each environment fullRootName]. ^names
</methods> <methods> Refactory.Browser.SelectorEnvironment <category>private</category>
defaultLabel ^''
privateIncludesSelector: aSelector inClass: aClass ^(self privateSelectorsForClass: aClass) includes: aSelector
privateSelectorsForClass: aClass ^aClass isMeta ifTrue: [metaClassSelectors at: aClass soleInstance fullRootName ifAbsent: [#()]] ifFalse: [classSelectors at: aClass fullRootName ifAbsent: [#()]]
</methods> <methods> Refactory.Browser.SelectorEnvironment <category>testing</category>
hasInitializerForClass: aClass ^initializers anySatisfy: [:each | each environment = aClass]
includesBinding: aBinding in: aNameSpace (super includesBinding: aBinding in: aNameSpace) ifFalse: [^false]. aBinding isForClass ifTrue: [^(self includesClass: aBinding value) or: [self includesClass: aBinding value class]]. ^initializers anySatisfy: [:ref | ref binding = aBinding]
includesClass: aClass ^((self privateSelectorsForClass: aClass) notEmpty or: [self hasInitializerForClass: aClass]) and: [super includesClass: aClass]
includesNameSpace: aNameSpace ^initializers anySatisfy: [:each | each environment = aNameSpace]
includesProtocol: aProtocol in: aClass ^(super includesProtocol: aProtocol in: aClass) and: [(environment selectorsFor: aProtocol in: aClass) anySatisfy: [:aSelector | self privateIncludesSelector: aSelector inClass: aClass]]
includesSelector: aSelector in: aClass ^(environment includesSelector: aSelector in: aClass) and: [self privateIncludesSelector: aSelector inClass: aClass]
isEmpty ^classSelectors isEmpty and: [metaClassSelectors isEmpty and: [initializers isEmpty]]
isSelector ^true
</methods> <methods> Refactory.Browser.SelectorEnvironment <category>accessing</category>
numberSelectors "This doesn't compute the correct result when a method that is included in our method list is not in the environment we are wrapping. It is implemented this way for efficiency." ^(classSelectors inject: 0 into: [:sum :each | sum + each size]) + (metaClassSelectors inject: 0 into: [:sum :each | sum + each size]) "+ initializers size"
selectorsForClass: aClass do: aBlock ^(self privateSelectorsForClass: aClass) do: [:each | (aClass includesSelector: each) ifTrue: [aBlock value: each]]
sharedVariableReferencesDo: aBlock initializers do: aBlock
</methods> <methods> Refactory.Browser.SelectorEnvironment <category>copying</category>
postCopy | newDict | newDict := classSelectors copy. newDict keysAndValuesDo: [:key :value | newDict at: key put: value copy]. classSelectors := newDict. newDict := metaClassSelectors copy. newDict keysAndValuesDo: [:key :value | newDict at: key put: value copy]. metaClassSelectors := newDict. initializers := initializers copy. ^super postCopy
</methods> <methods> Refactory.Browser.SelectorEnvironment <category>removing</category>
removeClass: aClass aClass isMeta ifTrue: [metaClassSelectors removeKey: aClass soleInstance fullRootName ifAbsent: []] ifFalse: [classSelectors removeKey: aClass fullRootName ifAbsent: []]
removeClass: aClass selector: aSelector (aClass isMeta ifTrue: [metaClassSelectors at: aClass soleInstance fullRootName ifAbsent: [^self]] ifFalse: [classSelectors at: aClass fullRootName ifAbsent: [^self]]) remove: aSelector ifAbsent: []
removeInitializer: aQualifiedReference initializers remove: aQualifiedReference ifAbsent: []
</methods> <methods> Refactory.Browser.SelectorEnvironment <category>adding</category>
addClass: aClass aClass isMeta ifTrue: [metaClassSelectors at: aClass soleInstance fullRootName put: aClass selectors] ifFalse: [classSelectors at: aClass fullRootName put: aClass selectors]
addClass: aClass selector: aSymbol (aClass isMeta ifTrue: [metaClassSelectors at: aClass soleInstance fullRootName ifAbsentPut: [Set new]] ifFalse: [classSelectors at: aClass fullRootName ifAbsentPut: [Set new]]) add: aSymbol
addDefinition: aGeneralMethodDefinition aGeneralMethodDefinition isForSharedVariable ifTrue: [self addInitializer: aGeneralMethodDefinition fullName asQualifiedReference] ifFalse: [self addClass: aGeneralMethodDefinition implementingClass selector: aGeneralMethodDefinition selector]
addInitializer: aQualifiedReference initializers add: aQualifiedReference
</methods> <methods> Refactory.Browser.SelectorEnvironment <category>printing</category>
storeOn: aStream | classBlock | aStream nextPutAll: '(('; nextPutAll: self class fullRootName; nextPutAll: ' onEnvironment: '. environment storeOn: aStream. aStream nextPut: $); nextPutAll: ' classes: #('. classBlock := [:key :value | aStream nextPutAll: '#('; store: key; nextPutAll: ' #('. value do: [:each | aStream store: each; nextPut: $ ]. aStream nextPutAll: '))'; cr]. classSelectors keysAndValuesDo: classBlock. aStream nextPutAll: ') metaClasses: #('. metaClassSelectors keysAndValuesDo: classBlock. aStream nextPutAll: '))'
</methods> <methods> Refactory.Browser.SelectorEnvironment class <category>instance creation</category>
implementorsMatching: aString in: anEnvironment | classDict metaDict | classDict := Dictionary new. metaDict := Dictionary new. anEnvironment classesDo: [:class | | selectors | selectors := Set new. anEnvironment selectorsForClass: class do: [:each | (aString match: each) ifTrue: [selectors add: each]]. selectors notEmpty ifTrue: [class isMeta ifTrue: [metaDict at: class soleInstance fullRootName put: selectors] ifFalse: [classDict at: class fullRootName put: selectors]]]. ^(self onEnvironment: anEnvironment) classSelectors: classDict metaClassSelectors: metaDict; label: ((#ImplementorsOf1s << #browser >> 'Implementors of <1s>') expandMacrosWith: aString); yourself
implementorsOf: aSelector in: anEnvironment | classDict metaDict selectors | classDict := Dictionary new. metaDict := Dictionary new. selectors := Set with: aSelector. anEnvironment classesDo: [:class | ((class includesSelector: aSelector) and: [anEnvironment includesSelector: aSelector in: class]) ifTrue: [class isMeta ifTrue: [metaDict at: class soleInstance fullRootName put: selectors copy] ifFalse: [classDict at: class fullRootName put: selectors copy]]]. ^(self onEnvironment: anEnvironment) classSelectors: classDict metaClassSelectors: metaDict; label: ((#ImplementorsOf1s << #browser >> 'Implementors of <1s>') expandMacrosWith: aSelector); yourself
matches: aString in: anEnvironment | newEnvironment | newEnvironment := (self onEnvironment: anEnvironment) label: ((#Matching1s << #browser >> 'Matching: <1s>') expandMacrosWith: aString); searchStrings: (Array with: aString); yourself. anEnvironment classesAndSelectorsDo: [:each :sel | | method | method := each compiledMethodAt: sel. method allLiterals do: [:lit | (self checkLiteral: lit matches: aString) ifTrue: [newEnvironment addClass: each selector: sel]]]. ^newEnvironment
onMethods: aMethodDefinitionCollection "We have to perserve the extra text in the original method definitions, so we defer to some specialized subclass." ^MethodDefinitionEnvironment onMethods: aMethodDefinitionCollection
onMethods: selectorCollection forClass: aClass in: anEnvironment | env | env := self onEnvironment: anEnvironment. selectorCollection do: [:each | env addClass: aClass selector: each]. ^env
referencesTo: aLiteral in: anEnvironment | classDict literalPrintString specialIndex variables | literalPrintString := aLiteral isVariableBinding ifTrue: [aLiteral key asString] ifFalse: [aLiteral isString ifTrue: [aLiteral] ifFalse: [aLiteral printString]]. specialIndex := CompiledCode specialSelectorIndexFor: aLiteral. classDict := Dictionary new. anEnvironment classesDo: [:class | | selectors | selectors := (class whichSelectorsReferTo: aLiteral) select: [:aSelector | anEnvironment includesSelector: aSelector in: class]. selectors notEmpty ifTrue: [classDict at: class put: selectors]]. variables := OrderedCollection new. anEnvironment sharedVariableReferencesDo: [:each | | binding init method | binding := each bindingOrNil. binding notNil ifTrue: [init := binding initializer. init notNil ifTrue: [method := init method. ((method refersToLiteral: aLiteral) or: [(specialIndex > 0 and: [method sendsSpecialSelector: specialIndex]) or: [method refersToSpecialLiteral: aLiteral]]) ifTrue: [variables add: each]]]]. ^(self onEnvironment: anEnvironment) on: classDict; initializers: variables; label: ((#ReferencesTo1s << #browser >> 'References to: <1s>') expandMacrosWith: literalPrintString); searchStrings: (Array with: literalPrintString); yourself
</methods> <methods> Refactory.Browser.SelectorEnvironment class <category>private</category>
checkLiteral: aLiteral matches: aString aLiteral class = Array ifTrue: [^aLiteral anySatisfy: [:each | self checkLiteral: each matches: aString]]. ^aLiteral isString and: [aString match: aLiteral]
</methods> <methods> Refactory.Browser.ClassEnvironment <category>initialize-release</category>
classes: aCollection aCollection do: [:each | self addClass: each]
initialize super initialize. classes := Set new. metaClasses := Set new
</methods> <methods> Refactory.Browser.ClassEnvironment <category>testing</category>
includesBinding: aBinding in: aNameSpace ^(super includesBinding: aBinding in: aNameSpace) and: [aBinding isForClass and: [(self includesClass: aBinding value) or: [self includesClass: aBinding value class]]]
includesClass: aClass ^(aClass isMeta ifTrue: [metaClasses includes: aClass soleInstance fullRootName] ifFalse: [classes includes: aClass fullRootName]) and: [super includesClass: aClass]
includesNameSpace: aNameSpace ^false
isClassEnvironment ^true
isEmpty ^classes isEmpty and: [metaClasses isEmpty]
</methods> <methods> Refactory.Browser.ClassEnvironment <category>copying</category>
postCopy classes := classes copy. metaClasses := metaClasses copy. ^super postCopy
</methods> <methods> Refactory.Browser.ClassEnvironment <category>private</category>
defaultLabel | stream | stream := String new writeStream. classes do: [:each | stream nextPutAll: each; nextPut: $ ]. ^stream contents
</methods> <methods> Refactory.Browser.ClassEnvironment <category>accessing-classes</category>
classesDo: aBlock classes do: [:each | | class | class := each asQualifiedReference value. (class notNil and: [environment includesClass: class]) ifTrue: [aBlock value: class]]. metaClasses do: [:each | | class | class := each asQualifiedReference value. (class notNil and: [environment includesClass: class class]) ifTrue: [aBlock value: class class]]
classNames ^(Set withAll: classes) addAll: metaClasses; yourself
</methods> <methods> Refactory.Browser.ClassEnvironment <category>printing</category>
storeOn: aStream aStream nextPut: $(. super storeOn: aStream. aStream nextPutAll: ' classes: (('. classes asArray storeOn: aStream. aStream nextPutAll: ' inject: OrderedCollection new into: [:sum :each | | class | class := (BindingReference pathString: each) valueOrDo: [nil]. class notNil ifTrue: [sum add: class]. sum]) , ('. metaClasses asArray storeOn: aStream. aStream nextPutAll: ' inject: OrderedCollection new into: [:sum :each | | class | class := (BindingReference pathString: each) valueOrDo: [nil]. class notNil ifTrue: [sum add: class class]. sum])))'
</methods> <methods> Refactory.Browser.ClassEnvironment <category>adding</category>
addClass: aClass aClass isMeta ifTrue: [metaClasses add: aClass soleInstance fullRootName] ifFalse: [classes add: aClass fullRootName]
</methods> <methods> Refactory.Browser.ClassEnvironment <category>removing</category>
removeClass: aClass aClass isMeta ifTrue: [metaClasses remove: aClass soleInstance fullRootName ifAbsent: []] ifFalse: [classes remove: aClass fullRootName ifAbsent: []]
</methods> <methods> Refactory.Browser.ClassEnvironment class <category>instance creation</category>
onEnvironment: anEnvironment classes: aCollection ^(self onEnvironment: anEnvironment) classes: aCollection; yourself
</methods> <methods> Refactory.Browser.UnparceledParcel <category>comparing</category>
= anObject ^self class = anObject class
hash ^self class hash
</methods> <methods> Refactory.Browser.UnparceledParcel <category>no-op changes</category>
addBinding: aBinding in: aNameSpace
addClass: aClass
addEntiretyOfClass: aClass "do nothing"
addName: aSymbol in: aNameSpace
addNameSpace: aNameSpace
addSelector: aSymbol forClass: aClass "Do nothing since we aren't really a parcel"
addSelectors: aCollection forClass: aClass
comment: aString
removeBinding: aBinding in: aNameSpace
removeEntiretyOfClass: aClass "do nothing"
removeName: aSymbol in: aNameSpace
removeNameSpace: aNameSpace
removeSelectors: aCollection forClass: aClass
</methods> <methods> Refactory.Browser.UnparceledParcel <category>querying</category>
allClassesAndNameSpaces | unparceled | unparceled := Set new. BrowserEnvironment new classesDo: [:each | (self class isUnparceled: each) ifTrue: [unparceled add: each instanceBehavior]]. Root withAllNameSpacesDo: [:each | (self class isNameSpaceUnparceled: each) ifTrue: [unparceled add: each]]. ^unparceled
allSharedReferencesDo: aBlock Root withAllNameSpacesDo: [:ns | ns bindingsDo: [:each | each isForGeneral ifTrue: [aBlock value: (ns fullyQualifiedReferenceOf: each key)]]]
definedBindingsFor: aClass | bindings | bindings := OrderedCollection new. aClass asNameSpace bindingsDo: [:each | | parcels | parcels := Parcel parcelsForBinding: each. (parcels isNil or: [parcels isEmpty]) ifTrue: [bindings add: each]]. ^bindings
definedClasses | unparceled | unparceled := Set new. BrowserEnvironment new classesDo: [:each | (Parcel isClassDefinedInParcel: each) ifFalse: [unparceled add: each instanceBehavior]]. ^unparceled
definedNameSpaces ^Root withAllNameSpaces select: [:each | (Parcel parcelsDefiningNameSpace: each) isEmpty]
definedSelectorsFor: aClass ^aClass selectors select: [:each | self definesSelector: each forClass: aClass]
definedStaticReferences | refs | refs := Set new. self allSharedReferencesDo: [:each | | parcels | parcels := Parcel parcelsForBinding: each binding. (parcels isNil or: [parcels isEmpty]) ifTrue: [refs add: each]]. ^refs
definesClass: aClass ^(Parcel parcelsDefiningClass: aClass) isEmpty
definesClassOrNameSpace: aClassOrNameSpace ^(aClassOrNameSpace isBehavior ifTrue: [Parcel parcelsDefiningClass: aClassOrNameSpace] ifFalse: [Parcel parcelsDefiningNameSpace: aClassOrNameSpace]) isEmpty
definesName: aSymbol in: aNameSpace | binding parcels | binding := aNameSpace asNameSpace bindingFor: aSymbol. binding isNil ifTrue: [^false]. parcels := Parcel parcelsForBinding: binding. ^parcels isNil or: [parcels isEmpty]
definesObject: aNameSpace | parcels | parcels := Parcel parcelsForClassOrNameSpace: aNameSpace. ^parcels isNil or: [parcels isEmpty]
definesOrExtendsClass: aClass ^self class isUnparceled: aClass
definesSelector: aSelector forClass: aClass ^(Parcel parcelsDefiningSelector: aSelector inClass: aClass) isEmpty
extendedClasses | unparceled | unparceled := Set new. BrowserEnvironment new classesAndSelectorsDo: [:class :sel | (Parcel isSelector: sel parceledInClass: class) ifFalse: [unparceled add: class instanceBehavior]]. ^unparceled
isPackage ^false
isParcel ^true
</methods> <methods> Refactory.Browser.UnparceledParcel <category>printing</category>
displayString ^self name
printOn: aStream aStream nextPutAll: self name
</methods> <methods> Refactory.Browser.UnparceledParcel <category>accessing</category>
comment ^(#UnparceledParcelComment << #browser >> 'This "parcel" holds all classes/methods/name spaces/shared variables that are not in a parcel. It is not a normal parcel, but is dynamically calculated.') asString
environment "This is the compilation environment, not to be confused with RB browser environments." ^nil
name ^self class unparceledParcelName
toolListIcon ^nil
versionString ^''
</methods> <methods> Refactory.Browser.UnparceledParcel <category>testing</category>
isUnparceledParcel ^true
</methods> <methods> Refactory.Browser.UnparceledParcel class <category>testing</category>
isBindingUnparceled: aBinding ^(Parcel isBindingDefinedInParcel: aBinding) not
isNameSpaceUnparceled: aNameSpace | parcels | parcels := Parcel parcelsForClassOrNameSpace: aNameSpace. (parcels isNil or: [parcels isEmpty]) ifTrue: [^true]. aNameSpace bindingsDo: [:each | (each isForGeneral and: [(parcels := Parcel parcelsForBinding: each) isNil or: [parcels isEmpty]]) ifTrue: [^true]]. ^false
isUnparceled: aClass ^(Parcel isClassDefinedInParcel: aClass) not or: [(aClass selectors anySatisfy: [:each | (Parcel isSelector: each parceledInClass: aClass) not]) or: [aClass asNameSpace localBindings anySatisfy: [:each | (Parcel isBindingDefinedInParcel: each) not]]]
</methods> <methods> Refactory.Browser.UnparceledParcel class <category>accessing</category>
unparceledParcelName ^'***Unparceled***'
</methods> <methods> Refactory.Browser.MethodDefinitionEnvironment <category>accessing</category>
methodDefinitions definitions removeAllSuchThat: [:each | each isForSharedVariable ifTrue: [each binding isNil] ifFalse: [each hasMethod not]]. ^definitions
</methods> <methods> Refactory.Browser.MethodDefinitionEnvironment <category>initialize-release</category>
definitions: aMethodDefinitionCollection definitions := aMethodDefinitionCollection asOrderedCollection
initialize definitions := OrderedCollection new. super initialize
</methods> <methods> Refactory.Browser.MethodDefinitionEnvironment <category>removing</category>
removeClass: aClass definitions removeAllSuchThat: [:each | each classOrNameSpace = aClass]. super removeClass: aClass
removeClass: aClass selector: aSelector definitions removeAllSuchThat: [:each | each classOrNameSpace = aClass and: [each selector = aSelector]]. super removeClass: aClass selector: aSelector
removeInitializer: aQualifiedReference definitions removeAllSuchThat: [:each | each isForSharedVariable and: [each classOrNameSpace = aQualifiedReference environment and: [each variableName = aQualifiedReference simpleName]]]. super removeInitializer: aQualifiedReference
</methods> <methods> Refactory.Browser.MethodDefinitionEnvironment <category>copying</category>
postCopy definitions := definitions copy. ^super postCopy
</methods> <methods> Refactory.Browser.MethodDefinitionEnvironment <category>adding</category>
addClass: aClass aClass selectors do: [:each | self addClass: aClass selector: each]. aClass asNameSpace bindingsDo: [:each | self addInitializer: (aClass asQualifiedReference append: each key)]
addClass: aClass selector: aSymbol definitions add: (MethodDefinition class: aClass selector: aSymbol). super addClass: aClass selector: aSymbol
addDefinition: aGeneralMethodDefinition aGeneralMethodDefinition isForSharedVariable ifTrue: [super addInitializer: aGeneralMethodDefinition fullName asQualifiedReference] ifFalse: [super addClass: aGeneralMethodDefinition implementingClass selector: aGeneralMethodDefinition selector]. definitions add: aGeneralMethodDefinition
addInitializer: aQualifiedReference definitions add: (RBInitializerDefinition nameSpace: aQualifiedReference environment key: aQualifiedReference simpleName). super addInitializer: aQualifiedReference
</methods> <methods> Refactory.Browser.MethodDefinitionEnvironment class <category>instance creation</category>
onMethods: aMethodDefinitionCollection | env | env := self new. aMethodDefinitionCollection do: [:each | each isBindingReference ifTrue: [env addInitializer: each] ifFalse: [env addDefinition: each]]. ^env
</methods> <methods> Refactory.Browser.ParcelEnvironment <category>private</category>
defaultLabel | stream | stream := String new writeStream. parcelNames do: [:each | stream nextPutAll: each] separatedBy: [stream nextPut: $ ]. ^stream contents
</methods> <methods> Refactory.Browser.ParcelEnvironment <category>testing</category>
definesClass: aBehavior ^self parcels anySatisfy: [:each | each definesClass: aBehavior]
includesBinding: aBinding in: aNameSpace (super includesBinding: aBinding in: aNameSpace) ifFalse: [^false]. ^aBinding isForClass ifTrue: [self parcels anySatisfy: [:each | (each definesOrExtendsClass: aBinding value) or: [each definesOrExtendsClass: aBinding value class]]] ifFalse: [aBinding isForNameSpace ifTrue: [self parcels anySatisfy: [:each | each definesObject: aBinding value]] ifFalse: [aNameSpace notNil and: [self parcels anySatisfy: [:each | each definesName: aBinding key in: aNameSpace]]]]
includesClass: aClass (super includesClass: aClass) ifFalse: [^false]. ^self parcels anySatisfy: [:each | each definesOrExtendsClass: aClass]
includesNameSpace: aNameSpace ^self parcels anySatisfy: [:each | each definesClassOrNameSpace: aNameSpace]
includesProtocol: aProtocol in: aClass ^(super includesProtocol: aProtocol in: aClass) and: [(environment selectorsFor: aProtocol in: aClass) anySatisfy: [:aSelector | self includesSelector: aSelector in: aClass]]
includesSelector: aSelector in: aClass ^(environment includesSelector: aSelector in: aClass) and: [self parcels anySatisfy: [:each | each definesSelector: aSelector forClass: aClass]]
isClassContainer ^true
</methods> <methods> Refactory.Browser.ParcelEnvironment <category>initialize-release</category>
parcelNames: aCollection parcelNames := aCollection
parcels: aCollection parcelNames := aCollection collect: [:each | each name]
</methods> <methods> Refactory.Browser.ParcelEnvironment <category>accessing</category>
parcels | parcels | parcels := OrderedCollection new: parcelNames size. parcelNames do: [:each | | parcel | parcel := each = UnparceledParcel unparceledParcelName ifTrue: [UnparceledParcel new] ifFalse: [Parcel parcelNamed: each]. parcel notNil ifTrue: [parcels add: parcel]]. ^parcels
</methods> <methods> Refactory.Browser.ParcelEnvironment <category>copying</category>
postCopy super postCopy. parcelNames := parcelNames copy
</methods> <methods> Refactory.Browser.ParcelEnvironment <category>printing</category>
storeOn: aStream aStream nextPut: $(. super storeOn: aStream. aStream nextPutAll: ' parcelNames: '. parcelNames asArray storeOn: aStream. aStream nextPut: $)
</methods> <methods> Refactory.Browser.ParcelEnvironment class <category>instance creation</category>
onEnvironment: anEnvironment parcelNames: aCollection ^(self onEnvironment: anEnvironment) parcelNames: aCollection; yourself
onEnvironment: anEnvironment parcels: parcelCollection ^(self onEnvironment: anEnvironment) parcels: parcelCollection; yourself
</methods> <methods> Kernel.NameSpaceOrganizer <category>categories</category>
classCategories | all | all := Set withAll: emptyCategories. self environment bindingsDo: [:i | i isForGeneral ifFalse: [all add: i category]]. ^all
sharedVariableCategories | all | all := Set withAll: emptyCategories. self environment bindingsDo: [:i | i isForGeneral ifTrue: [all add: i category]]. ^all
</methods> <methods> Kernel.NameSpace <category>RefactoringBrowser</category>
fullRootName | stream | self environment isNil ifTrue: [^self name]. stream := WriteStream on: (String new: 64). self fullRootNameInto: stream. ^stream contents
fullRootNameInto: aStream self environment notNil ifTrue: [self environment fullRootNameInto: aStream. aStream nextPut: $.]. aStream nextPutAll: self name
</methods> <methods> Core.Behavior <category>RefactoringBrowser</category>
fullRootName | stream | stream := WriteStream on: (String new: 64). self fullRootNameInto: stream. ^stream contents
fullRootNameInto: aStream self environment fullRootNameInto: aStream. aStream nextPut: $.. aStream nextPutAll: self name
</methods> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>Object</name> <environment>Core</environment> <super></super> <private>false</private> none <imports></imports> <category>Kernel-Objects</category> <attributes> <package>Kernel-Objects</package> </attributes> </class> <class> <name>Behavior</name> <environment>Core</environment> <super>Core.Object</super> <private>false</private> none superclass methodDict format subclasses <imports></imports> <category>Kernel-Classes</category> <attributes> <package>Kernel-Classes</package> </attributes> </class> <class> <name>NameSpace</name> <environment>Kernel</environment> <super>Kernel.GeneralNameSpace</super> <private>false</private> none parent name <imports></imports> <category>System-Name Spaces</category> <attributes> <package>System-Name Spaces</package> </attributes> </class> <class> <name>NameSpaceOrganizer</name> <environment>Kernel</environment> <super>Core.Object</super> <private>false</private> none comment environment emptyCategories <imports></imports> <category>System-Name Spaces</category> <attributes> <package>System-Name Spaces</package> </attributes> </class>