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