[squeak-dev] The Inbox: Collections-ct.849.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Aug 14 21:36:01 UTC 2019


A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/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!



More information about the Squeak-dev mailing list