Tools__CodeHighlightingService.st
changeset 13867 9b47144adc96
parent 13588 0701806de907
child 14486 c8b1e2d7dc46
--- a/Tools__CodeHighlightingService.st	Wed Feb 05 20:08:25 2014 +0100
+++ b/Tools__CodeHighlightingService.st	Wed Feb 05 20:08:27 2014 +0100
@@ -134,19 +134,19 @@
 !
 
 syntaxHighlighters
-    | highlighters |
+
+    | highlighters highlighter |
 
-    highlighters := OrderedCollection new.
+    highlighters := OrderedCollection new: 4.
+    highlighter := self syntaxHighlighter.
+    highlighter notNil ifTrue:[
+        highlighters add: highlighter 
+    ].
 
     codeView services do:[:service|
-        | highlighter |
-        highlighter := service syntaxHighlighter.        
-        highlighter notNil ifTrue:[
-            "HACK, since AbstractSyntaxHighlighter overwrites
-             emphasis instead of adding it..."
-            (highlighter isKindOf: AbstractSyntaxHighlighter class) ifTrue:[
-                highlighters addFirst: highlighter                    
-            ] ifFalse:[
+        service ~~ self ifTrue:[
+            highlighter := service syntaxHighlighter.        
+            highlighter notNil ifTrue:[
                 highlighters add: highlighter
             ].
         ]
@@ -154,7 +154,8 @@
     ^highlighters
 
     "Created: / 05-08-2011 / 10:49:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 30-07-2013 / 19:29:59 / cg"
+    "Modified: / 19-07-2012 / 12:58:48 / cg"
+    "Modified: / 23-04-2013 / 01:49:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !CodeHighlightingService methodsFor:'acessing-defaults'!
@@ -187,9 +188,8 @@
 !
 
 process: delayed
+
     |oldCode oldCodeList newCode elements cls mthd highlighterClasses|
-
-    enabled == false ifTrue:[^ self].      
 "/    codeView topView class == DebugView ifTrue:[^ self].
 
     done := false.
@@ -217,7 +217,7 @@
 
         "textView" modified ifFalse:[
             oldCodeList isNil ifFalse:[
-                oldCode := oldCodeList asStringCollection asStringWithoutEmphasis.
+                oldCode := oldCodeList asStringWithoutEmphasis.
                 "textView" modified ifFalse:[
                     Screen currentScreenQuerySignal answer:codeView device
                     do:[
@@ -232,16 +232,16 @@
                             "/ self showInfo:(errMsg colorizeAllWith:Color red).
                             newCode := nil.
                         ] do:[
-                            |codeAspect|
-
-                            elements := SortedCollection new.
+                            | codeAspect |
+                            
+                            elements := ParseTreeIndex new.
                             newCode := oldCode asText.
                             codeAspect := codeView codeAspect.
                             codeAspect == SyntaxHighlighter codeAspectMethod ifTrue:[
                                 highlighterClasses do:[:e|newCode := e formatMethod:mthd source:newCode in:cls using:syntaxPreferences elementsInto: elements].
                             ] ifFalse:[
                                 codeAspect == (SyntaxHighlighter codeAspectExpression) ifTrue:[
-                                    highlighterClasses do:[:e|newCode := e formatStatementList:newCode in:cls elementsInto: elements].
+                                    highlighterClasses do:[:e|newCode := e formatExpression:newCode in:cls elementsInto: elements].
                                 ] ifFalse:[
                                     codeAspect == (SyntaxHighlighter codeAspectClassDefinition) ifTrue:[
                                         highlighterClasses do:[:e|newCode := e formatClassDefinition:newCode string in:cls elementsInto: elements].
@@ -268,6 +268,8 @@
                                                 "/self delayedUpdateBufferLabelWithCheckIfModified
                                         ] ifFalse:[
                                             textView contents: newCode.
+                                            codeView syntaxElements: elements.
+                                            gutterView invalidate.
                                         ]
                                     ]
                                 ]
@@ -279,7 +281,7 @@
         ]
     ]
 
-    "Modified: / 16-09-2011 / 17:01:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 22-08-2011 / 14:17:47 / cg"
     "Created: / 24-01-2012 / 12:21:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 22-07-2013 / 13:33:40 / cg"
 !
@@ -317,6 +319,19 @@
                     "/ Certainly a kludge.
 
                     oldLine string = line string ifTrue:[
+                        | i |
+
+                        "JV@2012-02-01: Remove any emphasis on leading whitespace"
+                        "(presumably created by LintHighlighter)"
+                        i := line string indexOfNonSeparator.
+                        i > 1 ifTrue:[
+                            | e |
+
+                            (e := (line emphasisAt: i - 1)) notNil ifTrue:[
+                                line emphasisFrom: 1 to: i - 1 remove: e.
+                            ]
+                        ].
+
                         oldLine emphasis ~= line emphasis ifTrue:[
                             textView modifiedChannel removeDependent:self.
                             list at:lNr put:line.
@@ -353,25 +368,29 @@
             ]
         ]
     ].
-    codeView syntaxElements: elements
+    codeView syntaxElements: elements.
+    gutterView invalidate.
+
+"/    Transcript showCR:'--> rehighlighted ', self identityHash printString.
 
     "Modified: / 09-10-2006 / 11:50:17 / cg"
     "Created: / 14-02-2010 / 16:10:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 16-09-2011 / 17:33:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified (format): / 19-07-2012 / 12:07:05 / cg"
+    "Modified (format): / 21-08-2011 / 09:38:22 / cg"
+    "Modified: / 01-02-2012 / 19:18:00 / jv"
+    "Modified: / 17-03-2012 / 19:33:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !CodeHighlightingService class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeHighlightingService.st,v 1.46 2013-09-27 15:13:42 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeHighlightingService.st,v 1.47 2014-02-05 19:08:27 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeHighlightingService.st,v 1.46 2013-09-27 15:13:42 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeHighlightingService.st,v 1.47 2014-02-05 19:08:27 cg Exp $'
 !
 
 version_SVN
-    ^ '$Id: Tools__CodeHighlightingService.st,v 1.46 2013-09-27 15:13:42 cg Exp $'
+    ^ '$Id: Tools__CodeHighlightingService.st,v 1.47 2014-02-05 19:08:27 cg Exp $'
 ! !