Tools__BreakpointService.st
changeset 13572 7b7d06d0d564
parent 13420 3f8f012f121b
child 13573 70135af4ddeb
equal deleted inserted replaced
13571:54b41a330e8d 13572:7b7d06d0d564
    26 "{ Package: 'stx:libtool' }"
    26 "{ Package: 'stx:libtool' }"
    27 
    27 
    28 "{ NameSpace: Tools }"
    28 "{ NameSpace: Tools }"
    29 
    29 
    30 CodeViewService subclass:#BreakpointService
    30 CodeViewService subclass:#BreakpointService
    31 	instanceVariableNames:'breakpoints currentMethod currentMethodClass'
    31 	instanceVariableNames:'breakpoints currentMethod currentMethodClass methodHolder'
    32 	classVariableNames:''
    32 	classVariableNames:''
    33 	poolDictionaries:''
    33 	poolDictionaries:''
    34 	category:'Interface-CodeView'
    34 	category:'Interface-CodeView'
    35 !
    35 !
    36 
    36 
    96     aspect == #sizeOfView ifTrue:[^ self].
    96     aspect == #sizeOfView ifTrue:[^ self].
    97     aspect == #classHolder ifTrue:[^ self].
    97     aspect == #classHolder ifTrue:[^ self].
    98     aspect == #languageHolder ifTrue:[^ self].
    98     aspect == #languageHolder ifTrue:[^ self].
    99     sender == codeView modifiedChannel ifTrue:[^ self].
    99     sender == codeView modifiedChannel ifTrue:[^ self].
   100 
   100 
   101     (aspect == #methodHolder or:[sender == codeView methodHolder]) ifTrue:[
   101     "/ ATTENTION: I thought that fetching the methodHolder once in initialize would
       
   102     "/ be ok. However, it seems not (codeView gives me something which it does not use/change later).
       
   103     "/ so this fetch is called in update as well.
       
   104     "/ maybe s.o. (ie. Jan) fixes CodeView2
       
   105     (aspect == #methodHolder or:[sender == self fetchMethodHolder]) ifTrue:[
   102         self updateCurrentMethod.
   106         self updateCurrentMethod.
   103     ].
   107     ].
   104     super update: aspect with: param from: sender
   108     super update: aspect with: param from: sender
   105 
   109 
   106     "Created: / 06-07-2011 / 15:21:08 / cg"
   110     "Created: / 06-07-2011 / 15:21:08 / cg"
   143         realMethod isNil ifTrue:[
   147         realMethod isNil ifTrue:[
   144             realMethod := WrappedMethod allInstances detect:[:m | m originalMethod == method and:[m mclass notNil]] ifNone:nil.
   148             realMethod := WrappedMethod allInstances detect:[:m | m originalMethod == method and:[m mclass notNil]] ifNone:nil.
   145         ].
   149         ].
   146     ].
   150     ].
   147     realMethod ~~ currentMethod ifTrue:[
   151     realMethod ~~ currentMethod ifTrue:[
   148         "/ codeView methodHolder setValue:realMethod.
   152         "/ self methodHolder setValue:realMethod.
   149         oldBreakPoints := breakpoints.
   153         oldBreakPoints := breakpoints.
   150         self updateBreakPointsFor:realMethod.
   154         self updateBreakPointsFor:realMethod.
   151         oldBreakPoints ~= breakpoints ifTrue:[
   155         oldBreakPoints ~= breakpoints ifTrue:[
   152             gutterView invalidate.
   156             gutterView invalidate.
   153         ]
   157         ]
   213 
   217 
   214     "Created: / 27-01-2012 / 14:04:52 / cg"
   218     "Created: / 27-01-2012 / 14:04:52 / cg"
   215 ! !
   219 ! !
   216 
   220 
   217 !BreakpointService methodsFor:'initialization'!
   221 !BreakpointService methodsFor:'initialization'!
       
   222 
       
   223 fetchMethodHolder
       
   224     "redefinable in subclasses, which do not have a codeView2/methodHolder"
       
   225 
       
   226     "/ ATTENTION: I thought that fetching the methodHolder once in initialize would
       
   227     "/ be ok. However, it seems not (codeView gives me something which it does not use/change later).
       
   228     "/ so this fetch is called in update as well.
       
   229     "/ maybe s.o. (ie. Jan) fixes CodeView2
       
   230     methodHolder := codeView methodHolder.
       
   231     ^ methodHolder
       
   232 !
   218 
   233 
   219 initialize
   234 initialize
   220 
   235 
   221     super initialize.
   236     super initialize.
   222     breakpoints := OrderedCollection new.
   237     breakpoints := OrderedCollection new.
   343                                     bp isReached
   358                                     bp isReached
   344                                 ].
   359                                 ].
   345 
   360 
   346                 "/ must update breakpoints BEFORE the following, because it leads to a change
   361                 "/ must update breakpoints BEFORE the following, because it leads to a change
   347                 "/ notification, which may clear the breakpoints collection!!
   362                 "/ notification, which may clear the breakpoints collection!!
   348                 codeView methodHolder value:newMethod.
   363                 self fetchMethodHolder value:newMethod.
   349                 oldMethod mclass isNil ifTrue:[
   364                 oldMethod mclass isNil ifTrue:[
   350                     "/ although this is not strictly true, not doing this
   365                     "/ although this is not strictly true, not doing this
   351                     "/ would confuse a lot of other tools (such as the browser)
   366                     "/ would confuse a lot of other tools (such as the browser)
   352                     oldMethod mclass:class.
   367                     oldMethod mclass:class.
   353                 ].
   368                 ].
   529      Ask JV what the args means if unsure (I'm lazy to document
   544      Ask JV what the args means if unsure (I'm lazy to document
   530      them, now it is just an experiment...)"
   545      them, now it is just an experiment...)"
   531 
   546 
   532     |mthd bpnt icon dx dy|
   547     |mthd bpnt icon dx dy|
   533 
   548 
   534 "/ these tests make the breakpointService unusable for other applications (which are mote
   549     "/ these tests make the breakpointService unusable for other applications (which are not
   535 "/ based on smalltalk methods. They are not really needed: if there is a breakpoint,
   550     "/ based on smalltalk methods). They are not really needed: if there is a breakpoint,
   536 "/ I can show it. Period.
   551     "/ I can show it. Period.
   537 
   552 
   538 "/    (mthd := codeView methodHolder value) isNil ifTrue:[
   553     "/    (mthd := self methodHolder value) isNil ifTrue:[
   539 "/        ^ self
   554     "/        ^ self
   540 "/    ].
   555     "/    ].
   541 "/    currentMethodClass isNil ifTrue:[
   556     "/    currentMethodClass isNil ifTrue:[
   542 "/        "/ hack: ouch - was wrapped in the meantime;
   557     "/        "/ hack: ouch - was wrapped in the meantime;
   543 "/        ^ self. "/ wait for the real update
   558     "/        ^ self. "/ wait for the real update
   544 "/        "/ hurry up and update. Should be done elsewhere (in codeView)
   559     "/        "/ hurry up and update. Should be done elsewhere (in codeView)
   545 "/        "/ self updateCurrentMethod.
   560     "/        "/ self updateCurrentMethod.
   546 "/    ].
   561     "/    ].
   547 
   562 
   548    view == gutterView ifTrue:[
   563     view == gutterView ifTrue:[
   549         bpnt := self breakpointAtLine:lineNo.
   564         bpnt := self breakpointAtLine:lineNo.
   550         bpnt isNil ifTrue:[
   565         bpnt isNil ifTrue:[
   551             ^ self
   566             ^ self
   552         ].
   567         ].
   553         icon := bpnt icon.
   568         icon := bpnt icon.
   564 
   579 
   565     "Created: / 17-06-2011 / 13:52:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   580     "Created: / 17-06-2011 / 13:52:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   566     "Modified (format): / 05-07-2011 / 22:14:33 / cg"
   581     "Modified (format): / 05-07-2011 / 22:14:33 / cg"
   567 ! !
   582 ! !
   568 
   583 
       
   584 !BreakpointService methodsFor:'registering'!
       
   585 
       
   586 registerIn:aCodeView
       
   587     super registerIn:aCodeView.
       
   588     self fetchMethodHolder.
       
   589 ! !
       
   590 
   569 !BreakpointService methodsFor:'testing'!
   591 !BreakpointService methodsFor:'testing'!
   570 
   592 
   571 isBreakpointService
   593 isBreakpointService
   572     ^ true
   594     ^ true
   573 ! !
   595 ! !
   574 
   596 
   575 !BreakpointService class methodsFor:'documentation'!
   597 !BreakpointService class methodsFor:'documentation'!
   576 
   598 
   577 version
   599 version
   578     ^ '$Header: /cvs/stx/stx/libtool/Tools__BreakpointService.st,v 1.39 2013-08-30 22:54:49 cg Exp $'
   600     ^ '$Header: /cvs/stx/stx/libtool/Tools__BreakpointService.st,v 1.40 2013-09-24 15:49:13 cg Exp $'
   579 !
   601 !
   580 
   602 
   581 version_CVS
   603 version_CVS
   582     ^ '$Header: /cvs/stx/stx/libtool/Tools__BreakpointService.st,v 1.39 2013-08-30 22:54:49 cg Exp $'
   604     ^ '$Header: /cvs/stx/stx/libtool/Tools__BreakpointService.st,v 1.40 2013-09-24 15:49:13 cg Exp $'
   583 !
   605 !
   584 
   606 
   585 version_SVN
   607 version_SVN
   586     ^ '$Id: Tools__BreakpointService.st,v 1.39 2013-08-30 22:54:49 cg Exp $'
   608     ^ '$Id: Tools__BreakpointService.st,v 1.40 2013-09-24 15:49:13 cg Exp $'
   587 ! !
   609 ! !
   588 
   610