author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Thu, 27 Sep 2012 21:08:20 +0100 | |
branch | jv |
changeset 12296 | 6921627a8c27 |
parent 12265 | f1b3696cf042 |
child 12401 | 4714b9640528 |
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 |
" |
12125 | 12 |
"{ Package: 'stx:libtool' }" |
13 |
||
14 |
"{ NameSpace: Tools }" |
|
15 |
||
12262 | 16 |
Tools::CodeViewService subclass:#BackgroundSourceProcessingService |
12125 | 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 |
|
12125 | 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 |
||
12194
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
79 |
modelChanged |
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
80 |
"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
|
81 |
|
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
82 |
self sourceChanged: true |
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
83 |
|
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
84 |
"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
|
85 |
! |
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
86 |
|
12125 | 87 |
sourceChanged:force |
88 |
"Called when codeview's text changes" |
|
89 |
||
12194
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
90 |
(force or:[codeView reallyModified]) ifTrue:[ |
12125 | 91 |
self process |
92 |
]. |
|
93 |
||
94 |
"Modified: / 22-08-2011 / 13:51:53 / cg" |
|
95 |
"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
|
96 |
"Modified: / 17-03-2012 / 16:04:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
12125 | 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:[ |
|
12172
047fafb1c37f
Avoid reprocessing when test has not changed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
103 |
sender value ~= textView contents ifTrue:[ |
12194
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12172
diff
changeset
|
104 |
self modelChanged. |
12172
047fafb1c37f
Avoid reprocessing when test has not changed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
105 |
^self. |
047fafb1c37f
Avoid reprocessing when test has not changed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
106 |
]. |
12125 | 107 |
]. |
108 |
(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
|
109 |
self sourceChanged:true. |
047fafb1c37f
Avoid reprocessing when test has not changed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
110 |
^self. |
12125 | 111 |
]. |
112 |
]. |
|
113 |
codeView notNil ifTrue:[ |
|
114 |
sender == codeView languageHolder ifTrue:[ |
|
115 |
^ self sourceChanged:true |
|
116 |
]. |
|
117 |
sender == codeView classHolder ifTrue:[ |
|
118 |
^ self sourceChanged:true |
|
119 |
]. |
|
120 |
]. |
|
121 |
super |
|
122 |
update:aspect |
|
123 |
with:param |
|
124 |
from:sender |
|
125 |
||
126 |
"Created: / 06-03-2010 / 19:38:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
127 |
"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
|
128 |
"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
|
129 |
"Modified: / 17-03-2012 / 16:06:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
12125 | 130 |
! ! |
131 |
||
132 |
!BackgroundSourceProcessingService methodsFor:'event handling'! |
|
133 |
||
134 |
linesDeletedFrom:start to:end |
|
135 |
self sourceChanged:true |
|
136 |
||
137 |
"Created: / 06-07-2011 / 17:14:36 / jv" |
|
138 |
"Created: / 16-09-2011 / 15:18:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
139 |
! |
|
140 |
||
141 |
linesInsertedFrom:start to:end |
|
142 |
self sourceChanged:true |
|
143 |
||
144 |
"Created: / 06-07-2011 / 17:14:36 / jv" |
|
145 |
"Created: / 16-09-2011 / 15:18:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
146 |
! |
|
147 |
||
148 |
linesModifiedFrom:start to:end |
|
149 |
self sourceChanged:true |
|
150 |
||
151 |
"Created: / 06-07-2011 / 17:14:36 / jv" |
|
152 |
"Created: / 16-09-2011 / 15:15:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
153 |
! ! |
|
154 |
||
155 |
!BackgroundSourceProcessingService methodsFor:'initialization'! |
|
156 |
||
157 |
initialize |
|
158 |
job := (Smalltalk at:#BackgroundJob) |
|
159 |
named:self defaultJobName |
|
12265 | 160 |
on:[ |
161 |
Error handle:[:ex | |
|
162 |
(Dialog confirm:('Error while processing source:\\',ex description,'\\Debug ?') withCRs) |
|
163 |
ifTrue:[ |
|
164 |
ex reject. |
|
165 |
] |
|
166 |
] do:[ |
|
167 |
self process:true |
|
168 |
] |
|
169 |
]. |
|
12125 | 170 |
|
171 |
"Created: / 29-07-2011 / 10:31:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
172 |
"Modified: / 24-01-2012 / 12:26:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12265 | 173 |
"Modified: / 19-07-2012 / 16:17:21 / cg" |
12125 | 174 |
! ! |
175 |
||
176 |
!BackgroundSourceProcessingService methodsFor:'processing'! |
|
177 |
||
178 |
process |
|
179 |
"(Re)starts the processing job. Should be called whenever a source |
|
180 |
must be (re)processed." |
|
181 |
||
12262 | 182 |
| prio browser | |
12125 | 183 |
|
184 |
"/ this clobbers the codeViews modified state; therefore, we have to remember |
|
185 |
"/ this info somewhere ... |
|
12262 | 186 |
(browser := codeView browser) notNil ifTrue:[ |
12125 | 187 |
textView modified ifTrue:[ |
12262 | 188 |
browser navigationState realModifiedState: true |
12125 | 189 |
]. |
190 |
textView modifiedChannel setValue:false. |
|
191 |
]. |
|
192 |
||
193 |
job scheduled ifTrue:[ |
|
12262 | 194 |
job running ifFalse:[ |
195 |
"/ process already created, but did not get a change to start yet; |
|
196 |
^ self |
|
197 |
]. |
|
198 |
job stop. |
|
12125 | 199 |
]. |
12262 | 200 |
prio := Processor userBackgroundPriority. |
12125 | 201 |
job startWithPriority: prio. |
202 |
||
203 |
"Modified: / 07-07-2011 / 12:26:12 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
|
204 |
"Created: / 24-01-2012 / 12:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12262 | 205 |
"Modified: / 05-06-2012 / 23:58:20 / cg" |
12125 | 206 |
! |
207 |
||
208 |
process: delayed |
|
209 |
"Do the real source processing. If delayed is true, actuall data update must |
|
210 |
be done within the event queue using #pushUserEvent:... |
|
211 |
" |
|
212 |
||
213 |
self subclassResponsibility |
|
214 |
||
215 |
"Created: / 24-01-2012 / 12:25:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
216 |
! ! |
|
217 |
||
218 |
!BackgroundSourceProcessingService methodsFor:'registering'! |
|
219 |
||
220 |
registerIn: aCodeView |
|
221 |
||
222 |
super registerIn: aCodeView. |
|
223 |
textView addDependent: self. |
|
224 |
||
225 |
"Created: / 27-07-2011 / 13:25:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
226 |
! ! |
|
227 |
||
228 |
!BackgroundSourceProcessingService class methodsFor:'documentation'! |
|
229 |
||
230 |
version |
|
12265 | 231 |
^ '$Header: /cvs/stx/stx/libtool/Tools__BackgroundSourceProcessingService.st,v 1.3 2012/07/19 15:19:59 cg Exp $' |
12125 | 232 |
! |
233 |
||
234 |
version_CVS |
|
12265 | 235 |
^ '§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
|
236 |
! |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
237 |
|
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
238 |
version_SVN |
12265 | 239 |
^ '$Id: Tools__BackgroundSourceProcessingService.st 8022 2012-07-25 09:51:30Z vranyj1 $' |
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
240 |
! ! |