123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- Smalltalk createPackage: 'Helios-References'!
- HLWidget subclass: #HLReferences
- slots: {#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'!
- registerBindingsOn: aBindingGroup
- HLToolCommand
- registerConcreteClassesOn: aBindingGroup
- for: self model
- !
- search: aString
- self model search: aString.
- self setTabLabel: 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
- slots: {}
- 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 ]
- !
- reselectItem: aMethod
- self selectItem: aMethod
- !
- selectItem: aMethod
- super selectItem: aMethod.
- self model selectedClass: nil; selectedMethod: aMethod
- ! !
- !HLReferencesListWidget methodsFor: 'reactions'!
- onMethodSelected: aMethod
- aMethod ifNil: [ ^ self ].
- (self items includes: aMethod) ifFalse: [ ^ self ].
-
- self
- selectedItem: aMethod;
- activateItem: aMethod
- !
- onSearchReferences: aString
- self subclassResponsibility
- ! !
- !HLReferencesListWidget methodsFor: 'rendering'!
- renderItemLabel: aMethod on: html
- html with: aMethod asString
- ! !
- !HLReferencesListWidget class methodsFor: 'instance creation'!
- on: aModel
- ^ self new
- model: aModel;
- yourself
- ! !
- HLReferencesListWidget subclass: #HLClassReferencesListWidget
- slots: {}
- 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
- slots: {}
- 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
- slots: {}
- 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
- slots: {}
- 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
- slots: {#methodsCache. #classesAndMetaclassesCache}
- package: 'Helios-References'!
- !HLReferencesModel methodsFor: 'accessing'!
- allMethods
- ^ self methodsCache
- !
- classReferencesOf: aString
- "Answer all methods referencing the class named aString"
-
- ^self allMethods select: [ :each |
- (each referencedClasses includes: aString) ]
- !
- classesAndMetaclasses
- ^ self classesAndMetaclassesCache
- !
- implementorsOf: aString
- ^ self allMethods select: [ :each |
- each selector = aString ]
- !
- regexpReferencesOf: aString
- ^ self allMethods select: [ :each |
- each source match: aString ]
- !
- sendersOf: aString
- ^ self allMethods select: [ :each |
- each messageSends includes: aString ]
- ! !
- !HLReferencesModel methodsFor: 'actions'!
- openClassNamed: aString
- | browser |
-
- self withChangesDo: [
- browser := HLBrowser openAsTab.
- browser openClassNamed: aString ]
- !
- openMethod
- | browser |
-
- self selectedMethod ifNil: [ ^ self ].
-
- self withChangesDo: [
- browser := HLBrowser openAsTab.
- browser openMethod: self selectedMethod ]
- !
- 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 := OrderedCollection new.
-
- self environment classes do: [ :eachClass | eachClass includingPossibleMetaDo: [ :each |
- classesAndMetaclassesCache add: each ] ]
- !
- updateMethodsCache
- methodsCache := OrderedCollection new.
-
- self classesAndMetaclasses
- do: [ :each | methodsCache addAll: each methods ]
- ! !
- !HLReferencesModel methodsFor: 'testing'!
- isReferencesModel
- ^ true
- ! !
|