author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 26 Jan 2018 11:43:24 +0000 | |
branch | jv |
changeset 6279 | 232954e959f7 |
parent 6021 | 6bc4a2c5506d |
child 6129 | 159be1289d8b |
child 6435 | 6466b859a54d |
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, |
4876 | 613 |
"/ and pairs define regular comment opening/closing seqeuences. |
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 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
617 |
"Created: / 9.11.1997 / 01:05:25 / cg" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
618 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
619 |
|
201 | 620 |
doItAction |
621 |
"return the action to be performed when 'doIt' is selected" |
|
32 | 622 |
|
201 | 623 |
^ doItAction |
0 | 624 |
! |
625 |
||
4584 | 626 |
doItAction:aOneArgBlock |
627 |
"define the action to be performed when 'doIt' is selected. |
|
5053 | 628 |
The block will be evaluated, passing the selection as a String argument. |
4584 | 629 |
A default doItAction is set for you in the initialize method." |
630 |
||
631 |
doItAction := aOneArgBlock |
|
632 |
||
633 |
"Modified: 27.2.1996 / 15:31:37 / cg" |
|
634 |
! |
|
635 |
||
4675 | 636 |
editedClass |
637 |
"for the code completion" |
|
638 |
||
639 |
editedMethodOrClass isNil ifTrue:[^ nil]. |
|
5621 | 640 |
^ editedMethodOrClass isBehavior |
641 |
ifTrue:[editedMethodOrClass] |
|
642 |
ifFalse:[editedMethodOrClass mclass] |
|
4675 | 643 |
! |
644 |
||
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
645 |
editedLanguage |
5595 | 646 |
|mthd cls| |
647 |
||
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
648 |
editedLanguage notNil ifTrue:[ |
5595 | 649 |
^ editedLanguage |
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
650 |
]. |
5595 | 651 |
(mthd := self editedMethod )notNil ifTrue:[ |
652 |
^ mthd programmingLanguage. |
|
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 |
(cls := self editedClass) notNil ifTrue:[ |
655 |
^ cls programmingLanguage. |
|
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
656 |
]. |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
657 |
^ nil |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
658 |
|
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
659 |
"Modified: / 18-09-2013 / 12:58:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
660 |
! |
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 |
editedLanguage:aProgrammingLanguageOrNil |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
663 |
editedLanguage := aProgrammingLanguageOrNil. |
5024 | 664 |
aProgrammingLanguageOrNil notNil ifTrue:[ |
5053 | 665 |
commentStrings := aProgrammingLanguageOrNil commentStrings. |
5024 | 666 |
]. |
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
667 |
! |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
668 |
|
4675 | 669 |
editedMethod |
670 |
"for the code completion" |
|
671 |
||
672 |
editedMethodOrClass isNil ifTrue:[^ nil]. |
|
5621 | 673 |
^ editedMethodOrClass isBehavior |
674 |
ifTrue:[nil] |
|
675 |
ifFalse:[editedMethodOrClass] |
|
4675 | 676 |
! |
677 |
||
4606 | 678 |
editedMethodOrClass |
679 |
"for the code completion" |
|
680 |
||
681 |
^ editedMethodOrClass. |
|
682 |
! |
|
683 |
||
684 |
editedMethodOrClass:aMethodOrClass |
|
685 |
"for the code completion" |
|
686 |
||
687 |
editedMethodOrClass := aMethodOrClass. |
|
688 |
! |
|
689 |
||
3007 | 690 |
errorBackgroundColor |
691 |
errorBgColor notNil ifTrue:[ ^ errorBgColor ]. |
|
692 |
DefaultErrorBackgroundColor notNil ifTrue:[ ^ DefaultErrorBackgroundColor ]. |
|
5621 | 693 |
device hasColors ifTrue:[ ^ Color red ]. |
3007 | 694 |
|
695 |
^ selectionBgColor |
|
696 |
! |
|
697 |
||
698 |
errorForegroundColor |
|
699 |
errorFgColor notNil ifTrue:[ ^ errorFgColor ]. |
|
700 |
DefaultErrorForegroundColor notNil ifTrue:[ ^ DefaultErrorForegroundColor ]. |
|
701 |
^ selectionFgColor |
|
702 |
! |
|
703 |
||
4815 | 704 |
nameSpaceForDoits |
705 |
"can be used by the embedding application to control doIt execution |
|
706 |
(especially: for tools like expecco, to provide better workspaces" |
|
707 |
||
708 |
^ namespaceForDoits ? Smalltalk |
|
709 |
! |
|
710 |
||
4436 | 711 |
nameSpaceForDoits:aNameSpaceOrNil |
712 |
"can be used by the embedding application to control doIt execution |
|
713 |
(especially: for tools like expecco, to provide better workspaces" |
|
714 |
||
715 |
namespaceForDoits := aNameSpaceOrNil. |
|
716 |
||
717 |
"Created: / 26-07-2012 / 23:06:04 / cg" |
|
718 |
! |
|
719 |
||
4391 | 720 |
namespaceForDoits:aNameSpaceOrNil |
721 |
"can be used by the embedding application to control doIt execution |
|
722 |
(especially: for tools like expecco, to provide better workspaces" |
|
723 |
||
4436 | 724 |
<resource: #obsolete> |
725 |
||
4391 | 726 |
namespaceForDoits := aNameSpaceOrNil. |
727 |
||
728 |
"Created: / 04-03-2012 / 13:34:51 / cg" |
|
729 |
! |
|
730 |
||
731 |
poolsConsideredInDoIts:aCollectionOfPools |
|
732 |
"can be used by the embedding application to control doIt execution |
|
733 |
(especially: for tools like expecco, to provide better workspaces" |
|
734 |
||
735 |
poolsConsideredInDoIts := aCollectionOfPools. |
|
736 |
||
737 |
"Modified (format): / 04-03-2012 / 13:35:00 / cg" |
|
3537 | 738 |
! |
739 |
||
2601 | 740 |
simulatedSelf:anObject |
741 |
"define what self is in an evaluation" |
|
742 |
||
743 |
simulatedSelf := anObject |
|
3007 | 744 |
! |
745 |
||
746 |
warningBackgroundColor |
|
747 |
DefaultWarningBackgroundColor notNil ifTrue:[ ^ DefaultWarningBackgroundColor ]. |
|
5621 | 748 |
device hasColors ifTrue:[ ^ Color orange ]. |
3007 | 749 |
|
750 |
^ selectionBgColor |
|
751 |
! |
|
752 |
||
753 |
warningForegroundColor |
|
754 |
DefaultWarningForegroundColor notNil ifTrue:[ ^ DefaultWarningForegroundColor ]. |
|
755 |
^ selectionFgColor |
|
201 | 756 |
! ! |
757 |
||
758 |
!Workspace methodsFor:'compiler interface'! |
|
759 |
||
2303 | 760 |
compilerClass |
4432
2eaf85d92e62
corrected switching languages between tabs
Claus Gittinger <cg@exept.de>
parents:
4427
diff
changeset
|
761 |
^ compilerClass "? Compiler" |
2eaf85d92e62
corrected switching languages between tabs
Claus Gittinger <cg@exept.de>
parents:
4427
diff
changeset
|
762 |
|
2eaf85d92e62
corrected switching languages between tabs
Claus Gittinger <cg@exept.de>
parents:
4427
diff
changeset
|
763 |
"Modified: / 19-07-2012 / 17:04:35 / cg" |
2980 | 764 |
! |
765 |
||
766 |
compilerClass:aCompilerClass |
|
767 |
compilerClass := aCompilerClass |
|
2303 | 768 |
! |
769 |
||
201 | 770 |
currentSourceCode |
771 |
"special interface to compiler - called by parser |
|
772 |
to get the updated source code after a corrected error" |
|
773 |
||
774 |
^ self contents |
|
0 | 775 |
! |
776 |
||
201 | 777 |
wantChangeLog |
778 |
"sent by the compiler to ask if a changeLog entry should |
|
779 |
be written. Return true here." |
|
0 | 780 |
|
201 | 781 |
^ true |
0 | 782 |
! ! |
783 |
||
2754 | 784 |
!Workspace methodsFor:'compiler interface-error handling'! |
0 | 785 |
|
201 | 786 |
correctableError:aString position:relPos to:relEndPos from:aCompiler |
787 |
"compiler notifies us of a correctable error; |
|
788 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
789 |
this method should return true to the compiler if user wants the error |
|
790 |
to be corrected; false otherwise" |
|
791 |
||
5680 | 792 |
|action sameForAllHolder possibleFixes |
793 |
doNotShowAgainHolder doNotShowAgainForThisMethodHolder doNotShowAgainForThisReceiverSelectorHolder| |
|
4675 | 794 |
|
795 |
"/ the declare/correct fixes are here for backward compatibility |
|
796 |
"/ (in previous versions, these two were always offered as fix, |
|
797 |
"/ and compilers which honor the old interface will not anwer the PossibleCorrectionsQuery) |
|
798 |
possibleFixes := Parser possibleCorrectionsQuery query. |
|
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
799 |
|
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
800 |
sameForAllHolder := false asValue. |
201 | 801 |
|
802 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
5290 | 803 |
doNotShowAgainHolder := false asValue. |
804 |
doNotShowAgainForThisMethodHolder := false asValue. |
|
5680 | 805 |
doNotShowAgainForThisReceiverSelectorHolder := false asValue. |
5290 | 806 |
|
807 |
Dialog modifyingBoxWith:[:box | |
|
808 |
|declareButton makeSpaceOnlyOnce| |
|
809 |
||
810 |
(box isKindOf:OptionBox) ifTrue:[ |
|
811 |
"/ a bad hack for subDialogs... needs fix |
|
812 |
makeSpaceOnlyOnce := [ box addVerticalSpace:10. makeSpaceOnlyOnce := nil ]. |
|
813 |
||
814 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
|
815 |
makeSpaceOnlyOnce value. |
|
816 |
box verticalPanel |
|
817 |
add:(CheckBox |
|
818 |
label: "addCheckBoxAtBottom:" 'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
819 |
model:doNotShowAgainHolder). |
|
820 |
]. |
|
5680 | 821 |
DoNotShowCompilerWarningAgainForThisReceiverSelectorActionQuery isHandled ifTrue:[ |
822 |
makeSpaceOnlyOnce value. |
|
823 |
box verticalPanel |
|
824 |
add:(CheckBox |
|
825 |
label:(resources string:'Do not warn for this receiver>>selector combination (reenable earlier via Launcher''s settings dialog)') |
|
826 |
model:doNotShowAgainForThisReceiverSelectorHolder). |
|
827 |
]. |
|
5290 | 828 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
829 |
makeSpaceOnlyOnce value. |
|
830 |
box verticalPanel |
|
831 |
add:(CheckBox |
|
832 |
label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
|
833 |
model:doNotShowAgainForThisMethodHolder). |
|
834 |
]. |
|
835 |
SameForAllNotification isHandled ifTrue:[ |
|
836 |
box addVerticalSpace:10. |
|
837 |
box addCheckBoxAtBottom:'Same action for all' on:sameForAllHolder |
|
838 |
]. |
|
839 |
||
840 |
declareButton := box buttons at:2. |
|
841 |
declareButton pressAction:declareButton controller releaseAction. |
|
842 |
declareButton controller beTriggerOnDown. |
|
843 |
] |
|
844 |
] do:[ |
|
845 |
|buttonLabels actions| |
|
846 |
||
847 |
buttonLabels := OrderedCollection new. |
|
848 |
actions := OrderedCollection new. |
|
849 |
buttonLabels add:'Cancel'. actions add:#abort. |
|
850 |
possibleFixes do:[:each | |
|
851 |
buttonLabels add:(each buttonLabel). actions add:each. |
|
852 |
]. |
|
853 |
buttonLabels add:'Continue'. actions add:#continue. |
|
854 |
||
855 |
action := OptionBox |
|
856 |
request:aString |
|
857 |
label:(resources string:'Correctable Error') |
|
858 |
image:(WarningBox iconBitmap) |
|
859 |
buttonLabels:(resources array:buttonLabels) |
|
860 |
values:actions |
|
861 |
default:#continue |
|
862 |
onCancel:#abort. |
|
863 |
]. |
|
201 | 864 |
]. |
865 |
||
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
866 |
sameForAllHolder value ifTrue:[ |
5290 | 867 |
SameForAllNotification notify |
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
868 |
]. |
4691 | 869 |
doNotShowAgainHolder value == true ifTrue:[ |
5290 | 870 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
4691 | 871 |
]. |
872 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
|
5290 | 873 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
4691 | 874 |
]. |
5680 | 875 |
doNotShowAgainForThisReceiverSelectorHolder value == true ifTrue:[ |
876 |
DoNotShowCompilerWarningAgainForThisReceiverSelectorActionQuery actionQuery value |
|
877 |
]. |
|
4691 | 878 |
|
4675 | 879 |
action == #cancel ifTrue:[ |
5290 | 880 |
^ false |
4675 | 881 |
]. |
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
882 |
|
201 | 883 |
action == #abort ifTrue:[ |
5290 | 884 |
AbortOperationRequest raise. |
885 |
^ false |
|
201 | 886 |
]. |
4675 | 887 |
^ action |
368 | 888 |
|
4386 | 889 |
"Modified: / 28-02-2012 / 10:42:27 / cg" |
201 | 890 |
! |
891 |
||
2104 | 892 |
correctableSelectorWarning:aString position:relPos to:relEndPos from:aCompiler |
893 |
"compiler notifies us of a correctable selector warning; |
|
894 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
895 |
this method should return true to the compiler if user wants the error |
|
896 |
to be corrected; false otherwise" |
|
897 |
||
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
898 |
|action doNotShowAgainHolder| |
2104 | 899 |
|
3261 | 900 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
5053 | 901 |
doNotShowAgainHolder := false asValue. |
902 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
|
903 |
MessageNotUnderstood catch:[ |
|
904 |
(aCompiler notNil and:[DoNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
|
905 |
ex box addCheckBoxAtBottom:'Do not show this dialog again (reenable via Launchers Settings Dialog)' on:doNotShowAgainHolder. |
|
906 |
]. |
|
907 |
]. |
|
908 |
] do:[ |
|
909 |
action := OptionBox |
|
910 |
request:aString |
|
911 |
label:(resources string:'Warning') |
|
912 |
image:(WarningBox iconBitmap) |
|
913 |
buttonLabels:(resources array:#('Cancel' 'Correct...' 'Generate' 'Continue')) |
|
914 |
values:#(#abort #correct #generate #continue) |
|
915 |
default:#continue |
|
916 |
onCancel:#abort. |
|
917 |
]. |
|
918 |
doNotShowAgainHolder value == true ifTrue:[ |
|
919 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
|
920 |
]. |
|
2104 | 921 |
]. |
922 |
||
2338 | 923 |
action == #generate ifTrue:[ |
5053 | 924 |
^ action |
2338 | 925 |
]. |
926 |
||
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
927 |
(action isNil or:[action == #abort]) ifTrue:[ |
5053 | 928 |
AbortOperationRequest raise. |
929 |
^ false |
|
2104 | 930 |
]. |
931 |
^ action == #correct |
|
932 |
||
4386 | 933 |
"Created: / 19-01-2000 / 16:27:28 / cg" |
934 |
"Modified: / 28-02-2012 / 10:42:37 / cg" |
|
2104 | 935 |
! |
936 |
||
4188
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
937 |
correctableWarning:aString position:relPos to:relEndPos from:aCompiler |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
938 |
"compiler notifies us of a correctable warning; |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
939 |
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
|
940 |
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
|
941 |
to be corrected; false otherwise" |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
942 |
|
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
943 |
^ self correctableError:aString position:relPos to:relEndPos from:aCompiler |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
944 |
|
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
945 |
"Created: / 02-11-2010 / 13:29:01 / cg" |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
946 |
! |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
947 |
|
201 | 948 |
error:aString position:relPos to:relEndPos asWarning:asWarning |
2277 | 949 |
"obsolete - no longer invoked" |
950 |
||
951 |
^ self error:aString position:relPos to:relEndPos from:nil asWarning:asWarning |
|
952 |
! |
|
953 |
||
954 |
error:aString position:relPos to:relEndPos from:aCompiler |
|
5053 | 955 |
"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
|
956 |
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
|
957 |
Return true for correction, false of not (or not possible)" |
2277 | 958 |
|
959 |
^ 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
|
960 |
|
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
961 |
"Modified (Comment): / 30-06-2011 / 19:47:36 / cg" |
2277 | 962 |
! |
963 |
||
964 |
error:aString position:relPos to:relEndPos from:aCompiler asWarning:asWarning |
|
3397 | 965 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
201 | 966 |
and show a Box asking for continue/abort." |
967 |
||
3007 | 968 |
|answer fg bg| |
201 | 969 |
|
3007 | 970 |
fg := asWarning ifTrue:[ self warningForegroundColor ] ifFalse:[ self errorForegroundColor ]. |
971 |
bg := asWarning ifTrue:[ self warningBackgroundColor ] ifFalse:[ self errorBackgroundColor ]. |
|
201 | 972 |
|
3397 | 973 |
self |
5290 | 974 |
highlightingErrorPosition:relPos to:relEndPos |
975 |
withForeground:fg andBackground:bg |
|
976 |
do:[ |
|
977 |
|box lbl doNotShowAgainHolder doNotShowAgainForThisMethodHolder l1 y1 y2 l2| |
|
201 | 978 |
|
4170
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
979 |
"/ Warning isHandled ifTrue:[ |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
980 |
"/ Warning raiseErrorString:aString. |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
981 |
"/ ^ false |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
982 |
"/ ]. |
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
983 |
|
5290 | 984 |
lbl := aCompiler isNil ifTrue:['Compiler'] ifFalse:[aCompiler class name]. |
985 |
asWarning ifTrue:[ |
|
986 |
lbl := lbl , ' Warning' |
|
987 |
] ifFalse:[ |
|
988 |
lbl := lbl , ' Error'. |
|
989 |
]. |
|
990 |
||
991 |
" |
|
992 |
ask if we should abort or continue |
|
993 |
" |
|
994 |
Dialog modifyingBoxWith:[:box | |
|
995 |
|makeSpace| |
|
996 |
||
997 |
doNotShowAgainHolder := false asValue. |
|
998 |
doNotShowAgainForThisMethodHolder := false asValue. |
|
999 |
||
1000 |
box label:lbl. |
|
1001 |
box perform:#image: with:(WarningBox iconBitmap) ifNotUnderstood:[]. |
|
1002 |
||
1003 |
aCompiler notNil ifTrue:[ |
|
1004 |
makeSpace := [ box addVerticalSpace:10. makeSpace := nil ]. |
|
1005 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
|
1006 |
makeSpace value. |
|
1007 |
box verticalPanel |
|
1008 |
add:(CheckBox label:'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
1009 |
model:doNotShowAgainHolder). |
|
1010 |
]. |
|
1011 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
|
1012 |
makeSpace value. |
|
1013 |
box verticalPanel |
|
1014 |
add:(CheckBox label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
|
1015 |
model:doNotShowAgainForThisMethodHolder). |
|
1016 |
]. |
|
1017 |
]. |
|
1018 |
] do:[ |
|
1019 |
answer := OptionBox |
|
1020 |
request:aString |
|
1021 |
buttonLabels:(resources array:#('Abort' "'Keep Selected'" 'Continue')) |
|
1022 |
values:#(false "#keepSelected" true) |
|
1023 |
default:(asWarning ifTrue:true ifFalse:false). |
|
1024 |
answer := answer ? false. "/ if escaped |
|
1025 |
]. |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1026 |
"/ box := YesNoBox |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1027 |
"/ title:aString |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1028 |
"/ yesText:(resources string:'Continue') |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1029 |
"/ noText:(resources string:'Abort'). |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1030 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1031 |
"/ box label:lbl. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1032 |
"/ box image:(WarningBox iconBitmap). |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1033 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1034 |
"/ (aCompiler notNil and:[DoNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1035 |
"/ doNotShowAgainHolder := false asValue. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1036 |
"/ 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
|
1037 |
"/ ]. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1038 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1039 |
"/ "/ answer := box confirm. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1040 |
"/ answer := box confirm. |
3007 | 1041 |
|
5290 | 1042 |
doNotShowAgainHolder value == true ifTrue:[ |
1043 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
|
1044 |
]. |
|
1045 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
|
1046 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
|
1047 |
]. |
|
3007 | 1048 |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1049 |
"/ box destroy. |
5290 | 1050 |
]. |
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
1051 |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1052 |
answer == #keepSelected ifTrue:[ |
5290 | 1053 |
self hideCursor. |
1054 |
"redraw selection in normal color" |
|
1055 |
self invalidate. |
|
1056 |
AbortOperationRequest raise. |
|
4274
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 |
|
201 | 1059 |
" |
1060 |
do the abort if we have to |
|
1061 |
" |
|
3397 | 1062 |
answer ifFalse:[ |
5290 | 1063 |
"redraw selection in normal color" |
1064 |
self invalidate. |
|
1065 |
AbortOperationRequest raise. |
|
201 | 1066 |
]. |
1067 |
^ 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
|
1068 |
|
4170
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
1069 |
"Created: / 24-11-1995 / 22:56:34 / cg" |
4398 | 1070 |
"Modified: / 08-03-2012 / 10:24:21 / cg" |
201 | 1071 |
! |
1072 |
||
2663 | 1073 |
highlightingErrorLine:lineNr do:aBlock |
1074 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
1075 |
||
1076 |
|linePosition| |
|
1077 |
||
1078 |
linePosition := self characterPositionOfLine:lineNr col:1. |
|
1079 |
self highlightingErrorPosition:linePosition to:nil do:aBlock |
|
1080 |
! |
|
1081 |
||
59 | 1082 |
highlightingErrorPosition:relPos to:relEndPos do:aBlock |
1083 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
58 | 1084 |
|
5053 | 1085 |
self |
1086 |
highlightingErrorPosition:relPos to:relEndPos |
|
1087 |
withForeground:(self errorForegroundColor) andBackground:(self errorBackgroundColor) |
|
1088 |
do:aBlock |
|
3007 | 1089 |
! |
1090 |
||
1091 |
highlightingErrorPosition:relPos to:relEndPos withForeground:hilightFg andBackground:hilightBg do:aBlock |
|
1092 |
"evaluate aBlock while some selection is shown highlighted with colors passed as args." |
|
1093 |
||
1094 |
|absPosition oldFg oldBg| |
|
0 | 1095 |
|
58 | 1096 |
" |
1097 |
change color of selection & hide cursor |
|
1098 |
" |
|
3007 | 1099 |
oldFg := selectionFgColor. |
1100 |
oldBg := selectionBgColor. |
|
1101 |
selectionBgColor := hilightBg. |
|
1102 |
selectionFgColor := hilightFg. |
|
58 | 1103 |
self hideCursor. |
0 | 1104 |
|
58 | 1105 |
" |
1106 |
select the text - relEndPos may be nil in which case the whole line is selected |
|
1107 |
we have to adjust the positions given by the compiler, since they |
|
1108 |
are relative to the texts start (the compiler did stream-read the code). |
|
1109 |
" |
|
0 | 1110 |
codeStartPosition isNil ifTrue:[codeStartPosition := 1]. |
3427 | 1111 |
absPosition := codeStartPosition + (relPos ? 1) - 1. |
0 | 1112 |
relEndPos isNil ifTrue:[ |
5053 | 1113 |
self selectFromCharacterPosition:absPosition. |
1114 |
"/ self selectLineWhereCharacterPosition:absPosition. |
|
0 | 1115 |
] ifFalse:[ |
5053 | 1116 |
self selectFromCharacterPosition:absPosition to:(codeStartPosition + (relEndPos ? 1) - 1) |
0 | 1117 |
]. |
4273
4e9e823f9e41
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4252
diff
changeset
|
1118 |
expandingTop := true. "/ hack to make the top of the selection visible |
0 | 1119 |
self makeSelectionVisible. |
1120 |
||
4921 | 1121 |
self flush. |
58 | 1122 |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
1123 |
aBlock ensure:[ |
5053 | 1124 |
" |
1125 |
undo selection color change and show cursor again |
|
1126 |
" |
|
1127 |
selectionFgColor := oldFg. |
|
1128 |
selectionBgColor := oldBg. |
|
1129 |
self showCursor. |
|
0 | 1130 |
]. |
3427 | 1131 |
|
4273
4e9e823f9e41
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4252
diff
changeset
|
1132 |
"Modified: / 30-06-2011 / 17:24:04 / cg" |
0 | 1133 |
! |
1134 |
||
3007 | 1135 |
highlightingWarningPosition:relPos to:relEndPos do:aBlock |
1136 |
"evaluate aBlock while some selection is shown highlighted with warning colors." |
|
1137 |
||
5053 | 1138 |
self |
1139 |
highlightingErrorPosition:relPos to:relEndPos |
|
1140 |
withForeground:(self warningForegroundColor) andBackground:(self warningBackgroundColor) |
|
1141 |
do:aBlock |
|
3007 | 1142 |
! |
1143 |
||
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1144 |
unusedVariableWarning:aString position:relPos to:relEndPos from:aCompiler |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1145 |
"compiler notifies us of a (or some) unused variables; |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1146 |
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
|
1147 |
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
|
1148 |
to be corrected; false otherwise" |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1149 |
|
4386 | 1150 |
|action doNotShowAgainHolder doNotShowAgainForThisMethodHolder| |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1151 |
|
3007 | 1152 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
5290 | 1153 |
doNotShowAgainHolder := false asValue. |
1154 |
doNotShowAgainForThisMethodHolder := false asValue. |
|
1155 |
Dialog modifyingBoxWith:[:box | |
|
1156 |
|makeSpace| |
|
1157 |
||
1158 |
aCompiler notNil ifTrue:[ |
|
1159 |
makeSpace := [ box addVerticalSpace:10. makeSpace := nil ]. |
|
1160 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
|
1161 |
makeSpace value. |
|
1162 |
box verticalPanel |
|
1163 |
add:(CheckBox |
|
1164 |
label: "addCheckBoxAtBottom:" 'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
1165 |
model:doNotShowAgainHolder). |
|
1166 |
]. |
|
1167 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
|
1168 |
makeSpace value. |
|
1169 |
box verticalPanel |
|
1170 |
add:(CheckBox |
|
1171 |
label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
|
1172 |
model:doNotShowAgainForThisMethodHolder). |
|
1173 |
]. |
|
1174 |
]. |
|
1175 |
] do:[ |
|
1176 |
action := OptionBox |
|
1177 |
request:aString |
|
1178 |
label:(resources string:'Warning') |
|
1179 |
image:(WarningBox iconBitmap) |
|
1180 |
buttonLabels:(resources array:#('Cancel' 'Remove Variable(s)' 'Continue')) |
|
1181 |
values:#(#abort #correct #continue) |
|
1182 |
default:#continue. |
|
1183 |
action isNil ifTrue:[ action := #abort]. |
|
1184 |
]. |
|
1185 |
doNotShowAgainHolder value == true ifTrue:[ |
|
1186 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
|
1187 |
]. |
|
1188 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
|
1189 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
|
1190 |
]. |
|
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1191 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1192 |
|
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1193 |
action == #abort ifTrue:[ |
5290 | 1194 |
"/ self halt. |
1195 |
AbortOperationRequest raise. |
|
1196 |
^ false |
|
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1197 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1198 |
^ action == #correct |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
1199 |
|
4398 | 1200 |
"Modified: / 08-03-2012 / 10:23:58 / cg" |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1201 |
! |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1202 |
|
5053 | 1203 |
warning:aString position:relPos to:relEndPos from:aCompiler |
32 | 1204 |
"compiler notifies us of a warning - same behavior as error" |
0 | 1205 |
|
5053 | 1206 |
self error:aString position:relPos to:relEndPos from:aCompiler asWarning:true |
0 | 1207 |
! ! |
1208 |
||
3396 | 1209 |
!Workspace methodsFor:'drag & drop'! |
1210 |
||
1211 |
canDrop:aDropContext |
|
4090 | 1212 |
"if allowValueDrop is true, any text- or file-object can be dropped into workspace |
1213 |
(printString); otherwise, only ..." |
|
1214 |
||
1215 |
self isReadOnly ifTrue:[^ false]. |
|
3396 | 1216 |
|
4090 | 1217 |
allowValueDrop ifTrue:[^ true]. |
1218 |
^ super canDrop:aDropContext |
|
3428 | 1219 |
|
5053 | 1220 |
"/ ^ aDropContext dropObjects |
4090 | 1221 |
"/ contains:[:someObject| (someObject isTextObject or:[ someObject isFileObject ])]. |
3396 | 1222 |
|
1223 |
"Created: / 16-08-2005 / 22:01:13 / janfrog" |
|
3428 | 1224 |
"Modified: / 28-11-2006 / 16:18:51 / cg" |
3396 | 1225 |
! |
1226 |
||
3414 | 1227 |
doDrop:aDropContext |
4631 | 1228 |
<resource: #obsolete> |
1229 |
self obsoleteMethodWarning:'should no longer be reached'. |
|
3428 | 1230 |
self drop:aDropContext |
3414 | 1231 |
|
3428 | 1232 |
"Modified: / 28-11-2006 / 16:14:51 / cg" |
4386 | 1233 |
"Modified (format): / 28-02-2012 / 11:20:38 / cg" |
3414 | 1234 |
! |
1235 |
||
1236 |
drop:aDropContext |
|
1237 |
"Any object can be dropped into workspace..." |
|
1238 |
||
3870 | 1239 |
|textObjects nonTextObjects answer text| |
1240 |
||
5053 | 1241 |
textObjects := aDropContext dropObjects |
1242 |
select:[:dropObject | dropObject isTextObject |
|
1243 |
or:[ dropObject isFileObject ]]. |
|
1244 |
nonTextObjects := aDropContext dropObjects |
|
1245 |
reject:[:dropObject | dropObject isTextObject |
|
1246 |
or:[ dropObject isFileObject ]]. |
|
3870 | 1247 |
|
1248 |
self dropObjects:textObjects. |
|
3414 | 1249 |
|
3870 | 1250 |
nonTextObjects notEmpty ifTrue:[ |
5053 | 1251 |
answer := Dialog |
1252 |
confirmWithCancel:(resources |
|
1253 |
string:'Drop as textual representation or as object reference ?') |
|
1254 |
labels:(resources array:#('Cancel' 'Reference' 'Name' 'Text')) |
|
1255 |
values:#(nil #ref #name #text) |
|
1256 |
default:4. |
|
1257 |
answer isNil ifTrue:[^ self]. |
|
1258 |
(answer == #text or:[answer == #name]) ifTrue:[ |
|
1259 |
text := String streamContents:[:s | |
|
1260 |
nonTextObjects do:[:dropObject | |
|
1261 |
|obj| |
|
3870 | 1262 |
|
5053 | 1263 |
obj := dropObject theObject. |
1264 |
obj isMethod ifTrue:[ |
|
1265 |
s nextPutAll:(answer == #name ifTrue:[obj selector] ifFalse:[obj source]). |
|
1266 |
] ifFalse:[ |
|
1267 |
obj isClass ifTrue:[ |
|
1268 |
s nextPutAll:(answer == #name ifTrue:[obj name] ifFalse:[obj source asString]) |
|
1269 |
] ifFalse:[ |
|
1270 |
s nextPutAll:(answer == #name ifTrue:[obj className] ifFalse:[obj printString]) . |
|
1271 |
]. |
|
1272 |
]. |
|
1273 |
]. |
|
1274 |
]. |
|
1275 |
self paste:text. |
|
1276 |
] ifFalse:[ |
|
1277 |
nonTextObjects do:[:dropObject | |
|
1278 |
name := Dialog |
|
1279 |
request:(resources |
|
1280 |
string:'Name of the new Workspace Variable (refers to the dropped %1):' |
|
1281 |
with:dropObject theObject class name allBold |
|
1282 |
) |
|
1283 |
initialAnswer:'droppedObject' |
|
1284 |
okLabel:'Add' |
|
1285 |
title:'Enter Variable Name'. |
|
3414 | 1286 |
|
5053 | 1287 |
name notEmptyOrNil ifTrue:[ |
1288 |
Workspace addWorkspaceVariable:name. |
|
1289 |
Workspace workspaceVariableAt:name put:dropObject theObject. |
|
1290 |
self paste:name. |
|
1291 |
]. |
|
1292 |
]. |
|
1293 |
] |
|
3414 | 1294 |
]. |
1295 |
||
1296 |
"Created: / 13-10-2006 / 17:34:07 / cg" |
|
3396 | 1297 |
! ! |
1298 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1299 |
!Workspace methodsFor:'editing'! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1300 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1301 |
commentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1302 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1303 |
All lines from line1 to line2 get an end-of-line comment |
5053 | 1304 |
in the first col |
1925 | 1305 |
(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
|
1306 |
|
6016 | 1307 |
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
|
1308 |
|
3403 | 1309 |
"Created: / 09-11-1997 / 01:05:35 / cg" |
1310 |
"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
|
1311 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1312 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1313 |
commentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1314 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1315 |
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
|
1316 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1317 |
|
6016 | 1318 |
self commentSelection:commentStrings |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1319 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1320 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
1481 | 1321 |
"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
|
1322 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1323 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1324 |
uncommentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1325 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1326 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 1327 |
in the first col. |
1328 |
(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
|
1329 |
|
6016 | 1330 |
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
|
1331 |
|
3403 | 1332 |
"Created: / 09-11-1997 / 01:05:43 / cg" |
1333 |
"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
|
1334 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1335 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1336 |
uncommentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1337 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1338 |
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
|
1339 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1340 |
|
6016 | 1341 |
self uncommentSelection:commentStrings |
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 |
"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
|
1344 |
"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
|
1345 |
! ! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1346 |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1347 |
!Workspace methodsFor:'event handling'! |
3712 | 1348 |
|
0 | 1349 |
keyPress:key x:x y:y |
5053 | 1350 |
<resource: #keyboard (#DoIt #InspectIt #PrintIt #ReplaceIt |
1351 |
#BrowseIt #ImplementorsOfIt #ExpandAbbreviation |
|
1352 |
#CommentSelection #UncommentSelection)> |
|
60 | 1353 |
|
3800 | 1354 |
(key == #DoIt) ifTrue:[self doIt. ^ self]. |
1355 |
(key == #InspectIt) ifTrue:[self inspectIt. ^ self]. |
|
1356 |
(key == #PrintIt) ifTrue:[self printIt. ^ self]. |
|
1357 |
(key == #ReplaceIt) ifTrue:[self replaceIt. ^ self]. |
|
1358 |
(key == #BrowseIt) ifTrue:[self browseIt. ^ self]. |
|
1359 |
(key == #ImplementorsOfIt) ifTrue:[self browseImplementorsOfIt. ^ self]. |
|
1360 |
(key == #ExpandAbbreviation) ifTrue:[self expandAbbreviation. ^ self]. |
|
4587 | 1361 |
(key == #CommentSelection) ifTrue:[self commentSelection. ^ self]. |
1362 |
(key == #UncommentSelection) ifTrue:[self uncommentSelection. ^ self]. |
|
38 | 1363 |
|
0 | 1364 |
super keyPress:key x:x y:y |
3511 | 1365 |
|
1366 |
"Modified: / 08-11-2007 / 11:29:45 / cg" |
|
0 | 1367 |
! ! |
201 | 1368 |
|
2143 | 1369 |
!Workspace methodsFor:'executing'! |
201 | 1370 |
|
1501 | 1371 |
do:code withValueDo:aBlock |
5053 | 1372 |
"helper for doIt, printIt and inspectIt. |
1373 |
Evaluate the selection and, if all went well, evaluate the argument, |
|
418 | 1374 |
aBlock with the value. |
1375 |
Most work is in preparing for proper cleanup in case of abort |
|
1376 |
or other exception while the evaluation is performed. |
|
1377 |
(restore cursor, selectionColors etc.)" |
|
201 | 1378 |
|
4149 | 1379 |
|selLine selCol endLine endCol cLine cCol cleanUp executeBlock| |
201 | 1380 |
|
1381 |
code notNil ifTrue:[ |
|
5053 | 1382 |
code asString withoutSeparators isEmpty ifTrue:[ ^ self ]. |
2408 | 1383 |
|
5053 | 1384 |
codeStartPosition := self characterPositionOfSelection. |
201 | 1385 |
|
5053 | 1386 |
" |
1387 |
remember selection for later - if there is an error, |
|
1388 |
the notification method will highlight it. |
|
1389 |
thus destroying the current selection |
|
1390 |
" |
|
1391 |
selLine := selectionStartLine. |
|
1392 |
selCol := selectionStartCol. |
|
1393 |
endLine := selectionEndLine. |
|
1394 |
endCol := selectionEndCol. |
|
1395 |
cCol := cursorCol. |
|
1396 |
cLine := cursorLine. |
|
201 | 1397 |
|
5053 | 1398 |
" |
1399 |
cleanup: restore previous selection and cursor positions |
|
1400 |
" |
|
1401 |
cleanUp := [ |
|
1402 |
self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
|
1403 |
cLine notNil ifTrue:[ |
|
1404 |
self cursorLine:cLine col:cCol |
|
1405 |
]. |
|
1406 |
]. |
|
201 | 1407 |
|
5053 | 1408 |
" |
1409 |
perform the action. |
|
1410 |
Be careful to release the reference to the value; |
|
1411 |
otherwise, we could keep lots of garbage from being freed |
|
1412 |
until the view gets closed |
|
1413 |
" |
|
1414 |
executeBlock := [ |
|
1415 |
[ |
|
1416 |
AbortOperationRequest handle:[:ex | |
|
1417 |
"/ aBlock value:'** Abortsignal caught **'. |
|
1418 |
ex return |
|
1419 |
] do:[ |
|
1420 |
|value| |
|
929 | 1421 |
|
5053 | 1422 |
doItAction notNil ifTrue:[ |
1423 |
value := doItAction value:(code asString). |
|
1424 |
cleanUp value. cleanUp := nil. |
|
1425 |
aBlock notNil ifTrue:[ |
|
1426 |
aBlock value:value. |
|
1427 |
]. |
|
1428 |
value := nil. |
|
1429 |
self class rememberDoIt:code. |
|
1430 |
] |
|
1431 |
] |
|
1432 |
] ensure:[ |
|
1433 |
cleanUp notNil ifTrue:[ |
|
1434 |
cleanUp value. cleanUp := nil |
|
1435 |
]. |
|
1436 |
] |
|
1437 |
]. |
|
1438 |
aBlock isNil ifTrue:[ |
|
1439 |
"no action is performed with the result - give the user a visible |
|
1440 |
feedback, that something has been done" |
|
1441 |
self topView withVisibleCursor:Cursor execute do:executeBlock. |
|
1442 |
] ifFalse:[ |
|
1443 |
self topView withCursor:Cursor execute do:executeBlock. |
|
1444 |
]. |
|
201 | 1445 |
] |
257 | 1446 |
|
1501 | 1447 |
"Modified: / 22.4.1998 / 21:56:13 / ca" |
1448 |
"Created: / 22.4.1998 / 21:57:05 / ca" |
|
2409 | 1449 |
"Modified: / 26.9.2001 / 17:32:59 / cg" |
4677 | 1450 |
! |
201 | 1451 |
|
2733 | 1452 |
executeDoIt:theCode |
4391 | 1453 |
"the core of doIt, printIt, inspectIt, browseIt actions" |
1454 |
||
4618
d3554659540b
Fix for RegressionTests::Compiler2Tests>>test_03
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4617
diff
changeset
|
1455 |
| result compiler | |
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1456 |
|
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1457 |
"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
|
1458 |
[ |
5053 | 1459 |
result := ( compiler := (self compilerClass ? Compiler) new ) |
1460 |
currentNameSpace:namespaceForDoits; |
|
1461 |
moreSharedPools:poolsConsideredInDoIts; |
|
1462 |
evaluate:theCode |
|
1463 |
in:nil |
|
1464 |
receiver:simulatedSelf |
|
1465 |
notifying:self |
|
1466 |
logged:true |
|
1467 |
ifFail:nil |
|
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1468 |
] on: Parser undefinedVariableNotification do:[:ex| |
5053 | 1469 |
(ex parser == compiler and:[autoDefineVariables notNil]) ifTrue:[ |
1470 |
ex proceedWith: #declare |
|
1471 |
] ifFalse:[ |
|
1472 |
ex proceedWith: nil |
|
1473 |
]. |
|
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1474 |
] on: Parser askForVariableTypeOfUndeclaredQuery do:[:ex| |
5053 | 1475 |
autoDefineVariables == #workspace ifTrue:[ |
1476 |
ex proceedWith:#WorkspaceVariable |
|
1477 |
]. |
|
1478 |
autoDefineVariables == #doIt ifTrue:[ |
|
1479 |
ex proceedWith:#DoItTemporary |
|
1480 |
]. |
|
1481 |
ex pass. |
|
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1482 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1483 |
^result |
4391 | 1484 |
|
4438 | 1485 |
"Modified: / 27-07-2012 / 09:33:39 / cg" |
4618
d3554659540b
Fix for RegressionTests::Compiler2Tests>>test_03
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4617
diff
changeset
|
1486 |
"Modified: / 24-06-2013 / 15:31:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4677 | 1487 |
! ! |
1488 |
||
1489 |
!Workspace methodsFor:'initialization & release'! |
|
2733 | 1490 |
|
201 | 1491 |
initStyle |
966 | 1492 |
"setup viewStyle specifics" |
1493 |
||
201 | 1494 |
super initStyle. |
1495 |
||
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1496 |
DefaultViewBackground notNil ifTrue:[ |
5053 | 1497 |
viewBackground := DefaultViewBackground. |
1498 |
self backgroundColor:viewBackground. |
|
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1499 |
]. |
201 | 1500 |
! |
1501 |
||
1502 |
initialize |
|
1503 |
super initialize. |
|
1504 |
||
5105 | 1505 |
autoIndent := UserPreferences current autoIndentInCodeView. |
2775 | 1506 |
scrollWhenUpdating := #beginOfText. |
201 | 1507 |
showMatchingParenthesis := true. |
3428 | 1508 |
allowValueDrop := true. |
1509 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1510 |
commentStrings := #( |
5103 | 1511 |
'"/' |
1512 |
('"' '"') |
|
1513 |
). |
|
201 | 1514 |
|
1515 |
self initializeDoITAction. |
|
3396 | 1516 |
self initializeDragAndDrop. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1517 |
|
3428 | 1518 |
"Modified: / 28-11-2006 / 16:11:55 / cg" |
201 | 1519 |
! |
1520 |
||
1521 |
initializeDoITAction |
|
1522 |
"set up the block to be evaluated for doIts. |
|
1523 |
This is done here in a separate method to allow easier |
|
1524 |
redefinition in subclasses" |
|
1525 |
||
2733 | 1526 |
doItAction := [:theCode | self executeDoIt:theCode]. |
3396 | 1527 |
! |
1528 |
||
1529 |
initializeDragAndDrop |
|
1530 |
|target| |
|
1531 |
||
5053 | 1532 |
target := DropTarget |
1533 |
receiver:self |
|
1534 |
argument:nil |
|
1535 |
dropSelector:#drop: |
|
1536 |
canDropSelector:#canDrop:. |
|
3396 | 1537 |
self dropTarget:target |
1538 |
||
1539 |
"Created: / 16-08-2005 / 22:03:36 / janfrog" |
|
3411 | 1540 |
"Modified: / 13-10-2006 / 12:37:18 / cg" |
201 | 1541 |
! ! |
1542 |
||
418 | 1543 |
!Workspace methodsFor:'menu & menu actions'! |
1544 |
||
2285 | 1545 |
browseClass |
1546 |
"user selected 'browseClass' from menu; evaluate the code |
|
1547 |
and open a browser on the resulting class (if it evaluates to one)" |
|
1548 |
||
5053 | 1549 |
^ self |
1550 |
do:(self selectionAsString) |
|
1551 |
withValueDo:[:result | |
|
1552 |
result isBehavior ifTrue:[ |
|
1553 |
result browserClass openInClass:result selector:nil |
|
1554 |
] ifFalse:[ |
|
1555 |
self warn:'Selection does not evaluate to a class' |
|
1556 |
] |
|
1557 |
]. |
|
2285 | 1558 |
|
2410 | 1559 |
"Modified: / 26.9.2001 / 17:37:35 / cg" |
2285 | 1560 |
! |
1561 |
||
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1562 |
browseImplementorsOfIt |
4617 | 1563 |
"open a browser on the implementors of the selected text, |
1564 |
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
|
1565 |
|
5621 | 1566 |
|selectedText selector browserClass na browser |
5906 | 1567 |
cls node dwim targetClass targetImplClass| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1568 |
|
4617 | 1569 |
selectedText := self selectedTextOrSyntaxElement. |
1570 |
selectedText notEmptyOrNil ifTrue:[ |
|
5621 | 1571 |
self windowGroup withWaitCursorDo:[ |
1572 |
"/ hack, for now and expecco; must ask the Parser eventually... |
|
6021 | 1573 |
((compilerClass notNil and:[compilerClass includesBehavior:JavaScriptParser]) |
1574 |
or:[ self editedLanguage notNil |
|
1575 |
and:[ self editedLanguage isSTXJavaScript]]) ifTrue:[ |
|
5621 | 1576 |
"/ selector is in one piece anyway |
1577 |
(selectedText includes:$_) ifFalse:[ |
|
1578 |
"/ zero or one args - sigh (need to parse more to figure this out) |
|
1579 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:1. |
|
1580 |
selectedText := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:0. |
|
1581 |
] ifTrue:[ |
|
1582 |
"/ count _#s plus one arg - sigh |
|
1583 |
na := (selectedText occurrencesOf:$_) + 1. |
|
1584 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:na |
|
1585 |
]. |
|
1586 |
] ifFalse:[ |
|
1587 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
|
1588 |
]. |
|
1589 |
browserClass := UserPreferences systemBrowserClass. |
|
1590 |
||
1591 |
(selector notNil and:[selector ~= selectedText]) ifTrue:[ |
|
1592 |
(SystemBrowser |
|
1593 |
findImplementorsOfAny:(Array with:selectedText) |
|
1594 |
in:(Smalltalk allClasses) |
|
1595 |
ignoreCase:false) isEmpty ifTrue:[ |
|
1596 |
browser := browserClass browseImplementorsOf:selector |
|
1597 |
] ifFalse:[ |
|
1598 |
browser := browserClass browseImplementorsOfAny:(Set with:selector with:selectedText) |
|
1599 |
]. |
|
1600 |
] ifFalse:[ |
|
1601 |
browser := browserClass browseImplementorsOf:(selector ? selectedText) |
|
1602 |
]. |
|
5646 | 1603 |
browser notNil ifTrue:[ |
1604 |
"/ if the type of the receiver is known, |
|
1605 |
"/ select the targeted method immediately |
|
1606 |
(cls := self editedClass) notNil ifTrue:[ |
|
5906 | 1607 |
node := DoWhatIMeanSupport |
5646 | 1608 |
findNodeForInterval:(self selectionStartIndex to:self selectionStopIndex) |
1609 |
in:self contents string. |
|
1610 |
(node notNil and:[node isMessage]) ifTrue:[ |
|
5906 | 1611 |
dwim := DoWhatIMeanSupport new. |
1612 |
dwim setClass:cls andContext:nil. |
|
1613 |
dwim setSelf: simulatedSelf. |
|
5646 | 1614 |
targetClass := dwim classOfNode:node receiver. |
5906 | 1615 |
|
5646 | 1616 |
targetClass notNil ifTrue:[ |
1617 |
targetImplClass := targetClass whichClassImplements:(node selector). |
|
1618 |
targetImplClass notNil ifTrue:[ |
|
1619 |
browser selectMethod:(targetImplClass compiledMethodAt:(node selector)) |
|
1620 |
]. |
|
5621 | 1621 |
]. |
5646 | 1622 |
]. |
1623 |
] |
|
5621 | 1624 |
] |
1625 |
] |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1626 |
]. |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1627 |
|
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1628 |
"Created: / 5.11.2001 / 17:32:23 / cg" |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1629 |
"Modified: / 19.11.2001 / 22:15:17 / cg" |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1630 |
! |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1631 |
|
2307 | 1632 |
browseIt |
1633 |
"evaluate the code and open a browser on the resulting class (if it evaluates to one), |
|
2713 | 1634 |
or the class of the resulting object (if it does not evaluate to a class). |
1635 |
||
5731 | 1636 |
Added feature: |
1637 |
if selection is of the form class >> selector, |
|
1638 |
immediately switch to that selector." |
|
2713 | 1639 |
|
4617 | 1640 |
|codeToEvaluate el idx selector evaluatedValue classToBrowse gotResult| |
2713 | 1641 |
|
5053 | 1642 |
(self selection isEmptyOrNil |
5072 | 1643 |
and:[ self supportsSyntaxElements |
1644 |
and:[ (el := self syntaxElementForVariableUnderCursor) notNil ]]) |
|
5053 | 1645 |
ifTrue:[ |
5072 | 1646 |
codeToEvaluate := el name |
4617 | 1647 |
] ifFalse:[ |
5072 | 1648 |
codeToEvaluate := (self selectionOrTextOfCursorLine ? '') withoutSeparators. |
4617 | 1649 |
]. |
5964 | 1650 |
idx := codeToEvaluate indexOf:'»'. |
2713 | 1651 |
idx ~~ 0 ifTrue:[ |
5731 | 1652 |
selector := (codeToEvaluate copyFrom:idx+1) withoutSeparators string. |
5072 | 1653 |
(selector startsWith:'#') ifTrue:[ |
1654 |
selector := Symbol readFrom:selector. |
|
1655 |
]. |
|
1656 |
codeToEvaluate := codeToEvaluate copyTo:idx-1. |
|
5731 | 1657 |
] ifFalse:[ |
1658 |
idx := codeToEvaluate indexOfSubCollection:'>>'. |
|
1659 |
idx ~~ 0 ifTrue:[ |
|
1660 |
selector := (codeToEvaluate copyFrom:idx+2) withoutSeparators string. |
|
1661 |
(selector startsWith:'#') ifTrue:[ |
|
1662 |
selector := Symbol readFrom:selector. |
|
1663 |
]. |
|
1664 |
codeToEvaluate := codeToEvaluate copyTo:idx-1. |
|
1665 |
]. |
|
2713 | 1666 |
]. |
5731 | 1667 |
|
4997 | 1668 |
(Parser parseErrorSignal , MessageNotUnderstood) handle:[:ex | |
5072 | 1669 |
|className words| |
1670 |
||
1671 |
(classToBrowse := Smalltalk classNamed:codeToEvaluate) isNil ifTrue:[ |
|
1672 |
"/ handle className selector (for example from messageTally list) |
|
1673 |
codeToEvaluate includesSeparator ifTrue:[ |
|
1674 |
words := codeToEvaluate asCollectionOfWords. |
|
1675 |
classToBrowse := Smalltalk classNamed:words first. |
|
1676 |
classToBrowse notNil ifTrue:[ |
|
1677 |
selector := (words copyFrom:2) asStringWith:''. |
|
1678 |
((words size > 1) and:[words second = 'class']) ifTrue:[ |
|
1679 |
classToBrowse := classToBrowse theMetaclass. |
|
1680 |
selector := (words copyFrom:3) asStringWith:''. |
|
1681 |
]. |
|
1682 |
classToBrowse browserClass openInClass:classToBrowse selector:selector. |
|
1683 |
^ self. |
|
1684 |
]. |
|
1685 |
]. |
|
1686 |
||
1687 |
"/ fallback, if garbage is selected, look for matching classes. |
|
1688 |
className := SystemBrowser |
|
1689 |
askForClassNameMatching:codeToEvaluate |
|
1690 |
inEnvironment:nil |
|
1691 |
for:nil. |
|
1692 |
||
1693 |
className isNil ifTrue:[^ self]. |
|
1694 |
classToBrowse := Smalltalk classNamed:className. |
|
1695 |
] |
|
3910 | 1696 |
] do:[ |
5072 | 1697 |
gotResult := false. |
1698 |
||
1699 |
self |
|
1700 |
do:codeToEvaluate |
|
1701 |
withValueDo:[:result | evaluatedValue := result. gotResult := true.]. |
|
1702 |
||
1703 |
gotResult ifFalse:[^ self]. |
|
1704 |
||
1705 |
evaluatedValue isNil ifTrue:[ |
|
1706 |
codeToEvaluate asCollectionOfWords size == 1 ifTrue:[ |
|
1707 |
codeToEvaluate isUppercaseFirst ifTrue:[ |
|
1708 |
Dialog information:(codeToEvaluate allBold , ' is unbound or nil'). |
|
1709 |
^ self. |
|
1710 |
]. |
|
1711 |
] |
|
1712 |
]. |
|
1713 |
classToBrowse := evaluatedValue isBehavior |
|
1714 |
ifTrue:[ evaluatedValue ] |
|
1715 |
ifFalse:[ evaluatedValue class ]. |
|
3910 | 1716 |
]. |
1717 |
||
1718 |
classToBrowse browserClass openInClass:classToBrowse selector:selector |
|
4386 | 1719 |
|
1720 |
"Modified: / 28-02-2012 / 11:23:06 / cg" |
|
2307 | 1721 |
! |
1722 |
||
2285 | 1723 |
browseItsClass |
1724 |
"user selected 'browseItsClass' from menu; evaluate the code |
|
1725 |
and open a browser on the results class" |
|
1726 |
||
5053 | 1727 |
^ self |
1728 |
do:(self selectionAsString) |
|
1729 |
withValueDo:[:result | |
|
1730 |
result class browserClass openInClass:result class selector:nil |
|
1731 |
] |
|
2285 | 1732 |
|
2410 | 1733 |
"Modified: / 26.9.2001 / 17:38:06 / cg" |
2285 | 1734 |
! |
1735 |
||
2454 | 1736 |
browseReferencesToIt |
5003 | 1737 |
"open a browser on all references to the selected global, poolvar or namespace class" |
2454 | 1738 |
|
5066 | 1739 |
|nameOfVariable browserClass sym| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1740 |
|
5065 | 1741 |
nameOfVariable := self selectedTextOrSyntaxElement. |
1742 |
nameOfVariable notEmptyOrNil ifTrue:[ |
|
1743 |
browserClass := UserPreferences systemBrowserClass. |
|
1744 |
self windowGroup withWaitCursorDo:[ |
|
5618 | 1745 |
|cls nonMeta privateClass| |
4675 | 1746 |
|
5066 | 1747 |
(nameOfVariable startsWith:'#') ifTrue:[ |
1748 |
sym := (nameOfVariable copyFrom:2) asSymbolIfInterned. |
|
1749 |
browserClass browseForSymbol:sym. |
|
5065 | 1750 |
] ifFalse:[ |
5066 | 1751 |
"/ is it a class variable? |
1752 |
((cls := self editedClass) notNil |
|
5618 | 1753 |
and:[ ((nonMeta := cls theNonMetaclass) allClassVarNames includes:nameOfVariable) ]) ifTrue:[ |
1754 |
nonMeta isSharedPool ifTrue:[ |
|
1755 |
"/ class is a pool - browse all references to it. |
|
1756 |
browserClass browseReferendsOf:(nonMeta name,':',nameOfVariable) |
|
1757 |
] ifFalse:[ |
|
1758 |
browserClass |
|
1759 |
browseRefsTo:nameOfVariable |
|
1760 |
classVars:true |
|
1761 |
in:(nonMeta whichClassDefinesClassVar:nameOfVariable) withAllSubclasses |
|
1762 |
modificationsOnly:false. |
|
1763 |
]. |
|
5065 | 1764 |
] ifFalse:[ |
5066 | 1765 |
"/ is it a private class? |
1766 |
(cls notNil |
|
1767 |
and:[ (privateClass := cls theNonMetaclass privateClassNamed:nameOfVariable) notNil ]) ifTrue:[ |
|
1768 |
browserClass browseReferendsOf:(privateClass name) |
|
5065 | 1769 |
] ifFalse:[ |
5066 | 1770 |
|pool nsClass| |
1771 |
||
1772 |
"/ is it a pool variable? |
|
1773 |
cls notNil ifTrue:[ |
|
1774 |
pool := cls theNonMetaclass sharedPools |
|
1775 |
detect:[:pool | pool classVarNames includes:nameOfVariable] |
|
1776 |
ifNone:nil. |
|
1777 |
]. |
|
1778 |
pool notNil ifTrue:[ |
|
1779 |
browserClass browseReferendsOf:(pool name,':',nameOfVariable) |
|
5065 | 1780 |
] ifFalse:[ |
5066 | 1781 |
(cls notNil |
1782 |
and:[ cls nameSpace notNil |
|
1783 |
and:[ nameOfVariable knownAsSymbol |
|
5982 | 1784 |
and:[ cls nameSpace isNameSpace |
1785 |
and:[(nsClass := cls nameSpace at:nameOfVariable asSymbol) notNil |
|
5512 | 1786 |
and:[ nsClass isBehavior |
5982 | 1787 |
]]]]]) ifTrue:[ |
5066 | 1788 |
"/ a namespace class? |
1789 |
browserClass browseReferendsOf:nsClass name |
|
5065 | 1790 |
] ifFalse:[ |
5066 | 1791 |
"/ an instvar? |
5250 | 1792 |
(cls notNil and:[cls allInstVarNames includes:nameOfVariable]) ifTrue:[ |
5066 | 1793 |
browserClass |
1794 |
browseInstRefsTo:nameOfVariable |
|
1795 |
under:(cls whichClassDefinesInstVar:nameOfVariable) |
|
1796 |
modificationsOnly:false |
|
1797 |
] ifFalse:[ |
|
1798 |
"/ no, assume global |
|
1799 |
browserClass browseReferendsOf:nameOfVariable |
|
1800 |
] |
|
5065 | 1801 |
] |
1802 |
] |
|
1803 |
] |
|
1804 |
] |
|
1805 |
] |
|
1806 |
]. |
|
2454 | 1807 |
]. |
1808 |
||
5618 | 1809 |
"Created: / 05-11-2001 / 17:32:23 / cg" |
1810 |
"Modified: / 30-03-2016 / 20:33:17 / cg" |
|
2454 | 1811 |
! |
1812 |
||
2462 | 1813 |
browseSendersOfIt |
1814 |
"open a browser on the senders of the selected text" |
|
1815 |
||
2715 | 1816 |
|selectedText selector| |
2462 | 1817 |
|
4617 | 1818 |
selectedText := self selectedTextOrSyntaxElement. |
1819 |
selectedText notEmptyOrNil ifTrue:[ |
|
5053 | 1820 |
self windowGroup withWaitCursorDo:[ |
1821 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
|
1822 |
(UserPreferences systemBrowserClass) |
|
1823 |
browseAllCallsOn:(selector ? selectedText) |
|
1824 |
] |
|
2462 | 1825 |
]. |
1826 |
||
1827 |
"Created: / 5.11.2001 / 17:32:23 / cg" |
|
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1828 |
"Modified: / 19.11.2001 / 22:15:27 / cg" |
2462 | 1829 |
! |
1830 |
||
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1831 |
browseSharedPoolOfIt |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1832 |
"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
|
1833 |
|
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1834 |
|sel| |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1835 |
|
4617 | 1836 |
sel := self selectedTextOrSyntaxElement. |
1837 |
sel notEmptyOrNil ifTrue:[ |
|
5506 | 1838 |
sel := sel asSymbol. |
1839 |
self windowGroup withWaitCursorDo:[ |
|
1840 |
SharedPool allSubclassesDo:[:eachPool | |
|
1841 |
(eachPool includesKey:sel) ifTrue:[ |
|
1842 |
eachPool class browse:#initialize |
|
1843 |
]. |
|
1844 |
]. |
|
1845 |
]. |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1846 |
]. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1847 |
|
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1848 |
"Created: / 15-01-2011 / 14:01:39 / cg" |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1849 |
! |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1850 |
|
418 | 1851 |
doIt |
1852 |
"user selected 'doIt' from menu; show a wait-cursor, evaluate the code |
|
1853 |
and finally restore cursor; return result of evaluation" |
|
1854 |
||
5053 | 1855 |
^ self |
1856 |
do:(self selectionOrTextOfCursorLine) |
|
1857 |
withValueDo:nil |
|
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1858 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1859 |
"Modified: / 16.5.1998 / 16:45:01 / cg" |
418 | 1860 |
! |
1861 |
||
1862 |
editMenu |
|
5878 | 1863 |
"return my popUpMenu; that's the superclasses menu |
1107 | 1864 |
PLUS st-evaluation items: doIt, printIt and inspectIt." |
1865 |
||
5053 | 1866 |
<resource: #keyboard (#DoIt #PrintIt #InspectIt |
5065 | 1867 |
#CommentSelection #UncommentSelection |
1868 |
#BrowseIt #ImplementorsOfIt |
|
1869 |
)> |
|
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1251
diff
changeset
|
1870 |
<resource: #programMenu> |
489 | 1871 |
|
4998 | 1872 |
|m sub subsub idx sensor sel2 sel selectedSymbol| |
418 | 1873 |
|
1874 |
m := super editMenu. |
|
3252 | 1875 |
((sensor := self sensor) notNil and:[sensor ctrlDown and:[sensor shiftDown not]]) ifTrue:[ |
5065 | 1876 |
sub := m. |
1877 |
m := nil. |
|
2459 | 1878 |
] ifFalse:[ |
5065 | 1879 |
sub := m subMenuAt:#others. |
2459 | 1880 |
]. |
418 | 1881 |
|
2459 | 1882 |
sub notNil ifTrue:[ |
5065 | 1883 |
" |
1884 |
workspaces support #browse, implementors etc. add them after paste. |
|
1885 |
" |
|
1886 |
sub |
|
1887 |
addItemList:#( |
|
1888 |
('-' ) |
|
5682 | 1889 |
('Browse It' browseIt BrowseIt ) |
5065 | 1890 |
('Browse Pool' browseSharedPoolOfIt ) |
1891 |
('Senders of It' browseSendersOfIt ) |
|
1892 |
('Implementors of It' browseImplementorsOfIt ImplementorsOfIt ) |
|
1893 |
('References to It' browseReferencesToIt ) |
|
3910 | 1894 |
"/ ('Classes Containing It in Name' browseClassesContainingItInName ) |
5964 | 1895 |
"/ ('Methods Contaníning It in Name' browseMethodsContainingItInName ) |
1896 |
"/ ('Methods Contaníning It in Source' browseMethodsContainingItInSource ) |
|
5065 | 1897 |
('-' ) |
1898 |
('TimeIt' timeIt ) |
|
1899 |
('SpyOnIt' spyOnIt )) |
|
1900 |
resources:resources |
|
1901 |
after:#gotoLine. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1902 |
|
5065 | 1903 |
subsub := sub subMenuAt:#tools. |
1904 |
subsub notNil ifTrue:[ |
|
1905 |
subsub |
|
1906 |
addItemList:#( |
|
1907 |
('-' ) |
|
1908 |
('CommentIt' commentSelection CommentSelection ) |
|
1909 |
('UncommentIt' uncommentSelection UncommentSelection )) |
|
5579 | 1910 |
resources:resources |
1911 |
after:#'indent'. |
|
1912 |
subsub |
|
1913 |
addItemList:#( |
|
1914 |
('Inspect Instances' inspectInstances nil) |
|
1915 |
) |
|
1916 |
resources:resources |
|
1917 |
||
1918 |
after:#inspectString. |
|
1919 |
||
1920 |
(self hasSelection not |
|
1921 |
or:[ (sel := self selectionAsString asSymbolIfInterned) isNil |
|
1922 |
or:[ (Smalltalk at:sel) isBehavior not ]]) ifTrue:[ |
|
1923 |
sub disable:#inspectInstances |
|
1924 |
]. |
|
5065 | 1925 |
]. |
2867 | 1926 |
|
5065 | 1927 |
self hasSelection ifFalse:[ |
1928 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt |
|
1929 |
browseReferencesToIt timeIt spyOnIt |
|
5579 | 1930 |
browseSharedPoolOfIt browseIt inspectInstances). |
5065 | 1931 |
self supportsSyntaxElements ifTrue:[ |
1932 |
self syntaxElementForSelectorUnderCursor notNil ifTrue:[ |
|
1933 |
sub enableAll:#(browseImplementorsOfIt browseSendersOfIt ) |
|
1934 |
] ifFalse:[ |
|
1935 |
|el| |
|
4617 | 1936 |
|
5065 | 1937 |
(el := self syntaxElementForVariableUnderCursor) notNil ifTrue:[ |
1938 |
(el isGlobal or:[el isInstanceVariable]) ifTrue:[ |
|
1939 |
sub enable: #browseReferencesToIt |
|
1940 |
]. |
|
1941 |
el isClass ifTrue:[ |
|
1942 |
sub enable:#browseIt |
|
1943 |
] |
|
1944 |
] |
|
1945 |
] |
|
1946 |
]. |
|
1947 |
] ifTrue:[ |
|
1948 |
sel := self selectionAsString. |
|
1949 |
sel notNil ifTrue:[ |
|
1950 |
sel asSymbolIfInterned isNil ifTrue:[ |
|
1951 |
sel2 := SystemBrowser extractSelectorFrom:sel. |
|
1952 |
sel2 notNil ifTrue:[ |
|
1953 |
sel2 := sel2 asSymbolIfInterned. |
|
1954 |
]. |
|
1955 |
]. |
|
1956 |
]. |
|
1957 |
(sel2 isNil and:[sel isNil]) ifTrue:[ |
|
1958 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt). |
|
1959 |
]. |
|
1960 |
"/ a global or namespace-var selected ? |
|
1961 |
sel isNil ifTrue:[ |
|
1962 |
sub disable:#browseReferencesToIt. |
|
1963 |
] ifFalse:[ |
|
5066 | 1964 |
(sel startsWith:'#') ifTrue:[ |
1965 |
"/ a symbol selected - can search references |
|
5065 | 1966 |
] ifFalse:[ |
5066 | 1967 |
selectedSymbol := sel asSymbolIfInterned. |
1968 |
(selectedSymbol notNil |
|
1969 |
and:[(Smalltalk includesKey:selectedSymbol) |
|
1970 |
or:[(NameSpace allNameSpaces contains:[:ns | ns includesKey:selectedSymbol]) ]] |
|
1971 |
) ifTrue:[ |
|
1972 |
"/ a global or namespace var selected |
|
1973 |
] ifFalse:[ |
|
1974 |
|cls| |
|
1975 |
||
1976 |
cls := self editedClass. |
|
1977 |
cls notNil ifTrue:[ |
|
1978 |
cls := cls theNonMetaclass. |
|
1979 |
((cls allClassVarNames includes:sel) |
|
1980 |
or:[ (cls theNonMetaclass privateClassNamed:sel) notNil]) ifTrue:[ |
|
1981 |
"/ a classvar or private class |
|
1982 |
] ifFalse:[ |
|
1983 |
|pool| |
|
1984 |
"/ is it a pool variable? |
|
1985 |
pool := cls sharedPools |
|
1986 |
detect:[:pool | pool classVarNames includes:sel] |
|
1987 |
ifNone:nil. |
|
1988 |
pool isNil ifTrue:[ |
|
1989 |
"/ todo: an instvar selected? |
|
1990 |
(cls allInstVarNames includes:sel) ifFalse:[ |
|
1991 |
sub disable:#browseReferencesToIt. |
|
1992 |
]. |
|
5065 | 1993 |
]. |
1994 |
]. |
|
5066 | 1995 |
] ifFalse:[ |
1996 |
sub disable:#browseReferencesToIt. |
|
5065 | 1997 |
]. |
1998 |
]. |
|
1999 |
]. |
|
2000 |
]. |
|
2001 |
(selectedSymbol notNil |
|
2002 |
and:[SharedPool allSubclasses contains:[:pool | pool includesKey:selectedSymbol]]) ifFalse:[ |
|
2003 |
sub disable:#browseSharedPoolOfIt. |
|
2004 |
]. |
|
2005 |
]. |
|
2006 |
self isReadOnly ifTrue:[ |
|
2007 |
sub disableAll:#(commentSelection uncommentSelection) |
|
2008 |
]. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
2009 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
2010 |
|
2459 | 2011 |
m notNil ifTrue:[ |
5065 | 2012 |
" |
2013 |
workspaces support #doIt, #printIt and #inspectIt |
|
2014 |
add them after paste. |
|
2015 |
" |
|
2016 |
idx := m indexOf:#paste. |
|
2017 |
idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
|
2018 |
idx ~~ 0 ifTrue:[ |
|
2019 |
m |
|
2020 |
addItemList:#( |
|
2021 |
('-' ) |
|
2022 |
('DoIt' doIt DoIt ) |
|
2023 |
('PrintIt' printIt PrintIt ) |
|
2024 |
('InspectIt' inspectIt InspectIt)) |
|
2025 |
resources:resources |
|
2026 |
after:idx. |
|
4998 | 2027 |
|
5065 | 2028 |
]. |
2459 | 2029 |
|
5065 | 2030 |
(self hasSelectionOrTextInCursorLine) ifFalse:[ |
2031 |
|lNr line| |
|
3272 | 2032 |
|
5065 | 2033 |
lNr := self cursorLine. |
2034 |
line := self listAt:lNr. |
|
2035 |
line isEmptyOrNil ifTrue:[ |
|
2036 |
m disableAll:#(printIt doIt inspectIt browseIt) |
|
2037 |
]. |
|
2038 |
]. |
|
2039 |
self isReadOnly ifTrue:[ |
|
2040 |
m disable:#printIt |
|
2041 |
]. |
|
418 | 2042 |
]. |
2043 |
||
2459 | 2044 |
^ m ? sub. |
430 | 2045 |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
2046 |
"Modified: / 22-04-1998 / 21:49:06 / ca" |
4342 | 2047 |
"Modified: / 20-12-2011 / 11:22:20 / cg" |
418 | 2048 |
! |
2049 |
||
5579 | 2050 |
inspectInstances |
2051 |
|nameOfVariable cls insts| |
|
2052 |
||
2053 |
nameOfVariable := self selectedTextOrSyntaxElement. |
|
2054 |
nameOfVariable isEmptyOrNil ifTrue:[^ self]. |
|
2055 |
nameOfVariable := nameOfVariable asSymbolIfInterned. |
|
2056 |
nameOfVariable isNil ifTrue:[^ self]. |
|
2057 |
cls := Smalltalk at:nameOfVariable. |
|
2058 |
cls isNil ifTrue:[^ self]. |
|
2059 |
cls isBehavior ifFalse:[^ self]. |
|
2060 |
insts := cls allInstances. |
|
2061 |
insts isEmpty ifTrue:[ |
|
2062 |
Dialog information:(resources string:'No instances of %1' with:nameOfVariable). |
|
2063 |
^ self. |
|
2064 |
]. |
|
2065 |
insts inspect. |
|
2066 |
! |
|
2067 |
||
418 | 2068 |
inspectIt |
2069 |
"user selected 'inspectIt' from menu; use doIt to evaluate the code |
|
2070 |
and start an inspector on the result" |
|
2071 |
||
2981
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
2072 |
|shifted| |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
2073 |
|
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
2074 |
shifted := self sensor shiftDown. |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
2075 |
|
5053 | 2076 |
^ self |
2077 |
do:(self selectionOrTextOfCursorLine) |
|
2078 |
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
|
2079 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
2080 |
"Modified: / 16.5.1998 / 16:44:56 / cg" |
418 | 2081 |
! |
2082 |
||
2083 |
printIt |
|
2084 |
"user selected 'printIt' from menu; use doIt to evaluate the code |
|
2085 |
and insert result of evaluation into my text. |
|
2086 |
If the text is readOnly, do nothing." |
|
2087 |
||
1734 | 2088 |
self isReadOnly ifTrue:[ |
5148 | 2089 |
self beep. |
2090 |
^ self. |
|
3511 | 2091 |
]. |
5053 | 2092 |
self |
5148 | 2093 |
undoableDo:[ |
2094 |
self |
|
2095 |
do:(self selectionOrTextOfCursorLine) |
|
2096 |
withValueDo:[:result | |
|
5396 | 2097 |
|s printer lang| |
5148 | 2098 |
|
2099 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
|
5396 | 2100 |
"/ give the language a chance to generate a printString for that value |
2101 |
lang := self editedLanguage. |
|
2102 |
(lang notNil and:[(printer := lang valuePrinterClass) notNil]) ifTrue:[ |
|
5148 | 2103 |
s := printer printStringForPrintItOf:result |
2104 |
] ifFalse:[ |
|
6020 | 2105 |
result isProtoObject ifTrue:[ |
2106 |
s := result displayString. |
|
5148 | 2107 |
] ifFalse:[ |
6020 | 2108 |
(result isInteger |
2109 |
and:[ result > 10 |
|
2110 |
and:[ InspectorView defaultIntegerDisplayRadix ~= 10]]) ifTrue:[ |
|
2111 |
s := result displayString , ' "',(result radixPrintStringRadix: InspectorView defaultIntegerDisplayRadix),'"'. |
|
2112 |
] ifFalse:[ |
|
2113 |
s := result printStringForPrintIt "old: displayString" "very old: printString" |
|
2114 |
]. |
|
2115 |
] |
|
5148 | 2116 |
]. |
5565 | 2117 |
|
2118 |
self withAutoIndent:false do:[ |
|
2119 |
"/ if the returned string starts with a newLine, |
|
2120 |
"/ insert as a bunch of lines after the cursor line. |
|
2121 |
(s size > 0 and:[s startsWith:(Character cr)]) ifTrue:[ |
|
5566 | 2122 |
|cursorLine cursorCol lines| |
5565 | 2123 |
|
2124 |
cursorLine := self cursorLine. |
|
5566 | 2125 |
cursorCol := self cursorCol. |
5565 | 2126 |
lines := s asStringCollection copyFrom:2. |
5566 | 2127 |
self insertLines:lines before:cursorLine+((cursorCol == 1) ifTrue:0 ifFalse:1). |
5565 | 2128 |
self selectFromLine:cursorLine+1 toLine:cursorLine+lines size. |
2129 |
] ifFalse:[ |
|
2130 |
self insertSelectedStringAtCursor:s |
|
2131 |
] |
|
2132 |
] |
|
5148 | 2133 |
] |
2134 |
] |
|
2135 |
info:'PrintIt' |
|
3511 | 2136 |
|
4401 | 2137 |
"Modified: / 08-03-2012 / 16:14:34 / cg" |
3511 | 2138 |
! |
418 | 2139 |
|
4471 | 2140 |
profileIt |
2141 |
"user selected 'profileIt' from menu; show a wait-cursor, profile the code |
|
4472 | 2142 |
and finally restore the cursor. Open a visual profiler on the sample data." |
4471 | 2143 |
|
4472 | 2144 |
self spyOnItUsing:Tools::Profiler |
4471 | 2145 |
! |
2146 |
||
3511 | 2147 |
replaceIt |
2148 |
"like printIt, but replace the selection with the result, instead of |
|
2149 |
pasting it after the selection." |
|
2150 |
||
2151 |
self isReadOnly ifTrue:[ |
|
5053 | 2152 |
self beep. |
2153 |
^ self |
|
3511 | 2154 |
]. |
2155 |
||
5053 | 2156 |
self |
2157 |
undoableDo:[ |
|
2158 |
self |
|
2159 |
do:(self selectionOrTextOfCursorLine) |
|
2160 |
withValueDo:[:result | |
|
2161 |
self replaceSelectionBy:(result displayString "printString") |
|
2162 |
]. |
|
2163 |
undoSupport actionInfo:'ReplaceIt'. |
|
2164 |
] |
|
2165 |
info:'ReplaceIt' |
|
3511 | 2166 |
|
2167 |
"Created: / 08-11-2007 / 11:31:54 / cg" |
|
1501 | 2168 |
! |
2169 |
||
2170 |
spyOnIt |
|
2171 |
"user selected 'spyOnIt' from menu; show a wait-cursor, evaluate the code |
|
4472 | 2172 |
and finally restore the cursor. Show profile data on the Transcript" |
2173 |
||
2174 |
self spyOnItUsing:MessageTally |
|
2175 |
! |
|
2176 |
||
2177 |
spyOnItUsing:aProfiler |
|
2178 |
"common code for spyOnIt / profileIt. |
|
2179 |
Show a wait-cursor, evaluate the code with profier on it, |
|
2180 |
and finally restore the cursor. Show profile data as per profiler" |
|
1501 | 2181 |
|
5865 | 2182 |
|code codeToRun| |
2183 |
||
2184 |
codeToRun := self selectionOrTextOfCursorLine. |
|
2185 |
(codeToRun isEmptyOrNil or:[codeToRun isBlank]) ifTrue:[^ self]. |
|
2186 |
||
5504 | 2187 |
compilerClass == (Smalltalk at:#Compiler) ifFalse:[ |
5865 | 2188 |
"sigh - this measurement will include the time to compile - sigh" |
2189 |
aProfiler spyDetailedOn:[ self doIt ]. |
|
2190 |
^ self. |
|
4427 | 2191 |
]. |
2192 |
||
5865 | 2193 |
code := aProfiler name,' spyDetailedOn:[' , codeToRun, ']'. |
4149 | 2194 |
self do:code withValueDo:[:value| ]. |
1501 | 2195 |
! |
2196 |
||
2197 |
timeIt |
|
2198 |
"user selected 'timeIt' from menu; show a wait-cursor, evaluate the code |
|
2199 |
and finally restore cursor; return result of evaluation" |
|
2200 |
||
5135 | 2201 |
|code| |
4427 | 2202 |
|
5504 | 2203 |
compilerClass == (Smalltalk at:#Compiler) ifFalse:[ |
5135 | 2204 |
"sigh - this measurement will include the time to compile - sigh" |
2205 |
[ self doIt ] benchmark:'execution time: '. |
|
2206 |
^ self. |
|
4427 | 2207 |
]. |
1501 | 2208 |
|
5135 | 2209 |
code := '[' , self selectionAsString, '] benchmark:''execution time: '''. |
4149 | 2210 |
self do:code withValueDo:[:value | ]. |
1501 | 2211 |
|
4427 | 2212 |
"Modified: / 22-04-1998 / 22:03:51 / ca" |
2213 |
"Modified (format): / 02-06-2012 / 00:38:51 / cg" |
|
418 | 2214 |
! ! |
2215 |
||
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2216 |
!Workspace methodsFor:'misc'! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2217 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2218 |
expandAbbreviation |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2219 |
"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
|
2220 |
cursor, find an abbrev for it and expand." |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2221 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2222 |
|expandedString abortExpandAction oldSelectionStartLine oldSelectionStartCol oldSelectionEndLine oldSelectionEndCol oldCursorLine oldCursorCol |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2223 |
newCursorPos replStartCol| |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2224 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2225 |
oldCursorLine := self cursorLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2226 |
oldCursorCol := self cursorCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2227 |
oldSelectionStartLine := self selectionStartLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2228 |
oldSelectionStartCol := self selectionStartCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2229 |
oldSelectionEndLine := self selectionEndLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2230 |
oldSelectionEndCol := self selectionEndCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2231 |
|
5053 | 2232 |
abortExpandAction := |
2233 |
[ |
|
2234 |
self |
|
2235 |
selectFromLine:oldSelectionStartLine col:oldSelectionStartCol |
|
2236 |
toLine:oldSelectionEndLine col:oldSelectionEndCol. |
|
2237 |
self cursorLine:oldCursorLine col:oldCursorCol. |
|
2238 |
]. |
|
4706 | 2239 |
|
2240 |
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
|
2241 |
expandedString isNil ifTrue:[ |
5053 | 2242 |
abortExpandAction value. |
2243 |
^ self |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2244 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2245 |
newCursorPos := expandedString indexOf:$!!. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2246 |
newCursorPos ~~ 0 ifTrue:[ |
5053 | 2247 |
expandedString := expandedString copyWithout:$!!. |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2248 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2249 |
replStartCol := self selectionStartCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2250 |
self |
5053 | 2251 |
undoableDo:[ |
2252 |
self replaceSelectionBy: expandedString |
|
2253 |
] |
|
2254 |
info:'Replace'. |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2255 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2256 |
newCursorPos == 0 ifTrue:[ |
5053 | 2257 |
"/ cursor already fine (at the end) |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2258 |
] ifFalse:[ |
5053 | 2259 |
self cursorCol:replStartCol+newCursorPos-1 |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2260 |
] |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2261 |
! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2262 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2263 |
findAbbreviationKeyBeforeCursor |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2264 |
"after receiving an Alt-shift key-event, look for the string before the |
5053 | 2265 |
cursor, find an abbrev for it, return the key and the abbreviation for it. |
4706 | 2266 |
If none is found, return nil" |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2267 |
|
4745 | 2268 |
|snippets keys minMax maxKeyLen minKeyLen stringBeforeCursor| |
2269 |
||
5144 | 2270 |
snippets := self class snippets. |
4745 | 2271 |
keys := snippets keys. |
4714 | 2272 |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2273 |
minMax := (keys collect:[:k | k size]) minMax. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2274 |
minKeyLen := minMax first. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2275 |
maxKeyLen := minMax second. |
4714 | 2276 |
|
2277 |
stringBeforeCursor := self lineStringBeforeCursor. |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2278 |
maxKeyLen := maxKeyLen min:stringBeforeCursor size. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2279 |
|
4706 | 2280 |
maxKeyLen to:minKeyLen by:-1 do:[:keyLen | |
5144 | 2281 |
|lCharactersBeforeCursor expandedString| |
2282 |
||
2283 |
lCharactersBeforeCursor := stringBeforeCursor last:keyLen. |
|
2284 |
expandedString := snippets at:lCharactersBeforeCursor ifAbsent:nil. |
|
2285 |
expandedString notNil ifTrue:[ |
|
2286 |
^ { lCharactersBeforeCursor . expandedString withCRs } |
|
2287 |
]. |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2288 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2289 |
^ nil. |
4185 | 2290 |
|
2291 |
"Modified: / 29-10-2010 / 10:22:38 / cg" |
|
4617 | 2292 |
! |
2293 |
||
4706 | 2294 |
selectAbbreviationKeyBeforeCursor |
2295 |
"after receiving an Alt-shift key-event, look for the string before the |
|
5053 | 2296 |
cursor, find an abbrev for it, select it and return the abbreviation for it. |
4706 | 2297 |
If none is found, do not select and return nil" |
2298 |
||
4745 | 2299 |
|keyAndSnippet snippet key| |
2300 |
||
2301 |
(keyAndSnippet := self findAbbreviationKeyBeforeCursor) notNil ifTrue:[ |
|
5053 | 2302 |
key := keyAndSnippet first. |
2303 |
snippet := keyAndSnippet second. |
|
2304 |
self selectFromLine:cursorLine col:cursorCol-key size toLine:cursorLine col:cursorCol-1. |
|
2305 |
^ snippet |
|
4706 | 2306 |
]. |
2307 |
^ nil. |
|
2308 |
||
2309 |
"Modified: / 29-10-2010 / 10:22:38 / cg" |
|
2310 |
! |
|
2311 |
||
4617 | 2312 |
selectedTextOrSyntaxElement |
2313 |
|selectedText el| |
|
2314 |
||
2315 |
selectedText := self selectionAsString. |
|
2316 |
selectedText isEmptyOrNil ifTrue:[ |
|
5065 | 2317 |
el := self syntaxElementUnderCursor. |
2318 |
el notNil ifTrue:[ selectedText := el value ]. |
|
4617 | 2319 |
]. |
5053 | 2320 |
^ selectedText |
4998 | 2321 |
! |
2322 |
||
2323 |
syntaxElementForSelectorUnderCursor |
|
5065 | 2324 |
"we do not support syntax elements, but subclasses may do" |
2325 |
||
2326 |
^ nil |
|
2327 |
! |
|
2328 |
||
2329 |
syntaxElementUnderCursor |
|
2330 |
"we do not support syntax elements, but subclasses may do" |
|
4998 | 2331 |
|
2332 |
^ nil |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2333 |
! ! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2334 |
|
2646 | 2335 |
!Workspace methodsFor:'queries'! |
2336 |
||
2337 |
isWorkspace |
|
4395 | 2338 |
"back-query from the compiler to ask if this is an interactive view |
2339 |
(for error feedback)" |
|
2340 |
||
2646 | 2341 |
^ true |
4395 | 2342 |
|
2343 |
"Modified (comment): / 07-03-2012 / 17:52:59 / cg" |
|
5990 | 2344 |
! |
2345 |
||
2346 |
showLineLimitInMenu |
|
2347 |
^ false. |
|
2646 | 2348 |
! ! |
2349 |
||
206 | 2350 |
!Workspace class methodsFor:'documentation'! |
2351 |
||
4402 | 2352 |
version |
5396 | 2353 |
^ '$Header$' |
4402 | 2354 |
! |
2355 |
||
3959 | 2356 |
version_CVS |
5396 | 2357 |
^ '$Header$' |
858 | 2358 |
! ! |
5065 | 2359 |