11183
|
1 |
"{ Package: 'stx:libtool' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Tools }"
|
|
4 |
|
|
5 |
CodeViewService subclass:#BackgroundSourceProcessingService
|
|
6 |
instanceVariableNames:'job done modified'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'Interface-CodeView'
|
|
10 |
!
|
|
11 |
|
|
12 |
!BackgroundSourceProcessingService class methodsFor:'documentation'!
|
|
13 |
|
|
14 |
documentation
|
|
15 |
"
|
|
16 |
An abstract base class for all services that process current
|
|
17 |
(displayed) source code. All processing is done in background
|
|
18 |
job, that is restarted whenever a text in the editor is changed.
|
|
19 |
|
|
20 |
[author:]
|
|
21 |
Jan Vrany <jan.vrany@fit.cvut.cz>
|
|
22 |
|
|
23 |
[instance variables:]
|
|
24 |
job <BackgroundJob> A background job.
|
|
25 |
|
|
26 |
[class variables:]
|
|
27 |
|
|
28 |
[see also:]
|
|
29 |
|
|
30 |
"
|
|
31 |
! !
|
|
32 |
|
|
33 |
!BackgroundSourceProcessingService class methodsFor:'testing'!
|
|
34 |
|
|
35 |
isAbstract
|
|
36 |
|
|
37 |
^self == Tools::BackgroundSourceProcessingService
|
|
38 |
|
|
39 |
"Created: / 24-01-2012 / 12:27:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
40 |
! !
|
|
41 |
|
|
42 |
!BackgroundSourceProcessingService methodsFor:'acessing-defaults'!
|
|
43 |
|
|
44 |
defaultJobName
|
|
45 |
"Returns a human-readable job name, to ease identification in process browser"
|
|
46 |
|
|
47 |
^ 'CodeView2''s source processing job'
|
|
48 |
|
|
49 |
"Created: / 24-01-2012 / 12:05:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
50 |
! !
|
|
51 |
|
|
52 |
!BackgroundSourceProcessingService methodsFor:'change & update'!
|
|
53 |
|
|
54 |
sourceChanged:force
|
|
55 |
"Called when codeview's text changes"
|
|
56 |
|
|
57 |
(force or:[codeView textView modified]) ifTrue:[
|
|
58 |
self process
|
|
59 |
].
|
|
60 |
|
|
61 |
"Modified: / 22-08-2011 / 13:51:53 / cg"
|
|
62 |
"Modified (format): / 05-09-2011 / 05:06:40 / cg"
|
|
63 |
"Modified: / 24-01-2012 / 12:25:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
64 |
!
|
|
65 |
|
|
66 |
update:aspect with:param from:sender
|
|
67 |
textView notNil ifTrue:[
|
|
68 |
"/sender == textView modifiedChannel ifTrue:[^self codeChanged: false].
|
|
69 |
sender == textView model ifTrue:[
|
|
70 |
^ self sourceChanged:true
|
|
71 |
].
|
|
72 |
(sender == textView and:[aspect == #sizeOfContents]) ifTrue:[
|
|
73 |
^ self sourceChanged:true
|
|
74 |
].
|
|
75 |
].
|
|
76 |
codeView notNil ifTrue:[
|
|
77 |
sender == codeView languageHolder ifTrue:[
|
|
78 |
^ self sourceChanged:true
|
|
79 |
].
|
|
80 |
sender == codeView classHolder ifTrue:[
|
|
81 |
^ self sourceChanged:true
|
|
82 |
].
|
|
83 |
].
|
|
84 |
super
|
|
85 |
update:aspect
|
|
86 |
with:param
|
|
87 |
from:sender
|
|
88 |
|
|
89 |
"Created: / 06-03-2010 / 19:38:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
90 |
"Modified: / 13-09-2011 / 12:00:29 / cg"
|
|
91 |
"Modified: / 16-09-2011 / 17:30:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
92 |
! !
|
|
93 |
|
|
94 |
!BackgroundSourceProcessingService methodsFor:'event handling'!
|
|
95 |
|
|
96 |
linesDeletedFrom:start to:end
|
|
97 |
self sourceChanged:true
|
|
98 |
|
|
99 |
"Created: / 06-07-2011 / 17:14:36 / jv"
|
|
100 |
"Created: / 16-09-2011 / 15:18:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
101 |
!
|
|
102 |
|
|
103 |
linesInsertedFrom:start to:end
|
|
104 |
self sourceChanged:true
|
|
105 |
|
|
106 |
"Created: / 06-07-2011 / 17:14:36 / jv"
|
|
107 |
"Created: / 16-09-2011 / 15:18:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
108 |
!
|
|
109 |
|
|
110 |
linesModifiedFrom:start to:end
|
|
111 |
self sourceChanged:true
|
|
112 |
|
|
113 |
"Created: / 06-07-2011 / 17:14:36 / jv"
|
|
114 |
"Created: / 16-09-2011 / 15:15:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
115 |
! !
|
|
116 |
|
|
117 |
!BackgroundSourceProcessingService methodsFor:'initialization'!
|
|
118 |
|
|
119 |
initialize
|
|
120 |
job := (Smalltalk at:#BackgroundJob)
|
|
121 |
named:self defaultJobName
|
|
122 |
on:[self process:true].
|
|
123 |
|
|
124 |
"Created: / 29-07-2011 / 10:31:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
125 |
"Modified: / 03-08-2011 / 16:47:53 / cg"
|
|
126 |
"Modified (format): / 26-09-2011 / 15:39:56 / cg"
|
|
127 |
"Modified: / 24-01-2012 / 12:26:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
128 |
! !
|
|
129 |
|
|
130 |
!BackgroundSourceProcessingService methodsFor:'processing'!
|
|
131 |
|
|
132 |
process
|
|
133 |
"(Re)starts the processing job. Should be called whenever a source
|
|
134 |
must be (re)processed."
|
|
135 |
|
11558
|
136 |
| prio browser |
|
11183
|
137 |
|
|
138 |
"/ this clobbers the codeViews modified state; therefore, we have to remember
|
|
139 |
"/ this info somewhere ...
|
11558
|
140 |
(browser := codeView browser) notNil ifTrue:[
|
11183
|
141 |
textView modified ifTrue:[
|
11558
|
142 |
browser navigationState realModifiedState: true
|
11183
|
143 |
].
|
|
144 |
textView modifiedChannel setValue:false.
|
|
145 |
].
|
|
146 |
|
|
147 |
job scheduled ifTrue:[
|
|
148 |
job running ifFalse:[
|
|
149 |
"/ process already created, but did not get a change to start yet;
|
|
150 |
^ self
|
11558
|
151 |
].
|
|
152 |
job stop.
|
11183
|
153 |
].
|
11558
|
154 |
prio := Processor userBackgroundPriority.
|
11183
|
155 |
job startWithPriority: prio.
|
|
156 |
|
|
157 |
"Modified: / 07-07-2011 / 12:26:12 / Jan Vrany <jan.vrant@fit.cvut,cz>"
|
|
158 |
"Created: / 24-01-2012 / 12:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
11558
|
159 |
"Modified: / 05-06-2012 / 23:58:20 / cg"
|
11183
|
160 |
!
|
|
161 |
|
|
162 |
process: delayed
|
|
163 |
"Do the real source processing. If delayed is true, actuall data update must
|
|
164 |
be done within the event queue using #pushUserEvent:...
|
|
165 |
"
|
|
166 |
|
|
167 |
self subclassResponsibility
|
|
168 |
|
|
169 |
"Created: / 24-01-2012 / 12:25:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
170 |
! !
|
|
171 |
|
|
172 |
!BackgroundSourceProcessingService methodsFor:'registering'!
|
|
173 |
|
|
174 |
registerIn: aCodeView
|
|
175 |
|
|
176 |
super registerIn: aCodeView.
|
|
177 |
textView addDependent: self.
|
|
178 |
|
|
179 |
"Created: / 27-07-2011 / 13:25:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
180 |
! !
|
|
181 |
|
|
182 |
!BackgroundSourceProcessingService class methodsFor:'documentation'!
|
|
183 |
|
|
184 |
version
|
11558
|
185 |
^ '$Header: /cvs/stx/stx/libtool/Tools__BackgroundSourceProcessingService.st,v 1.2 2012-06-05 21:59:55 cg Exp $'
|
11183
|
186 |
!
|
|
187 |
|
|
188 |
version_CVS
|
11558
|
189 |
^ '$Header: /cvs/stx/stx/libtool/Tools__BackgroundSourceProcessingService.st,v 1.2 2012-06-05 21:59:55 cg Exp $'
|
11183
|
190 |
! !
|