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