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