The Inbox: Morphic-mt.1602.mcz

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

The Inbox: Morphic-mt.1602.mcz

commits-2
A new version of Morphic was added to project The Inbox:
http://source.squeak.org/inbox/Morphic-mt.1602.mcz

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

Name: Morphic-mt.1602
Author: mt
Time: 5 December 2019, 3:11:57.060176 pm
UUID: d86de487-98af-4640-bdc1-3c51bfa4cc06
Ancestors: Morphic-mt.1601

Refine that proposal Morphic-mt.1601:

- Let browse-it also browse calls for shared variables.
- Let implementors-of-it explore bindings of class pools and shared pools.

Note that a class/shared pool is selected if one of the pool's variables is selected. For shared pools, that very pool can be selected, too, through the class definition's "... poolDictionaries: ...".

Not sure whether class-pool exploration is usefull because that binding is artificial. Maybe browse the class instead?

=============== Diff against Morphic-mt.1601 ===============

Item was added:
+ ----- Method: SmalltalkEditor>>selectedBinding (in category 'selection - bindings') -----
+ selectedBinding
+ "Try to make a binding out of the current text selection. That binding can be a global or class."
+
+ ^ self selectedSymbol ifNotNil:
+ [ :symbol |
+ ((model respondsTo: #selectedClassOrMetaClass)
+ ifTrue: [ model selectedClassOrMetaClass ifNil: [ model environment ] ]
+ ifFalse: [ model environment ]) ifNotNil:
+ [ :environment | environment bindingOf: symbol ] ]!

Item was added:
+ ----- Method: SmalltalkEditor>>selectedClassVariable (in category 'selection - bindings') -----
+ selectedClassVariable
+ "Try to make a class-variable binding out of the current text selection."
+
+ ^ self selectedClassVariablePool ifNotNil:
+ [ :classToPool |
+ self selectedSymbol ifNotNil:
+ [ :symbol | classToPool value bindingOf: symbol ] ]!

Item was added:
+ ----- Method: SmalltalkEditor>>selectedClassVariablePool (in category 'selection - bindings') -----
+ selectedClassVariablePool
+ "Try to make an association from a class to its pool out of the current text selection. NOTE THAT this does not return the default class pool if there is a class selected but no symbol. That way, #selectedSharedVariablePool and this one can be used in a similar fashion."
+
+ (model respondsTo: #selectedClass) ifFalse: [ ^ nil ].
+
+ self flag: #fakeBinding. "mt: This might be confusing in client code..."
+
+ model selectedClass ifNotNil:
+ [ :currentClass |
+ self selectedSymbol ifNotNil:
+ [ :symbol |
+ currentClass withAllSuperclassesDo:
+ [ :class |
+ (class classPool includesKey: symbol)
+ ifTrue: [ ^ class name -> class classPool ] ] ].
+ ^ nil ].
+ ^ nil!

Item was added:
+ ----- Method: SmalltalkEditor>>selectedInstanceVariable (in category 'selection - bindings') -----
+ 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."
+
+ (model respondsTo: #selectedClassOrMetaClass) ifFalse: [ ^ nil ].
+
+ self flag: #fakeBinding. "mt: This might be confusing in client code..."
+
+ ^ self selection string ifNotNil:
+ [ :token | model selectedClassOrMetaClass ifNotNil:
+ [ :behavior |
+ (behavior instVarIndexFor: token ifAbsent: [ 0 ]) ~= 0
+ ifTrue: [ token -> behavior ]
+ ifFalse: [ nil ] ] ]!

Item was added:
+ ----- Method: SmalltalkEditor>>selectedLiteral (in category 'selection') -----
+ selectedLiteral
+ "Try to make a Smalltalk literal out of the current text selection."
+
+ ^ self selection string findLiteral!

Item was added:
+ ----- Method: SmalltalkEditor>>selectedSelector (in category 'selection') -----
+ selectedSelector
+ "Try to make a selector out of the current text selection."
+
+ ^ self selection string findSelector!

Item was added:
+ ----- Method: SmalltalkEditor>>selectedSharedVariable (in category 'selection - bindings') -----
+ selectedSharedVariable
+ "Try to make a pool-variable binding out of the current text selection, which can point to a variable in that pool."
+
+ ^ self selectedSharedVariablePool ifNotNil:
+ [ :poolBinding |
+ self selectedSymbol ifNotNil:
+ [ :symbol | poolBinding value bindingOf: symbol ] ]!

Item was added:
+ ----- Method: SmalltalkEditor>>selectedSharedVariablePool (in category 'selection - bindings') -----
+ selectedSharedVariablePool
+ "Try to make a shared-pool binding out of the current text selection. That selection can either point directly to the pool or into that pool at a variable."
+
+ (model respondsTo: #selectedClass) ifFalse: [ ^ nil ].
+
+ self selectedSymbol ifNotNil:
+ [ :symbol |
+ "Is a shared pool selected?"
+ (model environment bindingOf: symbol) ifNotNil: [:globalBinding |
+ ((globalBinding value isKindOf: Dictionary) or: [globalBinding value isKindOf: SharedPool])
+ ifTrue: [^ globalBinding]].
+ "Is a variable *within* a shared pool?"
+ ^ model selectedClass ifNotNil:
+ [ :class | class allSharedPools
+ detect: [ :pool | (pool bindingOf: symbol) notNil ]
+ ifFound: [ :pool | (model environment keyAtIdentityValue: pool ifAbsent: [])
+ ifNotNil: [ :poolName | model environment bindingOf: poolName ] ] ] ].!

Item was added:
+ ----- Method: SmalltalkEditor>>selectedSymbol (in category 'selection') -----
+ selectedSymbol
+ "Try to make a symbol out of the current text selection."
+
+ ^ self selection string findSymbol!

Item was changed:
  ----- Method: TextEditor>>browseIt (in category 'menu messages') -----
  browseIt
  "Launch a browser for the current selection, if appropriate."
 
  Preferences alternativeBrowseIt ifTrue: [^ self browseClassFromIt].
 
  self lineSelectAndEmptyCheck: [^ morph flash].
 
  "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].
+ self selectedSharedVariable ifNotNil:
+ [:binding | self systemNavigation browseAllCallsOn: binding].
 
  "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!

Item was changed:
  ----- Method: TextEditor>>implementorsOfIt (in category 'menu messages') -----
  implementorsOfIt
  "Open an implementors browser on the selected selector or a regular browser if the selection is a class binding."
 
  self lineSelectAndEmptyCheck: [^ self].
+ self selectedClassVariablePool ifNotNil:
+ [:binding | ^ binding explore]. "(model environment classNamed: binding key) browse ???"
+ self selectedSharedVariablePool ifNotNil:
+ [:binding | ^ binding explore].
- self selectedBinding ifNotNil:
- [:binding | ^ self systemNavigation browseClass: binding].
  self selectedSelector ifNotNil:
  [:selector | ^ self systemNavigation browseAllImplementorsOf: selector].
  morph flash!

Item was removed:
- ----- Method: TextEditor>>selectedBinding (in category 'menu messages') -----
- selectedBinding
- "Try to make a binding out of the current text selection. That binding can be a global or class."
-
- ^ self selectedSymbol ifNotNil:
- [ :symbol |
- ((model respondsTo: #selectedClassOrMetaClass)
- ifTrue: [ model selectedClassOrMetaClass ifNil: [ model environment ] ]
- ifFalse: [ model environment ]) ifNotNil:
- [ :environment | environment bindingOf: symbol ] ]!

Item was removed:
- ----- 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 removed:
- ----- 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."
-
- (model respondsTo: #selectedClassOrMetaClass) ifFalse: [ ^ nil ].
-
- ^ self selection string ifNotNil:
- [ :token | model selectedClassOrMetaClass ifNotNil:
- [ :behavior |
- (behavior instVarIndexFor: token ifAbsent: [ 0 ]) ~= 0
- ifTrue: [ token -> behavior ]
- ifFalse: [ nil ] ] ]!

Item was removed:
- ----- Method: TextEditor>>selectedLiteral (in category 'menu messages') -----
- selectedLiteral
- "Try to make a Smalltalk literal out of the current text selection."
-
- ^ self selection string findLiteral!

Item was removed:
- ----- Method: TextEditor>>selectedSelector (in category 'menu messages') -----
- selectedSelector
- "Try to make a selector out of the current text selection."
-
- ^ self selection string findSelector!

Item was removed:
- ----- Method: TextEditor>>selectedSymbol (in category 'menu messages') -----
- selectedSymbol
- "Try to make a symbol out of the current text selection."
-
- ^ self selection string findSymbol!