2011-12-24 2 views
6

검색하여 검색했습니다.Squeak smalltalk에서 클래스 내부의 문자열을 검색하는 방법은 무엇입니까? 패키지 내부는 어떻습니까?

나는 IRC에 갔다.

희망은 어리석지 않다. 그렇다면 Google에서 검색 할 올바른 문자열은 여전히 ​​많이 받아 들여질 것입니다.

+0

저는 fileOut에 대해 알고 있습니다. 하지만 더 좋은 방법이 있어야합니다. – josinalvo

+0

실제 답변이 아니지만 http://squeak.preeminent.org/tut2007/html/035B.html을 참고하여 의견을 남기고 특정 방법을 실제 형태로 다시 방문하십시오. 메서드 호출을 사용하면 해당 보낸 사람을 쉽게 찾을 수 있습니다. –

답변

1

다음은 '\'문자열이 포함 된 DosFileDirectory의 모든 메소드를 보여주는 예입니다.

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'. 

는 전체 패키지를 검색에 검색 부분을 포장 :

package := PackageOrganizer default packageNamed: packageName ifAbsent: [ self error: 'package doesn't exist' ]. 
package classesAndMetaClasses do: [ :class | ... ] 
2

이 리팩토링 엔진과 같은 질문에 대답하는 것은 매우 쉽다.

allCodeWithSlash := RBBrowserEnvironment new matches: '/' 

거기에서 더 수 범위 검색, 예를 들어, 다음 코드는 시스템에 /의 모든 항목을 찾습니다 에 클래스 내부 :

allCodeWithSlashInPackage open 

: 당신가 UI가로드 한 경우

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

, 당신은이 검색 결과의 브라우저를 열 수 있습니다

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

또는 패키지 내부

OmniBrowser를 사용하는 경우 Refactoring scope 메뉴를 통해 코드를 입력하지 않고도이 범위를 작성하고 탐색 할 수 있습니다.

관련 문제