The Trunk: Morphic-mt.1600.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Morphic-mt.1600.mcz

commits-2
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1600.mcz

==================== Summary ====================

Name: Morphic-mt.1600
Author: mt
Time: 4 December 2019, 3:08:44.132613 pm
UUID: 5bcf0a1b-6340-4728-a816-192bba1615a9
Ancestors: Morphic-mt.1599

Makes the magic of #browseIt and #browseItHere more readable. To achieve that readability, introduce #selectedClassVariable. Improves documentation of #selectedInstanceVariable.

If I omitted any former effect of #browseIt, please report.

=============== Diff against Morphic-mt.1599 ===============

Item was changed:
  ----- Method: TextEditor>>browseIt (in category 'menu messages') -----
  browseIt
+ "Launch a browser for the current selection, if appropriate."
- "Launch a browser for the current selection, if appropriate"
 
- | aSymbol anEntry maybeBrowseInstVar |
-
  Preferences alternativeBrowseIt ifTrue: [^ self browseClassFromIt].
 
+ self lineSelectAndEmptyCheck: [^ morph flash].
- self lineSelectAndEmptyCheck: [^ self].
 
+ "First, try to show all accesses to instance or class variables."
+ self selectedInstanceVariable ifNotNil:
+ [:nameToClass | self systemNavigation
+ browseAllAccessesTo: nameToClass key
+ from: nameToClass value].
+ self selectedClassVariable ifNotNil:
+ [:binding | self systemNavigation browseAllCallsOn: binding].
- maybeBrowseInstVar := [ | selectionString |
- selectionString := self selection asString.
- ([model selectedClass] on: Error do: [:ex|]) ifNotNil:
- [:class|
- (class allInstVarNames includes: selectionString) ifTrue:
- [self systemNavigation
- browseAllAccessesTo: selectionString
- from: (class classThatDefinesInstanceVariable: selectionString).
- ^nil]]].
 
+ "Then, either browse the class (from a binding) or all implementors of a selector."
+ self selectedBinding ifNotNil:
+ [:binding | ^ self systemNavigation browseClass: binding].
+ self selectedSelector ifNotNil:
+ [:selector | ^ self systemNavigation browseAllImplementorsOf: selector].
+
+ morph flash!
- (aSymbol := self selectedSymbol) ifNil:
- [maybeBrowseInstVar value.
- ^morph flash].
-
- aSymbol first isUppercase
- ifTrue:
- [anEntry := (model environment
- valueOf: aSymbol
- ifAbsent:
- [ ([model selectedClass] on: Error do: [:ex|]) ifNotNil:
- [:class|
- (class bindingOf: aSymbol) ifNotNil: "e.g. a class var"
- [:binding|
- self systemNavigation browseAllCallsOn: binding.
- ^ nil]].
- self systemNavigation browseAllImplementorsOf: aSymbol.
- ^ nil]).
- anEntry ifNil: [^ morph flash].
- (anEntry isBehavior and: [anEntry name == aSymbol]) ifFalse: "When is this ever false?"
- [anEntry := anEntry class].
- self systemNavigation browseClass: anEntry]
- ifFalse:
- [self systemNavigation browseAllImplementorsOf: aSymbol.
- maybeBrowseInstVar value]!

Item was changed:
  ----- Method: TextEditor>>browseItHere (in category 'menu messages') -----
  browseItHere
+ "Retarget the receiver's window to look at the selected class, if appropriate."
- "Retarget the receiver's window to look at the selected class, if appropriate.  3/1/96 sw"
- | aSymbol foundClass b |
- (((b := model) isKindOf: Browser) and: [b couldBrowseAnyClass])
- ifFalse: [^ morph flash].
- model okToChange ifFalse: [^ morph flash].
- self selectionInterval isEmpty ifTrue: [self selectWord].
- (aSymbol := self selectedSymbol) isNil ifTrue: [^ morph flash].
 
+ self wordSelectAndEmptyCheck: [^ morph flash].
+
+ ((model isKindOf: Browser) and: [model couldBrowseAnyClass])
+ ifFalse: [^ morph flash].
+ model okToChange
+ ifFalse: [^ morph flash].
+
+ self selectedSymbol ifNotNil: [:symbol |
+ (model environment classNamed: symbol) ifNotNil: [:class |
+ ^ model setClass: class]].
+
+ morph flash!
- foundClass := (Smalltalk at: aSymbol ifAbsent: [nil]).
- foundClass isNil ifTrue: [^ morph flash].
- (foundClass isKindOf: Class)
- ifTrue:
- [model selectSystemCategory: foundClass category.
- model classListIndex: (model classList indexOf: foundClass name)]!

Item was added:
+ ----- Method: TextEditor>>selectedClassVariable (in category 'menu messages') -----
+ selectedClassVariable
+ "Try to make a class-variable binding out of the current text selection."
+
+ (model respondsTo: #selectedClassOrMetaClass) ifFalse: [ ^ nil ].
+
+ ^ self selectedSymbol ifNotNil:
+ [ :symbol | model selectedClassOrMetaClass ifNotNil:
+ [ :classOrMetaClass | (classOrMetaClass theNonMetaClass allClassVarNames includes: symbol)
+ ifTrue: [ classOrMetaClass bindingOf: symbol ]
+ ifFalse: [ nil ] ] ]!

Item was changed:
  ----- Method: TextEditor>>selectedInstanceVariable (in category 'menu messages') -----
  selectedInstanceVariable
+ "Try to make an association from an instance-variable name to the class where this variable is defined. Make the implementation robust for models that do not know about classes.
+
+ Note that inst-var names might not have symbol a representation, only via their accessors."
- "Try to make an association from an instance-variable name to the class where this variable is defined. Make the implementation robust for models that do not know about classes."
 
  (model respondsTo: #selectedClassOrMetaClass) ifFalse: [ ^ nil ].
 
+ ^ self selection string ifNotNil:
- ^ self selection string ifNotNil:
  [ :token | model selectedClassOrMetaClass ifNotNil:
  [ :behavior |
  (behavior instVarIndexFor: token ifAbsent: [ 0 ]) ~= 0
  ifTrue: [ token -> behavior ]
  ifFalse: [ nil ] ] ]!