author | Stefan Vogel <sv@exept.de> |
Fri, 17 May 2019 17:09:44 +0200 | |
changeset 18766 | e0a9a93a8edc |
parent 18664 | 8c2338820773 |
child 18828 | 89ad6f8245e2 |
permissions | -rw-r--r-- |
18565 | 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' |
11607 | 34 |
classVariableNames:'' |
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. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
110 |
^ breakpoints |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
111 |
detect:[:each | each position = pos ] |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
112 |
ifNone:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
113 |
breakpoints |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
114 |
detect:[:each | each line == line and:[each position isNil ]] |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
115 |
ifNone:[ nil ] |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
116 |
] |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
117 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
118 |
"Modified: / 17-06-2011 / 13:59:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17620 | 119 |
"Modified: / 16-08-2017 / 08:29:51 / cg" |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
120 |
! |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
121 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
122 |
breakpoints |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
123 |
self fixupBreakpointPositions. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
124 |
^ breakpoints |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
125 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
126 |
"Modified: / 08-05-2014 / 14:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
18599 | 127 |
"Modified (comment): / 18-02-2019 / 20:11:07 / Claus Gittinger" |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
128 |
! |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
129 |
|
18565 | 130 |
firstBreakpointAtLine:line |
131 |
"return the breakpoint at line (may be disabled) or nil, if there is none" |
|
132 |
||
133 |
breakpoints isEmptyOrNil ifTrue:[^ nil]. |
|
134 |
||
135 |
^ breakpoints |
|
136 |
detect:[:each | each line == line ] |
|
137 |
ifNone:[ nil ] |
|
138 |
||
139 |
"Created: / 26-01-2019 / 18:49:33 / Claus Gittinger" |
|
140 |
! |
|
141 |
||
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
142 |
removeAllBreakpoints |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
143 |
breakpoints := OrderedCollection new. |
14510
5e9448af6e4f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14509
diff
changeset
|
144 |
gutterView invalidate. |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
145 |
! |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
146 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
147 |
setOrToggleBreakpointAtLine:line |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
148 |
|pos bpnt prepareFullBreakSupport mClass ok| |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
149 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
150 |
"/ if true, setting a single breakpoint in a method will create |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
151 |
"/ a whole set of invisible (and disabled) breakpoints in that method, |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
152 |
"/ one for each line. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
153 |
"/ These can later be enabled in the debugger |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
154 |
"/ (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
|
155 |
"/ to set additional breakpoints). |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
156 |
"/ 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
|
157 |
"/ prepareFullBreakSupport := false. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
158 |
prepareFullBreakSupport := true. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
159 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
160 |
codeView method isNil ifTrue:[ |
18606 | 161 |
^ nil |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
162 |
]. |
17500 | 163 |
currentMethod isNil ifTrue:[ |
18606 | 164 |
^ nil |
17072 | 165 |
]. |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
166 |
|
18606 | 167 |
"/ textView reallyModified ifTrue:[ |
168 |
"/ "/ leads to ugly behavior (method no longer found), if we allow |
|
169 |
"/ "/ this... |
|
170 |
"/ Dialog warn:'Please accept first (cannot set breakpoint while text is modified)'. |
|
171 |
"/ ^ self |
|
172 |
"/ ]. |
|
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
173 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
174 |
bpnt := self breakpointAtLine:line. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
175 |
bpnt isNil ifTrue:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
176 |
"/ 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
|
177 |
ok := (self canCreateOrToggleBreakpointAtLine:line). |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
178 |
ok ifFalse:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
179 |
(currentMethod isMethodWithBreakpoints and:[ prepareFullBreakSupport ]) ifFalse:[ |
17158 | 180 |
(codeView topView notNil and:[codeView topView isDebugView]) ifTrue:[ |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
181 |
(Dialog |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
182 |
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
|
183 |
(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
|
184 |
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
|
185 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
186 |
You can proceed to set the breakpoint, but it will only affect the next call into this method, not the current invocation.' |
16334 | 187 |
yesLabel:'Set Breakpoint for Next Call' noLabel:'OK') ifTrue:[ |
14950
29261c456545
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14849
diff
changeset
|
188 |
"/ self halt. |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
189 |
ok := true. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
190 |
] |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
191 |
] ifFalse:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
192 |
Dialog warn:'Sorry, cannot add a new breakpoint here.'. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
193 |
]. |
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 |
]. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
196 |
ok ifTrue:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
197 |
prepareFullBreakSupport ifTrue:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
198 |
"/ add a (disabled) breakpoint for every source line. This |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
199 |
"/ allows for breakpoints to be enabled/disabled in the debugger... |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
200 |
1 to:textView numberOfLines do:[:eachLine | |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
201 |
|oldBPnt eachPos otherBpnt| |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
202 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
203 |
oldBPnt := self breakpointAtLine:eachLine. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
204 |
oldBPnt isNil ifTrue:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
205 |
eachPos := textView characterPositionOfLine:eachLine col:1. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
206 |
breakpoints isNil ifTrue:[ breakpoints := OrderedCollection new]. |
15303
a5083c63035a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
15045
diff
changeset
|
207 |
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
|
208 |
eachLine == line ifTrue:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
209 |
bpnt := otherBpnt. |
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 |
otherBpnt beInvisible. |
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 |
] ifFalse:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
216 |
pos := textView characterPositionOfLine:line col:1. |
15303
a5083c63035a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
15045
diff
changeset
|
217 |
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
|
218 |
]. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
219 |
Screen current shiftDown ifTrue:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
220 |
"/ trace |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
221 |
bpnt beTracepoint |
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 |
self assert: breakpoints notEmptyOrNil. |
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 |
"/ recompile the method with breakpoints |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
226 |
self recompile. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
227 |
] |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
228 |
] ifFalse:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
229 |
"/ breakpoint already there - just enable/disable |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
230 |
Screen current shiftDown ifTrue:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
231 |
bpnt toggleTracing |
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 |
bpnt toggle. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
234 |
]. |
15983 | 235 |
(currentMethod isNil or:[(mClass := currentMethod mclass) isNil]) ifTrue:[ |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
236 |
"/ hack: ouch - was wrapped in the meantime; |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
237 |
"/ hurry up and update. Should be done elsewhere (in codeView) |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
238 |
self updateCurrentMethod. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
239 |
currentMethod notNil ifTrue:[ mClass := currentMethod mclass ]. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
240 |
]. |
15303
a5083c63035a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
15045
diff
changeset
|
241 |
bpnt method:currentMethod. |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
242 |
mClass notNil ifTrue:[ |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
243 |
Smalltalk changed:#methodTrap with:(MethodTrapChangeNotificationParameter changeClass:mClass changeSelector:currentMethod selector). |
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 |
]. |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
246 |
|
18644 | 247 |
bpnt notNil ifTrue:[ |
248 |
bpnt isReached ifFalse:[ |
|
249 |
| app | |
|
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
250 |
|
18644 | 251 |
app := codeView application. |
252 |
(app respondsTo: #showInfo:) ifTrue:[ |
|
253 |
app showInfo: 'Cannot set breakpoint here, try another line...'. |
|
254 |
]. |
|
255 |
"/ codeView flash. |
|
256 |
] ifTrue:[ |
|
257 |
"/ if it is ignored in the debugger, reenable |
|
258 |
Debugger notNil ifTrue:[ |
|
259 |
Debugger stopIgnoringHaltsFor:currentMethod atLineNr:bpnt line |
|
260 |
]. |
|
261 |
]. |
|
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
262 |
]. |
18644 | 263 |
|
264 |
gutterView redrawLine:line. |
|
18606 | 265 |
^ bpnt |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
266 |
|
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
267 |
"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
|
268 |
"Modified: / 21-02-2014 / 17:36:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17500 | 269 |
"Modified: / 13-04-2017 / 09:59:36 / cg" |
18644 | 270 |
"Modified: / 02-03-2019 / 11:32:07 / Claus Gittinger" |
14509
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
271 |
! ! |
763bb2f56f2f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14456
diff
changeset
|
272 |
|
10208 | 273 |
!BreakpointService methodsFor:'change & update'! |
274 |
||
275 |
update: aspect with: param from: sender |
|
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
276 |
aspect == #visibility ifTrue:[^ self]. |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
277 |
aspect == #sizeOfView ifTrue:[^ self]. |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
278 |
aspect == #classHolder ifTrue:[^ self]. |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
279 |
aspect == #languageHolder ifTrue:[^ self]. |
18620 | 280 |
(codeView notNil and:[sender == codeView modifiedChannel]) ifTrue:[^ self]. |
10208 | 281 |
|
13572
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
282 |
"/ ATTENTION: I thought that fetching the methodHolder once in initialize would |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
283 |
"/ 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
|
284 |
"/ so this fetch is called in update as well. |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
285 |
"/ maybe s.o. (ie. Jan) fixes CodeView2 |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
286 |
(aspect == #methodHolder or:[sender == self fetchMethodHolder]) ifTrue:[ |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
287 |
self updateCurrentMethod. |
10208 | 288 |
]. |
289 |
super update: aspect with: param from: sender |
|
290 |
||
291 |
"Created: / 06-07-2011 / 15:21:08 / cg" |
|
18620 | 292 |
"Modified: / 26-02-2019 / 18:06:23 / Claus Gittinger" |
10208 | 293 |
! |
294 |
||
295 |
updateBreakPointsFor:aMethod |
|
296 |
|methodsBreakPoints| |
|
297 |
||
13216
d1db940d42fb
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13209
diff
changeset
|
298 |
"/ Transcript show:'update breakpoints for method: '; showCR:aMethod. |
10208 | 299 |
aMethod notNil ifTrue:[ |
15383
671638959b16
Use breakpointsDo: instead of enumerating over literals.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15303
diff
changeset
|
300 |
aMethod breakpointsDo:[:eachLiteral | |
671638959b16
Use breakpointsDo: instead of enumerating over literals.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15303
diff
changeset
|
301 |
methodsBreakPoints isNil ifTrue:[ |
671638959b16
Use breakpointsDo: instead of enumerating over literals.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15303
diff
changeset
|
302 |
methodsBreakPoints := OrderedCollection new. |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
303 |
]. |
15383
671638959b16
Use breakpointsDo: instead of enumerating over literals.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15303
diff
changeset
|
304 |
methodsBreakPoints add:eachLiteral copy. |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
305 |
]. |
13106 | 306 |
currentMethodClass := aMethod mclass. |
307 |
] ifFalse:[ |
|
308 |
currentMethodClass := nil |
|
10208 | 309 |
]. |
310 |
breakpoints := methodsBreakPoints. |
|
17620 | 311 |
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
|
312 |
"/ 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
|
313 |
"/ 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
|
314 |
"/ 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
|
315 |
"/ 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
|
316 |
"/ #fixupBreakpointPositions |
15642
239bbe1c7328
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
15383
diff
changeset
|
317 |
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
|
318 |
]. |
10208 | 319 |
currentMethod := aMethod. |
320 |
||
321 |
"Created: / 06-07-2011 / 15:24:09 / cg" |
|
10226 | 322 |
"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
|
323 |
"Modified: / 23-02-2015 / 14:48:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17620 | 324 |
"Modified: / 16-08-2017 / 08:31:18 / cg" |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
325 |
! |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
326 |
|
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
327 |
updateCurrentMethod |
13101 | 328 |
|method realMethod oldBreakPoints| |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
329 |
|
13106 | 330 |
"/ codeView methodHolder class == BlockValue ifTrue:[self breakPoint:#cg]. |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
331 |
|
13201
3b6f308a7280
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13191
diff
changeset
|
332 |
method := realMethod := codeView method. |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
333 |
(method notNil and:[method mclass isNil]) ifTrue:[ |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
334 |
"/ hack: ouch - was wrapped in the meantime; |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
335 |
"/ hurry up and update. Should be done elsewhere (in codeView) |
14533
b0ab75a1f038
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14510
diff
changeset
|
336 |
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
|
337 |
realMethod isNil ifTrue:[ |
14533
b0ab75a1f038
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14510
diff
changeset
|
338 |
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
|
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 |
realMethod ~~ currentMethod ifTrue:[ |
13573
70135af4ddeb
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13572
diff
changeset
|
342 |
"/ self fetchMethodHolder setValue:realMethod. |
13101 | 343 |
oldBreakPoints := breakpoints. |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
344 |
self updateBreakPointsFor:realMethod. |
13101 | 345 |
oldBreakPoints ~= breakpoints ifTrue:[ |
346 |
gutterView invalidate. |
|
347 |
] |
|
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
348 |
]. |
13201
3b6f308a7280
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13191
diff
changeset
|
349 |
|
3b6f308a7280
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13191
diff
changeset
|
350 |
"Modified: / 22-07-2013 / 13:33:28 / cg" |
10208 | 351 |
! ! |
352 |
||
9982 | 353 |
!BreakpointService methodsFor:'event handling'! |
354 |
||
14845
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
355 |
buttonMultiPress:button x:x y:y in:view |
10714
3399fb50f42e
changed: #buttonPress:x:y:in:
Claus Gittinger <cg@exept.de>
parents:
10411
diff
changeset
|
356 |
|lineNr| |
3399fb50f42e
changed: #buttonPress:x:y:in:
Claus Gittinger <cg@exept.de>
parents:
10411
diff
changeset
|
357 |
|
9982 | 358 |
view == gutterView ifTrue:[ |
13152
778f0a1b39c2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13126
diff
changeset
|
359 |
button == 1 ifTrue:[ |
778f0a1b39c2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13126
diff
changeset
|
360 |
lineNr := textView yVisibleToLineNr:y. |
778f0a1b39c2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13126
diff
changeset
|
361 |
lineNr notNil ifTrue:[ self setOrToggleBreakpointAtLine:lineNr ]. |
778f0a1b39c2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13126
diff
changeset
|
362 |
^ true. |
778f0a1b39c2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13126
diff
changeset
|
363 |
]. |
778f0a1b39c2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13126
diff
changeset
|
364 |
button == 3 ifTrue:[ |
778f0a1b39c2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13126
diff
changeset
|
365 |
^ true. |
778f0a1b39c2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13126
diff
changeset
|
366 |
] |
9982 | 367 |
]. |
10182 | 368 |
^ false |
9982 | 369 |
|
370 |
"Created: / 17-06-2011 / 13:05:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
371 |
"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
|
372 |
"Modified: / 19-09-2011 / 14:41:00 / cg" |
10226 | 373 |
! |
374 |
||
14845
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
375 |
buttonPress:button x:x y:y in:view |
18664 | 376 |
|lineNr currentHelpListener| |
14845
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
377 |
|
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
378 |
"now disabled: need a double click (like in other editors); |
18644 | 379 |
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
|
380 |
|
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
381 |
view == gutterView ifTrue:[ |
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
382 |
button == 1 ifTrue:[ |
14849
6a193ec6c01f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14845
diff
changeset
|
383 |
lineNr := textView yVisibleToLineNr:y. |
18664 | 384 |
(currentHelpListener := FlyByHelp currentHelpListener) notNil ifTrue:[ |
14849
6a193ec6c01f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14845
diff
changeset
|
385 |
"/ show a message that a double click is now needed |
18664 | 386 |
currentHelpListener initiateHelpFor:view at:x@y now:true |
14849
6a193ec6c01f
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14845
diff
changeset
|
387 |
]. |
18644 | 388 |
"/ lineNr notNil ifTrue:[ self setOrToggleBreakpointAtLine:lineNr ]. |
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
|
389 |
^ false. |
14845
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
390 |
]. |
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
391 |
]. |
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
392 |
^ false |
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
393 |
|
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
394 |
"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
|
395 |
"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
|
396 |
"Modified: / 03-12-2014 / 10:22:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
18664 | 397 |
"Modified: / 12-03-2019 / 13:01:22 / Claus Gittinger" |
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 |
|
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
|
400 |
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
|
401 |
"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
|
402 |
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
|
403 |
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
|
404 |
|
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
|
405 |
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
|
406 |
textView undoableDo:[ |
14328
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
407 |
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
|
408 |
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
|
409 |
]. |
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
|
410 |
]. |
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
|
411 |
^ 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
|
412 |
]. |
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
|
413 |
^ 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
|
414 |
|
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
|
415 |
"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
|
416 |
"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
|
417 |
! |
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
|
418 |
|
10226 | 419 |
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
|
420 |
| breakpointsToRemove | |
10226 | 421 |
|
422 |
breakpoints isEmptyOrNil ifTrue:[^self]. |
|
14845
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
423 |
|
14456
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
424 |
breakpointsToRemove := Set new. |
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
425 |
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
|
426 |
| breakpointToRemove | |
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
427 |
|
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
428 |
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
|
429 |
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
|
430 |
]. |
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
431 |
breakpoints removeAll: breakpointsToRemove. |
218e0f00e309
Workaround for disappearing breakpoint icons after editing source code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14454
diff
changeset
|
432 |
self moveBreakpointsAfterLine: end by: (end - start + 1) negated |
10226 | 433 |
|
434 |
"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
|
435 |
"Modified: / 04-06-2014 / 17:56:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10226 | 436 |
! |
437 |
||
438 |
linesInsertedFrom: start to: end |
|
439 |
||
440 |
breakpoints isEmptyOrNil ifTrue:[^self]. |
|
14845
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
441 |
|
10226 | 442 |
self moveBreakpointsAfterLine: start - 1 by: (end - start + 1) |
443 |
||
444 |
"Created: / 06-07-2011 / 17:16:36 / jv" |
|
9982 | 445 |
! ! |
446 |
||
13126
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
447 |
!BreakpointService methodsFor:'help'! |
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
448 |
|
17914 | 449 |
helpTextAtLine:ignoredLineNr |
13126
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
450 |
|topView| |
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
451 |
|
17478 | 452 |
codeView method isNil ifTrue:[ |
453 |
^ nil |
|
454 |
]. |
|
455 |
currentMethod isNil ifTrue:[ |
|
456 |
^ nil |
|
457 |
]. |
|
13126
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
458 |
(self canCreateOrToggleBreakpointAtLine:nil) ifFalse:[ |
17157 | 459 |
((topView := codeView topView) notNil and:[topView isDebugView]) ifTrue:[ |
13126
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
460 |
self hasBreakpoints ifFalse:[ |
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
461 |
^ '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
|
462 |
]. |
13420
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
463 |
^ '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
|
464 |
]. |
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
465 |
^ 'Cannot add breakpoint when modified. Please accept first.' |
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
466 |
]. |
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
467 |
|
14845
7c4a218df889
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14533
diff
changeset
|
468 |
^ 'Double Click to toggle breakpoint. Shift-Double-Click to toggle tracepoint.' |
13126
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
469 |
|
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
470 |
"Created: / 27-01-2012 / 14:04:52 / cg" |
17478 | 471 |
"Modified: / 19-03-2017 / 01:15:48 / cg" |
13126
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
472 |
! ! |
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
473 |
|
9982 | 474 |
!BreakpointService methodsFor:'initialization'! |
475 |
||
13572
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
476 |
fetchMethodHolder |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
477 |
"redefinable in subclasses, which do not have a codeView2/methodHolder" |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
478 |
|
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
479 |
"/ ATTENTION: I thought that fetching the methodHolder once in initialize would |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
480 |
"/ 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
|
481 |
"/ so this fetch is called in update as well. |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
482 |
"/ maybe s.o. (ie. Jan) fixes CodeView2 |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
483 |
methodHolder := codeView methodHolder. |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
484 |
^ methodHolder |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
485 |
! |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
486 |
|
9982 | 487 |
initialize |
488 |
||
489 |
super initialize. |
|
490 |
breakpoints := OrderedCollection new. |
|
491 |
||
492 |
"Created: / 17-06-2011 / 13:49:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
493 |
! ! |
|
494 |
||
495 |
!BreakpointService methodsFor:'private'! |
|
496 |
||
14328
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
497 |
fixupBreakpointPositions |
18606 | 498 |
"computes the character positions of all line breakpoints" |
499 |
||
14328
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
500 |
breakpoints notEmptyOrNil ifTrue:[ |
14450
60b7e5f93d5a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14328
diff
changeset
|
501 |
breakpoints do:[:each | |
60b7e5f93d5a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14328
diff
changeset
|
502 |
| pos | |
14328
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
503 |
|
18606 | 504 |
pos := textView characterPositionOfLine:(each line) col:1. |
14450
60b7e5f93d5a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14328
diff
changeset
|
505 |
each position: pos. |
60b7e5f93d5a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14328
diff
changeset
|
506 |
]. |
18606 | 507 |
breakpoints := breakpoints select:[:b | b line >= 0]. |
508 |
breakpoints asOrderedCollection sort:[:a :b|a position < b position]. |
|
14328
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
509 |
]. |
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
510 |
|
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
511 |
"Created: / 08-05-2014 / 14:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17366 | 512 |
"Modified: / 07-02-2017 / 23:12:06 / cg" |
18606 | 513 |
"Modified: / 20-02-2019 / 17:49:59 / Claus Gittinger" |
14328
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
514 |
! |
9510671ea784
Fixes for breakpoint management when editing the code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14326
diff
changeset
|
515 |
|
10226 | 516 |
moveBreakpointsAfterLine:line by: delta |
517 |
breakpoints do:[:bpnt| |
|
11719 | 518 |
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
|
519 |
"/ 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
|
520 |
bpnt position:nil line:(bpnt line + delta). |
11719 | 521 |
] |
10226 | 522 |
]. |
14454
fdaebd3224b8
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
14450
diff
changeset
|
523 |
breakpoints := breakpoints reject:[:bpnt | bpnt line <= 0]. |
10226 | 524 |
|
525 |
"/gutterView redrawLinesFrom: line. |
|
526 |
||
527 |
"Created: / 17-06-2011 / 13:45:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
528 |
"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
|
529 |
"Modified: / 08-05-2014 / 14:01:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17092 | 530 |
"Modified: / 20-11-2016 / 19:09:12 / cg" |
10226 | 531 |
! |
532 |
||
10182 | 533 |
recompile |
534 |
"recompile the current method for changed breakpoints" |
|
535 |
||
18606 | 536 |
|oldMethod| |
10182 | 537 |
|
13201
3b6f308a7280
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13191
diff
changeset
|
538 |
oldMethod := codeView method. |
18606 | 539 |
(oldMethod isNil or:[oldMethod hasPrimitiveCode]) ifTrue:[^ self]. |
540 |
"/ be careful: if the text has been edited/modified, do not compile |
|
541 |
textView modified ifTrue:[ |
|
542 |
self breakPoint: #cg. |
|
543 |
self breakPoint: #jv. |
|
544 |
^self. |
|
545 |
]. |
|
10182 | 546 |
|
18606 | 547 |
self recompileMethod:oldMethod. |
10182 | 548 |
|
549 |
"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
|
550 |
"Modified: / 23-02-2015 / 14:49:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17777 | 551 |
"Modified: / 21-11-2017 / 13:09:36 / cg" |
18606 | 552 |
"Modified: / 20-02-2019 / 17:26:57 / Claus Gittinger" |
553 |
! |
|
554 |
||
555 |
recompileMethod:oldMethod |
|
556 |
"recompile oldMethod for changed breakpoints" |
|
557 |
||
558 |
| newMethod compilerClass compiler class selector| |
|
559 |
||
560 |
"/ prepare to get reachable bpts |
|
561 |
self fixupBreakpointPositions. |
|
562 |
breakpoints do:[:bp | bp isReached:false]. |
|
563 |
||
564 |
class := oldMethod mclass. |
|
565 |
class isNil ifTrue:[ |
|
566 |
class := codeView classHolder value. |
|
567 |
class isNil ifTrue:[ |
|
568 |
self breakPoint:#jv. |
|
569 |
Dialog warn:'oops - lost the method''s class'. |
|
570 |
^ self. |
|
571 |
] |
|
572 |
]. |
|
573 |
selector := oldMethod selector. |
|
574 |
||
575 |
compilerClass := oldMethod programmingLanguage compilerWithBreakpointSupportClass. |
|
576 |
compilerClass isNil ifTrue:[ |
|
577 |
Dialog warn:'No breakpoint support for this programming language'. |
|
578 |
^ self. |
|
579 |
]. |
|
580 |
compiler := compilerClass new. |
|
581 |
compiler breakpoints:breakpoints. |
|
582 |
||
583 |
Class withoutUpdatingChangesDo:[ |
|
584 |
newMethod := compiler |
|
585 |
compile:oldMethod source |
|
586 |
forClass:class |
|
587 |
inCategory:oldMethod category |
|
588 |
notifying:nil |
|
589 |
install:false |
|
590 |
skipIfSame:false |
|
591 |
silent:true |
|
592 |
foldConstants:true |
|
593 |
ifFail:[ Transcript showCR:'BreakpointService: failed to recompile for breakpoint' ]. |
|
594 |
||
595 |
selector isNil ifTrue:[ |
|
596 |
"/ May happen as the selector is not stored in the method but |
|
597 |
"/ searches through method's mclass methodDictionary. |
|
598 |
"/ Following should be save as breakpoint is not installed when |
|
599 |
"/ the code is modified... |
|
600 |
selector := compiler selector. |
|
601 |
]. |
|
602 |
||
603 |
oldMethod isWrapped ifTrue:[ |
|
604 |
"/ update the wrapped method - do not install |
|
605 |
newMethod originalMethod: oldMethod originalMethod. |
|
606 |
oldMethod replaceOriginalMethodWith:newMethod. |
|
607 |
] ifFalse:[ |
|
608 |
"/ install |
|
609 |
newMethod originalMethod: oldMethod. |
|
610 |
(class primAddSelector: selector withMethod:newMethod) ifFalse:[ |
|
611 |
oldMethod mclass:class. |
|
612 |
self breakPoint: #cg. |
|
613 |
self breakPoint: #jv. |
|
614 |
^ self |
|
615 |
]. |
|
616 |
]. |
|
617 |
||
618 |
breakpoints := breakpoints species new. |
|
619 |
newMethod breakpointsDo:[ :each | each method:newMethod. breakpoints add: each ]. |
|
620 |
"/ this assertion occasionally failed - and lead to wrong breakpoint handling in the compiler. |
|
621 |
"/ for now, as a q&d hack, sort them to make sure. |
|
622 |
"/ self assert:(breakpoints isSortedBy:[:a :b |a position <= b position]). |
|
623 |
breakpoints sort:[:a :b |a position <= b position]. |
|
624 |
||
625 |
"/ must update breakpoints BEFORE the following, because it leads to a change |
|
626 |
"/ notification, which may clear the breakpoints collection!! |
|
627 |
self fetchMethodHolder value:newMethod. |
|
628 |
oldMethod mclass isNil ifTrue:[ |
|
629 |
"/ although this is not strictly true, not doing this |
|
630 |
"/ would confuse a lot of other tools (such as the browser) |
|
631 |
oldMethod mclass:class. |
|
632 |
]. |
|
633 |
currentMethod := newMethod. |
|
634 |
class changed:#methodTrap with:selector. "/ tell browsers |
|
635 |
Smalltalk changed:#methodTrap with:(MethodTrapChangeNotificationParameter changeClass:class changeSelector:selector). |
|
636 |
]. |
|
637 |
||
638 |
"Created: / 20-02-2019 / 17:26:24 / Claus Gittinger" |
|
9982 | 639 |
! ! |
640 |
||
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
641 |
!BreakpointService methodsFor:'queries'! |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
642 |
|
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
643 |
canCreateOrToggleBreakpointAtLine:lineOrNilForAnywhere |
13420
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
644 |
"is it possible to place a breakpoint here and now?" |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
645 |
|
13126
6c0fc3e2986a
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13106
diff
changeset
|
646 |
|bpnt topView| |
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
647 |
|
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
648 |
textView reallyModified ifTrue:[ |
13420
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
649 |
"/ 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
|
650 |
"/ are while editing and shift them as required. |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
651 |
"/ (another idea worth a try would be |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
652 |
"/ to match the original parsetree (enumerating nodes with the breakpoints) |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
653 |
"/ against the new parsetree (walking in sync?) when finally compiling, |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
654 |
"/ and placing new breakpoints on matching tree nodes. |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
655 |
"/ (too much work, for a quick solution, I guess) |
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
656 |
^ false |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
657 |
]. |
13420
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
658 |
|
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
659 |
"/ can always toggle existing breakpoints... |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
660 |
lineOrNilForAnywhere notNil ifTrue:[ |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
661 |
bpnt := self breakpointAtLine:lineOrNilForAnywhere. |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
662 |
bpnt notNil ifTrue:[ |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
663 |
^ true. |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
664 |
] |
13420
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
665 |
] ifFalse:[ |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
666 |
(currentMethod notNil and:[currentMethod isMethodWithBreakpoints]) ifTrue:[ |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
667 |
^ true. |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
668 |
] |
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
669 |
]. |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
670 |
|
13420
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
671 |
"/ ok, the method has no breakpoints yet. |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
672 |
|
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
673 |
"/ 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
|
674 |
"/ I guess, we have to move code around a bit... |
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
675 |
((topView := codeView topView) class == DebugView) ifTrue:[ |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
676 |
"/ can only create new breakpoints in the debugger, |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
677 |
"/ iff we are in a wrapped method's prolog |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
678 |
topView selectedContextIsWrapped ifTrue:[ |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
679 |
topView selectedContext lineNumber == 1 ifTrue:[ |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
680 |
^ true |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
681 |
]. |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
682 |
]. |
13420
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
683 |
|
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
684 |
"/ well, if the debugger's code has already been modified, |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
685 |
"/ 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
|
686 |
"/ a breakpoint on the fly... |
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
687 |
topView showingAlreadyModifiedCode ifTrue:[^ true]. |
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
688 |
^ false. |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
689 |
]. |
13420
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
690 |
|
3f8f012f121b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13395
diff
changeset
|
691 |
"/ in a non-debugger, we can do it. |
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
692 |
^ true. |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
693 |
! |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
694 |
|
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
695 |
hasBreakpoints |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
696 |
^ breakpoints notEmptyOrNil |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
697 |
! ! |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
698 |
|
9982 | 699 |
!BreakpointService methodsFor:'redrawing'! |
700 |
||
16602 | 701 |
drawLine:lineNo in:view atX:x y:yBaseline width:w height:hFont ascent:aFont |
702 |
from:startCol to:endColOrNil with:fg and:bg |
|
9982 | 703 |
"Called by both gutterView and textView (well, not yet) to |
704 |
allow services to draw custom things on text view. |
|
705 |
Ask JV what the args means if unsure (I'm lazy to document |
|
706 |
them, now it is just an experiment...)" |
|
11607 | 707 |
|
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
708 |
|mthd bpnt icon dx dy| |
9982 | 709 |
|
16602 | 710 |
"/ these tests make the breakpointService unusable for other applications |
711 |
"/ (which are not based on smalltalk methods). |
|
712 |
"/ They are not really needed: if there is a breakpoint, |
|
13572
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
713 |
"/ I can show it. Period. |
13191
9745eed50f03
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13157
diff
changeset
|
714 |
|
13573
70135af4ddeb
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13572
diff
changeset
|
715 |
"/ (mthd := self fetchMethodHolder value) isNil ifTrue:[ |
13572
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
716 |
"/ ^ self |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
717 |
"/ ]. |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
718 |
"/ currentMethodClass isNil ifTrue:[ |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
719 |
"/ "/ hack: ouch - was wrapped in the meantime; |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
720 |
"/ ^ self. "/ wait for the real update |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
721 |
"/ "/ hurry up and update. Should be done elsewhere (in codeView) |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
722 |
"/ "/ self updateCurrentMethod. |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
723 |
"/ ]. |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
724 |
|
13572
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
725 |
view == gutterView ifTrue:[ |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
726 |
bpnt := self breakpointAtLine:lineNo. |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
727 |
bpnt isNil ifTrue:[ |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
728 |
^ self |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
729 |
]. |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
730 |
icon := bpnt icon. |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
731 |
icon isNil ifTrue:[ |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
732 |
^ self |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
733 |
]. |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
734 |
dx := ((w - icon width) / 2) rounded. |
16602 | 735 |
dy := ((hFont - icon height) / 2) rounded. |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
736 |
icon |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
737 |
displayOn:view |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
738 |
x:x + dx |
16602 | 739 |
y:yBaseline - hFont + dy + 4. "TODO: Magic constant" |
9982 | 740 |
]. |
741 |
||
742 |
"Created: / 17-06-2011 / 13:52:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10182 | 743 |
"Modified (format): / 05-07-2011 / 22:14:33 / cg" |
9982 | 744 |
! ! |
745 |
||
13572
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
746 |
!BreakpointService methodsFor:'registering'! |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
747 |
|
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
748 |
registerIn:aCodeView |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
749 |
super registerIn:aCodeView. |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
750 |
self fetchMethodHolder. |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
751 |
! ! |
7b7d06d0d564
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
13420
diff
changeset
|
752 |
|
12902
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
753 |
!BreakpointService methodsFor:'testing'! |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
754 |
|
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
755 |
isBreakpointService |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
756 |
^ true |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
757 |
! ! |
724e09dfd9a2
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12855
diff
changeset
|
758 |
|
9982 | 759 |
!BreakpointService class methodsFor:'documentation'! |
760 |
||
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
761 |
version |
15983 | 762 |
^ '$Header$' |
12949
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
763 |
! |
320a22d3c70b
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
12940
diff
changeset
|
764 |
|
9982 | 765 |
version_CVS |
15983 | 766 |
^ '$Header$' |
9982 | 767 |
! |
768 |
||
769 |
version_SVN |
|
15983 | 770 |
^ '$Id$' |
9982 | 771 |
! ! |
12507
3fa9ae668d96
class: Tools::BreakpointService
Claus Gittinger <cg@exept.de>
parents:
11987
diff
changeset
|
772 |