The Trunk: Collections-ct.849.mcz

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

The Trunk: Collections-ct.849.mcz

commits-2
Marcel Taeumel uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ct.849.mcz

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

Name: Collections-ct.849
Author: ct
Time: 14 August 2019, 11:35:57.1364 pm
UUID: aa322791-50ce-234e-9f55-40b28674c13f
Ancestors: Collections-fn.847

Refine #findSelector

1. Ignore leading $#
2. Don't fall over colons as part of arguments in a selected message send

I hope this is no performance sensitive method, but as it should be called only once per user interaction, I don't think so.

=============== Diff against Collections-fn.847 ===============

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 copyReplaceAll: ':' with: ': '. "for the style (aa max:bb) with no space"
- [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 findTokens: Character separators.
  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: $})]]]].
+ (sel at: 1 ifAbsent: [^ nil]) = $# ifTrue: [sel := sel allButFirst].
  sel isEmpty ifTrue: [^ nil].
  sel isOctetString ifTrue: [sel := sel asOctetString].
  Symbol hasInterned: sel ifTrue:
  [:aSymbol | ^ aSymbol].
  ^ nil!