The Inbox: Collections-nice.867.mcz

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

The Inbox: Collections-nice.867.mcz

commits-2
Nicolas Cellier uploaded a new version of Collections to project The Inbox:
http://source.squeak.org/inbox/Collections-nice.867.mcz

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

Name: Collections-nice.867
Author: nice
Time: 27 December 2019, 10:29:53.018596 pm
UUID: d3b5ceb3-62ab-4f61-a9a3-dd757041b47f
Ancestors: Collections-mt.866

Fix sendersOfIt for searching senders of an expression including a literal (byte) array

If you select following text

        preference: 'Send Mouse Wheel Events to Keyboard Focus'
                categoryList: #(Morphic keyboard mouse)
                description: 'If enabled, follow the behavior known from Microsoft Windows, where the mouse wheel works for the widget that has the keyboard focus. If disabled, follow the Mac OS style, where the mouse wheel is send to the widget under the mouse position'
                type: #Boolean
               
and browse senders, then if search for senders of #preference: instead of the whole keyword

This is because '#(Morphic keyboard mouse)' was replaced with '#aSymbol keyboard mouse)'

=============== Diff against Collections-mt.866 ===============

Item was changed:
  ----- Method: String>>findSelector (in category 'converting') -----
  findSelector
  "Dan's code for hunting down selectors with keyword parts; while this doesn't give a true parse, in most cases it does what we want, in where it doesn't, we're none the worse for it."
  | sel possibleParens |
  sel := self withBlanksTrimmed.
  (sel includes: $:)
  ifTrue:
  [sel := sel copyWithRegex: '''[^'']*''' matchesReplacedWith: '''a string'''.
+ sel := sel copyWithRegex: '#[^\[\(\s\.$]*' matchesReplacedWith: '#aSymbol'.
- sel := sel copyWithRegex: '#[^\s\.$]*' matchesReplacedWith: '#aSymbol'.
  sel := sel copyReplaceAll: ':' with: ': '. "for the style (aa max:bb) with no space"
  sel := sel copyReplaceAll: '[:' with: '[ :'.    "for the style ([:a) with no space"  
  possibleParens := sel substrings.
  sel := self class streamContents:
  [:s | | level |
  level := 0.
  possibleParens do:
  [:token |
  (level = 0 and: [token endsWith: ':'])
  ifTrue: [s nextPutAll: token]
  ifFalse: [level := level
  + (token occurrencesOf: $() - (token occurrencesOf: $))
  + (token occurrencesOf: $[) - (token occurrencesOf: $])
  + (token occurrencesOf: ${) - (token occurrencesOf: $})]]]]
  ifFalse:
  [sel := self substrings ifNotEmpty: [:tokens | tokens last]].
  sel ifEmpty: [^ nil].
  sel first = $# ifTrue:
  [sel := sel allButFirst.
  sel ifEmpty: [^ nil]].
  sel isOctetString ifTrue: [sel := sel asOctetString].
  ^ Symbol lookup: sel!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Collections-nice.867.mcz

timrowledge
That looks fun. Is this a place where we might be able to leverage Shout/refactoringbrowser stuff to do the 'proper' job?

> On 2019-12-27, at 1:30 PM, [hidden email] wrote:
>
> Nicolas Cellier uploaded a new version of Collections to project The Inbox:
> http://source.squeak.org/inbox/Collections-nice.867.mcz
>
> ==================== Summary ====================
>
> Name: Collections-nice.867
> Author: nice
> Time: 27 December 2019, 10:29:53.018596 pm
> UUID: d3b5ceb3-62ab-4f61-a9a3-dd757041b47f
> Ancestors: Collections-mt.866
>
> Fix sendersOfIt for searching senders of an expression including a literal (byte) array


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Strange OpCodes: CLOUT: Call Long-distance On Unused Telephone



Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Collections-nice.867.mcz

Nicolas Cellier
Well, selected chunk need not even to be valid Smalltalk, as long as it contains the whole selector...
It can be any piece of text in a workspace.
VW uses the ast, that's nice, but also restrict the possibilities.

Le sam. 28 déc. 2019 à 00:00, tim Rowledge <[hidden email]> a écrit :
That looks fun. Is this a place where we might be able to leverage Shout/refactoringbrowser stuff to do the 'proper' job?

> On 2019-12-27, at 1:30 PM, [hidden email] wrote:
>
> Nicolas Cellier uploaded a new version of Collections to project The Inbox:
> http://source.squeak.org/inbox/Collections-nice.867.mcz
>
> ==================== Summary ====================
>
> Name: Collections-nice.867
> Author: nice
> Time: 27 December 2019, 10:29:53.018596 pm
> UUID: d3b5ceb3-62ab-4f61-a9a3-dd757041b47f
> Ancestors: Collections-mt.866
>
> Fix sendersOfIt for searching senders of an expression including a literal (byte) array


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Strange OpCodes: CLOUT: Call Long-distance On Unused Telephone





Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Collections-nice.867.mcz

marcel.taeumel
In reply to this post by commits-2
+1

Could you also update StringTest >> #testFindSelector?

Best,
Marcel

Am 27.12.2019 22:30:08 schrieb [hidden email] <[hidden email]>:

Nicolas Cellier uploaded a new version of Collections to project The Inbox:
http://source.squeak.org/inbox/Collections-nice.867.mcz

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

Name: Collections-nice.867
Author: nice
Time: 27 December 2019, 10:29:53.018596 pm
UUID: d3b5ceb3-62ab-4f61-a9a3-dd757041b47f
Ancestors: Collections-mt.866

Fix sendersOfIt for searching senders of an expression including a literal (byte) array

If you select following text

preference: 'Send Mouse Wheel Events to Keyboard Focus'
categoryList: #(Morphic keyboard mouse)
description: 'If enabled, follow the behavior known from Microsoft Windows, where the mouse wheel works for the widget that has the keyboard focus. If disabled, follow the Mac OS style, where the mouse wheel is send to the widget under the mouse position'
type: #Boolean

and browse senders, then if search for senders of #preference: instead of the whole keyword

This is because '#(Morphic keyboard mouse)' was replaced with '#aSymbol keyboard mouse)'

=============== Diff against Collections-mt.866 ===============

Item was changed:
----- Method: String>>findSelector (in category 'converting') -----
findSelector
"Dan's code for hunting down selectors with keyword parts; while this doesn't give a true parse, in most cases it does what we want, in where it doesn't, we're none the worse for it."
| sel possibleParens |
sel := self withBlanksTrimmed.
(sel includes: $:)
ifTrue:
[sel := sel copyWithRegex: '''[^'']*''' matchesReplacedWith: '''a string'''.
+ sel := sel copyWithRegex: '#[^\[\(\s\.$]*' matchesReplacedWith: '#aSymbol'.
- sel := sel copyWithRegex: '#[^\s\.$]*' matchesReplacedWith: '#aSymbol'.
sel := sel copyReplaceAll: ':' with: ': '. "for the style (aa max:bb) with no space"
sel := sel copyReplaceAll: '[:' with: '[ :'. "for the style ([:a) with no space"
possibleParens := sel substrings.
sel := self class streamContents:
[:s | | level |
level := 0.
possibleParens do:
[:token |
(level = 0 and: [token endsWith: ':'])
ifTrue: [s nextPutAll: token]
ifFalse: [level := level
+ (token occurrencesOf: $() - (token occurrencesOf: $))
+ (token occurrencesOf: $[) - (token occurrencesOf: $])
+ (token occurrencesOf: ${) - (token occurrencesOf: $})]]]]
ifFalse:
[sel := self substrings ifNotEmpty: [:tokens | tokens last]].
sel ifEmpty: [^ nil].
sel first = $# ifTrue:
[sel := sel allButFirst.
sel ifEmpty: [^ nil]].
sel isOctetString ifTrue: [sel := sel asOctetString].
^ Symbol lookup: sel!