author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 25 Feb 2014 21:04:27 +0100 | |
changeset 14053 | 08f7da1dd758 |
parent 13881 | ceebd29ba8f6 |
child 14054 | 1931f75c8318 |
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 |
||
58 |
!BackgroundSourceProcessingService class methodsFor:'testing'! |
|
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 |
||
67 |
!BackgroundSourceProcessingService methodsFor:'acessing-defaults'! |
|
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 |
80 |
"Model has changed (i.e., value holder keeping displayed text" |
|
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:[ |
11183 | 91 |
self process |
92 |
]. |
|
93 |
||
94 |
"Modified: / 22-08-2011 / 13:51:53 / cg" |
|
95 |
"Modified (format): / 05-09-2011 / 05:06:40 / cg" |
|
13881 | 96 |
"Modified: / 17-03-2012 / 16:04:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11183 | 97 |
! |
98 |
||
99 |
update:aspect with:param from:sender |
|
100 |
textView notNil ifTrue:[ |
|
101 |
"/sender == textView modifiedChannel ifTrue:[^self codeChanged: false]. |
|
102 |
sender == textView model ifTrue:[ |
|
13881 | 103 |
sender value ~= textView contents ifTrue:[ |
104 |
self modelChanged. |
|
105 |
^self. |
|
106 |
]. |
|
11183 | 107 |
]. |
108 |
(sender == textView and:[aspect == #sizeOfContents]) ifTrue:[ |
|
13881 | 109 |
self sourceChanged:true. |
110 |
^self. |
|
11183 | 111 |
]. |
112 |
]. |
|
113 |
codeView notNil ifTrue:[ |
|
114 |
sender == codeView languageHolder ifTrue:[ |
|
13881 | 115 |
self sourceChanged:true. |
116 |
^self |
|
11183 | 117 |
]. |
118 |
sender == codeView classHolder ifTrue:[ |
|
13881 | 119 |
self sourceChanged:true. |
120 |
^self |
|
11183 | 121 |
]. |
122 |
]. |
|
13881 | 123 |
|
124 |
aspect == #codeAspect ifTrue:[ |
|
125 |
self sourceChanged:true. |
|
126 |
^self |
|
127 |
]. |
|
128 |
||
11183 | 129 |
super |
130 |
update:aspect |
|
131 |
with:param |
|
132 |
from:sender |
|
133 |
||
134 |
"Created: / 06-03-2010 / 19:38:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
135 |
"Modified: / 13-09-2011 / 12:00:29 / cg" |
|
13881 | 136 |
"Modified: / 22-02-2012 / 15:02:16 / jv" |
137 |
"Modified: / 15-04-2013 / 23:00:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11183 | 138 |
! ! |
139 |
||
140 |
!BackgroundSourceProcessingService methodsFor:'event handling'! |
|
141 |
||
142 |
linesDeletedFrom:start to:end |
|
143 |
self sourceChanged:true |
|
144 |
||
145 |
"Created: / 06-07-2011 / 17:14:36 / jv" |
|
146 |
"Created: / 16-09-2011 / 15:18:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
147 |
! |
|
148 |
||
149 |
linesInsertedFrom:start to:end |
|
150 |
self sourceChanged:true |
|
151 |
||
152 |
"Created: / 06-07-2011 / 17:14:36 / jv" |
|
153 |
"Created: / 16-09-2011 / 15:18:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
154 |
! |
|
155 |
||
156 |
linesModifiedFrom:start to:end |
|
157 |
self sourceChanged:true |
|
158 |
||
159 |
"Created: / 06-07-2011 / 17:14:36 / jv" |
|
160 |
"Created: / 16-09-2011 / 15:15:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
161 |
! ! |
|
162 |
||
163 |
!BackgroundSourceProcessingService methodsFor:'initialization'! |
|
164 |
||
165 |
initialize |
|
166 |
job := (Smalltalk at:#BackgroundJob) |
|
167 |
named:self defaultJobName |
|
14053
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
168 |
on:[self processSafely: true] |
11183 | 169 |
|
170 |
"Created: / 29-07-2011 / 10:31:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11618 | 171 |
"Modified: / 19-07-2012 / 16:17:21 / cg" |
14053
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
172 |
"Modified: / 25-02-2014 / 19:58:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11183 | 173 |
! ! |
174 |
||
175 |
!BackgroundSourceProcessingService methodsFor:'processing'! |
|
176 |
||
177 |
process |
|
178 |
"(Re)starts the processing job. Should be called whenever a source |
|
179 |
must be (re)processed." |
|
180 |
||
11558 | 181 |
| prio browser | |
11183 | 182 |
|
183 |
"/ this clobbers the codeViews modified state; therefore, we have to remember |
|
184 |
"/ this info somewhere ... |
|
11558 | 185 |
(browser := codeView browser) notNil ifTrue:[ |
11183 | 186 |
textView modified ifTrue:[ |
11558 | 187 |
browser navigationState realModifiedState: true |
11183 | 188 |
]. |
189 |
textView modifiedChannel setValue:false. |
|
190 |
]. |
|
191 |
||
192 |
job scheduled ifTrue:[ |
|
193 |
job running ifFalse:[ |
|
194 |
"/ process already created, but did not get a change to start yet; |
|
195 |
^ self |
|
11558 | 196 |
]. |
197 |
job stop. |
|
11183 | 198 |
]. |
11558 | 199 |
prio := Processor userBackgroundPriority. |
11183 | 200 |
job startWithPriority: prio. |
201 |
||
202 |
"Modified: / 07-07-2011 / 12:26:12 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
|
203 |
"Created: / 24-01-2012 / 12:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11558 | 204 |
"Modified: / 05-06-2012 / 23:58:20 / cg" |
11183 | 205 |
! |
206 |
||
207 |
process: delayed |
|
14053
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
208 |
"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
|
209 |
asynchronously using #pushUserEvent:. Individual services should override |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
210 |
this method. |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
211 |
|
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
212 |
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
|
213 |
#processSafely: which handle possible errors and protect against |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
214 |
'debugger bomb' |
11183 | 215 |
" |
216 |
||
217 |
self subclassResponsibility |
|
218 |
||
219 |
"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
|
220 |
"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
|
221 |
! |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
222 |
|
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
223 |
processSafely: delayed |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
224 |
"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
|
225 |
asynchronously using #pushUserEvent:" |
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 |
Exception , HaltInterrupt handle:[:ex| |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
228 |
"/ Kludge... |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
229 |
(codeView topView class == DebugView) ifTrue:[ |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
230 |
Transcript showCR: 'Error when processing source code'. |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
231 |
ex suspendedContext fullPrintAllOn: Transcript. |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
232 |
] ifFalse:[ |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
233 |
(Dialog confirm:('Error while processing source:\\',ex description,'\\Debug ?') withCRs) ifTrue:[ |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
234 |
ex reject. |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
235 |
] |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
236 |
] |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
237 |
] do:[ |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
238 |
self process: delayed |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
239 |
] |
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
240 |
|
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
241 |
"Created: / 25-02-2014 / 19:57:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11183 | 242 |
! ! |
243 |
||
244 |
!BackgroundSourceProcessingService methodsFor:'registering'! |
|
245 |
||
246 |
registerIn: aCodeView |
|
247 |
||
248 |
super registerIn: aCodeView. |
|
249 |
textView addDependent: self. |
|
250 |
||
251 |
"Created: / 27-07-2011 / 13:25:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
252 |
! ! |
|
253 |
||
254 |
!BackgroundSourceProcessingService class methodsFor:'documentation'! |
|
255 |
||
256 |
version |
|
14053
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
257 |
^ '$Header: /cvs/stx/stx/libtool/Tools__BackgroundSourceProcessingService.st,v 1.5 2014-02-25 20:04:27 vrany Exp $' |
11183 | 258 |
! |
259 |
||
260 |
version_CVS |
|
14053
08f7da1dd758
Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13881
diff
changeset
|
261 |
^ '$Header: /cvs/stx/stx/libtool/Tools__BackgroundSourceProcessingService.st,v 1.5 2014-02-25 20:04:27 vrany Exp $' |
11183 | 262 |
! ! |
13881 | 263 |