AbstractSyntaxHighlighter.st
branchjv
changeset 3716 bcd80550baab
parent 3675 6a75a2fe7a83
child 3735 6c929682760d
--- a/AbstractSyntaxHighlighter.st	Fri Feb 19 15:39:04 2016 +0000
+++ b/AbstractSyntaxHighlighter.st	Mon Feb 22 20:56:30 2016 +0000
@@ -255,6 +255,40 @@
     ^ self formatMethod:nil source:aString in:aClass using:preferencesOrNil
 
     "Modified: / 28-04-2010 / 13:02:11 / cg"
+!
+
+formatStatements:aString in:aClass
+    "Format (recolor) a list of statements with optional temporaries in a given class.
+     Return the text containing font changes and color information."
+
+    |parser tree text|
+
+    aString isNil ifTrue:[^ nil].
+
+    parser := self for:(ReadStream on:aString string) in:aClass.
+    parser ignoreErrors:true.
+    parser ignoreWarnings:true.
+    parser sourceText:(text := aString string asText).
+    "/ use an array here - this can be changed much faster using #at:put:
+    text emphasisCollection:(Array new:aString size).
+
+    parser nextToken.
+    tree := parser parseMethodBody.
+    "/ now, convert the emphasis-array to a runArray
+    text emphasisCollection:(text emphasis asRunArray).
+
+    tree == #Error ifTrue:[
+        ^ self colorize:text forErrorAtPosition:parser sourceStream position withOriginal:aString.
+    ].
+    ^ text
+
+    "
+     SyntaxHighlighter
+        formatStatements:'| a b | a error: b'
+        in:UndefinedObject
+    "
+
+    "Created: / 22-02-2016 / 20:50:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !AbstractSyntaxHighlighter class methodsFor:'highlighting'!
@@ -678,6 +712,11 @@
     ^ '$Header$'
 !
 
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+!
+
 version_SVN
     ^ '$ Id $'
 ! !