SystemBrowser.st
changeset 7395 4aa4c6b9a161
parent 7361 fd281ab33547
child 7524 0257265ae6b7
equal deleted inserted replaced
7394:ef23e1ac40ee 7395:4aa4c6b9a161
  4457     ].
  4457     ].
  4458     ^ searchBlock
  4458     ^ searchBlock
  4459 !
  4459 !
  4460 
  4460 
  4461 searchBlockForCode:aCodeString isMethod:isMethod
  4461 searchBlockForCode:aCodeString isMethod:isMethod
  4462     "return a block to search for a pice of code (intelligent search)."
  4462     "return a block to search for a piece of code (intelligent search)."
  4463 
  4463 
  4464     |errAction searchTree searcher globalVariablesUsed usedSymbols
  4464     |errAction searchTree searcher globalVariablesUsed usedSymbols
  4465      sentMessages searchBlock foundMatch|
  4465      sentMessages searchBlock foundMatch|
  4466 
  4466 
  4467 "/self halt.
  4467 "/self halt.
  4506                                 and:[ Smalltalk includesKey: node name asSymbol ]
  4506                                 and:[ Smalltalk includesKey: node name asSymbol ]
  4507                            ]   
  4507                            ]   
  4508                     thenCollect:[:node | node name asSymbol]. 
  4508                     thenCollect:[:node | node name asSymbol]. 
  4509 
  4509 
  4510     usedSymbols := searchTree usedSymbols.
  4510     usedSymbols := searchTree usedSymbols.
       
  4511 
       
  4512     "/ cannot use literals to speedup the search, because stc does not store
       
  4513     "/ constants in the literal-array.
       
  4514     "/ literalsUsed := searchTree usedLiterals.
       
  4515     "/ literalsUsed := literalsUsed select:[:lit | lit isString].
  4511 
  4516 
  4512     searcher := ParseTreeSearcher new.
  4517     searcher := ParseTreeSearcher new.
  4513     isMethod ifTrue:[
  4518     isMethod ifTrue:[
  4514         searcher 
  4519         searcher 
  4515             matchesMethod:searchTree
  4520             matchesMethod:searchTree
  4571                             ]
  4576                             ]
  4572                         ].
  4577                         ].
  4573                         foundMatch.
  4578                         foundMatch.
  4574                    ].
  4579                    ].
  4575     ^ searchBlock.
  4580     ^ searchBlock.
       
  4581 
       
  4582     "Modified: / 12-10-2006 / 21:30:05 / cg"
  4576 !
  4583 !
  4577 
  4584 
  4578 searchBlockForString:aString ignoreCase:ignoreCase match:doMatch
  4585 searchBlockForString:aString ignoreCase:ignoreCase match:doMatch
  4579     "return a block to search for a string."
  4586     "return a block to search for a string."
  4580 
  4587 
  4677      SystemBrowser findStringLiteral:'error' in:(Array with:Object) ignoreCase:true match:true
  4684      SystemBrowser findStringLiteral:'error' in:(Array with:Object) ignoreCase:true match:true
  4678      SystemBrowser findStringLiteral:'error' in:(Array with:Object) ignoreCase:true match:false
  4685      SystemBrowser findStringLiteral:'error' in:(Array with:Object) ignoreCase:true match:false
  4679      SystemBrowser findStringLiteral:'error' in:(Array with:Object) ignoreCase:false match:true
  4686      SystemBrowser findStringLiteral:'error' in:(Array with:Object) ignoreCase:false match:true
  4680      SystemBrowser findStringLiteral:'error' in:(Array with:Object) ignoreCase:false match:false
  4687      SystemBrowser findStringLiteral:'error' in:(Array with:Object) ignoreCase:false match:false
  4681     "
  4688     "
  4682 !
       
  4683 
       
  4684 xxfindImplementorsOf:aSelectorString in:aCollectionOfClasses ignoreCase:ignoreCase
       
  4685     "search for all implementors of aSelector in
       
  4686      the classes contained in aCollectionOfClasses and its metaclasses.
       
  4687      Return a collection of methods"
       
  4688 
       
  4689     |list sel srchST srchJava lcSelector|
       
  4690 
       
  4691     aSelectorString size == 0 ifTrue:[ ^ #() ].
       
  4692 
       
  4693     list := IdentitySet new.
       
  4694 
       
  4695 "/    ((aSelectorString ~= '*') and:[aSelectorString includesMatchCharacters]) ifTrue:[
       
  4696 "/        "a matchString"
       
  4697 "/
       
  4698 "/        ignoreCase == true ifTrue:[
       
  4699 "/            lcSelector := aSelectorString asLowercase.
       
  4700 "/
       
  4701 "/            srchST := [:aSelector :aMethod |
       
  4702 "/                            (lcSelector match:aSelector asLowercase) ifTrue:[
       
  4703 "/                                list add:aMethod
       
  4704 "/                            ]
       
  4705 "/                      ].
       
  4706 "/            srchJava := [:aSelector :aMethod |
       
  4707 "/                            (aSelector match:aMethod name asLowercase) ifTrue:[
       
  4708 "/                                list add:aMethod
       
  4709 "/                            ]
       
  4710 "/                      ].
       
  4711 "/        ] ifFalse:[
       
  4712 "/            srchST := [:aSelector :aMethod |
       
  4713 "/                            (aSelectorString match:aSelector) ifTrue:[
       
  4714 "/                                list add:aMethod
       
  4715 "/                            ]
       
  4716 "/                      ].
       
  4717 "/            srchJava := [:aSelector :aMethod |
       
  4718 "/                            (aSelectorString match:aMethod name) ifTrue:[
       
  4719 "/                                list add:aMethod
       
  4720 "/                            ]
       
  4721 "/                      ].
       
  4722 "/        ].
       
  4723 "/    ] ifFalse:[
       
  4724 
       
  4725         sel := aSelectorString asSymbolIfInterned.
       
  4726         sel isNil ifTrue:[
       
  4727             ^ #()
       
  4728         ].
       
  4729 
       
  4730         ignoreCase == true ifTrue:[
       
  4731             lcSelector := sel asLowercase.
       
  4732             srchJava := [:aSelector :aMethod |
       
  4733                             "/ allow search for signature AND
       
  4734                             "/ search for plain name
       
  4735                             ((aMethod name asLowercase = lcSelector)
       
  4736                             or:[aSelector asLowercase = lcSelector]) ifTrue:[
       
  4737                                 list add:aMethod
       
  4738                             ]
       
  4739                         ].
       
  4740             srchST := [:aSelector :aMethod |
       
  4741                             (aSelector asLowercase = lcSelector) ifTrue:[
       
  4742                                 list add:aMethod
       
  4743                             ]
       
  4744                         ].
       
  4745         ] ifFalse:[
       
  4746             srchJava := [:aSelector :aMethod |
       
  4747                             "/ allow search for signature AND
       
  4748                             "/ search for plain name
       
  4749                             ((aMethod name = sel)
       
  4750                             or:[aSelector == sel]) ifTrue:[
       
  4751                                 list add:aMethod
       
  4752                             ]
       
  4753                         ].
       
  4754             srchST := [:aSelector :aMethod |
       
  4755                             (aSelector == sel) ifTrue:[
       
  4756                                 list add:aMethod
       
  4757                             ]
       
  4758                         ].
       
  4759         ].
       
  4760 "/    ].
       
  4761 
       
  4762     aCollectionOfClasses do:[:aClass |
       
  4763         |srchBlock|
       
  4764 
       
  4765         aClass isObsolete ifFalse:[
       
  4766             aClass isJavaClass ifTrue:[
       
  4767                 srchBlock := srchJava
       
  4768             ] ifFalse:[
       
  4769                 srchBlock := srchST
       
  4770             ].
       
  4771             aClass methodDictionary keysAndValuesDo:srchBlock.
       
  4772             aClass isMeta ifFalse:[
       
  4773                 aClass class methodDictionary keysAndValuesDo:srchBlock
       
  4774             ]
       
  4775         ]
       
  4776     ].
       
  4777 
       
  4778     ^ list
       
  4779 
       
  4780     "
       
  4781      SystemBrowser findImplementorsOf:#+
       
  4782                                      in:(Array with:Number
       
  4783                                                with:Float
       
  4784                                                with:SmallInteger)
       
  4785     "
       
  4786 ! !
  4689 ! !
  4787 
  4690 
  4788 !SystemBrowser class methodsFor:'startup'!
  4691 !SystemBrowser class methodsFor:'startup'!
  4789 
  4692 
  4790 browseAllSelect:aBlock
  4693 browseAllSelect:aBlock
  5621 ! !
  5524 ! !
  5622 
  5525 
  5623 !SystemBrowser class methodsFor:'documentation'!
  5526 !SystemBrowser class methodsFor:'documentation'!
  5624 
  5527 
  5625 version
  5528 version
  5626     ^ '$Header: /cvs/stx/stx/libtool/SystemBrowser.st,v 1.241 2006-10-06 09:46:14 cg Exp $'
  5529     ^ '$Header: /cvs/stx/stx/libtool/SystemBrowser.st,v 1.242 2006-10-12 19:31:34 cg Exp $'
  5627 ! !
  5530 ! !
  5628 
  5531 
  5629 SystemBrowser initialize!
  5532 SystemBrowser initialize!