6

I searched, and searched.

I went to IRC

Hope the question is not silly. If it was, the right string to search at google would still be much appreciated

josinalvo
  • 1,366
  • 13
  • 26
  • I know about fileOut. But there has to be a better way – josinalvo Dec 24 '11 at 21:09
  • Not an actual answer, but see http://squeak.preeminent.org/tut2007/html/035B.html for its suggestion to leave comments to yourself to revisit particular methods in the form of actual method calls which you can easily find by looking for those senders. – Edward Ocampo-Gooding Jun 25 '12 at 02:27

2 Answers2

2

Answering such questions with the refactoring engine is quite easy. The following code finds all occurrences of / in the system:

allCodeWithSlash := RBBrowserEnvironment new matches: '/'

From there you can further scope the search, e.g. to inside a class:

allCodeWithSlashInClass := allCodeWithSlash forClasses: (Array with: DosFileDirectory)

Or inside a package:

allCodeWithSlashInPackage := allCodeWithSlash forPackageNames: (Array with: 'Files')

If you have an UI loaded, you can open a browser on any of these search results:

allCodeWithSlashInPackage open

If you use OmniBrowser, you can also build and navigate these scopes without typing any code through the Refactoring scope menu.

Lukas Renggli
  • 8,754
  • 23
  • 46
1

Here's an example that shows you all methods in DosFileDirectory containing the string '\'.

aString := '\\'.
class := DosFileDirectory.
methodsContainingString := class methodDictionary values select: [:method |
    method hasLiteralSuchThat: [:lit |
        (lit isString and: [lit isSymbol not]) and:
            [lit = aString]]].
messageList := methodsContainingString collect: [ :e | MethodReference new setStandardClass: class methodSymbol: e selector ].

SystemNavigation new
    browseMessageList: messageList
    name: 'methods containing string'.

To search a whole package, wrap the search part in:

package := PackageOrganizer default packageNamed: packageName ifAbsent: [ self error: 'package doesn't exist' ].
package classesAndMetaClasses do: [ :class | ... ]
Sean DeNigris
  • 6,306
  • 1
  • 31
  • 37