--- a/SyntaxHighlighter.st Sat Feb 21 12:27:04 2015 +0100
+++ b/SyntaxHighlighter.st Fri Feb 27 14:22:32 2015 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1998 by eXept Software AG
All Rights Reserved
@@ -100,55 +102,52 @@
"format (recolor) a method in a given class.
Return the text containing font changes and color information."
- |highlighter tree text endPos eColor|
+ "/ cg: I smell a wumpus: I don't think, all of this must be redefined - most is already there in the superclass.
+
+ |highlighter tree newText|
aString isNil ifTrue:[^ nil].
Error handle:[:ex |
- ex creator isHandled ifTrue:[
- ex reject.
- ].
+ "/ Transcript showCR:ex description.
(ParseError handles:ex) ifFalse:[
+ ex creator isHandled ifTrue:[
+ "/ Transcript showCR:'handled'.
+ ex reject.
+ ].
"Parse error may happen when re-formatting incomplete code while editing"
"/ ('SyntaxHighlighter [info]: error during highlight: ' , ex description) infoPrintCR.
"/ ex suspendedContext fullPrintAll.
].
+ highlighter notNil ifTrue:[
+ ^ self colorize:(newText ? aString) forErrorAtPosition:highlighter sourceStream position withOriginal:aString
+ ].
^ aString
] do:[
- highlighter := self for:(ReadStream on:aString string) in:aClass.
+ |sourceString|
+
+ sourceString := aString string.
+ newText := sourceString asUnicode16String asText.
+ "/ use an array here (instead of the RunArray) - this can be changed much faster using #at:put:
+ newText emphasisCollection:(Array new:sourceString size).
+
+ highlighter := self for:(ReadStream on:sourceString) in:aClass.
preferencesOrNil notNil ifTrue:[highlighter preferences:preferencesOrNil].
"/ highlighter ignoreErrors:true.
highlighter ignoreWarnings:true.
- highlighter sourceText:(text := aString string asText).
- "/ use an array here - this can be changed much faster using #at:put:
- text emphasisCollection:(Array new:aString size).
+ highlighter sourceText:newText.
tree := highlighter parseMethod.
+ newText := highlighter sourceText. "/ might have changed identity
"/ now, convert the emphasis-array to a runArray
- text emphasisCollection:(text emphasis asRunArray).
+ newText emphasisCollection:(newText emphasis asRunArray).
tree == #Error ifTrue:[
- eColor := UserPreferences current errorColor.
- eColor notNil ifTrue:[
- "/ mhmh - which is better ...
- "/ alternative1: color rest after error in red
- text
- emphasizeFrom:(highlighter sourceStream position + 1)
- to:text size
- with:(#color->eColor).
- ] ifFalse:[
- "/ alternative2: take original emphasis for rest
+ ^ self colorize:newText forErrorAtPosition:highlighter sourceStream position withOriginal:aString.
+ ].
+ ^ newText
+ ]
- endPos := highlighter sourceStream position + 1.
- endPos >= text size ifTrue:[
- ^ text
- ].
- ^ (text copyTo:endPos) , (aString copyFrom:(endPos+1))
- ].
- "/ alternative3: no emphasis for rest.
- ].
- ^ text
- ]
"
self
formatMethod:'foo
@@ -489,6 +488,7 @@
!
markReturnAt:pos
+ "/ sourceText := (sourceText copyTo:pos-1),(Character value:16r21e7),(sourceText copyFrom:pos+1).
self
markFrom:pos to:pos
withEmphasis:(preferences returnEmphasis)
@@ -710,10 +710,10 @@
!SyntaxHighlighter class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/SyntaxHighlighter.st,v 1.77 2015-02-01 21:53:27 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/SyntaxHighlighter.st,v 1.78 2015-02-27 13:22:32 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libcomp/SyntaxHighlighter.st,v 1.77 2015-02-01 21:53:27 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/SyntaxHighlighter.st,v 1.78 2015-02-27 13:22:32 cg Exp $'
! !