SystemBrowser.st
branchjv
changeset 16571 cf319f2e56d0
parent 16570 dc5e958a20dc
parent 16529 0514cf8d290b
child 16596 f111c3082dd1
equal deleted inserted replaced
16570:dc5e958a20dc 16571:cf319f2e56d0
   118     "Created: 30.4.1996 / 14:43:45 / cg"
   118     "Created: 30.4.1996 / 14:43:45 / cg"
   119 !
   119 !
   120 
   120 
   121 openInClass:aClass selector:aSelector
   121 openInClass:aClass selector:aSelector
   122     "launch a standard browser which immediately switches
   122     "launch a standard browser which immediately switches
   123      to aClass>>aSelector. Returns the browser"
   123      to aClass » aSelector. Returns the browser"
   124 
   124 
   125     |brwsr classesName|
   125     |brwsr classesName|
   126 
   126 
   127     brwsr := self openOnDevice:(Screen current).
   127     brwsr := self openOnDevice:(Screen current).
   128     brwsr waitUntilVisible.
   128     brwsr waitUntilVisible.
  5394     ] ifFalse:[
  5394     ] ifFalse:[
  5395         searchTree := RBParser 
  5395         searchTree := RBParser 
  5396                     parseRewriteExpression:aCodeString 
  5396                     parseRewriteExpression:aCodeString 
  5397                     onError: errAction.
  5397                     onError: errAction.
  5398     ].
  5398     ].
  5399 
  5399     
  5400     "/ extract messages sent by the pattern
  5400     "/ extract messages sent by the pattern
  5401     Error handle:[:ex |
  5401     Error handle:[:ex |
  5402         self halt:'check this, please'.
  5402         self halt:'check this, please'.
  5403     ] do:[
  5403     ] do:[
  5404         sentMessages := searchTree sentMessages.         
  5404         sentMessages := searchTree sentMessages.         
  5443     ] ifFalse:[
  5443     ] ifFalse:[
  5444         searcher 
  5444         searcher 
  5445             matchesTree:searchTree
  5445             matchesTree:searchTree
  5446             do:[:aNode :answer | foundMatch := true].
  5446             do:[:aNode :answer | foundMatch := true].
  5447     ].
  5447     ].
       
  5448     searcher computeQuickSearchStrings.
  5448 
  5449 
  5449     searchBlock := [:c :m :sel | 
  5450     searchBlock := [:c :m :sel | 
  5450                         |isSTCCompiled allSelectorsInLiteralArray allMessagesSent 
  5451                         |isSTCCompiled allSelectorsInLiteralArray allMessagesSent 
  5451                          allGlobalsReferenced allUsedSymbolsInLiteralArray allStringsInLiteralArray
  5452                          allGlobalsReferenced allUsedSymbolsInLiteralArray allStringsInLiteralArray
  5452                          allSent src rslt parseTree
  5453                          allSent src rslt parseTree
  5462                                 src := m source.
  5463                                 src := m source.
  5463                                 src notNil ifTrue:[
  5464                                 src notNil ifTrue:[
  5464                                     m makeRealMethod.
  5465                                     m makeRealMethod.
  5465                                 ].
  5466                                 ].
  5466                             ].
  5467                             ].
  5467                             "/ can speedup the search, by filtering for sent messages...
  5468                             "/ can speedup the search, by quickly filtering for sent messages...
  5468                             literalsInMethod := m literals.
  5469                             literalsInMethod := m literals.
  5469                             allSelectorsInLiteralArray := sentMessages isEmptyOrNil or:[ literalsInMethod includesAll:sentMessages ].
  5470                             allSelectorsInLiteralArray := sentMessages isEmptyOrNil or:[ literalsInMethod includesAll:sentMessages ].
  5470                             allSelectorsInLiteralArray ifTrue:[
  5471                             allSelectorsInLiteralArray ifTrue:[
  5471                                 "/ and used symbols/globals first...
  5472                                 "/ and used symbols/globals first...
  5472                                 allUsedSymbolsInLiteralArray := usedSymbols isEmptyOrNil or:[ literalsInMethod includesAll:usedSymbols ].
  5473                                 allUsedSymbolsInLiteralArray := usedSymbols isEmptyOrNil or:[ literalsInMethod includesAll:usedSymbols ].
  5497                                                                 "/ before doing a slow parse
  5498                                                                 "/ before doing a slow parse
  5498                                                                 allStringsInLiteralArray := usedStrings conform:[:eachString | src includesString:eachString].
  5499                                                                 allStringsInLiteralArray := usedStrings conform:[:eachString | src includesString:eachString].
  5499                                                             ]
  5500                                                             ]
  5500                                                         ].
  5501                                                         ].
  5501                                                         allStringsInLiteralArray ifTrue:[
  5502                                                         allStringsInLiteralArray ifTrue:[
  5502                                                             "/ the rest is done by the slower RB-match process...
  5503                                                             (searcher canQuicklyReject:src) ifTrue:[
  5503                                                             parseTree := RBParser 
  5504                                                                 "/ Transcript show:'qReject: '; showCR:m whoString.
       
  5505                                                             ] ifFalse:[
       
  5506                                                                 "/ the rest is done by the slower RB-match process...
       
  5507                                                                 parseTree := RBParser 
  5504                                                                             parseSearchMethod:src 
  5508                                                                             parseSearchMethod:src 
  5505                                                                             onError: [:str :pos | 
  5509                                                                             onError: [:str :pos | 
  5506                                                                                 "/ self halt.
  5510                                                                                 "/ self halt.
  5507                                                                                 Transcript show:'Error during search in '; showCR:m. 
  5511                                                                                 Transcript show:'Error during search in '; showCR:m. 
  5508                                                                                 Transcript showCR:str. 
  5512                                                                                 Transcript showCR:str. 
  5509                                                                                 Transcript showCR:pos. 
  5513                                                                                 Transcript showCR:pos. 
  5510                                                                                 nil].
  5514                                                                                 nil].
  5511 
  5515 
  5512                                                             parseTree notNil ifTrue:[
  5516                                                                 parseTree notNil ifTrue:[
  5513                                                                 searcher executeTree:parseTree.
  5517                                                                     searcher executeTree:parseTree.
  5514                                                                 "/ notice: searcher sets foundMatch !!
  5518                                                                     "/ notice: searcher sets foundMatch !!
       
  5519                                                                 ].
  5515                                                             ].
  5520                                                             ].
  5516                                                         ].
  5521                                                         ].
  5517                                                     ]
  5522                                                     ]
  5518                                                 ]
  5523                                                 ]
  5519                                             ]
  5524                                             ]
  6959     sel notNil ifTrue:[
  6964     sel notNil ifTrue:[
  6960         sel := sel asString withoutSeparators.
  6965         sel := sel asString withoutSeparators.
  6961         ('*>>*' match:sel) ifTrue:[
  6966         ('*>>*' match:sel) ifTrue:[
  6962             sep := $>
  6967             sep := $>
  6963         ] ifFalse:[
  6968         ] ifFalse:[
  6964             ('* *' match:sel) ifTrue:[
  6969             ('*»*' match:sel) ifTrue:[
  6965                 sep := Character space
  6970                 sep := $»
  6966             ]
  6971             ] ifFalse:[
       
  6972                 ('* *' match:sel) ifTrue:[
       
  6973                     sep := Character space
       
  6974                 ]
       
  6975             ].
  6967         ].
  6976         ].
  6968         sep notNil ifTrue:[
  6977         sep notNil ifTrue:[
  6969             "
  6978             "
  6970              extract class/sel from selection
  6979              extract class/sel from selection
  6971             "
  6980             "
  6972             s := ReadStream on:sel.
  6981             s := ReadStream on:sel.
  6973             clsName := s upTo:sep.
  6982             clsName := (s upTo:sep) withoutSeparators.
  6974             [s peek == sep] whileTrue:[s next].
  6983             [s peek == sep] whileTrue:[s next].
  6975             sel := s upToEnd.
  6984             sel := (s upToEnd) withoutSeparators.
  6976 
  6985 
  6977             (clsName endsWith:' class') ifTrue:[
  6986             (clsName endsWith:' class') ifTrue:[
  6978                 isMeta := true.
  6987                 isMeta := true.
  6979                 clsName := clsName copyButLast:6 "copyTo:(clsName size - 5)"
  6988                 clsName := clsName copyButLast:6 "copyTo:(clsName size - 5)"
  6980             ] ifFalse:[
  6989             ] ifFalse:[
  6991 
  7000 
  6992 extractSelectorFrom:aString
  7001 extractSelectorFrom:aString
  6993     "given an arbitrary string, try to extract a useful selector.
  7002     "given an arbitrary string, try to extract a useful selector.
  6994      Useful to open browser on a selected code fragment."
  7003      Useful to open browser on a selected code fragment."
  6995 
  7004 
  6996     |s sel sel2 t|
  7005     |s sel sel2 t idx|
  6997 
  7006 
  6998     aString isNil ifTrue:[^ nil].
  7007     aString isEmptyOrNil ifTrue:[^ nil].
  6999 
  7008 
  7000     s := aString asString string withoutSeparators.
  7009     (idx := aString indexOf:$») ~~ 0 ifTrue:[
       
  7010         s := (aString copyFrom:idx+1) withoutSeparators.
       
  7011         s isEmpty ifTrue:[^ nil]. 
       
  7012     ] ifFalse:[    
       
  7013         s := aString asString string withoutSeparators.
       
  7014     ].
  7001     sel := s asSymbolIfInterned.
  7015     sel := s asSymbolIfInterned.
  7002     sel isNil ifTrue:[
  7016     sel isNil ifTrue:[
  7003         sel := s.
  7017         sel := s.
  7004     ] ifFalse:[
  7018     ] ifFalse:[
  7005         (sel endsWith:$:) ifTrue:[
  7019         (sel endsWith:$:) ifTrue:[
  7009 
  7023 
  7010     t := Parser selectorInExpression:sel.
  7024     t := Parser selectorInExpression:sel.
  7011     t notNil ifTrue:[
  7025     t notNil ifTrue:[
  7012         sel := t
  7026         sel := t
  7013     ].
  7027     ].
  7014     (sel = s or:[sel isNil or:[t == #>>]]) ifTrue:[
  7028     (sel = s or:[sel isNil or:[t == #'>>']]) ifTrue:[
  7015         "oops - thats probably not what we want here ..."
  7029         "oops - thats probably not what we want here ..."
  7016         self extractClassAndSelectorFrom:s into:[:c :s :m |
  7030         self extractClassAndSelectorFrom:s into:[:c :s :m |
  7017             sel := s
  7031             sel := s
  7018         ]
  7032         ]
  7019     ].
  7033     ].
  7040      self extractSelectorFrom:'#''at:put:'''                       
  7054      self extractSelectorFrom:'#''at:put:'''                       
  7041      self extractSelectorFrom:'at:something put:someValue'     
  7055      self extractSelectorFrom:'at:something put:someValue'     
  7042      self extractSelectorFrom:'self at:something put:someValue'
  7056      self extractSelectorFrom:'self at:something put:someValue'
  7043      self extractSelectorFrom:'(self at:something put:someValue)' 
  7057      self extractSelectorFrom:'(self at:something put:someValue)' 
  7044      self extractSelectorFrom:'[self at:something put:someValue] value' 
  7058      self extractSelectorFrom:'[self at:something put:someValue] value' 
       
  7059      self extractSelectorFrom:'Array » at:put:' 
  7045      self extractSelectorFrom:'Array>>at:put:' 
  7060      self extractSelectorFrom:'Array>>at:put:' 
  7046      self extractSelectorFrom:'Array>>#at:put:' 
  7061      self extractSelectorFrom:'Array>>#at:put:' 
  7047      self extractSelectorFrom:'Array>>#''at:put:''' 
  7062      self extractSelectorFrom:'Array>>#''at:put:''' 
  7048     "
  7063     "
  7049 
  7064