Tools__LintService.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 03 Dec 2014 11:25:53 +0100
changeset 14972 0e176d3678b1
parent 14052 ebcdddd89b02
child 15030 c8d7085ee271
permissions -rw-r--r--
Support for line annotations
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
     1
"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
     2
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
efc1f0809373 initial checkin
vrany
parents:
diff changeset
     3
              All Rights Reserved
efc1f0809373 initial checkin
vrany
parents:
diff changeset
     4
efc1f0809373 initial checkin
vrany
parents:
diff changeset
     5
Permission is hereby granted, free of charge, to any person
efc1f0809373 initial checkin
vrany
parents:
diff changeset
     6
obtaining a copy of this software and associated documentation
efc1f0809373 initial checkin
vrany
parents:
diff changeset
     7
files (the 'Software'), to deal in the Software without
efc1f0809373 initial checkin
vrany
parents:
diff changeset
     8
restriction, including without limitation the rights to use,
efc1f0809373 initial checkin
vrany
parents:
diff changeset
     9
copy, modify, merge, publish, distribute, sublicense, and/or sell
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    10
copies of the Software, and to permit persons to whom the
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    11
Software is furnished to do so, subject to the following
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    12
conditions:
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    13
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    14
The above copyright notice and this permission notice shall be
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    15
included in all copies or substantial portions of the Software.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    16
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    17
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    18
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    19
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    20
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    21
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    22
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    23
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    24
OTHER DEALINGS IN THE SOFTWARE.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    25
"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    26
"{ Package: 'stx:libtool' }"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    27
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    28
"{ NameSpace: Tools }"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    29
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    30
CodeViewService subclass:#LintService
11416
941e576b6f71 changed: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11390
diff changeset
    31
	instanceVariableNames:'ruleHolderFromApp highlighter'
941e576b6f71 changed: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11390
diff changeset
    32
	classVariableNames:''
941e576b6f71 changed: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11390
diff changeset
    33
	poolDictionaries:''
941e576b6f71 changed: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11390
diff changeset
    34
	category:'Interface-Lint'
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    35
!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    36
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    37
!LintService class methodsFor:'documentation'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    38
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    39
copyright
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    40
"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    41
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    42
              All Rights Reserved
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    43
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    44
Permission is hereby granted, free of charge, to any person
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    45
obtaining a copy of this software and associated documentation
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    46
files (the 'Software'), to deal in the Software without
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    47
restriction, including without limitation the rights to use,
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    48
copy, modify, merge, publish, distribute, sublicense, and/or sell
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    49
copies of the Software, and to permit persons to whom the
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    50
Software is furnished to do so, subject to the following
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    51
conditions:
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    52
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    53
The above copyright notice and this permission notice shall be
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    54
included in all copies or substantial portions of the Software.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    55
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    56
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    57
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    58
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    59
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    60
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    61
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    62
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    63
OTHER DEALINGS IN THE SOFTWARE.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    64
"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    65
! !
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    66
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    67
!LintService class methodsFor:'accessing'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    68
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    69
label
13099
f4f0761ca231 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 11416
diff changeset
    70
    "Answers a short label - for UI"
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    71
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    72
    ^'SmallLint Checker'
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    73
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    74
    "Created: / 05-08-2011 / 11:01:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    75
! !
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    76
13202
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    77
!LintService class methodsFor:'testing'!
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    78
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    79
isUsefulFor:aCodeView
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    80
    "this filters useful services.
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    81
     Redefined to return true for myself - not for subclasses"
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    82
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    83
    ^ self == Tools::LintService
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    84
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    85
    "Created: / 22-07-2013 / 14:01:38 / cg"
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    86
! !
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    87
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    88
!LintService methodsFor:'accessing'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    89
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    90
syntaxHighlighter
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    91
    | app rules |
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    92
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
    93
    app := codeView application.
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
    94
    app notNil ifTrue:[
11390
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
    95
        rules := self ruleHolderFromApp value.
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
    96
        rules notEmptyOrNil ifTrue:[
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
    97
            highlighter rules: rules.
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
    98
            ^ highlighter
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
    99
        ].
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   100
    ].
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   101
    ^nil
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   102
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   103
    "Created: / 05-08-2011 / 10:59:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
11390
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   104
    "Modified: / 08-03-2012 / 01:23:48 / cg"
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   105
! !
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   106
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   107
!LintService methodsFor:'aspects'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   108
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   109
ruleHolderFromApp
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   110
    "return/create the 'ruleHolderFromApp' value holder (automatically generated)"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   111
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   112
    |app|
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   113
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   114
    ruleHolderFromApp isNil ifTrue:[
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   115
        (app := self application) notNil ifTrue:[
11390
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   116
            self fetchLintRuleHolder
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   117
            "/ ruleHolderFromApp := ValueHolder new.
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   118
            "/ ruleHolderFromApp addDependent:self.
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   119
        ].
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   120
    ].
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   121
    ^ ruleHolderFromApp
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   122
11390
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   123
    "Modified: / 08-03-2012 / 01:17:15 / cg"
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   124
!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   125
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   126
ruleHolderFromApp:something
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   127
    "set the 'ruleHolderFromApp' value holder (automatically generated)"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   128
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   129
    |oldValue newValue|
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   130
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   131
    ruleHolderFromApp notNil ifTrue:[
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   132
        oldValue := ruleHolderFromApp value.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   133
        ruleHolderFromApp removeDependent:self.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   134
    ].
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   135
    ruleHolderFromApp := something.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   136
    ruleHolderFromApp notNil ifTrue:[
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   137
        ruleHolderFromApp addDependent:self.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   138
    ].
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   139
    newValue := ruleHolderFromApp value.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   140
    oldValue ~~ newValue ifTrue:[
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   141
        self update:#value with:newValue from:ruleHolderFromApp.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   142
    ].
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   143
! !
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   144
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   145
!LintService methodsFor:'change & update'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   146
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   147
update: aspect with: param from: sender
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   148
    aspect == #sizeOfView ifFalse:[
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   149
        sender == ruleHolderFromApp ifTrue:[
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   150
            self syntaxHighlight: true.
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   151
            ^ self.
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   152
        ]
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   153
    ].
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   154
    super update: aspect with: param from: sender.
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   155
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   156
    "Created: / 05-08-2011 / 11:49:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   157
    "Modified: / 07-03-2012 / 17:16:59 / cg"
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   158
! !
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   159
14972
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   160
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   161
!LintService methodsFor:'help'!
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   162
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   163
flyByHelpTextAtLine:aLineNr
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   164
    |a html rule|
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   165
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   166
    a := self annotationAtLine:aLineNr.
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   167
    a notNil ifTrue:[
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   168
        (rule := a rule) notNil ifTrue:[
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   169
            ^ 'Lint says: ',rule name.
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   170
"/            html := String streamContents:[:s|
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   171
"/                        s 
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   172
"/                            nextPutAll: '<html>'; 
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   173
"/                            nextPutAll: rule name; 
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   174
"/                            nextPutAll:'<P>';  
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   175
"/                            nextPutLine: rule rationale;
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   176
"/                            nextPutAll: '</html>'. 
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   177
"/                    ].
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   178
"/            ^ html
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   179
        ]
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   180
    ].
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   181
    ^ nil
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   182
! !
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   183
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   184
!LintService methodsFor:'initialization'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   185
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   186
initialize
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   187
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   188
    super initialize.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   189
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   190
    highlighter := LintHighlighter new
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   191
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   192
    "Modified: / 03-09-2010 / 22:29:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   193
    "Created: / 05-08-2011 / 11:53:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   194
! !
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   195
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   196
!LintService methodsFor:'private'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   197
14972
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   198
annotationAtLine: lineNo
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   199
    | annotations |        
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   200
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   201
    (annotations := highlighter annotations) isEmptyOrNil ifTrue:[ ^ nil ].
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   202
    annotations do:[:annotation|
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   203
        | line |
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   204
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   205
        (line := annotation line) isNil ifTrue:[
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   206
            line := codeView lineOfCharacterPosition: annotation startPosition.
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   207
            annotation line: line.
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   208
        ].
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   209
        line > lineNo ifTrue:[ ^ nil ].
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   210
        line == lineNo ifTrue:[ ^ annotation ].
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   211
    ].
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   212
    ^nil
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   213
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   214
    "Created: / 30-01-2012 / 21:06:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   215
!
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   216
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   217
syntaxHighlight: delayed
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   218
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   219
    | service |
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   220
    service := self service: #'Tools::CodeHighlightingService'.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   221
    service notNil ifTrue:[
14052
ebcdddd89b02 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13498
diff changeset
   222
        service processSafely: delayed
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   223
    ]
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   224
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   225
    "Created: / 05-08-2011 / 11:49:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
14052
ebcdddd89b02 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13498
diff changeset
   226
    "Modified: / 25-02-2014 / 19:57:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   227
! !
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   228
14972
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   229
!LintService methodsFor:'redrawing'!
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   230
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   231
drawLine:lineNo in:view atX:x y:y width:w height:h from:startCol to:endColOrNil with:fg and:bg 
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   232
    "Called by both gutterView and textView (well, not yet) to
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   233
     allow services to draw custom things on text view.
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   234
     Ask JV what the args means if unsure (I'm lazy to document
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   235
     them, now it is just an experiment...)"
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   236
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   237
    | lang annotation |
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   238
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   239
    ((lang := codeView language) isNil or:[lang isSmalltalk not]) ifTrue:[ ^ self ].
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   240
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   241
    annotation :=  self annotationAtLine: lineNo.
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   242
    annotation notNil ifTrue:[
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   243
        self drawAnnotationIcon: (ToolbarIconLibrary smalllintWarning16x16)
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   244
                atX: x y: y  width: w height: h.
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   245
    ].
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   246
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   247
    "Created: / 30-01-2012 / 15:11:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   248
    "Modified: / 07-08-2013 / 00:19:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   249
! !
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   250
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   251
!LintService methodsFor:'registering'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   252
11390
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   253
fetchLintRuleHolder
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   254
    |app|
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   255
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   256
    app := self application.
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   257
    app notNil ifTrue:[
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   258
        "/ bad design; better idea would be to pass the lintRuleHolder back from the
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   259
        "/ application to me explicitely (in a postBuild method for some ruleCanvas of the app)
11390
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   260
        (app respondsTo: #selectedLintRules) ifTrue:[
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   261
            self ruleHolderFromApp: app selectedLintRules
11390
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   262
        ] ifFalse:[
13498
b8d845e42988 Added `environment` instance variable to Tools__NewSystemBrowser and
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13202
diff changeset
   263
            "/ self breakPoint:#jv.
11416
941e576b6f71 changed: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11390
diff changeset
   264
            "/ Transcript showCR:'LintService [info]: app does not provide a lintRuleHolder'
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   265
        ]
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   266
    ].
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   267
11390
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   268
    "Created: / 08-03-2012 / 01:16:38 / cg"
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   269
!
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   270
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   271
registerIn: aCodeView
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   272
    super registerIn: aCodeView.
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   273
    self fetchLintRuleHolder.
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   274
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   275
    "Modified: / 17-06-2011 / 13:07:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   276
    "Created: / 05-08-2011 / 11:47:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
11390
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   277
    "Modified: / 08-03-2012 / 01:16:51 / cg"
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   278
! !
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   279
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   280
!LintService class methodsFor:'documentation'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   281
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   282
version
14972
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   283
    ^ '$Header: /cvs/stx/stx/libtool/Tools__LintService.st,v 1.11 2014-12-03 10:25:53 vrany Exp $'
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   284
!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   285
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   286
version_CVS
14972
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   287
    ^ '$Header: /cvs/stx/stx/libtool/Tools__LintService.st,v 1.11 2014-12-03 10:25:53 vrany Exp $'
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   288
! !
13099
f4f0761ca231 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 11416
diff changeset
   289