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