Tools__LintService.st
changeset 14972 0e176d3678b1
parent 14052 ebcdddd89b02
child 15030 c8d7085ee271
--- a/Tools__LintService.st	Wed Dec 03 11:24:50 2014 +0100
+++ b/Tools__LintService.st	Wed Dec 03 11:25:53 2014 +0100
@@ -157,6 +157,30 @@
     "Modified: / 07-03-2012 / 17:16:59 / cg"
 ! !
 
+
+!LintService methodsFor:'help'!
+
+flyByHelpTextAtLine:aLineNr
+    |a html rule|
+
+    a := self annotationAtLine:aLineNr.
+    a notNil ifTrue:[
+        (rule := a rule) notNil ifTrue:[
+            ^ 'Lint says: ',rule name.
+"/            html := String streamContents:[:s|
+"/                        s 
+"/                            nextPutAll: '<html>'; 
+"/                            nextPutAll: rule name; 
+"/                            nextPutAll:'<P>';  
+"/                            nextPutLine: rule rationale;
+"/                            nextPutAll: '</html>'. 
+"/                    ].
+"/            ^ html
+        ]
+    ].
+    ^ nil
+! !
+
 !LintService methodsFor:'initialization'!
 
 initialize
@@ -171,6 +195,25 @@
 
 !LintService methodsFor:'private'!
 
+annotationAtLine: lineNo
+    | annotations |        
+
+    (annotations := highlighter annotations) isEmptyOrNil ifTrue:[ ^ nil ].
+    annotations do:[:annotation|
+        | line |
+
+        (line := annotation line) isNil ifTrue:[
+            line := codeView lineOfCharacterPosition: annotation startPosition.
+            annotation line: line.
+        ].
+        line > lineNo ifTrue:[ ^ nil ].
+        line == lineNo ifTrue:[ ^ annotation ].
+    ].
+    ^nil
+
+    "Created: / 30-01-2012 / 21:06:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 syntaxHighlight: delayed
 
     | service |
@@ -183,6 +226,28 @@
     "Modified: / 25-02-2014 / 19:57:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!LintService methodsFor:'redrawing'!
+
+drawLine:lineNo in:view atX:x y:y width:w height:h from:startCol to:endColOrNil with:fg and:bg 
+    "Called by both gutterView and textView (well, not yet) to
+     allow services to draw custom things on text view.
+     Ask JV what the args means if unsure (I'm lazy to document
+     them, now it is just an experiment...)"
+
+    | lang annotation |
+
+    ((lang := codeView language) isNil or:[lang isSmalltalk not]) ifTrue:[ ^ self ].
+
+    annotation :=  self annotationAtLine: lineNo.
+    annotation notNil ifTrue:[
+        self drawAnnotationIcon: (ToolbarIconLibrary smalllintWarning16x16)
+                atX: x y: y  width: w height: h.
+    ].
+
+    "Created: / 30-01-2012 / 15:11:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-08-2013 / 00:19:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !LintService methodsFor:'registering'!
 
 fetchLintRuleHolder
@@ -215,10 +280,10 @@
 !LintService class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__LintService.st,v 1.10 2014-02-25 20:03:46 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__LintService.st,v 1.11 2014-12-03 10:25:53 vrany Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__LintService.st,v 1.10 2014-02-25 20:03:46 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__LintService.st,v 1.11 2014-12-03 10:25:53 vrany Exp $'
 ! !