author | Claus Gittinger <cg@exept.de> |
Fri, 26 Jul 2013 21:56:21 +0200 | |
changeset 4308 | f1c31624744d |
parent 4304 | c1ac9271223b |
child 4309 | a558c52658d9 |
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 |
|
4238 | 15 |
instanceVariableNames:'tree tokens classOrNil methodOrNil codeView' |
16 |
classVariableNames:'LastSource LastParseTree LastScanTokens 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" |
4238 | 73 |
|
74 |
^ self new |
|
75 |
codeCompletionForClass:classOrNil context:contextOrNil codeView:codeView |
|
76 |
! |
|
77 |
||
78 |
codeCompletionForMethod:methodOrNil orClass:classOrNil codeView:codeView into:actionBlock |
|
79 |
self codeCompletionForMethod:methodOrNil orClass:classOrNil context:nil codeView:codeView into:actionBlock |
|
80 |
||
81 |
"Modified (format): / 03-07-2011 / 15:49:49 / cg" |
|
82 |
! |
|
83 |
||
84 |
codeCompletionForMethod:methodOrNil orClass:classOrNil context:contextOrNil codeView:codeView into:actionBlock |
|
85 |
"contextOrNil is the current context, if this is called from the debugger; |
|
86 |
nil, if called from the browser. |
|
87 |
If nonNil, we can make better guesses, because we actually know what a variable's type is. |
|
88 |
This is not yet done, sigh" |
|
89 |
||
90 |
^ self new |
|
91 |
codeCompletionForMethod:methodOrNil orClass:classOrNil |
|
92 |
context:contextOrNil |
|
93 |
codeView:codeView into:actionBlock |
|
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
94 |
! ! |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
95 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
96 |
!DoWhatIMeanSupport class methodsFor:'code completion-helpers'! |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
97 |
|
3300 | 98 |
findNodeForInterval:interval in:source |
4238 | 99 |
^ self new findNodeForInterval:interval in:source |
3300 | 100 |
! |
101 |
||
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
102 |
findNodeForInterval:interval in:source allowErrors:allowErrors |
4238 | 103 |
^ self new findNodeForInterval:interval in:source allowErrors:allowErrors |
4080
413b8c8a0161
added: #findNodeForInterval:in:allowErrors:mustBeMethod:
Claus Gittinger <cg@exept.de>
parents:
4070
diff
changeset
|
104 |
! |
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 |
findNodeForInterval:interval in:source allowErrors:allowErrors mustBeMethod:mustBeMethod |
413b8c8a0161
added: #findNodeForInterval:in:allowErrors:mustBeMethod:
Claus Gittinger <cg@exept.de>
parents:
4070
diff
changeset
|
107 |
"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
|
108 |
|
4238 | 109 |
^ self new |
110 |
findNodeForInterval:interval in:source allowErrors:allowErrors mustBeMethod:mustBeMethod |
|
3306
40e860fd2f02
argument-name completion in a methods selector pattern
Claus Gittinger <cg@exept.de>
parents:
3303
diff
changeset
|
111 |
! |
40e860fd2f02
argument-name completion in a methods selector pattern
Claus Gittinger <cg@exept.de>
parents:
3303
diff
changeset
|
112 |
|
40e860fd2f02
argument-name completion in a methods selector pattern
Claus Gittinger <cg@exept.de>
parents:
3303
diff
changeset
|
113 |
findNodeForInterval:interval inParseTree:parseTree |
4238 | 114 |
^ self new findNodeForInterval:interval inParseTree:parseTree |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
115 |
! |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
116 |
|
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
117 |
findNodeIn:tree forInterval:interval |
4238 | 118 |
^ self new findNodeIn:tree forInterval:interval |
2376 | 119 |
! ! |
120 |
||
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
121 |
!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
|
122 |
|
2975 | 123 |
classCategoryCompletion:aPartialCategory inEnvironment:anEnvironment |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
124 |
"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
|
125 |
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
|
126 |
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
|
127 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
128 |
|matches best lcName| |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
129 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
130 |
matches := IdentitySet new. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
131 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
132 |
"/ search for exact match |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
133 |
anEnvironment allClassesDo:[:aClass | |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
134 |
|category| |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
135 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
136 |
category := aClass category. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
137 |
(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
|
138 |
matches add:category |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
139 |
] |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
140 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
141 |
matches isEmpty ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
142 |
"/ search for case-ignoring match |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
143 |
lcName := aPartialCategory asLowercase. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
144 |
anEnvironment allClassesDo:[:aClass | |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
145 |
|category| |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
146 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
147 |
category := aClass category. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
148 |
(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
|
149 |
matches add:category |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
150 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
151 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
152 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
153 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
154 |
matches isEmpty ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
155 |
^ 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
|
156 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
157 |
matches size == 1 ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
158 |
^ 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
|
159 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
160 |
matches := matches asSortedCollection. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
161 |
best := matches longestCommonPrefix. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
162 |
^ 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
|
163 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
164 |
" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
165 |
Smalltalk classCategoryCompletion:'Sys' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
166 |
Smalltalk classCategoryCompletion:'System' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
167 |
Smalltalk classCategoryCompletion:'System-BinaryStorage' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
168 |
" |
2975 | 169 |
|
170 |
"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
|
171 |
! |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
172 |
|
2830 | 173 |
classNameEntryCompletionBlock |
174 |
"this block can be used in a dialog to perform className completion" |
|
175 |
||
2977 | 176 |
^ self entryCompletionBlockFor:#'classnameCompletion:inEnvironment:' |
2830 | 177 |
|
2977 | 178 |
"Modified: / 10-08-2006 / 13:22:02 / cg" |
2830 | 179 |
! |
180 |
||
2975 | 181 |
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
|
182 |
"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
|
183 |
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
|
184 |
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
|
185 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
186 |
|searchName matches matchedNamesWithoutPrefix ignCaseMatches best isMatchString cls nsPrefix |
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
187 |
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
|
188 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
189 |
aPartialClassName isEmpty ifTrue:[ |
2975 | 190 |
matches := Smalltalk allClassesForWhich:filterBlock. |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
191 |
^ InputCompletionResult bestName:aPartialClassName matchingNames:#() |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
192 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
193 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
194 |
(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
|
195 |
w1 := words first. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
196 |
w2 := words second. |
2975 | 197 |
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
|
198 |
bestMatch := rslt first. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
199 |
matches := rslt second. |
3549 | 200 |
('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
|
201 |
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
|
202 |
bestMatch := bestMatch , ' class'. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
203 |
]. |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
204 |
^ 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
|
205 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
206 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
207 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
208 |
(aPartialClassName startsWith:'Smalltalk::') ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
209 |
nsPrefix := 'Smalltalk::'. |
4214 | 210 |
searchName := aPartialClassName withoutPrefix:'Smalltalk::' |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
211 |
] ifFalse:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
212 |
nsPrefix := ''. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
213 |
searchName := aPartialClassName. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
214 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
215 |
|
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
216 |
searchName := searchName asUppercaseFirst. |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
217 |
lcSearchName := searchName asLowercase. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
218 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
219 |
isMatchString := searchName includesMatchCharacters. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
220 |
matches := OrderedCollection new. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
221 |
matchedNamesWithoutPrefix := Set new. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
222 |
ignCaseMatches := OrderedCollection new. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
223 |
others := OrderedCollection new. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
224 |
|
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
225 |
tryToMatch := |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
226 |
[:className :fullClassName| |
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
227 |
|addIt| |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
228 |
"/ (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
|
229 |
isMatchString ifTrue:[ |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
230 |
addIt := searchName match:className |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
231 |
] ifFalse:[ |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
232 |
addIt := className startsWith:searchName. |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
233 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
234 |
addIt ifTrue:[ |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
235 |
matches add:(nsPrefix , fullClassName). |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
236 |
matchedNamesWithoutPrefix add:className. |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
237 |
] ifFalse:[ |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
238 |
"/ try ignoring case |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
239 |
|
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
240 |
isMatchString ifTrue:[ |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
241 |
addIt := searchName match:className ignoreCase:true |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
242 |
] ifFalse:[ |
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
243 |
addIt := className asLowercase startsWith:lcSearchName. |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
244 |
addIt ifFalse:[ |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
245 |
others add:className |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
246 |
] |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
247 |
]. |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
248 |
addIt ifTrue:[ |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
249 |
ignCaseMatches add:(nsPrefix , fullClassName). |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
250 |
matchedNamesWithoutPrefix add:className. |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
251 |
]. |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
252 |
]. |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
253 |
addIt |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
254 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
255 |
|
2975 | 256 |
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
|
257 |
|addIt fullClassName classNameWithoutPrefix| |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
258 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
259 |
aClass isMeta ifFalse:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
260 |
fullClassName := aClass name. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
261 |
classNameWithoutPrefix := aClass nameWithoutPrefix. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
262 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
263 |
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
|
264 |
addIt ifFalse:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
265 |
classNameWithoutPrefix ~~ fullClassName ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
266 |
tryToMatch value:classNameWithoutPrefix value:fullClassName. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
267 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
268 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
269 |
] |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
270 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
271 |
|
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
272 |
"/ matches isEmpty ifTrue:[ |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
273 |
"/ matches := ignCaseMatches. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
274 |
"/ ]. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
275 |
matches := matches , ignCaseMatches. |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
276 |
|
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
277 |
"/ matches isEmpty ifTrue:[ |
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
278 |
"/ matches := ignCaseMatches. |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
279 |
"/ |
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
280 |
"/"/ matches isEmpty ifTrue:[ |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
281 |
"/"/ | nearBy | |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
282 |
"/"/ nearBy := SortedCollection new sortBlock:[:a :b | a key < b key]. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
283 |
"/"/ others do:[:className | |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
284 |
"/"/ |lcClassName dist cmpName| |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
285 |
"/"/ |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
286 |
"/"/ lcClassName := className asLowercase. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
287 |
"/"/ 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
|
288 |
"/"/ |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
289 |
"/"/ cmpName := lcClassName copyTo:(lcSearchName size min:lcClassName size). |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
290 |
"/"/ 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
|
291 |
"/"/ cmpName := lcClassName copyTo:(lcSearchName size + 1 min:lcClassName size). |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
292 |
"/"/ 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
|
293 |
"/"/ dist < 4 ifTrue:[ |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
294 |
"/"/ nearBy add:( dist -> (nsPrefix , className) ). |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
295 |
"/"/ ] |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
296 |
"/"/ ]. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
297 |
"/"/ matches := nearBy collect:[:eachPair | eachPair value]. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
298 |
"/"/ ]. |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
299 |
"/ ]. |
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
300 |
|
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
301 |
matches isEmpty ifTrue:[ |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
302 |
^ InputCompletionResult bestName:searchName matchingNames:(Array with:searchName) |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
303 |
]. |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
304 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
305 |
matches size == 1 ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
306 |
best := matches first. |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
307 |
^ 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
|
308 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
309 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
310 |
matches |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
311 |
sort:[:name1 :name2 | |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
312 |
"name1 comes before:name2 iff" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
313 |
((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
|
314 |
or:[ ((name1 includes:$:) == (name2 includes:$:)) |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
315 |
and:[ (name1 size < name2 size) |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
316 |
or: [ name1 < name2 ]] |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
317 |
] |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
318 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
319 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
320 |
isMatchString ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
321 |
best := searchName. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
322 |
] ifFalse:[ |
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
323 |
matchesForLongestPrefix := matches select:[:m | m asLowercase startsWith:lcSearchName]. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
324 |
best := ignCaseMatches isEmpty |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
325 |
ifTrue:[ matchesForLongestPrefix longestCommonPrefix ] |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
326 |
ifFalse:[ matchesForLongestPrefix longestCommonPrefixIgnoreCase:true ]. |
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
327 |
|
3198
fea29ae859c9
classnamecompletion fixed when namespace is involved
Claus Gittinger <cg@exept.de>
parents:
3135
diff
changeset
|
328 |
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
|
329 |
best := matchedNamesWithoutPrefix longestCommonPrefix. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
330 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
331 |
best size == 0 ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
332 |
"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
|
333 |
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
|
334 |
idx ~~ 1 ifTrue:[ |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
335 |
^ 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
|
336 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
337 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
338 |
best size < aPartialClassName size ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
339 |
best := aPartialClassName. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
340 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
341 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
342 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
343 |
cls := anEnvironment classNamed:best. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
344 |
(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
|
345 |
(matches conform:[:each | each = best |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
346 |
or:[each startsWith:(best , '::')]]) |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
347 |
ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
348 |
best := best , '::' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
349 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
350 |
]. |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
351 |
^ 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
|
352 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
353 |
" |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
354 |
Smalltalk classnameCompletion:'Arr' |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
355 |
Smalltalk classnameCompletion:'Arra' |
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
356 |
Smalltalk classnameCompletion:'arra' |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
357 |
Smalltalk classnameCompletion:'*rray' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
358 |
" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
359 |
|
2975 | 360 |
"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
|
361 |
! |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
362 |
|
2975 | 363 |
classnameCompletion:aPartialClassName inEnvironment:anEnvironment |
364 |
"given a partial classname, return an array consisting of |
|
365 |
2 entries: 1st: the best (longest) match |
|
366 |
2nd: collection consisting of matching names" |
|
367 |
||
368 |
^ self |
|
369 |
classnameCompletion:aPartialClassName |
|
370 |
filter:[:cls | true] |
|
371 |
inEnvironment:anEnvironment |
|
372 |
||
373 |
" |
|
4148
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
374 |
self classnameCompletion:'Arr' inEnvironment:Smalltalk |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
375 |
self classnameCompletion:'Arra' inEnvironment:Smalltalk |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
376 |
self classnameCompletion:'arra' inEnvironment:Smalltalk |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
377 |
self classnameCompletion:'*rray' inEnvironment:Smalltalk |
2975 | 378 |
" |
379 |
||
380 |
"Created: / 24-11-1995 / 17:24:45 / cg" |
|
381 |
"Modified: / 10-08-2006 / 13:01:30 / cg" |
|
382 |
! |
|
383 |
||
2977 | 384 |
entryCompletionBlockFor:completionSelector |
385 |
"this block can be used in a dialog to perform className completion" |
|
386 |
||
387 |
^ [:contents :field | |
|
388 |
|s what m| |
|
389 |
||
390 |
s := contents withoutSpaces. |
|
391 |
field topView withCursor:(Cursor questionMark) do:[ |
|
392 |
what := self perform:completionSelector with:s with:Smalltalk. |
|
393 |
]. |
|
3876
6e63fce83590
fixed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3867
diff
changeset
|
394 |
|
2977 | 395 |
field contents:(what first). |
396 |
(what at:2) size ~~ 1 ifTrue:[ |
|
3693 | 397 |
UserPreferences current beepInEditor ifTrue:[ |
398 |
field device beep |
|
399 |
] |
|
2977 | 400 |
] |
401 |
]. |
|
402 |
||
403 |
"Created: / 10-08-2006 / 13:21:37 / cg" |
|
404 |
! |
|
405 |
||
2975 | 406 |
globalNameCompletion:aPartialGlobalName inEnvironment:anEnvironment |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
407 |
"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
|
408 |
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
|
409 |
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
|
410 |
|
3863 | 411 |
^ self globalNameCompletion:aPartialGlobalName inEnvironment:anEnvironment match:true |
412 |
||
413 |
" |
|
414 |
Smalltalk globalnameCompletion:'Arr' |
|
415 |
Smalltalk globalnameCompletion:'Arra' |
|
416 |
Smalltalk globalnameCompletion:'arra' |
|
417 |
Smalltalk globalnameCompletion:'*rray' |
|
418 |
" |
|
419 |
||
420 |
"Created: / 10-08-2006 / 13:06:23 / cg" |
|
421 |
! |
|
422 |
||
423 |
globalNameCompletion:aPartialGlobalName inEnvironment:anEnvironment match:doMatch |
|
424 |
"given a partial globalName, return an array consisting of |
|
425 |
2 entries: 1st: the best (longest) match |
|
426 |
2nd: collection consisting of matching names" |
|
427 |
||
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
428 |
|searchName matches ignCaseMatches best isMatchString| |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
429 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
430 |
searchName := aPartialGlobalName. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
431 |
searchName isEmpty ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
432 |
^ Array with:searchName with:#() |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
433 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
434 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
435 |
(searchName at:1) isLowercase ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
436 |
searchName := searchName copy asUppercaseFirst |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
437 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
438 |
|
3863 | 439 |
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
|
440 |
matches := OrderedCollection new. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
441 |
ignCaseMatches := OrderedCollection new. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
442 |
anEnvironment keysDo:[:aGlobalName | |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
443 |
| addIt| |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
444 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
445 |
isMatchString ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
446 |
addIt := searchName match:aGlobalName |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
447 |
] ifFalse:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
448 |
addIt := aGlobalName startsWith:searchName |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
449 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
450 |
addIt ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
451 |
matches add:aGlobalName |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
452 |
] ifFalse:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
453 |
"/ try ignoring case |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
454 |
isMatchString ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
455 |
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
|
456 |
] ifFalse:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
457 |
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
|
458 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
459 |
addIt ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
460 |
ignCaseMatches add:aGlobalName |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
461 |
] |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
462 |
] |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
463 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
464 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
465 |
matches isEmpty ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
466 |
matches := ignCaseMatches |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
467 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
468 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
469 |
matches isEmpty ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
470 |
^ 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
|
471 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
472 |
matches size == 1 ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
473 |
^ 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
|
474 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
475 |
matches := matches asSortedCollection. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
476 |
isMatchString ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
477 |
best := searchName. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
478 |
] ifFalse:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
479 |
best := matches longestCommonPrefix. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
480 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
481 |
^ 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
|
482 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
483 |
" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
484 |
Smalltalk globalnameCompletion:'Arr' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
485 |
Smalltalk globalnameCompletion:'Arra' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
486 |
Smalltalk globalnameCompletion:'arra' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
487 |
Smalltalk globalnameCompletion:'*rray' |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
488 |
" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
489 |
|
2975 | 490 |
"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
|
491 |
! |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
492 |
|
4051 | 493 |
methodProtocolCompletion:aPartialProtocolName inEnvironment:anEnvironment |
494 |
"given a partial method protocol name, return an array consisting of |
|
495 |
2 entries: 1st: the best (longest) match |
|
496 |
2nd: collection consisting of matching protocols" |
|
497 |
||
498 |
|matches best lcName| |
|
499 |
||
500 |
matches := IdentitySet new. |
|
501 |
||
502 |
"/ search for exact match |
|
503 |
anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector | |
|
504 |
|protocol| |
|
505 |
||
506 |
protocol := eachMethod category. |
|
507 |
(protocol notNil and:[protocol startsWith:aPartialProtocolName]) ifTrue:[ |
|
508 |
matches add:protocol |
|
509 |
]. |
|
510 |
]. |
|
511 |
matches isEmpty ifTrue:[ |
|
512 |
"/ search for case-ignoring match |
|
513 |
lcName := aPartialProtocolName asLowercase. |
|
514 |
anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector | |
|
515 |
|protocol| |
|
516 |
||
517 |
protocol := eachMethod category. |
|
518 |
(protocol notNil and:[protocol asLowercase startsWith:lcName]) ifTrue:[ |
|
519 |
matches add:protocol |
|
520 |
]. |
|
521 |
]. |
|
522 |
]. |
|
523 |
||
524 |
matches isEmpty ifTrue:[ |
|
525 |
^ Array with:aPartialProtocolName with:(Array with:aPartialProtocolName) |
|
526 |
]. |
|
527 |
matches size == 1 ifTrue:[ |
|
528 |
^ Array with:matches first with:(matches asArray) |
|
529 |
]. |
|
530 |
matches := matches asSortedCollection. |
|
531 |
best := matches longestCommonPrefix. |
|
532 |
^ Array with:best with:matches asArray |
|
533 |
||
534 |
" |
|
535 |
Smalltalk methodProtocolCompletion:'doc' |
|
536 |
Smalltalk methodProtocolCompletion:'docu' |
|
537 |
Smalltalk methodProtocolCompletion:'documenta' |
|
538 |
" |
|
539 |
||
540 |
"Created: / 10-08-2006 / 13:05:27 / cg" |
|
541 |
"Modified: / 16-03-2011 / 12:30:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
542 |
! |
|
543 |
||
2975 | 544 |
nameSpaceCompletion:aPartialClassName inEnvironment:anEnvironment |
545 |
"given a partial name, return an array consisting of |
|
546 |
2 entries: 1st: the best (longest) match |
|
547 |
2nd: collection consisting of matching names" |
|
548 |
||
549 |
^ self |
|
550 |
classnameCompletion:aPartialClassName |
|
551 |
filter:[:cls | cls isNameSpace] |
|
552 |
inEnvironment:anEnvironment |
|
553 |
||
554 |
" |
|
555 |
DoWhatIMeanSupport nameSpaceCompletion:'To' inEnvironment:Smalltalk |
|
556 |
" |
|
557 |
||
558 |
"Created: / 10-08-2006 / 13:02:16 / cg" |
|
559 |
! |
|
560 |
||
561 |
packageCompletion:aPartialPackage inEnvironment:anEnvironment |
|
562 |
"given a partial package name, return an array consisting of |
|
563 |
2 entries: 1st: the best (longest) match |
|
564 |
2nd: collection consisting of matching packages" |
|
565 |
||
566 |
|matches best lcName| |
|
567 |
||
4195 | 568 |
matches := Smalltalk allProjectIDs |
569 |
select:[:package | package startsWith:aPartialPackage]. |
|
2975 | 570 |
|
571 |
matches isEmpty ifTrue:[ |
|
572 |
"/ search for case-ignoring match |
|
573 |
lcName := aPartialPackage asLowercase. |
|
574 |
anEnvironment allClassesDo:[:aClass | |
|
575 |
|package| |
|
576 |
||
577 |
package := aClass package. |
|
578 |
(package notNil and:[package asLowercase startsWith:lcName]) ifTrue:[ |
|
579 |
matches add:package |
|
580 |
]. |
|
581 |
]. |
|
582 |
]. |
|
583 |
||
584 |
matches isEmpty ifTrue:[ |
|
585 |
^ Array with:aPartialPackage with:(Array with:aPartialPackage) |
|
586 |
]. |
|
587 |
matches size == 1 ifTrue:[ |
|
588 |
^ Array with:matches first with:(matches asArray) |
|
589 |
]. |
|
590 |
matches := matches asSortedCollection. |
|
591 |
best := matches longestCommonPrefix. |
|
592 |
^ Array with:best with:matches asArray |
|
593 |
||
594 |
" |
|
595 |
DoWhatIMeanSupport packageCompletion:'stx:' inEnvironment:Smalltalk |
|
596 |
DoWhatIMeanSupport packageCompletion:'stx:libw' inEnvironment:Smalltalk |
|
597 |
" |
|
598 |
||
599 |
"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
|
600 |
! |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
601 |
|
2977 | 602 |
packageNameEntryCompletionBlock |
603 |
"this block can be used in a dialog to perform className completion" |
|
604 |
||
605 |
^ self entryCompletionBlockFor:#'packageCompletion:inEnvironment:' |
|
606 |
||
607 |
"Created: / 10-08-2006 / 13:22:31 / cg" |
|
608 |
! |
|
609 |
||
4148
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
610 |
poolnameCompletion:aPartialClassName inEnvironment:anEnvironment |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
611 |
"given a partial poolname, return an array consisting of |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
612 |
2 entries: 1st: the best (longest) match |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
613 |
2nd: collection consisting of matching names" |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
614 |
|
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
615 |
^ self |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
616 |
classnameCompletion:aPartialClassName |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
617 |
filter:[:cls | cls isSharedPool] |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
618 |
inEnvironment:anEnvironment |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
619 |
|
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
620 |
" |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
621 |
self poolnameCompletion:'Win' inEnvironment:Smalltalk |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
622 |
self poolnameCompletion:'Z' inEnvironment:Smalltalk |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
623 |
self poolnameCompletion:'a' inEnvironment:Smalltalk |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
624 |
" |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
625 |
! |
b314d59c1654
added: #poolnameCompletion:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
626 |
|
4049
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
627 |
resourceCompletion:aPartialResourceName inEnvironment:anEnvironment match:doMatch ignoreCase:ignoreCase |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
628 |
"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
|
629 |
2 entries: 1st: the longest match |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
630 |
2nd: collection consisting of matching defined resources" |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
631 |
|
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
632 |
|matches best lcSym isMatch| |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
633 |
|
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
634 |
matches := IdentitySet new. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
635 |
|
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
636 |
isMatch := doMatch and:[aPartialResourceName includesMatchCharacters]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
637 |
|
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
638 |
anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector | |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
639 |
eachMethod hasResource ifTrue:[ |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
640 |
eachMethod resources keysDo:[:eachResourceName | |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
641 |
(isMatch |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
642 |
ifTrue:[ (aPartialResourceName match:eachResourceName ignoreCase:ignoreCase) ] |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
643 |
ifFalse:[ ignoreCase |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
644 |
ifTrue:[ (eachResourceName asLowercase startsWith:aPartialResourceName asLowercase) ] |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
645 |
ifFalse:[ (eachResourceName startsWith:aPartialResourceName) ] ] |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
646 |
) ifTrue:[ |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
647 |
matches add:eachResourceName |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
648 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
649 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
650 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
651 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
652 |
(matches isEmpty and:[ignoreCase not]) ifTrue:[ |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
653 |
"/ search for case-ignoring match |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
654 |
lcSym := aPartialResourceName asLowercase. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
655 |
anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector | |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
656 |
eachMethod hasResource ifTrue:[ |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
657 |
eachMethod resources keysDo:[:eachResourceName | |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
658 |
(isMatch |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
659 |
ifTrue:[ (aPartialResourceName match:eachResourceName ignoreCase:true) ] |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
660 |
ifFalse:[ (eachResourceName asLowercase startsWith:lcSym) ]) |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
661 |
ifTrue:[ |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
662 |
matches add:eachResourceName |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
663 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
664 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
665 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
666 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
667 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
668 |
|
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
669 |
matches isEmpty ifTrue:[ |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
670 |
^ Array with:aPartialResourceName with:#() |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
671 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
672 |
matches size == 1 ifTrue:[ |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
673 |
^ Array with:matches first with:(matches asArray) |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
674 |
]. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
675 |
matches := matches asSortedCollection. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
676 |
best := matches longestCommonPrefix. |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
677 |
^ Array with:best with:matches asArray |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
678 |
|
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
679 |
" |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
680 |
DoWhatIMeanSupport resourceCompletion:'*debug*' inEnvironment:Smalltalk match:true ignoreCase:false |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
681 |
DoWhatIMeanSupport resourceCompletion:'context' inEnvironment:Smalltalk match:true ignoreCase:false |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
682 |
DoWhatIMeanSupport resourceCompletion:'key' inEnvironment:Smalltalk match:true ignoreCase:false |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
683 |
DoWhatIMeanSupport resourceCompletion:'cont' inEnvironment:Smalltalk match:true ignoreCase:false |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
684 |
" |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
685 |
|
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
686 |
"Created: / 06-07-2011 / 12:04:41 / cg" |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
687 |
! |
b5540a857436
added: #resourceCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
4047
diff
changeset
|
688 |
|
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
689 |
selectorCompletion:aPartialSymbolName inEnvironment:anEnvironment |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
690 |
"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
|
691 |
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
|
692 |
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
|
693 |
|
3863 | 694 |
^ self selectorCompletion:aPartialSymbolName inEnvironment:anEnvironment match:false |
695 |
! |
|
696 |
||
697 |
selectorCompletion:aPartialSymbolName inEnvironment:anEnvironment match:doMatch |
|
698 |
"given a partial selector, return an array consisting of |
|
699 |
2 entries: 1st: the longest match |
|
700 |
2nd: collection consisting of matching implemented selectors" |
|
701 |
||
3955
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
702 |
^ self |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
703 |
selectorCompletion:aPartialSymbolName |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
704 |
inEnvironment:anEnvironment |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
705 |
match:doMatch |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
706 |
ignoreCase:false |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
707 |
|
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
708 |
" |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
709 |
DoWhatIMeanSupport selectorCompletion:'inst*p' inEnvironment:Smalltalk match:true |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
710 |
DoWhatIMeanSupport selectorCompletion:'inst*pl' inEnvironment:Smalltalk match:true |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
711 |
DoWhatIMeanSupport selectorCompletion:'at:p' inEnvironment:Smalltalk match:true |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
712 |
DoWhatIMeanSupport selectorCompletion:'nextP' inEnvironment:Smalltalk match:true |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
713 |
DoWhatIMeanSupport selectorCompletion:'nextp' inEnvironment:Smalltalk match:true |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
714 |
" |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
715 |
|
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
716 |
"Modified: / 07-06-1996 / 08:44:33 / stefan" |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
717 |
"Modified: / 26-10-2010 / 20:30:27 / cg" |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
718 |
! |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
719 |
|
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
720 |
selectorCompletion:aPartialSymbolName inEnvironment:anEnvironment match:doMatch ignoreCase:ignoreCase |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
721 |
"given a partial selector, return an array consisting of |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
722 |
2 entries: 1st: the longest match |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
723 |
2nd: collection consisting of matching implemented selectors" |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
724 |
|
3863 | 725 |
|matches best lcSym isMatch| |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
726 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
727 |
matches := IdentitySet new. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
728 |
|
3863 | 729 |
isMatch := doMatch and:[aPartialSymbolName includesMatchCharacters]. |
730 |
||
3751 | 731 |
anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector | |
3863 | 732 |
(isMatch |
3955
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
733 |
ifTrue:[ (aPartialSymbolName match:eachSelector ignoreCase:ignoreCase) ] |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
734 |
ifFalse:[ ignoreCase |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
735 |
ifTrue:[ (eachSelector asLowercase startsWith:aPartialSymbolName asLowercase) ] |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
736 |
ifFalse:[ (eachSelector startsWith:aPartialSymbolName) ] ]) |
3863 | 737 |
ifTrue:[ |
3751 | 738 |
matches add:eachSelector |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
739 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
740 |
]. |
3955
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
741 |
(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
|
742 |
"/ search for case-ignoring match |
3867
03f7ad841731
changed: #selectorCompletion:inEnvironment:match:
Claus Gittinger <cg@exept.de>
parents:
3864
diff
changeset
|
743 |
lcSym := aPartialSymbolName asLowercase. |
3751 | 744 |
anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector | |
3863 | 745 |
(isMatch |
3867
03f7ad841731
changed: #selectorCompletion:inEnvironment:match:
Claus Gittinger <cg@exept.de>
parents:
3864
diff
changeset
|
746 |
ifTrue:[ (aPartialSymbolName match:eachSelector ignoreCase:true) ] |
3863 | 747 |
ifFalse:[ (eachSelector asLowercase startsWith:lcSym) ]) |
748 |
ifTrue:[ |
|
3751 | 749 |
matches add:eachSelector |
2661
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
750 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
751 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
752 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
753 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
754 |
matches isEmpty ifTrue:[ |
3864
10c7db09a580
changed: #selectorCompletion:inEnvironment:match:
Claus Gittinger <cg@exept.de>
parents:
3863
diff
changeset
|
755 |
^ 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
|
756 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
757 |
matches size == 1 ifTrue:[ |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
758 |
^ 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
|
759 |
]. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
760 |
matches := matches asSortedCollection. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
761 |
best := matches longestCommonPrefix. |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
762 |
^ 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
|
763 |
|
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
764 |
" |
3867
03f7ad841731
changed: #selectorCompletion:inEnvironment:match:
Claus Gittinger <cg@exept.de>
parents:
3864
diff
changeset
|
765 |
DoWhatIMeanSupport selectorCompletion:'inst*p' inEnvironment:Smalltalk match:true |
03f7ad841731
changed: #selectorCompletion:inEnvironment:match:
Claus Gittinger <cg@exept.de>
parents:
3864
diff
changeset
|
766 |
DoWhatIMeanSupport selectorCompletion:'inst*pl' inEnvironment:Smalltalk match:true |
03f7ad841731
changed: #selectorCompletion:inEnvironment:match:
Claus Gittinger <cg@exept.de>
parents:
3864
diff
changeset
|
767 |
DoWhatIMeanSupport selectorCompletion:'at:p' inEnvironment:Smalltalk match:true |
03f7ad841731
changed: #selectorCompletion:inEnvironment:match:
Claus Gittinger <cg@exept.de>
parents:
3864
diff
changeset
|
768 |
DoWhatIMeanSupport selectorCompletion:'nextP' inEnvironment:Smalltalk match:true |
03f7ad841731
changed: #selectorCompletion:inEnvironment:match:
Claus Gittinger <cg@exept.de>
parents:
3864
diff
changeset
|
769 |
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
|
770 |
" |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
771 |
|
3955
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
772 |
"Modified: / 07-06-1996 / 08:44:33 / stefan" |
94fb4a47d108
added: #selectorCompletion:inEnvironment:match:ignoreCase:
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
773 |
"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
|
774 |
! ! |
f68913f2facf
moved all input completion methods from Smalltalk to here.
Claus Gittinger <cg@exept.de>
parents:
2560
diff
changeset
|
775 |
|
2376 | 776 |
!DoWhatIMeanSupport class methodsFor:'rename support'! |
777 |
||
778 |
goodRenameDefaultFor:oldName lastOld:lastOldName lastNew:lastNewName |
|
2513 | 779 |
"generate a reasonable default for a rename operation. |
780 |
(used for rename category etc.)" |
|
2468 | 781 |
|
4065
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
782 |
|prefix suffix lastNewSize lastOldSize left right inserted deleted tryAgain| |
2376 | 783 |
|
784 |
lastNewName isNil ifTrue:[ ^ nil]. |
|
785 |
||
786 |
lastNewSize := lastNewName size. |
|
787 |
lastOldSize := lastOldName size. |
|
788 |
||
789 |
(lastNewName endsWith:lastOldName) ifTrue:[ |
|
2514 | 790 |
"last rename was |
791 |
'foo' -> 'Xfoo' |
|
792 |
then, a good default for |
|
793 |
'bar' would be 'Xbar' |
|
794 |
" |
|
2376 | 795 |
prefix := lastNewName copyTo:(lastNewSize - lastOldSize). |
796 |
^ (prefix , oldName). |
|
797 |
]. |
|
798 |
(lastOldName endsWith:lastNewName) ifTrue:[ |
|
2514 | 799 |
"last rename was |
800 |
'Xfoo' -> 'foo' |
|
801 |
then, a good default for |
|
802 |
'Xbar' would be 'bar' |
|
803 |
" |
|
2376 | 804 |
prefix := lastOldName copyTo:(lastOldSize - lastNewSize). |
2514 | 805 |
(oldName startsWith:prefix) ifTrue:[ |
806 |
^ (oldName copyFrom:prefix size+1). |
|
807 |
] |
|
808 |
]. |
|
809 |
(lastOldName asLowercase = lastNewName asLowercase) ifTrue:[ |
|
810 |
(lastOldName first ~= lastNewName first) ifTrue:[ |
|
811 |
(lastOldName first isLowercase = oldName first isLowercase) ifTrue:[ |
|
812 |
"last rename was |
|
813 |
'xfoo' -> 'Xfoo' |
|
814 |
then, a good default for |
|
815 |
'xbar' would be 'Xbar' |
|
816 |
" |
|
817 |
lastOldName first isLowercase ifTrue:[ |
|
818 |
^ oldName first asUppercase asString , (oldName copyFrom:2). |
|
819 |
] ifFalse:[ |
|
820 |
^ oldName first asLowercase asString , (oldName copyFrom:2). |
|
821 |
] |
|
822 |
] |
|
823 |
]. |
|
2376 | 824 |
]. |
825 |
(lastOldName withoutSeparators = lastNewName) ifTrue:[ |
|
2514 | 826 |
"last rename was |
827 |
' foo ' -> 'foo' |
|
828 |
then, a good default for |
|
829 |
' bar ' would be 'bar' |
|
830 |
" |
|
2376 | 831 |
^ oldName withoutSeparators. |
832 |
]. |
|
833 |
(lastNewName startsWith:lastOldName) ifTrue:[ |
|
2557 | 834 |
"last rename was |
835 |
'foo' -> 'fooX' |
|
836 |
then, a good default for |
|
837 |
'bar' would be 'barX' |
|
838 |
" |
|
2376 | 839 |
suffix := lastNewName copyLast:(lastNewSize - lastOldSize). |
840 |
^ (oldName , suffix). |
|
841 |
]. |
|
842 |
(lastOldName startsWith:lastNewName) ifTrue:[ |
|
2557 | 843 |
"last rename was |
844 |
'fooX' -> 'foo' |
|
845 |
then, a good default for |
|
846 |
'barX' would be 'bar' |
|
847 |
" |
|
2376 | 848 |
suffix := lastOldName copyLast:(lastOldSize - lastNewSize). |
849 |
(oldName endsWith:suffix) ifTrue:[ |
|
4210
5c5f1603748d
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4195
diff
changeset
|
850 |
^ (oldName copyButLast:suffix size). |
2376 | 851 |
] |
852 |
]. |
|
2558 | 853 |
|
2557 | 854 |
prefix := lastOldName commonPrefixWith:lastNewName. |
855 |
suffix := lastOldName commonSuffixWith:lastNewName. |
|
2559 | 856 |
|
2558 | 857 |
(prefix size > 0) ifTrue:[ |
858 |
(suffix size > 0) ifTrue:[ |
|
2559 | 859 |
|
860 |
prefix := prefix copyTo:(((lastNewName size - suffix size) min:(lastOldName size - suffix size)) min:prefix size). |
|
861 |
||
2558 | 862 |
"last rename was |
863 |
'fooR' -> 'fooXR' |
|
864 |
then, a good default for |
|
865 |
'barR' would be 'barXR' |
|
866 |
" |
|
867 |
left := lastOldName copyTo:prefix size. |
|
868 |
right := lastOldName copyLast:suffix size. |
|
2559 | 869 |
lastNewSize > lastOldSize ifTrue:[ |
4210
5c5f1603748d
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4195
diff
changeset
|
870 |
inserted := (lastNewName copyFrom:(left size + 1)) copyButLast:(right size). |
2559 | 871 |
inserted size > 0 ifTrue:[ |
3532 | 872 |
(oldName startsWith:prefix) ifTrue:[ |
873 |
^ (oldName copyTo:prefix size) , inserted , (oldName copyFrom:prefix size + 1) |
|
874 |
]. |
|
2559 | 875 |
]. |
876 |
]. |
|
3585 | 877 |
(oldName string endsWith:suffix string) ifTrue:[ |
4210
5c5f1603748d
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4195
diff
changeset
|
878 |
deleted := (lastOldName string copyFrom:(prefix size + 1)) copyButLast:(suffix size). |
3585 | 879 |
(oldName size-suffix size-deleted size + 1) >= 1 ifTrue:[ |
880 |
((oldName copyFrom:oldName size-suffix size-deleted size + 1) copyTo:deleted size) = deleted ifTrue:[ |
|
881 |
"last rename was |
|
882 |
'fooXR' -> 'fooR' |
|
883 |
then, a good default for |
|
884 |
'barXS' would be 'barS' |
|
885 |
" |
|
886 |
^ (oldName copyTo:oldName size-suffix size-deleted size) , suffix |
|
887 |
] |
|
2559 | 888 |
] |
889 |
] |
|
2558 | 890 |
]. |
891 |
||
892 |
(oldName endsWith:(lastOldName copyFrom:prefix size+1)) ifTrue:[ |
|
893 |
"last rename was |
|
894 |
'fooX' -> 'fooY' |
|
895 |
then, a good default for |
|
896 |
'barX' would be 'barY' |
|
897 |
" |
|
4210
5c5f1603748d
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4195
diff
changeset
|
898 |
left := oldName copyButLast:(lastOldName copyFrom:prefix size+1) size. |
2558 | 899 |
right := lastNewName copyFrom:prefix size+1. |
900 |
^ left , right |
|
901 |
] |
|
2557 | 902 |
]. |
2376 | 903 |
|
4065
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
904 |
suffix size > 0 ifTrue:[ |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
905 |
|prefix2| |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
906 |
|
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
907 |
"last rename was: |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
908 |
'fooSUFF1' -> 'barSUFF1' |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
909 |
then, a good default for |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
910 |
'fooSUFF2' -> 'barSUFF2' |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
911 |
" |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
912 |
prefix := lastOldName copyTo:(lastOldName size - suffix size). "/ the foo |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
913 |
(oldName startsWith:prefix) ifTrue:[ |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
914 |
prefix2 := lastNewName copyTo:(lastNewName size - suffix size). "/ the bar |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
915 |
^ prefix2,(oldName copyFrom:(prefix size+1)). |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
916 |
]. |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
917 |
]. |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
918 |
|
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
919 |
"/ was there something stripped at the end? |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
920 |
suffix := oldName commonSuffixWith:lastOldName. |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
921 |
[suffix size > 0] whileTrue:[ |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
922 |
tryAgain := self |
4210
5c5f1603748d
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4195
diff
changeset
|
923 |
goodRenameDefaultFor:(oldName copyButLast:suffix size) |
5c5f1603748d
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4195
diff
changeset
|
924 |
lastOld:(lastOldName copyButLast:suffix size) |
4065
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
925 |
lastNew:lastNewName. |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
926 |
tryAgain notNil ifTrue:[^ tryAgain]. |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
927 |
suffix := suffix copyFrom:2. |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
928 |
]. |
2382
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
929 |
^ nil |
2557 | 930 |
|
931 |
" |
|
2558 | 932 |
self goodRenameDefaultFor:'bar' lastOld:'foo' lastNew:'fooXX' |
933 |
self goodRenameDefaultFor:'bar' lastOld:'foo' lastNew:'XXfoo' |
|
934 |
||
935 |
self goodRenameDefaultFor:'barXX' lastOld:'fooXX' lastNew:'foo' |
|
936 |
self goodRenameDefaultFor:'XXbar' lastOld:'XXfoo' lastNew:'foo' |
|
937 |
||
938 |
self goodRenameDefaultFor:'barXX' lastOld:'fooXX' lastNew:'fooYY' |
|
939 |
self goodRenameDefaultFor:'XXbar' lastOld:'XXfoo' lastNew:'foo' |
|
940 |
||
2559 | 941 |
self goodRenameDefaultFor:'bar2' lastOld:'foo1' lastNew:'foo01' |
942 |
self goodRenameDefaultFor:'barXY' lastOld:'fooXY' lastNew:'fooY' |
|
2560 | 943 |
self goodRenameDefaultFor:'bar' lastOld:'foo' lastNew:'fXoo' |
944 |
self goodRenameDefaultFor:'bar' lastOld:'foo' lastNew:'fXXXoo' |
|
2559 | 945 |
self goodRenameDefaultFor:'bar' lastOld:'foo' lastNew:'foXXXo' |
946 |
||
947 |
self goodRenameDefaultFor:'bar001' lastOld:'foo001' lastNew:'foo002_001' |
|
2560 | 948 |
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
|
949 |
|
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
950 |
self goodRenameDefaultFor:'mti.odt2.level1HeadlineStyle' |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
951 |
lastOld:'mti.odt2.level1HeadlineMatchPattern' |
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
952 |
lastNew:'Key_odt2_level1HeadlineMatchPattern' |
2557 | 953 |
" |
4065
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
954 |
|
ebea28fa8bab
changed: #goodRenameDefaultFor:lastOld:lastNew:
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
955 |
"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
|
956 |
! |
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
957 |
|
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
958 |
goodRenameDefaultForFile:oldName lastOld:lastOldName lastNew:lastNewName |
2513 | 959 |
"generate a reasonable default for a file rename operation. |
960 |
(Try to rename multiple files in the new fileBrowser, |
|
961 |
to see what this is doing)" |
|
2468 | 962 |
|
2382
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
963 |
|prefix suffix t |
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
964 |
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
|
965 |
lastRemoved lastInserted default| |
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
966 |
|
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
967 |
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
|
968 |
default notNil ifTrue:[ ^ default]. |
d89d86edaae4
separated default for arbitrary renames and deault for files.
Claus Gittinger <cg@exept.de>
parents:
2376
diff
changeset
|
969 |
|
3135
7ad9ff29225e
changed #classCategoryLoadFromRepository
Claus Gittinger <cg@exept.de>
parents:
2977
diff
changeset
|
970 |
lastOldWOSuffix := lastOldName asFilename nameWithoutSuffix. |
7ad9ff29225e
changed #classCategoryLoadFromRepository
Claus Gittinger <cg@exept.de>
parents:
2977
diff
changeset
|
971 |
lastNewWOSuffix := lastNewName asFilename nameWithoutSuffix. |
7ad9ff29225e
changed #classCategoryLoadFromRepository
Claus Gittinger <cg@exept.de>
parents:
2977
diff
changeset
|
972 |
oldWOSuffix := oldName asFilename nameWithoutSuffix. |
2376 | 973 |
|
2434 | 974 |
"/ suffix change ? |
975 |
lastOldWOSuffix = lastNewWOSuffix ifTrue:[ |
|
976 |
lastOldName asFilename suffix ~= lastNewName asFilename suffix ifTrue:[ |
|
977 |
^ (oldName asFilename withSuffix:(lastNewName asFilename suffix)) pathName |
|
978 |
]. |
|
979 |
]. |
|
980 |
||
2553 | 981 |
default := self goodRenameDefaultFor:oldWOSuffix lastOld:lastOldWOSuffix lastNew:lastNewWOSuffix. |
982 |
default notNil ifTrue:[ |
|
983 |
lastOldRest := lastOldName copyFrom:lastOldWOSuffix size + 1. |
|
984 |
lastNewRest := lastNewName copyFrom:lastNewWOSuffix size + 1. |
|
985 |
oldRest := oldName copyFrom:oldWOSuffix size + 1. |
|
986 |
||
987 |
^ default , lastNewRest |
|
988 |
]. |
|
989 |
||
2376 | 990 |
prefix := lastOldWOSuffix commonPrefixWith:oldWOSuffix. |
991 |
(lastNewWOSuffix startsWith:prefix) ifTrue:[ |
|
992 |
lastOldRest := lastOldWOSuffix copyFrom:prefix size + 1. |
|
993 |
lastNewRest := lastNewWOSuffix copyFrom:prefix size + 1. |
|
994 |
oldRest := oldWOSuffix copyFrom:prefix size + 1. |
|
995 |
||
996 |
(lastNewRest endsWith:lastOldRest) ifTrue:[ |
|
4210
5c5f1603748d
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4195
diff
changeset
|
997 |
t := lastNewRest copyButLast:lastOldRest size. |
2376 | 998 |
^ ((prefix , t , oldRest) asFilename withSuffix:oldName asFilename suffix) name |
999 |
]. |
|
1000 |
]. |
|
1001 |
||
1002 |
suffix := lastOldWOSuffix commonSuffixWith:lastNewWOSuffix. |
|
1003 |
suffix size > 0 ifTrue:[ |
|
1004 |
"/ last change changed something at the beginning |
|
1005 |
prefix := oldWOSuffix commonPrefixWith:lastOldWOSuffix. |
|
1006 |
prefix size > 0 ifTrue:[ |
|
1007 |
"/ 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
|
1008 |
lastRemoved := lastOldWOSuffix copyButLast:suffix size. |
5c5f1603748d
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4195
diff
changeset
|
1009 |
lastInserted := lastNewWOSuffix copyButLast:suffix size. |
2376 | 1010 |
(lastRemoved startsWith:lastInserted) ifTrue:[ |
1011 |
oldWOSuffix size >= lastInserted size ifTrue:[ |
|
1012 |
^ (oldWOSuffix copyTo:lastInserted size) , (oldName copyFrom:lastRemoved size + 1) |
|
1013 |
] |
|
1014 |
]. |
|
1015 |
^ lastInserted , (oldName copyFrom:lastRemoved size + 1) |
|
1016 |
]. |
|
1017 |
]. |
|
1018 |
||
1019 |
^ nil |
|
3135
7ad9ff29225e
changed #classCategoryLoadFromRepository
Claus Gittinger <cg@exept.de>
parents:
2977
diff
changeset
|
1020 |
|
7ad9ff29225e
changed #classCategoryLoadFromRepository
Claus Gittinger <cg@exept.de>
parents:
2977
diff
changeset
|
1021 |
"Modified: / 07-11-2006 / 13:58:39 / cg" |
2376 | 1022 |
! ! |
1023 |
||
2515
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
1024 |
!DoWhatIMeanSupport class methodsFor:'typing distance'! |
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
1025 |
|
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
1026 |
isKey:k1 nextTo:k2 |
2774 | 1027 |
"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
|
1028 |
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
|
1029 |
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
|
1030 |
|
3316 | 1031 |
^ 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
|
1032 |
|
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
1033 |
" |
3299
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1034 |
self isKey:$a nextTo:$a |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1035 |
self isKey:$a nextTo:$s |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1036 |
self isKey:$a nextTo:$q |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1037 |
self isKey:$a nextTo:$w |
1cd4b22434a6
code completion stuff moved to here (for reuse)
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
1038 |
self isKey:$a nextTo:$z |
2517 | 1039 |
self isKey:$a nextTo:$x |
2515
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
1040 |
" |
3316 | 1041 |
|
1042 |
"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
|
1043 |
! |
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
1044 |
|
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
1045 |
isKey:k1 nextTo:k2 onKeyboard:keys |
2774 | 1046 |
"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
|
1047 |
|
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
1048 |
|row1 row2 col1 col2| |
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
1049 |
|
2774 | 1050 |
row1 := keys findFirst:[:eachRow | col1 := eachRow indexOf:k1. col1 ~~ 0]. |
2517 | 1051 |
row1 == 0 ifTrue:[^ false]. |
2774 | 1052 |
row2 := keys findFirst:[:eachRow | col2 := eachRow indexOf:k2. col2 ~~ 0]. |
2517 | 1053 |
row2 == 0 ifTrue:[^ false]. |
2515
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
1054 |
|
2774 | 1055 |
^ (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
|
1056 |
|
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
1057 |
" |
2774 | 1058 |
self isKey:$a nextTo:$q |
2517 | 1059 |
self isKey:$a nextTo:$x |
2515
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
1060 |
" |
3316 | 1061 |
! |
1062 |
||
1063 |
keyboard |
|
4093 | 1064 |
"the keyboard layout (useful to figure out which keys are nearby a key, |
1065 |
to find possible typing errors)" |
|
3316 | 1066 |
|
1067 |
|lang| |
|
1068 |
||
1069 |
lang := UserPreferences current language. |
|
1070 |
lang == #de ifTrue:[ |
|
1071 |
^ #( |
|
1072 |
'1234567890-' |
|
1073 |
'*qwertzuiop' |
|
1074 |
'**asdfghjkl:' |
|
1075 |
'***yxcvbnm' ). |
|
1076 |
]. |
|
1077 |
||
1078 |
lang == #fr ifTrue:[ |
|
1079 |
^ #( |
|
1080 |
'1234567890' |
|
1081 |
'*azertyuiop' |
|
1082 |
'**qsdfghjklm' |
|
1083 |
'***wxcvbn,' ). |
|
1084 |
]. |
|
1085 |
||
1086 |
^ #( |
|
1087 |
'1234567890-' |
|
1088 |
'*qwertyuiop' |
|
1089 |
'**asdfghjkl:' |
|
1090 |
'***zxcvbnm' ). |
|
1091 |
||
1092 |
" |
|
1093 |
self keyboard |
|
1094 |
" |
|
1095 |
||
1096 |
"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
|
1097 |
! ! |
69cbb89c127e
+isKey:nextTo: for simple typo detection
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
1098 |
|
4238 | 1099 |
!DoWhatIMeanSupport methodsFor:'code completion'! |
1100 |
||
1101 |
codeCompletionForClass:classOrNilArg context:contextOrNil codeView:codeViewArg |
|
1102 |
"contextOrNil is the current context, if this is called from the debugger; |
|
1103 |
nil, if called from the browser. |
|
1104 |
If nonNil, we can make better guesses, because we actually know what a variable's type is. |
|
1105 |
This is not yet done, sigh" |
|
1106 |
||
1107 |
|crsrPos char interval source node parent checkedNode| |
|
1108 |
||
1109 |
classOrNil := classOrNilArg. |
|
1110 |
codeView := codeViewArg. |
|
1111 |
||
1112 |
"/ classOrNil isNil ifTrue:[ |
|
1113 |
"/ self information:'No class'. |
|
1114 |
"/ ^ self. |
|
1115 |
"/ ]. |
|
1116 |
||
1117 |
crsrPos := codeView characterPositionOfCursor"-1". |
|
1118 |
char := codeView characterAtCharacterPosition:crsrPos. |
|
4301 | 1119 |
"/ Transcript show:crsrPos; show:' '; showCR:char. |
4238 | 1120 |
[crsrPos > 1 and:[char isSeparator or:['.' includes:char]]] whileTrue:[ |
1121 |
crsrPos := crsrPos - 1. |
|
1122 |
char := codeView characterAtCharacterPosition:crsrPos. |
|
1123 |
]. |
|
1124 |
||
1125 |
interval := codeView selectedInterval. |
|
4301 | 1126 |
"/ Transcript show:'iv: '; showCR:interval. |
4238 | 1127 |
interval isEmpty ifTrue:[ |
4301 | 1128 |
interval := crsrPos"-1" to:crsrPos. |
1129 |
"/ Transcript show:'iv2: '; showCR:interval. |
|
4238 | 1130 |
]. |
1131 |
||
1132 |
source := codeView contentsAsString string. |
|
1133 |
source := source copyTo:crsrPos. |
|
1134 |
||
1135 |
"/ this is too naive and stupid; if there is a syntactic error, |
|
1136 |
"/ we will not find a node for a long time (stepping back more and more, |
|
1137 |
"/ until reaching the beginning). This leads to a thousand and more times reparsing |
|
1138 |
"/ without any progress. |
|
1139 |
"/ TODO: do it vice-versa, in that the parser does a callOut for every node generated |
|
1140 |
"/ as it parses the code. Stop, when the interval is hit. |
|
1141 |
"/ that will also work for syntactic incorrect source code. |
|
1142 |
classOrNil notNil ifTrue:[ |
|
1143 |
node := self findNodeForInterval:interval in:source allowErrors:true mustBeMethod:true. |
|
4301 | 1144 |
"/ Transcript show:'nd1: '; showCR:node. |
4238 | 1145 |
]. |
1146 |
node isNil ifTrue:[ |
|
1147 |
node := self findNodeForInterval:interval in:source allowErrors:true mustBeMethod:false. |
|
4301 | 1148 |
"/ Transcript show:'nd2: '; showCR:node. |
4238 | 1149 |
]. |
1150 |
"/ [node isNil] whileTrue:[ |
|
1151 |
"/ "/ expand to the left ... |
|
1152 |
"/ interval start > 1 ifFalse:[ |
|
1153 |
"/ self information:'No parseNode found'. |
|
1154 |
"/ ^ self. |
|
1155 |
"/ ]. |
|
1156 |
"/ interval start:(interval start - 1). |
|
1157 |
"/ node := self findNodeForInterval:interval in:source allowErrors:true. |
|
1158 |
"/ ]. |
|
1159 |
node isNil ifTrue:[ |
|
1160 |
Transcript showCR:'No parseNode found'. |
|
1161 |
self breakPoint:#cg. |
|
1162 |
self information:'No parseNode found'. |
|
1163 |
^ self. |
|
1164 |
]. |
|
1165 |
||
1166 |
(node isVariable |
|
1167 |
and:[ (parent := node parent) notNil |
|
1168 |
and:[ parent isMessage |
|
1169 |
and:[ node stop < (codeView characterPositionOfCursor-1) ]]]) ifTrue:[ |
|
1170 |
node := parent. |
|
1171 |
]. |
|
1172 |
||
1173 |
node isVariable ifTrue:[ |
|
1174 |
self codeCompletionForVariable:node inClass:classOrNil codeView:codeView. |
|
1175 |
^ self. |
|
1176 |
]. |
|
1177 |
node isLiteral ifTrue:[ |
|
1178 |
node value isSymbol ifTrue:[ |
|
1179 |
self codeCompletionForLiteralSymbol:node inClass:classOrNil codeView:codeView. |
|
1180 |
^ self. |
|
1181 |
]. |
|
1182 |
]. |
|
1183 |
||
1184 |
checkedNode := node. |
|
1185 |
[checkedNode notNil] whileTrue:[ |
|
1186 |
checkedNode isMessage ifTrue:[ |
|
1187 |
"/ completion in a message-send |
|
1188 |
self codeCompletionForMessage:checkedNode inClass:classOrNil codeView:codeView. |
|
1189 |
^ self |
|
1190 |
]. |
|
1191 |
checkedNode isMethod ifTrue:[ |
|
1192 |
"/ completion in a method's selector pattern |
|
1193 |
self codeCompletionForMethod:checkedNode inClass:classOrNil codeView:codeView. |
|
1194 |
^ self. |
|
1195 |
]. |
|
1196 |
checkedNode := checkedNode parent. |
|
1197 |
]. |
|
1198 |
||
1199 |
self information:'Node is neither variable nor message.'. |
|
1200 |
||
1201 |
"Modified: / 04-07-2006 / 18:48:26 / fm" |
|
1202 |
"Modified: / 16-09-2011 / 14:54:47 / cg" |
|
1203 |
! ! |
|
1204 |
||
1205 |
!DoWhatIMeanSupport methodsFor:'code completion-helpers'! |
|
1206 |
||
1207 |
askUserForCompletion:what for:codeView at:position from:allTheBest |
|
1208 |
|list choice lastChoice| |
|
1209 |
||
1210 |
"/ cg: until the new stuff works,... |
|
1211 |
^ self old_askUserForCompletion:what for:codeView from:allTheBest. |
|
1212 |
||
1213 |
allTheBest isEmpty ifTrue:[ |
|
1214 |
^ nil |
|
1215 |
]. |
|
1216 |
allTheBest size == 1 ifTrue:[ |
|
1217 |
^ allTheBest first |
|
1218 |
]. |
|
1219 |
list := allTheBest. |
|
1220 |
LastChoices notNil ifTrue:[ |
|
1221 |
lastChoice := LastChoices at:what ifAbsent:nil. |
|
1222 |
lastChoice notNil ifTrue:[ |
|
4301 | 1223 |
list := { lastChoice allBold } , (list copyWithout:lastChoice). |
4238 | 1224 |
]. |
1225 |
]. |
|
1226 |
choice := Tools::CodeCompletionMenu |
|
1227 |
openFor:codeView |
|
1228 |
at:position |
|
1229 |
with:allTheBest. |
|
1230 |
LastChoices isNil ifTrue:[ |
|
1231 |
LastChoices := Dictionary new. |
|
1232 |
]. |
|
1233 |
LastChoices at:what put:choice. |
|
4301 | 1234 |
^ choice string |
4238 | 1235 |
|
1236 |
"Created: / 16-02-2010 / 10:09:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1237 |
"Modified (format): / 08-07-2011 / 08:49:35 / cg" |
|
1238 |
! |
|
1239 |
||
1240 |
askUserForCompletion:what for:codeView from:allTheBest |
|
1241 |
|list resources choice lastChoice| |
|
1242 |
||
1243 |
allTheBest isEmpty ifTrue:[ ^ nil ]. |
|
1244 |
allTheBest size == 1 ifTrue:[ ^ allTheBest first ]. |
|
1245 |
||
1246 |
list := allTheBest. |
|
1247 |
LastChoices notNil ifTrue:[ |
|
1248 |
lastChoice := LastChoices at:what ifAbsent:nil. |
|
1249 |
lastChoice notNil ifTrue:[ |
|
1250 |
list := {lastChoice. nil. } , (list copyWithout:lastChoice). |
|
1251 |
]. |
|
1252 |
]. |
|
1253 |
||
1254 |
list size < 30 ifTrue:[ |
|
1255 |
|menu idx exitKey| |
|
1256 |
||
1257 |
menu := PopUpMenu labels:list. |
|
1258 |
menu hideOnKeyFilter:[:key | |hide| |
|
1259 |
hide := ( #( CursorDown CursorUp Escape Return ) includes: key) not. |
|
1260 |
hide ifTrue:[ |
|
1261 |
exitKey := key. |
|
1262 |
]. |
|
1263 |
hide]. |
|
1264 |
||
1265 |
idx := menu startUp. |
|
1266 |
idx == 0 ifTrue:[ |
|
1267 |
exitKey notNil ifTrue:[ |
|
1268 |
codeView keyPress:exitKey x:0 y:0. |
|
1269 |
]. |
|
1270 |
^ nil |
|
1271 |
]. |
|
1272 |
choice := list at:idx. |
|
1273 |
] ifFalse:[ |
|
1274 |
resources := codeView application isNil |
|
1275 |
ifTrue:[ codeView resources] |
|
1276 |
ifFalse:[ codeView application resources ]. |
|
1277 |
||
1278 |
choice := Dialog |
|
1279 |
choose:(resources string:'Choose ',what) |
|
1280 |
fromList:list |
|
1281 |
lines:20 |
|
1282 |
title:(resources string:'Code completion'). |
|
1283 |
choice isNil ifTrue:[^ nil]. |
|
1284 |
]. |
|
1285 |
||
1286 |
LastChoices isNil ifTrue:[ |
|
1287 |
LastChoices := Dictionary new. |
|
1288 |
]. |
|
1289 |
LastChoices at:what put:choice. |
|
1290 |
^ choice |
|
1291 |
||
1292 |
"Created: / 10-11-2006 / 14:00:53 / cg" |
|
1293 |
! |
|
1294 |
||
1295 |
codeCompletionForLiteralSymbol:node into:actionBlock |
|
1296 |
|sym possibleCompletions best start stop oldLen newLen oldVar| |
|
1297 |
||
4302 | 1298 |
"/ Transcript show:'lit in '; show:methodOrNil; show:' / '; showCR:classOrNil. |
4238 | 1299 |
|
1300 |
sym := node value. |
|
1301 |
possibleCompletions := OrderedCollection new. |
|
1302 |
||
1303 |
Symbol allInstancesDo:[:existingSym | |
|
1304 |
(existingSym startsWith:sym) ifTrue:[ |
|
1305 |
(existingSym = sym) ifFalse:[ |
|
1306 |
possibleCompletions add:existingSym |
|
1307 |
]. |
|
1308 |
]. |
|
1309 |
]. |
|
1310 |
possibleCompletions sort. |
|
1311 |
||
1312 |
best := possibleCompletions longestCommonPrefix. |
|
1313 |
(best = sym or:[(possibleCompletions includes:best) not]) ifTrue:[ |
|
1314 |
actionBlock value:possibleCompletions value:nil. |
|
1315 |
^ self. |
|
1316 |
]. |
|
1317 |
||
1318 |
actionBlock value:(Array with:best) value:nil. |
|
1319 |
^ self. |
|
1320 |
"/ self showInfo:best. |
|
1321 |
||
1322 |
start := node start. |
|
1323 |
stop := node stop. |
|
1324 |
(codeView characterAtCharacterPosition:start) == $# ifTrue:[ |
|
1325 |
start := start + 1. |
|
1326 |
]. |
|
1327 |
(codeView characterAtCharacterPosition:start) == $' ifTrue:[ |
|
1328 |
start := start + 1. |
|
1329 |
stop := stop - 1. |
|
1330 |
]. |
|
1331 |
||
1332 |
oldVar := (codeView textFromCharacterPosition:start to:stop) asString string withoutSeparators. |
|
1333 |
||
1334 |
codeView |
|
1335 |
undoableDo:[ codeView replaceFromCharacterPosition:start to:stop with:best ] |
|
1336 |
info:'Completion'. |
|
1337 |
||
1338 |
(best startsWith:oldVar) ifTrue:[ |
|
1339 |
oldLen := stop - start + 1. |
|
1340 |
newLen := best size. |
|
1341 |
codeView selectFromCharacterPosition:start+oldLen to:start+newLen-1. |
|
1342 |
codeView dontReplaceSelectionOnInput |
|
1343 |
]. |
|
1344 |
||
1345 |
"Modified: / 16-02-2010 / 10:15:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1346 |
"Modified (format): / 03-07-2011 / 15:58:45 / cg" |
|
1347 |
! |
|
1348 |
||
1349 |
codeCompletionForMessage:node into:actionBlock |
|
1350 |
|selector srchClass implClass |
|
1351 |
bestSelectors selector2 bestSelectors2 allBest best info numArgs |
|
1352 |
newParts nSelParts oldLen newLen selectorParts |
|
1353 |
findBest parentNode selectorInBest selector2InBest2 |
|
1354 |
parser selectorsSentInCode split editAction| |
|
1355 |
||
4302 | 1356 |
"/ Transcript show:'msg in '; show:methodOrNil; show:' / '; showCR:classOrNil. |
4238 | 1357 |
|
1358 |
"/ classOrNil notNil ifTrue:[ |
|
1359 |
"/ parser := Parser parseMethod:codeView contents string in:classOrNil ignoreErrors:true ignoreWarnings:true. |
|
1360 |
"/ selectorsSentInCode := parser messagesSent. |
|
1361 |
"/ ]. |
|
1362 |
||
1363 |
findBest := [:node :selector | |
|
1364 |
|srchClass bestSelectors bestPrefixes| |
|
1365 |
||
1366 |
codeView topView withCursor:(Cursor questionMark) do:[ |
|
1367 |
srchClass := self lookupClassForMessage:node inClass:classOrNil. |
|
1368 |
srchClass notNil ifTrue:[ |
|
1369 |
bestSelectors := Parser findBest:30 selectorsFor:selector in:srchClass forCompletion:true. |
|
1370 |
] ifFalse:[ |
|
1371 |
bestSelectors := Parser findBest:30 selectorsFor:selector in:nil forCompletion:true. |
|
1372 |
]. |
|
1373 |
]. |
|
1374 |
||
1375 |
(bestSelectors includes:selector) ifTrue:[ |
|
1376 |
bestSelectors := bestSelectors select:[:sel | sel size > selector size]. |
|
1377 |
]. |
|
1378 |
bestSelectors |
|
1379 |
]. |
|
1380 |
||
1381 |
selector := node selector. |
|
1382 |
bestSelectors := findBest value:node value:selector. |
|
1383 |
||
1384 |
parentNode := node parent. |
|
1385 |
||
1386 |
"/ if its a unary message AND the parent is a keyword node, look for parent completion too. |
|
1387 |
(node selector isUnarySelector |
|
1388 |
and:[ parentNode notNil |
|
1389 |
and:[ parentNode isMessage |
|
1390 |
and:[ (selector2 := parentNode selector) isKeywordSelector ]]]) ifTrue:[ |
|
1391 |
"/ srchClass2 := self lookupClassForMessage:parentNode inClass:classOrNil. |
|
1392 |
selector2 := selector2,selector. |
|
1393 |
bestSelectors2 := findBest value:parentNode value:selector2. |
|
1394 |
]. |
|
1395 |
||
1396 |
bestSelectors2 isEmptyOrNil ifTrue:[ |
|
1397 |
allBest := bestSelectors. |
|
1398 |
] ifFalse:[ |
|
1399 |
bestSelectors isEmptyOrNil ifTrue:[ |
|
1400 |
allBest := bestSelectors2 |
|
1401 |
] ifFalse:[ |
|
1402 |
selectorInBest := (bestSelectors contains:[:sel | sel asLowercase startsWith:selector asLowercase]). |
|
1403 |
selector2InBest2 := (bestSelectors2 contains:[:sel | sel asLowercase startsWith:selector2 asLowercase]). |
|
1404 |
||
1405 |
(selectorInBest not and:[ selector2InBest2 ]) ifTrue:[ |
|
1406 |
"/ selector2 is more likely |
|
1407 |
allBest := bestSelectors2 |
|
1408 |
] ifFalse:[ |
|
1409 |
(selectorInBest and:[ selector2InBest2 not ]) ifTrue:[ |
|
1410 |
"/ selector more likely |
|
1411 |
allBest := bestSelectors |
|
1412 |
] ifFalse:[ |
|
1413 |
"/ assume same likelyness |
|
1414 |
||
1415 |
allBest := bestSelectors isEmpty |
|
1416 |
ifTrue:[ bestSelectors2 ] |
|
1417 |
ifFalse:[ bestSelectors , #(nil) , bestSelectors2 ]. |
|
1418 |
] |
|
1419 |
]. |
|
1420 |
]. |
|
1421 |
]. |
|
1422 |
||
1423 |
allBest isEmptyOrNil ifTrue:[ ^ self ]. |
|
1424 |
||
1425 |
split := [:list :splitHow | |
|
1426 |
|part1 part2 all| |
|
1427 |
||
1428 |
part1 := list select:splitHow. |
|
1429 |
part2 := list reject:splitHow. |
|
1430 |
part1 isEmpty ifTrue:[ |
|
1431 |
all := part2. |
|
1432 |
] ifFalse:[ |
|
1433 |
part2 isEmpty ifTrue:[ |
|
1434 |
all := part1. |
|
1435 |
] ifFalse:[ |
|
1436 |
all := part1 , part2. |
|
1437 |
] |
|
1438 |
]. |
|
1439 |
all |
|
1440 |
]. |
|
1441 |
||
1442 |
selectorsSentInCode notNil ifTrue:[ |
|
1443 |
"/ the ones already sent in the code are moved to the top of the list. |
|
1444 |
allBest := split value:allBest value:[:sel | selectorsSentInCode includes:sel]. |
|
1445 |
]. |
|
1446 |
||
1447 |
"/ the ones which are a prefix are moved towards the top of the list |
|
1448 |
allBest := split value:allBest value:[:sel | sel notNil and:[sel startsWith:selector]]. |
|
1449 |
||
1450 |
false ifTrue:[ |
|
1451 |
srchClass notNil ifTrue:[ |
|
1452 |
implClass := srchClass whichClassIncludesSelector:best. |
|
1453 |
] ifFalse:[ |
|
1454 |
implClass := Smalltalk allClasses select:[:cls | (cls includesSelector:best) or:[cls class includesSelector:best]]. |
|
1455 |
implClass size == 1 ifTrue:[ |
|
1456 |
implClass := implClass first. |
|
1457 |
] ifFalse:[ |
|
1458 |
implClass := nil |
|
1459 |
] |
|
1460 |
]. |
|
1461 |
||
1462 |
info := best storeString. |
|
1463 |
implClass notNil ifTrue:[ |
|
1464 |
info := implClass name , ' >> ' , info. |
|
1465 |
]. |
|
1466 |
self information:info. |
|
1467 |
]. |
|
1468 |
editAction := |
|
1469 |
[:index | |
|
1470 |
|best| |
|
1471 |
||
1472 |
best := allBest at:index. |
|
1473 |
||
1474 |
best ~= selector ifTrue:[ |
|
1475 |
numArgs := best numArgs. |
|
1476 |
(bestSelectors2 notEmptyOrNil and:[bestSelectors2 includes:best]) ifTrue:[ |
|
1477 |
selectorParts := parentNode selectorParts , node selectorParts. |
|
1478 |
] ifFalse:[ |
|
1479 |
selectorParts := node selectorParts. |
|
1480 |
]. |
|
1481 |
nSelParts := selectorParts size. |
|
1482 |
||
1483 |
newParts := best asCollectionOfSubstringsSeparatedBy:$:. |
|
1484 |
newParts := newParts select:[:part | part size > 0]. |
|
1485 |
||
1486 |
codeView |
|
1487 |
undoableDo:[ |
|
1488 |
|newCursorPosition stop| |
|
1489 |
||
1490 |
numArgs > nSelParts ifTrue:[ |
|
1491 |
stop := selectorParts last stop. |
|
1492 |
||
1493 |
"/ append the rest ... |
|
1494 |
numArgs downTo:nSelParts+1 do:[:idx | |
|
1495 |
|newPart| |
|
1496 |
||
1497 |
newPart := newParts at:idx. |
|
1498 |
(best endsWith:$:) ifTrue:[ |
|
1499 |
newPart := newPart , ':' |
|
1500 |
]. |
|
1501 |
||
1502 |
(codeView characterAtCharacterPosition:stop) == $: ifFalse:[ |
|
1503 |
newPart := ':' , newPart. |
|
1504 |
]. |
|
1505 |
newPart := (codeView characterAtCharacterPosition:stop) asString , newPart. |
|
1506 |
||
1507 |
codeView replaceFromCharacterPosition:stop to:stop with:newPart. |
|
1508 |
newCursorPosition := stop + newPart size. |
|
1509 |
] |
|
1510 |
]. |
|
1511 |
||
1512 |
(nSelParts min:newParts size) downTo:1 do:[:idx | |
|
1513 |
|newPart oldPartialToken start stop| |
|
1514 |
||
1515 |
newPart := newParts at:idx. |
|
1516 |
oldPartialToken := selectorParts at:idx. |
|
1517 |
start := oldPartialToken start. |
|
1518 |
stop := oldPartialToken stop. |
|
1519 |
||
1520 |
(best endsWith:$:) ifTrue:[ |
|
1521 |
(codeView characterAtCharacterPosition:stop+1) == $: ifFalse:[ |
|
1522 |
newPart := newPart , ':' |
|
1523 |
] |
|
1524 |
] ifFalse:[ |
|
1525 |
(codeView characterAtCharacterPosition:stop) == $: ifTrue:[ |
|
1526 |
newPart := newPart , ':' |
|
1527 |
] ifFalse:[ |
|
1528 |
(codeView characterAtCharacterPosition:stop+1) isSeparator ifFalse:[ |
|
1529 |
newPart := newPart , ' ' |
|
1530 |
] |
|
1531 |
] |
|
1532 |
"/ codeView replaceFromCharacterPosition:start to:stop with:(newPart , ':'). |
|
1533 |
"/ ] ifFalse:[ |
|
1534 |
"/ codeView replaceFromCharacterPosition:start to:stop with:newPart. |
|
1535 |
]. |
|
1536 |
||
1537 |
codeView replaceFromCharacterPosition:start to:stop with:newPart. |
|
1538 |
||
1539 |
oldLen := stop - start + 1. |
|
1540 |
newLen := newPart size. |
|
1541 |
||
1542 |
"/ codeView selectFromCharacterPosition:start+oldLen to:start+newLen-1. |
|
1543 |
newCursorPosition := stop + (newLen-oldLen). |
|
1544 |
]. |
|
1545 |
codeView cursorToCharacterPosition:newCursorPosition. |
|
1546 |
codeView cursorRight. "/ avoid going to the next line !! |
|
1547 |
codeView dontReplaceSelectionOnInput. |
|
1548 |
] |
|
1549 |
info:'Completion'. |
|
1550 |
]. |
|
1551 |
]. |
|
1552 |
||
1553 |
actionBlock value:allBest value:editAction. |
|
1554 |
||
1555 |
"Created: / 10-11-2006 / 13:18:27 / cg" |
|
1556 |
"Modified: / 16-02-2010 / 10:33:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1557 |
"Modified: / 21-07-2012 / 12:24:06 / cg" |
|
1558 |
! |
|
1559 |
||
1560 |
codeCompletionForMethod:node |
|
1561 |
"completion in a method's selector pattern" |
|
1562 |
||
1563 |
|crsrPos |
|
1564 |
selectorSoFar matchingSelectors |
|
1565 |
selectors distances best rest |
|
1566 |
allExistingMethods nameBag namesByCount selectors1 selectors2| |
|
1567 |
||
1568 |
crsrPos := codeView characterPositionOfCursor - 1. |
|
1569 |
||
1570 |
selectorSoFar := ''. |
|
1571 |
node selectorParts doWithIndex:[:partToken :argNr| |
|
1572 |
|part| |
|
1573 |
||
1574 |
part := partToken value. |
|
1575 |
selectorSoFar := selectorSoFar , part. |
|
1576 |
||
1577 |
(crsrPos >= partToken start |
|
1578 |
and:[crsrPos <= partToken stop]) ifTrue:[ |
|
1579 |
(classOrNil notNil and:[classOrNil isMeta]) ifTrue:[ |
|
1580 |
matchingSelectors := Smalltalk allClasses |
|
1581 |
inject:(Set new) |
|
1582 |
into:[:theSet :eachClass | |
|
1583 |
|md| |
|
1584 |
||
1585 |
md := eachClass theMetaclass methodDictionary. |
|
1586 |
theSet addAll:(md keys select:[:sel |sel startsWith:selectorSoFar]). |
|
1587 |
theSet. |
|
1588 |
]. |
|
1589 |
"/ dont forget the stuff in the class-line |
|
1590 |
Metaclass withAllSuperclassesDo:[:cls | |
|
1591 |
matchingSelectors addAll:(cls methodDictionary keys select:[:sel |sel startsWith:selectorSoFar]). |
|
1592 |
]. |
|
1593 |
] ifFalse:[ |
|
1594 |
matchingSelectors := Smalltalk allClasses |
|
1595 |
inject:(Set new) |
|
1596 |
into:[:theSet :eachClass | |
|
1597 |
|md| |
|
1598 |
||
1599 |
md := eachClass theNonMetaclass methodDictionary. |
|
1600 |
theSet addAll:(md keys select:[:sel |sel startsWith:selectorSoFar]). |
|
1601 |
theSet. |
|
1602 |
]. |
|
1603 |
]. |
|
1604 |
selectors := matchingSelectors asOrderedCollection. |
|
1605 |
||
1606 |
"/ if there is only one, and user has already entered it, he might want to complete the argument-name |
|
1607 |
(selectors size == 1 |
|
1608 |
and:[selectors first = selectorSoFar]) ifTrue:[ |
|
1609 |
selectorSoFar numArgs == 0 ifTrue:[ ^ self ]. |
|
1610 |
||
1611 |
allExistingMethods := (Smalltalk allImplementorsOf:selectorSoFar asSymbol) |
|
1612 |
collect:[:cls | cls compiledMethodAt:selectorSoFar asSymbol]. |
|
1613 |
nameBag := Bag new. |
|
1614 |
allExistingMethods do:[:eachMethod | nameBag addAll:(eachMethod methodArgNames ? #())]. |
|
1615 |
namesByCount := nameBag valuesAndCounts sort:[:a :b | a value < b value]. |
|
1616 |
"/ take the one which occurs most often |
|
1617 |
best := self askUserForCompletion:'argument' for:codeView at: node start from:(namesByCount collect:[:a | a key]). |
|
1618 |
||
1619 |
codeView |
|
1620 |
undoableDo:[ |
|
1621 |
(crsrPos+1) >= codeView contents size ifTrue:[ |
|
1622 |
codeView paste:best. |
|
1623 |
] ifFalse:[ |
|
1624 |
codeView insertString:best atCharacterPosition:crsrPos+1. |
|
1625 |
] |
|
1626 |
] |
|
1627 |
info:'completion'. |
|
1628 |
codeView cursorToCharacterPosition:(crsrPos + best size - 1). |
|
1629 |
] ifFalse:[ |
|
1630 |
"the ones implemented in superclasses are shown first" |
|
1631 |
classOrNil notNil ifTrue:[ |
|
1632 |
selectors1 := selectors select:[:sel | classOrNil respondsTo:sel]. "/ in super |
|
1633 |
selectors2 := selectors reject:[:sel | selectors1 includes:sel ]. "/ not in super |
|
1634 |
] ifFalse:[ |
|
1635 |
selectors1 := selectors |
|
1636 |
]. |
|
1637 |
||
1638 |
distances := selectors1 collect:[:each | each spellAgainst:selectorSoFar]. |
|
1639 |
distances sortWith:selectors1. |
|
1640 |
selectors1 reverse. |
|
1641 |
selectors := selectors1. |
|
1642 |
||
1643 |
selectors2 notEmptyOrNil ifTrue:[ |
|
1644 |
distances := selectors2 collect:[:each | each spellAgainst:selectorSoFar]. |
|
1645 |
distances sortWith:selectors2. |
|
1646 |
selectors2 reverse. |
|
1647 |
selectors1 := selectors1 collect:[:sel | sel allBold]. |
|
1648 |
selectors := selectors1,selectors2. |
|
1649 |
]. |
|
1650 |
||
1651 |
best := self askUserForCompletion:'selector' for:codeView at:(node start) from:selectors. |
|
1652 |
best isNil ifTrue:[^ self]. |
|
1653 |
||
1654 |
rest := best copyFrom:selectorSoFar size. |
|
1655 |
codeView |
|
1656 |
undoableDo:[ |
|
1657 |
codeView |
|
1658 |
replaceFromCharacterPosition:crsrPos+1 |
|
1659 |
to:crsrPos+1 |
|
1660 |
with:rest |
|
1661 |
] |
|
1662 |
info:'Completion'. |
|
1663 |
codeView cursorToCharacterPosition:(crsrPos+1 + rest size - 1). |
|
1664 |
]. |
|
1665 |
codeView cursorRight. "/ kludge to make it visible |
|
1666 |
]. |
|
1667 |
]. |
|
1668 |
||
1669 |
"Modified: / 04-07-2006 / 18:48:26 / fm" |
|
1670 |
"Created: / 10-11-2006 / 13:46:44 / cg" |
|
1671 |
"Modified: / 16-02-2010 / 10:13:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1672 |
"Modified: / 01-06-2012 / 20:31:36 / cg" |
|
1673 |
! |
|
1674 |
||
1675 |
codeCompletionForMethod:node inClass:classOrNil codeView:codeView |
|
1676 |
"completion in a method's selector pattern" |
|
1677 |
||
1678 |
|crsrPos |
|
1679 |
selectorSoFar matchingSelectors |
|
1680 |
selectors distances best rest |
|
1681 |
allExistingMethods nameBag namesByCount selectors1 selectors2| |
|
1682 |
||
1683 |
crsrPos := codeView characterPositionOfCursor - 1. |
|
1684 |
||
1685 |
selectorSoFar := ''. |
|
1686 |
node selectorParts doWithIndex:[:partToken :argNr| |
|
1687 |
|part| |
|
1688 |
||
1689 |
part := partToken value. |
|
1690 |
selectorSoFar := selectorSoFar , part. |
|
1691 |
||
1692 |
(crsrPos >= partToken start |
|
1693 |
and:[crsrPos <= partToken stop]) ifTrue:[ |
|
1694 |
(classOrNil notNil and:[classOrNil isMeta]) ifTrue:[ |
|
1695 |
matchingSelectors := Smalltalk allClasses |
|
1696 |
inject:(Set new) |
|
1697 |
into:[:theSet :eachClass | |
|
1698 |
|md| |
|
1699 |
||
1700 |
md := eachClass theMetaclass methodDictionary. |
|
1701 |
theSet addAll:(md keys select:[:sel |sel startsWith:selectorSoFar]). |
|
1702 |
theSet. |
|
1703 |
]. |
|
1704 |
"/ dont forget the stuff in the class-line |
|
1705 |
Metaclass withAllSuperclassesDo:[:cls | |
|
1706 |
matchingSelectors addAll:(cls methodDictionary keys select:[:sel |sel startsWith:selectorSoFar]). |
|
1707 |
]. |
|
1708 |
] ifFalse:[ |
|
1709 |
matchingSelectors := Smalltalk allClasses |
|
1710 |
inject:(Set new) |
|
1711 |
into:[:theSet :eachClass | |
|
1712 |
|md| |
|
1713 |
||
1714 |
md := eachClass theNonMetaclass methodDictionary. |
|
1715 |
theSet addAll:(md keys select:[:sel |sel startsWith:selectorSoFar]). |
|
1716 |
theSet. |
|
1717 |
]. |
|
1718 |
]. |
|
1719 |
selectors := matchingSelectors asOrderedCollection. |
|
1720 |
||
1721 |
"/ if there is only one, and user has already entered it, he might want to complete the argument-name |
|
1722 |
(selectors size == 1 |
|
1723 |
and:[selectors first = selectorSoFar]) ifTrue:[ |
|
1724 |
selectorSoFar numArgs == 0 ifTrue:[ ^ self ]. |
|
1725 |
||
1726 |
allExistingMethods := (Smalltalk allImplementorsOf:selectorSoFar asSymbol) |
|
1727 |
collect:[:cls | cls compiledMethodAt:selectorSoFar asSymbol]. |
|
1728 |
nameBag := Bag new. |
|
1729 |
allExistingMethods do:[:eachMethod | nameBag addAll:(eachMethod methodArgNames ? #())]. |
|
1730 |
namesByCount := nameBag valuesAndCounts sort:[:a :b | a value < b value]. |
|
1731 |
"/ take the one which occurs most often |
|
1732 |
best := self askUserForCompletion:'argument' for:codeView at: node start from:(namesByCount collect:[:a | a key]). |
|
1733 |
||
1734 |
codeView |
|
1735 |
undoableDo:[ |
|
1736 |
(crsrPos+1) >= codeView contents size ifTrue:[ |
|
1737 |
codeView paste:best. |
|
1738 |
] ifFalse:[ |
|
1739 |
codeView insertString:best atCharacterPosition:crsrPos+1. |
|
1740 |
] |
|
1741 |
] |
|
1742 |
info:'completion'. |
|
1743 |
codeView cursorToCharacterPosition:(crsrPos + best size - 1). |
|
1744 |
] ifFalse:[ |
|
1745 |
"the ones implemented in superclasses are shown first" |
|
1746 |
classOrNil notNil ifTrue:[ |
|
1747 |
selectors1 := selectors select:[:sel | classOrNil respondsTo:sel]. "/ in super |
|
1748 |
selectors2 := selectors reject:[:sel | selectors1 includes:sel ]. "/ not in super |
|
1749 |
] ifFalse:[ |
|
1750 |
selectors1 := selectors |
|
1751 |
]. |
|
1752 |
||
1753 |
distances := selectors1 collect:[:each | each spellAgainst:selectorSoFar]. |
|
1754 |
distances sortWith:selectors1. |
|
1755 |
selectors1 reverse. |
|
1756 |
selectors := selectors1. |
|
1757 |
||
1758 |
selectors2 notEmptyOrNil ifTrue:[ |
|
1759 |
distances := selectors2 collect:[:each | each spellAgainst:selectorSoFar]. |
|
1760 |
distances sortWith:selectors2. |
|
1761 |
selectors2 reverse. |
|
1762 |
selectors1 := selectors1 collect:[:sel | sel allBold]. |
|
1763 |
selectors := selectors1,selectors2. |
|
1764 |
]. |
|
1765 |
||
1766 |
best := self askUserForCompletion:'selector' for:codeView at:(node start) from:selectors. |
|
1767 |
best isNil ifTrue:[^ self]. |
|
1768 |
||
1769 |
rest := best copyFrom:selectorSoFar size. |
|
1770 |
codeView |
|
1771 |
undoableDo:[ |
|
1772 |
codeView |
|
1773 |
replaceFromCharacterPosition:crsrPos+1 |
|
1774 |
to:crsrPos+1 |
|
1775 |
with:rest |
|
1776 |
] |
|
1777 |
info:'Completion'. |
|
1778 |
codeView cursorToCharacterPosition:(crsrPos+1 + rest size - 1). |
|
1779 |
]. |
|
1780 |
codeView cursorRight. "/ kludge to make it visible |
|
1781 |
]. |
|
1782 |
]. |
|
1783 |
||
1784 |
"Modified: / 04-07-2006 / 18:48:26 / fm" |
|
1785 |
"Created: / 10-11-2006 / 13:46:44 / cg" |
|
1786 |
"Modified: / 16-02-2010 / 10:13:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1787 |
"Modified: / 01-06-2012 / 20:31:36 / cg" |
|
1788 |
! |
|
1789 |
||
1790 |
codeCompletionForMethod:node inClass:classOrNil codeView:codeView into:actionBlock |
|
1791 |
"completion in a method's selector pattern" |
|
1792 |
||
1793 |
|crsrPos |
|
1794 |
selectorSoFar matchingSelectors |
|
1795 |
selectors distances best rest |
|
1796 |
allExistingMethods nameBag namesByCount selectors1 selectors2| |
|
1797 |
||
4302 | 1798 |
"/ Transcript showCR:'m'. |
4238 | 1799 |
crsrPos := codeView characterPositionOfCursor - 1. |
1800 |
||
1801 |
selectorSoFar := ''. |
|
1802 |
node selectorParts doWithIndex:[:partToken :argNr| |
|
1803 |
|part| |
|
1804 |
||
1805 |
part := partToken value. |
|
1806 |
selectorSoFar := selectorSoFar , part. |
|
1807 |
||
1808 |
(crsrPos >= partToken start |
|
1809 |
and:[crsrPos <= partToken stop]) ifTrue:[ |
|
1810 |
(classOrNil notNil and:[classOrNil isMeta]) ifTrue:[ |
|
1811 |
matchingSelectors := Smalltalk allClasses |
|
1812 |
inject:(Set new) |
|
1813 |
into:[:theSet :eachClass | |
|
1814 |
|md| |
|
1815 |
||
1816 |
md := eachClass theMetaclass methodDictionary. |
|
1817 |
theSet addAll:(md keys select:[:sel |sel startsWith:selectorSoFar]). |
|
1818 |
theSet. |
|
1819 |
]. |
|
1820 |
"/ dont forget the stuff in the class-line |
|
1821 |
Metaclass withAllSuperclassesDo:[:cls | |
|
1822 |
matchingSelectors addAll:(cls methodDictionary keys select:[:sel |sel startsWith:selectorSoFar]). |
|
1823 |
]. |
|
1824 |
] ifFalse:[ |
|
1825 |
matchingSelectors := Smalltalk allClasses |
|
1826 |
inject:(Set new) |
|
1827 |
into:[:theSet :eachClass | |
|
1828 |
|md| |
|
1829 |
||
1830 |
md := eachClass theNonMetaclass methodDictionary. |
|
1831 |
theSet addAll:(md keys select:[:sel |sel startsWith:selectorSoFar]). |
|
1832 |
theSet. |
|
1833 |
]. |
|
1834 |
]. |
|
1835 |
selectors := matchingSelectors asOrderedCollection. |
|
1836 |
||
1837 |
"/ if there is only one, and user has already entered it, he might want to complete the argument-name |
|
1838 |
(selectors size == 1 |
|
1839 |
and:[selectors first = selectorSoFar]) ifTrue:[ |
|
1840 |
selectorSoFar numArgs == 0 ifTrue:[ ^ self ]. |
|
1841 |
||
1842 |
allExistingMethods := (Smalltalk allImplementorsOf:selectorSoFar asSymbol) |
|
1843 |
collect:[:cls | cls compiledMethodAt:selectorSoFar asSymbol]. |
|
1844 |
nameBag := Bag new. |
|
1845 |
allExistingMethods do:[:eachMethod | nameBag addAll:(eachMethod methodArgNames ? #())]. |
|
1846 |
namesByCount := nameBag valuesAndCounts sort:[:a :b | a value < b value]. |
|
1847 |
"/ take the one which occurs most often |
|
1848 |
"/ best := self askUserForCompletion:'argument' for:codeView at: node start from:(namesByCount collect:[:a | a key]). |
|
1849 |
actionBlock value:(namesByCount collect:[:a | a key]) value:nil. |
|
1850 |
^ self. |
|
1851 |
||
1852 |
codeView |
|
1853 |
undoableDo:[ |
|
1854 |
(crsrPos+1) >= codeView contents size ifTrue:[ |
|
1855 |
codeView paste:best. |
|
1856 |
] ifFalse:[ |
|
1857 |
codeView insertString:best atCharacterPosition:crsrPos+1. |
|
1858 |
] |
|
1859 |
] |
|
1860 |
info:'completion'. |
|
1861 |
codeView cursorToCharacterPosition:(crsrPos + best size - 1). |
|
1862 |
] ifFalse:[ |
|
1863 |
"the ones implemented in superclasses are shown first" |
|
1864 |
classOrNil notNil ifTrue:[ |
|
1865 |
selectors1 := selectors select:[:sel | classOrNil respondsTo:sel]. "/ in super |
|
1866 |
selectors2 := selectors reject:[:sel | selectors1 includes:sel ]. "/ not in super |
|
1867 |
] ifFalse:[ |
|
1868 |
selectors1 := selectors |
|
1869 |
]. |
|
1870 |
||
1871 |
distances := selectors1 collect:[:each | each spellAgainst:selectorSoFar]. |
|
1872 |
distances sortWith:selectors1. |
|
1873 |
selectors1 reverse. |
|
1874 |
selectors := selectors1. |
|
1875 |
||
1876 |
selectors2 notEmptyOrNil ifTrue:[ |
|
1877 |
distances := selectors2 collect:[:each | each spellAgainst:selectorSoFar]. |
|
1878 |
distances sortWith:selectors2. |
|
1879 |
selectors2 reverse. |
|
1880 |
selectors1 := selectors1 collect:[:sel | sel allBold]. |
|
1881 |
selectors := selectors1,selectors2. |
|
1882 |
]. |
|
1883 |
||
1884 |
"/ best := self askUserForCompletion:'selector' for:codeView at:(node start) from:selectors. |
|
1885 |
best := actionBlock value:selectors value:nil. |
|
1886 |
best isNil ifTrue:[^ self]. |
|
1887 |
||
1888 |
rest := best copyFrom:selectorSoFar size. |
|
1889 |
codeView |
|
1890 |
undoableDo:[ |
|
1891 |
codeView |
|
1892 |
replaceFromCharacterPosition:crsrPos+1 |
|
1893 |
to:crsrPos+1 |
|
1894 |
with:rest |
|
1895 |
] |
|
1896 |
info:'Completion'. |
|
1897 |
codeView cursorToCharacterPosition:(crsrPos+1 + rest size - 1). |
|
1898 |
]. |
|
1899 |
codeView cursorRight. "/ kludge to make it visible |
|
1900 |
]. |
|
1901 |
]. |
|
1902 |
||
1903 |
"Modified: / 04-07-2006 / 18:48:26 / fm" |
|
1904 |
"Created: / 10-11-2006 / 13:46:44 / cg" |
|
1905 |
"Modified: / 16-02-2010 / 10:13:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1906 |
"Modified: / 01-06-2012 / 20:31:36 / cg" |
|
1907 |
! |
|
1908 |
||
1909 |
codeCompletionForMethod:node into:actionBlock |
|
1910 |
"completion in a method's selector pattern" |
|
1911 |
||
1912 |
|crsrPos |
|
1913 |
selectorSoFar matchingSelectors |
|
1914 |
selectors distances best rest |
|
1915 |
allExistingMethods nameBag namesByCount selectors1 selectors2| |
|
1916 |
||
4302 | 1917 |
"/ Transcript showCR:'m'. |
4238 | 1918 |
crsrPos := codeView characterPositionOfCursor - 1. |
1919 |
||
1920 |
selectorSoFar := ''. |
|
1921 |
node selectorParts doWithIndex:[:partToken :argNr| |
|
1922 |
|part| |
|
1923 |
||
1924 |
part := partToken value. |
|
1925 |
selectorSoFar := selectorSoFar , part. |
|
1926 |
||
1927 |
(crsrPos >= partToken start |
|
1928 |
and:[crsrPos <= partToken stop]) ifTrue:[ |
|
1929 |
(classOrNil notNil and:[classOrNil isMeta]) ifTrue:[ |
|
1930 |
matchingSelectors := Smalltalk allClasses |
|
1931 |
inject:(Set new) |
|
1932 |
into:[:theSet :eachClass | |
|
1933 |
|md| |
|
1934 |
||
1935 |
md := eachClass theMetaclass methodDictionary. |
|
1936 |
theSet addAll:(md keys select:[:sel |sel startsWith:selectorSoFar]). |
|
1937 |
theSet. |
|
1938 |
]. |
|
1939 |
"/ dont forget the stuff in the class-line |
|
1940 |
Metaclass withAllSuperclassesDo:[:cls | |
|
1941 |
matchingSelectors addAll:(cls methodDictionary keys select:[:sel |sel startsWith:selectorSoFar]). |
|
1942 |
]. |
|
1943 |
] ifFalse:[ |
|
1944 |
matchingSelectors := Smalltalk allClasses |
|
1945 |
inject:(Set new) |
|
1946 |
into:[:theSet :eachClass | |
|
1947 |
|md| |
|
1948 |
||
1949 |
md := eachClass theNonMetaclass methodDictionary. |
|
1950 |
theSet addAll:(md keys select:[:sel |sel startsWith:selectorSoFar]). |
|
1951 |
theSet. |
|
1952 |
]. |
|
1953 |
]. |
|
1954 |
selectors := matchingSelectors asOrderedCollection. |
|
1955 |
||
1956 |
"/ if there is only one, and user has already entered it, he might want to complete the argument-name |
|
1957 |
(selectors size == 1 |
|
1958 |
and:[selectors first = selectorSoFar]) ifTrue:[ |
|
1959 |
selectorSoFar numArgs == 0 ifTrue:[ ^ self ]. |
|
1960 |
||
1961 |
allExistingMethods := (Smalltalk allImplementorsOf:selectorSoFar asSymbol) |
|
1962 |
collect:[:cls | cls compiledMethodAt:selectorSoFar asSymbol]. |
|
1963 |
nameBag := Bag new. |
|
1964 |
allExistingMethods do:[:eachMethod | nameBag addAll:(eachMethod methodArgNames ? #())]. |
|
1965 |
namesByCount := nameBag valuesAndCounts sort:[:a :b | a value < b value]. |
|
1966 |
"/ take the one which occurs most often |
|
1967 |
"/ best := self askUserForCompletion:'argument' for:codeView at: node start from:(namesByCount collect:[:a | a key]). |
|
1968 |
actionBlock value:(namesByCount collect:[:a | a key]) value:nil. |
|
1969 |
^ self. |
|
1970 |
||
1971 |
codeView |
|
1972 |
undoableDo:[ |
|
1973 |
(crsrPos+1) >= codeView contents size ifTrue:[ |
|
1974 |
codeView paste:best. |
|
1975 |
] ifFalse:[ |
|
1976 |
codeView insertString:best atCharacterPosition:crsrPos+1. |
|
1977 |
] |
|
1978 |
] |
|
1979 |
info:'completion'. |
|
1980 |
codeView cursorToCharacterPosition:(crsrPos + best size - 1). |
|
1981 |
] ifFalse:[ |
|
1982 |
"the ones implemented in superclasses are shown first" |
|
1983 |
classOrNil notNil ifTrue:[ |
|
1984 |
selectors1 := selectors select:[:sel | classOrNil respondsTo:sel]. "/ in super |
|
1985 |
selectors2 := selectors reject:[:sel | selectors1 includes:sel ]. "/ not in super |
|
1986 |
] ifFalse:[ |
|
1987 |
selectors1 := selectors |
|
1988 |
]. |
|
1989 |
||
1990 |
distances := selectors1 collect:[:each | each spellAgainst:selectorSoFar]. |
|
1991 |
distances sortWith:selectors1. |
|
1992 |
selectors1 reverse. |
|
1993 |
selectors := selectors1. |
|
1994 |
||
1995 |
selectors2 notEmptyOrNil ifTrue:[ |
|
1996 |
distances := selectors2 collect:[:each | each spellAgainst:selectorSoFar]. |
|
1997 |
distances sortWith:selectors2. |
|
1998 |
selectors2 reverse. |
|
1999 |
selectors1 := selectors1 collect:[:sel | sel allBold]. |
|
2000 |
selectors := selectors1,selectors2. |
|
2001 |
]. |
|
2002 |
||
2003 |
"/ best := self askUserForCompletion:'selector' for:codeView at:(node start) from:selectors. |
|
2004 |
best := actionBlock value:selectors value:nil. |
|
2005 |
best isNil ifTrue:[^ self]. |
|
2006 |
||
2007 |
rest := best copyFrom:selectorSoFar size. |
|
2008 |
codeView |
|
2009 |
undoableDo:[ |
|
2010 |
codeView |
|
2011 |
replaceFromCharacterPosition:crsrPos+1 |
|
2012 |
to:crsrPos+1 |
|
2013 |
with:rest |
|
2014 |
] |
|
2015 |
info:'Completion'. |
|
2016 |
codeView cursorToCharacterPosition:(crsrPos+1 + rest size - 1). |
|
2017 |
]. |
|
2018 |
codeView cursorRight. "/ kludge to make it visible |
|
2019 |
]. |
|
2020 |
]. |
|
2021 |
||
2022 |
"Modified: / 04-07-2006 / 18:48:26 / fm" |
|
2023 |
"Created: / 10-11-2006 / 13:46:44 / cg" |
|
2024 |
"Modified: / 16-02-2010 / 10:13:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2025 |
"Modified: / 01-06-2012 / 20:31:36 / cg" |
|
2026 |
! |
|
2027 |
||
2028 |
codeCompletionForMethod:methodOrNilArg orClass:classOrNilArg context:contextOrNil codeView:codeViewArg into:actionBlock |
|
2029 |
"contextOrNil is the current context, if this is called from the debugger; |
|
2030 |
nil, if called from the browser. |
|
2031 |
If nonNil, we can make better guesses, because we actually know what a variable's type is. |
|
2032 |
This is not yet done, sigh" |
|
2033 |
||
2034 |
|crsrPos char interval source node checkedNode| |
|
2035 |
||
2036 |
methodOrNil := methodOrNilArg. |
|
2037 |
classOrNil := classOrNilArg. |
|
2038 |
codeView := codeViewArg. |
|
2039 |
||
2040 |
"/ classOrNil isNil ifTrue:[ |
|
2041 |
"/ self information:'No class'. |
|
2042 |
"/ ^ self. |
|
2043 |
"/ ]. |
|
2044 |
||
2045 |
crsrPos := codeView characterPositionOfCursor"-1". |
|
2046 |
char := codeView characterAtCharacterPosition:crsrPos. |
|
2047 |
[crsrPos > 1 and:[char isSeparator or:['.' includes:char]]] whileTrue:[ |
|
2048 |
crsrPos := crsrPos - 1. |
|
2049 |
char := codeView characterAtCharacterPosition:crsrPos. |
|
2050 |
]. |
|
2051 |
||
2052 |
interval := codeView selectedInterval. |
|
2053 |
interval isEmpty ifTrue:[ |
|
2054 |
interval := crsrPos-1 to:crsrPos. |
|
2055 |
]. |
|
2056 |
||
2057 |
source := codeView contentsAsString string. |
|
2058 |
"/ source := source copyTo:crsrPos. |
|
2059 |
||
2060 |
"/ this is too naive and stupid; if there is a syntactic error, |
|
2061 |
"/ we will not find a node for a long time (stepping back more and more, |
|
2062 |
"/ until reaching the beginning). This leads to a thousand and more times reparsing |
|
2063 |
"/ without any progress. |
|
2064 |
"/ TODO: do it vice-versa, in that the parser does a callOut for every node generated |
|
2065 |
"/ as it parses the code. Stop, when the interval is hit. |
|
2066 |
"/ that will also work for syntactic incorrect source code. |
|
2067 |
classOrNil notNil ifTrue:[ |
|
2068 |
node := self findNodeForInterval:interval in:source allowErrors:true mustBeMethod:true. |
|
2069 |
]. |
|
2070 |
node isNil ifTrue:[ |
|
2071 |
node := self findNodeForInterval:interval in:source allowErrors:true mustBeMethod:false. |
|
2072 |
]. |
|
2073 |
"/ [node isNil] whileTrue:[ |
|
2074 |
"/ "/ expand to the left ... |
|
2075 |
"/ interval start > 1 ifFalse:[ |
|
2076 |
"/ self information:'No parseNode found'. |
|
2077 |
"/ ^ self. |
|
2078 |
"/ ]. |
|
2079 |
"/ interval start:(interval start - 1). |
|
2080 |
"/ node := self findNodeForInterval:interval in:source allowErrors:true. |
|
2081 |
"/ ]. |
|
2082 |
node isNil ifTrue:[ |
|
2083 |
Transcript showCR:'No parseNode found'. |
|
2084 |
self breakPoint:#cg. |
|
2085 |
self information:'No parseNode found'. |
|
2086 |
^ self. |
|
2087 |
]. |
|
2088 |
||
2089 |
(node isVariable |
|
2090 |
and:[ node parent notNil |
|
2091 |
and:[ node parent isMessage |
|
2092 |
and:[ node stop < (codeView characterPositionOfCursor-1) ]]]) ifTrue:[ |
|
2093 |
node := node parent. |
|
2094 |
]. |
|
2095 |
||
2096 |
node isVariable ifTrue:[ |
|
2097 |
self codeCompletionForVariable:node into:actionBlock. |
|
2098 |
^ self. |
|
2099 |
]. |
|
2100 |
node isLiteral ifTrue:[ |
|
2101 |
node value isSymbol ifTrue:[ |
|
2102 |
self codeCompletionForLiteralSymbol:node into:actionBlock. |
|
2103 |
^ self. |
|
2104 |
]. |
|
2105 |
]. |
|
2106 |
||
2107 |
checkedNode := node. |
|
2108 |
[checkedNode notNil] whileTrue:[ |
|
2109 |
checkedNode isMessage ifTrue:[ |
|
2110 |
"/ completion in a message-send |
|
2111 |
self codeCompletionForMessage:checkedNode into:actionBlock. |
|
2112 |
^ self |
|
2113 |
]. |
|
2114 |
checkedNode isMethod ifTrue:[ |
|
2115 |
"/ completion in a method's selector pattern |
|
2116 |
self codeCompletionForMethod:checkedNode into:actionBlock. |
|
2117 |
^ self. |
|
2118 |
]. |
|
2119 |
checkedNode := checkedNode parent. |
|
2120 |
]. |
|
2121 |
||
2122 |
self information:'Node is neither variable nor message.'. |
|
2123 |
||
2124 |
"Modified: / 04-07-2006 / 18:48:26 / fm" |
|
2125 |
"Modified: / 16-09-2011 / 14:54:47 / cg" |
|
2126 |
! |
|
2127 |
||
2128 |
codeCompletionForVariable:node into:actionBlock |
|
2129 |
|nonMetaClass crsrPos nm parent |
|
2130 |
allVariables allDistances variablesAlreadyAdded nodeVal |
|
2131 |
char oldLen newLen |
|
2132 |
getDistanceComputeBlockWithWeight addWithFactorBlock names allTheBest bestAssoc |
|
2133 |
globalFactor localFactor selectorOfMessageToNode tree implementors argIdx namesUsed kwPart |
|
2134 |
editAction suggestions nameIsOK| |
|
2135 |
||
4302 | 2136 |
"/ Transcript show:'var in '; show:methodOrNil; show:' / '; showCR:classOrNil. |
4238 | 2137 |
classOrNil notNil ifTrue:[ |
2138 |
nonMetaClass := classOrNil theNonMetaclass. |
|
2139 |
]. |
|
2140 |
||
2141 |
nm := node name. |
|
2142 |
||
2143 |
"/ if we are behind the variable and a space has already been entered, |
|
2144 |
"/ the user is probably looking for a message selector. |
|
2145 |
"/ If the variable represents a global, present its instance creation messages |
|
2146 |
crsrPos := codeView characterPositionOfCursor. |
|
2147 |
char := codeView characterAtCharacterPosition:crsrPos-1. |
|
2148 |
char isSeparator ifTrue:[ |
|
2149 |
nm knownAsSymbol ifTrue:[ |
|
2150 |
classOrNil isNil ifTrue:[ |
|
2151 |
nodeVal := Smalltalk at:nm asSymbol. |
|
2152 |
] ifFalse:[ |
|
2153 |
nodeVal := classOrNil topNameSpace at:nm asSymbol ifAbsent:[Smalltalk at:nm asSymbol]. |
|
2154 |
]. |
|
2155 |
nodeVal isBehavior ifTrue:[ |
|
2156 |
|methods menu exitKey idx| |
|
2157 |
||
2158 |
methods := nodeVal class methodDictionary values |
|
2159 |
select:[:m | |cat| |
|
2160 |
cat := m category asLowercase. |
|
2161 |
cat = 'instance creation' |
|
2162 |
]. |
|
2163 |
editAction := |
|
2164 |
[:answer | |
|
2165 |
codeView |
|
2166 |
undoableDo:[ |
|
2167 |
codeView insertString:answer atCharacterPosition:crsrPos. |
|
2168 |
codeView cursorToCharacterPosition:crsrPos+answer size. |
|
2169 |
] |
|
2170 |
info:'completion'. |
|
2171 |
]. |
|
2172 |
actionBlock value:(methods collect:[:each | each selector]) value:editAction. |
|
2173 |
^ self. |
|
2174 |
]. |
|
2175 |
]. |
|
2176 |
]. |
|
2177 |
||
2178 |
parent := node parent. |
|
2179 |
(parent notNil and:[parent isMessage]) ifTrue:[ |
|
2180 |
node == parent receiver ifTrue:[ |
|
2181 |
selectorOfMessageToNode := parent selector |
|
2182 |
] |
|
2183 |
]. |
|
2184 |
||
2185 |
getDistanceComputeBlockWithWeight := |
|
2186 |
[:weight | |
|
2187 |
[:each | |
|
2188 |
|dist factor| |
|
2189 |
||
2190 |
dist := each spellAgainst:nm. |
|
2191 |
factor := 1. |
|
2192 |
||
2193 |
(each startsWith:nm) ifTrue:[ |
|
2194 |
factor := 6 * nm size. |
|
2195 |
] ifFalse:[ |
|
2196 |
(each asLowercase startsWith:nm asLowercase) ifTrue:[ |
|
2197 |
factor := 4 * nm size. |
|
2198 |
]. |
|
2199 |
]. |
|
2200 |
dist := dist + (weight*factor). |
|
2201 |
||
2202 |
each -> (dist * weight) |
|
2203 |
] |
|
2204 |
]. |
|
2205 |
||
2206 |
nameIsOK := false. |
|
2207 |
addWithFactorBlock := |
|
2208 |
[:names :factor | |namesToAdd| |
|
2209 |
(names includes:nm) ifTrue:[nameIsOK := true]. |
|
2210 |
namesToAdd := names reject:[:nameToAdd | (nameToAdd = nm)]. |
|
2211 |
namesToAdd := namesToAdd reject:[:each | variablesAlreadyAdded includes:each ]. |
|
2212 |
variablesAlreadyAdded addAll:namesToAdd. |
|
2213 |
allVariables addAll:namesToAdd. |
|
2214 |
allDistances addAll:(namesToAdd collect:(getDistanceComputeBlockWithWeight value:factor)). |
|
2215 |
]. |
|
2216 |
||
2217 |
nm isUppercaseFirst ifTrue:[ |
|
2218 |
globalFactor := 2. "/ favour globals |
|
2219 |
localFactor := 1. |
|
2220 |
] ifFalse:[ |
|
2221 |
globalFactor := 1. "/ favour locals |
|
2222 |
localFactor := 2. |
|
2223 |
]. |
|
2224 |
||
2225 |
variablesAlreadyAdded := Set new. |
|
2226 |
allVariables := OrderedCollection new. |
|
2227 |
allDistances := OrderedCollection new. |
|
2228 |
||
2229 |
"/ are we in the method's selector spec ? |
|
2230 |
(parent notNil |
|
2231 |
and:[parent isMethod |
|
2232 |
and:[parent arguments includes:node]]) ifTrue:[ |
|
2233 |
"/ now thats cool: look how the naem of this argument is in other implementations |
|
2234 |
"/ of this method, and take that as a basis of the selection |
|
2235 |
||
2236 |
implementors := SystemBrowser |
|
2237 |
findImplementorsOf:(parent selector) |
|
2238 |
in:(Smalltalk allClasses) |
|
2239 |
ignoreCase:false. |
|
2240 |
"/ which argument is it |
|
2241 |
argIdx := parent arguments indexOf:node. |
|
2242 |
implementors size > 50 ifTrue:[ |
|
2243 |
implementors := implementors asOrderedCollection copyTo:50. |
|
2244 |
]. |
|
2245 |
namesUsed := implementors |
|
2246 |
collect:[:eachImplementor | |
|
2247 |
|parseTree| |
|
2248 |
parseTree := eachImplementor parseTree. |
|
2249 |
(parseTree notNil and:[parseTree arguments size > 0]) |
|
2250 |
ifFalse:nil |
|
2251 |
ifTrue:[ (parseTree arguments at:argIdx) name] ] |
|
2252 |
thenSelect:[:a | a notNil]. |
|
2253 |
||
2254 |
addWithFactorBlock value:namesUsed value:(2 * localFactor). |
|
2255 |
||
2256 |
classOrNil notNil ifTrue:[ |
|
2257 |
"/ also, look for the keyword before the argument, |
|
2258 |
"/ and see if there is such an instVar |
|
2259 |
"/ if so, add it with -Arg |
|
2260 |
parent selector isKeyword ifTrue:[ |
|
2261 |
kwPart := parent selector keywords at:argIdx. |
|
2262 |
(classOrNil allInstVarNames includes:(kwPart copyButLast:1)) ifTrue:[ |
|
2263 |
addWithFactorBlock |
|
2264 |
value:(classOrNil allInstVarNames collect:[:nm| nm,'Arg']) |
|
2265 |
value:(1 * localFactor). |
|
2266 |
]. |
|
2267 |
]. |
|
2268 |
] |
|
2269 |
] ifFalse:[ |
|
2270 |
classOrNil notNil ifTrue:[ |
|
2271 |
"/ locals in the block/method |
|
2272 |
names := node allVariablesOnScope. |
|
2273 |
"/ if there were no variables (due to a parse error) |
|
2274 |
"/ do another parse and see what we have |
|
2275 |
names isEmpty ifTrue:[ |
|
2276 |
tree := self treeForCode:(codeView contentsAsString string) allowErrors:true. |
|
2277 |
"/ better if we already have a body (include locals then) |
|
2278 |
"/ otherwise, only the arguments are considered |
|
2279 |
tree notNil ifTrue:[ |
|
2280 |
names := (tree body ? tree) allVariablesOnScope. |
|
2281 |
] |
|
2282 |
]. |
|
2283 |
||
2284 |
addWithFactorBlock value:names value:(4 * localFactor). |
|
2285 |
||
2286 |
"/ instance variables |
|
2287 |
addWithFactorBlock value:classOrNil instVarNames value:(3 * localFactor). |
|
2288 |
||
2289 |
"/ inherited instance variables |
|
2290 |
classOrNil superclass notNil ifTrue:[ |
|
2291 |
addWithFactorBlock value:classOrNil superclass allInstVarNames value:(2.5 * localFactor). |
|
2292 |
]. |
|
2293 |
]. |
|
2294 |
||
2295 |
selectorOfMessageToNode notNil ifTrue:[ |
|
2296 |
|names responders nonResponders| |
|
2297 |
||
2298 |
"/ responding to that messsage |
|
2299 |
||
2300 |
classOrNil notNil ifTrue:[ |
|
2301 |
"/ private classes |
|
2302 |
addWithFactorBlock value:(nonMetaClass privateClasses collect:[:cls | cls nameWithoutPrefix]) |
|
2303 |
value:(1.75 * globalFactor). |
|
2304 |
||
2305 |
"/ class variables |
|
2306 |
names := nonMetaClass classVarNames. |
|
2307 |
responders := names select:[:classVar | (nonMetaClass classVarAt:classVar) respondsTo:selectorOfMessageToNode]. |
|
2308 |
nonResponders := names reject:[:classVar | (nonMetaClass classVarAt:classVar) respondsTo:selectorOfMessageToNode]. |
|
2309 |
||
2310 |
addWithFactorBlock value:responders value:(1.5 * globalFactor). |
|
2311 |
addWithFactorBlock value:nonResponders value:(0.5 * 1.5 * globalFactor). |
|
2312 |
||
2313 |
"/ superclass var names |
|
2314 |
nonMetaClass allSuperclassesDo:[:superClass | |
|
2315 |
names := superClass classVarNames. |
|
2316 |
responders := names select:[:classVar | (superClass classVarAt:classVar) respondsTo:selectorOfMessageToNode]. |
|
2317 |
nonResponders := names reject:[:classVar | (superClass classVarAt:classVar) respondsTo:selectorOfMessageToNode]. |
|
2318 |
||
2319 |
addWithFactorBlock value:responders value:(1 * globalFactor). |
|
2320 |
addWithFactorBlock value:nonResponders value:(0.5 * 1 * globalFactor). |
|
2321 |
]. |
|
2322 |
||
2323 |
"/ namespace vars |
|
2324 |
classOrNil nameSpace ~~ Smalltalk ifTrue:[ |
|
2325 |
names := classOrNil topNameSpace keys. |
|
2326 |
names := names reject:[:nm | nm includes:$:]. |
|
2327 |
names := names select:[:nm | nm isUppercaseFirst ]. |
|
2328 |
responders := names select:[:nsVar | |c| c := classOrNil topNameSpace at:nsVar. c isBehavior not or:[c isLoaded and:[c respondsTo:selectorOfMessageToNode]]]. |
|
2329 |
nonResponders := names reject:[:nsVar | |c| c := classOrNil topNameSpace at:nsVar. c isBehavior not or:[c isLoaded and:[c respondsTo:selectorOfMessageToNode]]]. |
|
2330 |
addWithFactorBlock value:responders value:(1.5 * globalFactor). |
|
2331 |
addWithFactorBlock value:nonResponders value:(0.5 * 1.5 * globalFactor). |
|
2332 |
]. |
|
2333 |
]. |
|
2334 |
||
2335 |
"/ globals |
|
2336 |
names := Smalltalk keys. |
|
2337 |
"/ names := names reject:[:nm | nm includes:$:]. |
|
2338 |
names := names select:[:nm | nm isUppercaseFirst ] as:OrderedCollection. |
|
2339 |
responders := names select:[:glblVar | |c| c := Smalltalk at:glblVar. c isBehavior not or:[c isLoaded and:[c respondsTo:selectorOfMessageToNode]]]. |
|
2340 |
nonResponders := names reject:[:glblVar | |c| c := Smalltalk at:glblVar. c isBehavior not or:[c isLoaded and:[c respondsTo:selectorOfMessageToNode]]]. |
|
2341 |
addWithFactorBlock value:responders value:(1.5 * globalFactor). |
|
2342 |
addWithFactorBlock value:nonResponders value:(0.5 * 1.5 * globalFactor). |
|
2343 |
||
2344 |
"/ pool variables |
|
2345 |
classOrNil theNonMetaclass sharedPoolNames do:[:poolName | |
|
2346 |
|pool names| |
|
2347 |
||
2348 |
pool := Smalltalk at:poolName. |
|
2349 |
names := pool classVarNames. |
|
2350 |
names := names select:[:nm | nm isUppercaseFirst ]. |
|
2351 |
responders := names select:[:glblVar | |c| c := Smalltalk at:glblVar. c isBehavior not or:[c isLoaded and:[c respondsTo:selectorOfMessageToNode]]]. |
|
2352 |
nonResponders := names reject:[:glblVar | |c| c := Smalltalk at:glblVar. c isBehavior not or:[c isLoaded and:[c respondsTo:selectorOfMessageToNode]]]. |
|
2353 |
addWithFactorBlock value:responders value:(2.5 * globalFactor). |
|
2354 |
addWithFactorBlock value:nonResponders value:(0.5 * 2.5 * globalFactor). |
|
2355 |
]. |
|
2356 |
] ifFalse:[ |
|
2357 |
classOrNil notNil ifTrue:[ |
|
2358 |
"/ private classes |
|
2359 |
addWithFactorBlock value:(nonMetaClass privateClasses collect:[:cls | cls nameWithoutPrefix]) |
|
2360 |
value:(1.75 * globalFactor). |
|
2361 |
||
2362 |
"/ class variables |
|
2363 |
addWithFactorBlock value:nonMetaClass classVarNames value:(2.0 * globalFactor). |
|
2364 |
classOrNil superclass notNil ifTrue:[ |
|
2365 |
addWithFactorBlock value:nonMetaClass superclass allClassVarNames value:(2.0 * globalFactor). |
|
2366 |
]. |
|
2367 |
||
2368 |
"/ namespace vars |
|
2369 |
classOrNil nameSpace ~~ Smalltalk ifTrue:[ |
|
2370 |
names := classOrNil nameSpace isNameSpace ifTrue:[classOrNil nameSpace keys] ifFalse:[classOrNil nameSpace privateClasses collect:[:c | c nameWithoutPrefix]]. |
|
2371 |
names := names select:[:nm | nm isUppercaseFirst ]. |
|
2372 |
addWithFactorBlock value:names value:(1.5 * globalFactor). |
|
2373 |
]. |
|
2374 |
||
2375 |
"/ pool variables |
|
2376 |
classOrNil theNonMetaclass sharedPoolNames do:[:poolName | |
|
2377 |
|pool names| |
|
2378 |
||
2379 |
pool := Smalltalk at:poolName. |
|
2380 |
names := pool classVarNames. |
|
2381 |
addWithFactorBlock value:names value:(2.5 * globalFactor). |
|
2382 |
]. |
|
2383 |
]. |
|
2384 |
||
2385 |
"/ globals |
|
2386 |
names := Smalltalk keys. |
|
2387 |
names := names select:[:nm | nm isUppercaseFirst ]. |
|
2388 |
addWithFactorBlock value:names value:(1.5 * globalFactor). |
|
2389 |
]. |
|
2390 |
||
2391 |
"/ pseudos - assuming that thisContext is seldom used. |
|
2392 |
"/ also assuming, that nil is short so its usually typed in. |
|
2393 |
addWithFactorBlock value:#('self') value:(2.5 * localFactor). |
|
2394 |
addWithFactorBlock value:#('nil') value:(0.5 * localFactor). |
|
2395 |
addWithFactorBlock value:#('super' 'false') value:(2 * localFactor). |
|
2396 |
addWithFactorBlock value:#('thisContext') value:(1 * localFactor). |
|
2397 |
]. |
|
2398 |
||
2399 |
allDistances isEmpty ifTrue:[^ self]. |
|
2400 |
||
2401 |
bestAssoc := allDistances at:1. |
|
2402 |
bestAssoc := allDistances inject:bestAssoc into:[:el :best | el value > best value |
|
2403 |
ifTrue:[el] |
|
2404 |
ifFalse:[best] |
|
2405 |
]. |
|
2406 |
||
2407 |
allDistances sort:[:a :b | |
|
2408 |
a value > b value ifTrue:[ |
|
2409 |
true |
|
2410 |
] ifFalse:[ |
|
2411 |
a value = b value ifTrue:[ |
|
2412 |
a key < b key |
|
2413 |
] ifFalse:[ |
|
2414 |
false |
|
2415 |
] |
|
2416 |
] |
|
2417 |
]. |
|
2418 |
allTheBest := allDistances select:[:entry | entry value >= (bestAssoc value * 0.5)]. |
|
2419 |
nameIsOK ifTrue:[ |
|
2420 |
allTheBest := allTheBest select:[:assoc | assoc key startsWith:nm]. |
|
2421 |
]. |
|
2422 |
||
2423 |
allTheBest size > 15 ifTrue:[ |
|
2424 |
allTheBest := allDistances select:[:entry | entry value >= (bestAssoc value * 0.8)]. |
|
2425 |
]. |
|
2426 |
suggestions := allTheBest collect:[:assoc | assoc key]. |
|
2427 |
||
2428 |
editAction := |
|
2429 |
[:index | |
|
2430 |
|answer start stop oldVar| |
|
2431 |
||
2432 |
answer := suggestions at:index. |
|
2433 |
||
2434 |
start := node start. |
|
2435 |
stop := node stop. |
|
2436 |
oldVar := (codeView textFromCharacterPosition:start to:stop) asString string withoutSeparators. |
|
2437 |
||
2438 |
codeView |
|
2439 |
undoableDo:[ codeView replaceFromCharacterPosition:start to:stop with:answer ] |
|
2440 |
info:'Completion'. |
|
2441 |
||
2442 |
(answer startsWith:oldVar) ifTrue:[ |
|
2443 |
oldLen := stop - start + 1. |
|
2444 |
newLen := answer size. |
|
2445 |
codeView selectFromCharacterPosition:start+oldLen to:start+newLen-1. |
|
2446 |
codeView dontReplaceSelectionOnInput |
|
2447 |
]. |
|
2448 |
]. |
|
2449 |
||
2450 |
actionBlock value:suggestions value:editAction. |
|
2451 |
||
2452 |
"Created: / 10-11-2006 / 13:16:33 / cg" |
|
2453 |
"Modified: / 16-02-2010 / 10:13:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2454 |
"Modified: / 22-08-2012 / 22:07:24 / cg" |
|
2455 |
! |
|
2456 |
||
2457 |
findNodeForInterval:interval in:source |
|
2458 |
|tree node| |
|
2459 |
||
2460 |
interval isEmpty ifTrue: [^ nil]. |
|
2461 |
RBParser isNil ifTrue: [^ nil]. |
|
2462 |
||
2463 |
source = LastSource ifTrue:[ |
|
2464 |
tree := LastParseTree. |
|
2465 |
] ifFalse:[ |
|
2466 |
tree := RBParser |
|
2467 |
parseMethod:source |
|
2468 |
onError: |
|
2469 |
[:str :err ":nodesSoFar" | |
|
2470 |
"Transcript showCR:'Parse-Error: ',str." |
|
2471 |
nil |
|
2472 |
]. |
|
2473 |
||
2474 |
tree isNil ifTrue:[ |
|
2475 |
"/ try to parse as an expression |
|
2476 |
tree := RBParser |
|
2477 |
parseExpression:source |
|
2478 |
onError: |
|
2479 |
[:str :err ":nodesSoFar" | |
|
2480 |
"Transcript showCR:'Parse-Error: ',str." |
|
2481 |
nil |
|
2482 |
]. |
|
2483 |
||
2484 |
tree isNil ifTrue:[ |
|
2485 |
^ nil |
|
2486 |
]. |
|
2487 |
]. |
|
2488 |
||
2489 |
LastSource := source. |
|
2490 |
LastParseTree := tree. |
|
2491 |
]. |
|
2492 |
||
2493 |
node := tree whichNodeIsContainedBy:interval. |
|
2494 |
node isNil ifTrue: [ |
|
2495 |
node := tree bestNodeFor: interval. |
|
2496 |
node isNil ifTrue: [ |
|
2497 |
node := self findNodeIn:tree forInterval:interval |
|
2498 |
]. |
|
2499 |
]. |
|
2500 |
^ node |
|
2501 |
||
2502 |
"Modified: / 06-07-2011 / 12:42:53 / cg" |
|
2503 |
! |
|
2504 |
||
2505 |
findNodeForInterval:interval in:source allowErrors:allowErrors |
|
2506 |
^ self |
|
2507 |
findNodeForInterval:interval in:source allowErrors:allowErrors |
|
2508 |
mustBeMethod:false |
|
2509 |
||
2510 |
"Modified: / 16-09-2011 / 14:52:28 / cg" |
|
2511 |
! |
|
2512 |
||
2513 |
findNodeForInterval:interval in:source allowErrors:allowErrors mustBeMethod:mustBeMethod |
|
2514 |
"if mustBeMethod is true, do not try a regular expression (as in a workspace)." |
|
2515 |
||
2516 |
|"errCount" intersectingNodes smallestIntersectingNode firstIntersectingNode onErrorBlock nodeGenerationHook parser| |
|
2517 |
||
2518 |
interval isEmpty ifTrue: [^ nil]. |
|
2519 |
RBParser isNil ifTrue: [^ nil]. |
|
2520 |
||
2521 |
"/ LastSource := nil. |
|
2522 |
source = LastSource ifTrue:[ |
|
2523 |
tree := LastParseTree. |
|
2524 |
tokens := LastScanTokens. |
|
2525 |
] ifFalse:[ |
|
2526 |
intersectingNodes := OrderedCollection new. |
|
2527 |
||
2528 |
onErrorBlock := |
|
2529 |
[:str :err :nodesSoFar | |
|
2530 |
|nodes| |
|
2531 |
||
2532 |
allowErrors ifTrue:[ |
|
4301 | 2533 |
firstIntersectingNode notNil ifTrue:[ |
2534 |
^ firstIntersectingNode |
|
2535 |
]. |
|
4238 | 2536 |
nodesSoFar notNil ifTrue:[ |
2537 |
nodes := nodesSoFar asOrderedCollection |
|
2538 |
collect:[:nd | nd whichNodeIntersects:interval] |
|
2539 |
thenSelect:[:nd | nd notNil ]. |
|
2540 |
nodes size == 1 ifTrue:[ |
|
2541 |
^ nodes first |
|
2542 |
]. |
|
2543 |
] |
|
2544 |
]. |
|
2545 |
nil |
|
2546 |
]. |
|
2547 |
||
2548 |
nodeGenerationHook := |
|
2549 |
[:node | |
|
2550 |
"/ we would like to return here as soon as the node has been created by the parser; |
|
2551 |
"/ however, at that time, its parent(chain) is not yet created and so we might not know |
|
2552 |
"/ what the semantic intepretation (especially: scope of variable) will be. |
|
2553 |
"/ therefore, we parse all, and return the found node at the end. |
|
2554 |
"//// ^ node. |
|
2555 |
"/ self halt. |
|
2556 |
(node intersectsInterval:interval) ifTrue:[ |
|
2557 |
intersectingNodes add:node. |
|
2558 |
firstIntersectingNode isNil ifTrue:[ |
|
2559 |
firstIntersectingNode := smallestIntersectingNode := node |
|
2560 |
] ifFalse:[ |
|
2561 |
|lenNode lenSmallest| |
|
2562 |
||
2563 |
lenNode := (node stop - node start). |
|
2564 |
lenSmallest := (smallestIntersectingNode stop - smallestIntersectingNode start). |
|
2565 |
lenNode < lenSmallest ifTrue:[ |
|
2566 |
smallestIntersectingNode := node. |
|
2567 |
] |
|
2568 |
]. |
|
2569 |
]. |
|
2570 |
]. |
|
2571 |
||
2572 |
tree := RBParser |
|
2573 |
parseMethod: source |
|
2574 |
setup:[:p | |
|
2575 |
parser := p. |
|
2576 |
p rememberNodes:true. |
|
2577 |
p rememberTokens:true. |
|
2578 |
p nodeGenerationCallback:nodeGenerationHook |
|
2579 |
] |
|
2580 |
onError: onErrorBlock. |
|
2581 |
parser notNil ifTrue:[ tokens := parser rememberedTokens ]. |
|
2582 |
||
2583 |
mustBeMethod ifTrue:[ |
|
2584 |
"/ only cache parsed methods |
|
2585 |
tree notNil ifTrue:[ |
|
2586 |
LastSource := source. |
|
2587 |
LastParseTree := tree. |
|
2588 |
LastScanTokens := tokens. |
|
2589 |
]. |
|
2590 |
] ifFalse:[ |
|
2591 |
(tree isNil or:[firstIntersectingNode isNil]) ifTrue:[ |
|
2592 |
"/ try as an expression |
|
2593 |
tree := RBParser |
|
2594 |
parseExpression: source |
|
2595 |
setup:[:p | |
|
2596 |
parser := p. |
|
2597 |
p rememberNodes:true. |
|
2598 |
p rememberTokens:true. |
|
2599 |
p nodeGenerationCallback:nodeGenerationHook |
|
2600 |
] |
|
2601 |
onError: onErrorBlock. |
|
4276 | 2602 |
parser notNil ifTrue:[ tokens := parser rememberedTokens ]. |
4238 | 2603 |
]. |
2604 |
]. |
|
2605 |
"/ self halt. |
|
2606 |
firstIntersectingNode notNil ifTrue:[ ^ firstIntersectingNode ]. |
|
2607 |
]. |
|
2608 |
||
2609 |
^ self findNodeForInterval:interval inParseTree:tree. |
|
2610 |
||
2611 |
"Created: / 16-09-2011 / 14:52:08 / cg" |
|
2612 |
! |
|
2613 |
||
2614 |
findNodeForInterval:interval inParseTree:parseTree |
|
2615 |
|node| |
|
2616 |
||
2617 |
interval isEmpty ifTrue: [^ nil]. |
|
2618 |
parseTree isNil ifTrue:[^ nil]. |
|
2619 |
||
2620 |
node := parseTree whichNodeIsContainedBy:interval. |
|
2621 |
node isNil ifTrue:[ |
|
2622 |
node := parseTree whichNodeIntersects:interval. |
|
2623 |
node isNil ifTrue: [ |
|
2624 |
node := self findNodeIn:parseTree forInterval:interval |
|
2625 |
]. |
|
2626 |
]. |
|
2627 |
^ node |
|
2628 |
||
2629 |
"Modified: / 10-11-2006 / 13:13:58 / cg" |
|
2630 |
! |
|
2631 |
||
2632 |
findNodeIn:tree forInterval:interval |
|
2633 |
|nodeFound wouldReturn| |
|
2634 |
||
2635 |
nodeFound := nil. |
|
2636 |
tree nodesDo:[:eachNode | |
|
2637 |
(eachNode intersectsInterval:interval) ifTrue:[ |
|
2638 |
(nodeFound isNil or:[nodeFound == eachNode parent]) ifTrue:[ |
|
2639 |
nodeFound := eachNode |
|
2640 |
] ifFalse:[ |
|
2641 |
(nodeFound parent == eachNode parent |
|
2642 |
and:[ eachNode start >= nodeFound start |
|
2643 |
and:[ eachNode stop <= nodeFound stop ] ]) ifTrue:[ |
|
2644 |
] ifFalse:[ |
|
2645 |
(nodeFound parent notNil |
|
2646 |
and:[nodeFound parent isCascade and:[eachNode parent isCascade]]) ifFalse:[^ nil] |
|
2647 |
] |
|
2648 |
] |
|
2649 |
] ifFalse:[ |
|
2650 |
nodeFound notNil ifTrue:[ |
|
2651 |
"/ already found one - beyond that one; leave |
|
2652 |
wouldReturn notNil ifTrue:[wouldReturn := nodeFound]. |
|
2653 |
] |
|
2654 |
]. |
|
2655 |
]. |
|
2656 |
"/ (wouldReturn notNil and:[wouldReturn ~~ node]) ifTrue:[self halt]. |
|
2657 |
^ nodeFound |
|
2658 |
||
2659 |
"Modified: / 20-11-2006 / 12:31:12 / cg" |
|
2660 |
! |
|
2661 |
||
2662 |
lookupClassForMessage:node inClass:classProvidingNamespaceOrNil |
|
2663 |
|receiver nm nodeVal receiverClass| |
|
2664 |
||
2665 |
receiver := node receiver. |
|
2666 |
receiver isLiteral ifTrue:[ |
|
2667 |
^ receiver value class |
|
2668 |
]. |
|
2669 |
receiver isVariable ifTrue:[ |
|
2670 |
nm := receiver name. |
|
2671 |
nm = 'self' ifTrue:[ |
|
2672 |
classProvidingNamespaceOrNil isNil ifTrue:[^ UndefinedObject]. |
|
2673 |
^ classProvidingNamespaceOrNil |
|
2674 |
]. |
|
2675 |
nm = 'super' ifTrue:[ |
|
2676 |
classProvidingNamespaceOrNil isNil ifTrue:[^ Object]. |
|
2677 |
^ classProvidingNamespaceOrNil superclass |
|
2678 |
]. |
|
2679 |
nm isUppercaseFirst ifTrue:[ |
|
2680 |
"/ wouldn't it be better to simply 'evaluate' the variable ? |
|
2681 |
Error handle:[:ex | |
|
2682 |
] do:[ |
|
2683 |
|dummyReceiver| |
|
2684 |
||
2685 |
dummyReceiver := classProvidingNamespaceOrNil notNil ifTrue:[classProvidingNamespaceOrNil basicNew] ifFalse:[nil]. |
|
2686 |
nodeVal := Parser new evaluate:nm in:nil receiver:dummyReceiver. |
|
2687 |
]. |
|
2688 |
"/ (Smalltalk includesKey:nm asSymbol) ifTrue:[ |
|
2689 |
"/ nodeVal := Smalltalk at:nm asSymbol. |
|
2690 |
"/ ]. |
|
2691 |
nodeVal notNil ifTrue:[ |
|
2692 |
^ nodeVal class |
|
2693 |
] |
|
2694 |
] |
|
2695 |
]. |
|
2696 |
||
2697 |
receiver isMessage ifTrue:[ |
|
2698 |
(receiver selector = 'new' |
|
2699 |
or:[ receiver selector = 'new:' ]) ifTrue:[ |
|
2700 |
receiverClass := self lookupClassForMessage:receiver inClass:classProvidingNamespaceOrNil. |
|
2701 |
receiverClass notNil ifTrue:[ |
|
2702 |
receiverClass isBehavior ifTrue:[ |
|
2703 |
receiverClass isMeta ifTrue:[ |
|
2704 |
^ receiverClass theNonMetaclass |
|
2705 |
] |
|
2706 |
] |
|
2707 |
]. |
|
2708 |
]. |
|
2709 |
classProvidingNamespaceOrNil notNil ifTrue:[ |
|
2710 |
(receiver receiver isSelf and:[receiver selector = 'class']) ifTrue:[ |
|
2711 |
^ classProvidingNamespaceOrNil class |
|
2712 |
]. |
|
2713 |
]. |
|
2714 |
]. |
|
2715 |
^ nil |
|
2716 |
||
2717 |
"Modified: / 24-08-2010 / 15:05:49 / sr" |
|
2718 |
"Modified: / 17-07-2011 / 10:28:19 / cg" |
|
2719 |
! |
|
2720 |
||
2721 |
old_askUserForCompletion:what for:codeView from:allTheBest |
|
2722 |
|list resources choice lastChoice| |
|
2723 |
||
2724 |
allTheBest isEmpty ifTrue:[ ^ nil ]. |
|
2725 |
allTheBest size == 1 ifTrue:[ ^ allTheBest first ]. |
|
2726 |
||
2727 |
list := allTheBest. |
|
2728 |
LastChoices notNil ifTrue:[ |
|
2729 |
lastChoice := LastChoices at:what ifAbsent:nil. |
|
2730 |
lastChoice notNil ifTrue:[ |
|
2731 |
(list includes: lastChoice) ifTrue:[ |
|
4301 | 2732 |
list := {lastChoice allBold } , (list copyWithout:lastChoice). |
4238 | 2733 |
] |
2734 |
]. |
|
2735 |
]. |
|
2736 |
||
2737 |
list size < 30 ifTrue:[ |
|
2738 |
|menu idx exitKey| |
|
2739 |
||
2740 |
menu := PopUpMenu labels:list. |
|
2741 |
menu hideOnKeyFilter:[:key | |hide| |
|
2742 |
hide := ( #( CursorDown CursorUp Escape Return ) includes: key) not. |
|
2743 |
hide ifTrue:[ |
|
2744 |
exitKey := key. |
|
2745 |
]. |
|
2746 |
hide]. |
|
2747 |
||
2748 |
idx := menu startUp. |
|
2749 |
idx == 0 ifTrue:[ |
|
2750 |
exitKey notNil ifTrue:[ |
|
2751 |
codeView keyPress:exitKey x:0 y:0. |
|
2752 |
]. |
|
2753 |
^ nil |
|
2754 |
]. |
|
2755 |
choice := list at:idx. |
|
2756 |
] ifFalse:[ |
|
2757 |
resources := codeView application isNil |
|
2758 |
ifTrue:[ codeView resources] |
|
2759 |
ifFalse:[ codeView application resources ]. |
|
2760 |
||
2761 |
choice := Dialog |
|
2762 |
choose:(resources string:'Choose ',what) |
|
2763 |
fromList:list |
|
2764 |
lines:20 |
|
2765 |
initialSelection:(list firstIfEmpty:nil) |
|
2766 |
title:(resources string:'Code completion'). |
|
2767 |
choice isNil ifTrue:[^ nil]. |
|
2768 |
]. |
|
4301 | 2769 |
choice := choice string. |
4238 | 2770 |
|
2771 |
LastChoices isNil ifTrue:[ |
|
2772 |
LastChoices := Dictionary new. |
|
2773 |
]. |
|
2774 |
LastChoices at:what put:choice. |
|
2775 |
^ choice |
|
2776 |
||
2777 |
"Created: / 16-02-2010 / 09:38:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2778 |
"Modified: / 21-07-2012 / 12:21:10 / cg" |
|
2779 |
! |
|
2780 |
||
2781 |
treeForCode:source allowErrors:allowErrors |
|
2782 |
|tree| |
|
2783 |
||
2784 |
source = LastSource ifTrue:[ |
|
2785 |
tree := LastParseTree. |
|
2786 |
] ifFalse:[ |
|
2787 |
tree := RBParser |
|
2788 |
parseMethod:source |
|
2789 |
onError: [:str :err :nodesSoFar :parserOrNil| |
|
2790 |
allowErrors ifTrue:[ |
|
2791 |
"/ parserOrNil isNil if raised by the scanner |
|
2792 |
parserOrNil notNil ifTrue:[ |
|
2793 |
^ parserOrNil currentMethodNode |
|
2794 |
] |
|
2795 |
]. |
|
2796 |
^ nil |
|
2797 |
] |
|
2798 |
proceedAfterError:false |
|
2799 |
rememberNodes:true. |
|
2800 |
||
2801 |
tree notNil ifTrue:[ |
|
2802 |
LastSource := source. |
|
2803 |
LastParseTree := tree. |
|
2804 |
] |
|
2805 |
]. |
|
2806 |
^ tree |
|
2807 |
||
2808 |
"Modified: / 13-01-2012 / 11:54:30 / cg" |
|
2809 |
! ! |
|
2810 |
||
2811 |
!DoWhatIMeanSupport methodsFor:'code completion-helpers-old'! |
|
2812 |
||
2813 |
codeCompletionForLiteralSymbol:node inClass:classOrNil codeView:codeView |
|
2814 |
|sym possibleCompletions best start stop oldLen newLen oldVar| |
|
2815 |
||
2816 |
sym := node value. |
|
2817 |
possibleCompletions := OrderedCollection new. |
|
2818 |
||
2819 |
Symbol allInstancesDo:[:existingSym | |
|
2820 |
(existingSym startsWith:sym) ifTrue:[ |
|
2821 |
(existingSym = sym) ifFalse:[ |
|
2822 |
possibleCompletions add:existingSym |
|
2823 |
]. |
|
2824 |
]. |
|
2825 |
]. |
|
2826 |
possibleCompletions sort. |
|
2827 |
||
2828 |
best := possibleCompletions longestCommonPrefix. |
|
2829 |
(best = sym or:[(possibleCompletions includes:best) not]) ifTrue:[ |
|
2830 |
best := self askUserForCompletion:'symbol literal' for:codeView at: node start from:possibleCompletions. |
|
2831 |
best isNil ifTrue:[^ self]. |
|
2832 |
]. |
|
2833 |
||
2834 |
"/ self showInfo:best. |
|
2835 |
||
2836 |
start := node start. |
|
2837 |
stop := node stop. |
|
2838 |
(codeView characterAtCharacterPosition:start) == $# ifTrue:[ |
|
2839 |
start := start + 1. |
|
2840 |
]. |
|
2841 |
(codeView characterAtCharacterPosition:start) == $' ifTrue:[ |
|
2842 |
start := start + 1. |
|
2843 |
stop := stop - 1. |
|
2844 |
]. |
|
2845 |
||
2846 |
oldVar := (codeView textFromCharacterPosition:start to:stop) asString string withoutSeparators. |
|
2847 |
||
2848 |
codeView |
|
2849 |
undoableDo:[ codeView replaceFromCharacterPosition:start to:stop with:best ] |
|
2850 |
info:'Completion'. |
|
2851 |
||
2852 |
(best startsWith:oldVar) ifTrue:[ |
|
2853 |
oldLen := stop - start + 1. |
|
2854 |
newLen := best size. |
|
2855 |
codeView selectFromCharacterPosition:start+oldLen to:start+newLen-1. |
|
2856 |
codeView dontReplaceSelectionOnInput |
|
2857 |
]. |
|
2858 |
||
2859 |
"Modified: / 16-02-2010 / 10:15:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2860 |
"Modified (format): / 03-07-2011 / 15:58:45 / cg" |
|
2861 |
! |
|
2862 |
||
2863 |
codeCompletionForMessage:node inClass:classOrNil codeView:codeView |
|
2864 |
|selector srchClass implClass |
|
4277 | 2865 |
bestSelectors selector2 bestSelectors2 bestSelectorsFromRB allBest best info numArgs |
4238 | 2866 |
newParts nSelParts oldLen newLen selectorParts |
2867 |
findBest parentNode selectorInBest selector2InBest2 |
|
4277 | 2868 |
parser selectorsSentInCode split |
4304 | 2869 |
varName rbTypes rbType tryParent parentIsKeywordMessage| |
4277 | 2870 |
|
4281 | 2871 |
RefactoryTyper notNil ifTrue:[ |
4301 | 2872 |
"/ refactory package also provides a (very limited) typer; |
2873 |
"/ ask it for its oppinion as well (temporary - will vanish, once we have a better typer) |
|
4280 | 2874 |
(node receiver isVariable) ifTrue:[ |
2875 |
varName := node receiver name. |
|
2876 |
tree := RBParser |
|
2877 |
parseMethod:codeView contents string |
|
2878 |
onError:[:aString :pos | nil]. |
|
2879 |
tree notNil ifTrue:[ |
|
2880 |
rbTypes := RefactoryTyper |
|
2881 |
classesFor: varName |
|
2882 |
in: tree |
|
2883 |
model: nil |
|
2884 |
ignoredSelectors:(Array with:node selector). |
|
4301 | 2885 |
rbTypes size > 0 ifTrue:[ |
2886 |
rbTypes size > 1 ifTrue:[ |
|
2887 |
rbTypes remove:ProtoObject ifAbsent:[]. |
|
2888 |
rbTypes remove:Autoload ifAbsent:[]. |
|
2889 |
rbTypes remove:ObsoleteObject ifAbsent:[]. |
|
2890 |
]. |
|
2891 |
rbTypes size == 1 ifTrue:[ |
|
2892 |
rbType := rbTypes first. |
|
2893 |
] ifFalse:[ |
|
2894 |
rbType := Class commonSuperclassOf:rbTypes |
|
2895 |
]. |
|
4302 | 2896 |
(rbType notNil "and:[rbType ~= Object]") ifTrue:[ |
4301 | 2897 |
bestSelectorsFromRB := Parser findBest:30 selectorsFor:node selector in:rbType forCompletion:true. |
2898 |
]. |
|
4280 | 2899 |
] |
2900 |
] |
|
2901 |
]. |
|
4277 | 2902 |
]. |
4238 | 2903 |
|
2904 |
classOrNil notNil ifTrue:[ |
|
2905 |
parser := Parser parseMethod:codeView contents string in:classOrNil ignoreErrors:true ignoreWarnings:true. |
|
2906 |
selectorsSentInCode := parser messagesSent. |
|
2907 |
]. |
|
2908 |
||
2909 |
findBest := [:node :selector | |
|
2910 |
|srchClass bestSelectors bestPrefixes| |
|
2911 |
||
2912 |
codeView topView withCursor:(Cursor questionMark) do:[ |
|
2913 |
srchClass := self lookupClassForMessage:node inClass:classOrNil. |
|
2914 |
srchClass notNil ifTrue:[ |
|
2915 |
bestSelectors := Parser findBest:30 selectorsFor:selector in:srchClass forCompletion:true. |
|
2916 |
] ifFalse:[ |
|
2917 |
bestSelectors := Parser findBest:30 selectorsFor:selector in:nil forCompletion:true. |
|
2918 |
]. |
|
2919 |
]. |
|
2920 |
||
2921 |
(bestSelectors includes:selector) ifTrue:[ |
|
2922 |
bestSelectors := bestSelectors select:[:sel | sel size > selector size]. |
|
2923 |
]. |
|
2924 |
bestSelectors |
|
2925 |
]. |
|
2926 |
||
2927 |
selector := node selector. |
|
2928 |
bestSelectors := findBest value:node value:selector. |
|
2929 |
||
2930 |
parentNode := node parent. |
|
2931 |
||
4304 | 2932 |
parentIsKeywordMessage := |
2933 |
(parentNode notNil |
|
2934 |
and:[ parentNode isMessage |
|
2935 |
and:[ parentNode selector isKeywordSelector]]). |
|
2936 |
||
2937 |
tryParent := false. |
|
4238 | 2938 |
"/ if its a unary message AND the parent is a keyword node, look for parent completion too. |
4304 | 2939 |
(node selector isUnarySelector and:[ parentIsKeywordMessage ]) ifTrue:[ |
2940 |
tryParent := true. |
|
4301 | 2941 |
] ifFalse:[ |
2942 |
"/ also, if nothing was found |
|
2943 |
(bestSelectors isEmpty |
|
2944 |
and:[ parentNode notNil |
|
2945 |
and:[ parentNode isMessage ]]) ifTrue:[ |
|
2946 |
"/ srchClass2 := self lookupClassForMessage:parentNode inClass:classOrNil. |
|
4304 | 2947 |
"/ selector2 := parentNode selector. |
4301 | 2948 |
"/ selector2 := selector2,selector. |
2949 |
bestSelectors := findBest value:parentNode value:selector. |
|
2950 |
] |
|
4304 | 2951 |
]. |
2952 |
tryParent ifTrue:[ |
|
2953 |
selector2 := parentNode selector,selector. |
|
2954 |
bestSelectors2 := findBest value:parentNode value:selector2. |
|
2955 |
]. |
|
4238 | 2956 |
|
4282 | 2957 |
bestSelectors := (bestSelectorsFromRB ? #()) , bestSelectors. |
4277 | 2958 |
|
4304 | 2959 |
"/ if the parent is a keyword selector, the child cannot |
2960 |
parentIsKeywordMessage ifTrue:[ |
|
2961 |
bestSelectors := bestSelectors reject:[:sel | sel isKeywordSelector] |
|
2962 |
]. |
|
2963 |
||
4238 | 2964 |
bestSelectors2 isEmptyOrNil ifTrue:[ |
2965 |
allBest := bestSelectors. |
|
2966 |
] ifFalse:[ |
|
2967 |
bestSelectors isEmptyOrNil ifTrue:[ |
|
2968 |
allBest := bestSelectors2 |
|
2969 |
] ifFalse:[ |
|
2970 |
selectorInBest := (bestSelectors contains:[:sel | sel asLowercase startsWith:selector asLowercase]). |
|
2971 |
selector2InBest2 := (bestSelectors2 contains:[:sel | sel asLowercase startsWith:selector2 asLowercase]). |
|
2972 |
||
2973 |
(selectorInBest not and:[ selector2InBest2 ]) ifTrue:[ |
|
2974 |
"/ selector2 is more likely |
|
2975 |
allBest := bestSelectors2 |
|
2976 |
] ifFalse:[ |
|
2977 |
(selectorInBest and:[ selector2InBest2 not ]) ifTrue:[ |
|
2978 |
"/ selector more likely |
|
2979 |
allBest := bestSelectors |
|
2980 |
] ifFalse:[ |
|
2981 |
"/ assume same likelyness |
|
2982 |
||
2983 |
allBest := bestSelectors isEmpty |
|
2984 |
ifTrue:[ bestSelectors2 ] |
|
2985 |
ifFalse:[ bestSelectors , #(nil) , bestSelectors2 ]. |
|
2986 |
] |
|
2987 |
]. |
|
2988 |
]. |
|
2989 |
]. |
|
2990 |
||
2991 |
allBest isEmptyOrNil ifTrue:[ ^ self ]. |
|
2992 |
||
2993 |
split := [:list :splitHow | |
|
2994 |
|part1 part2 all| |
|
2995 |
||
2996 |
part1 := list select:splitHow. |
|
2997 |
part2 := list reject:splitHow. |
|
2998 |
part1 isEmpty ifTrue:[ |
|
2999 |
all := part2. |
|
3000 |
] ifFalse:[ |
|
3001 |
part2 isEmpty ifTrue:[ |
|
3002 |
all := part1. |
|
3003 |
] ifFalse:[ |
|
3004 |
all := part1 , part2. |
|
3005 |
] |
|
3006 |
]. |
|
3007 |
all |
|
3008 |
]. |
|
3009 |
||
3010 |
selectorsSentInCode notNil ifTrue:[ |
|
3011 |
"/ the ones already sent in the code are moved to the top of the list. |
|
3012 |
allBest := split value:allBest value:[:sel | selectorsSentInCode includes:sel]. |
|
3013 |
]. |
|
3014 |
||
3015 |
"/ the ones which are a prefix are moved towards the top of the list |
|
3016 |
allBest := split value:allBest value:[:sel | sel notNil and:[sel startsWith:selector]]. |
|
3017 |
||
3018 |
best := allBest first. |
|
3019 |
allBest size > 1 ifTrue:[ |
|
3020 |
"allBest size < 20 ifTrue:[ |
|
3021 |
|idx| |
|
3022 |
||
3023 |
idx := (PopUpMenu labels:allBest) startUp. |
|
3024 |
idx == 0 ifTrue:[ ^ self]. |
|
3025 |
best := allBest at:idx. |
|
3026 |
] ifFalse:[ |
|
4282 | 3027 |
allBest remove:nil ifAbsent:[]. |
4238 | 3028 |
best := Dialog request:'Matching selectors:' initialAnswer:best list:allBest. |
3029 |
||
3030 |
]." |
|
4282 | 3031 |
allBest remove:nil ifAbsent:[]. |
4238 | 3032 |
best := self askUserForCompletion:'selector' for:codeView at: node selectorParts first start from:allBest. |
3033 |
best isEmptyOrNil ifTrue:[^ self]. |
|
3034 |
best = '-' ifTrue:[^ self]. |
|
3035 |
]. |
|
3036 |
||
3037 |
false ifTrue:[ |
|
3038 |
srchClass notNil ifTrue:[ |
|
3039 |
implClass := srchClass whichClassIncludesSelector:best. |
|
3040 |
] ifFalse:[ |
|
3041 |
implClass := Smalltalk allClasses select:[:cls | (cls includesSelector:best) or:[cls class includesSelector:best]]. |
|
3042 |
implClass size == 1 ifTrue:[ |
|
3043 |
implClass := implClass first. |
|
3044 |
] ifFalse:[ |
|
3045 |
implClass := nil |
|
3046 |
] |
|
3047 |
]. |
|
3048 |
||
3049 |
info := best storeString. |
|
3050 |
implClass notNil ifTrue:[ |
|
3051 |
info := implClass name , ' >> ' , info. |
|
3052 |
]. |
|
3053 |
self information:info. |
|
3054 |
]. |
|
3055 |
||
3056 |
best ~= selector ifTrue:[ |
|
3057 |
numArgs := best numArgs. |
|
4304 | 3058 |
|
4238 | 3059 |
(bestSelectors2 notEmptyOrNil and:[bestSelectors2 includes:best]) ifTrue:[ |
3060 |
selectorParts := parentNode selectorParts , node selectorParts. |
|
3061 |
] ifFalse:[ |
|
3062 |
selectorParts := node selectorParts. |
|
3063 |
]. |
|
3064 |
nSelParts := selectorParts size. |
|
3065 |
||
3066 |
newParts := best asCollectionOfSubstringsSeparatedBy:$:. |
|
3067 |
newParts := newParts select:[:part | part size > 0]. |
|
3068 |
||
3069 |
codeView |
|
3070 |
undoableDo:[ |
|
3071 |
|newCursorPosition stop| |
|
3072 |
||
3073 |
numArgs > nSelParts ifTrue:[ |
|
3074 |
stop := selectorParts last stop. |
|
3075 |
||
3076 |
"/ append the rest ... |
|
3077 |
numArgs downTo:nSelParts+1 do:[:idx | |
|
3078 |
|newPart| |
|
3079 |
||
3080 |
newPart := newParts at:idx. |
|
3081 |
(best endsWith:$:) ifTrue:[ |
|
3082 |
newPart := newPart , ':' |
|
3083 |
]. |
|
3084 |
||
3085 |
(codeView characterAtCharacterPosition:stop) == $: ifFalse:[ |
|
3086 |
newPart := ':' , newPart. |
|
3087 |
]. |
|
3088 |
newPart := (codeView characterAtCharacterPosition:stop) asString , newPart. |
|
3089 |
||
3090 |
codeView replaceFromCharacterPosition:stop to:stop with:newPart. |
|
3091 |
newCursorPosition := stop + newPart size. |
|
3092 |
] |
|
3093 |
]. |
|
3094 |
||
3095 |
(nSelParts min:newParts size) downTo:1 do:[:idx | |
|
3096 |
|newPart oldPartialToken start stop| |
|
3097 |
||
3098 |
newPart := newParts at:idx. |
|
3099 |
oldPartialToken := selectorParts at:idx. |
|
3100 |
start := oldPartialToken start. |
|
3101 |
stop := oldPartialToken stop. |
|
3102 |
||
4304 | 3103 |
(best isKeywordSelector) ifTrue:[ |
3104 |
(oldPartialToken value endsWith:$:) ifTrue:[ |
|
4238 | 3105 |
newPart := newPart , ':' |
4304 | 3106 |
] ifFalse:[ |
3107 |
(codeView characterAtCharacterPosition:stop+1) == $: ifFalse:[ |
|
3108 |
newPart := newPart , ':' |
|
3109 |
] |
|
4238 | 3110 |
] |
3111 |
] ifFalse:[ |
|
3112 |
(codeView characterAtCharacterPosition:stop) == $: ifTrue:[ |
|
3113 |
newPart := newPart , ':' |
|
3114 |
] ifFalse:[ |
|
3115 |
(codeView characterAtCharacterPosition:stop+1) isSeparator ifFalse:[ |
|
4284 | 3116 |
(').' includes:(codeView characterAtCharacterPosition:stop+1)) ifFalse:[ |
3117 |
newPart := newPart , ' ' |
|
3118 |
]. |
|
4238 | 3119 |
] |
3120 |
] |
|
3121 |
"/ codeView replaceFromCharacterPosition:start to:stop with:(newPart , ':'). |
|
3122 |
"/ ] ifFalse:[ |
|
3123 |
"/ codeView replaceFromCharacterPosition:start to:stop with:newPart. |
|
3124 |
]. |
|
3125 |
||
3126 |
codeView replaceFromCharacterPosition:start to:stop with:newPart. |
|
3127 |
||
3128 |
"/ codeView selectFromCharacterPosition:start+oldLen to:start+newLen-1. |
|
4304 | 3129 |
newCursorPosition isNil ifTrue:[ |
3130 |
oldLen := stop - start + 1. |
|
3131 |
newLen := newPart size. |
|
3132 |
||
3133 |
newCursorPosition := stop + (newLen-oldLen) |
|
3134 |
]. |
|
4238 | 3135 |
]. |
4304 | 3136 |
|
4238 | 3137 |
codeView cursorToCharacterPosition:newCursorPosition. |
3138 |
codeView cursorRight. "/ avoid going to the next line !! |
|
4301 | 3139 |
((best endsWith:':') and:[numArgs == 1]) ifTrue:[ |
3140 |
|impls| |
|
3141 |
||
3142 |
"/ see if it expects a block argument (heuristic) |
|
3143 |
best := best asSymbol. |
|
3144 |
impls := Smalltalk allImplementorsOf:best. |
|
3145 |
(impls contains:[:cls | |
|
3146 |
|argName| |
|
3147 |
||
3148 |
argName := ((cls compiledMethodAt:best) methodArgAndVarNames at:1) asLowercase. |
|
3149 |
(argName includesString:'block') or:[ (argName includesString:'action')]] |
|
3150 |
) ifTrue:[ |
|
3151 |
codeView insertStringAtCursor:'[' |
|
3152 |
]. |
|
3153 |
]. |
|
4238 | 3154 |
codeView dontReplaceSelectionOnInput. |
3155 |
] |
|
3156 |
info:'Completion'. |
|
3157 |
]. |
|
3158 |
||
3159 |
"Created: / 10-11-2006 / 13:18:27 / cg" |
|
3160 |
"Modified: / 16-02-2010 / 10:33:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3161 |
"Modified: / 21-07-2012 / 12:24:06 / cg" |
|
3162 |
! |
|
3163 |
||
3164 |
codeCompletionForVariable:node inClass:classOrNil codeView:codeView |
|
4277 | 3165 |
|parent nonMetaClass crsrPos nm |
4238 | 3166 |
allVariables allDistances best nodeVal |
3167 |
char start stop oldLen newLen oldVar |
|
3168 |
getDistanceComputeBlockWithWeight addWithFactorBlock names allTheBest bestAssoc |
|
3169 |
globalFactor localFactor selectorOfMessageToNode tree implementors argIdx namesUsed kwPart| |
|
3170 |
||
3171 |
classOrNil notNil ifTrue:[ |
|
3172 |
nonMetaClass := classOrNil theNonMetaclass. |
|
3173 |
]. |
|
3174 |
||
3175 |
nm := node name. |
|
3176 |
||
3177 |
"/ if we are behind the variable and a space has already been entered, |
|
3178 |
"/ the user is probably looking for a message selector. |
|
3179 |
"/ If the variable represents a global, present its instance creation messages |
|
3180 |
crsrPos := codeView characterPositionOfCursor. |
|
3181 |
char := codeView characterAtCharacterPosition:crsrPos-1. |
|
3182 |
char isSeparator ifTrue:[ |
|
3183 |
classOrNil isNil ifTrue:[ |
|
3184 |
nodeVal := Smalltalk at:nm asSymbol. |
|
3185 |
] ifFalse:[ |
|
3186 |
nodeVal := classOrNil topNameSpace at:nm asSymbol ifAbsent:[Smalltalk at:nm asSymbol]. |
|
3187 |
]. |
|
3188 |
nodeVal isBehavior ifTrue:[ |
|
3189 |
|methods menu exitKey idx| |
|
3190 |
||
3191 |
methods := nodeVal class methodDictionary values |
|
3192 |
select:[:m | |cat| |
|
3193 |
cat := m category asLowercase. |
|
3194 |
cat = 'instance creation' |
|
3195 |
]. |
|
3196 |
||
3197 |
menu := PopUpMenu labels:(methods collect:[:each | each selector]). |
|
3198 |
menu hideOnKeyFilter:[:key | |hide| |
|
3199 |
hide := ( #( CursorDown CursorUp Escape Return ) includes: key) not. |
|
3200 |
hide ifTrue:[ |
|
3201 |
exitKey := key. |
|
3202 |
]. |
|
3203 |
hide]. |
|
3204 |
||
3205 |
idx := menu startUp. |
|
3206 |
idx == 0 ifTrue:[ |
|
3207 |
exitKey notNil ifTrue:[ |
|
3208 |
codeView keyPress:exitKey x:0 y:0. |
|
3209 |
]. |
|
3210 |
^ self |
|
3211 |
]. |
|
3212 |
best := (methods at:idx) selector. |
|
3213 |
codeView |
|
3214 |
undoableDo:[ |
|
3215 |
codeView insertString:best atCharacterPosition:crsrPos. |
|
3216 |
codeView cursorToCharacterPosition:crsrPos+best size. |
|
3217 |
] |
|
3218 |
info:'completion'. |
|
3219 |
^ self. |
|
3220 |
]. |
|
3221 |
]. |
|
3222 |
||
4277 | 3223 |
((parent := node parent) notNil and:[parent isMessage]) ifTrue:[ |
3224 |
node == parent receiver ifTrue:[ |
|
3225 |
selectorOfMessageToNode := parent selector |
|
4238 | 3226 |
] |
3227 |
]. |
|
3228 |
||
3229 |
getDistanceComputeBlockWithWeight := |
|
3230 |
[:weight | |
|
3231 |
[:each | |
|
3232 |
|dist factor| |
|
3233 |
||
3234 |
dist := each spellAgainst:nm. |
|
3235 |
factor := 1. |
|
3236 |
||
3237 |
(each startsWith:nm) ifTrue:[ |
|
3238 |
factor := 6 * nm size. |
|
3239 |
] ifFalse:[ |
|
3240 |
(each asLowercase startsWith:nm asLowercase) ifTrue:[ |
|
3241 |
factor := 4 * nm size. |
|
3242 |
]. |
|
3243 |
]. |
|
3244 |
dist := dist + (weight*factor). |
|
3245 |
||
3246 |
each -> (dist * weight) |
|
3247 |
] |
|
3248 |
]. |
|
3249 |
||
3250 |
addWithFactorBlock := |
|
3251 |
[:names :factor | |namesToAdd| |
|
3252 |
namesToAdd := names select:[:nameToAdd | nameToAdd ~= nm ]. |
|
3253 |
namesToAdd := namesToAdd reject:[:each | allVariables includes:each ]. |
|
3254 |
allVariables addAll:namesToAdd. |
|
3255 |
allDistances addAll:(namesToAdd collect:(getDistanceComputeBlockWithWeight value:factor)). |
|
3256 |
]. |
|
3257 |
||
3258 |
nm isUppercaseFirst ifTrue:[ |
|
3259 |
globalFactor := 2. "/ favour globals |
|
3260 |
localFactor := 1. |
|
3261 |
] ifFalse:[ |
|
3262 |
globalFactor := 1. "/ favour locals |
|
3263 |
localFactor := 2. |
|
3264 |
]. |
|
3265 |
||
3266 |
allVariables := OrderedCollection new. |
|
3267 |
allDistances := OrderedCollection new. |
|
3268 |
||
4308 | 3269 |
"/ are we in the method's selector spec ? |
4277 | 3270 |
((parent := node parent) notNil |
3271 |
and:[parent isMethod |
|
3272 |
and:[parent arguments includes:node]]) ifTrue:[ |
|
4238 | 3273 |
"/ now thats cool: look how the naem of this argument is in other implementations |
3274 |
"/ of this method, and take that as a basis of the selection |
|
3275 |
||
3276 |
implementors := SystemBrowser |
|
4277 | 3277 |
findImplementorsOf:(parent selector) |
4238 | 3278 |
in:(Smalltalk allClasses) |
3279 |
ignoreCase:false. |
|
3280 |
"/ which argument is it |
|
4277 | 3281 |
argIdx := parent arguments indexOf:node. |
4238 | 3282 |
implementors size > 50 ifTrue:[ |
3283 |
implementors := implementors asOrderedCollection copyTo:50. |
|
3284 |
]. |
|
3285 |
namesUsed := implementors |
|
3286 |
collect:[:eachImplementor | |
|
3287 |
|parseTree| |
|
3288 |
parseTree := eachImplementor parseTree. |
|
3289 |
(parseTree notNil and:[parseTree arguments size > 0]) |
|
3290 |
ifFalse:nil |
|
3291 |
ifTrue:[ (parseTree arguments at:argIdx) name] ] |
|
3292 |
thenSelect:[:a | a notNil] as:Set. |
|
3293 |
||
3294 |
addWithFactorBlock value:namesUsed value:(2 * localFactor). |
|
3295 |
||
3296 |
classOrNil notNil ifTrue:[ |
|
3297 |
"/ also, look for the keyword before the argument, |
|
3298 |
"/ and see if there is such an instVar |
|
3299 |
"/ if so, add it with -Arg |
|
4277 | 3300 |
parent selector isKeyword ifTrue:[ |
3301 |
kwPart := parent selector keywords at:argIdx. |
|
4238 | 3302 |
(classOrNil allInstVarNames includes:(kwPart copyButLast:1)) ifTrue:[ |
3303 |
addWithFactorBlock |
|
3304 |
value:(classOrNil allInstVarNames collect:[:nm| nm,'Arg']) |
|
3305 |
value:(1 * localFactor). |
|
3306 |
]. |
|
3307 |
]. |
|
3308 |
] |
|
3309 |
] ifFalse:[ |
|
3310 |
classOrNil notNil ifTrue:[ |
|
3311 |
"/ locals in the block/method |
|
3312 |
names := node allVariablesOnScope. |
|
3313 |
"/ if there were no variables (due to a parse error) |
|
3314 |
"/ do another parse and see what we have |
|
3315 |
names isEmpty ifTrue:[ |
|
3316 |
tree := self treeForCode:(codeView contentsAsString string) allowErrors:true. |
|
3317 |
"/ better if we already have a body (include locals then) |
|
3318 |
"/ otherwise, only the arguments are considered |
|
3319 |
tree notNil ifTrue:[ |
|
3320 |
names := (tree body ? tree) allVariablesOnScope. |
|
3321 |
] |
|
3322 |
]. |
|
3323 |
||
3324 |
addWithFactorBlock value:names value:(4 * localFactor). |
|
3325 |
||
3326 |
"/ instance variables |
|
3327 |
addWithFactorBlock value:classOrNil instVarNames value:(3 * localFactor). |
|
3328 |
||
3329 |
"/ inherited instance variables |
|
3330 |
classOrNil superclass notNil ifTrue:[ |
|
3331 |
addWithFactorBlock value:classOrNil superclass allInstVarNames value:(2.5 * localFactor). |
|
3332 |
]. |
|
3333 |
]. |
|
3334 |
||
3335 |
selectorOfMessageToNode notNil ifTrue:[ |
|
3336 |
|names responders nonResponders| |
|
3337 |
||
3338 |
"/ responding to that messsage |
|
3339 |
||
3340 |
classOrNil notNil ifTrue:[ |
|
3341 |
"/ private classes |
|
3342 |
addWithFactorBlock value:(nonMetaClass privateClasses collect:[:cls | cls nameWithoutPrefix]) |
|
3343 |
value:(1.75 * globalFactor). |
|
3344 |
||
3345 |
"/ class variables |
|
3346 |
names := nonMetaClass classVarNames. |
|
3347 |
responders := names select:[:classVar | (nonMetaClass classVarAt:classVar) respondsTo:selectorOfMessageToNode]. |
|
3348 |
nonResponders := names reject:[:classVar | (nonMetaClass classVarAt:classVar) respondsTo:selectorOfMessageToNode]. |
|
3349 |
||
3350 |
addWithFactorBlock value:responders value:(1.5 * globalFactor). |
|
3351 |
addWithFactorBlock value:nonResponders value:(0.5 * 1.5 * globalFactor). |
|
3352 |
||
3353 |
"/ superclass var names |
|
3354 |
nonMetaClass allSuperclassesDo:[:superClass | |
|
3355 |
names := superClass classVarNames. |
|
3356 |
responders := names select:[:classVar | (superClass classVarAt:classVar) respondsTo:selectorOfMessageToNode]. |
|
3357 |
nonResponders := names reject:[:classVar | (superClass classVarAt:classVar) respondsTo:selectorOfMessageToNode]. |
|
3358 |
||
3359 |
addWithFactorBlock value:responders value:(1 * globalFactor). |
|
3360 |
addWithFactorBlock value:nonResponders value:(0.5 * 1 * globalFactor). |
|
3361 |
]. |
|
3362 |
||
3363 |
"/ namespace vars |
|
3364 |
classOrNil nameSpace ~~ Smalltalk ifTrue:[ |
|
3365 |
names := classOrNil topNameSpace keys. |
|
3366 |
names := names reject:[:nm | nm includes:$:]. |
|
3367 |
names := names select:[:nm | nm isUppercaseFirst ]. |
|
3368 |
responders := names select:[:nsVar | |c| c := classOrNil topNameSpace at:nsVar. c isBehavior not or:[c isLoaded and:[c respondsTo:selectorOfMessageToNode]]]. |
|
3369 |
nonResponders := names reject:[:nsVar | |c| c := classOrNil topNameSpace at:nsVar. c isBehavior not or:[c isLoaded and:[c respondsTo:selectorOfMessageToNode]]]. |
|
3370 |
addWithFactorBlock value:responders value:(1.5 * globalFactor). |
|
3371 |
addWithFactorBlock value:nonResponders value:(0.5 * 1.5 * globalFactor). |
|
3372 |
]. |
|
3373 |
]. |
|
3374 |
||
3375 |
"/ globals |
|
3376 |
names := Smalltalk keys. |
|
3377 |
"/ names := names reject:[:nm | nm includes:$:]. |
|
3378 |
names := names select:[:nm | nm isUppercaseFirst ]. |
|
3379 |
responders := names select:[:glblVar | |c| c := Smalltalk at:glblVar. c isBehavior not or:[c isLoaded and:[c respondsTo:selectorOfMessageToNode]]]. |
|
3380 |
nonResponders := names reject:[:glblVar | |c| c := Smalltalk at:glblVar. c isBehavior not or:[c isLoaded and:[c respondsTo:selectorOfMessageToNode]]]. |
|
3381 |
addWithFactorBlock value:responders value:(1.5 * globalFactor). |
|
3382 |
addWithFactorBlock value:nonResponders value:(0.5 * 1.5 * globalFactor). |
|
3383 |
||
3384 |
"/ pool variables |
|
3385 |
classOrNil theNonMetaclass sharedPoolNames do:[:poolName | |
|
3386 |
|pool names| |
|
3387 |
||
3388 |
pool := Smalltalk at:poolName. |
|
3389 |
names := pool classVarNames. |
|
3390 |
names := names select:[:nm | nm isUppercaseFirst ]. |
|
3391 |
responders := names select:[:glblVar | |c| c := Smalltalk at:glblVar. c isBehavior not or:[c isLoaded and:[c respondsTo:selectorOfMessageToNode]]]. |
|
3392 |
nonResponders := names reject:[:glblVar | |c| c := Smalltalk at:glblVar. c isBehavior not or:[c isLoaded and:[c respondsTo:selectorOfMessageToNode]]]. |
|
3393 |
addWithFactorBlock value:responders value:(2.5 * globalFactor). |
|
3394 |
addWithFactorBlock value:nonResponders value:(0.5 * 2.5 * globalFactor). |
|
3395 |
]. |
|
3396 |
] ifFalse:[ |
|
3397 |
classOrNil notNil ifTrue:[ |
|
3398 |
"/ private classes |
|
3399 |
addWithFactorBlock value:(nonMetaClass privateClasses collect:[:cls | cls nameWithoutPrefix]) |
|
3400 |
value:(1.75 * globalFactor). |
|
3401 |
||
3402 |
"/ class variables |
|
3403 |
addWithFactorBlock value:nonMetaClass classVarNames value:(2.0 * globalFactor). |
|
3404 |
classOrNil superclass notNil ifTrue:[ |
|
3405 |
addWithFactorBlock value:nonMetaClass superclass allClassVarNames value:(2.0 * globalFactor). |
|
3406 |
]. |
|
3407 |
||
3408 |
"/ namespace vars |
|
3409 |
classOrNil nameSpace ~~ Smalltalk ifTrue:[ |
|
3410 |
names := classOrNil nameSpace isNameSpace ifTrue:[classOrNil nameSpace keys] ifFalse:[classOrNil nameSpace privateClasses collect:[:c | c nameWithoutPrefix]]. |
|
3411 |
names := names select:[:nm | nm isUppercaseFirst ]. |
|
3412 |
addWithFactorBlock value:names value:(1.5 * globalFactor). |
|
3413 |
]. |
|
3414 |
||
3415 |
"/ pool variables |
|
3416 |
classOrNil theNonMetaclass sharedPoolNames do:[:poolName | |
|
3417 |
|pool names| |
|
3418 |
||
3419 |
pool := Smalltalk at:poolName. |
|
3420 |
names := pool classVarNames. |
|
3421 |
addWithFactorBlock value:names value:(2.5 * globalFactor). |
|
3422 |
]. |
|
3423 |
]. |
|
3424 |
||
3425 |
"/ globals |
|
3426 |
names := Smalltalk keys. |
|
3427 |
names := names select:[:nm | nm isUppercaseFirst ]. |
|
3428 |
addWithFactorBlock value:names value:(1.5 * globalFactor). |
|
3429 |
]. |
|
3430 |
||
3431 |
"/ pseudos - assuming that thisContext is seldom used. |
|
3432 |
"/ also assuming, that nil is short so its usually typed in. |
|
3433 |
addWithFactorBlock value:#('self') value:(2.5 * localFactor). |
|
3434 |
addWithFactorBlock value:#('nil') value:(0.5 * localFactor). |
|
3435 |
addWithFactorBlock value:#('super' 'false') value:(2 * localFactor). |
|
3436 |
addWithFactorBlock value:#('thisContext') value:(1 * localFactor). |
|
3437 |
]. |
|
3438 |
||
3439 |
allDistances isEmpty ifTrue:[^ self]. |
|
3440 |
bestAssoc := allDistances at:1. |
|
3441 |
bestAssoc := allDistances inject:bestAssoc into:[:el :best | el value > best value |
|
3442 |
ifTrue:[el] |
|
3443 |
ifFalse:[best] |
|
3444 |
]. |
|
3445 |
||
3446 |
allDistances sort:[:a :b | |
|
3447 |
a value > b value ifTrue:[ |
|
3448 |
true |
|
3449 |
] ifFalse:[ |
|
3450 |
a value = b value ifTrue:[ |
|
3451 |
a key < b key |
|
3452 |
] ifFalse:[ |
|
3453 |
false |
|
3454 |
] |
|
3455 |
] |
|
3456 |
]. |
|
3457 |
allTheBest := allDistances select:[:entry | entry value >= (bestAssoc value * 0.5)]. |
|
3458 |
allTheBest size > 15 ifTrue:[ |
|
3459 |
allTheBest := allDistances select:[:entry | entry value >= (bestAssoc value * 0.8)]. |
|
3460 |
]. |
|
3461 |
||
3462 |
best := self askUserForCompletion:'variable' for:codeView at: node start from:(allTheBest collect:[:assoc | assoc key]). |
|
3463 |
best isNil ifTrue:[^ self]. |
|
3464 |
||
3465 |
"/ self showInfo:best. |
|
3466 |
||
3467 |
start := node start. |
|
3468 |
stop := node stop. |
|
3469 |
oldVar := (codeView textFromCharacterPosition:start to:stop) asString string withoutSeparators. |
|
3470 |
||
3471 |
codeView |
|
3472 |
undoableDo:[ codeView replaceFromCharacterPosition:start to:stop with:best ] |
|
3473 |
info:'Completion'. |
|
3474 |
||
3475 |
(best startsWith:oldVar) ifTrue:[ |
|
3476 |
oldLen := stop - start + 1. |
|
3477 |
newLen := best size. |
|
3478 |
codeView selectFromCharacterPosition:start+oldLen to:start+newLen-1. |
|
3479 |
codeView dontReplaceSelectionOnInput |
|
3480 |
]. |
|
3481 |
||
3482 |
"Created: / 10-11-2006 / 13:16:33 / cg" |
|
3483 |
"Modified: / 16-02-2010 / 10:13:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3484 |
"Modified: / 22-08-2012 / 22:07:24 / cg" |
|
4308 | 3485 |
"Modified (comment): / 26-07-2013 / 21:47:08 / cg" |
4238 | 3486 |
! ! |
3487 |
||
3854
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3488 |
!DoWhatIMeanSupport::InputCompletionResult class methodsFor:'instance creation'! |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3489 |
|
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3490 |
bestName:bestNameArg matchingNames:matchingNamesArg |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3491 |
^ self with:bestNameArg with:matchingNamesArg |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3492 |
|
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3493 |
" |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3494 |
self bestName:123 matchingNames:345 |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3495 |
" |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3496 |
! ! |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3497 |
|
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3498 |
!DoWhatIMeanSupport::InputCompletionResult methodsFor:'accessing'! |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3499 |
|
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3500 |
bestName |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3501 |
^ self at:1 |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3502 |
! |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3503 |
|
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3504 |
matchingNames |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3505 |
^ self at:2 |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3506 |
! ! |
d7904ce12bb6
changed: #classnameCompletion:filter:inEnvironment:
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
3507 |
|
2376 | 3508 |
!DoWhatIMeanSupport class methodsFor:'documentation'! |
3509 |
||
4281 | 3510 |
version |
4308 | 3511 |
^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.111 2013-07-26 19:56:21 cg Exp $' |
4281 | 3512 |
! |
3513 |
||
3761
6584390d427d
dont forget pool variables when looking for the best variable match
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
3514 |
version_CVS |
4308 | 3515 |
^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.111 2013-07-26 19:56:21 cg Exp $' |
2376 | 3516 |
! ! |
4194 | 3517 |