author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 30 Jan 2012 17:49:41 +0000 | |
branch | jv |
changeset 12128 | a7ff7d66ee85 |
parent 12125 | 0c49a3b13e43 |
child 12130 | 764a3c16d308 |
permissions | -rw-r--r-- |
9982 | 1 |
" |
10071 | 2 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
9982 | 3 |
All Rights Reserved |
4 |
||
10071 | 5 |
Permission is hereby granted, free of charge, to any person |
6 |
obtaining a copy of this software and associated documentation |
|
7 |
files (the 'Software'), to deal in the Software without |
|
8 |
restriction, including without limitation the rights to use, |
|
9 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
10 |
copies of the Software, and to permit persons to whom the |
|
11 |
Software is furnished to do so, subject to the following |
|
12 |
conditions: |
|
13 |
||
14 |
The above copyright notice and this permission notice shall be |
|
15 |
included in all copies or substantial portions of the Software. |
|
16 |
||
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
20 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
21 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
22 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
24 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9982 | 25 |
" |
26 |
"{ Package: 'stx:libtool' }" |
|
27 |
||
28 |
"{ NameSpace: Tools }" |
|
29 |
||
30 |
CodeViewService subclass:#BreakpointService |
|
10208 | 31 |
instanceVariableNames:'breakpoints currentMethod' |
9982 | 32 |
classVariableNames:'' |
33 |
poolDictionaries:'' |
|
34 |
category:'Interface-CodeView' |
|
35 |
! |
|
36 |
||
37 |
!BreakpointService class methodsFor:'documentation'! |
|
38 |
||
39 |
copyright |
|
40 |
" |
|
10071 | 41 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
9982 | 42 |
All Rights Reserved |
43 |
||
10071 | 44 |
Permission is hereby granted, free of charge, to any person |
45 |
obtaining a copy of this software and associated documentation |
|
46 |
files (the 'Software'), to deal in the Software without |
|
47 |
restriction, including without limitation the rights to use, |
|
48 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
49 |
copies of the Software, and to permit persons to whom the |
|
50 |
Software is furnished to do so, subject to the following |
|
51 |
conditions: |
|
52 |
||
53 |
The above copyright notice and this permission notice shall be |
|
54 |
included in all copies or substantial portions of the Software. |
|
55 |
||
56 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
57 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
58 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
59 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
60 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
61 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
62 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
63 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9982 | 64 |
" |
65 |
! ! |
|
66 |
||
10226 | 67 |
!BreakpointService methodsFor:'accessing'! |
68 |
||
69 |
breakpoints |
|
70 |
^ breakpoints |
|
71 |
! ! |
|
72 |
||
10208 | 73 |
!BreakpointService methodsFor:'change & update'! |
74 |
||
75 |
update: aspect with: param from: sender |
|
76 |
|method| |
|
77 |
||
78 |
method := codeView methodHolder value. |
|
79 |
method ~~ currentMethod ifTrue:[ |
|
80 |
self updateBreakPointsFor:method. |
|
81 |
]. |
|
82 |
||
83 |
super update: aspect with: param from: sender |
|
84 |
||
85 |
"Created: / 06-07-2011 / 15:21:08 / cg" |
|
86 |
! |
|
87 |
||
88 |
updateBreakPointsFor:aMethod |
|
89 |
|methodsBreakPoints| |
|
90 |
||
91 |
methodsBreakPoints := OrderedCollection new. |
|
92 |
aMethod notNil ifTrue:[ |
|
93 |
aMethod literalsDo:[:eachLiteral | |
|
94 |
eachLiteral class == Breakpoint ifTrue:[ |
|
10226 | 95 |
methodsBreakPoints add:eachLiteral copy. |
10208 | 96 |
]. |
97 |
]. |
|
98 |
]. |
|
99 |
breakpoints := methodsBreakPoints. |
|
100 |
currentMethod := aMethod. |
|
101 |
||
102 |
"Created: / 06-07-2011 / 15:24:09 / cg" |
|
10226 | 103 |
"Modified: / 06-07-2011 / 17:32:54 / jv" |
10208 | 104 |
! ! |
105 |
||
9982 | 106 |
!BreakpointService methodsFor:'event handling'! |
107 |
||
10182 | 108 |
buttonPress:button x:x y:y in:view |
12125 | 109 |
|lineNr| |
110 |
||
10182 | 111 |
codeView methodHolder value isNil ifTrue:[ |
112 |
^ false |
|
113 |
]. |
|
9982 | 114 |
view == gutterView ifTrue:[ |
115 |
button == 1 ifTrue:[ |
|
12125 | 116 |
lineNr := textView yVisibleToLineNr:y. |
117 |
lineNr notNil ifTrue:[ self setOrToggleBreakpointAtLine:lineNr ]. |
|
10182 | 118 |
^ true. |
9982 | 119 |
]. |
120 |
button == 3 ifTrue:[ |
|
10182 | 121 |
^ true. |
9982 | 122 |
] |
123 |
]. |
|
10182 | 124 |
^ false |
9982 | 125 |
|
126 |
"Created: / 17-06-2011 / 13:05:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
127 |
"Modified: / 28-06-2011 / 08:31:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12125 | 128 |
"Modified: / 19-09-2011 / 14:41:00 / cg" |
10226 | 129 |
! |
130 |
||
131 |
linesDeletedFrom: start to: end |
|
132 |
||
133 |
breakpoints isEmptyOrNil ifTrue:[^self]. |
|
134 |
self moveBreakpointsAfterLine: start - 1 by: (end - start + 1) negated |
|
135 |
||
136 |
"Created: / 06-07-2011 / 17:16:27 / jv" |
|
137 |
! |
|
138 |
||
139 |
linesInsertedFrom: start to: end |
|
140 |
||
141 |
breakpoints isEmptyOrNil ifTrue:[^self]. |
|
142 |
self moveBreakpointsAfterLine: start - 1 by: (end - start + 1) |
|
143 |
||
144 |
"Created: / 06-07-2011 / 17:16:36 / jv" |
|
9982 | 145 |
! ! |
146 |
||
147 |
!BreakpointService methodsFor:'initialization'! |
|
148 |
||
149 |
initialize |
|
150 |
||
151 |
super initialize. |
|
152 |
breakpoints := OrderedCollection new. |
|
153 |
||
154 |
"Created: / 17-06-2011 / 13:49:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
155 |
! ! |
|
156 |
||
157 |
!BreakpointService methodsFor:'private'! |
|
158 |
||
10182 | 159 |
breakpointAtLine:line |
160 |
|pos| |
|
9982 | 161 |
|
162 |
pos := textView characterPositionOfLine:line col:1. |
|
163 |
^ breakpoints ? #() detect:[:each | each position = pos ] ifNone:[ nil ] |
|
164 |
||
165 |
"Modified: / 17-06-2011 / 13:59:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10182 | 166 |
"Modified (format): / 05-07-2011 / 21:33:23 / cg" |
167 |
! |
|
168 |
||
10226 | 169 |
moveBreakpointsAfterLine:line by: delta |
170 |
||
171 |
|pos | |
|
172 |
||
173 |
||
174 |
breakpoints do:[:bpnt| |
|
175 |
bpnt line >= line ifTrue:[ |
|
176 |
pos := textView characterPositionOfLine:bpnt line + delta col:1. |
|
177 |
bpnt line: bpnt line + delta; position: pos |
|
178 |
] |
|
179 |
]. |
|
180 |
||
181 |
"/gutterView redrawLinesFrom: line. |
|
182 |
||
183 |
"Created: / 17-06-2011 / 13:45:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
184 |
"Modified: / 05-07-2011 / 21:32:49 / cg" |
|
185 |
"Created: / 06-07-2011 / 17:26:30 / jv" |
|
186 |
! |
|
187 |
||
10182 | 188 |
recompile |
189 |
"recompile the current method for changed breakpoints" |
|
190 |
||
191 |
|method| |
|
192 |
||
193 |
method := codeView methodHolder value. |
|
194 |
(method notNil and:[method hasPrimitiveCode not]) ifTrue:[ |
|
195 |
"/ be careful: if the text has been edited/modified, do not compile |
|
196 |
textView modified ifTrue:[ |
|
197 |
self halt |
|
198 |
] ifFalse:[ |
|
199 |
"/ prepare to get reachable bpts |
|
200 |
breakpoints do:[:bp | bp isReached:false]. |
|
201 |
||
10209 | 202 |
Class withoutUpdatingChangesDo:[ |
203 |
ByteCodeCompilerWithBreakpointSupport new |
|
204 |
breakpoints:breakpoints; |
|
10182 | 205 |
|
10209 | 206 |
compile:method source |
207 |
forClass:method mclass |
|
208 |
inCategory:method category |
|
209 |
notifying:nil |
|
210 |
install:true |
|
211 |
skipIfSame:false |
|
212 |
silent:true |
|
213 |
foldConstants:true |
|
214 |
ifFail:[ self halt ]. |
|
215 |
]. |
|
12125 | 216 |
"/ self halt. |
217 |
breakpoints := breakpoints |
|
218 |
select:[:bp | |
|
219 |
bp isReached ifFalse:[ Transcript show:'remove unreached:'; showCR:bp ]. |
|
220 |
bp isReached |
|
221 |
] |
|
10182 | 222 |
] |
223 |
] |
|
224 |
||
225 |
"Created: / 05-07-2011 / 21:33:13 / cg" |
|
9982 | 226 |
! |
227 |
||
228 |
setOrToggleBreakpointAtLine:line |
|
229 |
|pos bpnt| |
|
230 |
||
231 |
pos := textView characterPositionOfLine:line col:1. |
|
232 |
bpnt := self breakpointAtLine:line. |
|
10182 | 233 |
bpnt isNil ifTrue:[ |
10411 | 234 |
(codeView topView class ~~ DebugView) ifTrue:[ |
12125 | 235 |
breakpoints add:((bpnt := Breakpoint new) |
236 |
position:pos; |
|
237 |
line:line). |
|
238 |
Display shiftDown ifTrue:[ |
|
239 |
"/ trace |
|
240 |
bpnt beTracepoint |
|
241 |
]. |
|
10411 | 242 |
self recompile. |
243 |
]. |
|
10182 | 244 |
] ifFalse:[ |
12125 | 245 |
Display shiftDown ifTrue:[ |
246 |
bpnt toggleTracing |
|
247 |
] ifFalse:[ |
|
248 |
bpnt toggle. |
|
249 |
] |
|
10182 | 250 |
]. |
9982 | 251 |
gutterView redrawLine:line. |
252 |
||
253 |
"Created: / 17-06-2011 / 13:45:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10411 | 254 |
"Modified: / 27-07-2011 / 13:27:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
12125 | 255 |
"Modified: / 27-01-2012 / 13:55:12 / cg" |
9982 | 256 |
! ! |
257 |
||
258 |
!BreakpointService methodsFor:'redrawing'! |
|
259 |
||
10182 | 260 |
drawLine:lineNo in:view atX:x y:y width:w height:h from:startCol to:endColOrNil with:fg and:bg |
9982 | 261 |
"Called by both gutterView and textView (well, not yet) to |
262 |
allow services to draw custom things on text view. |
|
263 |
Ask JV what the args means if unsure (I'm lazy to document |
|
264 |
them, now it is just an experiment...)" |
|
10182 | 265 |
|
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
266 |
|bpnt icon| |
9982 | 267 |
|
10182 | 268 |
codeView methodHolder value isNil ifTrue:[ |
269 |
^ self |
|
270 |
]. |
|
271 |
view == gutterView ifTrue:[ |
|
272 |
bpnt := self breakpointAtLine:lineNo. |
|
273 |
bpnt isNil ifTrue:[ |
|
274 |
^ self |
|
275 |
]. |
|
276 |
icon := bpnt icon. |
|
277 |
icon isNil ifTrue:[ |
|
278 |
^ self |
|
279 |
]. |
|
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
280 |
self |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
281 |
drawAnnotationIcon:icon |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
282 |
atX:x y:y width:w height:y |
9982 | 283 |
]. |
284 |
||
285 |
"Created: / 17-06-2011 / 13:52:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10182 | 286 |
"Modified (format): / 05-07-2011 / 22:14:33 / cg" |
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
287 |
"Modified: / 30-01-2012 / 15:06:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9982 | 288 |
! ! |
289 |
||
290 |
!BreakpointService class methodsFor:'documentation'! |
|
291 |
||
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
292 |
version |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
293 |
^ '$Id: Tools__BreakpointService.st 7854 2012-01-30 17:49:41Z vranyj1 $' |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
294 |
! |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
295 |
|
9982 | 296 |
version_CVS |
12125 | 297 |
^ '§Header: /cvs/stx/stx/libtool/Tools__BreakpointService.st,v 1.11 2012/01/27 13:08:07 cg Exp §' |
9982 | 298 |
! |
299 |
||
300 |
version_SVN |
|
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
301 |
^ '$Id: Tools__BreakpointService.st 7854 2012-01-30 17:49:41Z vranyj1 $' |
12125 | 302 |
! ! |