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