SmallSense__ImplementorSearchProcessor.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sun, 11 Jan 2015 06:38:54 +0000
changeset 370 b02030d796d8
parent 366 e2083bc62428
child 377 c686ea588575
permissions -rw-r--r--
Initial work on Navigator, an unified search dialog Now it searches for classes and implementors only.

"
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
Copyright (C) 2013-2014 Jan Vrany

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
"
"{ Package: 'stx:goodies/smallsense' }"

"{ NameSpace: SmallSense }"

AbstractSearchProcessor subclass:#ImplementorSearchProcessor
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'SmallSense-Core-Interface-Search'
!

!ImplementorSearchProcessor class methodsFor:'documentation'!

copyright
"
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
Copyright (C) 2013-2014 Jan Vrany

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
"
! !

!ImplementorSearchProcessor methodsFor:'accessing - presentation'!

label
    "Return a label for this processor. This one is used as section label
     in Spotter"

    ^ 'Implementors'

    "Created: / 10-01-2015 / 06:41:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ImplementorSearchProcessor methodsFor:'searching'!

matchingObjectPOsFor: objects
    | pos |

    pos := OrderedCollection new: objects size.
    objects keysAndValuesDo: [ :selector :classes |
        pos add: (PO forClasses: classes selector: selector )

    ].
    ^ pos sort:[ :a :b | a label == b label ifTrue:[ a classes anElement name < b classes anElement name] ifFalse:[ a label < b label ] ]

    "Created: / 30-04-2014 / 09:50:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 12-12-2014 / 23:50:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

matchingObjectsForPattern:pattern filter: filter inEnvironment:environment relax: level 
    | matching |

    matching := Dictionary new.
    pattern notNil ifTrue:[
        environment 
            allMethodsDo:[:mthd |
                | selector name |

                name := selector := mthd selector.
                mthd isJavaMethod ifTrue:[ name := name upTo: $( ].
                ((filter isNil or:[filter value: mthd]) and:[(pattern match:name relax: level)]) ifTrue:[
                    (matching at: selector ifAbsentPut: [ Set new ]) add: mthd mclass
                ].
            ].
    ].

    ^ matching

    "Created: / 12-12-2014 / 21:24:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 12-12-2014 / 23:51:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !