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