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