Tools__LintService.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 14 Jun 2018 22:19:39 +0100
branchjv
changeset 18227 d25a407ba86d
parent 16617 69e7de1ef22f
permissions -rw-r--r--
Mini testrunner: show "green" if there's at least one pass and rest is pass or skip This is more meaningfull result then showing "gray" if there's at least one skip.
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
15030
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
    31
	instanceVariableNames:'ruleHolderFromApp highlighter annotations
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
    32
		annotationsSequenceNumber'
11416
941e576b6f71 changed: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11390
diff changeset
    33
	classVariableNames:''
941e576b6f71 changed: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11390
diff changeset
    34
	poolDictionaries:''
941e576b6f71 changed: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11390
diff changeset
    35
	category:'Interface-Lint'
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    36
!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    37
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    38
!LintService class methodsFor:'documentation'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    39
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    40
copyright
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    41
"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    42
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    43
              All Rights Reserved
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    44
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    45
Permission is hereby granted, free of charge, to any person
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    46
obtaining a copy of this software and associated documentation
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    47
files (the 'Software'), to deal in the Software without
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    48
restriction, including without limitation the rights to use,
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    49
copy, modify, merge, publish, distribute, sublicense, and/or sell
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    50
copies of the Software, and to permit persons to whom the
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    51
Software is furnished to do so, subject to the following
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    52
conditions:
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    53
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    54
The above copyright notice and this permission notice shall be
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    55
included in all copies or substantial portions of the Software.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    56
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    57
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    58
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    59
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    60
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    61
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    62
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    63
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    64
OTHER DEALINGS IN THE SOFTWARE.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    65
"
16605
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
    66
!
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
    67
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
    68
documentation
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
    69
"
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
    70
    cg:
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
    71
    
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
    72
    This service framework is a bit confusing; there is so much code duplication.
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
    73
    The distinction between LintService and Smallsense::SmalltalkLintService is
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
    74
    unclear to me.
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
    75
    
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
    76
    If I understand this correctly, this is used to highlight the
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
    77
    output of the static analyzer (debug-button in browser), whereas Smallsense::SmalltalkLintService
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
    78
    displays the output from the just-in-time analysis in the codeview
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
    79
    Is this correct?
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
    80
    Why not merge those two - most of the functionality is the same.     
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
    81
"    
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    82
! !
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    83
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    84
!LintService class methodsFor:'accessing'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    85
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    86
label
13099
f4f0761ca231 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 11416
diff changeset
    87
    "Answers a short label - for UI"
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    88
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    89
    ^'SmallLint Checker'
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    90
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    91
    "Created: / 05-08-2011 / 11:01:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    92
! !
efc1f0809373 initial checkin
vrany
parents:
diff changeset
    93
13202
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    94
!LintService class methodsFor:'testing'!
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    95
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    96
isUsefulFor:aCodeView
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    97
    "this filters useful services.
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    98
     Redefined to return true for myself - not for subclasses"
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
    99
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
   100
    ^ self == Tools::LintService
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
   101
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
   102
    "Created: / 22-07-2013 / 14:01:38 / cg"
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
   103
! !
dd6ea03d2edd class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 13099
diff changeset
   104
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   105
!LintService methodsFor:'accessing'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   106
15030
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   107
annotationAtLine: lineNo
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   108
    | anns |
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   109
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   110
    (anns := self annotations) notNil ifTrue:[ 
15076
c3c0c682a1e0 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 15030
diff changeset
   111
        ^ anns detect:[:annotation | annotation line = lineNo] ifNone:[nil]
15030
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   112
    ].
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   113
    ^ nil
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   114
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   115
    "Created: / 30-01-2012 / 21:06:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   116
    "Modified: / 15-12-2014 / 15:40:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   117
!
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   118
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   119
annotations
15076
c3c0c682a1e0 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 15030
diff changeset
   120
    #fixme. "/ code duplication with SmalltalkLintService >> annotations
15030
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   121
    (highlighter notNil and:[ highlighter sequenceNumber ~~ annotationsSequenceNumber ]) ifTrue:[
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   122
        | rulesToIntervalsMap annotationsPerLineMap |
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   123
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   124
        rulesToIntervalsMap := highlighter rulesToIntervalsMap.
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   125
        rulesToIntervalsMap notNil ifTrue:[ 
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   126
            annotationsPerLineMap := Dictionary new.
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   127
            rulesToIntervalsMap keysAndValuesDo:[ :rule :intervals |
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   128
                intervals do:[:interval | 
15076
c3c0c682a1e0 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 15030
diff changeset
   129
                    | line annotation ruleAlready|
15030
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   130
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   131
                    line := codeView lineOfCharacterPosition: interval first.
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   132
                    annotation := annotationsPerLineMap at: line ifAbsentPut:[ LintAnnotation new line: line ].
15076
c3c0c682a1e0 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 15030
diff changeset
   133
                    ruleAlready := annotation rule.
c3c0c682a1e0 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 15030
diff changeset
   134
                    ruleAlready notNil ifTrue:[ 
c3c0c682a1e0 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 15030
diff changeset
   135
                        ruleAlready isComposite ifTrue: [ 
c3c0c682a1e0 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 15030
diff changeset
   136
                            (ruleAlready rules includes:rule) ifFalse:[
c3c0c682a1e0 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 15030
diff changeset
   137
                                ruleAlready addRule:rule "rules add: rule"
c3c0c682a1e0 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 15030
diff changeset
   138
                            ].
c3c0c682a1e0 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 15030
diff changeset
   139
                        ] ifFalse:[
c3c0c682a1e0 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 15030
diff changeset
   140
                            ruleAlready ~= rule ifTrue:[
c3c0c682a1e0 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 15030
diff changeset
   141
                                annotation rule: (RBCompositeLintRule rules: (OrderedCollection with: ruleAlready with: rule))
c3c0c682a1e0 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 15030
diff changeset
   142
                            ]
c3c0c682a1e0 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 15030
diff changeset
   143
                        ]
15030
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   144
                    ] ifFalse:[ 
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   145
                        annotation rule: rule
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   146
                    ].
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   147
                ].
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   148
            ].
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   149
            annotations := annotationsPerLineMap values sort:[ :a :b | a line < b line ].
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   150
            annotationsSequenceNumber := highlighter sequenceNumber.
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   151
        ]
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   152
    ].
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   153
    ^annotations
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   154
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   155
    "Created: / 15-12-2014 / 15:29:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   156
    "Modified: / 15-12-2014 / 18:41:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   157
!
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   158
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   159
syntaxHighlighter
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   160
    | app rules |
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   161
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   162
    app := codeView application.
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   163
    app notNil ifTrue:[
11390
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   164
        rules := self ruleHolderFromApp value.
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   165
        rules notEmptyOrNil ifTrue:[
15030
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   166
            annotations := nil.
11390
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   167
            highlighter rules: rules.
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   168
            ^ highlighter
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   169
        ].
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   170
    ].
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   171
    ^nil
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   172
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   173
    "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
   174
    "Modified: / 08-03-2012 / 01:23:48 / cg"
15030
c8d7085ee271 LintHighlighter/.LintService refactored to show multiple rules at line...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14972
diff changeset
   175
    "Modified: / 15-12-2014 / 20:22:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   176
! !
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   177
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   178
!LintService methodsFor:'aspects'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   179
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   180
ruleHolderFromApp
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   181
    "return/create the 'ruleHolderFromApp' value holder (automatically generated)"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   182
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   183
    |app|
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   184
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   185
    ruleHolderFromApp isNil ifTrue:[
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   186
        (app := self application) notNil ifTrue:[
11390
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   187
            self fetchLintRuleHolder
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   188
            "/ ruleHolderFromApp := ValueHolder new.
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   189
            "/ ruleHolderFromApp addDependent:self.
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   190
        ].
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   191
    ].
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   192
    ^ ruleHolderFromApp
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   193
11390
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   194
    "Modified: / 08-03-2012 / 01:17:15 / cg"
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   195
!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   196
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   197
ruleHolderFromApp:something
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   198
    "set the 'ruleHolderFromApp' value holder (automatically generated)"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   199
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   200
    |oldValue newValue|
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   201
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   202
    ruleHolderFromApp notNil ifTrue:[
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   203
        oldValue := ruleHolderFromApp value.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   204
        ruleHolderFromApp removeDependent:self.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   205
    ].
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   206
    ruleHolderFromApp := something.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   207
    ruleHolderFromApp notNil ifTrue:[
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   208
        ruleHolderFromApp addDependent:self.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   209
    ].
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   210
    newValue := ruleHolderFromApp value.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   211
    oldValue ~~ newValue ifTrue:[
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   212
        self update:#value with:newValue from:ruleHolderFromApp.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   213
    ].
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   214
! !
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   215
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   216
!LintService methodsFor:'change & update'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   217
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   218
update: aspect with: param from: sender
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   219
    aspect == #sizeOfView ifFalse:[
16605
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
   220
    aspect == #pointerInView ifFalse:[
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   221
        sender == ruleHolderFromApp ifTrue:[
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   222
            self syntaxHighlight: true.
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   223
            ^ self.
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   224
        ]
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   225
    ].
16605
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
   226
    ].
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   227
    super update: aspect with: param from: sender.
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   228
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   229
    "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
   230
    "Modified: / 07-03-2012 / 17:16:59 / cg"
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   231
! !
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   232
14972
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   233
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   234
!LintService methodsFor:'initialization'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   235
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   236
initialize
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   237
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   238
    super initialize.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   239
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   240
    highlighter := LintHighlighter new
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   241
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   242
    "Modified: / 03-09-2010 / 22:29:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   243
    "Created: / 05-08-2011 / 11:53:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   244
! !
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   245
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   246
!LintService methodsFor:'private'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   247
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   248
syntaxHighlight: delayed
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   249
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   250
    | service |
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   251
    service := self service: #'Tools::CodeHighlightingService'.
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   252
    service notNil ifTrue:[
14052
ebcdddd89b02 Fix in BackrgoundSourceProcessingService:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13498
diff changeset
   253
        service processSafely: delayed
16605
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
   254
    ].
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
   255
    codeView updateScrollersViewBackground.
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   256
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   257
    "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
   258
    "Modified: / 25-02-2014 / 19:57:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   259
! !
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   260
14972
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   261
!LintService methodsFor:'redrawing'!
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   262
16605
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
   263
drawLine:lineNo in:view atX:x y:yBaseline width:w height:hFont ascent:aFont from:startCol to:endColOrNil with:fg and:bg 
14972
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   264
    "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
   265
     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
   266
     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
   267
     them, now it is just an experiment...)"
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   268
16605
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
   269
    "/ cg: why only for smalltalk?
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
   270
    "/ if there are annotations, why not show it?
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
   271
    "/ | lang |
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
   272
    "/ ((lang := codeView language) isNil or:[lang isSmalltalk not]) ifTrue:[ ^ self ].
14972
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   273
16605
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
   274
    self drawAnnotationInLine:lineNo 
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
   275
         in:view atX:x y:yBaseline width:w height:hFont ascent:aFont 
759e80b6e2fb #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16555
diff changeset
   276
         from:startCol to:endColOrNil with:fg and:bg
14972
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   277
! !
0e176d3678b1 Support for line annotations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14052
diff changeset
   278
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   279
!LintService methodsFor:'registering'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   280
11390
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   281
fetchLintRuleHolder
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   282
    |app|
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   283
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   284
    app := self application.
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   285
    app notNil ifTrue:[
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   286
        "/ bad design; better idea would be to pass the lintRuleHolder back from the
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   287
        "/ 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
   288
        (app respondsTo: #selectedLintRules) ifTrue:[
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   289
            self ruleHolderFromApp: app selectedLintRules
11390
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   290
        ] ifFalse:[
13498
b8d845e42988 Added `environment` instance variable to Tools__NewSystemBrowser and
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13202
diff changeset
   291
            "/ self breakPoint:#jv.
11416
941e576b6f71 changed: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11390
diff changeset
   292
            "/ Transcript showCR:'LintService [info]: app does not provide a lintRuleHolder'
11382
c078e68a2ffe changed:
Claus Gittinger <cg@exept.de>
parents: 11227
diff changeset
   293
        ]
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   294
    ].
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   295
11390
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   296
    "Created: / 08-03-2012 / 01:16:38 / cg"
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   297
!
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   298
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   299
registerIn: aCodeView
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   300
    super registerIn: aCodeView.
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   301
    self fetchLintRuleHolder.
b5af6f49f10f added: #fetchLintRuleHolder
Claus Gittinger <cg@exept.de>
parents: 11389
diff changeset
   302
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   303
    "Modified: / 17-06-2011 / 13:07:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   304
    "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
   305
    "Modified: / 08-03-2012 / 01:16:51 / cg"
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   306
! !
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   307
16555
6b84fcdf3207 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 15293
diff changeset
   308
!LintService methodsFor:'testing'!
6b84fcdf3207 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 15293
diff changeset
   309
6b84fcdf3207 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 15293
diff changeset
   310
isLintService
6b84fcdf3207 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 15293
diff changeset
   311
    ^ true
6b84fcdf3207 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 15293
diff changeset
   312
! !
6b84fcdf3207 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 15293
diff changeset
   313
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   314
!LintService class methodsFor:'documentation'!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   315
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   316
version
16555
6b84fcdf3207 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 15293
diff changeset
   317
    ^ '$Header$'
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   318
!
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   319
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   320
version_CVS
16555
6b84fcdf3207 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 15293
diff changeset
   321
    ^ '$Header$'
10484
efc1f0809373 initial checkin
vrany
parents:
diff changeset
   322
! !
13099
f4f0761ca231 class: Tools::LintService
Claus Gittinger <cg@exept.de>
parents: 11416
diff changeset
   323