author | mawalch |
Mon, 03 Apr 2017 07:15:26 +0200 | |
changeset 17486 | 80f1e777dcaa |
parent 17356 | c3f338f412b9 |
child 17717 | 13cd6ef0aeb8 |
permissions | -rw-r--r-- |
13881 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
11183 | 12 |
"{ Package: 'stx:libtool' }" |
13 |
||
14 |
"{ NameSpace: Tools }" |
|
15 |
||
16 |
CodeViewService subclass:#BackgroundSourceProcessingService |
|
17 |
instanceVariableNames:'job done modified' |
|
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'Interface-CodeView' |
|
21 |
! |
|
22 |
||
23 |
!BackgroundSourceProcessingService class methodsFor:'documentation'! |
|
24 |
||
13881 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
11183 | 39 |
documentation |
40 |
" |
|
41 |
An abstract base class for all services that process current |
|
42 |
(displayed) source code. All processing is done in background |
|
43 |
job, that is restarted whenever a text in the editor is changed. |
|
44 |
||
45 |
[author:] |
|
46 |
Jan Vrany <jan.vrany@fit.cvut.cz> |
|
47 |
||
48 |
[instance variables:] |
|
49 |
job <BackgroundJob> A background job. |
|
50 |
||
51 |
[class variables:] |
|
52 |
||
53 |
[see also:] |
|
54 |
||
55 |
" |
|
56 |
! ! |
|
57 |
||
16190 | 58 |
!BackgroundSourceProcessingService class methodsFor:'queries'! |
11183 | 59 |
|
60 |
isAbstract |
|
61 |
||
62 |
^self == Tools::BackgroundSourceProcessingService |
|
63 |
||
64 |
"Created: / 24-01-2012 / 12:27:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
65 |
! ! |
|
66 |
||
16763 | 67 |
!BackgroundSourceProcessingService methodsFor:'accessing-defaults'! |
11183 | 68 |
|
69 |
defaultJobName |
|
70 |
"Returns a human-readable job name, to ease identification in process browser" |
|
71 |
||
72 |
^ 'CodeView2''s source processing job' |
|
73 |
||
74 |
"Created: / 24-01-2012 / 12:05:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
75 |
! ! |
|
76 |
||
77 |
!BackgroundSourceProcessingService methodsFor:'change & update'! |
|
78 |
||
13881 | 79 |
modelChanged |
15501
46e2abb0c3e2
class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents:
14973
diff
changeset
|
80 |
"Model has changed (i.e. value holder keeping displayed text" |
13881 | 81 |
|
82 |
self sourceChanged: true |
|
83 |
||
84 |
"Created: / 17-03-2012 / 15:45:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
85 |
! |
|
86 |
||
11183 | 87 |
sourceChanged:force |
88 |
"Called when codeview's text changes" |
|
89 |
||
13881 | 90 |
(force or:[codeView reallyModified]) ifTrue:[ |
15501
46e2abb0c3e2
class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents:
14973
diff
changeset
|
91 |
self process. |
46e2abb0c3e2
class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents:
14973
diff
changeset
|
92 |
"/ cg: tried to avoid multiple processing, |
46e2abb0c3e2
class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents:
14973
diff
changeset
|
93 |
"/ but it seems to not help - still doing multiple |
46e2abb0c3e2
class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents:
14973
diff
changeset
|
94 |
"/ when clicking on a new method in a mixed-class-method list |
46e2abb0c3e2
class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents:
14973
diff
changeset
|
95 |
"/ (one for the method-class, one for the source) |
46e2abb0c3e2
class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents:
14973
diff
changeset
|
96 |
"/ codeView sensor enqueueMessage:#process for:self arguments:nil "/ self process |
11183 | 97 |
]. |
98 |
||
99 |
"Modified: / 22-08-2011 / 13:51:53 / cg" |
|
100 |
"Modified (format): / 05-09-2011 / 05:06:40 / cg" |
|
13881 | 101 |
"Modified: / 17-03-2012 / 16:04:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11183 | 102 |
! |
103 |
||
104 |
update:aspect with:param from:sender |
|
105 |
textView notNil ifTrue:[ |
|
106 |
"/sender == textView modifiedChannel ifTrue:[^self codeChanged: false]. |
|
107 |
sender == textView model ifTrue:[ |
|
13881 | 108 |
sender value ~= textView contents ifTrue:[ |
109 |
self modelChanged. |
|
110 |
^self. |
|
111 |
]. |
|
11183 | 112 |
]. |
113 |
(sender == textView and:[aspect == #sizeOfContents]) ifTrue:[ |
|
13881 | 114 |
self sourceChanged:true. |
115 |
^self. |
|
11183 | 116 |
]. |
117 |
]. |
|
118 |
codeView notNil ifTrue:[ |
|
119 |
sender == codeView languageHolder ifTrue:[ |
|
13881 | 120 |
self sourceChanged:true. |
121 |
^self |
|
11183 | 122 |
]. |
123 |
sender == codeView classHolder ifTrue:[ |
|
13881 | 124 |
self sourceChanged:true. |
125 |
^self |
|
11183 | 126 |
]. |
127 |
]. |
|
13881 | 128 |
|
129 |
aspect == #codeAspect ifTrue:[ |
|
130 |
self sourceChanged:true. |
|
131 |
^self |
|
132 |
]. |
|
133 |
||
11183 | 134 |
super |
135 |
update:aspect |
|
136 |
with:param |
|
137 |
from:sender |
|
138 |
||
139 |
"Created: / 06-03-2010 / 19:38:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
140 |
"Modified: / 13-09-2011 / 12:00:29 / cg" |
|
13881 | 141 |
"Modified: / 22-02-2012 / 15:02:16 / jv" |
142 |
"Modified: / 15-04-2013 / 23:00:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11183 | 143 |
! ! |
144 |
||
145 |
!BackgroundSourceProcessingService methodsFor:'event handling'! |
|
146 |
||
147 |
linesDeletedFrom:start to:end |
|
148 |
self sourceChanged:true |
|
149 |
||
150 |
"Created: / 06-07-2011 / 17:14:36 / jv" |
|
151 |
"Created: / 16-09-2011 / 15:18:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
152 |
! |
|
153 |
||
154 |
linesInsertedFrom:start to:end |
|
155 |
self sourceChanged:true |
|
156 |
||
157 |
"Created: / 06-07-2011 / 17:14:36 / jv" |
|
158 |
"Created: / 16-09-2011 / 15:18:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
159 |
! |
|
160 |
||
161 |
linesModifiedFrom:start to:end |
|
162 |
self sourceChanged:true |
|
163 |
||
164 |
"Created: / 06-07-2011 / 17:14:36 / jv" |
|
165 |
"Created: / 16-09-2011 / 15:15:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
166 |
! ! |
|
167 |
||
168 |
!BackgroundSourceProcessingService methodsFor:'initialization'! |
|
169 |
||
170 |
initialize |
|
171 |
job := (Smalltalk at:#BackgroundJob) |
|
172 |
named:self defaultJobName |
|
14053
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
173 |
on:[self processSafely: true] |
11183 | 174 |
|
175 |
"Created: / 29-07-2011 / 10:31:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11618 | 176 |
"Modified: / 19-07-2012 / 16:17:21 / cg" |
14053
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
177 |
"Modified: / 25-02-2014 / 19:58:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11183 | 178 |
! ! |
179 |
||
180 |
!BackgroundSourceProcessingService methodsFor:'processing'! |
|
181 |
||
182 |
process |
|
183 |
"(Re)starts the processing job. Should be called whenever a source |
|
184 |
must be (re)processed." |
|
185 |
||
11558 | 186 |
| prio browser | |
11183 | 187 |
|
188 |
"/ this clobbers the codeViews modified state; therefore, we have to remember |
|
189 |
"/ this info somewhere ... |
|
11558 | 190 |
(browser := codeView browser) notNil ifTrue:[ |
11183 | 191 |
textView modified ifTrue:[ |
11558 | 192 |
browser navigationState realModifiedState: true |
11183 | 193 |
]. |
194 |
textView modifiedChannel setValue:false. |
|
195 |
]. |
|
196 |
||
197 |
job scheduled ifTrue:[ |
|
198 |
job running ifFalse:[ |
|
199 |
"/ process already created, but did not get a change to start yet; |
|
200 |
^ self |
|
11558 | 201 |
]. |
202 |
job stop. |
|
11183 | 203 |
]. |
17165 | 204 |
prio := (Processor activePriority - 1) min:Processor userBackgroundPriority. |
11183 | 205 |
job startWithPriority: prio. |
206 |
||
207 |
"Modified: / 07-07-2011 / 12:26:12 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
|
208 |
"Created: / 24-01-2012 / 12:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11558 | 209 |
"Modified: / 05-06-2012 / 23:58:20 / cg" |
11183 | 210 |
! |
211 |
||
212 |
process: delayed |
|
14053
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
213 |
"Actually process source code. If `delayed` is true, view should be updated |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
214 |
asynchronously using #pushUserEvent:. Individual services should override |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
215 |
this method. |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
216 |
|
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
217 |
NOTE: Do not call this method from custom code directly, always call |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
218 |
#processSafely: which handle possible errors and protect against |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
219 |
'debugger bomb' |
11183 | 220 |
" |
221 |
||
222 |
self subclassResponsibility |
|
223 |
||
224 |
"Created: / 24-01-2012 / 12:25:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14053
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
225 |
"Modified (comment): / 25-02-2014 / 19:52:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
226 |
! |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
227 |
|
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
228 |
processSafely: delayed |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
229 |
"Process source code. If `delayed` is true, view should be updated |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
230 |
asynchronously using #pushUserEvent:" |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
231 |
|
16435 | 232 |
DebugView |
233 |
withOptionToIgnoreException:(BreakPointInterrupt,HaltInterrupt,Error) |
|
234 |
do:[ |
|
17356 | 235 |
(Error , ControlInterrupt) handle:[:ex| |
16435 | 236 |
"/ Kludge... |
17356 | 237 |
(codeView topView notNil and:[codeView topView isDebugView]) ifTrue:[ |
238 |
Transcript showCR: 'Error/Interrupt when processing source code'. |
|
16435 | 239 |
ex suspendedContext fullPrintAllOn: Transcript. |
240 |
ex return. |
|
15732
a40158f53779
class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents:
15731
diff
changeset
|
241 |
]. |
16435 | 242 |
ex reject "/ go ask for debugging |
243 |
] do:[ |
|
244 |
self process: delayed |
|
14053
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
245 |
] |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
246 |
] |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
247 |
|
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
248 |
"Created: / 25-02-2014 / 19:57:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
15562
97647e9841b7
Ignore also BreakpointInterrupt in #processSafely:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15501
diff
changeset
|
249 |
"Modified: / 27-03-2015 / 15:56:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11183 | 250 |
! ! |
251 |
||
252 |
!BackgroundSourceProcessingService methodsFor:'registering'! |
|
253 |
||
254 |
registerIn: aCodeView |
|
255 |
||
256 |
super registerIn: aCodeView. |
|
257 |
textView addDependent: self. |
|
258 |
||
259 |
"Created: / 27-07-2011 / 13:25:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14493
c2c143bf52a0
Fix in Tools::BackgroundSourceProcessingService>>unregister: stop possibly running background job
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14054
diff
changeset
|
260 |
! |
c2c143bf52a0
Fix in Tools::BackgroundSourceProcessingService>>unregister: stop possibly running background job
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14054
diff
changeset
|
261 |
|
c2c143bf52a0
Fix in Tools::BackgroundSourceProcessingService>>unregister: stop possibly running background job
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14054
diff
changeset
|
262 |
unregister |
c2c143bf52a0
Fix in Tools::BackgroundSourceProcessingService>>unregister: stop possibly running background job
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14054
diff
changeset
|
263 |
job stop. |
14704
5de671ef2e61
Fix in Tools::BackgroundSourceProcessingService>>unregister: remove itself from
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14493
diff
changeset
|
264 |
textView removeDependent: self. |
14493
c2c143bf52a0
Fix in Tools::BackgroundSourceProcessingService>>unregister: stop possibly running background job
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14054
diff
changeset
|
265 |
super unregister. |
c2c143bf52a0
Fix in Tools::BackgroundSourceProcessingService>>unregister: stop possibly running background job
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14054
diff
changeset
|
266 |
|
c2c143bf52a0
Fix in Tools::BackgroundSourceProcessingService>>unregister: stop possibly running background job
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14054
diff
changeset
|
267 |
"Created: / 13-06-2014 / 15:36:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
14704
5de671ef2e61
Fix in Tools::BackgroundSourceProcessingService>>unregister: remove itself from
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14493
diff
changeset
|
268 |
"Modified: / 08-08-2014 / 06:57:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11183 | 269 |
! ! |
270 |
||
271 |
!BackgroundSourceProcessingService class methodsFor:'documentation'! |
|
272 |
||
273 |
version |
|
15731
f205f06960fa
class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents:
15562
diff
changeset
|
274 |
^ '$Header$' |
11183 | 275 |
! |
276 |
||
277 |
version_CVS |
|
15731
f205f06960fa
class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents:
15562
diff
changeset
|
278 |
^ '$Header$' |
11183 | 279 |
! ! |
13881 | 280 |