author | Claus Gittinger <cg@exept.de> |
Thu, 09 Nov 2017 20:09:30 +0100 | |
changeset 6225 | 0122e4e6c587 |
parent 6223 | 5c12b231db19 |
child 6263 | 8d70af79d06f |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
5053 | 3 |
All Rights Reserved |
0 | 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 |
" |
|
2277 | 12 |
"{ Package: 'stx:libwidg' }" |
13 |
||
5250 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
0 | 16 |
TextCollector subclass:#Workspace |
5002 | 17 |
instanceVariableNames:'doItAction codeStartPosition errorFgColor errorBgColor |
18 |
commentStrings autoDefineWorkspaceVariables simulatedSelf |
|
19 |
autoDefineVariables compilerClass allowValueDrop |
|
20 |
poolsConsideredInDoIts namespaceForDoits editedMethodOrClass |
|
5595 | 21 |
editedLanguage' |
5982 | 22 |
classVariableNames:'DefaultErrorBackgroundColor DefaultErrorForegroundColor |
23 |
DefaultViewBackground DefaultWarningBackgroundColor |
|
24 |
DefaultWarningForegroundColor DoItHistory Sniplets Snippets |
|
25 |
WorkspaceVariables' |
|
5002 | 26 |
poolDictionaries:'' |
27 |
category:'Interface-Smalltalk' |
|
0 | 28 |
! |
29 |
||
4726 | 30 |
Workspace comment:'' |
3155 | 31 |
! |
32 |
||
32 | 33 |
!Workspace class methodsFor:'documentation'! |
34 |
||
38 | 35 |
copyright |
36 |
" |
|
37 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
5053 | 38 |
All Rights Reserved |
38 | 39 |
|
40 |
This software is furnished under a license and may be used |
|
41 |
only in accordance with the terms of that license and with the |
|
42 |
inclusion of the above copyright notice. This software may not |
|
43 |
be provided or otherwise made available to, or used by, any |
|
44 |
other person. No title to or ownership of the software is |
|
45 |
hereby transferred. |
|
46 |
" |
|
47 |
! |
|
48 |
||
32 | 49 |
documentation |
50 |
" |
|
51 |
a view for editable text which can evaluate expressions. |
|
38 | 52 |
I.e. its basically a view for editable text, with added |
53 |
'doIt', 'printIt' and 'inspectIt' functions on the popup-menu. |
|
125 | 54 |
|
38 | 55 |
The action to be performed on doIt is defined by a block, |
58 | 56 |
which can be defined by the owner of this view. |
60 | 57 |
(thus you can put a workspace into more complex widgets, and |
58 |
control what should happen on 'doIt'). |
|
58 | 59 |
|
5053 | 60 |
A useful default action is automatically defined, which simply |
61 |
evaluates the selection as a smalltalk expression. |
|
578 | 62 |
(but, a lisp or prolog workspace would define its own action, |
63 |
to call for another compiler/interpreter ...) |
|
32 | 64 |
|
4922 | 65 |
Special workspace- and doIt variables: |
5915 | 66 |
workspaces can be configured to automatically define undefined variables |
67 |
as either workspace- or doIt variables. When encountering undefined variables, |
|
68 |
the parser asks for an action, which is responded with #workspace or doIt if a |
|
69 |
workspace is the requestor of a doIt. Both are implemented as value holders, and |
|
70 |
the parser will generate code sending value/value: instead of normal assignment. |
|
71 |
Workspace variables are kept in the Workspace class and will both persist between doIts |
|
72 |
and also be visible across workspaces. They are perfect for scripting (and therefore enabled |
|
73 |
by default when stx is started with one of the scripting options). |
|
74 |
DoIt variables are only valid during a single doIt. |
|
75 |
Be aware that when you ask from the outside via workspaceVariableAt:, you'll get a valueHolder. |
|
76 |
This is by purbose, as it allows for easy monitoring and tracing of changes. |
|
5053 | 77 |
|
123 | 78 |
Caveat: |
5915 | 79 |
in this version, Workspace does not yet support doIt in MVC setups. |
80 |
For now, simulate this by setting the doItAction, to notify the |
|
81 |
model manually about the doIt. |
|
123 | 82 |
|
83 |
||
578 | 84 |
[instance variables:] |
32 | 85 |
|
121 | 86 |
doItAction <Block> block to evaluate for doIt |
123 | 87 |
|
5053 | 88 |
errorFgColor <Color> fg-Color to be used when highlighting errors |
121 | 89 |
|
90 |
errorBgColor <Color> bg-Color to be used when highlighting errors |
|
58 | 91 |
|
578 | 92 |
codeStartPosition private temporary |
121 | 93 |
|
578 | 94 |
|
95 |
[styleSheet values:] |
|
121 | 96 |
|
97 |
codeErrorSelectionForegroundColor fg color to highlight errors |
|
5915 | 98 |
(default: selection fg) |
418 | 99 |
|
121 | 100 |
codeErrorSelectionBackgroundColor bg color to highlight errors |
5915 | 101 |
(default: selection bg) |
578 | 102 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
103 |
[start with:] |
5915 | 104 |
Workspace open |
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
105 |
|
578 | 106 |
[see also:] |
5915 | 107 |
Workspace EditTextView |
108 |
Parser ByteCodeCompiler |
|
583 | 109 |
|
110 |
[author:] |
|
5915 | 111 |
Claus Gittinger |
32 | 112 |
" |
201 | 113 |
! ! |
114 |
||
3712 | 115 |
!Workspace class methodsFor:'accessing'! |
116 |
||
117 |
sniplets |
|
5144 | 118 |
<resource: #obsolete> |
119 |
self obsoleteMethodWarning. |
|
120 |
^ self snippets |
|
3713 | 121 |
|
122 |
" |
|
5144 | 123 |
Snippets := nil |
3713 | 124 |
" |
3712 | 125 |
! |
126 |
||
127 |
sniplets:something |
|
5144 | 128 |
<resource: #obsolete> |
129 |
self obsoleteMethodWarning. |
|
130 |
self snippets:something |
|
131 |
! |
|
132 |
||
133 |
snippets |
|
134 |
Snippets isNil ifTrue:[ |
|
135 |
Snippets := Dictionary new. |
|
136 |
self initializeDefaultAbbreviations. |
|
137 |
]. |
|
138 |
^ Snippets |
|
139 |
||
140 |
" |
|
141 |
Snippets := nil |
|
142 |
" |
|
143 |
! |
|
144 |
||
145 |
snippets:aDictionary |
|
146 |
Snippets := aDictionary. |
|
3712 | 147 |
! ! |
148 |
||
201 | 149 |
!Workspace class methodsFor:'defaults'! |
150 |
||
4799
4baf5f98c387
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4784
diff
changeset
|
151 |
defaultCompletionSupportClass |
4baf5f98c387
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4784
diff
changeset
|
152 |
^ WorkspaceCompletionSupport |
4baf5f98c387
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4784
diff
changeset
|
153 |
|
4baf5f98c387
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4784
diff
changeset
|
154 |
"Created: / 26-09-2013 / 17:59:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
155 |
! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
156 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
157 |
defaultLabel |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
158 |
"my default window label" |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
159 |
|
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
160 |
^ 'Workspace' |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
161 |
|
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
162 |
"Created: / 16.5.1998 / 16:53:37 / cg" |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
163 |
! |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
164 |
|
3716 | 165 |
initializeDefaultAbbreviations |
5144 | 166 |
"default snippets/abbreviations. TODO: save/load snippets" |
167 |
||
168 |
"flush and reinitialize snippets with: |
|
169 |
Snippets := Dictionary new. |
|
3741 | 170 |
" |
3807 | 171 |
"after a code change below, update with: |
5144 | 172 |
self initializeDefaultAbbreviations. |
3735 | 173 |
" |
3807 | 174 |
|
175 |
#( |
|
5144 | 176 |
't' 'true' |
177 |
'f' 'false' |
|
178 |
's' 'self' |
|
179 |
'su' 'super' |
|
180 |
'ss' 'super ' |
|
181 |
'n' 'nil' |
|
182 |
'y' 'yourself.' |
|
183 |
||
184 |
'in' 'isNil ' |
|
185 |
'nn' 'notNil ' |
|
186 |
'ie' 'isEmpty ' |
|
187 |
'ne' 'notEmpty ' |
|
188 |
'ien' 'isEmptyOrNil ' |
|
189 |
'nen' 'notEmptyOrNil ' |
|
190 |
||
5690 | 191 |
'[it' '[nil] ifTrue:[!!' |
192 |
'[if' '[nil] ifFalse:[!!' |
|
5144 | 193 |
'it' 'ifTrue:[!!' |
194 |
'if' 'ifFalse:[!!' |
|
195 |
'itf' 'ifTrue:[!!] ifFalse:[].' |
|
196 |
'int' 'isNil ifTrue:[!!].' |
|
197 |
'inf' 'isNil ifFalse:[!!].' |
|
198 |
'ints' 'isNil ifTrue:[^ self].' |
|
199 |
'infs' 'isNil ifFalse:[^ self].' |
|
200 |
'nnt' 'notNil ifTrue:[!!].' |
|
201 |
'nnf' 'notNil ifFalse:[!!].' |
|
202 |
'iet' 'isEmpty ifTrue:[!!].' |
|
203 |
'net' 'notEmpty ifTrue:[!!].' |
|
204 |
'ief' 'isEmpty ifFalse:[!!].' |
|
205 |
'nef' 'notEmpty ifFalse:[!!].' |
|
206 |
||
207 |
'wt' 'whileTrue:[!!]' |
|
208 |
'wf' 'whileFalse:[!!]' |
|
209 |
||
210 |
'do' 'do:[:each |!!]' |
|
211 |
'd:' 'do:[:each |!!]' |
|
212 |
'kdo' 'keysAndValuesDo:[:eachKey :eachValue |!!]' |
|
213 |
'kvd' 'keysAndValuesDo:[:eachKey :eachValue |!!]' |
|
214 |
'kv:' 'keysAndValuesDo:[:eachKey :eachValue |!!]' |
|
215 |
'k:' 'keysDo:[:eachKey | !!]' |
|
216 |
'dt' 'detect:[:each | !!]' |
|
217 |
'de' 'detect:[:each | !!]' |
|
218 |
'det' 'detect:[:each | !!]' |
|
219 |
'dtn' 'detect:[:each | !!] ifNone:[]' |
|
220 |
'cl' 'collect:[:each | !!]' |
|
221 |
'co' 'collect:[:each | !!]' |
|
222 |
'col' 'collect:[:each | !!]' |
|
223 |
'sl' 'select:[:each | !!]' |
|
224 |
'se' 'select:[:each | !!]' |
|
225 |
'sel' 'select:[:each | !!]' |
|
226 |
'rj' 'reject:[:each | !!]' |
|
227 |
're' 'reject:[:each | !!]' |
|
228 |
'rej' 'reject:[:each | !!]' |
|
229 |
'inj' 'inject:!! into:[:accum :each | ]' |
|
230 |
||
231 |
'ex' 'Error handle:[ex | !!] do:[].' |
|
5686 | 232 |
'[ sh' '[ self halt ].' |
5685 | 233 |
'[sh' '[self halt].' |
5144 | 234 |
'sh' 'self halt.' |
235 |
'mt' 'MessageTally spyOn:[!!].' |
|
236 |
||
237 |
'ih' '!! ifTrue:[ self halt ].' |
|
238 |
'ik' 'includesKey: #' |
|
239 |
'is' 'includesString: #' |
|
240 |
||
241 |
'af' 'asFilename ' |
|
242 |
'as' 'asString ' |
|
243 |
'aoc' 'asOrderedCollection ' |
|
244 |
||
245 |
'np' 'nextPut: ' |
|
246 |
'npa' 'nextPutAll: ' |
|
247 |
'npl' 'nextPutLine: ' |
|
248 |
||
249 |
'ps' 'printString' |
|
250 |
'sr' 'self subclassResponsibility.' |
|
251 |
||
252 |
'ati' 'at:!! ifAbsent: ' |
|
253 |
'atip' 'at:!! ifAbsentPut:[ ] ' |
|
254 |
'ap' 'at:!! ' |
|
255 |
||
256 |
'st' 'Smalltalk' |
|
257 |
'ts' 'Transcript showCR:''!!''.' |
|
258 |
'trs' 'Transcript showCR:''!!''.' |
|
259 |
'abb' 'Workspace snippets inspect.' |
|
260 |
'ws' 'Delay waitForSeconds: 1.' |
|
261 |
'wfs' 'Delay waitForSeconds: 1.' |
|
262 |
'wfm' 'Delay waitForMilliseconds: 1000.' |
|
263 |
'ini' 'initialize\ super initialize.\ ' |
|
264 |
'newi' 'new\ ^ super new initialize.' |
|
265 |
'upd' 'update:something with:aParameter from:changedObject\ !!\ ^ super update:something with:aParameter from:changedObject.' |
|
266 |
'OC' 'OrderedCollection' |
|
267 |
'oc' 'OrderedCollection' |
|
268 |
'SC' 'SortedCollection' |
|
269 |
'sc' 'SortedCollection' |
|
270 |
'D' 'Dictionary' |
|
271 |
'ID' 'IdentityDictionary' |
|
272 |
'Id' 'IdentityDictionary' |
|
273 |
'id' 'IdentityDictionary' |
|
274 |
'iD' 'IdentityDictionary' |
|
275 |
'OCn' 'OrderedCollection new.' |
|
276 |
'ocn' 'OrderedCollection new.' |
|
277 |
'SCn' 'SortedCollection new.' |
|
278 |
'IDn' 'IdentityDictionary new' |
|
279 |
'idn' 'IdentityDictionary new' |
|
280 |
'Dn' 'Dictionary new' |
|
281 |
'dn' 'Dictionary new' |
|
282 |
'Sn' 'Set new' |
|
283 |
'sn' 'Set new' |
|
284 |
'A' 'Array' |
|
285 |
'a' 'Array' |
|
286 |
'An' 'Array new:' |
|
287 |
'an' 'Array new:' |
|
288 |
'Aw' 'Array with:' |
|
289 |
'aw' 'Array with:' |
|
290 |
'Aww' 'Array with:!! with:' |
|
291 |
'sww' 'Array with:!! with:' |
|
292 |
'Awww' 'Array with:!! with: with:' |
|
293 |
'awww' 'Array with:!! with: with:' |
|
294 |
'Awwww' 'Array with:!! with: with: with:' |
|
295 |
'awwww' 'Array with:!! with: with: with:' |
|
296 |
'aw2' 'Array with:!! with:' |
|
297 |
'aw3' 'Array with:!! with: with:' |
|
298 |
'aw4' 'Array with:!! with: with: with:' |
|
299 |
'0' '(0.0 @ 0.0)' |
|
300 |
'1' '(1.0 @ 1.0)' |
|
301 |
'[' '[:!! ]' |
|
302 |
'(' '(!! )' |
|
303 |
||
304 |
"/ typos... |
|
305 |
'eslf' 'self' |
|
306 |
'slef' 'self' |
|
307 |
'sefl' 'self' |
|
308 |
'elf' 'self' |
|
309 |
'slf' 'self' |
|
310 |
'sef' 'self' |
|
311 |
||
312 |
'iftrue' 'ifTrue' |
|
313 |
'iffalse' 'ifFalse' |
|
314 |
'iftrue:' 'ifTrue:' |
|
315 |
'iffalse:' 'ifFalse:' |
|
3807 | 316 |
) pairWiseDo:[:abbrev :text | |
5144 | 317 |
Snippets |
318 |
at:abbrev put:text "/ ifPresent:[ self error:'duplicate abbreviation key' ] |
|
3807 | 319 |
]. |
4148
2fe252a82d5b
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4141
diff
changeset
|
320 |
|
5690 | 321 |
"Modified: / 30-04-2016 / 19:43:35 / cg" |
3716 | 322 |
! |
323 |
||
201 | 324 |
updateStyleCache |
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
325 |
"extract values from the styleSheet and cache them in class variables" |
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
326 |
|
1354 | 327 |
<resource: #style (#'codeErrorSelection.foregroundColor' |
5053 | 328 |
#'codeErrorSelection.backgroundColor' |
329 |
#'codeView.backgroundColor' )> |
|
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
330 |
|
1354 | 331 |
DefaultErrorForegroundColor := StyleSheet colorAt:'codeErrorSelection.foregroundColor'. |
332 |
DefaultErrorBackgroundColor := StyleSheet colorAt:'codeErrorSelection.backgroundColor'. |
|
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
333 |
DefaultViewBackground := StyleSheet colorAt:'codeView.backgroundColor'. |
32 | 334 |
! ! |
335 |
||
2776 | 336 |
!Workspace class methodsFor:'getting a new Workspace'! |
0 | 337 |
|
32 | 338 |
open |
0 | 339 |
"launch a new workspace" |
340 |
||
418 | 341 |
|scr topView workspace f| |
0 | 342 |
|
5053 | 343 |
topView := StandardSystemView |
344 |
label:(self classResources string:(self defaultLabel)) |
|
345 |
" minExtent:(100 @ 100)". |
|
23 | 346 |
|
418 | 347 |
scr := HVScrollableView for:self in:topView. |
348 |
scr origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
349 |
workspace := scr scrolledView. |
|
0 | 350 |
|
418 | 351 |
"/ adjust topViews extent according to my font |
352 |
||
0 | 353 |
f := workspace font. |
354 |
topView extent:((f widthOf:'x') * 40) @ (f height * 10). |
|
7 | 355 |
topView open. |
131 | 356 |
^ workspace |
0 | 357 |
|
58 | 358 |
" |
359 |
Workspace open |
|
360 |
" |
|
418 | 361 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
362 |
"Modified: / 16.5.1998 / 16:53:53 / cg" |
857 | 363 |
! |
364 |
||
365 |
openForRemote:hostName |
|
366 |
"launch a new workspace to evaluate expression on some remote machine. |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
367 |
Entered expressions are sent over to some partner machine, evaluated there, |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
368 |
and the result is shown here. |
857 | 369 |
This requires the RemoteObjects package to be loaded." |
370 |
||
371 |
|server remoteCompiler workspace| |
|
372 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
373 |
RemoteObjectServer isNil ifTrue:[ |
5053 | 374 |
self warn:'no remoteObjectServer available'. |
375 |
^ nil |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
376 |
]. |
857 | 377 |
|
378 |
server := RemoteObjectServer on:hostName. |
|
379 |
remoteCompiler := server get:#Compiler. |
|
380 |
||
381 |
workspace := self open. |
|
5053 | 382 |
workspace topView |
383 |
label:(self classResources string:'Remote Workspace {%1}' with:hostName). |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
384 |
|
857 | 385 |
workspace doItAction: |
5053 | 386 |
[:theCode | |
387 |
remoteCompiler |
|
388 |
evaluate:theCode |
|
389 |
in:nil |
|
390 |
receiver:nil |
|
391 |
notifying:workspace |
|
392 |
logged:true |
|
393 |
ifFail:nil |
|
394 |
] |
|
857 | 395 |
" |
396 |
Workspace openForRemote:'andi' |
|
397 |
" |
|
398 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
399 |
"Modified: / 16.5.1998 / 16:57:38 / cg" |
2686 | 400 |
! |
401 |
||
2794 | 402 |
openWith:initialText selected:selectedBoolean |
2686 | 403 |
"launch a new workspace with some initial contents" |
404 |
||
405 |
|workspace| |
|
406 |
||
407 |
workspace := self open. |
|
2794 | 408 |
workspace contents:initialText selected:selectedBoolean. |
2686 | 409 |
^ workspace |
410 |
||
411 |
" |
|
412 |
Workspace openWith:'Transcript showCR:''hello world''' |
|
413 |
" |
|
0 | 414 |
! ! |
415 |
||
2657 | 416 |
!Workspace class methodsFor:'history'! |
417 |
||
418 |
clearDoItHistory |
|
419 |
DoItHistory := nil |
|
420 |
! |
|
421 |
||
422 |
doItHistory |
|
423 |
^ DoItHistory |
|
424 |
! |
|
425 |
||
426 |
doItHistorySize |
|
427 |
"the number of remembered doIts" |
|
428 |
||
429 |
^ 20 |
|
430 |
! |
|
431 |
||
432 |
rememberDoIt:aString |
|
433 |
|string| |
|
434 |
||
435 |
string := aString asString string withoutSeparators. |
|
2726 | 436 |
(string asCollectionOfWords size <= 1) ifTrue:[ |
5053 | 437 |
Error handle:[:ex | |
438 |
"/ unparsable |
|
439 |
^ self |
|
440 |
] do:[ |
|
441 |
((Scanner new scanTokens:string) size <= 1) ifTrue:[ |
|
442 |
"it's a variable only" |
|
443 |
^ self |
|
444 |
] |
|
445 |
] |
|
2726 | 446 |
]. |
2657 | 447 |
|
448 |
DoItHistory isNil ifTrue:[ |
|
5053 | 449 |
DoItHistory := OrderedCollection new. |
2657 | 450 |
]. |
451 |
DoItHistory remove:string ifAbsent:nil. |
|
452 |
DoItHistory addFirst:string. |
|
453 |
DoItHistory size > self doItHistorySize ifTrue:[ |
|
5053 | 454 |
DoItHistory removeLast |
2657 | 455 |
]. |
456 |
! ! |
|
457 |
||
1523
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
458 |
!Workspace class methodsFor:'queries'! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
459 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
460 |
isVisualStartable |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
461 |
"returns whether this application class can be started via #open |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
462 |
(i.e. via a double click on the class in the browser)" |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
463 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
464 |
^ self == Workspace |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
465 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
466 |
"Created: / 16.5.1998 / 16:59:00 / cg" |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
467 |
"Modified: / 16.5.1998 / 16:59:39 / cg" |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
468 |
! ! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
469 |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
470 |
!Workspace class methodsFor:'workspace variables'! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
471 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
472 |
addWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
473 |
"create a new workspace variable" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
474 |
|
1933 | 475 |
|holder| |
476 |
||
3325 | 477 |
holder := self workspaceVariables at:name ifAbsentPut:[ ValueHolder new ]. |
1933 | 478 |
^ holder |
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
479 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
480 |
|
3157 | 481 |
anyWorkspaceVariableIsDefined |
482 |
^ WorkspaceVariables notEmptyOrNil |
|
483 |
||
484 |
"Created: / 20-04-2005 / 11:57:53 / cg" |
|
485 |
! |
|
486 |
||
5945 | 487 |
rememberResultAsWorkspaceVariable:lastResult |
488 |
"remember some last result as _0, |
|
489 |
and shift the previous results (i.e. _0 -> _1 -> .. _9)" |
|
490 |
||
491 |
|workspaceVariables| |
|
492 |
||
493 |
workspaceVariables := self workspaceVariables. |
|
494 |
||
495 |
9 to:1 by:-1 do:[:h| |
|
496 |
(workspaceVariables includesKey:('_%1' bindWith:h-1)) ifTrue:[ |
|
5961 | 497 |
self workspaceVariableAt:('_%1' bindWith:h) |
498 |
put:(self workspaceVariableAt:('_%1' bindWith:h-1)). |
|
5945 | 499 |
]. |
500 |
]. |
|
5961 | 501 |
self workspaceVariableAt:'_0' put:lastResult. |
502 |
||
503 |
"Modified: / 08-11-2016 / 22:39:41 / cg" |
|
5945 | 504 |
! |
505 |
||
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
506 |
removeAllWorkspaceVariables |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
507 |
"delete all workspace variables" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
508 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
509 |
WorkspaceVariables := nil |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
510 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
511 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
512 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
513 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
514 |
removeWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
515 |
"delete a workspace variable" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
516 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
517 |
WorkspaceVariables notNil ifTrue:[ |
5053 | 518 |
WorkspaceVariables removeKey:name ifAbsent:nil. |
519 |
WorkspaceVariables := WorkspaceVariables asNilIfEmpty. |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
520 |
]. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
521 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
522 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
523 |
workspaceVariableAt:name |
4924 | 524 |
"retrieve a workspace variable's value" |
525 |
||
526 |
^ (self workspaceVariableHolderAt:name) value |
|
527 |
||
528 |
" |
|
529 |
Workspace workspaceVariableAt:'foo' put:1234. |
|
5053 | 530 |
Workspace workspaceVariableAt:'foo' |
4924 | 531 |
" |
532 |
! |
|
533 |
||
534 |
workspaceVariableAt:name put:aValue |
|
535 |
"set or define a workspace variable" |
|
536 |
||
537 |
(self workspaceVariables at:name ifAbsentPut:[ ValueHolder new]) value:aValue |
|
538 |
! |
|
539 |
||
540 |
workspaceVariableHolderAt:name |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
541 |
"retrieve a workspace variable (actually, a holder onto it)" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
542 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
543 |
WorkspaceVariables isNil ifTrue:[^ nil]. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
544 |
^ WorkspaceVariables at:name ifAbsent:nil. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
545 |
|
4924 | 546 |
" |
547 |
Workspace workspaceVariableAt:'foo' put:1234. |
|
548 |
Workspace workspaceVariableAt:'foo' put:1234. |
|
549 |
" |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
550 |
! |
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
551 |
|
3157 | 552 |
workspaceVariableNames |
4923 | 553 |
"retrieve the collection of workspace variable names only" |
3157 | 554 |
|
555 |
WorkspaceVariables isNil ifTrue:[^ #()]. |
|
556 |
^ WorkspaceVariables keys |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
557 |
|
3157 | 558 |
"Created: / 20-04-2005 / 11:42:45 / cg" |
559 |
! |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
560 |
|
3157 | 561 |
workspaceVariables |
4924 | 562 |
"retrieve the collection of workspace variable holders. |
3157 | 563 |
That is a dictionary associating names to values." |
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
564 |
|
3325 | 565 |
WorkspaceVariables isNil ifTrue:[ |
5053 | 566 |
WorkspaceVariables := Dictionary new. |
3325 | 567 |
]. |
568 |
^ WorkspaceVariables |
|
3157 | 569 |
|
570 |
"Modified: / 20-04-2005 / 11:43:14 / cg" |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
571 |
! ! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
572 |
|
201 | 573 |
!Workspace methodsFor:'accessing'! |
0 | 574 |
|
3428 | 575 |
allowValueDrop:aBoolean |
576 |
"if on (the default), any smalltalk value can be dropped and leads to a workspace variable |
|
5595 | 577 |
holding on to that being defined. Can be turned off, if you don't like this (for standAlone apps)" |
3428 | 578 |
|
579 |
allowValueDrop := aBoolean. |
|
580 |
||
581 |
"Created: / 28-11-2006 / 16:13:02 / cg" |
|
582 |
! |
|
583 |
||
2679 | 584 |
autoDefineVariables |
4090 | 585 |
"undefined variables handling: |
5053 | 586 |
are automatically defined as workspace variable if autoDefineVariables is #workspace. |
587 |
are automatically defined as doit variable if autoDefineVariables is #doit. |
|
588 |
are left undefined if autoDefineVariables is nil." |
|
4090 | 589 |
|
5053 | 590 |
^ autoDefineVariables |
2535 | 591 |
! |
592 |
||
2679 | 593 |
autoDefineVariables:nilOrSymbol |
3429
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
594 |
"undefined variables handling: |
5053 | 595 |
are automatically defined as workspace variable if nilOrSymbol is #workspace. |
596 |
are automatically defined as doit variable if nilOrSymbol is #doit. |
|
597 |
are left undefined if nilOrSymbol is nil." |
|
3429
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
598 |
|
2679 | 599 |
autoDefineVariables := nilOrSymbol. |
3429
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
600 |
|
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
601 |
"Modified: / 28-11-2006 / 16:21:01 / cg" |
2679 | 602 |
! |
2535 | 603 |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
604 |
commentStrings:anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
605 |
"define the comment strings" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
606 |
|
4876 | 607 |
"/ The argument must be of the form: |
608 |
"/ #( |
|
609 |
"/ '"/' |
|
610 |
"/ ('"' '"') |
|
611 |
"/ ) |
|
5053 | 612 |
"/ where simple string elements define the EOL comment sequence, |
6170 | 613 |
"/ and pairs define regular comment opening/closing sequences. |
4876 | 614 |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
615 |
commentStrings := anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
616 |
|
6170 | 617 |
"Created: / 09-11-1997 / 01:05:25 / cg" |
618 |
"Modified (comment): / 15-06-2017 / 01:44:15 / mawalch" |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
619 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
620 |
|
201 | 621 |
doItAction |
622 |
"return the action to be performed when 'doIt' is selected" |
|
32 | 623 |
|
201 | 624 |
^ doItAction |
0 | 625 |
! |
626 |
||
4584 | 627 |
doItAction:aOneArgBlock |
628 |
"define the action to be performed when 'doIt' is selected. |
|
5053 | 629 |
The block will be evaluated, passing the selection as a String argument. |
4584 | 630 |
A default doItAction is set for you in the initialize method." |
631 |
||
632 |
doItAction := aOneArgBlock |
|
633 |
||
634 |
"Modified: 27.2.1996 / 15:31:37 / cg" |
|
635 |
! |
|
636 |
||
4675 | 637 |
editedClass |
638 |
"for the code completion" |
|
639 |
||
640 |
editedMethodOrClass isNil ifTrue:[^ nil]. |
|
5621 | 641 |
^ editedMethodOrClass isBehavior |
642 |
ifTrue:[editedMethodOrClass] |
|
643 |
ifFalse:[editedMethodOrClass mclass] |
|
4675 | 644 |
! |
645 |
||
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
646 |
editedLanguage |
6148 | 647 |
"get the programming language (for comments, indentation etc.)" |
648 |
||
5595 | 649 |
|mthd cls| |
650 |
||
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
651 |
editedLanguage notNil ifTrue:[ |
5595 | 652 |
^ editedLanguage |
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
653 |
]. |
5595 | 654 |
(mthd := self editedMethod )notNil ifTrue:[ |
655 |
^ mthd programmingLanguage. |
|
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
656 |
]. |
5595 | 657 |
(cls := self editedClass) notNil ifTrue:[ |
658 |
^ cls programmingLanguage. |
|
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
659 |
]. |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
660 |
^ nil |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
661 |
|
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
662 |
"Modified: / 18-09-2013 / 12:58:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6148 | 663 |
"Modified (comment): / 25-04-2017 / 12:53:40 / cg" |
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
664 |
! |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
665 |
|
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
666 |
editedLanguage:aProgrammingLanguageOrNil |
6148 | 667 |
"set the programming language (for comments, indentation etc.)" |
668 |
||
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
669 |
editedLanguage := aProgrammingLanguageOrNil. |
5024 | 670 |
aProgrammingLanguageOrNil notNil ifTrue:[ |
6148 | 671 |
commentStrings := aProgrammingLanguageOrNil commentStrings. |
5024 | 672 |
]. |
6148 | 673 |
|
674 |
"Modified (comment): / 25-04-2017 / 12:53:33 / cg" |
|
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
675 |
! |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
676 |
|
4675 | 677 |
editedMethod |
678 |
"for the code completion" |
|
679 |
||
680 |
editedMethodOrClass isNil ifTrue:[^ nil]. |
|
5621 | 681 |
^ editedMethodOrClass isBehavior |
682 |
ifTrue:[nil] |
|
683 |
ifFalse:[editedMethodOrClass] |
|
4675 | 684 |
! |
685 |
||
4606 | 686 |
editedMethodOrClass |
687 |
"for the code completion" |
|
688 |
||
689 |
^ editedMethodOrClass. |
|
690 |
! |
|
691 |
||
692 |
editedMethodOrClass:aMethodOrClass |
|
6129 | 693 |
"Sets the edited method or class (for code completion)" |
4606 | 694 |
|
695 |
editedMethodOrClass := aMethodOrClass. |
|
6129 | 696 |
|
697 |
"Modified (comment): / 09-03-2017 / 10:41:05 / cg" |
|
4606 | 698 |
! |
699 |
||
3007 | 700 |
errorBackgroundColor |
701 |
errorBgColor notNil ifTrue:[ ^ errorBgColor ]. |
|
702 |
DefaultErrorBackgroundColor notNil ifTrue:[ ^ DefaultErrorBackgroundColor ]. |
|
5621 | 703 |
device hasColors ifTrue:[ ^ Color red ]. |
3007 | 704 |
|
705 |
^ selectionBgColor |
|
706 |
! |
|
707 |
||
708 |
errorForegroundColor |
|
709 |
errorFgColor notNil ifTrue:[ ^ errorFgColor ]. |
|
710 |
DefaultErrorForegroundColor notNil ifTrue:[ ^ DefaultErrorForegroundColor ]. |
|
711 |
^ selectionFgColor |
|
712 |
! |
|
713 |
||
4815 | 714 |
nameSpaceForDoits |
715 |
"can be used by the embedding application to control doIt execution |
|
716 |
(especially: for tools like expecco, to provide better workspaces" |
|
717 |
||
718 |
^ namespaceForDoits ? Smalltalk |
|
719 |
! |
|
720 |
||
4436 | 721 |
nameSpaceForDoits:aNameSpaceOrNil |
722 |
"can be used by the embedding application to control doIt execution |
|
723 |
(especially: for tools like expecco, to provide better workspaces" |
|
724 |
||
725 |
namespaceForDoits := aNameSpaceOrNil. |
|
726 |
||
727 |
"Created: / 26-07-2012 / 23:06:04 / cg" |
|
728 |
! |
|
729 |
||
4391 | 730 |
namespaceForDoits:aNameSpaceOrNil |
731 |
"can be used by the embedding application to control doIt execution |
|
732 |
(especially: for tools like expecco, to provide better workspaces" |
|
733 |
||
4436 | 734 |
<resource: #obsolete> |
735 |
||
4391 | 736 |
namespaceForDoits := aNameSpaceOrNil. |
737 |
||
738 |
"Created: / 04-03-2012 / 13:34:51 / cg" |
|
739 |
! |
|
740 |
||
741 |
poolsConsideredInDoIts:aCollectionOfPools |
|
742 |
"can be used by the embedding application to control doIt execution |
|
743 |
(especially: for tools like expecco, to provide better workspaces" |
|
744 |
||
745 |
poolsConsideredInDoIts := aCollectionOfPools. |
|
746 |
||
747 |
"Modified (format): / 04-03-2012 / 13:35:00 / cg" |
|
3537 | 748 |
! |
749 |
||
6129 | 750 |
simulatedSelf |
751 |
"the 'self' instance used in an evaluation (also used in code completion of self messages)" |
|
752 |
||
753 |
^ simulatedSelf |
|
754 |
||
755 |
"Created: / 09-03-2017 / 10:48:27 / cg" |
|
756 |
! |
|
757 |
||
2601 | 758 |
simulatedSelf:anObject |
6129 | 759 |
"define what self is in an evaluation (also useful in code completion of self messages)" |
2601 | 760 |
|
761 |
simulatedSelf := anObject |
|
6129 | 762 |
|
763 |
"Modified (comment): / 09-03-2017 / 10:48:32 / cg" |
|
3007 | 764 |
! |
765 |
||
766 |
warningBackgroundColor |
|
767 |
DefaultWarningBackgroundColor notNil ifTrue:[ ^ DefaultWarningBackgroundColor ]. |
|
5621 | 768 |
device hasColors ifTrue:[ ^ Color orange ]. |
3007 | 769 |
|
770 |
^ selectionBgColor |
|
771 |
! |
|
772 |
||
773 |
warningForegroundColor |
|
774 |
DefaultWarningForegroundColor notNil ifTrue:[ ^ DefaultWarningForegroundColor ]. |
|
775 |
^ selectionFgColor |
|
201 | 776 |
! ! |
777 |
||
778 |
!Workspace methodsFor:'compiler interface'! |
|
779 |
||
2303 | 780 |
compilerClass |
4432
2eaf85d92e62
corrected switching languages between tabs
Claus Gittinger <cg@exept.de>
parents:
4427
diff
changeset
|
781 |
^ compilerClass "? Compiler" |
2eaf85d92e62
corrected switching languages between tabs
Claus Gittinger <cg@exept.de>
parents:
4427
diff
changeset
|
782 |
|
2eaf85d92e62
corrected switching languages between tabs
Claus Gittinger <cg@exept.de>
parents:
4427
diff
changeset
|
783 |
"Modified: / 19-07-2012 / 17:04:35 / cg" |
2980 | 784 |
! |
785 |
||
786 |
compilerClass:aCompilerClass |
|
787 |
compilerClass := aCompilerClass |
|
2303 | 788 |
! |
789 |
||
201 | 790 |
currentSourceCode |
791 |
"special interface to compiler - called by parser |
|
792 |
to get the updated source code after a corrected error" |
|
793 |
||
794 |
^ self contents |
|
0 | 795 |
! |
796 |
||
201 | 797 |
wantChangeLog |
798 |
"sent by the compiler to ask if a changeLog entry should |
|
799 |
be written. Return true here." |
|
0 | 800 |
|
201 | 801 |
^ true |
0 | 802 |
! ! |
803 |
||
2754 | 804 |
!Workspace methodsFor:'compiler interface-error handling'! |
0 | 805 |
|
201 | 806 |
correctableError:aString position:relPos to:relEndPos from:aCompiler |
807 |
"compiler notifies us of a correctable error; |
|
808 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
809 |
this method should return true to the compiler if user wants the error |
|
810 |
to be corrected; false otherwise" |
|
811 |
||
5680 | 812 |
|action sameForAllHolder possibleFixes |
813 |
doNotShowAgainHolder doNotShowAgainForThisMethodHolder doNotShowAgainForThisReceiverSelectorHolder| |
|
4675 | 814 |
|
815 |
"/ the declare/correct fixes are here for backward compatibility |
|
816 |
"/ (in previous versions, these two were always offered as fix, |
|
817 |
"/ and compilers which honor the old interface will not anwer the PossibleCorrectionsQuery) |
|
818 |
possibleFixes := Parser possibleCorrectionsQuery query. |
|
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
819 |
|
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
820 |
sameForAllHolder := false asValue. |
201 | 821 |
|
822 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
5290 | 823 |
doNotShowAgainHolder := false asValue. |
824 |
doNotShowAgainForThisMethodHolder := false asValue. |
|
5680 | 825 |
doNotShowAgainForThisReceiverSelectorHolder := false asValue. |
5290 | 826 |
|
827 |
Dialog modifyingBoxWith:[:box | |
|
828 |
|declareButton makeSpaceOnlyOnce| |
|
829 |
||
830 |
(box isKindOf:OptionBox) ifTrue:[ |
|
831 |
"/ a bad hack for subDialogs... needs fix |
|
832 |
makeSpaceOnlyOnce := [ box addVerticalSpace:10. makeSpaceOnlyOnce := nil ]. |
|
833 |
||
834 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
|
835 |
makeSpaceOnlyOnce value. |
|
836 |
box verticalPanel |
|
837 |
add:(CheckBox |
|
838 |
label: "addCheckBoxAtBottom:" 'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
839 |
model:doNotShowAgainHolder). |
|
840 |
]. |
|
5680 | 841 |
DoNotShowCompilerWarningAgainForThisReceiverSelectorActionQuery isHandled ifTrue:[ |
842 |
makeSpaceOnlyOnce value. |
|
843 |
box verticalPanel |
|
844 |
add:(CheckBox |
|
845 |
label:(resources string:'Do not warn for this receiver>>selector combination (reenable earlier via Launcher''s settings dialog)') |
|
846 |
model:doNotShowAgainForThisReceiverSelectorHolder). |
|
847 |
]. |
|
5290 | 848 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
849 |
makeSpaceOnlyOnce value. |
|
850 |
box verticalPanel |
|
851 |
add:(CheckBox |
|
852 |
label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
|
853 |
model:doNotShowAgainForThisMethodHolder). |
|
854 |
]. |
|
855 |
SameForAllNotification isHandled ifTrue:[ |
|
856 |
box addVerticalSpace:10. |
|
857 |
box addCheckBoxAtBottom:'Same action for all' on:sameForAllHolder |
|
858 |
]. |
|
859 |
||
860 |
declareButton := box buttons at:2. |
|
861 |
declareButton pressAction:declareButton controller releaseAction. |
|
862 |
declareButton controller beTriggerOnDown. |
|
863 |
] |
|
864 |
] do:[ |
|
865 |
|buttonLabels actions| |
|
866 |
||
867 |
buttonLabels := OrderedCollection new. |
|
868 |
actions := OrderedCollection new. |
|
869 |
buttonLabels add:'Cancel'. actions add:#abort. |
|
870 |
possibleFixes do:[:each | |
|
871 |
buttonLabels add:(each buttonLabel). actions add:each. |
|
872 |
]. |
|
873 |
buttonLabels add:'Continue'. actions add:#continue. |
|
874 |
||
875 |
action := OptionBox |
|
876 |
request:aString |
|
877 |
label:(resources string:'Correctable Error') |
|
878 |
image:(WarningBox iconBitmap) |
|
879 |
buttonLabels:(resources array:buttonLabels) |
|
880 |
values:actions |
|
881 |
default:#continue |
|
882 |
onCancel:#abort. |
|
883 |
]. |
|
201 | 884 |
]. |
885 |
||
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
886 |
sameForAllHolder value ifTrue:[ |
5290 | 887 |
SameForAllNotification notify |
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
888 |
]. |
4691 | 889 |
doNotShowAgainHolder value == true ifTrue:[ |
5290 | 890 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
4691 | 891 |
]. |
892 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
|
5290 | 893 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
4691 | 894 |
]. |
5680 | 895 |
doNotShowAgainForThisReceiverSelectorHolder value == true ifTrue:[ |
896 |
DoNotShowCompilerWarningAgainForThisReceiverSelectorActionQuery actionQuery value |
|
897 |
]. |
|
4691 | 898 |
|
4675 | 899 |
action == #cancel ifTrue:[ |
5290 | 900 |
^ false |
4675 | 901 |
]. |
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
902 |
|
201 | 903 |
action == #abort ifTrue:[ |
5290 | 904 |
AbortOperationRequest raise. |
905 |
^ false |
|
201 | 906 |
]. |
4675 | 907 |
^ action |
368 | 908 |
|
4386 | 909 |
"Modified: / 28-02-2012 / 10:42:27 / cg" |
201 | 910 |
! |
911 |
||
2104 | 912 |
correctableSelectorWarning:aString position:relPos to:relEndPos from:aCompiler |
913 |
"compiler notifies us of a correctable selector warning; |
|
914 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
915 |
this method should return true to the compiler if user wants the error |
|
916 |
to be corrected; false otherwise" |
|
917 |
||
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
918 |
|action doNotShowAgainHolder| |
2104 | 919 |
|
3261 | 920 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
5053 | 921 |
doNotShowAgainHolder := false asValue. |
922 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
|
923 |
MessageNotUnderstood catch:[ |
|
924 |
(aCompiler notNil and:[DoNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
|
925 |
ex box addCheckBoxAtBottom:'Do not show this dialog again (reenable via Launchers Settings Dialog)' on:doNotShowAgainHolder. |
|
926 |
]. |
|
927 |
]. |
|
928 |
] do:[ |
|
929 |
action := OptionBox |
|
930 |
request:aString |
|
931 |
label:(resources string:'Warning') |
|
932 |
image:(WarningBox iconBitmap) |
|
933 |
buttonLabels:(resources array:#('Cancel' 'Correct...' 'Generate' 'Continue')) |
|
934 |
values:#(#abort #correct #generate #continue) |
|
935 |
default:#continue |
|
936 |
onCancel:#abort. |
|
937 |
]. |
|
938 |
doNotShowAgainHolder value == true ifTrue:[ |
|
939 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
|
940 |
]. |
|
2104 | 941 |
]. |
942 |
||
2338 | 943 |
action == #generate ifTrue:[ |
5053 | 944 |
^ action |
2338 | 945 |
]. |
946 |
||
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
947 |
(action isNil or:[action == #abort]) ifTrue:[ |
5053 | 948 |
AbortOperationRequest raise. |
949 |
^ false |
|
2104 | 950 |
]. |
951 |
^ action == #correct |
|
952 |
||
4386 | 953 |
"Created: / 19-01-2000 / 16:27:28 / cg" |
954 |
"Modified: / 28-02-2012 / 10:42:37 / cg" |
|
2104 | 955 |
! |
956 |
||
4188
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
957 |
correctableWarning:aString position:relPos to:relEndPos from:aCompiler |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
958 |
"compiler notifies us of a correctable warning; |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
959 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
960 |
this method should return true to the compiler if user wants the error |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
961 |
to be corrected; false otherwise" |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
962 |
|
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
963 |
^ self correctableError:aString position:relPos to:relEndPos from:aCompiler |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
964 |
|
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
965 |
"Created: / 02-11-2010 / 13:29:01 / cg" |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
966 |
! |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
967 |
|
201 | 968 |
error:aString position:relPos to:relEndPos asWarning:asWarning |
2277 | 969 |
"obsolete - no longer invoked" |
970 |
||
971 |
^ self error:aString position:relPos to:relEndPos from:nil asWarning:asWarning |
|
972 |
! |
|
973 |
||
974 |
error:aString position:relPos to:relEndPos from:aCompiler |
|
5053 | 975 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
976 |
and show a Box asking for continue/abort. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
977 |
Return true for correction, false of not (or not possible)" |
2277 | 978 |
|
979 |
^ self error:aString position:relPos to:relEndPos from:aCompiler asWarning:false |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
980 |
|
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
981 |
"Modified (Comment): / 30-06-2011 / 19:47:36 / cg" |
2277 | 982 |
! |
983 |
||
984 |
error:aString position:relPos to:relEndPos from:aCompiler asWarning:asWarning |
|
3397 | 985 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
201 | 986 |
and show a Box asking for continue/abort." |
987 |
||
3007 | 988 |
|answer fg bg| |
201 | 989 |
|
3007 | 990 |
fg := asWarning ifTrue:[ self warningForegroundColor ] ifFalse:[ self errorForegroundColor ]. |
991 |
bg := asWarning ifTrue:[ self warningBackgroundColor ] ifFalse:[ self errorBackgroundColor ]. |
|
201 | 992 |
|
3397 | 993 |
self |
5290 | 994 |
highlightingErrorPosition:relPos to:relEndPos |
995 |
withForeground:fg andBackground:bg |
|
996 |
do:[ |
|
997 |
|box lbl doNotShowAgainHolder doNotShowAgainForThisMethodHolder l1 y1 y2 l2| |
|
201 | 998 |
|
4170
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
999 |
"/ Warning isHandled ifTrue:[ |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
1000 |
"/ Warning raiseErrorString:aString. |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
1001 |
"/ ^ false |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
1002 |
"/ ]. |
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1003 |
|
5290 | 1004 |
lbl := aCompiler isNil ifTrue:['Compiler'] ifFalse:[aCompiler class name]. |
1005 |
asWarning ifTrue:[ |
|
1006 |
lbl := lbl , ' Warning' |
|
1007 |
] ifFalse:[ |
|
1008 |
lbl := lbl , ' Error'. |
|
1009 |
]. |
|
1010 |
||
1011 |
" |
|
1012 |
ask if we should abort or continue |
|
1013 |
" |
|
1014 |
Dialog modifyingBoxWith:[:box | |
|
1015 |
|makeSpace| |
|
1016 |
||
1017 |
doNotShowAgainHolder := false asValue. |
|
1018 |
doNotShowAgainForThisMethodHolder := false asValue. |
|
1019 |
||
1020 |
box label:lbl. |
|
1021 |
box perform:#image: with:(WarningBox iconBitmap) ifNotUnderstood:[]. |
|
1022 |
||
1023 |
aCompiler notNil ifTrue:[ |
|
1024 |
makeSpace := [ box addVerticalSpace:10. makeSpace := nil ]. |
|
1025 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
|
1026 |
makeSpace value. |
|
1027 |
box verticalPanel |
|
1028 |
add:(CheckBox label:'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
1029 |
model:doNotShowAgainHolder). |
|
1030 |
]. |
|
1031 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
|
1032 |
makeSpace value. |
|
1033 |
box verticalPanel |
|
1034 |
add:(CheckBox label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
|
1035 |
model:doNotShowAgainForThisMethodHolder). |
|
1036 |
]. |
|
1037 |
]. |
|
1038 |
] do:[ |
|
1039 |
answer := OptionBox |
|
1040 |
request:aString |
|
1041 |
buttonLabels:(resources array:#('Abort' "'Keep Selected'" 'Continue')) |
|
1042 |
values:#(false "#keepSelected" true) |
|
1043 |
default:(asWarning ifTrue:true ifFalse:false). |
|
1044 |
answer := answer ? false. "/ if escaped |
|
1045 |
]. |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1046 |
"/ box := YesNoBox |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1047 |
"/ title:aString |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1048 |
"/ yesText:(resources string:'Continue') |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1049 |
"/ noText:(resources string:'Abort'). |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1050 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1051 |
"/ box label:lbl. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1052 |
"/ box image:(WarningBox iconBitmap). |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1053 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1054 |
"/ (aCompiler notNil and:[DoNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1055 |
"/ doNotShowAgainHolder := false asValue. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1056 |
"/ box addCheckBox:'Do not show this dialog again (reenable via Launchers Settings Dialog)' on:doNotShowAgainHolder. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1057 |
"/ ]. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1058 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1059 |
"/ "/ answer := box confirm. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1060 |
"/ answer := box confirm. |
3007 | 1061 |
|
5290 | 1062 |
doNotShowAgainHolder value == true ifTrue:[ |
1063 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
|
1064 |
]. |
|
1065 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
|
1066 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
|
1067 |
]. |
|
3007 | 1068 |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1069 |
"/ box destroy. |
5290 | 1070 |
]. |
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
1071 |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1072 |
answer == #keepSelected ifTrue:[ |
5290 | 1073 |
self hideCursor. |
1074 |
"redraw selection in normal color" |
|
1075 |
self invalidate. |
|
1076 |
AbortOperationRequest raise. |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1077 |
]. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1078 |
|
201 | 1079 |
" |
1080 |
do the abort if we have to |
|
1081 |
" |
|
3397 | 1082 |
answer ifFalse:[ |
5290 | 1083 |
"redraw selection in normal color" |
1084 |
self invalidate. |
|
1085 |
AbortOperationRequest raise. |
|
201 | 1086 |
]. |
1087 |
^ false |
|
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1088 |
|
4170
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
1089 |
"Created: / 24-11-1995 / 22:56:34 / cg" |
4398 | 1090 |
"Modified: / 08-03-2012 / 10:24:21 / cg" |
201 | 1091 |
! |
1092 |
||
2663 | 1093 |
highlightingErrorLine:lineNr do:aBlock |
1094 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
1095 |
||
1096 |
|linePosition| |
|
1097 |
||
1098 |
linePosition := self characterPositionOfLine:lineNr col:1. |
|
1099 |
self highlightingErrorPosition:linePosition to:nil do:aBlock |
|
1100 |
! |
|
1101 |
||
59 | 1102 |
highlightingErrorPosition:relPos to:relEndPos do:aBlock |
1103 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
58 | 1104 |
|
5053 | 1105 |
self |
1106 |
highlightingErrorPosition:relPos to:relEndPos |
|
1107 |
withForeground:(self errorForegroundColor) andBackground:(self errorBackgroundColor) |
|
1108 |
do:aBlock |
|
3007 | 1109 |
! |
1110 |
||
1111 |
highlightingErrorPosition:relPos to:relEndPos withForeground:hilightFg andBackground:hilightBg do:aBlock |
|
1112 |
"evaluate aBlock while some selection is shown highlighted with colors passed as args." |
|
1113 |
||
1114 |
|absPosition oldFg oldBg| |
|
0 | 1115 |
|
58 | 1116 |
" |
1117 |
change color of selection & hide cursor |
|
1118 |
" |
|
3007 | 1119 |
oldFg := selectionFgColor. |
1120 |
oldBg := selectionBgColor. |
|
1121 |
selectionBgColor := hilightBg. |
|
1122 |
selectionFgColor := hilightFg. |
|
58 | 1123 |
self hideCursor. |
0 | 1124 |
|
58 | 1125 |
" |
1126 |
select the text - relEndPos may be nil in which case the whole line is selected |
|
1127 |
we have to adjust the positions given by the compiler, since they |
|
1128 |
are relative to the texts start (the compiler did stream-read the code). |
|
1129 |
" |
|
0 | 1130 |
codeStartPosition isNil ifTrue:[codeStartPosition := 1]. |
3427 | 1131 |
absPosition := codeStartPosition + (relPos ? 1) - 1. |
0 | 1132 |
relEndPos isNil ifTrue:[ |
5053 | 1133 |
self selectFromCharacterPosition:absPosition. |
1134 |
"/ self selectLineWhereCharacterPosition:absPosition. |
|
0 | 1135 |
] ifFalse:[ |
5053 | 1136 |
self selectFromCharacterPosition:absPosition to:(codeStartPosition + (relEndPos ? 1) - 1) |
0 | 1137 |
]. |
4273
4e9e823f9e41
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4252
diff
changeset
|
1138 |
expandingTop := true. "/ hack to make the top of the selection visible |
0 | 1139 |
self makeSelectionVisible. |
1140 |
||
4921 | 1141 |
self flush. |
58 | 1142 |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
1143 |
aBlock ensure:[ |
5053 | 1144 |
" |
1145 |
undo selection color change and show cursor again |
|
1146 |
" |
|
1147 |
selectionFgColor := oldFg. |
|
1148 |
selectionBgColor := oldBg. |
|
1149 |
self showCursor. |
|
0 | 1150 |
]. |
3427 | 1151 |
|
4273
4e9e823f9e41
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4252
diff
changeset
|
1152 |
"Modified: / 30-06-2011 / 17:24:04 / cg" |
0 | 1153 |
! |
1154 |
||
3007 | 1155 |
highlightingWarningPosition:relPos to:relEndPos do:aBlock |
1156 |
"evaluate aBlock while some selection is shown highlighted with warning colors." |
|
1157 |
||
5053 | 1158 |
self |
1159 |
highlightingErrorPosition:relPos to:relEndPos |
|
1160 |
withForeground:(self warningForegroundColor) andBackground:(self warningBackgroundColor) |
|
1161 |
do:aBlock |
|
3007 | 1162 |
! |
1163 |
||
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1164 |
unusedVariableWarning:aString position:relPos to:relEndPos from:aCompiler |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1165 |
"compiler notifies us of a (or some) unused variables; |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1166 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1167 |
this method should return true to the compiler if user wants the error |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1168 |
to be corrected; false otherwise" |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1169 |
|
4386 | 1170 |
|action doNotShowAgainHolder doNotShowAgainForThisMethodHolder| |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1171 |
|
3007 | 1172 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
5290 | 1173 |
doNotShowAgainHolder := false asValue. |
1174 |
doNotShowAgainForThisMethodHolder := false asValue. |
|
1175 |
Dialog modifyingBoxWith:[:box | |
|
1176 |
|makeSpace| |
|
1177 |
||
1178 |
aCompiler notNil ifTrue:[ |
|
1179 |
makeSpace := [ box addVerticalSpace:10. makeSpace := nil ]. |
|
1180 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
|
1181 |
makeSpace value. |
|
1182 |
box verticalPanel |
|
1183 |
add:(CheckBox |
|
1184 |
label: "addCheckBoxAtBottom:" 'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
1185 |
model:doNotShowAgainHolder). |
|
1186 |
]. |
|
1187 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
|
1188 |
makeSpace value. |
|
1189 |
box verticalPanel |
|
1190 |
add:(CheckBox |
|
1191 |
label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
|
1192 |
model:doNotShowAgainForThisMethodHolder). |
|
1193 |
]. |
|
1194 |
]. |
|
1195 |
] do:[ |
|
1196 |
action := OptionBox |
|
1197 |
request:aString |
|
1198 |
label:(resources string:'Warning') |
|
1199 |
image:(WarningBox iconBitmap) |
|
1200 |
buttonLabels:(resources array:#('Cancel' 'Remove Variable(s)' 'Continue')) |
|
1201 |
values:#(#abort #correct #continue) |
|
1202 |
default:#continue. |
|
1203 |
action isNil ifTrue:[ action := #abort]. |
|
1204 |
]. |
|
1205 |
doNotShowAgainHolder value == true ifTrue:[ |
|
1206 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
|
1207 |
]. |
|
1208 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
|
1209 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
|
1210 |
]. |
|
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1211 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1212 |
|
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1213 |
action == #abort ifTrue:[ |
5290 | 1214 |
"/ self halt. |
1215 |
AbortOperationRequest raise. |
|
1216 |
^ false |
|
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1217 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1218 |
^ action == #correct |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
1219 |
|
4398 | 1220 |
"Modified: / 08-03-2012 / 10:23:58 / cg" |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1221 |
! |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1222 |
|
5053 | 1223 |
warning:aString position:relPos to:relEndPos from:aCompiler |
32 | 1224 |
"compiler notifies us of a warning - same behavior as error" |
0 | 1225 |
|
5053 | 1226 |
self error:aString position:relPos to:relEndPos from:aCompiler asWarning:true |
0 | 1227 |
! ! |
1228 |
||
3396 | 1229 |
!Workspace methodsFor:'drag & drop'! |
1230 |
||
1231 |
canDrop:aDropContext |
|
4090 | 1232 |
"if allowValueDrop is true, any text- or file-object can be dropped into workspace |
1233 |
(printString); otherwise, only ..." |
|
1234 |
||
1235 |
self isReadOnly ifTrue:[^ false]. |
|
3396 | 1236 |
|
4090 | 1237 |
allowValueDrop ifTrue:[^ true]. |
1238 |
^ super canDrop:aDropContext |
|
3428 | 1239 |
|
5053 | 1240 |
"/ ^ aDropContext dropObjects |
4090 | 1241 |
"/ contains:[:someObject| (someObject isTextObject or:[ someObject isFileObject ])]. |
3396 | 1242 |
|
1243 |
"Created: / 16-08-2005 / 22:01:13 / janfrog" |
|
3428 | 1244 |
"Modified: / 28-11-2006 / 16:18:51 / cg" |
3396 | 1245 |
! |
1246 |
||
3414 | 1247 |
doDrop:aDropContext |
4631 | 1248 |
<resource: #obsolete> |
1249 |
self obsoleteMethodWarning:'should no longer be reached'. |
|
3428 | 1250 |
self drop:aDropContext |
3414 | 1251 |
|
3428 | 1252 |
"Modified: / 28-11-2006 / 16:14:51 / cg" |
4386 | 1253 |
"Modified (format): / 28-02-2012 / 11:20:38 / cg" |
3414 | 1254 |
! |
1255 |
||
1256 |
drop:aDropContext |
|
1257 |
"Any object can be dropped into workspace..." |
|
1258 |
||
3870 | 1259 |
|textObjects nonTextObjects answer text| |
1260 |
||
5053 | 1261 |
textObjects := aDropContext dropObjects |
1262 |
select:[:dropObject | dropObject isTextObject |
|
1263 |
or:[ dropObject isFileObject ]]. |
|
1264 |
nonTextObjects := aDropContext dropObjects |
|
1265 |
reject:[:dropObject | dropObject isTextObject |
|
1266 |
or:[ dropObject isFileObject ]]. |
|
3870 | 1267 |
|
1268 |
self dropObjects:textObjects. |
|
3414 | 1269 |
|
3870 | 1270 |
nonTextObjects notEmpty ifTrue:[ |
5053 | 1271 |
answer := Dialog |
1272 |
confirmWithCancel:(resources |
|
1273 |
string:'Drop as textual representation or as object reference ?') |
|
1274 |
labels:(resources array:#('Cancel' 'Reference' 'Name' 'Text')) |
|
1275 |
values:#(nil #ref #name #text) |
|
1276 |
default:4. |
|
1277 |
answer isNil ifTrue:[^ self]. |
|
1278 |
(answer == #text or:[answer == #name]) ifTrue:[ |
|
1279 |
text := String streamContents:[:s | |
|
1280 |
nonTextObjects do:[:dropObject | |
|
1281 |
|obj| |
|
3870 | 1282 |
|
5053 | 1283 |
obj := dropObject theObject. |
1284 |
obj isMethod ifTrue:[ |
|
1285 |
s nextPutAll:(answer == #name ifTrue:[obj selector] ifFalse:[obj source]). |
|
1286 |
] ifFalse:[ |
|
1287 |
obj isClass ifTrue:[ |
|
1288 |
s nextPutAll:(answer == #name ifTrue:[obj name] ifFalse:[obj source asString]) |
|
1289 |
] ifFalse:[ |
|
1290 |
s nextPutAll:(answer == #name ifTrue:[obj className] ifFalse:[obj printString]) . |
|
1291 |
]. |
|
1292 |
]. |
|
1293 |
]. |
|
1294 |
]. |
|
1295 |
self paste:text. |
|
1296 |
] ifFalse:[ |
|
1297 |
nonTextObjects do:[:dropObject | |
|
1298 |
name := Dialog |
|
1299 |
request:(resources |
|
1300 |
string:'Name of the new Workspace Variable (refers to the dropped %1):' |
|
1301 |
with:dropObject theObject class name allBold |
|
1302 |
) |
|
1303 |
initialAnswer:'droppedObject' |
|
1304 |
okLabel:'Add' |
|
1305 |
title:'Enter Variable Name'. |
|
3414 | 1306 |
|
5053 | 1307 |
name notEmptyOrNil ifTrue:[ |
1308 |
Workspace addWorkspaceVariable:name. |
|
1309 |
Workspace workspaceVariableAt:name put:dropObject theObject. |
|
1310 |
self paste:name. |
|
1311 |
]. |
|
1312 |
]. |
|
1313 |
] |
|
3414 | 1314 |
]. |
1315 |
||
1316 |
"Created: / 13-10-2006 / 17:34:07 / cg" |
|
3396 | 1317 |
! ! |
1318 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1319 |
!Workspace methodsFor:'editing'! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1320 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1321 |
commentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1322 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1323 |
All lines from line1 to line2 get an end-of-line comment |
5053 | 1324 |
in the first col |
1925 | 1325 |
(if no eol comment is available, a bracketing comment is used)." |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1326 |
|
6016 | 1327 |
self commentFrom:line1 to:line2 commentStrings:commentStrings. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1328 |
|
3403 | 1329 |
"Created: / 09-11-1997 / 01:05:35 / cg" |
1330 |
"Modified: / 09-10-2006 / 10:46:44 / cg" |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1331 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1332 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1333 |
commentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1334 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1335 |
All lines from line1 to line2 get an end-of-line comment |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1336 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1337 |
|
6016 | 1338 |
self commentSelection:commentStrings |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1339 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1340 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
1481 | 1341 |
"Modified: / 5.4.1998 / 16:52:23 / cg" |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1342 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1343 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1344 |
uncommentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1345 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1346 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 1347 |
in the first col. |
1348 |
(if no eol comment is available, a bracketing comment is removed)" |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1349 |
|
6016 | 1350 |
self uncommentFrom:line1 to:line2 commentStrings:commentStrings. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1351 |
|
3403 | 1352 |
"Created: / 09-11-1997 / 01:05:43 / cg" |
1353 |
"Modified: / 09-10-2006 / 10:46:59 / cg" |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1354 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1355 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1356 |
uncommentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1357 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1358 |
All lines from line1 to line2 get an end-of-line comment |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1359 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1360 |
|
6016 | 1361 |
self uncommentSelection:commentStrings |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1362 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1363 |
"Modified: / 7.1.1997 / 20:13:32 / cg" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1364 |
"Created: / 9.11.1997 / 01:05:46 / cg" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1365 |
! ! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1366 |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1367 |
!Workspace methodsFor:'event handling'! |
3712 | 1368 |
|
0 | 1369 |
keyPress:key x:x y:y |
5053 | 1370 |
<resource: #keyboard (#DoIt #InspectIt #PrintIt #ReplaceIt |
1371 |
#BrowseIt #ImplementorsOfIt #ExpandAbbreviation |
|
1372 |
#CommentSelection #UncommentSelection)> |
|
60 | 1373 |
|
3800 | 1374 |
(key == #DoIt) ifTrue:[self doIt. ^ self]. |
1375 |
(key == #InspectIt) ifTrue:[self inspectIt. ^ self]. |
|
1376 |
(key == #PrintIt) ifTrue:[self printIt. ^ self]. |
|
1377 |
(key == #ReplaceIt) ifTrue:[self replaceIt. ^ self]. |
|
1378 |
(key == #BrowseIt) ifTrue:[self browseIt. ^ self]. |
|
1379 |
(key == #ImplementorsOfIt) ifTrue:[self browseImplementorsOfIt. ^ self]. |
|
1380 |
(key == #ExpandAbbreviation) ifTrue:[self expandAbbreviation. ^ self]. |
|
4587 | 1381 |
(key == #CommentSelection) ifTrue:[self commentSelection. ^ self]. |
1382 |
(key == #UncommentSelection) ifTrue:[self uncommentSelection. ^ self]. |
|
38 | 1383 |
|
0 | 1384 |
super keyPress:key x:x y:y |
3511 | 1385 |
|
1386 |
"Modified: / 08-11-2007 / 11:29:45 / cg" |
|
0 | 1387 |
! ! |
201 | 1388 |
|
2143 | 1389 |
!Workspace methodsFor:'executing'! |
201 | 1390 |
|
1501 | 1391 |
do:code withValueDo:aBlock |
5053 | 1392 |
"helper for doIt, printIt and inspectIt. |
1393 |
Evaluate the selection and, if all went well, evaluate the argument, |
|
418 | 1394 |
aBlock with the value. |
1395 |
Most work is in preparing for proper cleanup in case of abort |
|
1396 |
or other exception while the evaluation is performed. |
|
1397 |
(restore cursor, selectionColors etc.)" |
|
201 | 1398 |
|
6223 | 1399 |
|selLine selCol endLine endCol cLine cCol cleanUp executeBlock savedBackground| |
201 | 1400 |
|
1401 |
code notNil ifTrue:[ |
|
6223 | 1402 |
code asString withoutSeparators isEmpty ifTrue:[ ^ self ]. |
1403 |
||
1404 |
codeStartPosition := self characterPositionOfSelection. |
|
1405 |
||
1406 |
" |
|
1407 |
remember selection for later - if there is an error, |
|
1408 |
the notification method will highlight it. |
|
1409 |
thus destroying the current selection |
|
1410 |
" |
|
1411 |
selLine := selectionStartLine. |
|
1412 |
selCol := selectionStartCol. |
|
1413 |
endLine := selectionEndLine. |
|
1414 |
endCol := selectionEndCol. |
|
1415 |
cCol := cursorCol. |
|
1416 |
cLine := cursorLine. |
|
1417 |
||
1418 |
" |
|
1419 |
cleanup: restore previous selection and cursor positions |
|
1420 |
" |
|
1421 |
cleanUp := |
|
1422 |
[ |
|
1423 |
self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
|
1424 |
cLine notNil ifTrue:[ |
|
1425 |
self cursorLine:cLine col:cCol |
|
1426 |
]. |
|
1427 |
savedBackground notNil ifTrue:[ |
|
1428 |
self backgroundColor:savedBackground. |
|
1429 |
self invalidate. |
|
1430 |
]. |
|
1431 |
]. |
|
1432 |
||
1433 |
" |
|
1434 |
perform the action. |
|
1435 |
Be careful to release the reference to the value; |
|
1436 |
otherwise, we could keep lots of garbage from being freed |
|
1437 |
until the view gets closed |
|
1438 |
" |
|
1439 |
executeBlock := |
|
1440 |
[ |
|
1441 |
[ |
|
1442 |
|busyColor| |
|
1443 |
||
1444 |
(busyColor := UserPreferences current busyBackgroundColorInDoits) notNil ifTrue:[ |
|
1445 |
savedBackground := self backgroundColor. |
|
1446 |
self backgroundColor:busyColor. |
|
1447 |
self invalidateRepairNow:true. |
|
1448 |
]. |
|
1449 |
||
1450 |
AbortOperationRequest handle:[:ex | |
|
1451 |
"/ aBlock value:'** Abortsignal caught **'. |
|
1452 |
ex return |
|
1453 |
] do:[ |
|
1454 |
|value| |
|
1455 |
||
1456 |
doItAction notNil ifTrue:[ |
|
1457 |
value := doItAction value:(code asString). |
|
1458 |
cleanUp value. cleanUp := nil. |
|
1459 |
aBlock notNil ifTrue:[ |
|
1460 |
aBlock value:value. |
|
1461 |
]. |
|
1462 |
value := nil. |
|
1463 |
self class rememberDoIt:code. |
|
1464 |
] |
|
1465 |
] |
|
1466 |
] ensure:[ |
|
1467 |
cleanUp notNil ifTrue:[ |
|
1468 |
cleanUp value. cleanUp := nil |
|
1469 |
]. |
|
1470 |
] |
|
1471 |
]. |
|
1472 |
aBlock isNil ifTrue:[ |
|
1473 |
"no action is performed with the result - give the user a visible |
|
1474 |
feedback, that something has been done" |
|
1475 |
self topView withVisibleCursor:Cursor execute do:executeBlock. |
|
1476 |
] ifFalse:[ |
|
1477 |
self topView withCursor:Cursor execute do:executeBlock. |
|
1478 |
]. |
|
201 | 1479 |
] |
257 | 1480 |
|
6223 | 1481 |
"Created: / 22-04-1998 / 21:57:05 / ca" |
1482 |
"Modified: / 01-11-2017 / 11:27:26 / cg" |
|
4677 | 1483 |
! |
201 | 1484 |
|
2733 | 1485 |
executeDoIt:theCode |
4391 | 1486 |
"the core of doIt, printIt, inspectIt, browseIt actions" |
1487 |
||
4618
d3554659540b
Fix for RegressionTests::Compiler2Tests>>test_03
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4617
diff
changeset
|
1488 |
| result compiler | |
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1489 |
|
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1490 |
"JV@2012-03-19: Changed to reflect value of autoDefineVariables" |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1491 |
[ |
6223 | 1492 |
compiler := (self compilerClass ? Compiler) new. |
1493 |
result := compiler |
|
1494 |
currentNameSpace:namespaceForDoits; |
|
1495 |
moreSharedPools:poolsConsideredInDoIts; |
|
1496 |
evaluate:theCode in:nil |
|
1497 |
receiver:simulatedSelf |
|
1498 |
notifying:self logged:true |
|
1499 |
ifFail:nil |
|
1500 |
] on:(Parser undefinedVariableNotification) do:[:ex| |
|
1501 |
(ex parser == compiler and:[autoDefineVariables notNil]) ifTrue:[ |
|
1502 |
ex proceedWith: #declare |
|
1503 |
] ifFalse:[ |
|
1504 |
ex proceedWith: nil |
|
1505 |
]. |
|
1506 |
] on:(Parser askForVariableTypeOfUndeclaredQuery) do:[:ex| |
|
1507 |
autoDefineVariables == #workspace ifTrue:[ |
|
1508 |
ex proceedWith:#WorkspaceVariable |
|
1509 |
]. |
|
1510 |
autoDefineVariables == #doIt ifTrue:[ |
|
1511 |
ex proceedWith:#DoItTemporary |
|
1512 |
]. |
|
1513 |
ex pass. |
|
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1514 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1515 |
^result |
4391 | 1516 |
|
4618
d3554659540b
Fix for RegressionTests::Compiler2Tests>>test_03
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4617
diff
changeset
|
1517 |
"Modified: / 24-06-2013 / 15:31:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6223 | 1518 |
"Modified (format): / 01-11-2017 / 11:18:31 / cg" |
4677 | 1519 |
! ! |
1520 |
||
1521 |
!Workspace methodsFor:'initialization & release'! |
|
2733 | 1522 |
|
201 | 1523 |
initStyle |
966 | 1524 |
"setup viewStyle specifics" |
1525 |
||
201 | 1526 |
super initStyle. |
1527 |
||
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1528 |
DefaultViewBackground notNil ifTrue:[ |
5053 | 1529 |
viewBackground := DefaultViewBackground. |
1530 |
self backgroundColor:viewBackground. |
|
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1531 |
]. |
201 | 1532 |
! |
1533 |
||
1534 |
initialize |
|
1535 |
super initialize. |
|
1536 |
||
5105 | 1537 |
autoIndent := UserPreferences current autoIndentInCodeView. |
2775 | 1538 |
scrollWhenUpdating := #beginOfText. |
201 | 1539 |
showMatchingParenthesis := true. |
3428 | 1540 |
allowValueDrop := true. |
1541 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1542 |
commentStrings := #( |
5103 | 1543 |
'"/' |
1544 |
('"' '"') |
|
1545 |
). |
|
201 | 1546 |
|
1547 |
self initializeDoITAction. |
|
3396 | 1548 |
self initializeDragAndDrop. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1549 |
|
3428 | 1550 |
"Modified: / 28-11-2006 / 16:11:55 / cg" |
201 | 1551 |
! |
1552 |
||
1553 |
initializeDoITAction |
|
1554 |
"set up the block to be evaluated for doIts. |
|
1555 |
This is done here in a separate method to allow easier |
|
1556 |
redefinition in subclasses" |
|
1557 |
||
2733 | 1558 |
doItAction := [:theCode | self executeDoIt:theCode]. |
3396 | 1559 |
! |
1560 |
||
1561 |
initializeDragAndDrop |
|
1562 |
|target| |
|
1563 |
||
5053 | 1564 |
target := DropTarget |
1565 |
receiver:self |
|
1566 |
argument:nil |
|
1567 |
dropSelector:#drop: |
|
1568 |
canDropSelector:#canDrop:. |
|
3396 | 1569 |
self dropTarget:target |
1570 |
||
1571 |
"Created: / 16-08-2005 / 22:03:36 / janfrog" |
|
3411 | 1572 |
"Modified: / 13-10-2006 / 12:37:18 / cg" |
201 | 1573 |
! ! |
1574 |
||
418 | 1575 |
!Workspace methodsFor:'menu & menu actions'! |
1576 |
||
2285 | 1577 |
browseClass |
1578 |
"user selected 'browseClass' from menu; evaluate the code |
|
1579 |
and open a browser on the resulting class (if it evaluates to one)" |
|
1580 |
||
5053 | 1581 |
^ self |
1582 |
do:(self selectionAsString) |
|
1583 |
withValueDo:[:result | |
|
1584 |
result isBehavior ifTrue:[ |
|
1585 |
result browserClass openInClass:result selector:nil |
|
1586 |
] ifFalse:[ |
|
1587 |
self warn:'Selection does not evaluate to a class' |
|
1588 |
] |
|
1589 |
]. |
|
2285 | 1590 |
|
2410 | 1591 |
"Modified: / 26.9.2001 / 17:37:35 / cg" |
2285 | 1592 |
! |
1593 |
||
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1594 |
browseImplementorsOfIt |
4617 | 1595 |
"open a browser on the implementors of the selected text, |
1596 |
or - if I support syntax elements, on the syntax element at the cursor position" |
|
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1597 |
|
5621 | 1598 |
|selectedText selector browserClass na browser |
5906 | 1599 |
cls node dwim targetClass targetImplClass| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1600 |
|
4617 | 1601 |
selectedText := self selectedTextOrSyntaxElement. |
1602 |
selectedText notEmptyOrNil ifTrue:[ |
|
5621 | 1603 |
self windowGroup withWaitCursorDo:[ |
1604 |
"/ hack, for now and expecco; must ask the Parser eventually... |
|
6021 | 1605 |
((compilerClass notNil and:[compilerClass includesBehavior:JavaScriptParser]) |
1606 |
or:[ self editedLanguage notNil |
|
1607 |
and:[ self editedLanguage isSTXJavaScript]]) ifTrue:[ |
|
5621 | 1608 |
"/ selector is in one piece anyway |
1609 |
(selectedText includes:$_) ifFalse:[ |
|
1610 |
"/ zero or one args - sigh (need to parse more to figure this out) |
|
1611 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:1. |
|
1612 |
selectedText := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:0. |
|
1613 |
] ifTrue:[ |
|
1614 |
"/ count _#s plus one arg - sigh |
|
1615 |
na := (selectedText occurrencesOf:$_) + 1. |
|
1616 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:na |
|
1617 |
]. |
|
1618 |
] ifFalse:[ |
|
1619 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
|
1620 |
]. |
|
6201 | 1621 |
browserClass := SystemBrowser default. |
5621 | 1622 |
|
1623 |
(selector notNil and:[selector ~= selectedText]) ifTrue:[ |
|
1624 |
(SystemBrowser |
|
1625 |
findImplementorsOfAny:(Array with:selectedText) |
|
1626 |
in:(Smalltalk allClasses) |
|
1627 |
ignoreCase:false) isEmpty ifTrue:[ |
|
1628 |
browser := browserClass browseImplementorsOf:selector |
|
1629 |
] ifFalse:[ |
|
1630 |
browser := browserClass browseImplementorsOfAny:(Set with:selector with:selectedText) |
|
1631 |
]. |
|
1632 |
] ifFalse:[ |
|
1633 |
browser := browserClass browseImplementorsOf:(selector ? selectedText) |
|
1634 |
]. |
|
5646 | 1635 |
browser notNil ifTrue:[ |
1636 |
"/ if the type of the receiver is known, |
|
1637 |
"/ select the targeted method immediately |
|
1638 |
(cls := self editedClass) notNil ifTrue:[ |
|
5906 | 1639 |
node := DoWhatIMeanSupport |
5646 | 1640 |
findNodeForInterval:(self selectionStartIndex to:self selectionStopIndex) |
1641 |
in:self contents string. |
|
1642 |
(node notNil and:[node isMessage]) ifTrue:[ |
|
5906 | 1643 |
dwim := DoWhatIMeanSupport new. |
1644 |
dwim setClass:cls andContext:nil. |
|
1645 |
dwim setSelf: simulatedSelf. |
|
5646 | 1646 |
targetClass := dwim classOfNode:node receiver. |
5906 | 1647 |
|
5646 | 1648 |
targetClass notNil ifTrue:[ |
1649 |
targetImplClass := targetClass whichClassImplements:(node selector). |
|
1650 |
targetImplClass notNil ifTrue:[ |
|
1651 |
browser selectMethod:(targetImplClass compiledMethodAt:(node selector)) |
|
1652 |
]. |
|
5621 | 1653 |
]. |
5646 | 1654 |
]. |
1655 |
] |
|
5621 | 1656 |
] |
1657 |
] |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1658 |
]. |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1659 |
|
6201 | 1660 |
"Created: / 05-11-2001 / 17:32:23 / cg" |
1661 |
"Modified: / 01-09-2017 / 14:24:04 / cg" |
|
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1662 |
! |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1663 |
|
2307 | 1664 |
browseIt |
1665 |
"evaluate the code and open a browser on the resulting class (if it evaluates to one), |
|
2713 | 1666 |
or the class of the resulting object (if it does not evaluate to a class). |
1667 |
||
5731 | 1668 |
Added feature: |
1669 |
if selection is of the form class >> selector, |
|
1670 |
immediately switch to that selector." |
|
2713 | 1671 |
|
4617 | 1672 |
|codeToEvaluate el idx selector evaluatedValue classToBrowse gotResult| |
2713 | 1673 |
|
5053 | 1674 |
(self selection isEmptyOrNil |
5072 | 1675 |
and:[ self supportsSyntaxElements |
1676 |
and:[ (el := self syntaxElementForVariableUnderCursor) notNil ]]) |
|
5053 | 1677 |
ifTrue:[ |
5072 | 1678 |
codeToEvaluate := el name |
4617 | 1679 |
] ifFalse:[ |
5072 | 1680 |
codeToEvaluate := (self selectionOrTextOfCursorLine ? '') withoutSeparators. |
4617 | 1681 |
]. |
5964 | 1682 |
idx := codeToEvaluate indexOf:'»'. |
2713 | 1683 |
idx ~~ 0 ifTrue:[ |
5731 | 1684 |
selector := (codeToEvaluate copyFrom:idx+1) withoutSeparators string. |
5072 | 1685 |
(selector startsWith:'#') ifTrue:[ |
1686 |
selector := Symbol readFrom:selector. |
|
1687 |
]. |
|
1688 |
codeToEvaluate := codeToEvaluate copyTo:idx-1. |
|
5731 | 1689 |
] ifFalse:[ |
1690 |
idx := codeToEvaluate indexOfSubCollection:'>>'. |
|
1691 |
idx ~~ 0 ifTrue:[ |
|
1692 |
selector := (codeToEvaluate copyFrom:idx+2) withoutSeparators string. |
|
1693 |
(selector startsWith:'#') ifTrue:[ |
|
1694 |
selector := Symbol readFrom:selector. |
|
1695 |
]. |
|
1696 |
codeToEvaluate := codeToEvaluate copyTo:idx-1. |
|
1697 |
]. |
|
2713 | 1698 |
]. |
5731 | 1699 |
|
4997 | 1700 |
(Parser parseErrorSignal , MessageNotUnderstood) handle:[:ex | |
5072 | 1701 |
|className words| |
1702 |
||
1703 |
(classToBrowse := Smalltalk classNamed:codeToEvaluate) isNil ifTrue:[ |
|
1704 |
"/ handle className selector (for example from messageTally list) |
|
1705 |
codeToEvaluate includesSeparator ifTrue:[ |
|
1706 |
words := codeToEvaluate asCollectionOfWords. |
|
1707 |
classToBrowse := Smalltalk classNamed:words first. |
|
1708 |
classToBrowse notNil ifTrue:[ |
|
1709 |
selector := (words copyFrom:2) asStringWith:''. |
|
1710 |
((words size > 1) and:[words second = 'class']) ifTrue:[ |
|
1711 |
classToBrowse := classToBrowse theMetaclass. |
|
1712 |
selector := (words copyFrom:3) asStringWith:''. |
|
1713 |
]. |
|
1714 |
classToBrowse browserClass openInClass:classToBrowse selector:selector. |
|
1715 |
^ self. |
|
1716 |
]. |
|
1717 |
]. |
|
1718 |
||
1719 |
"/ fallback, if garbage is selected, look for matching classes. |
|
1720 |
className := SystemBrowser |
|
1721 |
askForClassNameMatching:codeToEvaluate |
|
1722 |
inEnvironment:nil |
|
1723 |
for:nil. |
|
1724 |
||
1725 |
className isNil ifTrue:[^ self]. |
|
1726 |
classToBrowse := Smalltalk classNamed:className. |
|
1727 |
] |
|
3910 | 1728 |
] do:[ |
5072 | 1729 |
gotResult := false. |
1730 |
||
1731 |
self |
|
1732 |
do:codeToEvaluate |
|
1733 |
withValueDo:[:result | evaluatedValue := result. gotResult := true.]. |
|
1734 |
||
1735 |
gotResult ifFalse:[^ self]. |
|
1736 |
||
1737 |
evaluatedValue isNil ifTrue:[ |
|
1738 |
codeToEvaluate asCollectionOfWords size == 1 ifTrue:[ |
|
1739 |
codeToEvaluate isUppercaseFirst ifTrue:[ |
|
1740 |
Dialog information:(codeToEvaluate allBold , ' is unbound or nil'). |
|
1741 |
^ self. |
|
1742 |
]. |
|
1743 |
] |
|
1744 |
]. |
|
1745 |
classToBrowse := evaluatedValue isBehavior |
|
1746 |
ifTrue:[ evaluatedValue ] |
|
1747 |
ifFalse:[ evaluatedValue class ]. |
|
3910 | 1748 |
]. |
1749 |
||
1750 |
classToBrowse browserClass openInClass:classToBrowse selector:selector |
|
4386 | 1751 |
|
1752 |
"Modified: / 28-02-2012 / 11:23:06 / cg" |
|
2307 | 1753 |
! |
1754 |
||
2285 | 1755 |
browseItsClass |
1756 |
"user selected 'browseItsClass' from menu; evaluate the code |
|
1757 |
and open a browser on the results class" |
|
1758 |
||
5053 | 1759 |
^ self |
1760 |
do:(self selectionAsString) |
|
1761 |
withValueDo:[:result | |
|
1762 |
result class browserClass openInClass:result class selector:nil |
|
1763 |
] |
|
2285 | 1764 |
|
2410 | 1765 |
"Modified: / 26.9.2001 / 17:38:06 / cg" |
2285 | 1766 |
! |
1767 |
||
2454 | 1768 |
browseReferencesToIt |
5003 | 1769 |
"open a browser on all references to the selected global, poolvar or namespace class" |
2454 | 1770 |
|
5066 | 1771 |
|nameOfVariable browserClass sym| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1772 |
|
5065 | 1773 |
nameOfVariable := self selectedTextOrSyntaxElement. |
1774 |
nameOfVariable notEmptyOrNil ifTrue:[ |
|
6201 | 1775 |
browserClass := SystemBrowser default. |
5065 | 1776 |
self windowGroup withWaitCursorDo:[ |
5618 | 1777 |
|cls nonMeta privateClass| |
4675 | 1778 |
|
5066 | 1779 |
(nameOfVariable startsWith:'#') ifTrue:[ |
1780 |
sym := (nameOfVariable copyFrom:2) asSymbolIfInterned. |
|
1781 |
browserClass browseForSymbol:sym. |
|
5065 | 1782 |
] ifFalse:[ |
5066 | 1783 |
"/ is it a class variable? |
1784 |
((cls := self editedClass) notNil |
|
5618 | 1785 |
and:[ ((nonMeta := cls theNonMetaclass) allClassVarNames includes:nameOfVariable) ]) ifTrue:[ |
1786 |
nonMeta isSharedPool ifTrue:[ |
|
1787 |
"/ class is a pool - browse all references to it. |
|
1788 |
browserClass browseReferendsOf:(nonMeta name,':',nameOfVariable) |
|
1789 |
] ifFalse:[ |
|
1790 |
browserClass |
|
1791 |
browseRefsTo:nameOfVariable |
|
1792 |
classVars:true |
|
1793 |
in:(nonMeta whichClassDefinesClassVar:nameOfVariable) withAllSubclasses |
|
1794 |
modificationsOnly:false. |
|
1795 |
]. |
|
5065 | 1796 |
] ifFalse:[ |
5066 | 1797 |
"/ is it a private class? |
1798 |
(cls notNil |
|
1799 |
and:[ (privateClass := cls theNonMetaclass privateClassNamed:nameOfVariable) notNil ]) ifTrue:[ |
|
1800 |
browserClass browseReferendsOf:(privateClass name) |
|
5065 | 1801 |
] ifFalse:[ |
5066 | 1802 |
|pool nsClass| |
1803 |
||
1804 |
"/ is it a pool variable? |
|
1805 |
cls notNil ifTrue:[ |
|
1806 |
pool := cls theNonMetaclass sharedPools |
|
1807 |
detect:[:pool | pool classVarNames includes:nameOfVariable] |
|
1808 |
ifNone:nil. |
|
1809 |
]. |
|
1810 |
pool notNil ifTrue:[ |
|
1811 |
browserClass browseReferendsOf:(pool name,':',nameOfVariable) |
|
5065 | 1812 |
] ifFalse:[ |
5066 | 1813 |
(cls notNil |
1814 |
and:[ cls nameSpace notNil |
|
1815 |
and:[ nameOfVariable knownAsSymbol |
|
5982 | 1816 |
and:[ cls nameSpace isNameSpace |
1817 |
and:[(nsClass := cls nameSpace at:nameOfVariable asSymbol) notNil |
|
5512 | 1818 |
and:[ nsClass isBehavior |
5982 | 1819 |
]]]]]) ifTrue:[ |
5066 | 1820 |
"/ a namespace class? |
1821 |
browserClass browseReferendsOf:nsClass name |
|
5065 | 1822 |
] ifFalse:[ |
5066 | 1823 |
"/ an instvar? |
5250 | 1824 |
(cls notNil and:[cls allInstVarNames includes:nameOfVariable]) ifTrue:[ |
5066 | 1825 |
browserClass |
1826 |
browseInstRefsTo:nameOfVariable |
|
1827 |
under:(cls whichClassDefinesInstVar:nameOfVariable) |
|
1828 |
modificationsOnly:false |
|
1829 |
] ifFalse:[ |
|
1830 |
"/ no, assume global |
|
1831 |
browserClass browseReferendsOf:nameOfVariable |
|
1832 |
] |
|
5065 | 1833 |
] |
1834 |
] |
|
1835 |
] |
|
1836 |
] |
|
1837 |
] |
|
1838 |
]. |
|
2454 | 1839 |
]. |
1840 |
||
5618 | 1841 |
"Created: / 05-11-2001 / 17:32:23 / cg" |
6201 | 1842 |
"Modified: / 01-09-2017 / 14:24:09 / cg" |
2454 | 1843 |
! |
1844 |
||
2462 | 1845 |
browseSendersOfIt |
1846 |
"open a browser on the senders of the selected text" |
|
1847 |
||
2715 | 1848 |
|selectedText selector| |
2462 | 1849 |
|
4617 | 1850 |
selectedText := self selectedTextOrSyntaxElement. |
1851 |
selectedText notEmptyOrNil ifTrue:[ |
|
6201 | 1852 |
self windowGroup withWaitCursorDo:[ |
1853 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
|
1854 |
SystemBrowser default |
|
1855 |
browseAllCallsOn:(selector ? selectedText) |
|
1856 |
] |
|
2462 | 1857 |
]. |
1858 |
||
6201 | 1859 |
"Created: / 05-11-2001 / 17:32:23 / cg" |
1860 |
"Modified: / 01-09-2017 / 14:24:13 / cg" |
|
2462 | 1861 |
! |
1862 |
||
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1863 |
browseSharedPoolOfIt |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1864 |
"open a browser on the shared pool in which the selected variable is" |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1865 |
|
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1866 |
|sel| |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1867 |
|
4617 | 1868 |
sel := self selectedTextOrSyntaxElement. |
1869 |
sel notEmptyOrNil ifTrue:[ |
|
5506 | 1870 |
sel := sel asSymbol. |
1871 |
self windowGroup withWaitCursorDo:[ |
|
1872 |
SharedPool allSubclassesDo:[:eachPool | |
|
1873 |
(eachPool includesKey:sel) ifTrue:[ |
|
1874 |
eachPool class browse:#initialize |
|
1875 |
]. |
|
1876 |
]. |
|
1877 |
]. |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1878 |
]. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1879 |
|
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1880 |
"Created: / 15-01-2011 / 14:01:39 / cg" |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1881 |
! |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1882 |
|
418 | 1883 |
doIt |
1884 |
"user selected 'doIt' from menu; show a wait-cursor, evaluate the code |
|
1885 |
and finally restore cursor; return result of evaluation" |
|
1886 |
||
5053 | 1887 |
^ self |
1888 |
do:(self selectionOrTextOfCursorLine) |
|
1889 |
withValueDo:nil |
|
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1890 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1891 |
"Modified: / 16.5.1998 / 16:45:01 / cg" |
418 | 1892 |
! |
1893 |
||
1894 |
editMenu |
|
5878 | 1895 |
"return my popUpMenu; that's the superclasses menu |
1107 | 1896 |
PLUS st-evaluation items: doIt, printIt and inspectIt." |
1897 |
||
5053 | 1898 |
<resource: #keyboard (#DoIt #PrintIt #InspectIt |
5065 | 1899 |
#CommentSelection #UncommentSelection |
1900 |
#BrowseIt #ImplementorsOfIt |
|
1901 |
)> |
|
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1251
diff
changeset
|
1902 |
<resource: #programMenu> |
489 | 1903 |
|
4998 | 1904 |
|m sub subsub idx sensor sel2 sel selectedSymbol| |
418 | 1905 |
|
1906 |
m := super editMenu. |
|
3252 | 1907 |
((sensor := self sensor) notNil and:[sensor ctrlDown and:[sensor shiftDown not]]) ifTrue:[ |
5065 | 1908 |
sub := m. |
1909 |
m := nil. |
|
2459 | 1910 |
] ifFalse:[ |
5065 | 1911 |
sub := m subMenuAt:#others. |
2459 | 1912 |
]. |
418 | 1913 |
|
2459 | 1914 |
sub notNil ifTrue:[ |
5065 | 1915 |
" |
1916 |
workspaces support #browse, implementors etc. add them after paste. |
|
1917 |
" |
|
1918 |
sub |
|
1919 |
addItemList:#( |
|
1920 |
('-' ) |
|
5682 | 1921 |
('Browse It' browseIt BrowseIt ) |
5065 | 1922 |
('Browse Pool' browseSharedPoolOfIt ) |
1923 |
('Senders of It' browseSendersOfIt ) |
|
1924 |
('Implementors of It' browseImplementorsOfIt ImplementorsOfIt ) |
|
1925 |
('References to It' browseReferencesToIt ) |
|
3910 | 1926 |
"/ ('Classes Containing It in Name' browseClassesContainingItInName ) |
5964 | 1927 |
"/ ('Methods Contaníning It in Name' browseMethodsContainingItInName ) |
1928 |
"/ ('Methods Contaníning It in Source' browseMethodsContainingItInSource ) |
|
5065 | 1929 |
('-' ) |
1930 |
('TimeIt' timeIt ) |
|
1931 |
('SpyOnIt' spyOnIt )) |
|
1932 |
resources:resources |
|
1933 |
after:#gotoLine. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1934 |
|
5065 | 1935 |
subsub := sub subMenuAt:#tools. |
1936 |
subsub notNil ifTrue:[ |
|
1937 |
subsub |
|
1938 |
addItemList:#( |
|
1939 |
('-' ) |
|
1940 |
('CommentIt' commentSelection CommentSelection ) |
|
1941 |
('UncommentIt' uncommentSelection UncommentSelection )) |
|
5579 | 1942 |
resources:resources |
1943 |
after:#'indent'. |
|
1944 |
subsub |
|
1945 |
addItemList:#( |
|
1946 |
('Inspect Instances' inspectInstances nil) |
|
1947 |
) |
|
1948 |
resources:resources |
|
1949 |
||
1950 |
after:#inspectString. |
|
1951 |
||
1952 |
(self hasSelection not |
|
1953 |
or:[ (sel := self selectionAsString asSymbolIfInterned) isNil |
|
1954 |
or:[ (Smalltalk at:sel) isBehavior not ]]) ifTrue:[ |
|
1955 |
sub disable:#inspectInstances |
|
1956 |
]. |
|
5065 | 1957 |
]. |
2867 | 1958 |
|
5065 | 1959 |
self hasSelection ifFalse:[ |
1960 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt |
|
1961 |
browseReferencesToIt timeIt spyOnIt |
|
5579 | 1962 |
browseSharedPoolOfIt browseIt inspectInstances). |
5065 | 1963 |
self supportsSyntaxElements ifTrue:[ |
1964 |
self syntaxElementForSelectorUnderCursor notNil ifTrue:[ |
|
1965 |
sub enableAll:#(browseImplementorsOfIt browseSendersOfIt ) |
|
1966 |
] ifFalse:[ |
|
1967 |
|el| |
|
4617 | 1968 |
|
5065 | 1969 |
(el := self syntaxElementForVariableUnderCursor) notNil ifTrue:[ |
1970 |
(el isGlobal or:[el isInstanceVariable]) ifTrue:[ |
|
1971 |
sub enable: #browseReferencesToIt |
|
1972 |
]. |
|
1973 |
el isClass ifTrue:[ |
|
1974 |
sub enable:#browseIt |
|
1975 |
] |
|
1976 |
] |
|
1977 |
] |
|
1978 |
]. |
|
1979 |
] ifTrue:[ |
|
1980 |
sel := self selectionAsString. |
|
1981 |
sel notNil ifTrue:[ |
|
1982 |
sel asSymbolIfInterned isNil ifTrue:[ |
|
1983 |
sel2 := SystemBrowser extractSelectorFrom:sel. |
|
1984 |
sel2 notNil ifTrue:[ |
|
1985 |
sel2 := sel2 asSymbolIfInterned. |
|
1986 |
]. |
|
1987 |
]. |
|
1988 |
]. |
|
1989 |
(sel2 isNil and:[sel isNil]) ifTrue:[ |
|
1990 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt). |
|
1991 |
]. |
|
1992 |
"/ a global or namespace-var selected ? |
|
1993 |
sel isNil ifTrue:[ |
|
1994 |
sub disable:#browseReferencesToIt. |
|
1995 |
] ifFalse:[ |
|
5066 | 1996 |
(sel startsWith:'#') ifTrue:[ |
1997 |
"/ a symbol selected - can search references |
|
5065 | 1998 |
] ifFalse:[ |
5066 | 1999 |
selectedSymbol := sel asSymbolIfInterned. |
2000 |
(selectedSymbol notNil |
|
2001 |
and:[(Smalltalk includesKey:selectedSymbol) |
|
2002 |
or:[(NameSpace allNameSpaces contains:[:ns | ns includesKey:selectedSymbol]) ]] |
|
2003 |
) ifTrue:[ |
|
2004 |
"/ a global or namespace var selected |
|
2005 |
] ifFalse:[ |
|
2006 |
|cls| |
|
2007 |
||
2008 |
cls := self editedClass. |
|
2009 |
cls notNil ifTrue:[ |
|
2010 |
cls := cls theNonMetaclass. |
|
2011 |
((cls allClassVarNames includes:sel) |
|
2012 |
or:[ (cls theNonMetaclass privateClassNamed:sel) notNil]) ifTrue:[ |
|
2013 |
"/ a classvar or private class |
|
2014 |
] ifFalse:[ |
|
2015 |
|pool| |
|
2016 |
"/ is it a pool variable? |
|
2017 |
pool := cls sharedPools |
|
2018 |
detect:[:pool | pool classVarNames includes:sel] |
|
2019 |
ifNone:nil. |
|
2020 |
pool isNil ifTrue:[ |
|
2021 |
"/ todo: an instvar selected? |
|
2022 |
(cls allInstVarNames includes:sel) ifFalse:[ |
|
2023 |
sub disable:#browseReferencesToIt. |
|
2024 |
]. |
|
5065 | 2025 |
]. |
2026 |
]. |
|
5066 | 2027 |
] ifFalse:[ |
2028 |
sub disable:#browseReferencesToIt. |
|
5065 | 2029 |
]. |
2030 |
]. |
|
2031 |
]. |
|
2032 |
]. |
|
2033 |
(selectedSymbol notNil |
|
2034 |
and:[SharedPool allSubclasses contains:[:pool | pool includesKey:selectedSymbol]]) ifFalse:[ |
|
2035 |
sub disable:#browseSharedPoolOfIt. |
|
2036 |
]. |
|
2037 |
]. |
|
2038 |
self isReadOnly ifTrue:[ |
|
2039 |
sub disableAll:#(commentSelection uncommentSelection) |
|
2040 |
]. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
2041 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
2042 |
|
2459 | 2043 |
m notNil ifTrue:[ |
5065 | 2044 |
" |
2045 |
workspaces support #doIt, #printIt and #inspectIt |
|
2046 |
add them after paste. |
|
2047 |
" |
|
2048 |
idx := m indexOf:#paste. |
|
2049 |
idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
|
2050 |
idx ~~ 0 ifTrue:[ |
|
2051 |
m |
|
2052 |
addItemList:#( |
|
2053 |
('-' ) |
|
2054 |
('DoIt' doIt DoIt ) |
|
2055 |
('PrintIt' printIt PrintIt ) |
|
2056 |
('InspectIt' inspectIt InspectIt)) |
|
2057 |
resources:resources |
|
2058 |
after:idx. |
|
4998 | 2059 |
|
5065 | 2060 |
]. |
2459 | 2061 |
|
5065 | 2062 |
(self hasSelectionOrTextInCursorLine) ifFalse:[ |
2063 |
|lNr line| |
|
3272 | 2064 |
|
5065 | 2065 |
lNr := self cursorLine. |
2066 |
line := self listAt:lNr. |
|
2067 |
line isEmptyOrNil ifTrue:[ |
|
2068 |
m disableAll:#(printIt doIt inspectIt browseIt) |
|
2069 |
]. |
|
2070 |
]. |
|
2071 |
self isReadOnly ifTrue:[ |
|
2072 |
m disable:#printIt |
|
2073 |
]. |
|
418 | 2074 |
]. |
2075 |
||
2459 | 2076 |
^ m ? sub. |
430 | 2077 |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
2078 |
"Modified: / 22-04-1998 / 21:49:06 / ca" |
4342 | 2079 |
"Modified: / 20-12-2011 / 11:22:20 / cg" |
418 | 2080 |
! |
2081 |
||
5579 | 2082 |
inspectInstances |
2083 |
|nameOfVariable cls insts| |
|
2084 |
||
2085 |
nameOfVariable := self selectedTextOrSyntaxElement. |
|
2086 |
nameOfVariable isEmptyOrNil ifTrue:[^ self]. |
|
2087 |
nameOfVariable := nameOfVariable asSymbolIfInterned. |
|
2088 |
nameOfVariable isNil ifTrue:[^ self]. |
|
2089 |
cls := Smalltalk at:nameOfVariable. |
|
2090 |
cls isNil ifTrue:[^ self]. |
|
2091 |
cls isBehavior ifFalse:[^ self]. |
|
2092 |
insts := cls allInstances. |
|
2093 |
insts isEmpty ifTrue:[ |
|
2094 |
Dialog information:(resources string:'No instances of %1' with:nameOfVariable). |
|
2095 |
^ self. |
|
2096 |
]. |
|
2097 |
insts inspect. |
|
2098 |
! |
|
2099 |
||
418 | 2100 |
inspectIt |
2101 |
"user selected 'inspectIt' from menu; use doIt to evaluate the code |
|
2102 |
and start an inspector on the result" |
|
2103 |
||
2981
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
2104 |
|shifted| |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
2105 |
|
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
2106 |
shifted := self sensor shiftDown. |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
2107 |
|
5053 | 2108 |
^ self |
2109 |
do:(self selectionOrTextOfCursorLine) |
|
2110 |
withValueDo:[:result | shifted ifTrue:[result basicInspect] ifFalse:[result inspect] ] |
|
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
2111 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
2112 |
"Modified: / 16.5.1998 / 16:44:56 / cg" |
418 | 2113 |
! |
2114 |
||
2115 |
printIt |
|
2116 |
"user selected 'printIt' from menu; use doIt to evaluate the code |
|
2117 |
and insert result of evaluation into my text. |
|
2118 |
If the text is readOnly, do nothing." |
|
2119 |
||
1734 | 2120 |
self isReadOnly ifTrue:[ |
5148 | 2121 |
self beep. |
2122 |
^ self. |
|
3511 | 2123 |
]. |
5053 | 2124 |
self |
5148 | 2125 |
undoableDo:[ |
2126 |
self |
|
2127 |
do:(self selectionOrTextOfCursorLine) |
|
2128 |
withValueDo:[:result | |
|
5396 | 2129 |
|s printer lang| |
5148 | 2130 |
|
2131 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
|
5396 | 2132 |
"/ give the language a chance to generate a printString for that value |
2133 |
lang := self editedLanguage. |
|
2134 |
(lang notNil and:[(printer := lang valuePrinterClass) notNil]) ifTrue:[ |
|
5148 | 2135 |
s := printer printStringForPrintItOf:result |
2136 |
] ifFalse:[ |
|
6020 | 2137 |
result isProtoObject ifTrue:[ |
2138 |
s := result displayString. |
|
5148 | 2139 |
] ifFalse:[ |
6020 | 2140 |
(result isInteger |
2141 |
and:[ result > 10 |
|
2142 |
and:[ InspectorView defaultIntegerDisplayRadix ~= 10]]) ifTrue:[ |
|
2143 |
s := result displayString , ' "',(result radixPrintStringRadix: InspectorView defaultIntegerDisplayRadix),'"'. |
|
2144 |
] ifFalse:[ |
|
2145 |
s := result printStringForPrintIt "old: displayString" "very old: printString" |
|
2146 |
]. |
|
2147 |
] |
|
5148 | 2148 |
]. |
5565 | 2149 |
|
2150 |
self withAutoIndent:false do:[ |
|
2151 |
"/ if the returned string starts with a newLine, |
|
2152 |
"/ insert as a bunch of lines after the cursor line. |
|
2153 |
(s size > 0 and:[s startsWith:(Character cr)]) ifTrue:[ |
|
5566 | 2154 |
|cursorLine cursorCol lines| |
5565 | 2155 |
|
2156 |
cursorLine := self cursorLine. |
|
5566 | 2157 |
cursorCol := self cursorCol. |
5565 | 2158 |
lines := s asStringCollection copyFrom:2. |
5566 | 2159 |
self insertLines:lines before:cursorLine+((cursorCol == 1) ifTrue:0 ifFalse:1). |
5565 | 2160 |
self selectFromLine:cursorLine+1 toLine:cursorLine+lines size. |
2161 |
] ifFalse:[ |
|
2162 |
self insertSelectedStringAtCursor:s |
|
2163 |
] |
|
2164 |
] |
|
5148 | 2165 |
] |
2166 |
] |
|
2167 |
info:'PrintIt' |
|
3511 | 2168 |
|
4401 | 2169 |
"Modified: / 08-03-2012 / 16:14:34 / cg" |
3511 | 2170 |
! |
418 | 2171 |
|
4471 | 2172 |
profileIt |
2173 |
"user selected 'profileIt' from menu; show a wait-cursor, profile the code |
|
4472 | 2174 |
and finally restore the cursor. Open a visual profiler on the sample data." |
4471 | 2175 |
|
4472 | 2176 |
self spyOnItUsing:Tools::Profiler |
4471 | 2177 |
! |
2178 |
||
3511 | 2179 |
replaceIt |
2180 |
"like printIt, but replace the selection with the result, instead of |
|
2181 |
pasting it after the selection." |
|
2182 |
||
2183 |
self isReadOnly ifTrue:[ |
|
5053 | 2184 |
self beep. |
2185 |
^ self |
|
3511 | 2186 |
]. |
2187 |
||
5053 | 2188 |
self |
2189 |
undoableDo:[ |
|
2190 |
self |
|
2191 |
do:(self selectionOrTextOfCursorLine) |
|
2192 |
withValueDo:[:result | |
|
2193 |
self replaceSelectionBy:(result displayString "printString") |
|
2194 |
]. |
|
2195 |
undoSupport actionInfo:'ReplaceIt'. |
|
2196 |
] |
|
2197 |
info:'ReplaceIt' |
|
3511 | 2198 |
|
2199 |
"Created: / 08-11-2007 / 11:31:54 / cg" |
|
1501 | 2200 |
! |
2201 |
||
2202 |
spyOnIt |
|
2203 |
"user selected 'spyOnIt' from menu; show a wait-cursor, evaluate the code |
|
4472 | 2204 |
and finally restore the cursor. Show profile data on the Transcript" |
2205 |
||
2206 |
self spyOnItUsing:MessageTally |
|
2207 |
! |
|
2208 |
||
2209 |
spyOnItUsing:aProfiler |
|
2210 |
"common code for spyOnIt / profileIt. |
|
2211 |
Show a wait-cursor, evaluate the code with profier on it, |
|
2212 |
and finally restore the cursor. Show profile data as per profiler" |
|
1501 | 2213 |
|
5865 | 2214 |
|code codeToRun| |
2215 |
||
2216 |
codeToRun := self selectionOrTextOfCursorLine. |
|
2217 |
(codeToRun isEmptyOrNil or:[codeToRun isBlank]) ifTrue:[^ self]. |
|
2218 |
||
5504 | 2219 |
compilerClass == (Smalltalk at:#Compiler) ifFalse:[ |
5865 | 2220 |
"sigh - this measurement will include the time to compile - sigh" |
2221 |
aProfiler spyDetailedOn:[ self doIt ]. |
|
2222 |
^ self. |
|
4427 | 2223 |
]. |
2224 |
||
5865 | 2225 |
code := aProfiler name,' spyDetailedOn:[' , codeToRun, ']'. |
4149 | 2226 |
self do:code withValueDo:[:value| ]. |
1501 | 2227 |
! |
2228 |
||
2229 |
timeIt |
|
2230 |
"user selected 'timeIt' from menu; show a wait-cursor, evaluate the code |
|
2231 |
and finally restore cursor; return result of evaluation" |
|
2232 |
||
5135 | 2233 |
|code| |
4427 | 2234 |
|
5504 | 2235 |
compilerClass == (Smalltalk at:#Compiler) ifFalse:[ |
5135 | 2236 |
"sigh - this measurement will include the time to compile - sigh" |
2237 |
[ self doIt ] benchmark:'execution time: '. |
|
2238 |
^ self. |
|
4427 | 2239 |
]. |
1501 | 2240 |
|
5135 | 2241 |
code := '[' , self selectionAsString, '] benchmark:''execution time: '''. |
4149 | 2242 |
self do:code withValueDo:[:value | ]. |
1501 | 2243 |
|
4427 | 2244 |
"Modified: / 22-04-1998 / 22:03:51 / ca" |
2245 |
"Modified (format): / 02-06-2012 / 00:38:51 / cg" |
|
418 | 2246 |
! ! |
2247 |
||
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2248 |
!Workspace methodsFor:'misc'! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2249 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2250 |
expandAbbreviation |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2251 |
"after receiving an Alt-shift key-event, look for the string before the |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2252 |
cursor, find an abbrev for it and expand." |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2253 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2254 |
|expandedString abortExpandAction oldSelectionStartLine oldSelectionStartCol oldSelectionEndLine oldSelectionEndCol oldCursorLine oldCursorCol |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2255 |
newCursorPos replStartCol| |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2256 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2257 |
oldCursorLine := self cursorLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2258 |
oldCursorCol := self cursorCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2259 |
oldSelectionStartLine := self selectionStartLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2260 |
oldSelectionStartCol := self selectionStartCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2261 |
oldSelectionEndLine := self selectionEndLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2262 |
oldSelectionEndCol := self selectionEndCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2263 |
|
5053 | 2264 |
abortExpandAction := |
2265 |
[ |
|
2266 |
self |
|
2267 |
selectFromLine:oldSelectionStartLine col:oldSelectionStartCol |
|
2268 |
toLine:oldSelectionEndLine col:oldSelectionEndCol. |
|
2269 |
self cursorLine:oldCursorLine col:oldCursorCol. |
|
2270 |
]. |
|
4706 | 2271 |
|
2272 |
expandedString := self selectAbbreviationKeyBeforeCursor. "/ returns the new string AND selects the key |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2273 |
expandedString isNil ifTrue:[ |
5053 | 2274 |
abortExpandAction value. |
2275 |
^ self |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2276 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2277 |
newCursorPos := expandedString indexOf:$!!. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2278 |
newCursorPos ~~ 0 ifTrue:[ |
5053 | 2279 |
expandedString := expandedString copyWithout:$!!. |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2280 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2281 |
replStartCol := self selectionStartCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2282 |
self |
5053 | 2283 |
undoableDo:[ |
2284 |
self replaceSelectionBy: expandedString |
|
2285 |
] |
|
2286 |
info:'Replace'. |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2287 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2288 |
newCursorPos == 0 ifTrue:[ |
5053 | 2289 |
"/ cursor already fine (at the end) |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2290 |
] ifFalse:[ |
5053 | 2291 |
self cursorCol:replStartCol+newCursorPos-1 |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2292 |
] |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2293 |
! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2294 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2295 |
findAbbreviationKeyBeforeCursor |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2296 |
"after receiving an Alt-shift key-event, look for the string before the |
5053 | 2297 |
cursor, find an abbrev for it, return the key and the abbreviation for it. |
4706 | 2298 |
If none is found, return nil" |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2299 |
|
4745 | 2300 |
|snippets keys minMax maxKeyLen minKeyLen stringBeforeCursor| |
2301 |
||
5144 | 2302 |
snippets := self class snippets. |
4745 | 2303 |
keys := snippets keys. |
4714 | 2304 |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2305 |
minMax := (keys collect:[:k | k size]) minMax. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2306 |
minKeyLen := minMax first. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2307 |
maxKeyLen := minMax second. |
4714 | 2308 |
|
2309 |
stringBeforeCursor := self lineStringBeforeCursor. |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2310 |
maxKeyLen := maxKeyLen min:stringBeforeCursor size. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2311 |
|
4706 | 2312 |
maxKeyLen to:minKeyLen by:-1 do:[:keyLen | |
5144 | 2313 |
|lCharactersBeforeCursor expandedString| |
2314 |
||
2315 |
lCharactersBeforeCursor := stringBeforeCursor last:keyLen. |
|
2316 |
expandedString := snippets at:lCharactersBeforeCursor ifAbsent:nil. |
|
2317 |
expandedString notNil ifTrue:[ |
|
2318 |
^ { lCharactersBeforeCursor . expandedString withCRs } |
|
2319 |
]. |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2320 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2321 |
^ nil. |
4185 | 2322 |
|
2323 |
"Modified: / 29-10-2010 / 10:22:38 / cg" |
|
4617 | 2324 |
! |
2325 |
||
4706 | 2326 |
selectAbbreviationKeyBeforeCursor |
2327 |
"after receiving an Alt-shift key-event, look for the string before the |
|
5053 | 2328 |
cursor, find an abbrev for it, select it and return the abbreviation for it. |
4706 | 2329 |
If none is found, do not select and return nil" |
2330 |
||
4745 | 2331 |
|keyAndSnippet snippet key| |
2332 |
||
2333 |
(keyAndSnippet := self findAbbreviationKeyBeforeCursor) notNil ifTrue:[ |
|
5053 | 2334 |
key := keyAndSnippet first. |
2335 |
snippet := keyAndSnippet second. |
|
2336 |
self selectFromLine:cursorLine col:cursorCol-key size toLine:cursorLine col:cursorCol-1. |
|
2337 |
^ snippet |
|
4706 | 2338 |
]. |
2339 |
^ nil. |
|
2340 |
||
2341 |
"Modified: / 29-10-2010 / 10:22:38 / cg" |
|
2342 |
! |
|
2343 |
||
4617 | 2344 |
selectedTextOrSyntaxElement |
2345 |
|selectedText el| |
|
2346 |
||
2347 |
selectedText := self selectionAsString. |
|
2348 |
selectedText isEmptyOrNil ifTrue:[ |
|
5065 | 2349 |
el := self syntaxElementUnderCursor. |
2350 |
el notNil ifTrue:[ selectedText := el value ]. |
|
4617 | 2351 |
]. |
5053 | 2352 |
^ selectedText |
4998 | 2353 |
! |
2354 |
||
2355 |
syntaxElementForSelectorUnderCursor |
|
5065 | 2356 |
"we do not support syntax elements, but subclasses may do" |
2357 |
||
2358 |
^ nil |
|
2359 |
! |
|
2360 |
||
2361 |
syntaxElementUnderCursor |
|
2362 |
"we do not support syntax elements, but subclasses may do" |
|
4998 | 2363 |
|
2364 |
^ nil |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2365 |
! ! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2366 |
|
2646 | 2367 |
!Workspace methodsFor:'queries'! |
2368 |
||
2369 |
isWorkspace |
|
4395 | 2370 |
"back-query from the compiler to ask if this is an interactive view |
2371 |
(for error feedback)" |
|
2372 |
||
2646 | 2373 |
^ true |
4395 | 2374 |
|
2375 |
"Modified (comment): / 07-03-2012 / 17:52:59 / cg" |
|
5990 | 2376 |
! |
2377 |
||
2378 |
showLineLimitInMenu |
|
2379 |
^ false. |
|
2646 | 2380 |
! ! |
2381 |
||
206 | 2382 |
!Workspace class methodsFor:'documentation'! |
2383 |
||
4402 | 2384 |
version |
5396 | 2385 |
^ '$Header$' |
4402 | 2386 |
! |
2387 |
||
3959 | 2388 |
version_CVS |
5396 | 2389 |
^ '$Header$' |
858 | 2390 |
! ! |
5065 | 2391 |