123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390 |
- Smalltalk current createPackage: 'Helios-References'!
- Object subclass: #HLMethodReference
- instanceVariableNames: 'selector methodClass'
- package: 'Helios-References'!
- !HLMethodReference methodsFor: 'accessing'!
- method
- ^ self methodClass methodAt: self selector
- !
- methodClass
- ^ methodClass
- !
- methodClass: aClass
- methodClass := aClass
- !
- selector
- ^ selector
- !
- selector: aString
- selector := aString
- !
- source
- ^ self method source
- ! !
- !HLMethodReference methodsFor: 'initialization'!
- initializeFromMethod: aCompiledMethod
- self
- selector: aCompiledMethod selector;
- methodClass: aCompiledMethod methodClass
- ! !
- !HLMethodReference class methodsFor: 'instance creation'!
- on: aCompiledMethod
- ^ self new
- initializeFromMethod: aCompiledMethod;
- yourself
- ! !
- HLWidget subclass: #HLReferences
- instanceVariableNames: 'model sendersListWidget implementorsListWidget classReferencesListWidget regexpListWidget sourceCodeWidget'
- package: 'Helios-References'!
- !HLReferences methodsFor: 'accessing'!
- classReferencesListWidget
- ^ classReferencesListWidget ifNil: [
- classReferencesListWidget := HLClassReferencesListWidget on: self model.
- classReferencesListWidget next: self regexpListWidget ]
- !
- implementorsListWidget
- ^ implementorsListWidget ifNil: [
- implementorsListWidget := HLImplementorsListWidget on: self model.
- implementorsListWidget next: self classReferencesListWidget ]
- !
- model
- ^ model ifNil: [
- model := (HLReferencesModel new
- environment: self manager environment;
- yourself) ]
- !
- model: aModel
- model := aModel
- !
- regexpListWidget
- ^ regexpListWidget ifNil: [
- regexpListWidget := HLRegexpListWidget on: self model.
- regexpListWidget next: self sourceCodeWidget ]
- !
- sendersListWidget
- ^ sendersListWidget ifNil: [
- sendersListWidget := HLSendersListWidget on: self model.
- sendersListWidget next: self implementorsListWidget ]
- !
- sourceCodeWidget
- ^ sourceCodeWidget ifNil: [
- sourceCodeWidget := HLBrowserCodeWidget new
- browserModel: self model;
- yourself ]
- ! !
- !HLReferences methodsFor: 'actions'!
- open
- HLManager current addTab: (HLTab on: self labelled: self class tabLabel)
- !
- registerBindingsOn: aBindingGroup
- HLToolCommand
- registerConcreteClassesOn: aBindingGroup
- for: self model
- !
- search: aString
- self model search: aString
- ! !
- !HLReferences methodsFor: 'rendering'!
- renderContentOn: html
- html with: (HLContainer with: (HLHorizontalSplitter
- with: (HLVerticalSplitter
- with: (HLVerticalSplitter
- with: self sendersListWidget
- with: self implementorsListWidget)
- with: (HLVerticalSplitter
- with: self classReferencesListWidget
- with: self regexpListWidget))
- with: self sourceCodeWidget)).
-
- self sendersListWidget focus
- ! !
- !HLReferences class methodsFor: 'accessing'!
- tabClass
- ^ 'references'
- !
- tabLabel
- ^ 'References'
- !
- tabPriority
- ^ 100
- ! !
- !HLReferences class methodsFor: 'testing'!
- canBeOpenAsTab
- ^ false
- ! !
- HLToolListWidget subclass: #HLReferencesListWidget
- instanceVariableNames: ''
- package: 'Helios-References'!
- !HLReferencesListWidget methodsFor: 'accessing'!
- commandCategory
- ^ 'Methods'
- !
- label
- ^ 'List'
- ! !
- !HLReferencesListWidget methodsFor: 'actions'!
- activateListItem: anItem
- self model withChangesDo: [ super activateListItem: anItem ]
- !
- observeModel
- self model announcer
- on: HLSearchReferences
- do: [ :ann | self onSearchReferences: ann searchString ];
- on: HLMethodSelected
- do: [ :ann | self onMethodSelected: ann item ]
- !
- selectItem: aMethod
- self model selectedMethod: aMethod
- ! !
- !HLReferencesListWidget methodsFor: 'reactions'!
- onMethodSelected: aMethod
- aMethod ifNil: [ ^ self ].
- self items detect: [ :each | each = aMethod selector ] ifNone: [ ^ self ].
-
- self
- selectedItem: aMethod selector;
- activateItem: aMethod selector
- !
- onSearchReferences: aString
- self subclassResponsibility
- ! !
- !HLReferencesListWidget methodsFor: 'rendering'!
- renderItemLabel: aMethod on: html
- html with: aMethod methodClass name, ' >> #', aMethod selector
- ! !
- !HLReferencesListWidget class methodsFor: 'instance creation'!
- on: aModel
- ^ self new
- model: aModel;
- yourself
- ! !
- HLReferencesListWidget subclass: #HLClassReferencesListWidget
- instanceVariableNames: ''
- package: 'Helios-References'!
- !HLClassReferencesListWidget methodsFor: 'accessing'!
- label
- ^ 'Class references'
- ! !
- !HLClassReferencesListWidget methodsFor: 'reactions'!
- onSearchReferences: aString
- self selectItem: nil.
- self items: (self model classReferencesOf: aString).
- self refresh
- ! !
- HLReferencesListWidget subclass: #HLImplementorsListWidget
- instanceVariableNames: ''
- package: 'Helios-References'!
- !HLImplementorsListWidget methodsFor: 'accessing'!
- label
- ^ 'Implementors'
- ! !
- !HLImplementorsListWidget methodsFor: 'reactions'!
- onSearchReferences: aString
- self selectItem: nil.
- self items: (self model implementorsOf: aString).
- self refresh
- ! !
- HLReferencesListWidget subclass: #HLRegexpListWidget
- instanceVariableNames: ''
- package: 'Helios-References'!
- !HLRegexpListWidget methodsFor: 'accessing'!
- label
- ^ 'Source search'
- ! !
- !HLRegexpListWidget methodsFor: 'reactions'!
- onSearchReferences: aString
- self selectItem: nil.
- self items: (self model regexpReferencesOf: aString).
- self refresh
- ! !
- HLReferencesListWidget subclass: #HLSendersListWidget
- instanceVariableNames: ''
- package: 'Helios-References'!
- !HLSendersListWidget methodsFor: 'accessing'!
- label
- ^ 'Senders'
- ! !
- !HLSendersListWidget methodsFor: 'reactions'!
- onSearchReferences: aString
- self selectItem: nil.
- self items: (self model sendersOf: aString).
- self refresh
- ! !
- HLToolModel subclass: #HLReferencesModel
- instanceVariableNames: 'methodsCache classesAndMetaclassesCache'
- package: 'Helios-References'!
- !HLReferencesModel methodsFor: 'accessing'!
- allMethods
- ^ self methodsCache
- !
- allSelectors
- ^ (self allMethods
- collect: [ :each | each selector ])
- asSet
- !
- classReferencesOf: aString
- "Answer all methods referencing the class named aString"
-
- | references |
-
- references := OrderedCollection new.
-
- self classesAndMetaclasses do: [ :each |
- each methodDictionary values do: [ :method |
- (method referencedClasses includes: aString) ifTrue: [
- references add: method ] ] ].
-
- ^ references
- !
- classesAndMetaclasses
- ^ self classesAndMetaclassesCache
- !
- implementorsOf: aString
- ^ (self allMethods select: [ :each |
- each selector = aString ])
- collect: [ :each | self methodReferenceOn: each ]
- !
- methodReferenceOn: aCompiledMethod
- ^ HLMethodReference on: aCompiledMethod
- !
- regexpReferencesOf: aString
- ^ (self allMethods select: [ :each |
- each source match: aString ])
- collect: [ :each | self methodReferenceOn: each ]
- !
- sendersOf: aString
- ^ (self allMethods select: [ :each |
- each messageSends includes: aString ])
- collect: [ :each | self methodReferenceOn: each ]
- ! !
- !HLReferencesModel methodsFor: 'actions'!
- search: aString
- self updateCaches.
-
- self announcer announce: (HLSearchReferences new
- searchString: aString;
- yourself)
- ! !
- !HLReferencesModel methodsFor: 'cache'!
- classesAndMetaclassesCache
- classesAndMetaclassesCache ifNil: [ self updateClassesAndMetaclassesCache ].
-
- ^ classesAndMetaclassesCache
- !
- methodsCache
- methodsCache ifNil: [ self updateMethodsCache ].
-
- ^ methodsCache
- !
- updateCaches
- self
- updateClassesAndMetaclassesCache;
- updateMethodsCache
- !
- updateClassesAndMetaclassesCache
- classesAndMetaclassesCache := self environment classes
- inject: OrderedCollection new
- into: [ :acc :each |
- acc
- add: each;
- add: each class;
- yourself ]
- !
- updateMethodsCache
- methodsCache := self classesAndMetaclasses
- inject: OrderedCollection new
- into: [ :acc :each |
- acc, each methods ]
- ! !
- !HLReferencesModel methodsFor: 'testing'!
- isReferencesModel
- ^ true
- ! !
|