#REFACTORING by exept
class: Breakpoint
added: #breakPointMessageForContext:
changed: #break
--- a/Breakpoint.st Tue Jul 02 23:53:17 2019 +0200
+++ b/Breakpoint.st Tue Jul 09 15:23:45 2019 +0200
@@ -136,81 +136,19 @@
<resource: #skipInDebuggersWalkBack>
- |sender mthd where lineNr message
- source sourceLines sourceLine prevLine nextLine|
+ |sender message|
description isEnabled ifFalse:[^ self].
+
sender := thisContext sender.
(description shouldBreakIn:sender) ifTrue:[
- message := 'Breakpoint encountered at line %1 in %2'.
- where := '?'.
-
- mthd := method.
- mthd notNil ifTrue:[
- mthd mclass isNil ifTrue:[
- mthd := sender method.
- ].
- where := mthd whoString.
-
- (lineNr := self line) notNil ifTrue:[
- (source := mthd source) notNil ifTrue:[
- sourceLines := source asStringCollection.
- sourceLine := sourceLines at:lineNr ifAbsent:[nil].
- sourceLine notNil ifTrue:[
- sourceLine := (sourceLine "withoutLeadingSeparators" contractAtEndTo:60) allItalic withColor:Color darkRed.
- message := 'Breakpoint encountered at line %1 in %2\near:\%3'.
- lineNr > 1 ifTrue:[
- prevLine := sourceLines at:(lineNr-1) ifAbsent:[nil].
- prevLine notEmptyOrNil ifTrue:[
- "/ prevLine := prevLine withoutLeadingSeparators.
- prevLine notEmpty ifTrue:[
- prevLine := (prevLine contractAtEndTo:60) allItalic.
- lineNr > 2 ifTrue:[
- prevLine := '...', Character cr , prevLine.
- ].
- ] ifFalse:[
- prevLine := '...'.
- ].
- prevLine := prevLine withColor:Color grey.
- message := 'Breakpoint encountered at line %1 in %2\near:\%4\%3'.
- ].
- ].
- lineNr < (sourceLines size) ifTrue:[
- nextLine := sourceLines at:(lineNr+1) ifAbsent:[nil].
- nextLine notEmptyOrNil ifTrue:[
- "/ nextLine := nextLine withoutLeadingSeparators.
- nextLine notEmpty ifTrue:[
- nextLine := (nextLine contractAtEndTo:60) allItalic.
- lineNr < (sourceLines size - 1) ifTrue:[
- nextLine := nextLine , Character cr , '...'.
- ].
- ] ifFalse:[
- nextLine := '...'.
- ].
- nextLine := nextLine withColor:Color grey.
-
- prevLine notNil ifTrue:[
- message := 'Breakpoint encountered at line %1 in %2\near:\%4\%3\%5'.
- ] ifFalse:[
- message := 'Breakpoint encountered at line %1 in %2\near:\%3\%5'.
- ].
- ].
- ].
- ].
- ].
- ].
- ].
+ message := self breakPointMessageForContext:sender.
"/ to disable this breakpoint:
"/ description disable.
BreakPointInterrupt basicNew
- raiseRequestWith:self
- errorString:(message withCRs
- bindWith:self line
- with:where
- with:sourceLine
- with:prevLine
- with:nextLine)
+ raiseRequestWith:self
+ errorString:message
"/ not in sender, because otherwise the debugger won't
"/ detect the break on the stack
"/ in:sender.
@@ -234,6 +172,76 @@
"Modified: / 11-07-2011 / 18:17:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 21-10-2017 / 15:24:35 / cg"
"Modified: / 02-07-2019 / 23:49:17 / Claus Gittinger"
+!
+
+breakPointMessageForContext:sender
+ |mthd where lineNr message
+ source sourceLines sourceLine prevLine nextLine|
+
+ message := 'Breakpoint encountered at line %1 in %2'.
+ where := '?'.
+
+ mthd := method.
+ mthd notNil ifTrue:[
+ mthd mclass isNil ifTrue:[
+ mthd := sender method.
+ ].
+ where := mthd whoString.
+
+ (lineNr := self line) notNil ifTrue:[
+ (source := mthd source) notNil ifTrue:[
+ sourceLines := source asStringCollection.
+ sourceLine := sourceLines at:lineNr ifAbsent:[nil].
+ sourceLine notNil ifTrue:[
+ sourceLine := (sourceLine "withoutLeadingSeparators" contractAtEndTo:60) allItalic withColor:Color darkRed.
+ message := 'Breakpoint encountered at line %1 in %2\near:\%3'.
+ lineNr > 1 ifTrue:[
+ prevLine := sourceLines at:(lineNr-1) ifAbsent:[nil].
+ prevLine notEmptyOrNil ifTrue:[
+ "/ prevLine := prevLine withoutLeadingSeparators.
+ prevLine notEmpty ifTrue:[
+ prevLine := (prevLine contractAtEndTo:60) allItalic.
+ lineNr > 2 ifTrue:[
+ prevLine := '...', Character cr , prevLine.
+ ].
+ ] ifFalse:[
+ prevLine := '...'.
+ ].
+ prevLine := prevLine withColor:Color grey.
+ message := 'Breakpoint encountered at line %1 in %2\near:\%4\%3'.
+ ].
+ ].
+ lineNr < (sourceLines size) ifTrue:[
+ nextLine := sourceLines at:(lineNr+1) ifAbsent:[nil].
+ nextLine notEmptyOrNil ifTrue:[
+ "/ nextLine := nextLine withoutLeadingSeparators.
+ nextLine notEmpty ifTrue:[
+ nextLine := (nextLine contractAtEndTo:60) allItalic.
+ lineNr < (sourceLines size - 1) ifTrue:[
+ nextLine := nextLine , Character cr , '...'.
+ ].
+ ] ifFalse:[
+ nextLine := '...'.
+ ].
+ nextLine := nextLine withColor:Color grey.
+
+ prevLine notNil ifTrue:[
+ message := 'Breakpoint encountered at line %1 in %2\near:\%4\%3\%5'.
+ ] ifFalse:[
+ message := 'Breakpoint encountered at line %1 in %2\near:\%3\%5'.
+ ].
+ ].
+ ].
+ ].
+ ].
+ ].
+ ].
+ ^ (message withCRs
+ bindWith:self line
+ with:where
+ with:sourceLine
+ with:prevLine
+ with:nextLine)
! !
!Breakpoint methodsFor:'initialization'!