Hi All,
the "find method with string literals containing..." command, command-E does /not/ look inside Symbol literals. Here's a case where I specifically wanted it to, I wanted to find the reference to CogSimStackEntry in instVarNamesAndTypesForTranslationDo: aBinaryBlock "enumerate aBinaryBlock with the names and C type strings for the inst vars to include in a CogSSOptStatus struct." self instVarNames do: [:ivn| aBinaryBlock value: ivn value: (ivn = 'ssEntry' ifTrue: [#'CogSimStackEntry *'] ifFalse: [#sqInt])] The method in question is SystemNavigation>>browseMethodsWithString: aString matchCase: caseSensitive "Launch a browser on all methods that contain string literals with aString as a substring. Make the search case-sensitive or insensitive as dictated by the caseSensitive boolean parameter" self browseAllSelect: [:method | method hasLiteralSuchThat: [:lit | (lit isString and: [lit isSymbol not]) and: [lit includesSubstring: aString caseSensitive: caseSensitive]]] name: 'Methods with string ', aString printString, (caseSensitive ifTrue: [' (case-sensitive)'] ifFalse: [' (case-insensitive)']) autoSelect: aString Would people object if I changed this? One way to change it is to exclude Symbol literals that are also messages in the receiver. So, e.g... browseMethodsWithString: aString matchCase: caseSensitive "Launch a browser on all methods that contain string literals with aString as a substring. Make the search case-sensitive or insensitive as dictated by the caseSensitive boolean parameter" self browseAllSelect: [:method | method hasLiteralSuchThat: [:lit | lit isString and: [(lit includesSubstring: aString caseSensitive: caseSensitive) and: [lit isSymbol ifTrue: [(method messages includes: lit) not] ifFalse: [true]]]]] name: 'Methods with string ', aString printString, (caseSensitive ifTrue: [' (case-sensitive)'] ifFalse: [' (case-insensitive)']) autoSelect: aString Would anyone object to me committing this definition? _,,,^..^,,,_ best, Eliot |
I believe this feature was intended to help humans find methods from
seeing them in labels on the UI. Symbols would not normally concern that use-case. Having said that, one could argue that Symbols are Strings, and therefore a Symbol used as a literal in a method is a String used as a literal in a method, and the function is, "find a string literal". For example, even in this case, we have a Symbol is referenced which we intend to perform: selectorToPerform := someCondition ifTrue: [ #add: ] ifFalse: [ #remove: ] Then searching for the string 'add' would regard that a hit. It seems like it shouldn't be a big deal even for the first use-case.. On Mon, Apr 18, 2016 at 6:35 PM, Eliot Miranda <[hidden email]> wrote: > Hi All, > > the "find method with string literals containing..." command, command-E > does /not/ look inside Symbol literals. Here's a case where I specifically > wanted it to, I wanted to find the reference to CogSimStackEntry in > > instVarNamesAndTypesForTranslationDo: aBinaryBlock > "enumerate aBinaryBlock with the names and C type strings for the inst vars > to include in a CogSSOptStatus struct." > > self instVarNames do: > [:ivn| > aBinaryBlock > value: ivn > value: (ivn = 'ssEntry' > ifTrue: [#'CogSimStackEntry *'] > ifFalse: [#sqInt])] > > The method in question is > > SystemNavigation>>browseMethodsWithString: aString matchCase: caseSensitive > "Launch a browser on all methods that contain string literals with aString > as a substring. Make the search case-sensitive or insensitive as dictated by > the caseSensitive boolean parameter" > > self browseAllSelect: > [:method | > method hasLiteralSuchThat: [:lit | > (lit isString and: [lit isSymbol not]) and: > [lit includesSubstring: aString caseSensitive: caseSensitive]]] > name: 'Methods with string ', aString printString, (caseSensitive ifTrue: > [' (case-sensitive)'] ifFalse: [' (case-insensitive)']) > autoSelect: aString > > Would people object if I changed this? One way to change it is to exclude > Symbol literals that are also messages in the receiver. So, e.g... > > browseMethodsWithString: aString matchCase: caseSensitive > "Launch a browser on all methods that contain string literals with aString > as a substring. Make the search case-sensitive or insensitive as dictated by > the caseSensitive boolean parameter" > > self browseAllSelect: > [:method | > method hasLiteralSuchThat: > [:lit | > lit isString > and: [(lit includesSubstring: aString caseSensitive: caseSensitive) > and: [lit isSymbol > ifTrue: [(method messages includes: lit) not] > ifFalse: [true]]]]] > name: 'Methods with string ', aString printString, (caseSensitive ifTrue: > [' (case-sensitive)'] ifFalse: [' (case-insensitive)']) > autoSelect: aString > > Would anyone object to me committing this definition? > > _,,,^..^,,,_ > best, Eliot > > > |
In reply to this post by Eliot Miranda-2
Hi Eliot,
just search "method source containing...". In VMMaker, searching for "CogSimStackEntry" only yields 25 results. :-) There is no keyboard shortcut for that. Best, Marcel |
Free forum by Nabble | Edit this page |