author | Claus Gittinger <cg@exept.de> |
Mon, 20 Jan 2020 21:02:47 +0100 | |
changeset 19422 | c6ca1c3e0fd7 |
parent 19356 | 2b2dbaa0751a |
child 19439 | 3f67162018e1 |
permissions | -rw-r--r-- |
19336 | 1 |
"{ Encoding: utf8 }" |
2 |
||
9982 | 3 |
" |
10071 | 4 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
11607 | 5 |
All Rights Reserved |
9982 | 6 |
|
10071 | 7 |
Permission is hereby granted, free of charge, to any person |
8 |
obtaining a copy of this software and associated documentation |
|
9 |
files (the 'Software'), to deal in the Software without |
|
10 |
restriction, including without limitation the rights to use, |
|
11 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
12 |
copies of the Software, and to permit persons to whom the |
|
13 |
Software is furnished to do so, subject to the following |
|
14 |
conditions: |
|
15 |
||
16 |
The above copyright notice and this permission notice shall be |
|
17 |
included in all copies or substantial portions of the Software. |
|
18 |
||
19 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
20 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
21 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
22 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
23 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
24 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
25 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
26 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9982 | 27 |
" |
28 |
"{ Package: 'stx:libtool' }" |
|
29 |
||
30 |
"{ NameSpace: Tools }" |
|
31 |
||
32 |
CodeViewService subclass:#BreakpointService |
|
13572
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
33 |
instanceVariableNames:'breakpoints currentMethod currentMethodClass methodHolder' |
19330 | 34 |
classVariableNames:'NeedDoubleClickToToggleBreakpoints' |
11607 | 35 |
poolDictionaries:'' |
36 |
category:'Interface-CodeView' |
|
9982 | 37 |
! |
38 |
||
39 |
!BreakpointService class methodsFor:'documentation'! |
|
40 |
||
41 |
copyright |
|
42 |
" |
|
10071 | 43 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
11607 | 44 |
All Rights Reserved |
9982 | 45 |
|
10071 | 46 |
Permission is hereby granted, free of charge, to any person |
47 |
obtaining a copy of this software and associated documentation |
|
48 |
files (the 'Software'), to deal in the Software without |
|
49 |
restriction, including without limitation the rights to use, |
|
50 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
51 |
copies of the Software, and to permit persons to whom the |
|
52 |
Software is furnished to do so, subject to the following |
|
53 |
conditions: |
|
54 |
||
55 |
The above copyright notice and this permission notice shall be |
|
56 |
included in all copies or substantial portions of the Software. |
|
57 |
||
58 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
59 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
60 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
61 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
62 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
63 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
64 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
65 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9982 | 66 |
" |
18606 | 67 |
! |
68 |
||
69 |
documentation |
|
70 |
" |
|
71 |
somewhat badly designed for non-reusability: |
|
72 |
I should not care for recompiling methods here, |
|
73 |
but instead delegate this task to a breakPointInstaller. |
|
74 |
The way it is currently designed makes it hard to reuse this |
|
75 |
component in non-smalltalk setups (i.e. groovy-, node- or C editors). |
|
76 |
||
77 |
Fiddling around here breaks it almost for sure, as this is highly obfuscated code. |
|
78 |
" |
|
9982 | 79 |
! ! |
80 |
||
13101 | 81 |
!BreakpointService class methodsFor:'accessing'! |
82 |
||
83 |
label |
|
84 |
"Answers a short label - for UI" |
|
85 |
||
86 |
^ 'Breakpoints' |
|
87 |
! ! |
|
88 |
||
13206 | 89 |
!BreakpointService class methodsFor:'testing'! |
90 |
||
91 |
isUsefulFor:aCodeView |
|
92 |
"this filters useful services. |
|
93 |
Redefined to return true for myself - not for subclasses" |
|
94 |
||
95 |
^ self == Tools::BreakpointService |
|
96 |
||
97 |
"Created: / 22-07-2013 / 14:01:17 / cg" |
|
98 |
! ! |
|
99 |
||
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
100 |
!BreakpointService methodsFor:'accessing'! |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
101 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
102 |
breakpointAtLine:line |
14845
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
103 |
"return the breakpoint at line (may be disabled) or nil, if there is none" |
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
104 |
|
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
105 |
|pos| |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
106 |
|
17620 | 107 |
breakpoints isEmptyOrNil ifTrue:[^ nil]. |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
108 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
109 |
pos := textView characterPositionOfLine:line col:1. |
19019 | 110 |
"/ breakpoints are sorted by line |
111 |
"/ (or even by position within a line, but those are currently not supported by the GUI). |
|
112 |
"/ We can stop searching early |
|
113 |
breakpoints do:[:each | |
|
114 |
|bpLine| |
|
115 |
||
116 |
bpLine := each line. |
|
117 |
bpLine == line ifTrue:[^ each]. |
|
118 |
bpLine > line ifTrue:[^ nil]. |
|
119 |
]. |
|
120 |
^ nil. |
|
121 |
||
122 |
"/ ^ breakpoints |
|
123 |
"/ detect:[:each | each position = pos ] |
|
124 |
"/ ifNone:[ |
|
125 |
"/ breakpoints |
|
126 |
"/ detect:[:each | each line == line and:[each position isNil ]] |
|
127 |
"/ ifNone:[ |
|
128 |
"/ self halt. |
|
129 |
"/ nil |
|
130 |
"/ ] |
|
131 |
"/ ] |
|
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
132 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
133 |
"Modified: / 17-06-2011 / 13:59:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17620 | 134 |
"Modified: / 16-08-2017 / 08:29:51 / cg" |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
135 |
! |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
136 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
137 |
breakpoints |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
138 |
self fixupBreakpointPositions. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
139 |
^ breakpoints |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
140 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
141 |
"Modified: / 08-05-2014 / 14:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
18599 | 142 |
"Modified (comment): / 18-02-2019 / 20:11:07 / Claus Gittinger" |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
143 |
! |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
144 |
|
18565 | 145 |
firstBreakpointAtLine:line |
146 |
"return the breakpoint at line (may be disabled) or nil, if there is none" |
|
147 |
||
148 |
breakpoints isEmptyOrNil ifTrue:[^ nil]. |
|
149 |
||
150 |
^ breakpoints |
|
151 |
detect:[:each | each line == line ] |
|
152 |
ifNone:[ nil ] |
|
153 |
||
154 |
"Created: / 26-01-2019 / 18:49:33 / Claus Gittinger" |
|
155 |
! |
|
156 |
||
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
157 |
removeAllBreakpoints |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
158 |
breakpoints := OrderedCollection new. |
14510
5e9448af6e4f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14509
diff
changeset
|
159 |
gutterView invalidate. |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
160 |
! |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
161 |
|
19336 | 162 |
setBreakpointAtLine:line |
163 |
"unconditionally set a breakpoint (called via double click)" |
|
164 |
||
165 |
self setOrToggleBreakpointAtLine:line toggle:false |
|
166 |
! |
|
167 |
||
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
168 |
setOrToggleBreakpointAtLine:line |
19336 | 169 |
"toggle a breakpoint (called via single click)" |
170 |
||
171 |
self setOrToggleBreakpointAtLine:line toggle:true |
|
172 |
! |
|
173 |
||
174 |
setOrToggleBreakpointAtLine:line toggle:doToggleBoolean |
|
175 |
"set (via double click) or toggle (via single click) a breakpoint" |
|
176 |
||
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
177 |
|pos bpnt prepareFullBreakSupport mClass ok| |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
178 |
|
19336 | 179 |
"/ if prepareFullBreakSupport is true, setting a single breakpoint in a method will create |
180 |
"/ a whole set of invisible (and disabled) breakpoints in that method, one for each line. |
|
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
181 |
"/ These can later be enabled in the debugger |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
182 |
"/ (otherwise, the debugger's behavior is stupid, as it cannot recompile a method |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
183 |
"/ to set additional breakpoints). |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
184 |
"/ We accept the additional overhead, as we are in debug mode anyway. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
185 |
"/ prepareFullBreakSupport := false. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
186 |
prepareFullBreakSupport := true. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
187 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
188 |
codeView method isNil ifTrue:[ |
18606 | 189 |
^ nil |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
190 |
]. |
17500 | 191 |
currentMethod isNil ifTrue:[ |
18606 | 192 |
^ nil |
17072 | 193 |
]. |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
194 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
195 |
bpnt := self breakpointAtLine:line. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
196 |
bpnt isNil ifTrue:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
197 |
"/ no breakpoint there - create a new one as required (i.e. recompile) |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
198 |
ok := (self canCreateOrToggleBreakpointAtLine:line). |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
199 |
ok ifFalse:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
200 |
(currentMethod isMethodWithBreakpoints and:[ prepareFullBreakSupport ]) ifFalse:[ |
17158 | 201 |
(codeView topView notNil and:[codeView topView isDebugView]) ifTrue:[ |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
202 |
(Dialog |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
203 |
confirm:'Sorry, in an active method, I can only add new breakpoints in an already breakpointed method. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
204 |
(i.e. a method stopped at a method breakpoint or one which already has statement breakpoints) |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
205 |
The reason is that the method needs to be recompiled for the breakpoint, which would not affect the method being currently executed. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
206 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
207 |
You can proceed to set the breakpoint, but it will only affect the next call into this method, not the current invocation.' |
16334 | 208 |
yesLabel:'Set Breakpoint for Next Call' noLabel:'OK') ifTrue:[ |
14950
29261c456545
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14849
diff
changeset
|
209 |
"/ self halt. |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
210 |
ok := true. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
211 |
] |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
212 |
] ifFalse:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
213 |
Dialog warn:'Sorry, cannot add a new breakpoint here.'. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
214 |
]. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
215 |
] |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
216 |
]. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
217 |
ok ifTrue:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
218 |
prepareFullBreakSupport ifTrue:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
219 |
"/ add a (disabled) breakpoint for every source line. This |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
220 |
"/ allows for breakpoints to be enabled/disabled in the debugger... |
19287 | 221 |
breakpoints notNil ifTrue:[ self sortBreakpoints ]. |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
222 |
1 to:textView numberOfLines do:[:eachLine | |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
223 |
|oldBPnt eachPos otherBpnt| |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
224 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
225 |
oldBPnt := self breakpointAtLine:eachLine. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
226 |
oldBPnt isNil ifTrue:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
227 |
eachPos := textView characterPositionOfLine:eachLine col:1. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
228 |
breakpoints isNil ifTrue:[ breakpoints := OrderedCollection new]. |
15303
a5083c63035a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
15045
diff
changeset
|
229 |
breakpoints add:((otherBpnt := Breakpoint new method:codeView method) position:eachPos line:eachLine). |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
230 |
eachLine == line ifTrue:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
231 |
bpnt := otherBpnt. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
232 |
] ifFalse:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
233 |
otherBpnt beInvisible. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
234 |
] |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
235 |
]. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
236 |
]. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
237 |
] ifFalse:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
238 |
pos := textView characterPositionOfLine:line col:1. |
15303
a5083c63035a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
15045
diff
changeset
|
239 |
breakpoints add:((bpnt := Breakpoint new method:codeView method) position:pos line:line). |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
240 |
]. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
241 |
Screen current shiftDown ifTrue:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
242 |
"/ trace |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
243 |
bpnt beTracepoint |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
244 |
]. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
245 |
self assert: breakpoints notEmptyOrNil. |
19287 | 246 |
self sortBreakpoints. |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
247 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
248 |
"/ recompile the method with breakpoints |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
249 |
self recompile. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
250 |
] |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
251 |
] ifFalse:[ |
19336 | 252 |
(doToggleBoolean or:[bpnt isEnabled not]) ifTrue:[ |
253 |
"/ breakpoint already there - just enable/disable |
|
254 |
Screen current shiftDown ifTrue:[ |
|
255 |
bpnt toggleTracing |
|
256 |
] ifFalse:[ |
|
257 |
bpnt toggle. |
|
258 |
]. |
|
259 |
(currentMethod isNil or:[(mClass := currentMethod mclass) isNil]) ifTrue:[ |
|
260 |
"/ hack: ouch - was wrapped in the meantime; |
|
261 |
"/ hurry up and update. Should be done elsewhere (in codeView) |
|
262 |
self updateCurrentMethod. |
|
263 |
currentMethod notNil ifTrue:[ mClass := currentMethod mclass ]. |
|
264 |
]. |
|
265 |
bpnt method:currentMethod. |
|
266 |
mClass notNil ifTrue:[ |
|
267 |
Smalltalk changed:#methodTrap with:(MethodTrapChangeNotificationParameter changeClass:mClass changeSelector:currentMethod selector). |
|
268 |
]. |
|
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
269 |
]. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
270 |
]. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
271 |
|
18644 | 272 |
bpnt notNil ifTrue:[ |
19336 | 273 |
"/ if it was ignored in the debugger, reenable |
274 |
Debugger notNil ifTrue:[ |
|
275 |
Debugger stopIgnoringHaltsFor:currentMethod atLineNr:bpnt line |
|
18644 | 276 |
]. |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
277 |
]. |
18644 | 278 |
|
279 |
gutterView redrawLine:line. |
|
18606 | 280 |
^ bpnt |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
281 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
282 |
"Created: / 17-06-2011 / 13:45:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
283 |
"Modified: / 21-02-2014 / 17:36:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17500 | 284 |
"Modified: / 13-04-2017 / 09:59:36 / cg" |
18644 | 285 |
"Modified: / 02-03-2019 / 11:32:07 / Claus Gittinger" |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
286 |
! ! |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
287 |
|
10208 | 288 |
!BreakpointService methodsFor:'change & update'! |
289 |
||
290 |
update: aspect with: param from: sender |
|
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
291 |
aspect == #visibility ifTrue:[^ self]. |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
292 |
aspect == #sizeOfView ifTrue:[^ self]. |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
293 |
aspect == #classHolder ifTrue:[^ self]. |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
294 |
aspect == #languageHolder ifTrue:[^ self]. |
18620 | 295 |
(codeView notNil and:[sender == codeView modifiedChannel]) ifTrue:[^ self]. |
10208 | 296 |
|
13572
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
297 |
"/ ATTENTION: I thought that fetching the methodHolder once in initialize would |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
298 |
"/ be ok. However, it seems not (codeView gives me something which it does not use/change later). |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
299 |
"/ so this fetch is called in update as well. |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
300 |
"/ maybe s.o. (ie. Jan) fixes CodeView2 |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
301 |
(aspect == #methodHolder or:[sender == self fetchMethodHolder]) ifTrue:[ |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
302 |
self updateCurrentMethod. |
10208 | 303 |
]. |
304 |
super update: aspect with: param from: sender |
|
305 |
||
306 |
"Created: / 06-07-2011 / 15:21:08 / cg" |
|
18620 | 307 |
"Modified: / 26-02-2019 / 18:06:23 / Claus Gittinger" |
10208 | 308 |
! |
309 |
||
310 |
updateBreakPointsFor:aMethod |
|
311 |
|methodsBreakPoints| |
|
312 |
||
13216
d1db940d42fb
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13209
diff
changeset
|
313 |
"/ Transcript show:'update breakpoints for method: '; showCR:aMethod. |
10208 | 314 |
aMethod notNil ifTrue:[ |
15383
671638959b16
Use breakpointsDo: instead of enumerating over literals.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15303
diff
changeset
|
315 |
aMethod breakpointsDo:[:eachLiteral | |
671638959b16
Use breakpointsDo: instead of enumerating over literals.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15303
diff
changeset
|
316 |
methodsBreakPoints isNil ifTrue:[ |
671638959b16
Use breakpointsDo: instead of enumerating over literals.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15303
diff
changeset
|
317 |
methodsBreakPoints := OrderedCollection new. |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
318 |
]. |
15383
671638959b16
Use breakpointsDo: instead of enumerating over literals.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15303
diff
changeset
|
319 |
methodsBreakPoints add:eachLiteral copy. |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
320 |
]. |
13106 | 321 |
currentMethodClass := aMethod mclass. |
322 |
] ifFalse:[ |
|
323 |
currentMethodClass := nil |
|
10208 | 324 |
]. |
325 |
breakpoints := methodsBreakPoints. |
|
17620 | 326 |
breakpoints notEmptyOrNil ifTrue:[ |
14456
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
327 |
"/ Nil out breakpoint's position. It's invalid as soon as |
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
328 |
"/ user edits the code. Instead, depend on line information. |
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
329 |
"/ Breakpoint character positions are fixed up just before |
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
330 |
"/ passing a breakpoints to the compiler, see |
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
331 |
"/ #fixupBreakpointPositions |
15642
239bbe1c7328
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
15383
diff
changeset
|
332 |
breakpoints do:[:each | each method:aMethod. each position: nil ]. |
14456
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
333 |
]. |
10208 | 334 |
currentMethod := aMethod. |
335 |
||
336 |
"Created: / 06-07-2011 / 15:24:09 / cg" |
|
10226 | 337 |
"Modified: / 06-07-2011 / 17:32:54 / jv" |
15383
671638959b16
Use breakpointsDo: instead of enumerating over literals.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15303
diff
changeset
|
338 |
"Modified: / 23-02-2015 / 14:48:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17620 | 339 |
"Modified: / 16-08-2017 / 08:31:18 / cg" |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
340 |
! |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
341 |
|
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
342 |
updateCurrentMethod |
13101 | 343 |
|method realMethod oldBreakPoints| |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
344 |
|
13106 | 345 |
"/ codeView methodHolder class == BlockValue ifTrue:[self breakPoint:#cg]. |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
346 |
|
13201
3b6f308a7280
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13191
diff
changeset
|
347 |
method := realMethod := codeView method. |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
348 |
(method notNil and:[method mclass isNil]) ifTrue:[ |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
349 |
"/ hack: ouch - was wrapped in the meantime; |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
350 |
"/ hurry up and update. Should be done elsewhere (in codeView) |
14533
b0ab75a1f038
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14510
diff
changeset
|
351 |
realMethod := MethodWithBreakpoints allBreakpointedMethods detect:[:m | m originalMethod == method and:[m mclass notNil]] ifNone:nil. |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
352 |
realMethod isNil ifTrue:[ |
14533
b0ab75a1f038
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14510
diff
changeset
|
353 |
realMethod := WrappedMethod allWrappedMethods detect:[:m | m originalMethod == method and:[m mclass notNil]] ifNone:nil. |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
354 |
]. |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
355 |
]. |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
356 |
realMethod ~~ currentMethod ifTrue:[ |
13573
70135af4ddeb
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13572
diff
changeset
|
357 |
"/ self fetchMethodHolder setValue:realMethod. |
13101 | 358 |
oldBreakPoints := breakpoints. |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
359 |
self updateBreakPointsFor:realMethod. |
13101 | 360 |
oldBreakPoints ~= breakpoints ifTrue:[ |
361 |
gutterView invalidate. |
|
362 |
] |
|
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
363 |
]. |
13201
3b6f308a7280
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13191
diff
changeset
|
364 |
|
3b6f308a7280
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13191
diff
changeset
|
365 |
"Modified: / 22-07-2013 / 13:33:28 / cg" |
10208 | 366 |
! ! |
367 |
||
9982 | 368 |
!BreakpointService methodsFor:'event handling'! |
369 |
||
14845
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
370 |
buttonMultiPress:button x:x y:y in:view |
9982 | 371 |
view == gutterView ifTrue:[ |
13152
778f0a1b39c2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13126
diff
changeset
|
372 |
button == 1 ifTrue:[ |
19336 | 373 |
self setBreakpointAtX:x y:y. |
374 |
"/ self setOrToggleBreakpointAtX:x y:y. |
|
13152
778f0a1b39c2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13126
diff
changeset
|
375 |
^ true. |
778f0a1b39c2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13126
diff
changeset
|
376 |
]. |
778f0a1b39c2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13126
diff
changeset
|
377 |
button == 3 ifTrue:[ |
19071 | 378 |
"/ cg:huch - why that? |
13152
778f0a1b39c2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13126
diff
changeset
|
379 |
^ true. |
778f0a1b39c2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13126
diff
changeset
|
380 |
] |
9982 | 381 |
]. |
10182 | 382 |
^ false |
9982 | 383 |
|
384 |
"Created: / 17-06-2011 / 13:05:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
385 |
"Modified: / 28-06-2011 / 08:31:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10714
3399fb50f42e
changed: #buttonPress:x:y:in:
Claus Gittinger <cg@exept.de>
parents:
10411
diff
changeset
|
386 |
"Modified: / 19-09-2011 / 14:41:00 / cg" |
10226 | 387 |
! |
388 |
||
14845
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
389 |
buttonPress:button x:x y:y in:view |
19071 | 390 |
"Handles an event in given view (a subview of codeView). |
391 |
If the method returns true, it has eaten the event and it will not be processed |
|
392 |
by the view or other services. |
|
393 |
Notice, that this is called both for events in the gutter AND for events in the text." |
|
394 |
||
18664 | 395 |
|lineNr currentHelpListener| |
14845
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
396 |
|
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
397 |
"now disabled: need a double click (like in other editors); |
18644 | 398 |
also this allows toggling breakpoints even if there are service-annotations" |
14845
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
399 |
|
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
400 |
view == gutterView ifTrue:[ |
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
401 |
button == 1 ifTrue:[ |
19331 | 402 |
"/ see hack in CodeView2 >> buttonPress:x:y:in: |
403 |
^ false. |
|
404 |
"/ lineNr := textView yVisibleToLineNr:y. |
|
405 |
"/ (self singleClickToToggle) ifFalse:[ |
|
406 |
"/ (currentHelpListener := FlyByHelp currentHelpListener) notNil ifTrue:[ |
|
407 |
"/ "/ show a message that a double click is now needed |
|
408 |
"/ currentHelpListener initiateHelpFor:view at:x@y now:true |
|
409 |
"/ ]. |
|
410 |
"/ ^ false. |
|
411 |
"/ ]. |
|
412 |
"/ lineNr notNil ifTrue:[ self setOrToggleBreakpointAtLine:lineNr ]. |
|
413 |
"/ ^ true. |
|
14845
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
414 |
]. |
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
415 |
]. |
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
416 |
^ false |
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
417 |
|
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
418 |
"Created: / 17-06-2011 / 13:05:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
419 |
"Modified: / 19-09-2011 / 14:41:00 / cg" |
14971
a33058120f3d
Make service not eat click event - it does not install breakpoint on signle-click!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14950
diff
changeset
|
420 |
"Modified: / 03-12-2014 / 10:22:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
18664 | 421 |
"Modified: / 12-03-2019 / 13:01:22 / Claus Gittinger" |
14845
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
422 |
! |
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
423 |
|
14326
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
424 |
keyPress:key x:x y:y in: view |
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
425 |
"Handles an event in given view (a subview of codeView). |
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
426 |
If the method returns true, it has eaten the event and it will not be processed |
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
427 |
by the view." |
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
428 |
|
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
429 |
key == #Accept ifTrue:[ |
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
430 |
textView undoableDo:[ |
14328
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
431 |
BreakpointQuery answer: self breakpoints do:[ |
14326
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
432 |
textView accept. |
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
433 |
]. |
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
434 |
]. |
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
435 |
^ true |
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
436 |
]. |
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
437 |
^ false |
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
438 |
|
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
439 |
"Created: / 08-05-2014 / 10:42:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
14328
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
440 |
"Modified: / 08-05-2014 / 13:52:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
14326
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
441 |
! |
8b59bf2da03e
When accepting a modified code, tell the compiler to reinsert breakpoints if any.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13977
diff
changeset
|
442 |
|
10226 | 443 |
linesDeletedFrom: start to: end |
14456
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
444 |
| breakpointsToRemove | |
10226 | 445 |
|
446 |
breakpoints isEmptyOrNil ifTrue:[^self]. |
|
14845
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
447 |
|
14456
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
448 |
breakpointsToRemove := Set new. |
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
449 |
start to: end do:[:line | |
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
450 |
| breakpointToRemove | |
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
451 |
|
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
452 |
breakpointToRemove := self breakpointAtLine: line. |
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
453 |
breakpointToRemove notNil ifTrue:[ breakpointsToRemove add: breakpointToRemove ]. |
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
454 |
]. |
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
455 |
breakpoints removeAll: breakpointsToRemove. |
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
456 |
self moveBreakpointsAfterLine: end by: (end - start + 1) negated |
10226 | 457 |
|
458 |
"Created: / 06-07-2011 / 17:16:27 / jv" |
|
14456
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
459 |
"Modified: / 04-06-2014 / 17:56:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10226 | 460 |
! |
461 |
||
462 |
linesInsertedFrom: start to: end |
|
463 |
||
464 |
breakpoints isEmptyOrNil ifTrue:[^self]. |
|
14845
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
465 |
|
10226 | 466 |
self moveBreakpointsAfterLine: start - 1 by: (end - start + 1) |
467 |
||
468 |
"Created: / 06-07-2011 / 17:16:36 / jv" |
|
19071 | 469 |
! |
470 |
||
19336 | 471 |
setBreakpointAtX:x y:y |
472 |
|lineNr| |
|
473 |
||
474 |
lineNr := textView yVisibleToLineNr:y. |
|
475 |
lineNr notNil ifTrue:[ self setBreakpointAtLine:lineNr ]. |
|
476 |
! |
|
477 |
||
19071 | 478 |
setOrToggleBreakpointAtX:x y:y |
479 |
|lineNr| |
|
480 |
||
481 |
lineNr := textView yVisibleToLineNr:y. |
|
482 |
lineNr notNil ifTrue:[ self setOrToggleBreakpointAtLine:lineNr ]. |
|
9982 | 483 |
! ! |
484 |
||
13126
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
485 |
!BreakpointService methodsFor:'help'! |
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
486 |
|
18844 | 487 |
basicHelpTextAtLine:ignoredLineNr |
13126
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
488 |
|topView| |
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
489 |
|
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
490 |
(self canCreateOrToggleBreakpointAtLine:nil) ifFalse:[ |
17157 | 491 |
((topView := codeView topView) notNil and:[topView isDebugView]) ifTrue:[ |
13126
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
492 |
self hasBreakpoints ifFalse:[ |
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
493 |
^ 'Sorry - cannot add breakpoint in the debugger (would need recompilation)\(can only add breakpoints if stopped at a method breakpoint)' withCRs |
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
494 |
]. |
13420
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
495 |
^ 'Sorry - cannot add new breakpoint if method is already entered\(i.e. if not stopped at a breakpoint).' withCRs |
13126
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
496 |
]. |
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
497 |
^ 'Cannot add breakpoint when modified. Please accept first.' |
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
498 |
]. |
19101 | 499 |
self singleClickToToggle ifTrue:[ |
19356 | 500 |
^ 'Click to toggle breakpoint.\For tracepoint, click with SHIFT pressed.\\Double click, if other info is shown here (lint info)' |
19101 | 501 |
]. |
19104 | 502 |
^ 'Double click to toggle breakpoint.\For tracepoint, click with SHIFT pressed.' |
13126
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
503 |
|
18844 | 504 |
"Created: / 26-06-2019 / 19:50:56 / Claus Gittinger" |
505 |
! |
|
506 |
||
507 |
helpTextAtLine:ignoredLineNr |
|
19102 | 508 |
|helpText| |
509 |
||
19071 | 510 |
(codeView method isNil and:[currentMethod isNil]) ifTrue:[ |
19102 | 511 |
helpText := 'No current method. Cannot set breakpoint.' |
512 |
] ifFalse:[ |
|
513 |
helpText := self basicHelpTextAtLine:ignoredLineNr |
|
18844 | 514 |
]. |
19102 | 515 |
^ self resources stringWithCRs:helpText. |
18844 | 516 |
|
13126
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
517 |
"Created: / 27-01-2012 / 14:04:52 / cg" |
17478 | 518 |
"Modified: / 19-03-2017 / 01:15:48 / cg" |
18844 | 519 |
"Modified: / 26-06-2019 / 19:52:18 / Claus Gittinger" |
13126
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
520 |
! ! |
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
521 |
|
9982 | 522 |
!BreakpointService methodsFor:'initialization'! |
523 |
||
13572
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
524 |
fetchMethodHolder |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
525 |
"redefinable in subclasses, which do not have a codeView2/methodHolder" |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
526 |
|
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
527 |
"/ ATTENTION: I thought that fetching the methodHolder once in initialize would |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
528 |
"/ be ok. However, it seems not (codeView gives me something which it does not use/change later). |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
529 |
"/ so this fetch is called in update as well. |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
530 |
"/ maybe s.o. (ie. Jan) fixes CodeView2 |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
531 |
methodHolder := codeView methodHolder. |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
532 |
^ methodHolder |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
533 |
! |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
534 |
|
9982 | 535 |
initialize |
536 |
||
537 |
super initialize. |
|
538 |
breakpoints := OrderedCollection new. |
|
539 |
||
540 |
"Created: / 17-06-2011 / 13:49:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
541 |
! ! |
|
542 |
||
543 |
!BreakpointService methodsFor:'private'! |
|
544 |
||
14328
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
545 |
fixupBreakpointPositions |
18606 | 546 |
"computes the character positions of all line breakpoints" |
547 |
||
19019 | 548 |
breakpoints notEmptyOrNil ifTrue:[ |
549 |
"/ self assert:(breakpoints contains:[:b | b line < 0]) not. |
|
14450
60b7e5f93d5a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14328
diff
changeset
|
550 |
breakpoints do:[:each | |
60b7e5f93d5a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14328
diff
changeset
|
551 |
| pos | |
14328
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
552 |
|
18606 | 553 |
pos := textView characterPositionOfLine:(each line) col:1. |
18828 | 554 |
each position:pos line:(each line). |
14450
60b7e5f93d5a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14328
diff
changeset
|
555 |
]. |
19019 | 556 |
"/ self assert:(breakpoints contains:[:b | b line < 0]) not. |
18606 | 557 |
breakpoints := breakpoints select:[:b | b line >= 0]. |
19019 | 558 |
self sortBreakpoints. |
14328
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
559 |
]. |
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
560 |
|
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
561 |
"Created: / 08-05-2014 / 14:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17366 | 562 |
"Modified: / 07-02-2017 / 23:12:06 / cg" |
18828 | 563 |
"Modified: / 21-06-2019 / 07:47:19 / Claus Gittinger" |
14328
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
564 |
! |
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
565 |
|
10226 | 566 |
moveBreakpointsAfterLine:line by: delta |
19019 | 567 |
"/ self assert:(breakpoints contains:[:b | b line < 0]) not. |
10226 | 568 |
breakpoints do:[:bpnt| |
11719 | 569 |
bpnt line >= line ifTrue:[ |
14328
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
570 |
"/ Note that position will be fixed up in BreakpointService>>breakpoints |
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
571 |
bpnt position:nil line:(bpnt line + delta). |
11719 | 572 |
] |
10226 | 573 |
]. |
19019 | 574 |
"/ self assert:(breakpoints contains:[:b | b line < 0]) not. |
14454
fdaebd3224b8
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14450
diff
changeset
|
575 |
breakpoints := breakpoints reject:[:bpnt | bpnt line <= 0]. |
10226 | 576 |
|
577 |
"/gutterView redrawLinesFrom: line. |
|
578 |
||
579 |
"Created: / 17-06-2011 / 13:45:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
580 |
"Created: / 06-07-2011 / 17:26:30 / jv" |
|
14328
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
581 |
"Modified: / 08-05-2014 / 14:01:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17092 | 582 |
"Modified: / 20-11-2016 / 19:09:12 / cg" |
10226 | 583 |
! |
584 |
||
10182 | 585 |
recompile |
586 |
"recompile the current method for changed breakpoints" |
|
587 |
||
18606 | 588 |
|oldMethod| |
10182 | 589 |
|
13201
3b6f308a7280
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13191
diff
changeset
|
590 |
oldMethod := codeView method. |
18606 | 591 |
(oldMethod isNil or:[oldMethod hasPrimitiveCode]) ifTrue:[^ self]. |
592 |
"/ be careful: if the text has been edited/modified, do not compile |
|
593 |
textView modified ifTrue:[ |
|
594 |
self breakPoint: #cg. |
|
595 |
self breakPoint: #jv. |
|
596 |
^self. |
|
597 |
]. |
|
10182 | 598 |
|
18606 | 599 |
self recompileMethod:oldMethod. |
10182 | 600 |
|
601 |
"Created: / 05-07-2011 / 21:33:13 / cg" |
|
15383
671638959b16
Use breakpointsDo: instead of enumerating over literals.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15303
diff
changeset
|
602 |
"Modified: / 23-02-2015 / 14:49:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17777 | 603 |
"Modified: / 21-11-2017 / 13:09:36 / cg" |
18606 | 604 |
"Modified: / 20-02-2019 / 17:26:57 / Claus Gittinger" |
605 |
! |
|
606 |
||
607 |
recompileMethod:oldMethod |
|
608 |
"recompile oldMethod for changed breakpoints" |
|
609 |
||
610 |
| newMethod compilerClass compiler class selector| |
|
611 |
||
612 |
"/ prepare to get reachable bpts |
|
613 |
self fixupBreakpointPositions. |
|
614 |
breakpoints do:[:bp | bp isReached:false]. |
|
615 |
||
616 |
class := oldMethod mclass. |
|
617 |
class isNil ifTrue:[ |
|
19194 | 618 |
class := oldMethod getMclass. |
18606 | 619 |
class isNil ifTrue:[ |
19194 | 620 |
class := oldMethod originalMethodIfWrapped mclass. |
621 |
class isNil ifTrue:[ |
|
622 |
class := oldMethod originalMethodIfWrapped getMclass. |
|
623 |
class isNil ifTrue:[ |
|
624 |
class := codeView classHolder value. |
|
625 |
class isNil ifTrue:[ |
|
626 |
self breakPoint:#jv. |
|
627 |
Dialog warn:'oops - lost the method''s class'. |
|
628 |
^ self. |
|
629 |
] |
|
630 |
] |
|
631 |
] |
|
18606 | 632 |
] |
633 |
]. |
|
634 |
selector := oldMethod selector. |
|
635 |
||
636 |
compilerClass := oldMethod programmingLanguage compilerWithBreakpointSupportClass. |
|
637 |
compilerClass isNil ifTrue:[ |
|
638 |
Dialog warn:'No breakpoint support for this programming language'. |
|
639 |
^ self. |
|
640 |
]. |
|
641 |
compiler := compilerClass new. |
|
642 |
compiler breakpoints:breakpoints. |
|
643 |
||
644 |
Class withoutUpdatingChangesDo:[ |
|
645 |
newMethod := compiler |
|
646 |
compile:oldMethod source |
|
647 |
forClass:class |
|
648 |
inCategory:oldMethod category |
|
649 |
notifying:nil |
|
650 |
install:false |
|
651 |
skipIfSame:false |
|
652 |
silent:true |
|
653 |
foldConstants:true |
|
654 |
ifFail:[ Transcript showCR:'BreakpointService: failed to recompile for breakpoint' ]. |
|
655 |
||
656 |
selector isNil ifTrue:[ |
|
657 |
"/ May happen as the selector is not stored in the method but |
|
658 |
"/ searches through method's mclass methodDictionary. |
|
659 |
"/ Following should be save as breakpoint is not installed when |
|
660 |
"/ the code is modified... |
|
661 |
selector := compiler selector. |
|
662 |
]. |
|
663 |
||
664 |
oldMethod isWrapped ifTrue:[ |
|
665 |
"/ update the wrapped method - do not install |
|
666 |
newMethod originalMethod: oldMethod originalMethod. |
|
667 |
oldMethod replaceOriginalMethodWith:newMethod. |
|
668 |
] ifFalse:[ |
|
669 |
"/ install |
|
670 |
newMethod originalMethod: oldMethod. |
|
671 |
(class primAddSelector: selector withMethod:newMethod) ifFalse:[ |
|
672 |
oldMethod mclass:class. |
|
673 |
self breakPoint: #cg. |
|
674 |
self breakPoint: #jv. |
|
675 |
^ self |
|
676 |
]. |
|
677 |
]. |
|
678 |
||
679 |
breakpoints := breakpoints species new. |
|
680 |
newMethod breakpointsDo:[ :each | each method:newMethod. breakpoints add: each ]. |
|
681 |
"/ this assertion occasionally failed - and lead to wrong breakpoint handling in the compiler. |
|
682 |
"/ for now, as a q&d hack, sort them to make sure. |
|
683 |
"/ self assert:(breakpoints isSortedBy:[:a :b |a position <= b position]). |
|
19019 | 684 |
self sortBreakpoints. |
18606 | 685 |
|
686 |
"/ must update breakpoints BEFORE the following, because it leads to a change |
|
687 |
"/ notification, which may clear the breakpoints collection!! |
|
688 |
self fetchMethodHolder value:newMethod. |
|
689 |
oldMethod mclass isNil ifTrue:[ |
|
690 |
"/ although this is not strictly true, not doing this |
|
691 |
"/ would confuse a lot of other tools (such as the browser) |
|
692 |
oldMethod mclass:class. |
|
693 |
]. |
|
694 |
currentMethod := newMethod. |
|
695 |
class changed:#methodTrap with:selector. "/ tell browsers |
|
696 |
Smalltalk changed:#methodTrap with:(MethodTrapChangeNotificationParameter changeClass:class changeSelector:selector). |
|
697 |
]. |
|
698 |
||
699 |
"Created: / 20-02-2019 / 17:26:24 / Claus Gittinger" |
|
19019 | 700 |
! |
701 |
||
702 |
sortBreakpoints |
|
703 |
"breakpoints are sorted by line |
|
704 |
(or even by position within a line, but those are currently not supported by the GUI)" |
|
705 |
||
706 |
breakpoints := breakpoints |
|
707 |
asOrderedCollection |
|
708 |
sort:[:a :b| |
|
709 |
|pA pB| |
|
710 |
||
711 |
pA := a position. |
|
712 |
pB := b position. |
|
713 |
(pA notNil and:[pB notNil]) ifTrue:[ |
|
714 |
"/ self assert:(pA <= pB) = (a line <= b line). |
|
715 |
pA < pB |
|
716 |
] ifFalse:[ |
|
717 |
a line < b line |
|
718 |
] |
|
719 |
]. |
|
9982 | 720 |
! ! |
721 |
||
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
722 |
!BreakpointService methodsFor:'queries'! |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
723 |
|
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
724 |
canCreateOrToggleBreakpointAtLine:lineOrNilForAnywhere |
13420
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
725 |
"is it possible to place a breakpoint here and now?" |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
726 |
|
13126
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
727 |
|bpnt topView| |
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
728 |
|
19332 | 729 |
textView isNil ifTrue:[ |
730 |
"/ happens due to a bug, after disabling the service; |
|
731 |
"/ it seems to still be asked |
|
732 |
^ false |
|
733 |
]. |
|
734 |
||
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
735 |
textView reallyModified ifTrue:[ |
13420
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
736 |
"/ this is not really true - we could keep track of where the breakpoints |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
737 |
"/ are while editing and shift them as required. |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
738 |
"/ (another idea worth a try would be |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
739 |
"/ to match the original parsetree (enumerating nodes with the breakpoints) |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
740 |
"/ against the new parsetree (walking in sync?) when finally compiling, |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
741 |
"/ and placing new breakpoints on matching tree nodes. |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
742 |
"/ (too much work, for a quick solution, I guess) |
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
743 |
^ false |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
744 |
]. |
13420
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
745 |
|
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
746 |
"/ can always toggle existing breakpoints... |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
747 |
lineOrNilForAnywhere notNil ifTrue:[ |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
748 |
bpnt := self breakpointAtLine:lineOrNilForAnywhere. |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
749 |
bpnt notNil ifTrue:[ |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
750 |
^ true. |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
751 |
] |
13420
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
752 |
] ifFalse:[ |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
753 |
(currentMethod notNil and:[currentMethod isMethodWithBreakpoints]) ifTrue:[ |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
754 |
^ true. |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
755 |
] |
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
756 |
]. |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
757 |
|
13420
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
758 |
"/ ok, the method has no breakpoints yet. |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
759 |
|
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
760 |
"/ this is a bad hack - looking into the debugger's state here. |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
761 |
"/ I guess, we have to move code around a bit... |
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
762 |
((topView := codeView topView) class == DebugView) ifTrue:[ |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
763 |
"/ can only create new breakpoints in the debugger, |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
764 |
"/ iff we are in a wrapped method's prolog |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
765 |
topView selectedContextIsWrapped ifTrue:[ |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
766 |
topView selectedContext lineNumber == 1 ifTrue:[ |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
767 |
^ true |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
768 |
]. |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
769 |
]. |
13420
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
770 |
|
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
771 |
"/ well, if the debugger's code has already been modified, |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
772 |
"/ we will accept the new code anyway. So there's no problem in adding |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
773 |
"/ a breakpoint on the fly... |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
774 |
topView showingAlreadyModifiedCode ifTrue:[^ true]. |
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
775 |
^ false. |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
776 |
]. |
13420
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
777 |
|
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
778 |
"/ in a non-debugger, we can do it. |
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
779 |
^ true. |
18844 | 780 |
|
781 |
"Modified: / 26-06-2019 / 19:52:07 / Claus Gittinger" |
|
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
782 |
! |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
783 |
|
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
784 |
hasBreakpoints |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
785 |
^ breakpoints notEmptyOrNil |
19097 | 786 |
! |
787 |
||
788 |
singleClickToToggle |
|
789 |
"/ not yet working correctly: must ignore double clicks then, |
|
790 |
"/ but only some... |
|
19330 | 791 |
^ (NeedDoubleClickToToggleBreakpoints ? false) not |
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
792 |
! ! |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
793 |
|
9982 | 794 |
!BreakpointService methodsFor:'redrawing'! |
795 |
||
16602 | 796 |
drawLine:lineNo in:view atX:x y:yBaseline width:w height:hFont ascent:aFont |
797 |
from:startCol to:endColOrNil with:fg and:bg |
|
9982 | 798 |
"Called by both gutterView and textView (well, not yet) to |
799 |
allow services to draw custom things on text view. |
|
800 |
Ask JV what the args means if unsure (I'm lazy to document |
|
801 |
them, now it is just an experiment...)" |
|
11607 | 802 |
|
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
803 |
|mthd bpnt icon dx dy| |
9982 | 804 |
|
16602 | 805 |
"/ these tests make the breakpointService unusable for other applications |
806 |
"/ (which are not based on smalltalk methods). |
|
807 |
"/ They are not really needed: if there is a breakpoint, |
|
13572
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
808 |
"/ I can show it. Period. |
13191
9745eed50f03
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13157
diff
changeset
|
809 |
|
13573
70135af4ddeb
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13572
diff
changeset
|
810 |
"/ (mthd := self fetchMethodHolder value) isNil ifTrue:[ |
13572
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
811 |
"/ ^ self |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
812 |
"/ ]. |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
813 |
"/ currentMethodClass isNil ifTrue:[ |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
814 |
"/ "/ hack: ouch - was wrapped in the meantime; |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
815 |
"/ ^ self. "/ wait for the real update |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
816 |
"/ "/ hurry up and update. Should be done elsewhere (in codeView) |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
817 |
"/ "/ self updateCurrentMethod. |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
818 |
"/ ]. |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
819 |
|
13572
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
820 |
view == gutterView ifTrue:[ |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
821 |
bpnt := self breakpointAtLine:lineNo. |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
822 |
bpnt isNil ifTrue:[ |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
823 |
^ self |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
824 |
]. |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
825 |
icon := bpnt icon. |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
826 |
icon isNil ifTrue:[ |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
827 |
^ self |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
828 |
]. |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
829 |
dx := ((w - icon width) / 2) rounded. |
16602 | 830 |
dy := ((hFont - icon height) / 2) rounded. |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
831 |
icon |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
832 |
displayOn:view |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
833 |
x:x + dx |
16602 | 834 |
y:yBaseline - hFont + dy + 4. "TODO: Magic constant" |
9982 | 835 |
]. |
836 |
||
837 |
"Created: / 17-06-2011 / 13:52:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10182 | 838 |
"Modified (format): / 05-07-2011 / 22:14:33 / cg" |
9982 | 839 |
! ! |
840 |
||
13572
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
841 |
!BreakpointService methodsFor:'registering'! |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
842 |
|
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
843 |
registerIn:aCodeView |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
844 |
super registerIn:aCodeView. |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
845 |
self fetchMethodHolder. |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
846 |
! ! |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
847 |
|
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
848 |
!BreakpointService methodsFor:'testing'! |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
849 |
|
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
850 |
isBreakpointService |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
851 |
^ true |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
852 |
! ! |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
853 |
|
9982 | 854 |
!BreakpointService class methodsFor:'documentation'! |
855 |
||
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
856 |
version |
15983 | 857 |
^ '$Header$' |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
858 |
! |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
859 |
|
9982 | 860 |
version_CVS |
15983 | 861 |
^ '$Header$' |
9982 | 862 |
! |
863 |
||
864 |
version_SVN |
|
15983 | 865 |
^ '$Id$' |
9982 | 866 |
! ! |
12507
3fa9ae668d96
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
11987
diff
changeset
|
867 |