Tools__BackgroundSourceProcessingService.st
author Claus Gittinger <cg@exept.de>
Wed, 19 Nov 2014 18:50:02 +0100
changeset 14846 5fab48017422
parent 14704 5de671ef2e61
child 14973 5972c23eeb9a
permissions -rw-r--r--
class: Tools::BackgroundSourceProcessingService added: #flyByHelpTextAtLine: changed: #annotationFlyByTextAtLine: line specific tooltips
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13881
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
     1
"
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
     2
 COPYRIGHT (c) 2006 by eXept Software AG
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
     3
              All Rights Reserved
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
     4
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
     5
 This software is furnished under a license and may be used
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
     6
 only in accordance with the terms of that license and with the
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
     8
 be provided or otherwise made available to, or used by, any
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
     9
 other person.  No title to or ownership of the software is
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    10
 hereby transferred.
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    11
"
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    12
"{ Package: 'stx:libtool' }"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    13
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    14
"{ NameSpace: Tools }"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    15
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    16
CodeViewService subclass:#BackgroundSourceProcessingService
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    17
	instanceVariableNames:'job done modified'
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    18
	classVariableNames:''
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    19
	poolDictionaries:''
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    20
	category:'Interface-CodeView'
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    21
!
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    22
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    23
!BackgroundSourceProcessingService class methodsFor:'documentation'!
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    24
13881
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    25
copyright
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    26
"
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    27
 COPYRIGHT (c) 2006 by eXept Software AG
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    28
              All Rights Reserved
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    29
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    30
 This software is furnished under a license and may be used
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    31
 only in accordance with the terms of that license and with the
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    33
 be provided or otherwise made available to, or used by, any
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    34
 other person.  No title to or ownership of the software is
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    35
 hereby transferred.
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    36
"
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    37
!
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    38
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    39
documentation
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    40
"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    41
    An abstract base class for all services that process current
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    42
    (displayed) source code. All processing is done in background
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    43
    job, that is restarted whenever a text in the editor is changed.
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    44
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    45
    [author:]
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    46
        Jan Vrany <jan.vrany@fit.cvut.cz>
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    47
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    48
    [instance variables:]
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    49
        job         <BackgroundJob> A background job.
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    50
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    51
    [class variables:]
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    52
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    53
    [see also:]
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    54
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    55
"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    56
! !
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    57
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    58
!BackgroundSourceProcessingService class methodsFor:'testing'!
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    59
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    60
isAbstract
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    61
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    62
    ^self == Tools::BackgroundSourceProcessingService
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    63
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    64
    "Created: / 24-01-2012 / 12:27:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    65
! !
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    66
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    67
!BackgroundSourceProcessingService methodsFor:'acessing-defaults'!
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    68
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    69
defaultJobName
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    70
    "Returns a human-readable job name, to ease identification in process browser"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    71
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    72
    ^ 'CodeView2''s source processing job'
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    73
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    74
    "Created: / 24-01-2012 / 12:05:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    75
! !
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    76
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    77
!BackgroundSourceProcessingService methodsFor:'change & update'!
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    78
13881
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    79
modelChanged
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    80
    "Model has changed (i.e., value holder keeping displayed text"
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    81
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    82
    self sourceChanged: true
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    83
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    84
    "Created: / 17-03-2012 / 15:45:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    85
!
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    86
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    87
sourceChanged:force
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    88
    "Called when codeview's text changes"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    89
13881
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    90
    (force or:[codeView reallyModified]) ifTrue:[
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    91
        self process
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    92
    ].
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    93
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    94
    "Modified: / 22-08-2011 / 13:51:53 / cg"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    95
    "Modified (format): / 05-09-2011 / 05:06:40 / cg"
13881
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
    96
    "Modified: / 17-03-2012 / 16:04:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    97
!
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    98
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
    99
update:aspect with:param from:sender 
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   100
    textView notNil ifTrue:[
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   101
        "/sender == textView modifiedChannel ifTrue:[^self codeChanged: false].
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   102
        sender == textView model ifTrue:[
13881
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   103
            sender value ~= textView contents ifTrue:[
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   104
                self modelChanged.
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   105
                ^self.
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   106
            ].
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   107
        ].
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   108
        (sender == textView and:[aspect == #sizeOfContents]) ifTrue:[
13881
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   109
            self sourceChanged:true.
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   110
            ^self.
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   111
        ].
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   112
    ].
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   113
    codeView notNil ifTrue:[
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   114
        sender == codeView languageHolder ifTrue:[
13881
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   115
            self sourceChanged:true.
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   116
            ^self
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   117
        ].
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   118
        sender == codeView classHolder ifTrue:[
13881
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   119
            self sourceChanged:true.
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   120
            ^self
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   121
        ].
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   122
    ].
13881
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   123
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   124
    aspect == #codeAspect ifTrue:[
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   125
        self sourceChanged:true.
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   126
        ^self
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   127
    ].
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   128
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   129
    super 
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   130
        update:aspect
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   131
        with:param
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   132
        from:sender
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   133
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   134
    "Created: / 06-03-2010 / 19:38:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   135
    "Modified: / 13-09-2011 / 12:00:29 / cg"
13881
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   136
    "Modified: / 22-02-2012 / 15:02:16 / jv"
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   137
    "Modified: / 15-04-2013 / 23:00:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   138
! !
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   139
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   140
!BackgroundSourceProcessingService methodsFor:'event handling'!
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   141
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   142
linesDeletedFrom:start to:end 
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   143
    self sourceChanged:true
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   144
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   145
    "Created: / 06-07-2011 / 17:14:36 / jv"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   146
    "Created: / 16-09-2011 / 15:18:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   147
!
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   148
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   149
linesInsertedFrom:start to:end 
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   150
    self sourceChanged:true
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   151
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   152
    "Created: / 06-07-2011 / 17:14:36 / jv"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   153
    "Created: / 16-09-2011 / 15:18:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   154
!
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   155
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   156
linesModifiedFrom:start to:end 
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   157
    self sourceChanged:true
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   158
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   159
    "Created: / 06-07-2011 / 17:14:36 / jv"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   160
    "Created: / 16-09-2011 / 15:15:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   161
! !
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   162
14846
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   163
!BackgroundSourceProcessingService methodsFor:'help'!
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   164
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   165
flyByHelpTextAtLine:aLineNr
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   166
    |a html rule|
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   167
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   168
    a := self annotationAtLine:aLineNr.
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   169
    a notNil ifTrue:[
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   170
        (rule := a rule) notNil ifTrue:[
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   171
            ^ 'Lint says: ',rule name.
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   172
"/            html := String streamContents:[:s|
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   173
"/                        s 
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   174
"/                            nextPutAll: '<html>'; 
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   175
"/                            nextPutAll: rule name; 
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   176
"/                            nextPutAll:'<P>';  
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   177
"/                            nextPutLine: rule rationale;
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   178
"/                            nextPutAll: '</html>'. 
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   179
"/                    ].
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   180
"/            ^ html
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   181
        ]
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   182
    ].
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   183
    ^ nil
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   184
! !
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   185
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   186
!BackgroundSourceProcessingService methodsFor:'initialization'!
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   187
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   188
initialize
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   189
    job := (Smalltalk at:#BackgroundJob) 
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   190
                named:self defaultJobName
14053
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   191
                on:[self processSafely: true]
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   192
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   193
    "Created: / 29-07-2011 / 10:31:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
11618
29842c419b87 changed: #initialize
Claus Gittinger <cg@exept.de>
parents: 11558
diff changeset
   194
    "Modified: / 19-07-2012 / 16:17:21 / cg"
14053
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   195
    "Modified: / 25-02-2014 / 19:58:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   196
! !
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   197
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   198
!BackgroundSourceProcessingService methodsFor:'processing'!
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   199
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   200
process
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   201
    "(Re)starts the processing job. Should be called whenever a source 
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   202
     must be (re)processed."
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   203
11558
0e93cd2b9c48 fixed process priorities
Claus Gittinger <cg@exept.de>
parents: 11183
diff changeset
   204
    | prio browser |
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   205
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   206
    "/ this clobbers the codeViews modified state; therefore, we have to remember
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   207
    "/ this info somewhere ...
11558
0e93cd2b9c48 fixed process priorities
Claus Gittinger <cg@exept.de>
parents: 11183
diff changeset
   208
    (browser := codeView browser) notNil ifTrue:[
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   209
        textView modified ifTrue:[
11558
0e93cd2b9c48 fixed process priorities
Claus Gittinger <cg@exept.de>
parents: 11183
diff changeset
   210
            browser navigationState realModifiedState: true
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   211
        ].
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   212
        textView modifiedChannel setValue:false.
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   213
    ].
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   214
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   215
    job scheduled ifTrue:[
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   216
        job running ifFalse:[
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   217
            "/ process already created, but did not get a change to start yet;
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   218
            ^ self
11558
0e93cd2b9c48 fixed process priorities
Claus Gittinger <cg@exept.de>
parents: 11183
diff changeset
   219
        ].
0e93cd2b9c48 fixed process priorities
Claus Gittinger <cg@exept.de>
parents: 11183
diff changeset
   220
        job stop.
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   221
    ].
11558
0e93cd2b9c48 fixed process priorities
Claus Gittinger <cg@exept.de>
parents: 11183
diff changeset
   222
    prio := Processor userBackgroundPriority.
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   223
    job startWithPriority: prio.
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   224
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   225
    "Modified: / 07-07-2011 / 12:26:12 / Jan Vrany <jan.vrant@fit.cvut,cz>"
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   226
    "Created: / 24-01-2012 / 12:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
11558
0e93cd2b9c48 fixed process priorities
Claus Gittinger <cg@exept.de>
parents: 11183
diff changeset
   227
    "Modified: / 05-06-2012 / 23:58:20 / cg"
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   228
!
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   229
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   230
process: delayed
14053
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   231
    "Actually process source code. If `delayed` is true, view should be updated
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   232
     asynchronously using #pushUserEvent:. Individual services should override
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   233
     this method.
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   234
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   235
     NOTE: Do not call this method from custom code directly, always call
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   236
     #processSafely: which handle possible errors and protect against
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   237
     'debugger bomb'
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   238
     "
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   239
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   240
    self subclassResponsibility
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   241
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   242
    "Created: / 24-01-2012 / 12:25:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
14053
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   243
    "Modified (comment): / 25-02-2014 / 19:52:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   244
!
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   245
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   246
processSafely: delayed
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   247
    "Process source code. If `delayed` is true, view should be updated
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   248
     asynchronously using #pushUserEvent:"
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   249
14054
1931f75c8318 Oops, catch Error, not Exception,.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14053
diff changeset
   250
    Error , HaltInterrupt handle:[:ex|
14053
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   251
        "/ Kludge...    
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   252
        (codeView topView class == DebugView) ifTrue:[
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   253
            Transcript showCR: 'Error when processing source code'.
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   254
            ex suspendedContext fullPrintAllOn: Transcript.
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   255
        ] ifFalse:[
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   256
            (Dialog confirm:('Error while processing source:\\',ex description,'\\Debug ?') withCRs) ifTrue:[
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   257
                ex reject.
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   258
            ]
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   259
        ]
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   260
    ] do:[
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   261
        self process: delayed
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   262
    ]
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   263
08f7da1dd758 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13881
diff changeset
   264
    "Created: / 25-02-2014 / 19:57:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   265
! !
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   266
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   267
!BackgroundSourceProcessingService methodsFor:'registering'!
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   268
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   269
registerIn: aCodeView
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   270
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   271
    super registerIn: aCodeView.
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   272
    textView addDependent: self.
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   273
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   274
    "Created: / 27-07-2011 / 13:25:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
14493
c2c143bf52a0 Fix in Tools::BackgroundSourceProcessingService>>unregister: stop possibly running background job
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14054
diff changeset
   275
!
c2c143bf52a0 Fix in Tools::BackgroundSourceProcessingService>>unregister: stop possibly running background job
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14054
diff changeset
   276
c2c143bf52a0 Fix in Tools::BackgroundSourceProcessingService>>unregister: stop possibly running background job
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14054
diff changeset
   277
unregister
c2c143bf52a0 Fix in Tools::BackgroundSourceProcessingService>>unregister: stop possibly running background job
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14054
diff changeset
   278
    job stop.
14704
5de671ef2e61 Fix in Tools::BackgroundSourceProcessingService>>unregister: remove itself from
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14493
diff changeset
   279
    textView removeDependent: self.     
14493
c2c143bf52a0 Fix in Tools::BackgroundSourceProcessingService>>unregister: stop possibly running background job
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14054
diff changeset
   280
    super unregister.
c2c143bf52a0 Fix in Tools::BackgroundSourceProcessingService>>unregister: stop possibly running background job
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14054
diff changeset
   281
c2c143bf52a0 Fix in Tools::BackgroundSourceProcessingService>>unregister: stop possibly running background job
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14054
diff changeset
   282
    "Created: / 13-06-2014 / 15:36:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
14704
5de671ef2e61 Fix in Tools::BackgroundSourceProcessingService>>unregister: remove itself from
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14493
diff changeset
   283
    "Modified: / 08-08-2014 / 06:57:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   284
! !
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   285
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   286
!BackgroundSourceProcessingService class methodsFor:'documentation'!
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   287
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   288
version
14846
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   289
    ^ '$Header: /cvs/stx/stx/libtool/Tools__BackgroundSourceProcessingService.st,v 1.9 2014-11-19 17:50:02 cg Exp $'
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   290
!
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   291
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   292
version_CVS
14846
5fab48017422 class: Tools::BackgroundSourceProcessingService
Claus Gittinger <cg@exept.de>
parents: 14704
diff changeset
   293
    ^ '$Header: /cvs/stx/stx/libtool/Tools__BackgroundSourceProcessingService.st,v 1.9 2014-11-19 17:50:02 cg Exp $'
11183
a0ab27f5679c initial checkin
vrany
parents:
diff changeset
   294
! !
13881
ceebd29ba8f6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 11618
diff changeset
   295