--- a/Tools__BreakpointService.st Tue Dec 03 22:29:42 2019 +0100
+++ b/Tools__BreakpointService.st Wed Dec 04 13:02:06 2019 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
All Rights Reserved
@@ -157,12 +159,25 @@
gutterView invalidate.
!
+setBreakpointAtLine:line
+ "unconditionally set a breakpoint (called via double click)"
+
+ self setOrToggleBreakpointAtLine:line toggle:false
+!
+
setOrToggleBreakpointAtLine:line
+ "toggle a breakpoint (called via single click)"
+
+ self setOrToggleBreakpointAtLine:line toggle:true
+!
+
+setOrToggleBreakpointAtLine:line toggle:doToggleBoolean
+ "set (via double click) or toggle (via single click) a breakpoint"
+
|pos bpnt prepareFullBreakSupport mClass ok|
- "/ if true, setting a single breakpoint in a method will create
- "/ a whole set of invisible (and disabled) breakpoints in that method,
- "/ one for each line.
+ "/ if prepareFullBreakSupport is true, setting a single breakpoint in a method will create
+ "/ a whole set of invisible (and disabled) breakpoints in that method, one for each line.
"/ These can later be enabled in the debugger
"/ (otherwise, the debugger's behavior is stupid, as it cannot recompile a method
"/ to set additional breakpoints).
@@ -177,13 +192,6 @@
^ nil
].
-"/ textView reallyModified ifTrue:[
-"/ "/ leads to ugly behavior (method no longer found), if we allow
-"/ "/ this...
-"/ Dialog warn:'Please accept first (cannot set breakpoint while text is modified)'.
-"/ ^ self
-"/ ].
-
bpnt := self breakpointAtLine:line.
bpnt isNil ifTrue:[
"/ no breakpoint there - create a new one as required (i.e. recompile)
@@ -241,38 +249,30 @@
self recompile.
]
] ifFalse:[
- "/ breakpoint already there - just enable/disable
- Screen current shiftDown ifTrue:[
- bpnt toggleTracing
- ] ifFalse:[
- bpnt toggle.
- ].
- (currentMethod isNil or:[(mClass := currentMethod mclass) isNil]) ifTrue:[
- "/ hack: ouch - was wrapped in the meantime;
- "/ hurry up and update. Should be done elsewhere (in codeView)
- self updateCurrentMethod.
- currentMethod notNil ifTrue:[ mClass := currentMethod mclass ].
- ].
- bpnt method:currentMethod.
- mClass notNil ifTrue:[
- Smalltalk changed:#methodTrap with:(MethodTrapChangeNotificationParameter changeClass:mClass changeSelector:currentMethod selector).
+ (doToggleBoolean or:[bpnt isEnabled not]) ifTrue:[
+ "/ breakpoint already there - just enable/disable
+ Screen current shiftDown ifTrue:[
+ bpnt toggleTracing
+ ] ifFalse:[
+ bpnt toggle.
+ ].
+ (currentMethod isNil or:[(mClass := currentMethod mclass) isNil]) ifTrue:[
+ "/ hack: ouch - was wrapped in the meantime;
+ "/ hurry up and update. Should be done elsewhere (in codeView)
+ self updateCurrentMethod.
+ currentMethod notNil ifTrue:[ mClass := currentMethod mclass ].
+ ].
+ bpnt method:currentMethod.
+ mClass notNil ifTrue:[
+ Smalltalk changed:#methodTrap with:(MethodTrapChangeNotificationParameter changeClass:mClass changeSelector:currentMethod selector).
+ ].
].
].
bpnt notNil ifTrue:[
- true "bpnt isReached" ifFalse:[
- | app |
-
- app := codeView application.
- (app respondsTo: #showInfo:) ifTrue:[
- app showInfo: 'Cannot set breakpoint here, try another line...'.
- ].
- "/ codeView flash.
- ] ifTrue:[
- "/ if it is ignored in the debugger, reenable
- Debugger notNil ifTrue:[
- Debugger stopIgnoringHaltsFor:currentMethod atLineNr:bpnt line
- ].
+ "/ if it was ignored in the debugger, reenable
+ Debugger notNil ifTrue:[
+ Debugger stopIgnoringHaltsFor:currentMethod atLineNr:bpnt line
].
].
@@ -370,7 +370,8 @@
buttonMultiPress:button x:x y:y in:view
view == gutterView ifTrue:[
button == 1 ifTrue:[
- self setOrToggleBreakpointAtX:x y:y.
+ self setBreakpointAtX:x y:y.
+ "/ self setOrToggleBreakpointAtX:x y:y.
^ true.
].
button == 3 ifTrue:[
@@ -467,6 +468,13 @@
"Created: / 06-07-2011 / 17:16:36 / jv"
!
+setBreakpointAtX:x y:y
+ |lineNr|
+
+ lineNr := textView yVisibleToLineNr:y.
+ lineNr notNil ifTrue:[ self setBreakpointAtLine:lineNr ].
+!
+
setOrToggleBreakpointAtX:x y:y
|lineNr|