Administrator
|
I have a lot of methods which send messages similar to the following, but with varying numbers of arguments. I want to be able to automatically extract the symbols used as the argument to the #statusTag: keyword (to be able to keep a #packagerKnownSymbols implementation up to date). self gbsMessenger statusTag: #atOop:putClient: message: '%1 atOop: %2 putClient: %3' with: self with: (oop printStringRadix: 16) with: obj identityHash. Any such tool or script would be welcome. Absent such a result, guidance on doing so effectively would also be appreciated. You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/7cbd9990-5760-4d3e-85ed-e9c7997872c0%40googlegroups.com. |
You can use the rewrite searcher on the rewrite tools. I have some code doing something similar. If you don't figure it out for the Monday ping me and I can lookup the code for doing it
-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/739fb767-4f93-481c-ad07-937132895c1b%40googlegroups.com. |
In reply to this post by Richard Sargent
*Steve*
-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/61ba95b4-046a-4b86-958e-d950d62fbf5b%40googlegroups.com. |
On Sunday, September 22, 2019 at 9:39:31 AM UTC-5, Steven LaFavor wrote:
Something was bothering me when I wrote this message, and in looking at it again, I now see the string in the message: argument that actually *is* the invocation of the method, so please ignore my response. *Steve* You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/5bdbf514-daff-4c65-b5f1-883309dff25c%40googlegroups.com. |
In reply to this post by Richard Sargent
Richard, something like this should do the trick: | searcher symbols| symbols := Set new. searcher := ParseTreeSearcher new. searcher answer: false; matches: 'self gbsMessenger statusTag: `@symbol message: `@message with: `@first with: `@second with: `@third' do: [:node :answer | | literalValue | literalValue := node arguments first value. literalValue isSymbol ifTrue: [symbols add: literalValue]. false]. SmalllintChecker newWithContext rule: ( TransformationRule new rewriteUsing: searcher; yourself); environment: ( ClassEnvironment onEnvironment: BrowserEnvironment new classes: ((System loadedApplications select: [:app | app name beginsWith: #Gb ] ) inject: OrderedCollection new into: [:classes :app | app withAllSubApplications do: [:subapp | classes addAll: subapp defined;yourself ]. classes])); run. symbols On Friday, September 20, 2019 at 9:12:13 PM UTC-3, Richard Sargent wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/43d7d850-ee3e-4501-a165-803cd38edbc6%40googlegroups.com. |
Administrator
|
In reply to this post by Steven LaFavor
Steve, Your original response was fine. I don't understand your latest response. :-) Atoms are not an option for me here because I need to maintain source code compatibility with other Smalltalks (as much as possible). On Sunday, September 22, 2019 at 12:20:42 PM UTC-7, Steven LaFavor wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/4b3bfca6-0acc-4dae-a63c-7660bdce2323%40googlegroups.com. |
Administrator
|
In reply to this post by gcotelli
On Monday, September 23, 2019 at 5:04:04 AM UTC-7, Gabriel Cotelli wrote:
--
Thanks, Gabriel. That will be helpful. Do you know if I can generalize the message pattern to include all variants of #statusTag:message:*? i.e. 0 to n #with: keywords and the most general #withArguments: keywords? At this point, I am only asking to get a better understanding. I have scripted enumerating the list of selectors and finding the methods that send each. Getting the parse tree of each method is easy (#stsParseTree) and enumerating the nodes to find the appropriate EsKeywordPattern instance and extracting the #statusTag: argument is now relatively easy. (#allNodesDo:, #isKeywordPattern, arguments first, etc.)
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/0c99f3c5-e0b0-453e-b3a0-952456da922b%40googlegroups.com. |
Administrator
|
For those who care, the attached file is a script which does what I was seeking. Feel free to adapt it to your own needs. (Note, a real object-oriented solution would utilize the parse tree visitor pattern defined for the Code Assist tools. This one is quick and dirty.) You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/9ec65f79-3ab1-4d11-aa4e-73bcdeff544f%40googlegroups.com. ExampleProcessingParseTreeOfSendersOfSpecificSelectors.st (975 bytes) Download Attachment |
Free forum by Nabble | Edit this page |