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