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