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