author | Stefan Vogel <sv@exept.de> |
Mon, 26 Mar 2018 15:53:53 +0200 | |
changeset 4222 | 9757ab066985 |
parent 4202 | b74cb013e847 |
child 4229 | 35f7bbf9efa4 |
permissions | -rw-r--r-- |
2506 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
2371 | 12 |
"{ Package: 'stx:libcomp' }" |
13 |
||
3561
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
14 |
"{ NameSpace: Smalltalk }" |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
15 |
|
2371 | 16 |
Parser subclass:#AbstractSyntaxHighlighter |
4202 | 17 |
instanceVariableNames:'method sourceText preferences fullSelectorCheck commentColor |
18 |
commentEmphasis commentFont constantColor constantEmphasis' |
|
2371 | 19 |
classVariableNames:'' |
20 |
poolDictionaries:'' |
|
21 |
category:'System-Compiler' |
|
22 |
! |
|
23 |
||
2506 | 24 |
!AbstractSyntaxHighlighter class methodsFor:'documentation'! |
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
3345
718b64ff3db3
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3344
diff
changeset
|
38 |
! |
718b64ff3db3
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3344
diff
changeset
|
39 |
|
718b64ff3db3
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3344
diff
changeset
|
40 |
documentation |
718b64ff3db3
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3344
diff
changeset
|
41 |
" |
718b64ff3db3
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3344
diff
changeset
|
42 |
common superclass for (smalltalk-) syntax highlighting. |
3599 | 43 |
|
44 |
This will parse the source code and update the local copy of the |
|
45 |
sourceText (in that instvar) by changing emphasis and color, |
|
46 |
as syntax elements are encountered. |
|
47 |
This is done by redefining appropriate markXXX methods, which are |
|
48 |
called by the parser whenever an interesting syntactic construct is encountered. |
|
49 |
These methods are no-ops in the Parser class, but redefined here to update |
|
50 |
the colorization of sourceText. |
|
4200 | 51 |
|
52 |
Caveat: |
|
53 |
used to be a smalltalk syntax highlighter and therefore (wrongly) subclassed Parser. |
|
54 |
However, over time, much functionality was added, which is of use for other languages also |
|
55 |
and this class will therefore be changed to use composition and have parsing delegated. |
|
56 |
to be independent of the language and to not inherit stuff, which is not needed. |
|
3345
718b64ff3db3
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3344
diff
changeset
|
57 |
" |
2506 | 58 |
! ! |
2371 | 59 |
|
60 |
!AbstractSyntaxHighlighter class methodsFor:'api highlighting'! |
|
61 |
||
62 |
formatClassDefinition:aString in:aClass |
|
63 |
"format (recolor) a class definition expression in a given class. |
|
64 |
Return the text containing font changes and color information." |
|
65 |
||
66 |
^ self formatExpression:aString in:aClass |
|
67 |
! |
|
68 |
||
2506 | 69 |
formatClassDefinition:aString in:aClass elementsInto: elements |
70 |
"format (recolor) a class definition expression in a given class. |
|
71 |
Return the text containing font changes and color information." |
|
72 |
||
73 |
^ self formatExpression:aString in:aClass |
|
74 |
||
75 |
"Created: / 10-04-2011 / 18:18:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
76 |
! |
|
77 |
||
2371 | 78 |
formatExpression:aString in:aClass |
79 |
"format (recolor) an expression in a given class. |
|
80 |
Return the text containing font changes and color information." |
|
81 |
||
3599 | 82 |
|parser tree text| |
2371 | 83 |
|
84 |
aString isNil ifTrue:[^ nil]. |
|
85 |
||
86 |
parser := self for:(ReadStream on:aString string) in:aClass. |
|
87 |
parser ignoreErrors:true. |
|
88 |
parser ignoreWarnings:true. |
|
89 |
parser sourceText:(text := aString string asText). |
|
90 |
"/ use an array here - this can be changed much faster using #at:put: |
|
91 |
text emphasisCollection:(Array new:aString size). |
|
92 |
||
93 |
parser nextToken. |
|
94 |
tree := parser expression. |
|
95 |
"/ now, convert the emphasis-array to a runArray |
|
96 |
text emphasisCollection:(text emphasis asRunArray). |
|
97 |
||
98 |
tree == #Error ifTrue:[ |
|
3599 | 99 |
^ self colorize:text forErrorAtPosition:parser sourceStream position withOriginal:aString. |
2371 | 100 |
]. |
101 |
^ text |
|
102 |
||
103 |
" |
|
104 |
self |
|
3599 | 105 |
formatExpression:'(1 + 2) max:5' |
106 |
in:UndefinedObject |
|
2371 | 107 |
" |
108 |
||
109 |
"Modified: / 7.4.1998 / 09:57:19 / cg" |
|
110 |
"Created: / 9.4.1998 / 16:57:16 / cg" |
|
111 |
! |
|
112 |
||
4198 | 113 |
formatFileContents:aString elementsInto:elementsCollection |
114 |
"format (recolor) a file's contents. |
|
115 |
Return the text containing font changes and color information. |
|
116 |
Here, nothing is done ,just for protocol completeness" |
|
117 |
||
118 |
^ aString |
|
119 |
||
120 |
"Created: / 21-10-2017 / 13:28:35 / cg" |
|
121 |
! |
|
122 |
||
2371 | 123 |
formatMethod:aString in:aClass |
3191 | 124 |
<resource: #obsolete> |
2371 | 125 |
"format (recolor) a method in a given class. |
126 |
Return the text containing font changes and color information." |
|
127 |
||
128 |
self obsoleteMethodWarning:'use #formatMethodSource:in:'. |
|
129 |
^ self formatMethod:nil source:aString in:aClass using:nil |
|
130 |
||
131 |
" |
|
132 |
self |
|
3469 | 133 |
formatMethod:'foo |
2371 | 134 |
^ self bar:''hello''. |
135 |
||
136 |
' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , ' |
|
137 |
' |
|
3469 | 138 |
in:UndefinedObject |
2371 | 139 |
" |
140 |
||
141 |
"Modified: / 28-04-2010 / 13:03:04 / cg" |
|
142 |
! |
|
143 |
||
144 |
formatMethod:aString in:aClass using:preferencesOrNil |
|
3191 | 145 |
<resource: #obsolete> |
2371 | 146 |
"format (recolor) a method in a given class. |
147 |
Return the text containing font changes and color information." |
|
148 |
||
149 |
self obsoleteMethodWarning:'use #formatMethodSource:in:using:'. |
|
150 |
^ self formatMethod:nil source:aString in:aClass using:preferencesOrNil |
|
151 |
||
152 |
"Modified: / 28-04-2010 / 13:03:15 / cg" |
|
153 |
! |
|
154 |
||
155 |
formatMethod:methodOrNil source:aString in:aClass |
|
156 |
"format (recolor) a method in a given class. |
|
157 |
Return the text containing font changes and color information." |
|
158 |
||
159 |
^ self formatMethod:methodOrNil source:aString in:aClass using:nil |
|
160 |
||
161 |
" |
|
162 |
self |
|
3469 | 163 |
formatMethod:'foo |
2371 | 164 |
^ self bar:''hello''. |
165 |
||
166 |
' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , ' |
|
167 |
' |
|
3469 | 168 |
in:UndefinedObject |
2371 | 169 |
" |
170 |
||
171 |
"Created: / 28-04-2010 / 13:44:24 / cg" |
|
172 |
! |
|
173 |
||
174 |
formatMethod:methodOrNil source:aString in:aClass using:preferencesOrNil |
|
175 |
"format (recolor) a method in a given class. |
|
176 |
Return the text containing font changes and color information." |
|
177 |
||
3599 | 178 |
"/ cg: I smell a wumpus: I don't think, all of this must be copied to subclasses |
179 |
||
180 |
|highlighter tree newText| |
|
2371 | 181 |
|
182 |
aString isNil ifTrue:[^ nil]. |
|
183 |
||
184 |
Error handle:[:ex | |
|
3599 | 185 |
"/ Transcript showCR:ex description. |
186 |
self breakPoint:#cg. |
|
3201
13eb554c3f26
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3191
diff
changeset
|
187 |
|
3599 | 188 |
(ParseError handles:ex) ifFalse:[ |
189 |
ex creator isHandled ifTrue:[ |
|
190 |
"/ Transcript showCR:'handled' . |
|
191 |
ex reject. |
|
192 |
]. |
|
193 |
"Parse error may happen when re-formatting incomplete code while editing" |
|
194 |
('SyntaxHighlighter [info]: error during highlight: ' , ex description) infoPrintCR. |
|
195 |
"/ ex suspendedContext fullPrintAll. |
|
196 |
]. |
|
197 |
highlighter notNil ifTrue:[ |
|
198 |
^ self colorize:(newText ? aString) forErrorAtPosition:highlighter sourceStream position withOriginal:aString |
|
199 |
]. |
|
200 |
^ aString |
|
2371 | 201 |
] do:[ |
3599 | 202 |
|sourceString| |
2371 | 203 |
|
3599 | 204 |
sourceString := aString string. |
3675 | 205 |
newText := sourceString "asUnicode16String" asText. |
3599 | 206 |
"/ use an array here (instead of the RunArray) - this can be changed much faster using #at:put: |
207 |
newText emphasisCollection:(Array new:sourceString size). |
|
208 |
||
209 |
highlighter := self for:(ReadStream on:aString string) in:aClass. |
|
210 |
highlighter method:methodOrNil. |
|
211 |
preferencesOrNil notNil ifTrue:[highlighter preferences:preferencesOrNil]. |
|
212 |
"/ highlighter ignoreErrors:true. |
|
213 |
highlighter ignoreWarnings:true. |
|
214 |
highlighter sourceText:newText. |
|
2371 | 215 |
|
3599 | 216 |
tree := highlighter parseMethod. |
217 |
newText := highlighter sourceText. "/ might have changed identity |
|
218 |
"/ now, convert the emphasis-array to a runArray |
|
219 |
newText emphasisCollection:(newText emphasis asRunArray). |
|
2371 | 220 |
|
3599 | 221 |
tree == #Error ifTrue:[ |
222 |
^ self colorize:newText forErrorAtPosition:highlighter sourceStream position withOriginal:aString. |
|
223 |
]. |
|
224 |
^ newText |
|
2371 | 225 |
] |
3599 | 226 |
|
2371 | 227 |
" |
228 |
self |
|
3599 | 229 |
formatMethod:'foo |
2371 | 230 |
^ self bar:''hello''. |
231 |
||
232 |
' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , ' |
|
233 |
' |
|
3599 | 234 |
in:UndefinedObject |
2371 | 235 |
" |
236 |
||
237 |
"Created: / 28-04-2010 / 13:01:42 / cg" |
|
2527
a87cf2c8edf2
changed: #formatMethod:source:in:using:
Claus Gittinger <cg@exept.de>
parents:
2526
diff
changeset
|
238 |
"Modified: / 05-07-2011 / 11:22:20 / cg" |
2371 | 239 |
! |
240 |
||
2526
ecd1ee8f03bc
category of: #formatMethod:source:in:using:elementsInto:
Claus Gittinger <cg@exept.de>
parents:
2525
diff
changeset
|
241 |
formatMethod:aMethodOrNil source:aString in:aClass using:preferencesOrNil elementsInto: elements |
2568
44f3c6ce19f1
fixed #formatMethod:source:in:using:elementsInto:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2527
diff
changeset
|
242 |
|
44f3c6ce19f1
fixed #formatMethod:source:in:using:elementsInto:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2527
diff
changeset
|
243 |
^ self formatMethod:aMethodOrNil source:aString in:aClass using:preferencesOrNil |
2526
ecd1ee8f03bc
category of: #formatMethod:source:in:using:elementsInto:
Claus Gittinger <cg@exept.de>
parents:
2525
diff
changeset
|
244 |
|
ecd1ee8f03bc
category of: #formatMethod:source:in:using:elementsInto:
Claus Gittinger <cg@exept.de>
parents:
2525
diff
changeset
|
245 |
"Created: / 05-07-2011 / 10:41:14 / cg" |
2568
44f3c6ce19f1
fixed #formatMethod:source:in:using:elementsInto:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2527
diff
changeset
|
246 |
"Modified: / 20-07-2011 / 16:29:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2526
ecd1ee8f03bc
category of: #formatMethod:source:in:using:elementsInto:
Claus Gittinger <cg@exept.de>
parents:
2525
diff
changeset
|
247 |
! |
ecd1ee8f03bc
category of: #formatMethod:source:in:using:elementsInto:
Claus Gittinger <cg@exept.de>
parents:
2525
diff
changeset
|
248 |
|
2371 | 249 |
formatMethodSource:aString in:aClass |
250 |
"format (recolor) a method in a given class. |
|
251 |
Return the text containing font changes and color information." |
|
252 |
||
253 |
^ self formatMethod:nil source:aString in:aClass using:nil |
|
254 |
||
255 |
" |
|
256 |
self |
|
3469 | 257 |
formatMethod:'foo |
2371 | 258 |
^ self bar:''hello''. |
259 |
||
260 |
' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , ' |
|
261 |
' |
|
3469 | 262 |
in:UndefinedObject |
2371 | 263 |
" |
264 |
||
265 |
"Created: / 28-04-2010 / 12:58:13 / cg" |
|
266 |
! |
|
267 |
||
268 |
formatMethodSource:aString in:aClass using:preferencesOrNil |
|
269 |
"format (recolor) a method in a given class. |
|
270 |
Return the text containing font changes and color information." |
|
271 |
||
272 |
^ self formatMethod:nil source:aString in:aClass using:preferencesOrNil |
|
273 |
||
274 |
"Modified: / 28-04-2010 / 13:02:11 / cg" |
|
275 |
! ! |
|
276 |
||
3599 | 277 |
!AbstractSyntaxHighlighter class methodsFor:'highlighting'! |
278 |
||
279 |
colorize:text forErrorAtPosition:pos withOriginal:originalString |
|
280 |
|eColor endPos| |
|
281 |
||
282 |
endPos := pos + 1. |
|
283 |
||
284 |
"/ mhmh - which is better ... |
|
285 |
||
286 |
"/ alternative1: colorize the rest after the error in red |
|
287 |
||
288 |
eColor := UserPreferences current errorColor. |
|
289 |
eColor notNil ifTrue:[ |
|
290 |
^ text |
|
291 |
emphasizeFrom:endPos |
|
292 |
to:text size |
|
293 |
with:(#color->eColor). |
|
294 |
]. |
|
295 |
||
296 |
"/ alternative2: take the original emphasis for the rest |
|
297 |
endPos >= text size ifTrue:[ |
|
298 |
^ text |
|
299 |
] ifFalse:[ |
|
300 |
^ (text copyTo:endPos) , (originalString copyFrom:(endPos+1)) |
|
301 |
]. |
|
302 |
||
303 |
"/ alternative3: no emphasis for rest. |
|
304 |
^ text |
|
305 |
! ! |
|
306 |
||
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
307 |
!AbstractSyntaxHighlighter class methodsFor:'misc'! |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
308 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
309 |
collectionEnumerationSelectors |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
310 |
"these are considered wellknown, builtin selectors of very common |
3469 | 311 |
collection enumeration methods. |
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
312 |
These are optionally shown with another color (dark green)" |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
313 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
314 |
^ #( |
3469 | 315 |
collect: |
316 |
select: |
|
317 |
inject:into: |
|
318 |
count: |
|
319 |
collect:thenSelect: |
|
320 |
select:thenCollect: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
321 |
) |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
322 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
323 |
"Created: / 14-02-2012 / 15:56:59 / cg" |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
324 |
! |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
325 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
326 |
controlFlowSelectors |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
327 |
"these are considered wellknown, builtin selectors of very common |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
328 |
control flow constructs. Correspond to syntax or special forms in other |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
329 |
languages. These are optionally shown with another color (blue)" |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
330 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
331 |
^ #( |
3977 | 332 |
ifTrue: ifFalse: |
333 |
ifTrue:ifFalse: ifFalse:ifTrue: |
|
334 |
ifNil: ifNotNil: |
|
335 |
ifNil:ifNotNil: ifNotNil:ifNil: |
|
336 |
and: or: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
337 |
|
3977 | 338 |
whileTrue: |
339 |
whileFalse: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
340 |
|
3977 | 341 |
to:do: |
342 |
downTo:do: |
|
343 |
to:by:do: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
344 |
|
3977 | 345 |
loop |
346 |
repeat |
|
347 |
whileTrue |
|
348 |
whileFalse |
|
349 |
doWhile: |
|
350 |
doUntil: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
351 |
|
3977 | 352 |
do: |
353 |
doWithIndex: |
|
354 |
pairWiseDo: |
|
355 |
keysAndValuesDo: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
356 |
|
3977 | 357 |
withPriority:do: |
358 |
handle:do: |
|
359 |
on:do: |
|
360 |
catch: |
|
361 |
ignoreIn: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
362 |
|
3977 | 363 |
"/ newProcess |
364 |
fork: |
|
365 |
ensure: |
|
366 |
ifCurtailed: |
|
367 |
valueOnUnwindDo: |
|
368 |
valueNowOrOnUnwindDo: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
369 |
|
3977 | 370 |
caseOf: |
371 |
caseOf:otherwise: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
372 |
) |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
373 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
374 |
"Created: / 08-09-2006 / 15:56:47 / cg" |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
375 |
! |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
376 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
377 |
debugSelectors |
3235
6385bfe15842
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3231
diff
changeset
|
378 |
"these are considered harmful if left in a deployed application: |
6385bfe15842
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3231
diff
changeset
|
379 |
selectors for debugging which open a debugger (unless haltSignal is |
3469 | 380 |
caught or disabled, which end-user apps should do). |
3235
6385bfe15842
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3231
diff
changeset
|
381 |
These are optionally shown with another color (redish)" |
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
382 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
383 |
^ #( |
3469 | 384 |
halt halt: |
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
385 |
) |
3235
6385bfe15842
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3231
diff
changeset
|
386 |
|
6385bfe15842
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3231
diff
changeset
|
387 |
"Modified (comment): / 27-07-2013 / 11:45:07 / cg" |
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
388 |
! |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
389 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
390 |
errorRaisingSelectors |
3469 | 391 |
"these are error raisers. |
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
392 |
These are optionally shown with another color (red)" |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
393 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
394 |
^ #( |
3469 | 395 |
error error: |
396 |
raise raiseRequest: |
|
397 |
raiseErrorString: raiseRequestErrorString: |
|
398 |
raiseWith: raiseRequestWith: |
|
399 |
raiseWith:errorString: raiseRequestWith:errorString: |
|
400 |
subclassResponsibility |
|
401 |
obsoleteMethodWarning obsoleteMethodWarning: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
402 |
) |
3342
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
403 |
! |
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
404 |
|
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
405 |
isControlFlowSelector:aSelector |
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
406 |
"these are considered wellknown, builtin selectors of very common |
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
407 |
control flow constructs. Correspond to syntax or special forms in other |
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
408 |
languages. These are optionally shown with another color (blue)" |
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
409 |
|
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
410 |
(self controlFlowSelectors includesIdentical:aSelector) ifTrue:[^ true]. |
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
411 |
|
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
412 |
true "((aSelector startsWith:'with') or:[ aSelector startsWith:'all'])" ifTrue:[ |
3469 | 413 |
((aSelector endsWith:'do:') or:[ aSelector endsWith:'Do:']) ifTrue:[ |
414 |
^ true |
|
415 |
] |
|
3342
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
416 |
]. |
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
417 |
^ false. |
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
418 |
! ! |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
419 |
|
3732 | 420 |
!AbstractSyntaxHighlighter class methodsFor:'queries'! |
421 |
||
422 |
isAbstract |
|
423 |
^ self == AbstractSyntaxHighlighter |
|
424 |
! ! |
|
425 |
||
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
426 |
!AbstractSyntaxHighlighter class methodsFor:'utilities'! |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
427 |
|
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
428 |
mark:sourceText from:pos1 to:pos2 withAddedEmphasis:addedEmphasis |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
429 |
sourceText emphasisFrom:pos1 to:pos2 add:addedEmphasis |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
430 |
|
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
431 |
"Created: / 01-06-2012 / 21:43:36 / cg" |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
432 |
! |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
433 |
|
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
434 |
mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:clrIn |
3352
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
435 |
self mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:clrIn font:nil |
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
436 |
! |
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
437 |
|
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
438 |
mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:clrIn font:fontIn |
4202 | 439 |
"all positions are 1-based" |
440 |
||
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
441 |
|e p2 clr| |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
442 |
|
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
443 |
(clrIn isNil or:[clrIn = Color black]) ifTrue:[ |
4202 | 444 |
e := fontEmp |
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
445 |
] ifFalse:[ |
4202 | 446 |
clr := clrIn onDevice:Screen current. |
447 |
fontEmp isNil ifTrue:[ |
|
448 |
e := (#color->clr) |
|
449 |
] ifFalse:[ |
|
450 |
e := Text addEmphasis:fontEmp to:(#color->clr). |
|
451 |
] |
|
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
452 |
]. |
3352
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
453 |
fontIn notNil ifTrue:[ |
4202 | 454 |
e := Text addEmphasis:e to:(#font->fontIn) |
3352
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
455 |
]. |
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
456 |
|
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
457 |
(p2 := pos2) isNil ifTrue:[ |
4202 | 458 |
p2 := sourceText size |
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
459 |
] ifFalse:[ |
4202 | 460 |
p2 := p2 min:sourceText size |
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
461 |
]. |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
462 |
sourceText emphasizeFrom:pos1 to:p2 with:e |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
463 |
|
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
464 |
"Created: / 01-06-2012 / 21:42:41 / cg" |
4202 | 465 |
"Modified (comment): / 21-10-2017 / 14:24:20 / cg" |
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
466 |
! |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
467 |
|
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
468 |
mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
469 |
|e p2 clr fgClr| |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
470 |
|
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
471 |
fgClr := fgClr1 ? fgClr2. |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
472 |
(fgClr isNil or:[fgClr = Color black]) ifTrue:[ |
3469 | 473 |
e := fontEmp |
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
474 |
] ifFalse:[ |
3469 | 475 |
clr := fgClr onDevice:Screen current. |
476 |
fontEmp isNil ifTrue:[ |
|
477 |
e := (#color->clr) |
|
478 |
] ifFalse:[ |
|
479 |
e := Text addEmphasis:fontEmp to:(#color->clr). |
|
480 |
] |
|
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
481 |
]. |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
482 |
bgClr notNil ifTrue:[ |
3469 | 483 |
e := Text addEmphasis:(#backgroundColor->bgClr) to:e. |
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
484 |
]. |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
485 |
(p2 := pos2) isNil ifTrue:[ |
3469 | 486 |
p2 := sourceText size |
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
487 |
] ifFalse:[ |
3469 | 488 |
p2 := p2 min:sourceText size |
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
489 |
]. |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
490 |
sourceText emphasizeFrom:pos1 to:p2 with:e |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
491 |
|
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
492 |
"Created: / 01-06-2012 / 21:44:17 / cg" |
3561
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
493 |
! |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
494 |
|
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
495 |
mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp ifNil:fontEmp2 color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
496 |
|e p2 clr fgClr| |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
497 |
|
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
498 |
fgClr := fgClr1 ? fgClr2. |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
499 |
(fgClr isNil or:[fgClr = Color black]) ifTrue:[ |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
500 |
e := fontEmp ? fontEmp2 |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
501 |
] ifFalse:[ |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
502 |
clr := fgClr onDevice:Screen current. |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
503 |
(fontEmp ? fontEmp2) isNil ifTrue:[ |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
504 |
e := (#color->clr) |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
505 |
] ifFalse:[ |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
506 |
e := Text addEmphasis:(fontEmp ? fontEmp2) to:(#color->clr). |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
507 |
] |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
508 |
]. |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
509 |
bgClr notNil ifTrue:[ |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
510 |
e := Text addEmphasis:(#backgroundColor->bgClr) to:e. |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
511 |
]. |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
512 |
(p2 := pos2) isNil ifTrue:[ |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
513 |
p2 := sourceText size |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
514 |
] ifFalse:[ |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
515 |
p2 := p2 min:sourceText size |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
516 |
]. |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
517 |
sourceText emphasizeFrom:pos1 to:p2 with:e |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
518 |
|
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
519 |
"Created: / 01-06-2012 / 21:44:17 / cg" |
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
520 |
! ! |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
521 |
|
2371 | 522 |
!AbstractSyntaxHighlighter methodsFor:'accessing'! |
523 |
||
4202 | 524 |
fetchHeavilyUsedPreferenceValues |
525 |
preferences isNil ifTrue:[ |
|
526 |
commentColor := commentEmphasis := commentFont := nil. |
|
527 |
constantColor := constantEmphasis := nil. |
|
528 |
^ self. |
|
529 |
]. |
|
530 |
||
531 |
commentColor := preferences commentColor. |
|
532 |
commentEmphasis := preferences commentEmphasis. |
|
533 |
commentFont := preferences commentFont. |
|
534 |
||
535 |
constantColor := preferences constantColor. |
|
536 |
constantEmphasis := preferences constantEmphasis. |
|
537 |
||
538 |
"Created: / 21-10-2017 / 14:13:33 / cg" |
|
539 |
! |
|
540 |
||
2371 | 541 |
method:aMethod |
2525 | 542 |
"the original method, if known (for subclasses which can make use of it)" |
543 |
||
544 |
method := aMethod. |
|
2371 | 545 |
|
546 |
"Created: / 28-04-2010 / 13:15:33 / cg" |
|
547 |
! |
|
548 |
||
4202 | 549 |
preferences:aUserPreferencesInstance |
550 |
preferences := aUserPreferencesInstance. |
|
551 |
||
552 |
fullSelectorCheck := preferences fullSelectorCheck. |
|
553 |
self fetchHeavilyUsedPreferenceValues. |
|
554 |
||
555 |
"Modified: / 21-10-2017 / 14:20:06 / cg" |
|
2371 | 556 |
! |
557 |
||
558 |
sourceText |
|
3599 | 559 |
"retrieve the updated source text after the highlighting process" |
560 |
||
2371 | 561 |
^ sourceText |
562 |
||
563 |
"Created: / 31.3.1998 / 11:49:05 / cg" |
|
564 |
! |
|
565 |
||
566 |
sourceText:aString |
|
3599 | 567 |
"this text will be updated by the highlighting process" |
568 |
||
2371 | 569 |
sourceText := aString. |
570 |
||
571 |
"Created: / 31-03-1998 / 11:49:05 / cg" |
|
572 |
"Modified: / 28-04-2010 / 13:22:27 / cg" |
|
573 |
! ! |
|
574 |
||
575 |
!AbstractSyntaxHighlighter methodsFor:'error handling'! |
|
576 |
||
577 |
parseError:aMessage position:position to:endPos |
|
578 |
"/ Transcript showCR:aMessage. |
|
579 |
super parseError:aMessage position:position to:endPos. |
|
580 |
||
3469 | 581 |
self |
582 |
markFrom:position to:endPos |
|
583 |
withEmphasis:nil color:UserPreferences current errorColor |
|
2371 | 584 |
! |
585 |
||
586 |
showErrorMessage:aMessage position:pos |
|
587 |
"/ Transcript showCR:aMessage. |
|
588 |
super showErrorMessage:aMessage position:pos. |
|
589 |
||
3469 | 590 |
self |
591 |
markFrom:pos to:nil |
|
592 |
withEmphasis:nil color:UserPreferences current errorColor |
|
2371 | 593 |
! |
594 |
||
595 |
syntaxError:aMessage position:position to:endPos |
|
596 |
"/ Transcript showCR:aMessage. |
|
597 |
super syntaxError:aMessage position:position to:endPos. |
|
598 |
||
3469 | 599 |
self |
600 |
markFrom:position to:endPos |
|
601 |
withEmphasis:nil color:UserPreferences current errorColor |
|
2371 | 602 |
! |
603 |
||
604 |
warning:msg position:pos1 to:pos2 |
|
605 |
"/ self markUnknownIdentifierFrom:pos1 to:pos2 |
|
606 |
||
607 |
"/ self |
|
3469 | 608 |
"/ markFrom:pos1 to:pos2 |
2371 | 609 |
"/ withEmphasis:nil color:UserPreferences current errorColor |
610 |
||
611 |
"Modified: / 25.9.1999 / 18:42:30 / cg" |
|
612 |
! ! |
|
613 |
||
614 |
!AbstractSyntaxHighlighter methodsFor:'initialization'! |
|
615 |
||
616 |
initialize |
|
4114 | 617 |
<modifier: #super> "must be called if redefined" |
618 |
||
2371 | 619 |
super initialize. |
620 |
||
621 |
foldConstants := false. |
|
4202 | 622 |
self preferences:(UserPreferences current). |
2371 | 623 |
|
624 |
"Created: / 31-03-1998 / 15:12:55 / cg" |
|
4202 | 625 |
"Modified: / 21-10-2017 / 14:20:11 / cg" |
2371 | 626 |
! ! |
627 |
||
628 |
!AbstractSyntaxHighlighter methodsFor:'misc'! |
|
629 |
||
2817
b92ea70a5a9f
added: #collectionEnumerationSelectors
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
630 |
collectionEnumerationSelectors |
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
631 |
^ self class collectionEnumerationSelectors |
2817
b92ea70a5a9f
added: #collectionEnumerationSelectors
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
632 |
! |
b92ea70a5a9f
added: #collectionEnumerationSelectors
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
633 |
|
2371 | 634 |
controlFlowSelectors |
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
635 |
^ self class controlFlowSelectors |
2371 | 636 |
! |
637 |
||
3228
e276f545e004
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3216
diff
changeset
|
638 |
debugSelectors |
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
639 |
^ self class debugSelectors |
3228
e276f545e004
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3216
diff
changeset
|
640 |
! |
e276f545e004
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3216
diff
changeset
|
641 |
|
2371 | 642 |
defineAsUndeclaredVariable:aName |
643 |
"redefined to NOT declare undefined vars" |
|
644 |
||
645 |
^ VariableNode globalNamed:aName |
|
646 |
||
647 |
"Modified: / 19.10.1998 / 19:38:12 / cg" |
|
648 |
! |
|
649 |
||
3228
e276f545e004
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3216
diff
changeset
|
650 |
errorRaisingSelectors |
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
651 |
^ self class errorRaisingSelectors |
3228
e276f545e004
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3216
diff
changeset
|
652 |
! |
e276f545e004
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3216
diff
changeset
|
653 |
|
2371 | 654 |
isSyntaxHighlighter |
655 |
^ true |
|
656 |
||
657 |
! |
|
658 |
||
659 |
plausibilityCheck:aNode |
|
660 |
"redefined to NOT do checks" |
|
661 |
||
662 |
^ nil |
|
663 |
||
664 |
"Modified: / 19.10.1998 / 19:38:12 / cg" |
|
665 |
"Created: / 19.10.1998 / 19:57:18 / cg" |
|
666 |
! ! |
|
667 |
||
668 |
!AbstractSyntaxHighlighter methodsFor:'syntax detection'! |
|
669 |
||
4202 | 670 |
markCommentFrom:pos1 to:pos2 |
671 |
"all positions are 1-based" |
|
672 |
||
673 |
self |
|
674 |
markFrom:pos1 to:pos2 |
|
675 |
withEmphasis:commentEmphasis |
|
676 |
color:commentColor |
|
677 |
font:commentFont |
|
678 |
||
679 |
" |
|
680 |
UserPreferences current commentEmphasis |
|
681 |
UserPreferences current commentColor |
|
682 |
" |
|
683 |
||
684 |
"Modified (comment): / 21-10-2017 / 14:24:51 / cg" |
|
685 |
! |
|
686 |
||
687 |
markConstantFrom:pos1 to:pos2 |
|
688 |
self |
|
689 |
markFrom:pos1 to:pos2 |
|
690 |
withEmphasis:constantEmphasis |
|
691 |
color:constantColor |
|
692 |
||
693 |
"Created: / 31-03-1998 / 18:09:22 / cg" |
|
694 |
"Modified: / 21-10-2017 / 14:15:48 / cg" |
|
695 |
! |
|
696 |
||
697 |
markFrom:pos1 length:len withEmphasis:fontEmp color:clrIn |
|
698 |
self markFrom:pos1 to:pos1+len-1 withEmphasis:fontEmp color:clrIn |
|
699 |
||
700 |
"Created: / 21-10-2017 / 14:47:46 / cg" |
|
701 |
! |
|
702 |
||
2371 | 703 |
markFrom:pos1 to:pos2 withAddedEmphasis:addedEmphasis |
3469 | 704 |
self class |
705 |
mark:sourceText from:pos1 to:pos2 withAddedEmphasis:addedEmphasis |
|
2371 | 706 |
|
707 |
"Created: / 15-01-2008 / 11:48:18 / cg" |
|
708 |
! |
|
709 |
||
710 |
markFrom:pos1 to:pos2 withEmphasis:fontEmp color:clrIn |
|
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
711 |
self class |
3469 | 712 |
mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:clrIn |
2371 | 713 |
|
714 |
"Created: / 31-03-1998 / 13:26:53 / cg" |
|
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
715 |
"Modified: / 01-06-2012 / 21:43:04 / cg" |
2371 | 716 |
! |
717 |
||
3352
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
718 |
markFrom:pos1 to:pos2 withEmphasis:fontEmp color:clrIn font:fontInOrNil |
4202 | 719 |
"all positions are 1-based" |
720 |
||
3352
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
721 |
self class |
4202 | 722 |
mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:clrIn font:fontInOrNil |
3352
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
723 |
|
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
724 |
"Created: / 31-03-1998 / 13:26:53 / cg" |
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
725 |
"Modified: / 01-06-2012 / 21:43:04 / cg" |
4202 | 726 |
"Modified (comment): / 21-10-2017 / 14:24:47 / cg" |
3352
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
727 |
! |
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
728 |
|
2813
51e4b12f18dc
added: #markFrom:to:withEmphasis:color:ifNil:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
2688
diff
changeset
|
729 |
markFrom:pos1 to:pos2 withEmphasis:fontEmp color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr |
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
730 |
self class |
3469 | 731 |
mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr |
2813
51e4b12f18dc
added: #markFrom:to:withEmphasis:color:ifNil:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
2688
diff
changeset
|
732 |
|
51e4b12f18dc
added: #markFrom:to:withEmphasis:color:ifNil:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
2688
diff
changeset
|
733 |
"Created: / 13-02-2012 / 11:48:09 / cg" |
51e4b12f18dc
added: #markFrom:to:withEmphasis:color:ifNil:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
2688
diff
changeset
|
734 |
! |
51e4b12f18dc
added: #markFrom:to:withEmphasis:color:ifNil:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
2688
diff
changeset
|
735 |
|
3561
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
736 |
markFrom:pos1 to:pos2 withEmphasis:fontEmp ifNil:fontEmp2 color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
737 |
self class |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
738 |
mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp ifNil:fontEmp2 color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
739 |
|
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
740 |
"Created: / 13-02-2012 / 11:48:09 / cg" |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
741 |
! |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
742 |
|
2371 | 743 |
markVariable:v |
744 |
|pos endPos| |
|
745 |
||
746 |
pos := tokenPosition. |
|
747 |
endPos := pos+tokenName size-1. |
|
3189
5a4bb1727d08
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3145
diff
changeset
|
748 |
self markVariable:v from:pos to:endPos assigned:false |
2371 | 749 |
|
2464
595ec0d9efa9
comment/format in: #markVariable:
Claus Gittinger <cg@exept.de>
parents:
2392
diff
changeset
|
750 |
"Modified: / 30-11-2010 / 14:44:28 / cg" |
2371 | 751 |
! ! |
752 |
||
753 |
!AbstractSyntaxHighlighter class methodsFor:'documentation'! |
|
754 |
||
2663
e94fe6b650ad
changed: #controlFlowSelectors
Claus Gittinger <cg@exept.de>
parents:
2662
diff
changeset
|
755 |
version |
3675 | 756 |
^ '$Header$' |
2663
e94fe6b650ad
changed: #controlFlowSelectors
Claus Gittinger <cg@exept.de>
parents:
2662
diff
changeset
|
757 |
! |
e94fe6b650ad
changed: #controlFlowSelectors
Claus Gittinger <cg@exept.de>
parents:
2662
diff
changeset
|
758 |
|
2371 | 759 |
version_CVS |
3675 | 760 |
^ '$Header$' |
2506 | 761 |
! |
762 |
||
763 |
version_SVN |
|
3189
5a4bb1727d08
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3145
diff
changeset
|
764 |
^ '$ Id $' |
2371 | 765 |
! ! |
3561
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
766 |