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