author | Claus Gittinger <cg@exept.de> |
Sun, 17 Jul 2011 11:13:33 +0200 | |
changeset 4058 | 8221d2e915df |
parent 4054 | f6bdf516b10b |
child 4065 | ebea28fa8bab |
permissions | -rw-r--r-- |
2376 | 1 |
" |
2 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
"{ Package: 'stx:libwidg2' }" |
|
13 |
||
14 |
Object subclass:#DoWhatIMeanSupport |
|
15 |
instanceVariableNames:'' |
|
3853 | 16 |
classVariableNames:'LastSource LastParseTree LastChoices' |
2376 | 17 |
poolDictionaries:'' |
18 |
category:'System-Support' |
|
19 |
! |
|
20 |
||
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
21 |
Array variableSubclass:#InputCompletionResult |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
22 |
instanceVariableNames:'' |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
23 |
classVariableNames:'' |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
24 |
poolDictionaries:'' |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
25 |
privateIn:DoWhatIMeanSupport |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
26 |
! |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
27 |
|
2376 | 28 |
!DoWhatIMeanSupport class methodsFor:'documentation'! |
29 |
||
30 |
copyright |
|
31 |
" |
|
32 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
33 |
All Rights Reserved |
|
34 |
||
35 |
This software is furnished under a license and may be used |
|
36 |
only in accordance with the terms of that license and with the |
|
37 |
inclusion of the above copyright notice. This software may not |
|
38 |
be provided or otherwise made available to, or used by, any |
|
39 |
other person. No title to or ownership of the software is |
|
40 |
hereby transferred. |
|
41 |
" |
|
42 |
! |
|
43 |
||
44 |
documentation |
|
45 |
" |
|
46 |
misc collected UI support (functional) |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
47 |
These used to be in the Smalltalk and SystemBrowser class; |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
48 |
however, they are only needed for programmers, and some of the stuff is useful in multiple |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
49 |
places. |
3667 | 50 |
Therefore it is: |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
51 |
1) not needed for standalone executables |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
52 |
2) published here to avoid multiple implementations |
2376 | 53 |
|
54 |
[author:] |
|
55 |
Claus Gittinger (cg@exept.de) |
|
56 |
||
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
57 |
" |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
58 |
! ! |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
59 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
60 |
!DoWhatIMeanSupport class methodsFor:'code completion'! |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
61 |
|
4044 | 62 |
codeCompletionForClass:classOrNil codeView:codeView |
63 |
self codeCompletionForClass:classOrNil context:nil codeView:codeView |
|
64 |
||
65 |
"Modified (format): / 03-07-2011 / 15:49:49 / cg" |
|
3557 | 66 |
! |
67 |
||
4044 | 68 |
codeCompletionForClass:classOrNil context:contextOrNil codeView:codeView |
3900
82fa031be815
comment/format in: #codeCompletionForClass:context:codeView:
Claus Gittinger <cg@exept.de>
parents:
3896
diff
changeset
|
69 |
"contextOrNil is the current context, if this is called from the debugger; |
3557 | 70 |
nil, if called from the browser. |
3900
82fa031be815
comment/format in: #codeCompletionForClass:context:codeView:
Claus Gittinger <cg@exept.de>
parents:
3896
diff
changeset
|
71 |
If nonNil, we can make better guesses, because we actually know what a variable's type is. |
82fa031be815
comment/format in: #codeCompletionForClass:context:codeView:
Claus Gittinger <cg@exept.de>
parents:
3896
diff
changeset
|
72 |
This is not yet done, sigh" |
3557 | 73 |
|
3900
82fa031be815
comment/format in: #codeCompletionForClass:context:codeView:
Claus Gittinger <cg@exept.de>
parents:
3896
diff
changeset
|
74 |
|crsrPos char interval source node checkedNode| |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
75 |
|
4044 | 76 |
"/ classOrNil isNil ifTrue:[ |
77 |
"/ self information:'No class'. |
|
78 |
"/ ^ self. |
|
79 |
"/ ]. |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
80 |
|
3731
eb92d54a47ac
fixed code completion for selector
Claus Gittinger <cg@exept.de>
parents:
3720
diff
changeset
|
81 |
crsrPos := codeView characterPositionOfCursor-1. |
eb92d54a47ac
fixed code completion for selector
Claus Gittinger <cg@exept.de>
parents:
3720
diff
changeset
|
82 |
char := codeView characterAtCharacterPosition:crsrPos. |
eb92d54a47ac
fixed code completion for selector
Claus Gittinger <cg@exept.de>
parents:
3720
diff
changeset
|
83 |
[crsrPos > 1 and:[char isSeparator or:['.' includes:char]]] whileTrue:[ |
eb92d54a47ac
fixed code completion for selector
Claus Gittinger <cg@exept.de>
parents:
3720
diff
changeset
|
84 |
crsrPos := crsrPos - 1. |
eb92d54a47ac
fixed code completion for selector
Claus Gittinger <cg@exept.de>
parents:
3720
diff
changeset
|
85 |
char := codeView characterAtCharacterPosition:crsrPos. |
eb92d54a47ac
fixed code completion for selector
Claus Gittinger <cg@exept.de>
parents:
3720
diff
changeset
|
86 |
]. |
eb92d54a47ac
fixed code completion for selector
Claus Gittinger <cg@exept.de>
parents:
3720
diff
changeset
|
87 |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
88 |
interval := codeView selectedInterval. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
89 |
interval isEmpty ifTrue:[ |
4050 | 90 |
interval := crsrPos-1 to:crsrPos. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
91 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
92 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
93 |
source := codeView contentsAsString string. |
3731
eb92d54a47ac
fixed code completion for selector
Claus Gittinger <cg@exept.de>
parents:
3720
diff
changeset
|
94 |
source := source copyTo:crsrPos. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
95 |
|
3720
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
96 |
"/ this is too naive and stupid; if there is a syntactic error, |
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
97 |
"/ we will not find a node for a long time (stepping back more and more, |
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
98 |
"/ until reaching the beginning). This leads to a thousand and more times reparsing |
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
99 |
"/ without any progress. |
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
100 |
"/ TODO: do it vice-versa, in that the parser does a callOut for every node generated |
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
101 |
"/ as it parses the code. Stop, when the interval is hit. |
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
102 |
"/ that will also work for syntactic incorrect source code. |
3895
79124f2311a1
comment/format in: #findNodeForInterval:in:allowErrors:
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
103 |
node := self findNodeForInterval:interval in:source allowErrors:true. |
3720
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
104 |
"/ [node isNil] whileTrue:[ |
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
105 |
"/ "/ expand to the left ... |
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
106 |
"/ interval start > 1 ifFalse:[ |
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
107 |
"/ self information:'No parseNode found'. |
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
108 |
"/ ^ self. |
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
109 |
"/ ]. |
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
110 |
"/ interval start:(interval start - 1). |
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
111 |
"/ node := self findNodeForInterval:interval in:source allowErrors:true. |
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
112 |
"/ ]. |
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
113 |
node isNil ifTrue:[ |
3895
79124f2311a1
comment/format in: #findNodeForInterval:in:allowErrors:
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
114 |
Transcript showCR:'No parseNode found'. |
79124f2311a1
comment/format in: #findNodeForInterval:in:allowErrors:
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
115 |
self breakPoint:#cg. |
3720
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
116 |
self information:'No parseNode found'. |
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
117 |
^ self. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
118 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
119 |
|
3356
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
120 |
(node isVariable |
3366 | 121 |
and:[ node parent notNil |
3356
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
122 |
and:[ node parent isMessage |
3366 | 123 |
and:[ node stop < (codeView characterPositionOfCursor-1) ]]]) ifTrue:[ |
3356
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
124 |
node := node parent. |
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
125 |
]. |
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
126 |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
127 |
node isVariable ifTrue:[ |
4044 | 128 |
self codeCompletionForVariable:node inClass:classOrNil codeView:codeView. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
129 |
^ self. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
130 |
]. |
3552
e631f2f7bb2a
code completion for symbol literals
Claus Gittinger <cg@exept.de>
parents:
3551
diff
changeset
|
131 |
node isLiteral ifTrue:[ |
e631f2f7bb2a
code completion for symbol literals
Claus Gittinger <cg@exept.de>
parents:
3551
diff
changeset
|
132 |
node value isSymbol ifTrue:[ |
4044 | 133 |
self codeCompletionForLiteralSymbol:node inClass:classOrNil codeView:codeView. |
3552
e631f2f7bb2a
code completion for symbol literals
Claus Gittinger <cg@exept.de>
parents:
3551
diff
changeset
|
134 |
^ self. |
e631f2f7bb2a
code completion for symbol literals
Claus Gittinger <cg@exept.de>
parents:
3551
diff
changeset
|
135 |
]. |
e631f2f7bb2a
code completion for symbol literals
Claus Gittinger <cg@exept.de>
parents:
3551
diff
changeset
|
136 |
]. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
137 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
138 |
checkedNode := node. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
139 |
[checkedNode notNil] whileTrue:[ |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
140 |
checkedNode isMessage ifTrue:[ |
3306
40e860fd2f02
argument-name completion in a methods selector pattern
Claus Gittinger <cg@exept.de>
parents:
3303
diff
changeset
|
141 |
"/ completion in a message-send |
4044 | 142 |
self codeCompletionForMessage:checkedNode inClass:classOrNil codeView:codeView. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
143 |
^ self |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
144 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
145 |
checkedNode isMethod ifTrue:[ |
3900
82fa031be815
comment/format in: #codeCompletionForClass:context:codeView:
Claus Gittinger <cg@exept.de>
parents:
3896
diff
changeset
|
146 |
"/ completion in a method's selector pattern |
4044 | 147 |
self codeCompletionForMethod:checkedNode inClass:classOrNil codeView:codeView. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
148 |
^ self. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
149 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
150 |
checkedNode := checkedNode parent. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
151 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
152 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
153 |
self information:'Node is neither variable nor message.'. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
154 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
155 |
"Modified: / 04-07-2006 / 18:48:26 / fm" |
4050 | 156 |
"Modified: / 06-07-2011 / 13:56:39 / cg" |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
157 |
! ! |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
158 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
159 |
!DoWhatIMeanSupport class methodsFor:'code completion-helpers'! |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
160 |
|
4051 | 161 |
askUserForCompletion:what for:codeView at:position from:allTheBest |
162 |
|list choice lastChoice| |
|
163 |
||
4054
f6bdf516b10b
changed: #askUserForCompletion:for:at:from:
Claus Gittinger <cg@exept.de>
parents:
4051
diff
changeset
|
164 |
"/ cg: until the new stuff works,... |
f6bdf516b10b
changed: #askUserForCompletion:for:at:from:
Claus Gittinger <cg@exept.de>
parents:
4051
diff
changeset
|
165 |
^ self old_askUserForCompletion:what for:codeView from:allTheBest. |
f6bdf516b10b
changed: #askUserForCompletion:for:at:from:
Claus Gittinger <cg@exept.de>
parents:
4051
diff
changeset
|
166 |
|
4051 | 167 |
allTheBest isEmpty ifTrue:[ |
168 |
^ nil |
|
169 |
]. |
|
170 |
allTheBest size == 1 ifTrue:[ |
|
171 |
^ allTheBest first |
|
172 |
]. |
|
173 |
list := allTheBest. |
|
174 |
LastChoices notNil ifTrue:[ |
|
175 |
lastChoice := LastChoices at:what ifAbsent:nil. |
|
176 |
lastChoice notNil ifTrue:[ |
|
4054
f6bdf516b10b
changed: #askUserForCompletion:for:at:from:
Claus Gittinger <cg@exept.de>
parents:
4051
diff
changeset
|
177 |
list := { lastChoice. nil } , (list copyWithout:lastChoice). |
4051 | 178 |
]. |
179 |
]. |
|
180 |
choice := Tools::CodeCompletionMenu |
|
181 |
openFor:codeView |
|
182 |
at:position |
|
183 |
with:allTheBest. |
|
184 |
LastChoices isNil ifTrue:[ |
|
185 |
LastChoices := Dictionary new. |
|
186 |
]. |
|
187 |
LastChoices at:what put:choice. |
|
188 |
^ choice |
|
189 |
||
190 |
"Created: / 16-02-2010 / 10:09:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
4054
f6bdf516b10b
changed: #askUserForCompletion:for:at:from:
Claus Gittinger <cg@exept.de>
parents:
4051
diff
changeset
|
191 |
"Modified (format): / 08-07-2011 / 08:49:35 / cg" |
4051 | 192 |
! |
193 |
||
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
194 |
askUserForCompletion:what for:codeView from:allTheBest |
3853 | 195 |
|list resources choice lastChoice| |
3598 | 196 |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
197 |
allTheBest isEmpty ifTrue:[ ^ nil ]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
198 |
allTheBest size == 1 ifTrue:[ ^ allTheBest first ]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
199 |
|
3853 | 200 |
list := allTheBest. |
201 |
LastChoices notNil ifTrue:[ |
|
202 |
lastChoice := LastChoices at:what ifAbsent:nil. |
|
203 |
lastChoice notNil ifTrue:[ |
|
204 |
list := {lastChoice. nil. } , (list copyWithout:lastChoice). |
|
205 |
]. |
|
206 |
]. |
|
207 |
||
208 |
list size < 30 ifTrue:[ |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
209 |
|menu idx exitKey| |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
210 |
|
3853 | 211 |
menu := PopUpMenu labels:list. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
212 |
menu hideOnKeyFilter:[:key | |hide| |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
213 |
hide := ( #( CursorDown CursorUp Escape Return ) includes: key) not. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
214 |
hide ifTrue:[ |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
215 |
exitKey := key. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
216 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
217 |
hide]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
218 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
219 |
idx := menu startUp. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
220 |
idx == 0 ifTrue:[ |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
221 |
exitKey notNil ifTrue:[ |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
222 |
codeView keyPress:exitKey x:0 y:0. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
223 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
224 |
^ nil |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
225 |
]. |
3853 | 226 |
choice := list at:idx. |
227 |
] ifFalse:[ |
|
228 |
resources := codeView application isNil |
|
229 |
ifTrue:[ codeView resources] |
|
230 |
ifFalse:[ codeView application resources ]. |
|
3598 | 231 |
|
3853 | 232 |
choice := Dialog |
233 |
choose:(resources string:'Choose ',what) |
|
234 |
fromList:list |
|
235 |
lines:20 |
|
236 |
title:(resources string:'Code completion'). |
|
237 |
choice isNil ifTrue:[^ nil]. |
|
238 |
]. |
|
239 |
||
240 |
LastChoices isNil ifTrue:[ |
|
241 |
LastChoices := Dictionary new. |
|
242 |
]. |
|
243 |
LastChoices at:what put:choice. |
|
244 |
^ choice |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
245 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
246 |
"Created: / 10-11-2006 / 14:00:53 / cg" |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
247 |
! |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
248 |
|
4051 | 249 |
codeCompletionForLiteralSymbol:node inClass:classOrNil codeView:codeView |
250 |
|sym possibleCompletions best start stop oldLen newLen oldVar| |
|
251 |
||
252 |
sym := node value. |
|
253 |
possibleCompletions := OrderedCollection new. |
|
254 |
||
255 |
Symbol allInstancesDo:[:existingSym | |
|
256 |
(existingSym startsWith:sym) ifTrue:[ |
|
257 |
(existingSym = sym) ifFalse:[ |
|
258 |
possibleCompletions add:existingSym |
|
259 |
]. |
|
260 |
]. |
|
261 |
]. |
|
262 |
possibleCompletions sort. |
|
263 |
||
264 |
best := possibleCompletions longestCommonPrefix. |
|
265 |
(best = sym or:[(possibleCompletions includes:best) not]) ifTrue:[ |
|
266 |
best := self askUserForCompletion:'symbol literal' for:codeView at: node start from:possibleCompletions. |
|
267 |
best isNil ifTrue:[^ self]. |
|
268 |
]. |
|
269 |
||
270 |
"/ self showInfo:best. |
|
271 |
||
272 |
start := node start. |
|
273 |
stop := node stop. |
|
274 |
(codeView characterAtCharacterPosition:start) == $# ifTrue:[ |
|
275 |
start := start + 1. |
|
276 |
]. |
|
277 |
(codeView characterAtCharacterPosition:start) == $' ifTrue:[ |
|
278 |
start := start + 1. |
|
279 |
stop := stop - 1. |
|
280 |
]. |
|
281 |
||
282 |
oldVar := (codeView textFromCharacterPosition:start to:stop) asString string withoutSeparators. |
|
283 |
||
284 |
codeView |
|
285 |
undoableDo:[ codeView replaceFromCharacterPosition:start to:stop with:best ] |
|
286 |
info:'Completion'. |
|
287 |
||
288 |
(best startsWith:oldVar) ifTrue:[ |
|
289 |
oldLen := stop - start + 1. |
|
290 |
newLen := best size. |
|
291 |
codeView selectFromCharacterPosition:start+oldLen to:start+newLen-1. |
|
292 |
codeView dontReplaceSelectionOnInput |
|
293 |
]. |
|
294 |
||
295 |
"Modified: / 16-02-2010 / 10:15:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
296 |
"Modified (format): / 03-07-2011 / 15:58:45 / cg" |
|
297 |
! |
|
298 |
||
4050 | 299 |
codeCompletionForMessage:node inClass:classOrNil codeView:codeView |
300 |
|selector srchClass implClass |
|
301 |
bestSelectors selector2 bestSelectors2 allBest best info numArgs |
|
302 |
newParts nSelParts oldLen newLen selectorParts |
|
303 |
findBest parentNode selectorInBest selector2InBest2 |
|
304 |
parser selectorsSentInCode split| |
|
305 |
||
306 |
classOrNil notNil ifTrue:[ |
|
307 |
parser := Parser parseMethod:codeView contents string in:classOrNil ignoreErrors:true ignoreWarnings:true. |
|
308 |
selectorsSentInCode := parser messagesSent. |
|
309 |
]. |
|
310 |
||
311 |
findBest := [:node :selector | |
|
312 |
|srchClass bestSelectors bestPrefixes| |
|
313 |
||
4058 | 314 |
codeView topView withCursor:(Cursor questionMark) do:[ |
315 |
srchClass := self lookupClassForMessage:node inClass:classOrNil. |
|
316 |
srchClass notNil ifTrue:[ |
|
317 |
bestSelectors := Parser findBest:30 selectorsFor:selector in:srchClass forCompletion:true. |
|
318 |
] ifFalse:[ |
|
4050 | 319 |
bestSelectors := Parser findBest:30 selectorsFor:selector in:nil forCompletion:true. |
320 |
]. |
|
321 |
]. |
|
322 |
||
323 |
(bestSelectors includes:selector) ifTrue:[ |
|
324 |
bestSelectors := bestSelectors select:[:sel | sel size > selector size]. |
|
325 |
]. |
|
326 |
bestSelectors |
|
327 |
]. |
|
328 |
||
329 |
selector := node selector. |
|
330 |
bestSelectors := findBest value:node value:selector. |
|
331 |
||
332 |
parentNode := node parent. |
|
333 |
||
334 |
"/ if its a unary message AND the parent is a keyword node, look for parent completion too. |
|
335 |
(node selector isUnarySelector |
|
336 |
and:[ parentNode notNil |
|
337 |
and:[ parentNode isMessage |
|
338 |
and:[ (selector2 := parentNode selector) isKeywordSelector ]]]) ifTrue:[ |
|
339 |
"/ srchClass2 := self lookupClassForMessage:parentNode inClass:classOrNil. |
|
340 |
selector2 := selector2,selector. |
|
341 |
bestSelectors2 := findBest value:parentNode value:selector2. |
|
342 |
]. |
|
343 |
||
344 |
bestSelectors2 isEmptyOrNil ifTrue:[ |
|
345 |
allBest := bestSelectors. |
|
346 |
] ifFalse:[ |
|
347 |
bestSelectors isEmptyOrNil ifTrue:[ |
|
348 |
allBest := bestSelectors2 |
|
349 |
] ifFalse:[ |
|
350 |
selectorInBest := (bestSelectors contains:[:sel | sel asLowercase startsWith:selector asLowercase]). |
|
351 |
selector2InBest2 := (bestSelectors2 contains:[:sel | sel asLowercase startsWith:selector2 asLowercase]). |
|
352 |
||
353 |
(selectorInBest not and:[ selector2InBest2 ]) ifTrue:[ |
|
354 |
"/ selector2 is more likely |
|
355 |
allBest := bestSelectors2 |
|
356 |
] ifFalse:[ |
|
357 |
(selectorInBest and:[ selector2InBest2 not ]) ifTrue:[ |
|
358 |
"/ selector more likely |
|
359 |
allBest := bestSelectors |
|
360 |
] ifFalse:[ |
|
361 |
"/ assume same likelyness |
|
362 |
||
363 |
allBest := bestSelectors isEmpty |
|
364 |
ifTrue:[ bestSelectors2 ] |
|
365 |
ifFalse:[ bestSelectors , #(nil) , bestSelectors2 ]. |
|
366 |
] |
|
367 |
]. |
|
368 |
]. |
|
369 |
]. |
|
370 |
||
371 |
allBest isEmptyOrNil ifTrue:[ ^ self ]. |
|
372 |
||
373 |
split := [:list :splitHow | |
|
374 |
|part1 part2 all| |
|
375 |
||
376 |
part1 := list select:splitHow. |
|
377 |
part2 := list reject:splitHow. |
|
378 |
part1 isEmpty ifTrue:[ |
|
379 |
all := part2. |
|
380 |
] ifFalse:[ |
|
381 |
part2 isEmpty ifTrue:[ |
|
382 |
all := part1. |
|
383 |
] ifFalse:[ |
|
384 |
all := part1 , part2. |
|
385 |
] |
|
386 |
]. |
|
387 |
all |
|
388 |
]. |
|
389 |
||
390 |
selectorsSentInCode notNil ifTrue:[ |
|
391 |
"/ the ones already sent in the code are moved to the top of the list. |
|
392 |
allBest := split value:allBest value:[:sel | selectorsSentInCode includes:sel]. |
|
393 |
]. |
|
394 |
||
395 |
"/ the ones which are a prefix are moved towards the top of the list |
|
396 |
allBest := split value:allBest value:[:sel | sel notNil and:[sel startsWith:selector]]. |
|
397 |
||
398 |
best := allBest first. |
|
399 |
allBest size > 1 ifTrue:[ |
|
400 |
"allBest size < 20 ifTrue:[ |
|
401 |
|idx| |
|
402 |
||
403 |
idx := (PopUpMenu labels:allBest) startUp. |
|
404 |
idx == 0 ifTrue:[ ^ self]. |
|
405 |
best := allBest at:idx. |
|
406 |
] ifFalse:[ |
|
407 |
best := Dialog request:'Matching selectors:' initialAnswer:best list:allBest. |
|
408 |
||
409 |
]." |
|
410 |
best := self askUserForCompletion:'selector' for:codeView at: node selectorParts first start from:allBest. |
|
411 |
best isEmptyOrNil ifTrue:[^ self]. |
|
412 |
best = '-' ifTrue:[^ self]. |
|
413 |
]. |
|
414 |
||
415 |
false ifTrue:[ |
|
416 |
srchClass notNil ifTrue:[ |
|
417 |
implClass := srchClass whichClassIncludesSelector:best. |
|
418 |
] ifFalse:[ |
|
419 |
implClass := Smalltalk allClasses select:[:cls | (cls includesSelector:best) or:[cls class includesSelector:best]]. |
|
420 |
implClass size == 1 ifTrue:[ |
|
421 |
implClass := implClass first. |
|
422 |
] ifFalse:[ |
|
423 |
implClass := nil |
|
424 |
] |
|
425 |
]. |
|
426 |
||
427 |
info := best storeString. |
|
428 |
implClass notNil ifTrue:[ |
|
429 |
info := implClass name , ' >> ' , info. |
|
430 |
]. |
|
431 |
self information:info. |
|
432 |
]. |
|
433 |
||
434 |
best ~= selector ifTrue:[ |
|
435 |
numArgs := best numArgs. |
|
436 |
(bestSelectors2 notEmptyOrNil and:[bestSelectors2 includes:best]) ifTrue:[ |
|
437 |
selectorParts := parentNode selectorParts , node selectorParts. |
|
438 |
] ifFalse:[ |
|
439 |
selectorParts := node selectorParts. |
|
440 |
]. |
|
441 |
nSelParts := selectorParts size. |
|
442 |
||
443 |
newParts := best asCollectionOfSubstringsSeparatedBy:$:. |
|
444 |
newParts := newParts select:[:part | part size > 0]. |
|
445 |
||
446 |
codeView |
|
447 |
undoableDo:[ |
|
448 |
|newCursorPosition stop| |
|
449 |
||
450 |
numArgs > nSelParts ifTrue:[ |
|
451 |
stop := selectorParts last stop. |
|
452 |
||
453 |
"/ append the rest ... |
|
454 |
numArgs downTo:nSelParts+1 do:[:idx | |
|
455 |
|newPart| |
|
456 |
||
457 |
newPart := newParts at:idx. |
|
458 |
(best endsWith:$:) ifTrue:[ |
|
459 |
newPart := newPart , ':' |
|
460 |
]. |
|
461 |
||
462 |
(codeView characterAtCharacterPosition:stop) == $: ifFalse:[ |
|
463 |
newPart := ':' , newPart. |
|
464 |
]. |
|
465 |
newPart := (codeView characterAtCharacterPosition:stop) asString , newPart. |
|
466 |
||
467 |
codeView replaceFromCharacterPosition:stop to:stop with:newPart. |
|
468 |
newCursorPosition isNil ifTrue:[ |
|
469 |
newCursorPosition := stop + newPart size. |
|
470 |
] |
|
471 |
] |
|
472 |
]. |
|
473 |
||
474 |
(nSelParts min:newParts size) downTo:1 do:[:idx | |
|
475 |
|newPart oldPartialToken start stop| |
|
476 |
||
477 |
newPart := newParts at:idx. |
|
478 |
oldPartialToken := selectorParts at:idx. |
|
479 |
start := oldPartialToken start. |
|
480 |
stop := oldPartialToken stop. |
|
481 |
||
482 |
(best endsWith:$:) ifTrue:[ |
|
483 |
(codeView characterAtCharacterPosition:stop+1) == $: ifFalse:[ |
|
484 |
newPart := newPart , ':' |
|
485 |
] |
|
486 |
] ifFalse:[ |
|
487 |
(codeView characterAtCharacterPosition:stop) == $: ifTrue:[ |
|
488 |
newPart := newPart , ':' |
|
489 |
] ifFalse:[ |
|
490 |
(codeView characterAtCharacterPosition:stop+1) isSeparator ifFalse:[ |
|
491 |
newPart := newPart , ' ' |
|
492 |
] |
|
493 |
] |
|
494 |
"/ codeView replaceFromCharacterPosition:start to:stop with:(newPart , ':'). |
|
495 |
"/ ] ifFalse:[ |
|
496 |
"/ codeView replaceFromCharacterPosition:start to:stop with:newPart. |
|
497 |
]. |
|
498 |
||
499 |
codeView replaceFromCharacterPosition:start to:stop with:newPart. |
|
500 |
||
501 |
oldLen := stop - start + 1. |
|
502 |
newLen := newPart size. |
|
503 |
||
504 |
"/ codeView selectFromCharacterPosition:start+oldLen to:start+newLen-1. |
|
505 |
newCursorPosition isNil ifTrue:[ |
|
506 |
newCursorPosition := stop + (newLen-oldLen). |
|
507 |
]. |
|
508 |
]. |
|
509 |
codeView cursorToCharacterPosition:newCursorPosition. |
|
510 |
codeView cursorRight. "/ avoid going to the next line !! |
|
511 |
codeView dontReplaceSelectionOnInput. |
|
512 |
] |
|
513 |
info:'Completion'. |
|
514 |
]. |
|
515 |
||
516 |
"Created: / 10-11-2006 / 13:18:27 / cg" |
|
517 |
"Modified: / 16-02-2010 / 10:33:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
4058 | 518 |
"Modified: / 17-07-2011 / 10:32:05 / cg" |
4050 | 519 |
! |
520 |
||
4051 | 521 |
codeCompletionForMethod:node inClass:classOrNil codeView:codeView |
522 |
"completion in a methods selector pattern" |
|
523 |
||
524 |
|crsrPos |
|
525 |
selectorSoFar matchingSelectors |
|
526 |
selectors distances best rest |
|
527 |
allExistingMethods namesOfArguments |
|
528 |
nameBag namesByCount| |
|
529 |
||
530 |
crsrPos := codeView characterPositionOfCursor - 1. |
|
531 |
||
532 |
selectorSoFar := ''. |
|
533 |
node selectorParts doWithIndex:[:partToken :argNr| |
|
534 |
|part| |
|
535 |
||
536 |
part := partToken value. |
|
537 |
selectorSoFar := selectorSoFar , part. |
|
538 |
||
539 |
(crsrPos >= partToken start |
|
540 |
and:[crsrPos <= partToken stop]) ifTrue:[ |
|
541 |
matchingSelectors := Smalltalk allClasses |
|
542 |
inject:(Set new) |
|
543 |
into:[:theSet :eachClass | |
|
544 |
|md| |
|
545 |
||
546 |
(classOrNil notNil and:[classOrNil isMeta]) ifTrue:[ |
|
547 |
md := eachClass theMetaclass methodDictionary |
|
548 |
] ifFalse:[ |
|
549 |
md := eachClass theNonMetaclass methodDictionary |
|
550 |
]. |
|
551 |
theSet addAll:(md keys select:[:sel |sel startsWith:selectorSoFar]). |
|
552 |
theSet. |
|
553 |
]. |
|
554 |
selectors := matchingSelectors asOrderedCollection. |
|
555 |
"/ if there is only one, and user has already entered it, he might want to complete the argument-name |
|
556 |
(selectors size == 1 |
|
557 |
and:[selectors first = selectorSoFar]) ifTrue:[ |
|
558 |
allExistingMethods := (Smalltalk allImplementorsOf:selectorSoFar asSymbol) |
|
559 |
collect:[:cls | cls compiledMethodAt:selectorSoFar asSymbol]. |
|
560 |
namesOfArguments := allExistingMethods collect:[:eachMethod | eachMethod methodArgNames]. |
|
561 |
nameBag := Bag new. |
|
562 |
namesOfArguments do:[:eachNameVector | nameBag add:(eachNameVector at:argNr)]. |
|
563 |
namesByCount := nameBag valuesAndCounts sort:[:a :b | a value < b value]. |
|
564 |
"/ take the one which occurs most often |
|
565 |
best := self askUserForCompletion:'argument' for:codeView at: node start from:(namesByCount collect:[:a | a key]). |
|
566 |
||
567 |
codeView |
|
568 |
undoableDo:[ |
|
569 |
(crsrPos+1) >= codeView contents size ifTrue:[ |
|
570 |
codeView paste:best. |
|
571 |
] ifFalse:[ |
|
572 |
codeView insertString:best atCharacterPosition:crsrPos+1. |
|
573 |
] |
|
574 |
] |
|
575 |
info:'completion'. |
|
576 |
codeView cursorToCharacterPosition:(crsrPos + best size - 1). |
|
577 |
] ifFalse:[ |
|
578 |
distances := selectors collect:[:each | each spellAgainst:selectorSoFar]. |
|
579 |
distances sortWith:selectors. |
|
580 |
selectors reverse. |
|
581 |
best := self askUserForCompletion:'selector' for:codeView at: node start from:selectors. |
|
582 |
best isNil ifTrue:[^ self]. |
|
583 |
||
584 |
rest := best copyFrom:selectorSoFar size. |
|
585 |
||
586 |
codeView |
|
587 |
undoableDo:[ |
|
588 |
codeView |
|
589 |
replaceFromCharacterPosition:crsrPos |
|
590 |
to:crsrPos |
|
591 |
with:rest |
|
592 |
] |
|
593 |
info:'Completion'. |
|
594 |
codeView cursorToCharacterPosition:(crsrPos + rest size - 1). |
|
595 |
]. |
|
596 |
codeView cursorRight. "/ kludge to make it visible |
|
597 |
]. |
|
598 |
]. |
|
599 |
||
600 |
"Modified: / 04-07-2006 / 18:48:26 / fm" |
|
601 |
"Created: / 10-11-2006 / 13:46:44 / cg" |
|
602 |
"Modified: / 16-02-2010 / 10:13:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
603 |
"Modified: / 06-07-2011 / 14:17:07 / cg" |
|
604 |
! |
|
605 |
||
4044 | 606 |
codeCompletionForVariable:node inClass:classOrNil codeView:codeView |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
607 |
|nonMetaClass crsrPos nm |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
608 |
allVariables allDistances best nodeVal |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
609 |
char start stop oldLen newLen oldVar |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
610 |
getDistanceComputeBlockWithWeight addWithFactorBlock names allTheBest bestAssoc |
3551
0c83710ae45e
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3550
diff
changeset
|
611 |
globalFactor localFactor selectorOfMessageToNode tree implementors argIdx namesUsed kwPart| |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
612 |
|
4044 | 613 |
classOrNil notNil ifTrue:[ |
614 |
nonMetaClass := classOrNil theNonMetaclass. |
|
615 |
]. |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
616 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
617 |
nm := node name. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
618 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
619 |
"/ if we are behind the variable and a space has already been entered, |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
620 |
"/ the user is probably looking for a message selector. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
621 |
"/ If the variable represents a global, present its instance creation messages |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
622 |
crsrPos := codeView characterPositionOfCursor. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
623 |
char := codeView characterAtCharacterPosition:crsrPos-1. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
624 |
char isSeparator ifTrue:[ |
4044 | 625 |
classOrNil isNil ifTrue:[ |
626 |
nodeVal := Smalltalk at:nm asSymbol. |
|
627 |
] ifFalse:[ |
|
628 |
nodeVal := classOrNil topNameSpace at:nm asSymbol ifAbsent:[Smalltalk at:nm asSymbol]. |
|
629 |
]. |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
630 |
nodeVal isBehavior ifTrue:[ |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
631 |
|methods menu exitKey idx| |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
632 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
633 |
methods := nodeVal class methodDictionary values |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
634 |
select:[:m | |cat| |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
635 |
cat := m category asLowercase. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
636 |
cat = 'instance creation' |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
637 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
638 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
639 |
menu := PopUpMenu labels:(methods collect:[:each | each selector]). |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
640 |
menu hideOnKeyFilter:[:key | |hide| |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
641 |
hide := ( #( CursorDown CursorUp Escape Return ) includes: key) not. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
642 |
hide ifTrue:[ |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
643 |
exitKey := key. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
644 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
645 |
hide]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
646 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
647 |
idx := menu startUp. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
648 |
idx == 0 ifTrue:[ |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
649 |
exitKey notNil ifTrue:[ |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
650 |
codeView keyPress:exitKey x:0 y:0. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
651 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
652 |
^ self |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
653 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
654 |
best := (methods at:idx) selector. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
655 |
codeView |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
656 |
undoableDo:[ |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
657 |
codeView insertString:best atCharacterPosition:crsrPos. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
658 |
codeView cursorToCharacterPosition:crsrPos+best size. |
3362 | 659 |
] |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
660 |
info:'completion'. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
661 |
^ self. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
662 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
663 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
664 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
665 |
(node parent notNil and:[node parent isMessage]) ifTrue:[ |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
666 |
node == node parent receiver ifTrue:[ |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
667 |
selectorOfMessageToNode := node parent selector |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
668 |
] |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
669 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
670 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
671 |
getDistanceComputeBlockWithWeight := |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
672 |
[:weight | |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
673 |
[:each | |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
674 |
|dist factor| |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
675 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
676 |
dist := each spellAgainst:nm. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
677 |
factor := 1. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
678 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
679 |
(each startsWith:nm) ifTrue:[ |
3551
0c83710ae45e
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3550
diff
changeset
|
680 |
factor := 6 * nm size. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
681 |
] ifFalse:[ |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
682 |
(each asLowercase startsWith:nm asLowercase) ifTrue:[ |
3551
0c83710ae45e
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3550
diff
changeset
|
683 |
factor := 4 * nm size. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
684 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
685 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
686 |
dist := dist + (weight*factor). |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
687 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
688 |
each -> (dist * weight) |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
689 |
] |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
690 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
691 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
692 |
addWithFactorBlock := |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
693 |
[:names :factor | |namesToAdd| |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
694 |
namesToAdd := names select:[:nameToAdd | nameToAdd ~= nm ]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
695 |
namesToAdd := namesToAdd reject:[:each | allVariables includes:each ]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
696 |
allVariables addAll:namesToAdd. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
697 |
allDistances addAll:(namesToAdd collect:(getDistanceComputeBlockWithWeight value:factor)). |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
698 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
699 |
|
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
700 |
nm isUppercaseFirst ifTrue:[ |
3551
0c83710ae45e
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3550
diff
changeset
|
701 |
globalFactor := 2. "/ favour globals |
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
702 |
localFactor := 1. |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
703 |
] ifFalse:[ |
3551
0c83710ae45e
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3550
diff
changeset
|
704 |
globalFactor := 1. "/ favour locals |
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
705 |
localFactor := 2. |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
706 |
]. |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
707 |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
708 |
allVariables := OrderedCollection new. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
709 |
allDistances := OrderedCollection new. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
710 |
|
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
711 |
"/ are we in the methods selector spec ? |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
712 |
(node parent notNil |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
713 |
and:[node parent isMethod |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
714 |
and:[node parent arguments includes:node]]) ifTrue:[ |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
715 |
"/ now thats cool: look how the naem of this argument is in other implementations |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
716 |
"/ of this method, and take that as a basis of the selection |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
717 |
|
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
718 |
implementors := SystemBrowser |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
719 |
findImplementorsOf:(node parent selector) |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
720 |
in:(Smalltalk allClasses) |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
721 |
ignoreCase:false. |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
722 |
"/ which argument is it |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
723 |
argIdx := node parent arguments indexOf:node. |
3554 | 724 |
implementors size > 50 ifTrue:[ |
725 |
implementors := implementors asOrderedCollection copyTo:50. |
|
726 |
]. |
|
3551
0c83710ae45e
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3550
diff
changeset
|
727 |
namesUsed := (implementors |
0c83710ae45e
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3550
diff
changeset
|
728 |
collect:[:eachImplementor | |
0c83710ae45e
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3550
diff
changeset
|
729 |
|parseTree| |
0c83710ae45e
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3550
diff
changeset
|
730 |
parseTree := eachImplementor parseTree. |
0c83710ae45e
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3550
diff
changeset
|
731 |
(parseTree notNil and:[parseTree arguments size > 0]) |
0c83710ae45e
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3550
diff
changeset
|
732 |
ifFalse:nil |
0c83710ae45e
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3550
diff
changeset
|
733 |
ifTrue:[ (parseTree arguments at:argIdx) name] ] |
0c83710ae45e
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3550
diff
changeset
|
734 |
thenSelect:[:a | a notNil]) asSet. |
0c83710ae45e
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3550
diff
changeset
|
735 |
|
0c83710ae45e
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3550
diff
changeset
|
736 |
addWithFactorBlock value:namesUsed value:(2 * localFactor). |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
737 |
|
4044 | 738 |
classOrNil notNil ifTrue:[ |
739 |
"/ also, look for the keyword before the argument, |
|
740 |
"/ and see if there is such an instVar |
|
741 |
"/ if so, add it with -Arg |
|
742 |
node parent selector isKeyword ifTrue:[ |
|
743 |
kwPart := node parent selector keywords at:argIdx. |
|
744 |
(classOrNil allInstVarNames includes:(kwPart copyWithoutLast:1)) ifTrue:[ |
|
745 |
addWithFactorBlock |
|
746 |
value:(classOrNil allInstVarNames collect:[:nm| nm,'Arg']) |
|
747 |
value:(1 * localFactor). |
|
748 |
]. |
|
3551
0c83710ae45e
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3550
diff
changeset
|
749 |
]. |
4044 | 750 |
] |
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
751 |
] ifFalse:[ |
4044 | 752 |
classOrNil notNil ifTrue:[ |
753 |
"/ locals in the block/method |
|
754 |
names := node allVariablesOnScope. |
|
755 |
"/ if there were no variables (due to a parse error) |
|
756 |
"/ do another parse and see what we have |
|
757 |
names isEmpty ifTrue:[ |
|
758 |
tree := self treeForCode:(codeView contentsAsString string) allowErrors:true. |
|
759 |
"/ better if we already have a body (include locals then) |
|
760 |
"/ otherwise, only the arguments are considered |
|
761 |
tree notNil ifTrue:[ |
|
762 |
names := (tree body ? tree) allVariablesOnScope. |
|
763 |
] |
|
764 |
]. |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
765 |
|
4044 | 766 |
addWithFactorBlock value:names value:(4 * localFactor). |
767 |
||
768 |
"/ instance variables |
|
769 |
addWithFactorBlock value:classOrNil instVarNames value:(3 * localFactor). |
|
3470
5cbf651bb214
name completion: care also for private class names
Claus Gittinger <cg@exept.de>
parents:
3366
diff
changeset
|
770 |
|
4044 | 771 |
"/ inherited instance variables |
772 |
classOrNil superclass notNil ifTrue:[ |
|
773 |
addWithFactorBlock value:classOrNil superclass allInstVarNames value:(2.5 * localFactor). |
|
774 |
]. |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
775 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
776 |
|
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
777 |
selectorOfMessageToNode notNil ifTrue:[ |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
778 |
|names responders nonResponders| |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
779 |
|
4044 | 780 |
"/ responding to that messsage |
781 |
||
782 |
classOrNil notNil ifTrue:[ |
|
783 |
"/ private classes |
|
784 |
addWithFactorBlock value:(nonMetaClass privateClasses collect:[:cls | cls nameWithoutPrefix]) |
|
785 |
value:(1.75 * globalFactor). |
|
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
786 |
|
4044 | 787 |
"/ class variables |
788 |
names := nonMetaClass classVarNames. |
|
789 |
responders := names select:[:classVar | (nonMetaClass classVarAt:classVar) respondsTo:selectorOfMessageToNode]. |
|
790 |
nonResponders := names reject:[:classVar | (nonMetaClass classVarAt:classVar) respondsTo:selectorOfMessageToNode]. |
|
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
791 |
|
4044 | 792 |
addWithFactorBlock value:responders value:(1.5 * globalFactor). |
793 |
addWithFactorBlock value:nonResponders value:(0.5 * 1.5 * globalFactor). |
|
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
794 |
|
4044 | 795 |
"/ superclass var names |
796 |
nonMetaClass allSuperclassesDo:[:superClass | |
|
797 |
names := superClass classVarNames. |
|
798 |
responders := names select:[:classVar | (superClass classVarAt:classVar) respondsTo:selectorOfMessageToNode]. |
|
799 |
nonResponders := names reject:[:classVar | (superClass classVarAt:classVar) respondsTo:selectorOfMessageToNode]. |
|
800 |
||
801 |
addWithFactorBlock value:responders value:(1 * globalFactor). |
|
802 |
addWithFactorBlock value:nonResponders value:(0.5 * 1 * globalFactor). |
|
803 |
]. |
|
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
804 |
|
4044 | 805 |
"/ namespace vars |
806 |
classOrNil nameSpace ~~ Smalltalk ifTrue:[ |
|
807 |
names := classOrNil topNameSpace keys. |
|
808 |
names := names reject:[:nm | nm includes:$:]. |
|
809 |
names := names select:[:nm | nm isUppercaseFirst ]. |
|
810 |
responders := names select:[:nsVar | |c| c := classOrNil topNameSpace at:nsVar. c isBehavior not or:[c isLoaded and:[c respondsTo:selectorOfMessageToNode]]]. |
|
811 |
nonResponders := names reject:[:nsVar | |c| c := classOrNil topNameSpace at:nsVar. c isBehavior not or:[c isLoaded and:[c respondsTo:selectorOfMessageToNode]]]. |
|
812 |
addWithFactorBlock value:responders value:(1.5 * globalFactor). |
|
813 |
addWithFactorBlock value:nonResponders value:(0.5 * 1.5 * globalFactor). |
|
814 |
]. |
|
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
815 |
]. |
3470
5cbf651bb214
name completion: care also for private class names
Claus Gittinger <cg@exept.de>
parents:
3366
diff
changeset
|
816 |
|
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
817 |
"/ globals |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
818 |
names := Smalltalk keys. |
3718 | 819 |
"/ names := names reject:[:nm | nm includes:$:]. |
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
820 |
names := names select:[:nm | nm isUppercaseFirst ]. |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
821 |
responders := names select:[:glblVar | |c| c := Smalltalk at:glblVar. c isBehavior not or:[c isLoaded and:[c respondsTo:selectorOfMessageToNode]]]. |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
822 |
nonResponders := names reject:[:glblVar | |c| c := Smalltalk at:glblVar. c isBehavior not or:[c isLoaded and:[c respondsTo:selectorOfMessageToNode]]]. |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
823 |
addWithFactorBlock value:responders value:(1.5 * globalFactor). |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
824 |
addWithFactorBlock value:nonResponders value:(0.5 * 1.5 * globalFactor). |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
825 |
] ifFalse:[ |
4044 | 826 |
classOrNil notNil ifTrue:[ |
827 |
"/ private classes |
|
828 |
addWithFactorBlock value:(nonMetaClass privateClasses collect:[:cls | cls nameWithoutPrefix]) |
|
829 |
value:(1.75 * globalFactor). |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
830 |
|
4044 | 831 |
"/ class variables |
832 |
addWithFactorBlock value:nonMetaClass classVarNames value:(1.5 * globalFactor). |
|
833 |
classOrNil superclass notNil ifTrue:[ |
|
834 |
addWithFactorBlock value:nonMetaClass superclass allClassVarNames value:(1 * globalFactor). |
|
835 |
]. |
|
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
836 |
|
4044 | 837 |
"/ namespace vars |
838 |
classOrNil nameSpace ~~ Smalltalk ifTrue:[ |
|
839 |
names := classOrNil nameSpace isNameSpace ifTrue:[classOrNil nameSpace keys] ifFalse:[classOrNil nameSpace privateClasses collect:[:c | c nameWithoutPrefix]]. |
|
840 |
names := names select:[:nm | nm isUppercaseFirst ]. |
|
841 |
addWithFactorBlock value:names value:(1.5 * globalFactor). |
|
842 |
]. |
|
3761
6584390d427d
dont forget pool variables when looking for the best variable match
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
843 |
|
4044 | 844 |
"/ pool variables |
845 |
classOrNil theNonMetaclass sharedPools do:[:poolName | |
|
846 |
|pool names| |
|
3761
6584390d427d
dont forget pool variables when looking for the best variable match
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
847 |
|
4044 | 848 |
pool := Smalltalk at:poolName. |
849 |
names := pool classVarNames. |
|
850 |
addWithFactorBlock value:names value:(1.5 * globalFactor). |
|
851 |
]. |
|
3761
6584390d427d
dont forget pool variables when looking for the best variable match
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
852 |
]. |
6584390d427d
dont forget pool variables when looking for the best variable match
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
853 |
|
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
854 |
"/ globals |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
855 |
names := Smalltalk keys. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
856 |
names := names select:[:nm | nm isUppercaseFirst ]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
857 |
addWithFactorBlock value:names value:(1.5 * globalFactor). |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
858 |
]. |
3550
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
859 |
|
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
860 |
"/ pseudos - assuming that thisContext is seldom used. |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
861 |
"/ also assuming, that nil is short so its usually typed in. |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
862 |
addWithFactorBlock value:#('self') value:(2.5 * localFactor). |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
863 |
addWithFactorBlock value:#('nil') value:(0.5 * localFactor). |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
864 |
addWithFactorBlock value:#('super' 'false') value:(2 * localFactor). |
34c8ab9f403f
much better method-argument-name completion
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
865 |
addWithFactorBlock value:#('thisContext') value:(1 * localFactor). |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
866 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
867 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
868 |
bestAssoc := allDistances at:1. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
869 |
bestAssoc := allDistances inject:bestAssoc into:[:el :best | el value > best value |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
870 |
ifTrue:[el] |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
871 |
ifFalse:[best] |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
872 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
873 |
|
3660 | 874 |
allDistances sort:[:a :b | |
875 |
a value > b value ifTrue:[ |
|
876 |
true |
|
877 |
] ifFalse:[ |
|
878 |
a value = b value ifTrue:[ |
|
879 |
a key < b key |
|
880 |
] ifFalse:[ |
|
881 |
false |
|
882 |
] |
|
883 |
] |
|
884 |
]. |
|
3554 | 885 |
allTheBest := allDistances select:[:entry | entry value >= (bestAssoc value * 0.5)]. |
886 |
allTheBest size > 15 ifTrue:[ |
|
887 |
allTheBest := allDistances select:[:entry | entry value >= (bestAssoc value * 0.8)]. |
|
888 |
]. |
|
4047
bd93629fe049
changed: #codeCompletionForVariable:inClass:codeView:
Claus Gittinger <cg@exept.de>
parents:
4045
diff
changeset
|
889 |
|
4044 | 890 |
best := self askUserForCompletion:'variable' for:codeView at: node start from:(allTheBest collect:[:assoc | assoc key]). |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
891 |
best isNil ifTrue:[^ self]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
892 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
893 |
"/ self showInfo:best. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
894 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
895 |
start := node start. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
896 |
stop := node stop. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
897 |
oldVar := (codeView textFromCharacterPosition:start to:stop) asString string withoutSeparators. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
898 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
899 |
codeView |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
900 |
undoableDo:[ codeView replaceFromCharacterPosition:start to:stop with:best ] |
3600 | 901 |
info:'Completion'. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
902 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
903 |
(best startsWith:oldVar) ifTrue:[ |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
904 |
oldLen := stop - start + 1. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
905 |
newLen := best size. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
906 |
codeView selectFromCharacterPosition:start+oldLen to:start+newLen-1. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
907 |
codeView dontReplaceSelectionOnInput |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
908 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
909 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
910 |
"Created: / 10-11-2006 / 13:16:33 / cg" |
4044 | 911 |
"Modified: / 16-02-2010 / 10:13:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4047
bd93629fe049
changed: #codeCompletionForVariable:inClass:codeView:
Claus Gittinger <cg@exept.de>
parents:
4045
diff
changeset
|
912 |
"Modified: / 05-07-2011 / 10:09:52 / cg" |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
913 |
! |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
914 |
|
3300 | 915 |
findNodeForInterval:interval in:source |
916 |
|tree node| |
|
917 |
||
918 |
interval isEmpty ifTrue: [^ nil]. |
|
919 |
RBParser isNil ifTrue: [^ nil]. |
|
920 |
||
3475
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
921 |
source = LastSource ifTrue:[ |
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
922 |
tree := LastParseTree. |
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
923 |
] ifFalse:[ |
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
924 |
tree := RBParser |
3300 | 925 |
parseMethod:source |
4050 | 926 |
onError: |
927 |
[:str :err ":nodesSoFar" | |
|
928 |
"Transcript showCR:'Parse-Error: ',str." |
|
929 |
nil |
|
930 |
]. |
|
3905
ad2810a7e3de
comment/format in: #findNodeForInterval:in:
Claus Gittinger <cg@exept.de>
parents:
3901
diff
changeset
|
931 |
|
4050 | 932 |
tree isNil ifTrue:[ |
933 |
"/ try to parse as an expression |
|
934 |
tree := RBParser |
|
935 |
parseExpression:source |
|
936 |
onError: |
|
937 |
[:str :err ":nodesSoFar" | |
|
938 |
"Transcript showCR:'Parse-Error: ',str." |
|
939 |
nil |
|
940 |
]. |
|
941 |
||
942 |
tree isNil ifTrue:[ |
|
943 |
^ nil |
|
944 |
]. |
|
945 |
]. |
|
3300 | 946 |
|
3475
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
947 |
LastSource := source. |
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
948 |
LastParseTree := tree. |
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
949 |
]. |
3300 | 950 |
|
951 |
node := tree whichNodeIsContainedBy:interval. |
|
952 |
node isNil ifTrue: [ |
|
3475
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
953 |
node := tree bestNodeFor: interval. |
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
954 |
node isNil ifTrue: [ |
3734 | 955 |
node := self findNodeIn:tree forInterval:interval |
3475
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
956 |
]. |
3300 | 957 |
]. |
958 |
^ node |
|
959 |
||
4050 | 960 |
"Modified: / 06-07-2011 / 12:42:53 / cg" |
3300 | 961 |
! |
962 |
||
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
963 |
findNodeForInterval:interval in:source allowErrors:allowErrors |
4050 | 964 |
|tree "errCount" firstIntersectingNode onErrorBlock nodeGenerationHook| |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
965 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
966 |
interval isEmpty ifTrue: [^ nil]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
967 |
RBParser isNil ifTrue: [^ nil]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
968 |
|
3475
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
969 |
source = LastSource ifTrue:[ |
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
970 |
tree := LastParseTree. |
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
971 |
] ifFalse:[ |
4050 | 972 |
onErrorBlock := |
973 |
[:str :err :nodesSoFar | |
|
974 |
|nodes| |
|
975 |
||
976 |
allowErrors ifTrue:[ |
|
977 |
firstIntersectingNode notNil ifTrue:[^ firstIntersectingNode]. |
|
978 |
nodes := nodesSoFar asOrderedCollection |
|
979 |
collect:[:nd | nd whichNodeIntersects:interval] |
|
980 |
thenSelect:[:nd | nd notNil ]. |
|
981 |
nodes size == 1 ifTrue:[ |
|
982 |
^ nodes first |
|
983 |
]. |
|
984 |
]. |
|
985 |
nil |
|
986 |
]. |
|
987 |
||
988 |
nodeGenerationHook := |
|
989 |
[:node | |
|
990 |
"/ we would like to return here as soon as the node has been created by the parser; |
|
991 |
"/ however, at that time, its parent(chain) is not yet created and so we might not know |
|
992 |
"/ what the semantic intepretation (especially: scope of variable) will be. |
|
993 |
"/ therefore, we parse all, and return the found node at the end. |
|
994 |
"//// ^ node. |
|
995 |
firstIntersectingNode isNil ifTrue:[ |
|
996 |
(node intersectsInterval:interval) ifTrue:[ |
|
997 |
firstIntersectingNode := node |
|
998 |
]. |
|
999 |
]. |
|
1000 |
]. |
|
1001 |
||
3475
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
1002 |
tree := RBParser |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1003 |
parseMethod:source |
4050 | 1004 |
onError: onErrorBlock |
3720
f37c0d1757e3
use new rbparser callback-as-nodes-are-generated to find a node
Claus Gittinger <cg@exept.de>
parents:
3718
diff
changeset
|
1005 |
rememberNodes:true |
4050 | 1006 |
nodeGenerationCallback:nodeGenerationHook. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1007 |
"/ onError: [:str :err | errCount := (errCount?0) + 1. self halt.] |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1008 |
"/ proceedAfterError:true. |
3751 | 1009 |
|
4050 | 1010 |
(tree isNil or:[firstIntersectingNode isNil]) ifTrue:[ |
1011 |
"/ try as an expression |
|
1012 |
tree := RBParser |
|
1013 |
parseExpression:source |
|
1014 |
onError: onErrorBlock |
|
1015 |
rememberNodes:true |
|
1016 |
nodeGenerationCallback:nodeGenerationHook. |
|
1017 |
]. |
|
1018 |
||
3751 | 1019 |
tree notNil ifTrue:[ |
1020 |
LastSource := source. |
|
1021 |
LastParseTree := tree. |
|
1022 |
]. |
|
1023 |
^ firstIntersectingNode |
|
3475
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
1024 |
]. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1025 |
|
3306
40e860fd2f02
argument-name completion in a methods selector pattern
Claus Gittinger <cg@exept.de>
parents:
3303
diff
changeset
|
1026 |
^ self findNodeForInterval:interval inParseTree:tree. |
3896
9a5437a71fdb
comment/format in: #findNodeForInterval:in:allowErrors:
Claus Gittinger <cg@exept.de>
parents:
3895
diff
changeset
|
1027 |
|
4050 | 1028 |
"Modified: / 06-07-2011 / 13:56:06 / cg" |
3306
40e860fd2f02
argument-name completion in a methods selector pattern
Claus Gittinger <cg@exept.de>
parents:
3303
diff
changeset
|
1029 |
! |
40e860fd2f02
argument-name completion in a methods selector pattern
Claus Gittinger <cg@exept.de>
parents:
3303
diff
changeset
|
1030 |
|
40e860fd2f02
argument-name completion in a methods selector pattern
Claus Gittinger <cg@exept.de>
parents:
3303
diff
changeset
|
1031 |
findNodeForInterval:interval inParseTree:parseTree |
40e860fd2f02
argument-name completion in a methods selector pattern
Claus Gittinger <cg@exept.de>
parents:
3303
diff
changeset
|
1032 |
|node| |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1033 |
|
3306
40e860fd2f02
argument-name completion in a methods selector pattern
Claus Gittinger <cg@exept.de>
parents:
3303
diff
changeset
|
1034 |
interval isEmpty ifTrue: [^ nil]. |
40e860fd2f02
argument-name completion in a methods selector pattern
Claus Gittinger <cg@exept.de>
parents:
3303
diff
changeset
|
1035 |
parseTree isNil ifTrue:[^ nil]. |
40e860fd2f02
argument-name completion in a methods selector pattern
Claus Gittinger <cg@exept.de>
parents:
3303
diff
changeset
|
1036 |
|
40e860fd2f02
argument-name completion in a methods selector pattern
Claus Gittinger <cg@exept.de>
parents:
3303
diff
changeset
|
1037 |
node := parseTree whichNodeIsContainedBy:interval. |
3475
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
1038 |
node isNil ifTrue:[ |
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
1039 |
node := parseTree whichNodeIntersects:interval. |
3680 | 1040 |
node isNil ifTrue: [ |
1041 |
node := self findNodeIn:parseTree forInterval:interval |
|
1042 |
]. |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1043 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1044 |
^ node |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1045 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1046 |
"Modified: / 10-11-2006 / 13:13:58 / cg" |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1047 |
! |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1048 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1049 |
findNodeIn:tree forInterval:interval |
3734 | 1050 |
|nodeFound wouldReturn| |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1051 |
|
3734 | 1052 |
nodeFound := nil. |
1053 |
tree nodesDo:[:eachNode | |
|
1054 |
(eachNode intersectsInterval:interval) ifTrue:[ |
|
1055 |
(nodeFound isNil or:[nodeFound == eachNode parent]) ifTrue:[ |
|
1056 |
nodeFound := eachNode |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1057 |
] ifFalse:[ |
3734 | 1058 |
(nodeFound parent == eachNode parent |
1059 |
and:[ eachNode start >= nodeFound start |
|
1060 |
and:[ eachNode stop <= nodeFound stop ] ]) ifTrue:[ |
|
1061 |
] ifFalse:[ |
|
1062 |
(nodeFound parent notNil |
|
1063 |
and:[nodeFound parent isCascade and:[eachNode parent isCascade]]) ifFalse:[^ nil] |
|
1064 |
] |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1065 |
] |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1066 |
] ifFalse:[ |
3734 | 1067 |
nodeFound notNil ifTrue:[ |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1068 |
"/ already found one - beyond that one; leave |
3734 | 1069 |
wouldReturn notNil ifTrue:[wouldReturn := nodeFound]. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1070 |
] |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1071 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1072 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1073 |
"/ (wouldReturn notNil and:[wouldReturn ~~ node]) ifTrue:[self halt]. |
3734 | 1074 |
^ nodeFound |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1075 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1076 |
"Modified: / 20-11-2006 / 12:31:12 / cg" |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1077 |
! |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1078 |
|
4050 | 1079 |
lookupClassForMessage:node inClass:classProvidingNamespaceOrNil |
3681
6dca6308d156
better selector completion for (class new) receivers
Claus Gittinger <cg@exept.de>
parents:
3680
diff
changeset
|
1080 |
|receiver nm nodeVal receiverClass| |
3356
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1081 |
|
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1082 |
receiver := node receiver. |
4050 | 1083 |
receiver isLiteral ifTrue:[ |
1084 |
^ receiver value class |
|
1085 |
]. |
|
3356
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1086 |
receiver isVariable ifTrue:[ |
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1087 |
nm := receiver name. |
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1088 |
nm = 'self' ifTrue:[ |
4050 | 1089 |
classProvidingNamespaceOrNil isNil ifTrue:[^ UndefinedObject]. |
1090 |
^ classProvidingNamespaceOrNil |
|
3356
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1091 |
]. |
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1092 |
nm = 'super' ifTrue:[ |
4050 | 1093 |
classProvidingNamespaceOrNil isNil ifTrue:[^ Object]. |
1094 |
^ classProvidingNamespaceOrNil superclass |
|
3356
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1095 |
]. |
3734 | 1096 |
nm isUppercaseFirst ifTrue:[ |
3356
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1097 |
"/ wouldn't it be better to simply 'evaluate' the variable ? |
3929 | 1098 |
Error handle:[:ex | |
1099 |
] do:[ |
|
4050 | 1100 |
|dummyReceiver| |
1101 |
||
1102 |
dummyReceiver := classProvidingNamespaceOrNil notNil ifTrue:[classProvidingNamespaceOrNil basicNew] ifFalse:[nil]. |
|
1103 |
nodeVal := Parser new evaluate:nm in:nil receiver:dummyReceiver. |
|
3929 | 1104 |
]. |
3356
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1105 |
"/ (Smalltalk includesKey:nm asSymbol) ifTrue:[ |
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1106 |
"/ nodeVal := Smalltalk at:nm asSymbol. |
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1107 |
"/ ]. |
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1108 |
nodeVal notNil ifTrue:[ |
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1109 |
^ nodeVal class |
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1110 |
] |
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1111 |
] |
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1112 |
]. |
4050 | 1113 |
|
3681
6dca6308d156
better selector completion for (class new) receivers
Claus Gittinger <cg@exept.de>
parents:
3680
diff
changeset
|
1114 |
receiver isMessage ifTrue:[ |
6dca6308d156
better selector completion for (class new) receivers
Claus Gittinger <cg@exept.de>
parents:
3680
diff
changeset
|
1115 |
(receiver selector = 'new' |
6dca6308d156
better selector completion for (class new) receivers
Claus Gittinger <cg@exept.de>
parents:
3680
diff
changeset
|
1116 |
or:[ receiver selector = 'new:' ]) ifTrue:[ |
4050 | 1117 |
receiverClass := self lookupClassForMessage:receiver inClass:classProvidingNamespaceOrNil. |
3681
6dca6308d156
better selector completion for (class new) receivers
Claus Gittinger <cg@exept.de>
parents:
3680
diff
changeset
|
1118 |
receiverClass notNil ifTrue:[ |
6dca6308d156
better selector completion for (class new) receivers
Claus Gittinger <cg@exept.de>
parents:
3680
diff
changeset
|
1119 |
receiverClass isBehavior ifTrue:[ |
6dca6308d156
better selector completion for (class new) receivers
Claus Gittinger <cg@exept.de>
parents:
3680
diff
changeset
|
1120 |
receiverClass isMeta ifTrue:[ |
6dca6308d156
better selector completion for (class new) receivers
Claus Gittinger <cg@exept.de>
parents:
3680
diff
changeset
|
1121 |
^ receiverClass theNonMetaclass |
6dca6308d156
better selector completion for (class new) receivers
Claus Gittinger <cg@exept.de>
parents:
3680
diff
changeset
|
1122 |
] |
6dca6308d156
better selector completion for (class new) receivers
Claus Gittinger <cg@exept.de>
parents:
3680
diff
changeset
|
1123 |
] |
6dca6308d156
better selector completion for (class new) receivers
Claus Gittinger <cg@exept.de>
parents:
3680
diff
changeset
|
1124 |
]. |
6dca6308d156
better selector completion for (class new) receivers
Claus Gittinger <cg@exept.de>
parents:
3680
diff
changeset
|
1125 |
]. |
4058 | 1126 |
classProvidingNamespaceOrNil notNil ifTrue:[ |
1127 |
(receiver receiver isSelf and:[receiver selector = 'class']) ifTrue:[ |
|
1128 |
^ classProvidingNamespaceOrNil class |
|
1129 |
]. |
|
1130 |
]. |
|
3681
6dca6308d156
better selector completion for (class new) receivers
Claus Gittinger <cg@exept.de>
parents:
3680
diff
changeset
|
1131 |
]. |
3356
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1132 |
^ nil |
3929 | 1133 |
|
1134 |
"Modified: / 24-08-2010 / 15:05:49 / sr" |
|
4058 | 1135 |
"Modified: / 17-07-2011 / 10:28:19 / cg" |
3356
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1136 |
! |
b1e3ccd1bcf2
better messageSelector completion
Claus Gittinger <cg@exept.de>
parents:
3331
diff
changeset
|
1137 |
|
4051 | 1138 |
old_askUserForCompletion:what for:codeView from:allTheBest |
1139 |
|list resources choice lastChoice| |
|
1140 |
||
1141 |
allTheBest isEmpty ifTrue:[ ^ nil ]. |
|
1142 |
allTheBest size == 1 ifTrue:[ ^ allTheBest first ]. |
|
1143 |
||
1144 |
list := allTheBest. |
|
1145 |
LastChoices notNil ifTrue:[ |
|
1146 |
lastChoice := LastChoices at:what ifAbsent:nil. |
|
1147 |
lastChoice notNil ifTrue:[ |
|
1148 |
list := {lastChoice. nil. } , (list copyWithout:lastChoice). |
|
1149 |
]. |
|
1150 |
]. |
|
1151 |
||
1152 |
list size < 30 ifTrue:[ |
|
1153 |
|menu idx exitKey| |
|
1154 |
||
1155 |
menu := PopUpMenu labels:list. |
|
1156 |
menu hideOnKeyFilter:[:key | |hide| |
|
1157 |
hide := ( #( CursorDown CursorUp Escape Return ) includes: key) not. |
|
1158 |
hide ifTrue:[ |
|
1159 |
exitKey := key. |
|
1160 |
]. |
|
1161 |
hide]. |
|
1162 |
||
1163 |
idx := menu startUp. |
|
1164 |
idx == 0 ifTrue:[ |
|
1165 |
exitKey notNil ifTrue:[ |
|
1166 |
codeView keyPress:exitKey x:0 y:0. |
|
1167 |
]. |
|
1168 |
^ nil |
|
1169 |
]. |
|
1170 |
choice := list at:idx. |
|
1171 |
] ifFalse:[ |
|
1172 |
resources := codeView application isNil |
|
1173 |
ifTrue:[ codeView resources] |
|
1174 |
ifFalse:[ codeView application resources ]. |
|
1175 |
||
1176 |
choice := Dialog |
|
1177 |
choose:(resources string:'Choose ',what) |
|
1178 |
fromList:list |
|
1179 |
lines:20 |
|
1180 |
title:(resources string:'Code completion'). |
|
1181 |
choice isNil ifTrue:[^ nil]. |
|
1182 |
]. |
|
1183 |
||
1184 |
LastChoices isNil ifTrue:[ |
|
1185 |
LastChoices := Dictionary new. |
|
1186 |
]. |
|
1187 |
LastChoices at:what put:choice. |
|
1188 |
^ choice |
|
1189 |
||
1190 |
"Created: / 16-02-2010 / 09:38:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1191 |
! |
|
1192 |
||
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1193 |
treeForCode:source allowErrors:allowErrors |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1194 |
|tree| |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1195 |
|
3475
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
1196 |
source = LastSource ifTrue:[ |
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
1197 |
tree := LastParseTree. |
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
1198 |
] ifFalse:[ |
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
1199 |
tree := RBParser |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1200 |
parseMethod:source |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1201 |
onError: [:str :err :nodesSoFar :parser| |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1202 |
allowErrors ifTrue:[ |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1203 |
^ parser currentMethodNode |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1204 |
]. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1205 |
^ nil |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1206 |
] |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1207 |
proceedAfterError:false |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1208 |
rememberNodes:true. |
3896
9a5437a71fdb
comment/format in: #findNodeForInterval:in:allowErrors:
Claus Gittinger <cg@exept.de>
parents:
3895
diff
changeset
|
1209 |
|
9a5437a71fdb
comment/format in: #findNodeForInterval:in:allowErrors:
Claus Gittinger <cg@exept.de>
parents:
3895
diff
changeset
|
1210 |
tree notNil ifTrue:[ |
9a5437a71fdb
comment/format in: #findNodeForInterval:in:allowErrors:
Claus Gittinger <cg@exept.de>
parents:
3895
diff
changeset
|
1211 |
LastSource := source. |
9a5437a71fdb
comment/format in: #findNodeForInterval:in:allowErrors:
Claus Gittinger <cg@exept.de>
parents:
3895
diff
changeset
|
1212 |
LastParseTree := tree. |
9a5437a71fdb
comment/format in: #findNodeForInterval:in:allowErrors:
Claus Gittinger <cg@exept.de>
parents:
3895
diff
changeset
|
1213 |
] |
3475
8ed28a1e4e37
cache last parse tree (for flyByHelp)
Claus Gittinger <cg@exept.de>
parents:
3470
diff
changeset
|
1214 |
]. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1215 |
^ tree |
3896
9a5437a71fdb
comment/format in: #findNodeForInterval:in:allowErrors:
Claus Gittinger <cg@exept.de>
parents:
3895
diff
changeset
|
1216 |
|
9a5437a71fdb
comment/format in: #findNodeForInterval:in:allowErrors:
Claus Gittinger <cg@exept.de>
parents:
3895
diff
changeset
|
1217 |
"Modified: / 27-04-2010 / 17:57:37 / cg" |
2376 | 1218 |
! ! |
1219 |
||
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1220 |
!DoWhatIMeanSupport class methodsFor:'input completion support'! |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1221 |
|
2975 | 1222 |
classCategoryCompletion:aPartialCategory inEnvironment:anEnvironment |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1223 |
"given a partial class category name, return an array consisting of |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1224 |
2 entries: 1st: the best (longest) match |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1225 |
2nd: collection consisting of matching categories" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1226 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1227 |
|matches best lcName| |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1228 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1229 |
matches := IdentitySet new. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1230 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1231 |
"/ search for exact match |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1232 |
anEnvironment allClassesDo:[:aClass | |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1233 |
|category| |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1234 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1235 |
category := aClass category. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1236 |
(category notNil and:[category startsWith:aPartialCategory]) ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1237 |
matches add:category |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1238 |
] |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1239 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1240 |
matches isEmpty ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1241 |
"/ search for case-ignoring match |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1242 |
lcName := aPartialCategory asLowercase. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1243 |
anEnvironment allClassesDo:[:aClass | |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1244 |
|category| |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1245 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1246 |
category := aClass category. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1247 |
(category notNil and:[category asLowercase startsWith:lcName]) ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1248 |
matches add:category |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1249 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1250 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1251 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1252 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1253 |
matches isEmpty ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1254 |
^ Array with:aPartialCategory with:(Array with:aPartialCategory) |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1255 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1256 |
matches size == 1 ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1257 |
^ Array with:matches first with:(matches asArray) |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1258 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1259 |
matches := matches asSortedCollection. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1260 |
best := matches longestCommonPrefix. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1261 |
^ Array with:best with:matches asArray |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1262 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1263 |
" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1264 |
Smalltalk classCategoryCompletion:'Sys' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1265 |
Smalltalk classCategoryCompletion:'System' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1266 |
Smalltalk classCategoryCompletion:'System-BinaryStorage' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1267 |
" |
2975 | 1268 |
|
1269 |
"Created: / 10-08-2006 / 13:06:45 / cg" |
|
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1270 |
! |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1271 |
|
2830 | 1272 |
classNameEntryCompletionBlock |
1273 |
"this block can be used in a dialog to perform className completion" |
|
1274 |
||
2977 | 1275 |
^ self entryCompletionBlockFor:#'classnameCompletion:inEnvironment:' |
2830 | 1276 |
|
2977 | 1277 |
"Modified: / 10-08-2006 / 13:22:02 / cg" |
2830 | 1278 |
! |
1279 |
||
2975 | 1280 |
classnameCompletion:aPartialClassName filter:filterBlock inEnvironment:anEnvironment |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1281 |
"given a partial classname, return an array consisting of |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1282 |
2 entries: 1st: the best (longest) match |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1283 |
2nd: collection consisting of matching names" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1284 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1285 |
|searchName matches matchedNamesWithoutPrefix ignCaseMatches best isMatchString cls nsPrefix |
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1286 |
others lcSearchName tryToMatch idx words w1 w2 rslt bestMatch matchesForLongestPrefix| |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1287 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1288 |
aPartialClassName isEmpty ifTrue:[ |
2975 | 1289 |
matches := Smalltalk allClassesForWhich:filterBlock. |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1290 |
^ InputCompletionResult bestName:aPartialClassName matchingNames:#() |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1291 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1292 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1293 |
(words := aPartialClassName asCollectionOfWords) size > 1 ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1294 |
w1 := words first. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1295 |
w2 := words second. |
2975 | 1296 |
rslt := self classnameCompletion:w1 filter:filterBlock inEnvironment:anEnvironment. |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1297 |
bestMatch := rslt first. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1298 |
matches := rslt second. |
3549 | 1299 |
('class' copyTo:(w2 size min:5)) = w2 ifTrue:[ |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1300 |
matches := matches collect:[:m | m , ' class']. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1301 |
bestMatch := bestMatch , ' class'. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1302 |
]. |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1303 |
^ InputCompletionResult bestName:bestMatch matchingNames:matches |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1304 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1305 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1306 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1307 |
(aPartialClassName startsWith:'Smalltalk::') ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1308 |
nsPrefix := 'Smalltalk::'. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1309 |
searchName := aPartialClassName copyFrom:'Smalltalk::' size + 1 |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1310 |
] ifFalse:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1311 |
nsPrefix := ''. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1312 |
searchName := aPartialClassName. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1313 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1314 |
|
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1315 |
searchName := searchName asUppercaseFirst. |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1316 |
lcSearchName := searchName asLowercase. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1317 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1318 |
isMatchString := searchName includesMatchCharacters. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1319 |
matches := OrderedCollection new. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1320 |
matchedNamesWithoutPrefix := Set new. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1321 |
ignCaseMatches := OrderedCollection new. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1322 |
others := OrderedCollection new. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1323 |
|
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1324 |
tryToMatch := |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1325 |
[:className :fullClassName| |
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1326 |
|addIt| |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1327 |
"/ (className startsWith:'JavaScript') ifTrue:[self halt]. |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1328 |
isMatchString ifTrue:[ |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1329 |
addIt := searchName match:className |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1330 |
] ifFalse:[ |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1331 |
addIt := className startsWith:searchName. |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1332 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1333 |
addIt ifTrue:[ |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1334 |
matches add:(nsPrefix , fullClassName). |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1335 |
matchedNamesWithoutPrefix add:className. |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1336 |
] ifFalse:[ |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1337 |
"/ try ignoring case |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1338 |
|
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1339 |
isMatchString ifTrue:[ |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1340 |
addIt := searchName match:className ignoreCase:true |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1341 |
] ifFalse:[ |
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1342 |
addIt := className asLowercase startsWith:lcSearchName. |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1343 |
addIt ifFalse:[ |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1344 |
others add:className |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1345 |
] |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1346 |
]. |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1347 |
addIt ifTrue:[ |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1348 |
ignCaseMatches add:(nsPrefix , fullClassName). |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1349 |
matchedNamesWithoutPrefix add:className. |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1350 |
]. |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1351 |
]. |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1352 |
addIt |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1353 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1354 |
|
2975 | 1355 |
anEnvironment allClassesForWhich:filterBlock do:[:aClass | |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1356 |
|addIt fullClassName classNameWithoutPrefix| |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1357 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1358 |
aClass isMeta ifFalse:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1359 |
fullClassName := aClass name. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1360 |
classNameWithoutPrefix := aClass nameWithoutPrefix. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1361 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1362 |
addIt := tryToMatch value:fullClassName value:fullClassName. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1363 |
addIt ifFalse:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1364 |
classNameWithoutPrefix ~~ fullClassName ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1365 |
tryToMatch value:classNameWithoutPrefix value:fullClassName. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1366 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1367 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1368 |
] |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1369 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1370 |
|
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1371 |
"/ matches isEmpty ifTrue:[ |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1372 |
"/ matches := ignCaseMatches. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1373 |
"/ ]. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1374 |
matches := matches , ignCaseMatches. |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1375 |
|
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1376 |
"/ matches isEmpty ifTrue:[ |
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1377 |
"/ matches := ignCaseMatches. |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1378 |
"/ |
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1379 |
"/"/ matches isEmpty ifTrue:[ |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1380 |
"/"/ | nearBy | |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1381 |
"/"/ nearBy := SortedCollection new sortBlock:[:a :b | a key < b key]. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1382 |
"/"/ others do:[:className | |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1383 |
"/"/ |lcClassName dist cmpName| |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1384 |
"/"/ |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1385 |
"/"/ lcClassName := className asLowercase. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1386 |
"/"/ dist := lcClassName levenshteinTo:lcSearchName s:9 k:1 c:0 i:9 d:2. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1387 |
"/"/ |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1388 |
"/"/ cmpName := lcClassName copyTo:(lcSearchName size min:lcClassName size). |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1389 |
"/"/ dist := dist min:(cmpName levenshteinTo:lcSearchName s:9 k:1 c:0 i:9 d:2). |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1390 |
"/"/ cmpName := lcClassName copyTo:(lcSearchName size + 1 min:lcClassName size). |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1391 |
"/"/ dist := dist min:(cmpName levenshteinTo:lcSearchName s:9 k:1 c:0 i:9 d:2). |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1392 |
"/"/ dist < 4 ifTrue:[ |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1393 |
"/"/ nearBy add:( dist -> (nsPrefix , className) ). |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1394 |
"/"/ ] |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1395 |
"/"/ ]. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1396 |
"/"/ matches := nearBy collect:[:eachPair | eachPair value]. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1397 |
"/"/ ]. |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1398 |
"/ ]. |
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1399 |
|
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1400 |
matches isEmpty ifTrue:[ |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1401 |
^ InputCompletionResult bestName:searchName matchingNames:(Array with:searchName) |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1402 |
]. |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1403 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1404 |
matches size == 1 ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1405 |
best := matches first. |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1406 |
^ InputCompletionResult bestName:best matchingNames:(matches asArray) |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1407 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1408 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1409 |
matches |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1410 |
sort:[:name1 :name2 | |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1411 |
"name1 comes before:name2 iff" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1412 |
((name2 includes:$:) and:[(name1 includes:$:) not]) |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1413 |
or:[ ((name1 includes:$:) == (name2 includes:$:)) |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1414 |
and:[ (name1 size < name2 size) |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1415 |
or: [ name1 < name2 ]] |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1416 |
] |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1417 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1418 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1419 |
isMatchString ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1420 |
best := searchName. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1421 |
] ifFalse:[ |
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1422 |
matchesForLongestPrefix := matches select:[:m | m asLowercase startsWith:lcSearchName]. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1423 |
best := ignCaseMatches isEmpty |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1424 |
ifTrue:[ matchesForLongestPrefix longestCommonPrefix ] |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1425 |
ifFalse:[ matchesForLongestPrefix longestCommonPrefixIgnoreCase:true ]. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1426 |
|
3198
fea29ae859c9
classnamecompletion fixed when namespace is involved
Claus Gittinger <cg@exept.de>
parents:
3135
diff
changeset
|
1427 |
best size < aPartialClassName size "best size == 0" ifTrue:[ |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1428 |
best := matchedNamesWithoutPrefix longestCommonPrefix. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1429 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1430 |
best size == 0 ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1431 |
"if tried again, return next match" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1432 |
idx := ((matches indexOf:aPartialClassName) + 1) \\ matches size. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1433 |
idx ~~ 1 ifTrue:[ |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1434 |
^ InputCompletionResult bestName:(matches at:idx) matchingNames:(matches asArray) |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1435 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1436 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1437 |
best size < aPartialClassName size ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1438 |
best := aPartialClassName. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1439 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1440 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1441 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1442 |
cls := anEnvironment classNamed:best. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1443 |
(cls isBehavior and:[cls isNameSpace]) ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1444 |
(matches conform:[:each | each = best |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1445 |
or:[each startsWith:(best , '::')]]) |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1446 |
ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1447 |
best := best , '::' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1448 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1449 |
]. |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1450 |
^ InputCompletionResult bestName:best matchingNames:matches asArray |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1451 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1452 |
" |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1453 |
Smalltalk classnameCompletion:'Arr' |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1454 |
Smalltalk classnameCompletion:'Arra' |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1455 |
Smalltalk classnameCompletion:'arra' |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1456 |
Smalltalk classnameCompletion:'*rray' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1457 |
" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1458 |
|
2975 | 1459 |
"Created: / 10-08-2006 / 13:01:08 / cg" |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1460 |
! |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1461 |
|
2975 | 1462 |
classnameCompletion:aPartialClassName inEnvironment:anEnvironment |
1463 |
"given a partial classname, return an array consisting of |
|
1464 |
2 entries: 1st: the best (longest) match |
|
1465 |
2nd: collection consisting of matching names" |
|
1466 |
||
1467 |
^ self |
|
1468 |
classnameCompletion:aPartialClassName |
|
1469 |
filter:[:cls | true] |
|
1470 |
inEnvironment:anEnvironment |
|
1471 |
||
1472 |
" |
|
1473 |
Smalltalk classnameCompletion:'Arr' |
|
1474 |
Smalltalk classnameCompletion:'Arra' |
|
1475 |
Smalltalk classnameCompletion:'arra' |
|
1476 |
Smalltalk classnameCompletion:'*rray' |
|
1477 |
" |
|
1478 |
||
1479 |
"Created: / 24-11-1995 / 17:24:45 / cg" |
|
1480 |
"Modified: / 10-08-2006 / 13:01:30 / cg" |
|
1481 |
! |
|
1482 |
||
2977 | 1483 |
entryCompletionBlockFor:completionSelector |
1484 |
"this block can be used in a dialog to perform className completion" |
|
1485 |
||
1486 |
^ [:contents :field | |
|
1487 |
|s what m| |
|
1488 |
||
1489 |
s := contents withoutSpaces. |
|
1490 |
field topView withCursor:(Cursor questionMark) do:[ |
|
1491 |
what := self perform:completionSelector with:s with:Smalltalk. |
|
1492 |
]. |
|
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
1493 |
|
2977 | 1494 |
field contents:(what first). |
1495 |
(what at:2) size ~~ 1 ifTrue:[ |
|
3693 | 1496 |
UserPreferences current beepInEditor ifTrue:[ |
1497 |
field device beep |
|
1498 |
] |
|
2977 | 1499 |
] |
1500 |
]. |
|
1501 |
||
1502 |
"Created: / 10-08-2006 / 13:21:37 / cg" |
|
1503 |
! |
|
1504 |
||
2975 | 1505 |
globalNameCompletion:aPartialGlobalName inEnvironment:anEnvironment |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1506 |
"given a partial globalName, return an array consisting of |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1507 |
2 entries: 1st: the best (longest) match |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1508 |
2nd: collection consisting of matching names" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1509 |
|
3863 | 1510 |
^ self globalNameCompletion:aPartialGlobalName inEnvironment:anEnvironment match:true |
1511 |
||
1512 |
" |
|
1513 |
Smalltalk globalnameCompletion:'Arr' |
|
1514 |
Smalltalk globalnameCompletion:'Arra' |
|
1515 |
Smalltalk globalnameCompletion:'arra' |
|
1516 |
Smalltalk globalnameCompletion:'*rray' |
|
1517 |
" |
|
1518 |
||
1519 |
"Created: / 10-08-2006 / 13:06:23 / cg" |
|
1520 |
! |
|
1521 |
||
1522 |
globalNameCompletion:aPartialGlobalName inEnvironment:anEnvironment match:doMatch |
|
1523 |
"given a partial globalName, return an array consisting of |
|
1524 |
2 entries: 1st: the best (longest) match |
|
1525 |
2nd: collection consisting of matching names" |
|
1526 |
||
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1527 |
|searchName matches ignCaseMatches best isMatchString| |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1528 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1529 |
searchName := aPartialGlobalName. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1530 |
searchName isEmpty ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1531 |
^ Array with:searchName with:#() |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1532 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1533 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1534 |
(searchName at:1) isLowercase ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1535 |
searchName := searchName copy asUppercaseFirst |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1536 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1537 |
|
3863 | 1538 |
isMatchString := doMatch and:[ searchName includesMatchCharacters ]. |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1539 |
matches := OrderedCollection new. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1540 |
ignCaseMatches := OrderedCollection new. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1541 |
anEnvironment keysDo:[:aGlobalName | |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1542 |
| addIt| |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1543 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1544 |
isMatchString ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1545 |
addIt := searchName match:aGlobalName |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1546 |
] ifFalse:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1547 |
addIt := aGlobalName startsWith:searchName |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1548 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1549 |
addIt ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1550 |
matches add:aGlobalName |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1551 |
] ifFalse:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1552 |
"/ try ignoring case |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1553 |
isMatchString ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1554 |
addIt := searchName match:aGlobalName ignoreCase:true |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1555 |
] ifFalse:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1556 |
addIt := aGlobalName asLowercase startsWith:searchName asLowercase |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1557 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1558 |
addIt ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1559 |
ignCaseMatches add:aGlobalName |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1560 |
] |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1561 |
] |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1562 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1563 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1564 |
matches isEmpty ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1565 |
matches := ignCaseMatches |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1566 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1567 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1568 |
matches isEmpty ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1569 |
^ Array with:searchName with:(Array with:searchName) |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1570 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1571 |
matches size == 1 ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1572 |
^ Array with:matches first with:(matches asArray) |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1573 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1574 |
matches := matches asSortedCollection. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1575 |
isMatchString ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1576 |
best := searchName. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1577 |
] ifFalse:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1578 |
best := matches longestCommonPrefix. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1579 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1580 |
^ Array with:best with:matches asArray |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1581 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1582 |
" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1583 |
Smalltalk globalnameCompletion:'Arr' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1584 |
Smalltalk globalnameCompletion:'Arra' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1585 |
Smalltalk globalnameCompletion:'arra' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1586 |
Smalltalk globalnameCompletion:'*rray' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1587 |
" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1588 |
|
2975 | 1589 |
"Created: / 10-08-2006 / 13:06:23 / cg" |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1590 |
! |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1591 |
|
4051 | 1592 |
methodProtocolCompletion:aPartialProtocolName inEnvironment:anEnvironment |
1593 |
"given a partial method protocol name, return an array consisting of |
|
1594 |
2 entries: 1st: the best (longest) match |
|
1595 |
2nd: collection consisting of matching protocols" |
|
1596 |
||
1597 |
|matches best lcName| |
|
1598 |
||
1599 |
matches := IdentitySet new. |
|
1600 |
||
1601 |
"/ search for exact match |
|
1602 |
anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector | |
|
1603 |
|protocol| |
|
1604 |
||
1605 |
protocol := eachMethod category. |
|
1606 |
(protocol notNil and:[protocol startsWith:aPartialProtocolName]) ifTrue:[ |
|
1607 |
matches add:protocol |
|
1608 |
]. |
|
1609 |
]. |
|
1610 |
matches isEmpty ifTrue:[ |
|
1611 |
"/ search for case-ignoring match |
|
1612 |
lcName := aPartialProtocolName asLowercase. |
|
1613 |
anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector | |
|
1614 |
|protocol| |
|
1615 |
||
1616 |
protocol := eachMethod category. |
|
1617 |
(protocol notNil and:[protocol asLowercase startsWith:lcName]) ifTrue:[ |
|
1618 |
matches add:protocol |
|
1619 |
]. |
|
1620 |
]. |
|
1621 |
]. |
|
1622 |
||
1623 |
matches isEmpty ifTrue:[ |
|
1624 |
^ Array with:aPartialProtocolName with:(Array with:aPartialProtocolName) |
|
1625 |
]. |
|
1626 |
matches size == 1 ifTrue:[ |
|
1627 |
^ Array with:matches first with:(matches asArray) |
|
1628 |
]. |
|
1629 |
matches := matches asSortedCollection. |
|
1630 |
best := matches longestCommonPrefix. |
|
1631 |
^ Array with:best with:matches asArray |
|
1632 |
||
1633 |
" |
|
1634 |
Smalltalk methodProtocolCompletion:'doc' |
|
1635 |
Smalltalk methodProtocolCompletion:'docu' |
|
1636 |
Smalltalk methodProtocolCompletion:'documenta' |
|
1637 |
" |
|
1638 |
||
1639 |
"Created: / 10-08-2006 / 13:05:27 / cg" |
|
1640 |
"Modified: / 16-03-2011 / 12:30:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1641 |
! |
|
1642 |
||
2975 | 1643 |
nameSpaceCompletion:aPartialClassName inEnvironment:anEnvironment |
1644 |
"given a partial name, return an array consisting of |
|
1645 |
2 entries: 1st: the best (longest) match |
|
1646 |
2nd: collection consisting of matching names" |
|
1647 |
||
1648 |
^ self |
|
1649 |
classnameCompletion:aPartialClassName |
|
1650 |
filter:[:cls | cls isNameSpace] |
|
1651 |
inEnvironment:anEnvironment |
|
1652 |
||
1653 |
" |
|
1654 |
DoWhatIMeanSupport nameSpaceCompletion:'To' inEnvironment:Smalltalk |
|
1655 |
" |
|
1656 |
||
1657 |
"Created: / 10-08-2006 / 13:02:16 / cg" |
|
1658 |
! |
|
1659 |
||
1660 |
packageCompletion:aPartialPackage inEnvironment:anEnvironment |
|
1661 |
"given a partial package name, return an array consisting of |
|
1662 |
2 entries: 1st: the best (longest) match |
|
1663 |
2nd: collection consisting of matching packages" |
|
1664 |
||
1665 |
|matches best lcName| |
|
1666 |
||
1667 |
matches := IdentitySet new. |
|
1668 |
||
1669 |
"/ search for exact match |
|
1670 |
anEnvironment allClassesDo:[:aClass | |
|
1671 |
|package| |
|
1672 |
||
1673 |
package := aClass package. |
|
1674 |
(package notNil and:[package startsWith:aPartialPackage]) ifTrue:[ |
|
1675 |
matches add:package |
|
1676 |
] |
|
1677 |
]. |
|
1678 |
matches isEmpty ifTrue:[ |
|
1679 |
"/ search for case-ignoring match |
|
1680 |
lcName := aPartialPackage asLowercase. |
|
1681 |
anEnvironment allClassesDo:[:aClass | |
|
1682 |
|package| |
|
1683 |
||
1684 |
package := aClass package. |
|
1685 |
(package notNil and:[package asLowercase startsWith:lcName]) ifTrue:[ |
|
1686 |
matches add:package |
|
1687 |
]. |
|
1688 |
]. |
|
1689 |
]. |
|
1690 |
||
1691 |
matches isEmpty ifTrue:[ |
|
1692 |
^ Array with:aPartialPackage with:(Array with:aPartialPackage) |
|
1693 |
]. |
|
1694 |
matches size == 1 ifTrue:[ |
|
1695 |
^ Array with:matches first with:(matches asArray) |
|
1696 |
]. |
|
1697 |
matches := matches asSortedCollection. |
|
1698 |
best := matches longestCommonPrefix. |
|
1699 |
^ Array with:best with:matches asArray |
|
1700 |
||
1701 |
" |
|
1702 |
DoWhatIMeanSupport packageCompletion:'stx:' inEnvironment:Smalltalk |
|
1703 |
DoWhatIMeanSupport packageCompletion:'stx:libw' inEnvironment:Smalltalk |
|
1704 |
" |
|
1705 |
||
1706 |
"Created: / 10-08-2006 / 13:05:07 / cg" |
|
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1707 |
! |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1708 |
|
2977 | 1709 |
packageNameEntryCompletionBlock |
1710 |
"this block can be used in a dialog to perform className completion" |
|
1711 |
||
1712 |
^ self entryCompletionBlockFor:#'packageCompletion:inEnvironment:' |
|
1713 |
||
1714 |
"Created: / 10-08-2006 / 13:22:31 / cg" |
|
1715 |
! |
|
1716 |
||
4049
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1717 |
resourceCompletion:aPartialResourceName inEnvironment:anEnvironment match:doMatch ignoreCase:ignoreCase |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1718 |
"given a partial resource name, return an array consisting of |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1719 |
2 entries: 1st: the longest match |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1720 |
2nd: collection consisting of matching defined resources" |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1721 |
|
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1722 |
|matches best lcSym isMatch| |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1723 |
|
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1724 |
matches := IdentitySet new. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1725 |
|
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1726 |
isMatch := doMatch and:[aPartialResourceName includesMatchCharacters]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1727 |
|
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1728 |
anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector | |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1729 |
eachMethod hasResource ifTrue:[ |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1730 |
eachMethod resources keysDo:[:eachResourceName | |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1731 |
(isMatch |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1732 |
ifTrue:[ (aPartialResourceName match:eachResourceName ignoreCase:ignoreCase) ] |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1733 |
ifFalse:[ ignoreCase |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1734 |
ifTrue:[ (eachResourceName asLowercase startsWith:aPartialResourceName asLowercase) ] |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1735 |
ifFalse:[ (eachResourceName startsWith:aPartialResourceName) ] ] |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1736 |
) ifTrue:[ |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1737 |
matches add:eachResourceName |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1738 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1739 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1740 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1741 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1742 |
(matches isEmpty and:[ignoreCase not]) ifTrue:[ |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1743 |
"/ search for case-ignoring match |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1744 |
lcSym := aPartialResourceName asLowercase. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1745 |
anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector | |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1746 |
eachMethod hasResource ifTrue:[ |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1747 |
eachMethod resources keysDo:[:eachResourceName | |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1748 |
(isMatch |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1749 |
ifTrue:[ (aPartialResourceName match:eachResourceName ignoreCase:true) ] |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1750 |
ifFalse:[ (eachResourceName asLowercase startsWith:lcSym) ]) |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1751 |
ifTrue:[ |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1752 |
matches add:eachResourceName |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1753 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1754 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1755 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1756 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1757 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1758 |
|
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1759 |
matches isEmpty ifTrue:[ |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1760 |
^ Array with:aPartialResourceName with:#() |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1761 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1762 |
matches size == 1 ifTrue:[ |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1763 |
^ Array with:matches first with:(matches asArray) |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1764 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1765 |
matches := matches asSortedCollection. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1766 |
best := matches longestCommonPrefix. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1767 |
^ Array with:best with:matches asArray |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1768 |
|
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1769 |
" |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1770 |
DoWhatIMeanSupport resourceCompletion:'*debug*' inEnvironment:Smalltalk match:true ignoreCase:false |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1771 |
DoWhatIMeanSupport resourceCompletion:'context' inEnvironment:Smalltalk match:true ignoreCase:false |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1772 |
DoWhatIMeanSupport resourceCompletion:'key' inEnvironment:Smalltalk match:true ignoreCase:false |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1773 |
DoWhatIMeanSupport resourceCompletion:'cont' inEnvironment:Smalltalk match:true ignoreCase:false |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1774 |
" |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1775 |
|
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1776 |
"Created: / 06-07-2011 / 12:04:41 / cg" |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1777 |
! |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
1778 |
|
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1779 |
selectorCompletion:aPartialSymbolName inEnvironment:anEnvironment |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1780 |
"given a partial selector, return an array consisting of |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1781 |
2 entries: 1st: the longest match |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1782 |
2nd: collection consisting of matching implemented selectors" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1783 |
|
3863 | 1784 |
^ self selectorCompletion:aPartialSymbolName inEnvironment:anEnvironment match:false |
1785 |
! |
|
1786 |
||
1787 |
selectorCompletion:aPartialSymbolName inEnvironment:anEnvironment match:doMatch |
|
1788 |
"given a partial selector, return an array consisting of |
|
1789 |
2 entries: 1st: the longest match |
|
1790 |
2nd: collection consisting of matching implemented selectors" |
|
1791 |
||
3955
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1792 |
^ self |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1793 |
selectorCompletion:aPartialSymbolName |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1794 |
inEnvironment:anEnvironment |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1795 |
match:doMatch |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1796 |
ignoreCase:false |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1797 |
|
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1798 |
" |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1799 |
DoWhatIMeanSupport selectorCompletion:'inst*p' inEnvironment:Smalltalk match:true |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1800 |
DoWhatIMeanSupport selectorCompletion:'inst*pl' inEnvironment:Smalltalk match:true |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1801 |
DoWhatIMeanSupport selectorCompletion:'at:p' inEnvironment:Smalltalk match:true |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1802 |
DoWhatIMeanSupport selectorCompletion:'nextP' inEnvironment:Smalltalk match:true |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1803 |
DoWhatIMeanSupport selectorCompletion:'nextp' inEnvironment:Smalltalk match:true |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1804 |
" |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1805 |
|
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1806 |
"Modified: / 07-06-1996 / 08:44:33 / stefan" |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1807 |
"Modified: / 26-10-2010 / 20:30:27 / cg" |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1808 |
! |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1809 |
|
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1810 |
selectorCompletion:aPartialSymbolName inEnvironment:anEnvironment match:doMatch ignoreCase:ignoreCase |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1811 |
"given a partial selector, return an array consisting of |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1812 |
2 entries: 1st: the longest match |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1813 |
2nd: collection consisting of matching implemented selectors" |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1814 |
|
3863 | 1815 |
|matches best lcSym isMatch| |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1816 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1817 |
matches := IdentitySet new. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1818 |
|
3863 | 1819 |
isMatch := doMatch and:[aPartialSymbolName includesMatchCharacters]. |
1820 |
||
3751 | 1821 |
anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector | |
3863 | 1822 |
(isMatch |
3955
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1823 |
ifTrue:[ (aPartialSymbolName match:eachSelector ignoreCase:ignoreCase) ] |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1824 |
ifFalse:[ ignoreCase |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1825 |
ifTrue:[ (eachSelector asLowercase startsWith:aPartialSymbolName asLowercase) ] |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1826 |
ifFalse:[ (eachSelector startsWith:aPartialSymbolName) ] ]) |
3863 | 1827 |
ifTrue:[ |
3751 | 1828 |
matches add:eachSelector |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1829 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1830 |
]. |
3955
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1831 |
(matches isEmpty and:[ignoreCase not]) ifTrue:[ |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1832 |
"/ search for case-ignoring match |
3867
03f7ad841731
changed: #selectorCompletion:inEnvironment:match:
Claus Gittinger <cg@exept.de>
parents:
3864
diff
changeset
|
1833 |
lcSym := aPartialSymbolName asLowercase. |
3751 | 1834 |
anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector | |
3863 | 1835 |
(isMatch |
3867
03f7ad841731
changed: #selectorCompletion:inEnvironment:match:
Claus Gittinger <cg@exept.de>
parents:
3864
diff
changeset
|
1836 |
ifTrue:[ (aPartialSymbolName match:eachSelector ignoreCase:true) ] |
3863 | 1837 |
ifFalse:[ (eachSelector asLowercase startsWith:lcSym) ]) |
1838 |
ifTrue:[ |
|
3751 | 1839 |
matches add:eachSelector |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1840 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1841 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1842 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1843 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1844 |
matches isEmpty ifTrue:[ |
3864
10c7db09a580
changed: #selectorCompletion:inEnvironment:match:
Claus Gittinger <cg@exept.de>
parents:
3863
diff
changeset
|
1845 |
^ Array with:aPartialSymbolName with:#() "/ (Array with:aPartialSymbolName) |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1846 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1847 |
matches size == 1 ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1848 |
^ Array with:matches first with:(matches asArray) |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1849 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1850 |
matches := matches asSortedCollection. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1851 |
best := matches longestCommonPrefix. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1852 |
^ Array with:best with:matches asArray |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1853 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1854 |
" |
3867
03f7ad841731
changed: #selectorCompletion:inEnvironment:match:
Claus Gittinger <cg@exept.de>
parents:
3864
diff
changeset
|
1855 |
DoWhatIMeanSupport selectorCompletion:'inst*p' inEnvironment:Smalltalk match:true |
03f7ad841731
changed: #selectorCompletion:inEnvironment:match:
Claus Gittinger <cg@exept.de>
parents:
3864
diff
changeset
|
1856 |
DoWhatIMeanSupport selectorCompletion:'inst*pl' inEnvironment:Smalltalk match:true |
03f7ad841731
changed: #selectorCompletion:inEnvironment:match:
Claus Gittinger <cg@exept.de>
parents:
3864
diff
changeset
|
1857 |
DoWhatIMeanSupport selectorCompletion:'at:p' inEnvironment:Smalltalk match:true |
03f7ad841731
changed: #selectorCompletion:inEnvironment:match:
Claus Gittinger <cg@exept.de>
parents:
3864
diff
changeset
|
1858 |
DoWhatIMeanSupport selectorCompletion:'nextP' inEnvironment:Smalltalk match:true |
03f7ad841731
changed: #selectorCompletion:inEnvironment:match:
Claus Gittinger <cg@exept.de>
parents:
3864
diff
changeset
|
1859 |
DoWhatIMeanSupport selectorCompletion:'nextp' inEnvironment:Smalltalk match:true |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1860 |
" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1861 |
|
3955
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1862 |
"Modified: / 07-06-1996 / 08:44:33 / stefan" |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1863 |
"Created: / 26-10-2010 / 20:30:06 / cg" |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1864 |
! ! |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
1865 |
|
2376 | 1866 |
!DoWhatIMeanSupport class methodsFor:'rename support'! |
1867 |
||
1868 |
goodRenameDefaultFor:oldName lastOld:lastOldName lastNew:lastNewName |
|
2513 | 1869 |
"generate a reasonable default for a rename operation. |
1870 |
(used for rename category etc.)" |
|
2468 | 1871 |
|
2559 | 1872 |
|prefix suffix lastNewSize lastOldSize left right inserted deleted| |
2376 | 1873 |
|
1874 |
lastNewName isNil ifTrue:[ ^ nil]. |
|
1875 |
||
1876 |
lastNewSize := lastNewName size. |
|
1877 |
lastOldSize := lastOldName size. |
|
1878 |
||
1879 |
(lastNewName endsWith:lastOldName) ifTrue:[ |
|
2514 | 1880 |
"last rename was |
1881 |
'foo' -> 'Xfoo' |
|
1882 |
then, a good default for |
|
1883 |
'bar' would be 'Xbar' |
|
1884 |
" |
|
2376 | 1885 |
prefix := lastNewName copyTo:(lastNewSize - lastOldSize). |
1886 |
^ (prefix , oldName). |
|
1887 |
]. |
|
1888 |
(lastOldName endsWith:lastNewName) ifTrue:[ |
|
2514 | 1889 |
"last rename was |
1890 |
'Xfoo' -> 'foo' |
|
1891 |
then, a good default for |
|
1892 |
'Xbar' would be 'bar' |
|
1893 |
" |
|
2376 | 1894 |
prefix := lastOldName copyTo:(lastOldSize - lastNewSize). |
2514 | 1895 |
(oldName startsWith:prefix) ifTrue:[ |
1896 |
^ (oldName copyFrom:prefix size+1). |
|
1897 |
] |
|
1898 |
]. |
|
1899 |
(lastOldName asLowercase = lastNewName asLowercase) ifTrue:[ |
|
1900 |
(lastOldName first ~= lastNewName first) ifTrue:[ |
|
1901 |
(lastOldName first isLowercase = oldName first isLowercase) ifTrue:[ |
|
1902 |
"last rename was |
|
1903 |
'xfoo' -> 'Xfoo' |
|
1904 |
then, a good default for |
|
1905 |
'xbar' would be 'Xbar' |
|
1906 |
" |
|
1907 |
lastOldName first isLowercase ifTrue:[ |
|
1908 |
^ oldName first asUppercase asString , (oldName copyFrom:2). |
|
1909 |
] ifFalse:[ |
|
1910 |
^ oldName first asLowercase asString , (oldName copyFrom:2). |
|
1911 |
] |
|
1912 |
] |
|
1913 |
]. |
|
2376 | 1914 |
]. |
1915 |
(lastOldName withoutSeparators = lastNewName) ifTrue:[ |
|
2514 | 1916 |
"last rename was |
1917 |
' foo ' -> 'foo' |
|
1918 |
then, a good default for |
|
1919 |
' bar ' would be 'bar' |
|
1920 |
" |
|
2376 | 1921 |
^ oldName withoutSeparators. |
1922 |
]. |
|
1923 |
(lastNewName startsWith:lastOldName) ifTrue:[ |
|
2557 | 1924 |
"last rename was |
1925 |
'foo' -> 'fooX' |
|
1926 |
then, a good default for |
|
1927 |
'bar' would be 'barX' |
|
1928 |
" |
|
2376 | 1929 |
suffix := lastNewName copyLast:(lastNewSize - lastOldSize). |
1930 |
^ (oldName , suffix). |
|
1931 |
]. |
|
1932 |
(lastOldName startsWith:lastNewName) ifTrue:[ |
|
2557 | 1933 |
"last rename was |
1934 |
'fooX' -> 'foo' |
|
1935 |
then, a good default for |
|
1936 |
'barX' would be 'bar' |
|
1937 |
" |
|
2376 | 1938 |
suffix := lastOldName copyLast:(lastOldSize - lastNewSize). |
1939 |
(oldName endsWith:suffix) ifTrue:[ |
|
1940 |
^ (oldName copyWithoutLast:suffix size). |
|
1941 |
] |
|
1942 |
]. |
|
2558 | 1943 |
|
2557 | 1944 |
prefix := lastOldName commonPrefixWith:lastNewName. |
1945 |
suffix := lastOldName commonSuffixWith:lastNewName. |
|
2559 | 1946 |
|
2558 | 1947 |
(prefix size > 0) ifTrue:[ |
1948 |
(suffix size > 0) ifTrue:[ |
|
2559 | 1949 |
|
1950 |
prefix := prefix copyTo:(((lastNewName size - suffix size) min:(lastOldName size - suffix size)) min:prefix size). |
|
1951 |
||
2558 | 1952 |
"last rename was |
1953 |
'fooR' -> 'fooXR' |
|
1954 |
then, a good default for |
|
1955 |
'barR' would be 'barXR' |
|
1956 |
" |
|
1957 |
left := lastOldName copyTo:prefix size. |
|
1958 |
right := lastOldName copyLast:suffix size. |
|
2559 | 1959 |
lastNewSize > lastOldSize ifTrue:[ |
1960 |
inserted := (lastNewName copyFrom:(left size + 1)) copyWithoutLast:(right size). |
|
1961 |
inserted size > 0 ifTrue:[ |
|
3532 | 1962 |
(oldName startsWith:prefix) ifTrue:[ |
1963 |
^ (oldName copyTo:prefix size) , inserted , (oldName copyFrom:prefix size + 1) |
|
1964 |
]. |
|
2559 | 1965 |
]. |
1966 |
]. |
|
3585 | 1967 |
(oldName string endsWith:suffix string) ifTrue:[ |
1968 |
deleted := (lastOldName string copyFrom:(prefix size + 1)) copyWithoutLast:(suffix size). |
|
1969 |
(oldName size-suffix size-deleted size + 1) >= 1 ifTrue:[ |
|
1970 |
((oldName copyFrom:oldName size-suffix size-deleted size + 1) copyTo:deleted size) = deleted ifTrue:[ |
|
1971 |
"last rename was |
|
1972 |
'fooXR' -> 'fooR' |
|
1973 |
then, a good default for |
|
1974 |
'barXS' would be 'barS' |
|
1975 |
" |
|
1976 |
^ (oldName copyTo:oldName size-suffix size-deleted size) , suffix |
|
1977 |
] |
|
2559 | 1978 |
] |
1979 |
] |
|
2558 | 1980 |
]. |
1981 |
||
1982 |
(oldName endsWith:(lastOldName copyFrom:prefix size+1)) ifTrue:[ |
|
1983 |
"last rename was |
|
1984 |
'fooX' -> 'fooY' |
|
1985 |
then, a good default for |
|
1986 |
'barX' would be 'barY' |
|
1987 |
" |
|
1988 |
left := oldName copyWithoutLast:(lastOldName copyFrom:prefix size+1) size. |
|
1989 |
right := lastNewName copyFrom:prefix size+1. |
|
1990 |
^ left , right |
|
1991 |
] |
|
2557 | 1992 |
]. |
2376 | 1993 |
|
2382
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
1994 |
^ nil |
2557 | 1995 |
|
1996 |
" |
|
2558 | 1997 |
self goodRenameDefaultFor:'bar' lastOld:'foo' lastNew:'fooXX' |
1998 |
self goodRenameDefaultFor:'bar' lastOld:'foo' lastNew:'XXfoo' |
|
1999 |
||
2000 |
self goodRenameDefaultFor:'barXX' lastOld:'fooXX' lastNew:'foo' |
|
2001 |
self goodRenameDefaultFor:'XXbar' lastOld:'XXfoo' lastNew:'foo' |
|
2002 |
||
2003 |
self goodRenameDefaultFor:'barXX' lastOld:'fooXX' lastNew:'fooYY' |
|
2004 |
self goodRenameDefaultFor:'XXbar' lastOld:'XXfoo' lastNew:'foo' |
|
2005 |
||
2559 | 2006 |
self goodRenameDefaultFor:'bar2' lastOld:'foo1' lastNew:'foo01' |
2007 |
self goodRenameDefaultFor:'barXY' lastOld:'fooXY' lastNew:'fooY' |
|
2560 | 2008 |
self goodRenameDefaultFor:'bar' lastOld:'foo' lastNew:'fXoo' |
2009 |
self goodRenameDefaultFor:'bar' lastOld:'foo' lastNew:'fXXXoo' |
|
2559 | 2010 |
self goodRenameDefaultFor:'bar' lastOld:'foo' lastNew:'foXXXo' |
2011 |
||
2012 |
self goodRenameDefaultFor:'bar001' lastOld:'foo001' lastNew:'foo002_001' |
|
2560 | 2013 |
self goodRenameDefaultFor:'CoastCore-CSFoo' lastOld:'CoastCore-CSBar' lastNew:'Coast-Core-CSBar' |
2557 | 2014 |
" |
2382
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
2015 |
! |
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
2016 |
|
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
2017 |
goodRenameDefaultForFile:oldName lastOld:lastOldName lastNew:lastNewName |
2513 | 2018 |
"generate a reasonable default for a file rename operation. |
2019 |
(Try to rename multiple files in the new fileBrowser, |
|
2020 |
to see what this is doing)" |
|
2468 | 2021 |
|
2382
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
2022 |
|prefix suffix t |
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
2023 |
lastOldWOSuffix lastNewWOSuffix oldWOSuffix lastOldRest oldRest lastNewRest |
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
2024 |
lastRemoved lastInserted default| |
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
2025 |
|
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
2026 |
default := self goodRenameDefaultFor:oldName lastOld:lastOldName lastNew:lastNewName. |
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
2027 |
default notNil ifTrue:[ ^ default]. |
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
2028 |
|
3135
7ad9ff29225e
changed #classCategoryLoadFromRepository
Claus Gittinger <cg@exept.de>
parents:
2977
diff
changeset
|
2029 |
lastOldWOSuffix := lastOldName asFilename nameWithoutSuffix. |
7ad9ff29225e
changed #classCategoryLoadFromRepository
Claus Gittinger <cg@exept.de>
parents:
2977
diff
changeset
|
2030 |
lastNewWOSuffix := lastNewName asFilename nameWithoutSuffix. |
7ad9ff29225e
changed #classCategoryLoadFromRepository
Claus Gittinger <cg@exept.de>
parents:
2977
diff
changeset
|
2031 |
oldWOSuffix := oldName asFilename nameWithoutSuffix. |
2376 | 2032 |
|
2434 | 2033 |
"/ suffix change ? |
2034 |
lastOldWOSuffix = lastNewWOSuffix ifTrue:[ |
|
2035 |
lastOldName asFilename suffix ~= lastNewName asFilename suffix ifTrue:[ |
|
2036 |
^ (oldName asFilename withSuffix:(lastNewName asFilename suffix)) pathName |
|
2037 |
]. |
|
2038 |
]. |
|
2039 |
||
2553 | 2040 |
default := self goodRenameDefaultFor:oldWOSuffix lastOld:lastOldWOSuffix lastNew:lastNewWOSuffix. |
2041 |
default notNil ifTrue:[ |
|
2042 |
lastOldRest := lastOldName copyFrom:lastOldWOSuffix size + 1. |
|
2043 |
lastNewRest := lastNewName copyFrom:lastNewWOSuffix size + 1. |
|
2044 |
oldRest := oldName copyFrom:oldWOSuffix size + 1. |
|
2045 |
||
2046 |
^ default , lastNewRest |
|
2047 |
]. |
|
2048 |
||
2376 | 2049 |
prefix := lastOldWOSuffix commonPrefixWith:oldWOSuffix. |
2050 |
(lastNewWOSuffix startsWith:prefix) ifTrue:[ |
|
2051 |
lastOldRest := lastOldWOSuffix copyFrom:prefix size + 1. |
|
2052 |
lastNewRest := lastNewWOSuffix copyFrom:prefix size + 1. |
|
2053 |
oldRest := oldWOSuffix copyFrom:prefix size + 1. |
|
2054 |
||
2055 |
(lastNewRest endsWith:lastOldRest) ifTrue:[ |
|
2056 |
t := lastNewRest copyWithoutLast:lastOldRest size. |
|
2057 |
^ ((prefix , t , oldRest) asFilename withSuffix:oldName asFilename suffix) name |
|
2058 |
]. |
|
2059 |
]. |
|
2060 |
||
2061 |
suffix := lastOldWOSuffix commonSuffixWith:lastNewWOSuffix. |
|
2062 |
suffix size > 0 ifTrue:[ |
|
2063 |
"/ last change changed something at the beginning |
|
2064 |
prefix := oldWOSuffix commonPrefixWith:lastOldWOSuffix. |
|
2065 |
prefix size > 0 ifTrue:[ |
|
2066 |
"/ this name starts with the same characters |
|
2067 |
lastRemoved := lastOldWOSuffix copyWithoutLast:suffix size. |
|
2068 |
lastInserted := lastNewWOSuffix copyWithoutLast:suffix size. |
|
2069 |
(lastRemoved startsWith:lastInserted) ifTrue:[ |
|
2070 |
oldWOSuffix size >= lastInserted size ifTrue:[ |
|
2071 |
^ (oldWOSuffix copyTo:lastInserted size) , (oldName copyFrom:lastRemoved size + 1) |
|
2072 |
] |
|
2073 |
]. |
|
2074 |
^ lastInserted , (oldName copyFrom:lastRemoved size + 1) |
|
2075 |
]. |
|
2076 |
]. |
|
2077 |
||
2078 |
^ nil |
|
3135
7ad9ff29225e
changed #classCategoryLoadFromRepository
Claus Gittinger <cg@exept.de>
parents:
2977
diff
changeset
|
2079 |
|
7ad9ff29225e
changed #classCategoryLoadFromRepository
Claus Gittinger <cg@exept.de>
parents:
2977
diff
changeset
|
2080 |
"Modified: / 07-11-2006 / 13:58:39 / cg" |
2376 | 2081 |
! ! |
2082 |
||
2515
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2083 |
!DoWhatIMeanSupport class methodsFor:'typing distance'! |
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2084 |
|
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2085 |
isKey:k1 nextTo:k2 |
2774 | 2086 |
"return true, if k1 and k2 are adjacent keys on the keyboard. |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
2087 |
This is used to specially priorize plausible typing errors of adjacent keys. |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
2088 |
CAVEAT: hard coded us- and german keyboards here." |
2515
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2089 |
|
3316 | 2090 |
^ self isKey:k1 nextTo:k2 onKeyboard:(self keyboard) |
2515
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2091 |
|
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2092 |
" |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
2093 |
self isKey:$a nextTo:$a |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
2094 |
self isKey:$a nextTo:$s |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
2095 |
self isKey:$a nextTo:$q |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
2096 |
self isKey:$a nextTo:$w |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
2097 |
self isKey:$a nextTo:$z |
2517 | 2098 |
self isKey:$a nextTo:$x |
2515
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2099 |
" |
3316 | 2100 |
|
2101 |
"Modified: / 16-01-2008 / 17:17:31 / cg" |
|
2515
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2102 |
! |
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2103 |
|
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2104 |
isKey:k1 nextTo:k2 onKeyboard:keys |
2774 | 2105 |
"return true, if k1 and k2 are adjacent keys on the keyboard defined by keys" |
2515
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2106 |
|
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2107 |
|row1 row2 col1 col2| |
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2108 |
|
2774 | 2109 |
row1 := keys findFirst:[:eachRow | col1 := eachRow indexOf:k1. col1 ~~ 0]. |
2517 | 2110 |
row1 == 0 ifTrue:[^ false]. |
2774 | 2111 |
row2 := keys findFirst:[:eachRow | col2 := eachRow indexOf:k2. col2 ~~ 0]. |
2517 | 2112 |
row2 == 0 ifTrue:[^ false]. |
2515
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2113 |
|
2774 | 2114 |
^ (row1-row2) abs <= 1 and:[(col1-col2) abs <= 1] |
2515
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2115 |
|
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2116 |
" |
2774 | 2117 |
self isKey:$a nextTo:$q |
2517 | 2118 |
self isKey:$a nextTo:$x |
2515
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2119 |
" |
3316 | 2120 |
! |
2121 |
||
2122 |
keyboard |
|
2123 |
"the keyboard layout (to find possible typing errors)" |
|
2124 |
||
2125 |
|lang| |
|
2126 |
||
2127 |
lang := UserPreferences current language. |
|
2128 |
lang == #de ifTrue:[ |
|
2129 |
^ #( |
|
2130 |
'1234567890-' |
|
2131 |
'*qwertzuiop' |
|
2132 |
'**asdfghjkl:' |
|
2133 |
'***yxcvbnm' ). |
|
2134 |
]. |
|
2135 |
||
2136 |
lang == #fr ifTrue:[ |
|
2137 |
^ #( |
|
2138 |
'1234567890' |
|
2139 |
'*azertyuiop' |
|
2140 |
'**qsdfghjklm' |
|
2141 |
'***wxcvbn,' ). |
|
2142 |
]. |
|
2143 |
||
2144 |
^ #( |
|
2145 |
'1234567890-' |
|
2146 |
'*qwertyuiop' |
|
2147 |
'**asdfghjkl:' |
|
2148 |
'***zxcvbnm' ). |
|
2149 |
||
2150 |
" |
|
2151 |
self keyboard |
|
2152 |
" |
|
2153 |
||
2154 |
"Created: / 16-01-2008 / 17:17:13 / cg" |
|
2515
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2155 |
! ! |
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
2156 |
|
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2157 |
!DoWhatIMeanSupport::InputCompletionResult class methodsFor:'instance creation'! |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2158 |
|
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2159 |
bestName:bestNameArg matchingNames:matchingNamesArg |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2160 |
^ self with:bestNameArg with:matchingNamesArg |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2161 |
|
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2162 |
" |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2163 |
self bestName:123 matchingNames:345 |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2164 |
" |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2165 |
! ! |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2166 |
|
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2167 |
!DoWhatIMeanSupport::InputCompletionResult methodsFor:'accessing'! |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2168 |
|
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2169 |
bestName |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2170 |
^ self at:1 |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2171 |
! |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2172 |
|
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2173 |
matchingNames |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2174 |
^ self at:2 |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2175 |
! ! |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
2176 |
|
2376 | 2177 |
!DoWhatIMeanSupport class methodsFor:'documentation'! |
2178 |
||
3761
6584390d427d
dont forget pool variables when looking for the best variable match
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
2179 |
version_CVS |
4058 | 2180 |
^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.84 2011-07-17 09:13:33 cg Exp $' |
2376 | 2181 |
! ! |