author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sat, 13 Dec 2014 00:11:58 +0000 | |
changeset 366 | e2083bc62428 |
child 370 | b02030d796d8 |
permissions | -rw-r--r-- |
366
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1 |
" |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
2 |
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
3 |
Copyright (C) 2013-2014 Jan Vrany |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
4 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
5 |
This library is free software; you can redistribute it and/or |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
6 |
modify it under the terms of the GNU Lesser General Public |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
7 |
License as published by the Free Software Foundation; either |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
8 |
version 2.1 of the License. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
9 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
10 |
This library is distributed in the hope that it will be useful, |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
13 |
Lesser General Public License for more details. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
14 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
15 |
You should have received a copy of the GNU Lesser General Public |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
16 |
License along with this library; if not, write to the Free Software |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
17 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
18 |
" |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
19 |
"{ Package: 'stx:goodies/smallsense' }" |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
20 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
21 |
"{ NameSpace: SmallSense }" |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
22 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
23 |
AbstractSearchProcessor subclass:#ClassSearchProcessor |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
24 |
instanceVariableNames:'matchFullyQualifiedClassName' |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
25 |
classVariableNames:'' |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
26 |
poolDictionaries:'' |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
27 |
category:'SmallSense-Core-Interface-Search' |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
28 |
! |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
29 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
30 |
!ClassSearchProcessor class methodsFor:'documentation'! |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
31 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
32 |
copyright |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
33 |
" |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
34 |
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
35 |
Copyright (C) 2013-2014 Jan Vrany |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
36 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
37 |
This library is free software; you can redistribute it and/or |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
38 |
modify it under the terms of the GNU Lesser General Public |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
39 |
License as published by the Free Software Foundation; either |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
40 |
version 2.1 of the License. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
41 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
42 |
This library is distributed in the hope that it will be useful, |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
43 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
44 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
45 |
Lesser General Public License for more details. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
46 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
47 |
You should have received a copy of the GNU Lesser General Public |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
48 |
License along with this library; if not, write to the Free Software |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
49 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
50 |
" |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
51 |
! ! |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
52 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
53 |
!ClassSearchProcessor methodsFor:'accessing'! |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
54 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
55 |
matchFullyQualifiedClassName |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
56 |
^ matchFullyQualifiedClassName |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
57 |
! |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
58 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
59 |
matchFullyQualifiedClassName:something |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
60 |
matchFullyQualifiedClassName := something. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
61 |
! ! |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
62 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
63 |
!ClassSearchProcessor methodsFor:'searching'! |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
64 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
65 |
matchingObjectPOsFor: objects |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
66 |
| matchQualified | |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
67 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
68 |
matchQualified := matchFullyQualifiedClassName == true. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
69 |
matchQualified ifTrue:[ |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
70 |
objects sort:[:a :b | a displayString < b displayString ]. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
71 |
] ifFalse:[ |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
72 |
objects sort:[:a :b | a nameWithoutPrefix < b nameWithoutPrefix ]. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
73 |
]. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
74 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
75 |
^ objects collect:[:each | |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
76 |
(ClassPO new) |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
77 |
klass:each; |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
78 |
showPrefix:matchQualified |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
79 |
]. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
80 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
81 |
"Created: / 30-04-2014 / 09:50:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
82 |
"Modified: / 12-12-2014 / 23:10:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
83 |
! |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
84 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
85 |
matchingObjectsForPattern:pattern filter: filter inEnvironment:environment relax: level |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
86 |
| matching matchQualified | |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
87 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
88 |
matching := OrderedCollection new. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
89 |
matchQualified := matchFullyQualifiedClassName == true. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
90 |
pattern notNil ifTrue:[ |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
91 |
matchQualified ifFalse:[ |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
92 |
environment |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
93 |
allClassesDo:[:cls | |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
94 |
((filter isNil or:[filter value: cls]) and:[(pattern match:cls nameWithoutPrefix relax: level)]) ifTrue:[ |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
95 |
matching add:cls. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
96 |
]. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
97 |
]. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
98 |
] ifTrue:[ |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
99 |
environment |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
100 |
allClassesDo:[:cls | |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
101 |
((filter isNil or:[filter value: cls]) and:[(pattern match:cls displayString relax: level)]) ifTrue:[ |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
102 |
matching add:cls |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
103 |
] |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
104 |
]. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
105 |
] |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
106 |
]. |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
107 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
108 |
^ matching |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
109 |
|
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
110 |
"Created: / 12-12-2014 / 21:24:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
111 |
"Modified: / 12-12-2014 / 23:14:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
112 |
! ! |
e2083bc62428
Decoupling search logic from dialogs (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
113 |