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