23 Object subclass:#GroovySourceHighlighter |
23 Object subclass:#GroovySourceHighlighter |
24 instanceVariableNames:'preferences cachedStringEmphasis cachedStringColor sourceText |
24 instanceVariableNames:'preferences cachedStringEmphasis cachedStringColor sourceText |
25 sourceIndex' |
25 sourceIndex' |
26 classVariableNames:'' |
26 classVariableNames:'' |
27 poolDictionaries:'' |
27 poolDictionaries:'' |
28 category:'Languages-Java-Tools-Source' |
28 category:'Languages-Groovy-Tools-Source' |
29 ! |
29 ! |
30 |
30 |
31 JavaScanner subclass:#Scanner |
31 GroovyScanner subclass:#Scanner |
32 instanceVariableNames:'buffer bufferFirst bufferLast highlighter' |
32 instanceVariableNames:'buffer bufferFirst bufferLast highlighter' |
33 classVariableNames:'' |
33 classVariableNames:'' |
34 poolDictionaries:'' |
34 poolDictionaries:'' |
35 privateIn:GroovySourceHighlighter |
35 privateIn:GroovySourceHighlighter |
36 ! |
36 ! |
232 ! ! |
232 ! ! |
233 |
233 |
234 !GroovySourceHighlighter methodsFor:'formatting-private'! |
234 !GroovySourceHighlighter methodsFor:'formatting-private'! |
235 |
235 |
236 format: source |
236 format: source |
237 | scanner | |
237 "Simple formatting based on lexical structure only" |
238 |
238 |
239 sourceText := source string asText. |
239 | scanner token lastToken0 lastToken1 lastValue0 lastValue1 lastPosition0 lastPosition1 | |
|
240 sourceText := source asText. |
240 scanner := Scanner for: source string. |
241 scanner := Scanner for: source string. |
241 scanner highlighter: self. |
242 scanner highlighter: self. |
242 [ |
243 [ |
243 [ scanner nextToken ~~ #EOF ] whileTrue. |
244 [ (token := scanner nextToken) ~~ #EOF ] whileTrue:[ |
|
245 "/ Here, try to guess what's selector... |
|
246 token == $( ifTrue:[ |
|
247 lastPosition0 == #Identifier ifTrue:[ |
|
248 self markSelectorFrom: lastPosition0 to: lastPosition0 + lastValue0 size - 1. |
|
249 ]. |
|
250 ]. |
|
251 |
|
252 lastToken1 := lastToken0. |
|
253 lastValue1 := lastValue0. |
|
254 lastPosition1 := lastPosition0. |
|
255 |
|
256 lastToken0 := token. |
|
257 lastValue0 := scanner tokenValue. |
|
258 lastPosition0 := scanner tokenStartPosition. |
|
259 ]. |
244 ] on: Error do:[:ex| |
260 ] on: Error do:[:ex| |
245 ex |
261 ]. |
246 ]. |
|
247 |
|
248 ^ sourceText |
262 ^ sourceText |
249 |
263 |
250 "Created: / 02-10-2013 / 14:40:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
264 "Created: / 02-10-2013 / 14:40:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
265 "Modified: / 03-10-2013 / 20:27:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
251 ! ! |
266 ! ! |
252 |
267 |
253 !GroovySourceHighlighter methodsFor:'queries'! |
268 !GroovySourceHighlighter methodsFor:'queries'! |
254 |
269 |
255 doLexicalHighlightingOnly |
270 doLexicalHighlightingOnly |
694 "Created: / 17-03-2012 / 00:05:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
709 "Created: / 17-03-2012 / 00:05:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
695 ! ! |
710 ! ! |
696 |
711 |
697 !GroovySourceHighlighter class methodsFor:'documentation'! |
712 !GroovySourceHighlighter class methodsFor:'documentation'! |
698 |
713 |
699 version |
|
700 ^ '$Header: /cvs/stx/stx/libjava/tools/GroovySourceHighlighter.st,v 1.1 2013-10-03 08:31:41 vrany Exp $' |
|
701 ! |
|
702 |
|
703 version_CVS |
|
704 ^ '$Header: /cvs/stx/stx/libjava/tools/GroovySourceHighlighter.st,v 1.1 2013-10-03 08:31:41 vrany Exp $' |
|
705 ! |
|
706 |
|
707 version_HG |
714 version_HG |
708 |
715 |
709 ^ '$Changeset: <not expanded> $' |
716 ^ '$Changeset: <not expanded> $' |
710 ! ! |
717 ! ! |
711 |
718 |