[squeak-dev] The Trunk: Collections-nice.891.mcz
Thiede, Christoph
Christoph.Thiede at student.hpi.uni-potsdam.de
Sun May 10 11:22:35 UTC 2020
Hi Nicolas,
Does this work for you? #copyReplaceAll:with: appears not to accept regexes.
For example, consider this output:
'123' copyReplaceAll: '\d' with: 'x'. "'123'"
On my machine, the following does not work:
[cid:e490ef14-7d7b-419e-997f-dbfee712f2d2]
I selected everything and pressed <cmd>m. I would rather expect to be notified that there are not implementors of #foo:?
(By the way, see also the discussion in this thread<http://forum.world.st/The-Inbox-Collections-ct-885-mcz-td5114711.html>. #copyReplaceAll:with: and #copyWithRegex:matchesReplacedWith: is another pair of similar-featured methods that maybe could be merged if we created a common protocol for comparison and matching ...)
Best,
Christoph
________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von commits at source.squeak.org <commits at source.squeak.org>
Gesendet: Samstag, 9. Mai 2020 18:27:53
An: squeak-dev at lists.squeakfoundation.org; packages at lists.squeakfoundation.org
Betreff: [squeak-dev] The Trunk: Collections-nice.891.mcz
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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200510/3a29c6a4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 9529 bytes
Desc: pastedImage.png
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200510/3a29c6a4/attachment.png>
More information about the Squeak-dev
mailing list
|