author | Claus Gittinger <cg@exept.de> |
Sun, 17 Jun 2018 08:31:51 +0200 | |
changeset 4278 | d756ed6a7120 |
parent 4230 | da2bd8a66489 |
child 4259 | c707f9aa7015 |
child 4643 | e305b814a348 |
permissions | -rw-r--r-- |
662 | 1 |
" |
2 |
COPYRIGHT (c) 1998 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 |
" |
|
1110 | 12 |
"{ Package: 'stx:libcomp' }" |
13 |
||
3560 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
2373 | 16 |
AbstractSyntaxHighlighter subclass:#SyntaxHighlighter |
17 |
instanceVariableNames:'currentSuperclasses currentSubclasses |
|
18 |
cachedLocalIdentifierEmphasis cachedLocalIdentifierColor |
|
19 |
cachedStringEmphasis cachedStringColor' |
|
662 | 20 |
classVariableNames:'' |
21 |
poolDictionaries:'' |
|
22 |
category:'System-Compiler' |
|
23 |
! |
|
24 |
||
25 |
!SyntaxHighlighter class methodsFor:'documentation'! |
|
26 |
||
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
||
40 |
||
681 | 41 |
! |
42 |
||
43 |
documentation |
|
44 |
" |
|
45 |
colors a method. |
|
46 |
" |
|
47 |
||
48 |
||
662 | 49 |
! ! |
50 |
||
4211 | 51 |
!SyntaxHighlighter class methodsFor:'constants'! |
52 |
||
53 |
codeAspectClassDefinition |
|
54 |
^ #classDefinition |
|
55 |
||
56 |
"Created: / 27-07-2012 / 22:17:24 / cg" |
|
57 |
! |
|
58 |
||
59 |
codeAspectExpression |
|
60 |
^ #expression |
|
61 |
||
62 |
"Created: / 27-07-2012 / 22:01:26 / cg" |
|
63 |
! |
|
64 |
||
65 |
codeAspectFile |
|
66 |
^ #file |
|
67 |
||
68 |
"Created: / 21-10-2017 / 13:25:14 / cg" |
|
69 |
! |
|
70 |
||
71 |
codeAspectMethod |
|
72 |
^ #method |
|
73 |
||
74 |
"Created: / 27-07-2012 / 22:01:42 / cg" |
|
75 |
! ! |
|
76 |
||
662 | 77 |
!SyntaxHighlighter methodsFor:'initialization'! |
78 |
||
79 |
initialize |
|
4113 | 80 |
<modifier: #super> "must be called if redefined" |
81 |
||
662 | 82 |
super initialize. |
83 |
||
990
cd1aa00086fd
dont care to fold constants during syntaxHighlight
Claus Gittinger <cg@exept.de>
parents:
987
diff
changeset
|
84 |
foldConstants := false. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1553
diff
changeset
|
85 |
"/ parserFlags allowDollarInIdentifier:true. |
990
cd1aa00086fd
dont care to fold constants during syntaxHighlight
Claus Gittinger <cg@exept.de>
parents:
987
diff
changeset
|
86 |
|
4203 | 87 |
self preferences:(UserPreferences current). |
1526 | 88 |
fullSelectorCheck := preferences fullSelectorCheck. |
662 | 89 |
|
4113 | 90 |
"Created: / 31-03-1998 / 15:12:55 / cg" |
4203 | 91 |
"Modified: / 21-10-2017 / 14:20:27 / cg" |
662 | 92 |
! ! |
93 |
||
94 |
!SyntaxHighlighter methodsFor:'syntax detection'! |
|
95 |
||
96 |
markArgumentIdentifierFrom:pos1 to:pos2 |
|
97 |
self |
|
98 |
markFrom:pos1 to:pos2 |
|
1553 | 99 |
withEmphasis:(preferences argumentIdentifierEmphasis) |
100 |
color:(preferences argumentIdentifierColor) |
|
662 | 101 |
|
102 |
"Modified: / 31.3.1998 / 18:01:27 / cg" |
|
103 |
! |
|
104 |
||
2811 | 105 |
markAssignedClassVariableIdentifierFrom:pos1 to:pos2 |
106 |
self |
|
107 |
markFrom:pos1 to:pos2 |
|
3560 | 108 |
withEmphasis:(preferences sideEffectAssignmentEmphasis) ifNil:(preferences classVariableIdentifierEmphasis) |
109 |
color:(preferences sideEffectAssignmentColor) ifNil:(preferences classVariableIdentifierColor) |
|
2811 | 110 |
backgroundColor:(preferences sideEffectAssignmentBackgroundColor) |
111 |
||
112 |
"Created: / 13-02-2012 / 11:49:59 / cg" |
|
113 |
! |
|
114 |
||
115 |
markAssignedGlobalIdentifierFrom:pos1 to:pos2 |
|
116 |
self |
|
117 |
markFrom:pos1 to:pos2 |
|
3560 | 118 |
withEmphasis:(preferences sideEffectAssignmentEmphasis) ifNil:(preferences globalIdentifierEmphasis) |
119 |
color:(preferences sideEffectAssignmentColor) ifNil:(preferences globalIdentifierColor) |
|
2811 | 120 |
backgroundColor:(preferences sideEffectAssignmentBackgroundColor) |
121 |
||
122 |
"Modified: / 31-03-1998 / 18:02:14 / cg" |
|
123 |
"Created: / 13-02-2012 / 11:44:33 / cg" |
|
124 |
! |
|
125 |
||
2997 | 126 |
markAssignedIdentifierFrom:pos1 to:pos2 |
127 |
"any other identifier (PrivateClass, Workspace, Doit, etc.)" |
|
128 |
||
129 |
self markAssignedGlobalIdentifierFrom:pos1 to:pos2 |
|
130 |
! |
|
131 |
||
2811 | 132 |
markAssignedInstVarIdentifierFrom:pos1 to:pos2 |
133 |
self |
|
134 |
markFrom:pos1 to:pos2 |
|
3560 | 135 |
withEmphasis:(preferences sideEffectAssignmentEmphasis) ifNil:(preferences instVarIdentifierEmphasis) |
136 |
color:(preferences sideEffectAssignmentColor) ifNil:(preferences instVarIdentifierColor) |
|
2811 | 137 |
backgroundColor:(preferences sideEffectAssignmentBackgroundColor) |
138 |
||
139 |
"Created: / 13-02-2012 / 11:50:19 / cg" |
|
140 |
! |
|
141 |
||
142 |
markAssignedPoolVariableIdentifierFrom:pos1 to:pos2 |
|
143 |
self |
|
144 |
markFrom:pos1 to:pos2 |
|
3560 | 145 |
withEmphasis:(preferences sideEffectAssignmentEmphasis) ifNil:(preferences poolVariableIdentifierEmphasis) |
146 |
color:(preferences sideEffectAssignmentColor) ifNil:(preferences poolVariableIdentifierColor) |
|
2811 | 147 |
backgroundColor:(preferences sideEffectAssignmentBackgroundColor) |
148 |
||
149 |
"Created: / 13-02-2012 / 11:49:14 / cg" |
|
150 |
! |
|
151 |
||
152 |
markAssignedVariable:v from:pos to:endPos |
|
153 |
"support for syntaxColoring" |
|
154 |
||
155 |
|type| |
|
156 |
||
157 |
type := v type. |
|
158 |
(type == #BlockArg |
|
159 |
or:[ type == #MethodArg |
|
160 |
or:[ type == #BlockVariable |
|
161 |
or:[ type == #MethodVariable]]]) ifTrue:[ |
|
3187 | 162 |
self markVariable:v from:pos to:endPos assigned:true. |
2811 | 163 |
^ self |
164 |
]. |
|
165 |
(type == #GlobalVariable) ifTrue:[ |
|
166 |
self markAssignedGlobalIdentifierFrom:pos to:endPos. |
|
167 |
^ self |
|
168 |
]. |
|
169 |
(type == #PoolVariable) ifTrue:[ |
|
170 |
self markAssignedPoolVariableIdentifierFrom:pos to:endPos. |
|
171 |
^ self |
|
172 |
]. |
|
173 |
(type == #ClassVariable) ifTrue:[ |
|
174 |
self markAssignedClassVariableIdentifierFrom:pos to:endPos. |
|
175 |
^ self |
|
176 |
]. |
|
177 |
(type == #InstanceVariable) ifTrue:[ |
|
178 |
self markAssignedInstVarIdentifierFrom:pos to:endPos. |
|
179 |
^ self |
|
180 |
]. |
|
181 |
||
182 |
self markAssignedIdentifierFrom:pos to:endPos. |
|
183 |
||
184 |
"Created: / 13-02-2012 / 11:42:23 / cg" |
|
185 |
! |
|
186 |
||
884 | 187 |
markBadIdentifierFrom:pos1 to:pos2 |
188 |
self |
|
189 |
markFrom:pos1 to:pos2 |
|
1553 | 190 |
withEmphasis:(preferences badIdentifierEmphasis) |
191 |
color:(preferences badIdentifierColor) |
|
884 | 192 |
! |
193 |
||
2055 | 194 |
markBlockFrom:pos1 to:pos2 |
2228 | 195 |
"an experiment (which does not look too good, after all): |
196 |
the deeper the nesting of the block, the darker the background color." |
|
197 |
||
2055 | 198 |
"/ |level color| |
199 |
"/ |
|
200 |
"/ level := currentBlock isNil ifTrue:[1] ifFalse:[currentBlock nestingLevel+1]. |
|
2228 | 201 |
"/ level > 5 ifTrue:[ |
202 |
"/ color := Color yellow darkened. |
|
203 |
"/ ] ifFalse:[ |
|
204 |
"/ color := { |
|
205 |
"/ Color yellow lightened lightened. |
|
206 |
"/ Color yellow lightened . |
|
207 |
"/ Color yellow . |
|
208 |
"/ Color yellow slightlyDarkened . |
|
209 |
"/ Color yellow darkened . |
|
210 |
"/ } at:level. |
|
211 |
"/ ]. |
|
2055 | 212 |
"/ self |
213 |
"/ markFrom:pos1 to:pos2 |
|
2228 | 214 |
"/ withAddedEmphasis:(#backgroundColor->color). |
2055 | 215 |
! |
216 |
||
662 | 217 |
markBooleanConstantFrom:pos1 to:pos2 |
218 |
self |
|
219 |
markFrom:pos1 to:pos2 |
|
1553 | 220 |
withEmphasis:(preferences booleanConstantEmphasis) |
221 |
color:(preferences booleanConstantColor) |
|
662 | 222 |
|
223 |
"Created: / 31.3.1998 / 18:09:01 / cg" |
|
665 | 224 |
"Modified: / 31.3.1998 / 19:36:44 / cg" |
662 | 225 |
! |
226 |
||
673 | 227 |
markBracketAt:pos |
2070 | 228 |
|level colors clr em| |
229 |
||
230 |
preferences emphasizeParenthesisLevel ifFalse:[ |
|
231 |
self |
|
232 |
markFrom:pos to:pos |
|
233 |
withEmphasis:(preferences bracketEmphasis) |
|
234 |
color:(preferences bracketColor). |
|
235 |
||
236 |
^ self |
|
237 |
]. |
|
238 |
||
239 |
level := currentBlock isNil ifTrue:[1] ifFalse:[currentBlock nestingLevel + 2]. |
|
240 |
(sourceText at:pos) = $] ifTrue:[ |
|
241 |
level := level - 1. |
|
242 |
]. |
|
243 |
||
244 |
colors := Array |
|
245 |
with:(Color black) |
|
246 |
with:(Color blue) |
|
247 |
with:(Color green blendWith:(Color grey:30)) |
|
248 |
with:(Color red blendWith:(Color grey:30)) |
|
249 |
with:(Color yellow darkened). |
|
250 |
||
251 |
clr := colors at:((level-1) \\ colors size + 1). |
|
252 |
em := #normal. |
|
253 |
level > 1 ifTrue:[ |
|
254 |
em := #bold. |
|
255 |
]. |
|
673 | 256 |
self |
257 |
markFrom:pos to:pos |
|
2070 | 258 |
withEmphasis:em |
259 |
color:clr |
|
673 | 260 |
! |
261 |
||
870 | 262 |
markClassVariableIdentifierFrom:pos1 to:pos2 |
263 |
self |
|
264 |
markFrom:pos1 to:pos2 |
|
1553 | 265 |
withEmphasis:(preferences classVariableIdentifierEmphasis) |
266 |
color:(preferences classVariableIdentifierColor) |
|
870 | 267 |
|
268 |
"Modified: / 31.3.1998 / 18:02:14 / cg" |
|
269 |
! |
|
270 |
||
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
271 |
markGlobalClassIdentifierFrom:pos1 to:pos2 |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
272 |
self |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
273 |
markFrom:pos1 to:pos2 |
1553 | 274 |
withEmphasis:(preferences globalClassIdentifierEmphasis) |
275 |
color:(preferences globalClassIdentifierColor) |
|
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
276 |
|
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
277 |
"Modified: / 31.3.1998 / 18:02:14 / cg" |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
278 |
"Created: / 4.3.1999 / 12:53:02 / cg" |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
279 |
! |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
280 |
|
662 | 281 |
markGlobalIdentifierFrom:pos1 to:pos2 |
282 |
self |
|
283 |
markFrom:pos1 to:pos2 |
|
1553 | 284 |
withEmphasis:(preferences globalIdentifierEmphasis) |
285 |
color:(preferences globalIdentifierColor) |
|
662 | 286 |
|
287 |
"Modified: / 31.3.1998 / 18:02:14 / cg" |
|
288 |
! |
|
289 |
||
290 |
markHereFrom:pos1 to:pos2 |
|
291 |
self |
|
292 |
markFrom:pos1 to:pos2 |
|
1553 | 293 |
withEmphasis:(preferences hereEmphasis) |
294 |
color:(preferences hereColor) |
|
662 | 295 |
|
296 |
"Modified: / 31.3.1998 / 18:02:25 / cg" |
|
297 |
! |
|
298 |
||
299 |
markIdentifierFrom:pos1 to:pos2 |
|
300 |
self |
|
301 |
markFrom:pos1 to:pos2 |
|
1553 | 302 |
withEmphasis:(preferences identifierEmphasis) |
303 |
color:(preferences identifierColor) |
|
662 | 304 |
|
305 |
"Modified: / 31.3.1998 / 18:02:39 / cg" |
|
306 |
"Created: / 31.3.1998 / 18:04:56 / cg" |
|
307 |
! |
|
308 |
||
686 | 309 |
markInstVarIdentifierFrom:pos1 to:pos2 |
310 |
self |
|
311 |
markFrom:pos1 to:pos2 |
|
1553 | 312 |
withEmphasis:(preferences instVarIdentifierEmphasis) |
313 |
color:(preferences instVarIdentifierColor) |
|
686 | 314 |
|
315 |
"Created: / 16.4.1998 / 18:35:40 / cg" |
|
316 |
"Modified: / 16.4.1998 / 18:37:30 / cg" |
|
317 |
! |
|
318 |
||
662 | 319 |
markLocalIdentifierFrom:pos1 to:pos2 |
1802 | 320 |
cachedLocalIdentifierEmphasis isNil ifTrue:[ |
321 |
cachedLocalIdentifierEmphasis := preferences localIdentifierEmphasis. |
|
322 |
cachedLocalIdentifierColor := preferences localIdentifierColor. |
|
323 |
]. |
|
662 | 324 |
self |
325 |
markFrom:pos1 to:pos2 |
|
1802 | 326 |
withEmphasis:cachedLocalIdentifierEmphasis |
327 |
color:cachedLocalIdentifierColor |
|
662 | 328 |
|
329 |
"Modified: / 31.3.1998 / 18:02:39 / cg" |
|
330 |
! |
|
331 |
||
332 |
markMethodSelectorFrom:pos1 to:pos2 |
|
333 |
self |
|
334 |
markFrom:pos1 to:pos2 |
|
1553 | 335 |
withEmphasis:(preferences methodSelectorEmphasis) |
336 |
color:(preferences methodSelectorColor) |
|
662 | 337 |
|
338 |
"Modified: / 31.3.1998 / 18:02:52 / cg" |
|
339 |
! |
|
340 |
||
1684 | 341 |
markNumberConstantFrom:pos1 to:pos2 |
342 |
self |
|
343 |
markFrom:pos1 to:pos2 |
|
344 |
withEmphasis:(preferences numberConstantEmphasis) |
|
345 |
color:(preferences numberConstantColor) |
|
346 |
||
347 |
"Modified: / 31.3.1998 / 18:01:44 / cg" |
|
348 |
"Created: / 31.3.1998 / 18:09:22 / cg" |
|
349 |
! |
|
350 |
||
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
351 |
markParenthesisAt:pos |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
352 |
|colors clr em| |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
353 |
|
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
354 |
preferences emphasizeParenthesisLevel ifFalse:[^ self]. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
355 |
|
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
356 |
colors := Array |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
357 |
with:(Color black) |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
358 |
with:(Color blue) |
1757 | 359 |
with:(Color green blendWith:(Color grey:30)) |
360 |
with:(Color red blendWith:(Color grey:30)) |
|
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
361 |
with:(Color yellow darkened). |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
362 |
|
1757 | 363 |
clr := colors at:((parenthesisLevel-1) \\ colors size + 1). |
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
364 |
em := #normal. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
365 |
parenthesisLevel > 1 ifTrue:[ |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
366 |
em := #bold. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
367 |
]. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
368 |
self |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
369 |
markFrom:pos to:pos |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
370 |
withEmphasis:em |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
371 |
color:clr |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
372 |
! |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
373 |
|
1553 | 374 |
markPoolVariableIdentifierFrom:pos1 to:pos2 |
375 |
self |
|
376 |
markFrom:pos1 to:pos2 |
|
377 |
withEmphasis:(preferences poolVariableIdentifierEmphasis) |
|
378 |
color:(preferences poolVariableIdentifierColor) |
|
379 |
! |
|
380 |
||
838 | 381 |
markReturnAt:pos |
3598 | 382 |
"/ sourceText := (sourceText copyTo:pos-1),(Character value:16r21e7),(sourceText copyFrom:pos+1). |
838 | 383 |
self |
384 |
markFrom:pos to:pos |
|
1553 | 385 |
withEmphasis:(preferences returnEmphasis) |
386 |
color:(preferences returnColor) |
|
838 | 387 |
|
388 |
"Modified: / 31.3.1998 / 19:36:44 / cg" |
|
389 |
"Created: / 5.1.1980 / 00:44:27 / cg" |
|
390 |
! |
|
391 |
||
863 | 392 |
markSelector:selectorString from:pos1 to:pos2 receiverNode:aReceiverNode |
1498
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
393 |
|fg selectorSymbol check ok rec em| |
863 | 394 |
|
395 |
"/ uncommenting the code below |
|
396 |
"/ will suppress highlighting of common selectors ... |
|
397 |
"/ |
|
398 |
"/ (#( |
|
399 |
"/ 'ifTrue:' |
|
400 |
"/ 'ifFalse:' |
|
401 |
"/ 'not' |
|
402 |
"/ 'and:' |
|
403 |
"/ 'or:' |
|
404 |
"/ '=' |
|
405 |
"/ '==' |
|
406 |
"/ '~=' |
|
407 |
"/ '~~' |
|
408 |
"/ ) includes:sel) ifTrue:[ |
|
409 |
"/ ^ self |
|
410 |
"/ ]. |
|
411 |
||
1526 | 412 |
fg := preferences selectorColor. |
413 |
em := preferences selectorEmphasis. |
|
1498
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
414 |
selectorSymbol := selectorString asSymbolIfInterned. |
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
415 |
selectorSymbol isNil ifTrue:[ |
1905 | 416 |
em := preferences unimplementedSelectorEmphasis. |
417 |
fg := preferences unimplementedSelectorColor. |
|
1498
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
418 |
] ifFalse:[ |
1905 | 419 |
ok := true. |
420 |
||
863 | 421 |
fullSelectorCheck == true ifTrue:[ |
422 |
||
1498
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
423 |
check := [:cls | (cls includesSelector:selectorSymbol) |
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
424 |
or:[cls class includesSelector:selectorSymbol]]. |
863 | 425 |
|
426 |
ok := false. |
|
427 |
||
428 |
"/ limit search if possible |
|
429 |
(classToCompileFor notNil |
|
430 |
and:[aReceiverNode isSelf or:[aReceiverNode isSuper]]) ifTrue:[ |
|
431 |
currentSuperclasses isNil ifTrue:[ |
|
432 |
currentSuperclasses := classToCompileFor withAllSuperclasses. |
|
433 |
]. |
|
434 |
ok := currentSuperclasses contains:check. |
|
435 |
(ok not and:[aReceiverNode isSelf]) ifTrue:[ |
|
436 |
currentSubclasses isNil ifTrue:[ |
|
437 |
currentSubclasses := classToCompileFor allSubclasses. |
|
438 |
]. |
|
439 |
ok := currentSubclasses contains:check. |
|
440 |
]. |
|
441 |
] ifFalse:[ |
|
3816 | 442 |
aReceiverNode isLiteral ifTrue:[ |
863 | 443 |
ok := aReceiverNode evaluate class withAllSuperclasses contains:check. |
444 |
] ifFalse:[ |
|
445 |
(aReceiverNode isGlobal |
|
446 |
and:[(rec := aReceiverNode evaluate) isBehavior]) ifTrue:[ |
|
447 |
ok := rec class withAllSuperclasses contains:check. |
|
448 |
] ifFalse:[ |
|
449 |
ok := Smalltalk allClasses contains:check |
|
450 |
] |
|
451 |
] |
|
452 |
]. |
|
1905 | 453 |
]. |
3232 | 454 |
|
1905 | 455 |
ok ifFalse:[ |
456 |
em := preferences unimplementedSelectorEmphasis. |
|
457 |
fg := preferences unimplementedSelectorColor. |
|
458 |
] ifTrue:[ |
|
3343 | 459 |
(self class isControlFlowSelector:selectorSymbol) ifTrue:[ |
1905 | 460 |
em := preferences controlFlowSelectorEmphasis. |
2816
e8b84f6d7462
changed: #markSelector:from:to:receiverNode:
Claus Gittinger <cg@exept.de>
parents:
2811
diff
changeset
|
461 |
fg := preferences controlFlowSelectorColor |
e8b84f6d7462
changed: #markSelector:from:to:receiverNode:
Claus Gittinger <cg@exept.de>
parents:
2811
diff
changeset
|
462 |
] ifFalse:[ |
e8b84f6d7462
changed: #markSelector:from:to:receiverNode:
Claus Gittinger <cg@exept.de>
parents:
2811
diff
changeset
|
463 |
(self collectionEnumerationSelectors includesIdentical:selectorSymbol) ifTrue:[ |
e8b84f6d7462
changed: #markSelector:from:to:receiverNode:
Claus Gittinger <cg@exept.de>
parents:
2811
diff
changeset
|
464 |
em := preferences collectionEnumerationSelectorEmphasis. |
e8b84f6d7462
changed: #markSelector:from:to:receiverNode:
Claus Gittinger <cg@exept.de>
parents:
2811
diff
changeset
|
465 |
fg := preferences collectionEnumerationSelectorColor |
3229 | 466 |
] ifFalse:[ |
467 |
(self debugSelectors includesIdentical:selectorSymbol) ifTrue:[ |
|
468 |
em := preferences debugSelectorEmphasis. |
|
469 |
fg := preferences debugSelectorColor |
|
470 |
] ifFalse:[ |
|
471 |
(self errorRaisingSelectors includesIdentical:selectorSymbol) ifTrue:[ |
|
472 |
em := preferences errorRaisingSelectorEmphasis. |
|
473 |
fg := preferences errorRaisingSelectorColor |
|
474 |
]. |
|
475 |
]. |
|
2816
e8b84f6d7462
changed: #markSelector:from:to:receiverNode:
Claus Gittinger <cg@exept.de>
parents:
2811
diff
changeset
|
476 |
]. |
e8b84f6d7462
changed: #markSelector:from:to:receiverNode:
Claus Gittinger <cg@exept.de>
parents:
2811
diff
changeset
|
477 |
]. |
e8b84f6d7462
changed: #markSelector:from:to:receiverNode:
Claus Gittinger <cg@exept.de>
parents:
2811
diff
changeset
|
478 |
em isNil ifTrue:[ |
e8b84f6d7462
changed: #markSelector:from:to:receiverNode:
Claus Gittinger <cg@exept.de>
parents:
2811
diff
changeset
|
479 |
em := preferences selectorEmphasis |
e8b84f6d7462
changed: #markSelector:from:to:receiverNode:
Claus Gittinger <cg@exept.de>
parents:
2811
diff
changeset
|
480 |
]. |
e8b84f6d7462
changed: #markSelector:from:to:receiverNode:
Claus Gittinger <cg@exept.de>
parents:
2811
diff
changeset
|
481 |
fg isNil ifTrue:[ |
e8b84f6d7462
changed: #markSelector:from:to:receiverNode:
Claus Gittinger <cg@exept.de>
parents:
2811
diff
changeset
|
482 |
fg := preferences selectorColor |
1905 | 483 |
]. |
484 |
]. |
|
863 | 485 |
]. |
486 |
self |
|
487 |
markFrom:pos1 to:pos2 |
|
1553 | 488 |
withEmphasis:em |
489 |
color:fg |
|
863 | 490 |
|
2816
e8b84f6d7462
changed: #markSelector:from:to:receiverNode:
Claus Gittinger <cg@exept.de>
parents:
2811
diff
changeset
|
491 |
"Modified: / 14-02-2012 / 16:03:52 / cg" |
863 | 492 |
! |
493 |
||
662 | 494 |
markSelfFrom:pos1 to:pos2 |
495 |
self |
|
496 |
markFrom:pos1 to:pos2 |
|
1553 | 497 |
withEmphasis:(preferences selfEmphasis) |
498 |
color:(preferences selfColor) |
|
662 | 499 |
|
500 |
"Modified: / 31.3.1998 / 18:03:10 / cg" |
|
501 |
! |
|
502 |
||
503 |
markStringFrom:pos1 to:pos2 |
|
1802 | 504 |
cachedStringEmphasis isNil ifTrue:[ |
505 |
cachedStringEmphasis := preferences stringEmphasis. |
|
506 |
cachedStringColor := preferences stringColor. |
|
507 |
]. |
|
662 | 508 |
self |
509 |
markFrom:pos1 to:pos2 |
|
1802 | 510 |
withEmphasis:cachedStringEmphasis |
511 |
color:cachedStringColor |
|
662 | 512 |
|
513 |
"Modified: / 31.3.1998 / 18:03:18 / cg" |
|
514 |
! |
|
515 |
||
516 |
markSuperFrom:pos1 to:pos2 |
|
517 |
self |
|
518 |
markFrom:pos1 to:pos2 |
|
1553 | 519 |
withEmphasis:(preferences superEmphasis) |
520 |
color:(preferences superColor) |
|
662 | 521 |
|
522 |
"Modified: / 31.3.1998 / 18:03:26 / cg" |
|
523 |
! |
|
524 |
||
672 | 525 |
markSymbolFrom:pos1 to:pos2 |
526 |
self |
|
527 |
markFrom:pos1 to:pos2 |
|
1553 | 528 |
withEmphasis:(preferences symbolEmphasis) |
529 |
color:(preferences symbolColor) |
|
672 | 530 |
|
531 |
"Created: / 1.4.1998 / 12:56:47 / cg" |
|
532 |
"Modified: / 1.4.1998 / 12:58:00 / cg" |
|
533 |
! |
|
534 |
||
662 | 535 |
markThisContextFrom:pos1 to:pos2 |
536 |
self |
|
537 |
markFrom:pos1 to:pos2 |
|
1553 | 538 |
withEmphasis:(preferences thisContextEmphasis) |
539 |
color:(preferences thisContextColor) |
|
662 | 540 |
|
541 |
"Modified: / 31.3.1998 / 18:03:36 / cg" |
|
665 | 542 |
! |
543 |
||
544 |
markUnknownIdentifierFrom:pos1 to:pos2 |
|
545 |
self |
|
546 |
markFrom:pos1 to:pos2 |
|
1553 | 547 |
withEmphasis:(preferences unknownIdentifierEmphasis) |
548 |
color:(preferences unknownIdentifierColor) |
|
665 | 549 |
|
550 |
"Created: / 31.3.1998 / 19:09:26 / cg" |
|
551 |
"Modified: / 31.3.1998 / 19:10:30 / cg" |
|
686 | 552 |
! |
553 |
||
3187 | 554 |
markVariable:v from:pos to:endPos assigned:assigned |
686 | 555 |
"support for syntaxColoring" |
556 |
||
823 | 557 |
|type globalValue nameSym| |
686 | 558 |
|
559 |
type := v type. |
|
560 |
(type == #BlockArg |
|
561 |
or:[type == #MethodArg]) ifTrue:[ |
|
562 |
self markArgumentIdentifierFrom:pos to:endPos. |
|
563 |
^ self |
|
564 |
]. |
|
565 |
(type == #BlockVariable |
|
566 |
or:[type == #MethodVariable]) ifTrue:[ |
|
567 |
self markLocalIdentifierFrom:pos to:endPos. |
|
568 |
^ self |
|
569 |
]. |
|
570 |
(type == #GlobalVariable) ifTrue:[ |
|
823 | 571 |
nameSym := v name asSymbolIfInterned. |
572 |
nameSym notNil ifTrue:[ |
|
573 |
globalValue := Smalltalk at:nameSym ifAbsent:nil. |
|
574 |
]. |
|
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
575 |
globalValue isBehavior ifTrue:[ |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
576 |
self markGlobalClassIdentifierFrom:pos to:endPos. |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
577 |
] ifFalse:[ |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
578 |
self markGlobalIdentifierFrom:pos to:endPos. |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
579 |
]. |
686 | 580 |
^ self |
581 |
]. |
|
1553 | 582 |
(type == #PoolVariable) ifTrue:[ |
583 |
self markPoolVariableIdentifierFrom:pos to:endPos. |
|
584 |
^ self |
|
585 |
]. |
|
870 | 586 |
(type == #ClassVariable) ifTrue:[ |
587 |
self markClassVariableIdentifierFrom:pos to:endPos. |
|
588 |
^ self |
|
589 |
]. |
|
686 | 590 |
(type == #InstanceVariable) ifTrue:[ |
591 |
self markInstVarIdentifierFrom:pos to:endPos. |
|
592 |
^ self |
|
593 |
]. |
|
594 |
||
595 |
self markIdentifierFrom:pos to:endPos. |
|
596 |
||
597 |
"Created: / 16.4.1998 / 18:49:34 / cg" |
|
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
598 |
"Modified: / 4.3.1999 / 12:56:13 / cg" |
662 | 599 |
! ! |
600 |
||
601 |
!SyntaxHighlighter class methodsFor:'documentation'! |
|
602 |
||
603 |
version |
|
3816 | 604 |
^ '$Header$' |
2228 | 605 |
! |
606 |
||
607 |
version_CVS |
|
3816 | 608 |
^ '$Header$' |
662 | 609 |
! ! |
2997 | 610 |