--- a/tools/JavaSyntaxHighlighter.st Sat Jul 27 19:12:25 2013 +0100
+++ b/tools/JavaSyntaxHighlighter.st Sun Aug 04 01:46:45 2013 +0100
@@ -98,6 +98,12 @@
"Created: / 04-08-2011 / 23:44:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+formatClassDefinition:newCode line: ln number: lnr in:cls
+ ^self new formatClassDefinition:newCode line: ln number: lnr in:cls.
+
+ "Created: / 04-08-2013 / 00:25:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
formatExpression:source in:class
^self new formatExpression:source in:class
@@ -131,6 +137,12 @@
^self new formatMethod:mth source:source in:class using: preferences elementsInto: elements
"Created: / 04-08-2011 / 23:42:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+formatMethod:mthd source:newCode line: ln number: lnr in:cls using:syntaxPreferences
+ ^ self new formatMethod:mthd source:newCode line: ln number: lnr in:cls using:syntaxPreferences
+
+ "Created: / 04-08-2013 / 00:26:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaSyntaxHighlighter methodsFor:'formatting'!
@@ -150,6 +162,27 @@
"Created: / 04-08-2011 / 23:44:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+formatClassDefinition:newCode line: line number: lnr in:cls
+ | scanner |
+
+ line isEmptyOrNil ifTrue:[ ^ nil ].
+
+ sourceText := line asText.
+ preferences isNil ifTrue:[
+ preferences := UserPreferences current.
+ ].
+ scanner := Scanner for: line asString.
+ scanner highlighter: self.
+ [
+ [ scanner nextToken ~~ #EOF ] whileTrue.
+ ] on: Error do:[
+
+ ].
+ ^ sourceText
+
+ "Created: / 04-08-2013 / 00:25:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
formatExpression:source in:class
"/ self breakPoint:#jv.
@@ -182,6 +215,28 @@
^self formatMethod:mth source:source in:class using: prefs
"Created: / 04-08-2011 / 23:42:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+formatMethod:mthd source:newCode line: line number: lnr in:cls using:syntaxPreferences
+ | scanner |
+
+ line isEmptyOrNil ifTrue:[ ^ nil ].
+
+ sourceText := line asText.
+ preferences := syntaxPreferences.
+ preferences isNil ifTrue:[
+ preferences := UserPreferences current.
+ ].
+ scanner := Scanner for: line asString.
+ scanner highlighter: self.
+ [
+ [ scanner nextToken ~~ #EOF ] whileTrue.
+ ] on: Error do:[
+
+ ].
+ ^ sourceText
+
+ "Created: / 04-08-2013 / 00:26:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaSyntaxHighlighter methodsFor:'formatting - private'!
@@ -708,26 +763,21 @@
!JavaSyntaxHighlighter::Scanner methodsFor:'reading next token'!
nextToken
- |t|
+ | t |
- [
- t := super nextToken.
- tokenEndPosition := source position.
- t isNil
- ] whileTrue.
- Verbose == true ifTrue:[
- Transcript
- show:'JavaScanner nextToken => ';
- show: t storeString;
- show: ' | ';
- showCR: tokenValue.
- ].
+ t := super nextToken.
+ t == #String ifTrue:[
+ highlighter markStringFrom:tokenStartPosition + 1 to: tokenEndPosition + 1.
+ ] ifFalse:[
+ t == #Integer ifTrue:[
+ highlighter markConstantFrom:tokenStartPosition + 1 to: tokenEndPosition + 1.
+ ]].
^ t
"Created: / 14-05-1998 / 15:48:04 / cg"
"Modified: / 16-05-1998 / 19:12:29 / cg"
- "Modified: / 17-03-2012 / 17:35:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Created: / 17-03-2012 / 19:15:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 03-08-2013 / 20:12:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
skipComment