[squeak-dev] The Trunk: Collections-nice.891.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat May 9 16:27:53 UTC 2020
Nicolas Cellier uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-nice.891.mcz
==================== Summary ====================
Name: Collections-nice.891
Author: nice
Time: 9 May 2020, 6:27:51.164977 pm
UUID: 4b4cd1ee-3b62-4ee2-b819-5b4481f6ecee
Ancestors: Collections-nice.890
Find a selector in a line containing an assignment
This uses new (negative) lookahead extensions to Regex (hence requires Regex >= Regex-Core-ct.56).
Example: try alt+m in following line (extracted from these changes):
sel := sel copyReplaceAll: ':(?!=)' with: ': '. "blah"
=============== Diff against Collections-nice.890 ===============
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: '\$.' matchesReplacedWith: '$x'. "handle $( $[ and $:"
+ 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 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!
More information about the Squeak-dev
mailing list
|