author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 30 Jan 2013 11:15:09 +0000 | |
branch | jv |
changeset 12401 | 4714b9640528 |
parent 12265 | f1b3696cf042 |
parent 11618 | 29842c419b87 |
child 12431 | 9f0c59c742d5 |
permissions | -rw-r--r-- |
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
1 |
" |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
3 |
All Rights Reserved |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
4 |
|
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
5 |
This software is furnished under a license and may be used |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
10 |
hereby transferred. |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
11 |
" |
11183 | 12 |
"{ Package: 'stx:libtool' }" |
13 |
||
14 |
"{ NameSpace: Tools }" |
|
15 |
||
12262 | 16 |
Tools::CodeViewService subclass:#BackgroundSourceProcessingService |
11183 | 17 |
instanceVariableNames:'job done modified' |
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'Interface-CodeView' |
|
21 |
! |
|
22 |
||
23 |
!BackgroundSourceProcessingService class methodsFor:'documentation'! |
|
24 |
||
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
25 |
copyright |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
26 |
" |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
27 |
COPYRIGHT (c) 2006 by eXept Software AG |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
28 |
All Rights Reserved |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
29 |
|
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
30 |
This software is furnished under a license and may be used |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
31 |
only in accordance with the terms of that license and with the |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
32 |
inclusion of the above copyright notice. This software may not |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
33 |
be provided or otherwise made available to, or used by, any |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
34 |
other person. No title to or ownership of the software is |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
35 |
hereby transferred. |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
36 |
" |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
37 |
! |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
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 |
||
12401
4714b9640528
Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
58 |
|
11183 | 59 |
!BackgroundSourceProcessingService class methodsFor:'testing'! |
60 |
||
61 |
isAbstract |
|
62 |
||
63 |
^self == Tools::BackgroundSourceProcessingService |
|
64 |
||
65 |
"Created: / 24-01-2012 / 12:27:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
66 |
! ! |
|
67 |
||
12401
4714b9640528
Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
68 |
|
11183 | 69 |
!BackgroundSourceProcessingService methodsFor:'acessing-defaults'! |
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 |
||
12401
4714b9640528
Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
79 |
|
11183 | 80 |
!BackgroundSourceProcessingService methodsFor:'change & update'! |
81 |
||
12194
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
82 |
modelChanged |
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
83 |
"Model has changed (i.e., value holder keeping displayed text" |
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
84 |
|
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
85 |
self sourceChanged: true |
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
86 |
|
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
87 |
"Created: / 17-03-2012 / 15:45:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
88 |
! |
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
89 |
|
11183 | 90 |
sourceChanged:force |
91 |
"Called when codeview's text changes" |
|
92 |
||
12194
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
93 |
(force or:[codeView reallyModified]) ifTrue:[ |
11183 | 94 |
self process |
95 |
]. |
|
96 |
||
97 |
"Modified: / 22-08-2011 / 13:51:53 / cg" |
|
98 |
"Modified (format): / 05-09-2011 / 05:06:40 / cg" |
|
12194
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
99 |
"Modified: / 17-03-2012 / 16:04:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11183 | 100 |
! |
101 |
||
102 |
update:aspect with:param from:sender |
|
103 |
textView notNil ifTrue:[ |
|
104 |
"/sender == textView modifiedChannel ifTrue:[^self codeChanged: false]. |
|
105 |
sender == textView model ifTrue:[ |
|
12172
047fafb1c37f
Avoid reprocessing when test has not changed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
106 |
sender value ~= textView contents ifTrue:[ |
12194
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
107 |
self modelChanged. |
12172
047fafb1c37f
Avoid reprocessing when test has not changed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
108 |
^self. |
047fafb1c37f
Avoid reprocessing when test has not changed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
109 |
]. |
11183 | 110 |
]. |
111 |
(sender == textView and:[aspect == #sizeOfContents]) ifTrue:[ |
|
12172
047fafb1c37f
Avoid reprocessing when test has not changed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
112 |
self sourceChanged:true. |
047fafb1c37f
Avoid reprocessing when test has not changed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
113 |
^self. |
11183 | 114 |
]. |
115 |
]. |
|
116 |
codeView notNil ifTrue:[ |
|
117 |
sender == codeView languageHolder ifTrue:[ |
|
118 |
^ self sourceChanged:true |
|
119 |
]. |
|
120 |
sender == codeView classHolder ifTrue:[ |
|
121 |
^ self sourceChanged:true |
|
122 |
]. |
|
123 |
]. |
|
124 |
super |
|
125 |
update:aspect |
|
126 |
with:param |
|
127 |
from:sender |
|
128 |
||
129 |
"Created: / 06-03-2010 / 19:38:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
130 |
"Modified: / 13-09-2011 / 12:00:29 / cg" |
|
12172
047fafb1c37f
Avoid reprocessing when test has not changed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
131 |
"Modified: / 22-02-2012 / 15:02:16 / jv" |
12194
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
132 |
"Modified: / 17-03-2012 / 16:06:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11183 | 133 |
! ! |
134 |
||
12401
4714b9640528
Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
135 |
|
11183 | 136 |
!BackgroundSourceProcessingService methodsFor:'event handling'! |
137 |
||
138 |
linesDeletedFrom:start to:end |
|
139 |
self sourceChanged:true |
|
140 |
||
141 |
"Created: / 06-07-2011 / 17:14:36 / jv" |
|
142 |
"Created: / 16-09-2011 / 15:18:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
143 |
! |
|
144 |
||
145 |
linesInsertedFrom:start to:end |
|
146 |
self sourceChanged:true |
|
147 |
||
148 |
"Created: / 06-07-2011 / 17:14:36 / jv" |
|
149 |
"Created: / 16-09-2011 / 15:18:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
150 |
! |
|
151 |
||
152 |
linesModifiedFrom:start to:end |
|
153 |
self sourceChanged:true |
|
154 |
||
155 |
"Created: / 06-07-2011 / 17:14:36 / jv" |
|
156 |
"Created: / 16-09-2011 / 15:15:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
157 |
! ! |
|
158 |
||
12401
4714b9640528
Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
159 |
|
11183 | 160 |
!BackgroundSourceProcessingService methodsFor:'initialization'! |
161 |
||
162 |
initialize |
|
163 |
job := (Smalltalk at:#BackgroundJob) |
|
164 |
named:self defaultJobName |
|
11618 | 165 |
on:[ |
166 |
Error handle:[:ex | |
|
167 |
(Dialog confirm:('Error while processing source:\\',ex description,'\\Debug ?') withCRs) |
|
168 |
ifTrue:[ |
|
169 |
ex reject. |
|
170 |
] |
|
171 |
] do:[ |
|
172 |
self process:true |
|
173 |
] |
|
174 |
]. |
|
11183 | 175 |
|
176 |
"Created: / 29-07-2011 / 10:31:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
177 |
"Modified: / 24-01-2012 / 12:26:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11618 | 178 |
"Modified: / 19-07-2012 / 16:17:21 / cg" |
11183 | 179 |
! ! |
180 |
||
12401
4714b9640528
Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
181 |
|
11183 | 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 |
]. |
11558 | 206 |
prio := 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 |
|
215 |
"Do the real source processing. If delayed is true, actuall data update must |
|
216 |
be done within the event queue using #pushUserEvent:... |
|
217 |
" |
|
218 |
||
219 |
self subclassResponsibility |
|
220 |
||
221 |
"Created: / 24-01-2012 / 12:25:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
222 |
! ! |
|
223 |
||
12401
4714b9640528
Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
224 |
|
11183 | 225 |
!BackgroundSourceProcessingService methodsFor:'registering'! |
226 |
||
227 |
registerIn: aCodeView |
|
228 |
||
229 |
super registerIn: aCodeView. |
|
230 |
textView addDependent: self. |
|
231 |
||
232 |
"Created: / 27-07-2011 / 13:25:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
233 |
! ! |
|
234 |
||
12401
4714b9640528
Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
235 |
|
11183 | 236 |
!BackgroundSourceProcessingService class methodsFor:'documentation'! |
237 |
||
238 |
version |
|
11618 | 239 |
^ '$Header: /cvs/stx/stx/libtool/Tools__BackgroundSourceProcessingService.st,v 1.3 2012-07-19 15:19:59 cg Exp $' |
11183 | 240 |
! |
241 |
||
242 |
version_CVS |
|
11618 | 243 |
^ '$Header: /cvs/stx/stx/libtool/Tools__BackgroundSourceProcessingService.st,v 1.3 2012-07-19 15:19:59 cg Exp $' |
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
244 |
! |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
245 |
|
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
246 |
version_SVN |
12265 | 247 |
^ '$Id: Tools__BackgroundSourceProcessingService.st 8022 2012-07-25 09:51:30Z vranyj1 $' |
11183 | 248 |
! ! |
12401
4714b9640528
Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
249 |