author | Claus Gittinger <cg@exept.de> |
Sun, 29 Jan 2017 12:55:36 +0100 | |
changeset 4103 | 2536fe3291dd |
parent 3977 | 39fe23d7db13 |
child 3980 | dbd096a81e74 |
child 4114 | a68e6f98cb02 |
permissions | -rw-r--r-- |
3977 | 1 |
"{ Encoding: utf8 }" |
2 |
||
2506 | 3 |
" |
4 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
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 |
" |
|
2371 | 14 |
"{ Package: 'stx:libcomp' }" |
15 |
||
3561
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
16 |
"{ NameSpace: Smalltalk }" |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
17 |
|
2371 | 18 |
Parser subclass:#AbstractSyntaxHighlighter |
2525 | 19 |
instanceVariableNames:'method sourceText preferences fullSelectorCheck' |
2371 | 20 |
classVariableNames:'' |
21 |
poolDictionaries:'' |
|
22 |
category:'System-Compiler' |
|
23 |
! |
|
24 |
||
2506 | 25 |
!AbstractSyntaxHighlighter class methodsFor:'documentation'! |
26 |
||
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 2006 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 |
" |
|
3345
718b64ff3db3
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3344
diff
changeset
|
39 |
! |
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 |
documentation |
718b64ff3db3
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3344
diff
changeset
|
42 |
" |
718b64ff3db3
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3344
diff
changeset
|
43 |
common superclass for (smalltalk-) syntax highlighting. |
3599 | 44 |
|
45 |
This will parse the source code and update the local copy of the |
|
46 |
sourceText (in that instvar) by changing emphasis and color, |
|
47 |
as syntax elements are encountered. |
|
48 |
This is done by redefining appropriate markXXX methods, which are |
|
49 |
called by the parser whenever an interesting syntactic construct is encountered. |
|
50 |
These methods are no-ops in the Parser class, but redefined here to update |
|
51 |
the colorization of sourceText. |
|
3345
718b64ff3db3
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3344
diff
changeset
|
52 |
" |
2506 | 53 |
! ! |
2371 | 54 |
|
55 |
!AbstractSyntaxHighlighter class methodsFor:'api highlighting'! |
|
56 |
||
57 |
formatClassDefinition:aString in:aClass |
|
58 |
"format (recolor) a class definition expression in a given class. |
|
59 |
Return the text containing font changes and color information." |
|
60 |
||
61 |
^ self formatExpression:aString in:aClass |
|
62 |
! |
|
63 |
||
2506 | 64 |
formatClassDefinition:aString in:aClass elementsInto: elements |
65 |
"format (recolor) a class definition expression in a given class. |
|
66 |
Return the text containing font changes and color information." |
|
67 |
||
68 |
^ self formatExpression:aString in:aClass |
|
69 |
||
70 |
"Created: / 10-04-2011 / 18:18:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
71 |
! |
|
72 |
||
2371 | 73 |
formatExpression:aString in:aClass |
74 |
"format (recolor) an expression in a given class. |
|
75 |
Return the text containing font changes and color information." |
|
76 |
||
3599 | 77 |
|parser tree text| |
2371 | 78 |
|
79 |
aString isNil ifTrue:[^ nil]. |
|
80 |
||
81 |
parser := self for:(ReadStream on:aString string) in:aClass. |
|
82 |
parser ignoreErrors:true. |
|
83 |
parser ignoreWarnings:true. |
|
84 |
parser sourceText:(text := aString string asText). |
|
85 |
"/ use an array here - this can be changed much faster using #at:put: |
|
86 |
text emphasisCollection:(Array new:aString size). |
|
87 |
||
88 |
parser nextToken. |
|
89 |
tree := parser expression. |
|
90 |
"/ now, convert the emphasis-array to a runArray |
|
91 |
text emphasisCollection:(text emphasis asRunArray). |
|
92 |
||
93 |
tree == #Error ifTrue:[ |
|
3599 | 94 |
^ self colorize:text forErrorAtPosition:parser sourceStream position withOriginal:aString. |
2371 | 95 |
]. |
96 |
^ text |
|
97 |
||
98 |
" |
|
99 |
self |
|
3599 | 100 |
formatExpression:'(1 + 2) max:5' |
101 |
in:UndefinedObject |
|
2371 | 102 |
" |
103 |
||
104 |
"Modified: / 7.4.1998 / 09:57:19 / cg" |
|
105 |
"Created: / 9.4.1998 / 16:57:16 / cg" |
|
106 |
! |
|
107 |
||
108 |
formatMethod:aString in:aClass |
|
3191 | 109 |
<resource: #obsolete> |
2371 | 110 |
"format (recolor) a method in a given class. |
111 |
Return the text containing font changes and color information." |
|
112 |
||
113 |
self obsoleteMethodWarning:'use #formatMethodSource:in:'. |
|
114 |
^ self formatMethod:nil source:aString in:aClass using:nil |
|
115 |
||
116 |
" |
|
117 |
self |
|
3469 | 118 |
formatMethod:'foo |
2371 | 119 |
^ self bar:''hello''. |
120 |
||
121 |
' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , ' |
|
122 |
' |
|
3469 | 123 |
in:UndefinedObject |
2371 | 124 |
" |
125 |
||
126 |
"Modified: / 28-04-2010 / 13:03:04 / cg" |
|
127 |
! |
|
128 |
||
129 |
formatMethod:aString in:aClass using:preferencesOrNil |
|
3191 | 130 |
<resource: #obsolete> |
2371 | 131 |
"format (recolor) a method in a given class. |
132 |
Return the text containing font changes and color information." |
|
133 |
||
134 |
self obsoleteMethodWarning:'use #formatMethodSource:in:using:'. |
|
135 |
^ self formatMethod:nil source:aString in:aClass using:preferencesOrNil |
|
136 |
||
137 |
"Modified: / 28-04-2010 / 13:03:15 / cg" |
|
138 |
! |
|
139 |
||
140 |
formatMethod:methodOrNil source:aString in:aClass |
|
141 |
"format (recolor) a method in a given class. |
|
142 |
Return the text containing font changes and color information." |
|
143 |
||
144 |
^ self formatMethod:methodOrNil source:aString in:aClass using:nil |
|
145 |
||
146 |
" |
|
147 |
self |
|
3469 | 148 |
formatMethod:'foo |
2371 | 149 |
^ self bar:''hello''. |
150 |
||
151 |
' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , ' |
|
152 |
' |
|
3469 | 153 |
in:UndefinedObject |
2371 | 154 |
" |
155 |
||
156 |
"Created: / 28-04-2010 / 13:44:24 / cg" |
|
157 |
! |
|
158 |
||
159 |
formatMethod:methodOrNil source:aString in:aClass using:preferencesOrNil |
|
160 |
"format (recolor) a method in a given class. |
|
161 |
Return the text containing font changes and color information." |
|
162 |
||
3599 | 163 |
"/ cg: I smell a wumpus: I don't think, all of this must be copied to subclasses |
164 |
||
165 |
|highlighter tree newText| |
|
2371 | 166 |
|
167 |
aString isNil ifTrue:[^ nil]. |
|
168 |
||
169 |
Error handle:[:ex | |
|
3599 | 170 |
"/ Transcript showCR:ex description. |
171 |
self breakPoint:#cg. |
|
3201
13eb554c3f26
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3191
diff
changeset
|
172 |
|
3599 | 173 |
(ParseError handles:ex) ifFalse:[ |
174 |
ex creator isHandled ifTrue:[ |
|
175 |
"/ Transcript showCR:'handled' . |
|
176 |
ex reject. |
|
177 |
]. |
|
178 |
"Parse error may happen when re-formatting incomplete code while editing" |
|
179 |
('SyntaxHighlighter [info]: error during highlight: ' , ex description) infoPrintCR. |
|
180 |
"/ ex suspendedContext fullPrintAll. |
|
181 |
]. |
|
182 |
highlighter notNil ifTrue:[ |
|
183 |
^ self colorize:(newText ? aString) forErrorAtPosition:highlighter sourceStream position withOriginal:aString |
|
184 |
]. |
|
185 |
^ aString |
|
2371 | 186 |
] do:[ |
3599 | 187 |
|sourceString| |
2371 | 188 |
|
3599 | 189 |
sourceString := aString string. |
3675 | 190 |
newText := sourceString "asUnicode16String" asText. |
3599 | 191 |
"/ use an array here (instead of the RunArray) - this can be changed much faster using #at:put: |
192 |
newText emphasisCollection:(Array new:sourceString size). |
|
193 |
||
194 |
highlighter := self for:(ReadStream on:aString string) in:aClass. |
|
195 |
highlighter method:methodOrNil. |
|
196 |
preferencesOrNil notNil ifTrue:[highlighter preferences:preferencesOrNil]. |
|
197 |
"/ highlighter ignoreErrors:true. |
|
198 |
highlighter ignoreWarnings:true. |
|
199 |
highlighter sourceText:newText. |
|
2371 | 200 |
|
3599 | 201 |
tree := highlighter parseMethod. |
202 |
newText := highlighter sourceText. "/ might have changed identity |
|
203 |
"/ now, convert the emphasis-array to a runArray |
|
204 |
newText emphasisCollection:(newText emphasis asRunArray). |
|
2371 | 205 |
|
3599 | 206 |
tree == #Error ifTrue:[ |
207 |
^ self colorize:newText forErrorAtPosition:highlighter sourceStream position withOriginal:aString. |
|
208 |
]. |
|
209 |
^ newText |
|
2371 | 210 |
] |
3599 | 211 |
|
2371 | 212 |
" |
213 |
self |
|
3599 | 214 |
formatMethod:'foo |
2371 | 215 |
^ self bar:''hello''. |
216 |
||
217 |
' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , ' |
|
218 |
' |
|
3599 | 219 |
in:UndefinedObject |
2371 | 220 |
" |
221 |
||
222 |
"Created: / 28-04-2010 / 13:01:42 / cg" |
|
2527
a87cf2c8edf2
changed: #formatMethod:source:in:using:
Claus Gittinger <cg@exept.de>
parents:
2526
diff
changeset
|
223 |
"Modified: / 05-07-2011 / 11:22:20 / cg" |
2371 | 224 |
! |
225 |
||
2526
ecd1ee8f03bc
category of: #formatMethod:source:in:using:elementsInto:
Claus Gittinger <cg@exept.de>
parents:
2525
diff
changeset
|
226 |
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
|
227 |
|
44f3c6ce19f1
fixed #formatMethod:source:in:using:elementsInto:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2527
diff
changeset
|
228 |
^ 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
|
229 |
|
ecd1ee8f03bc
category of: #formatMethod:source:in:using:elementsInto:
Claus Gittinger <cg@exept.de>
parents:
2525
diff
changeset
|
230 |
"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
|
231 |
"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
|
232 |
! |
ecd1ee8f03bc
category of: #formatMethod:source:in:using:elementsInto:
Claus Gittinger <cg@exept.de>
parents:
2525
diff
changeset
|
233 |
|
2371 | 234 |
formatMethodSource:aString in:aClass |
235 |
"format (recolor) a method in a given class. |
|
236 |
Return the text containing font changes and color information." |
|
237 |
||
238 |
^ self formatMethod:nil source:aString in:aClass using:nil |
|
239 |
||
240 |
" |
|
241 |
self |
|
3469 | 242 |
formatMethod:'foo |
2371 | 243 |
^ self bar:''hello''. |
244 |
||
245 |
' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , ' |
|
246 |
' |
|
3469 | 247 |
in:UndefinedObject |
2371 | 248 |
" |
249 |
||
250 |
"Created: / 28-04-2010 / 12:58:13 / cg" |
|
251 |
! |
|
252 |
||
253 |
formatMethodSource:aString in:aClass using:preferencesOrNil |
|
254 |
"format (recolor) a method in a given class. |
|
255 |
Return the text containing font changes and color information." |
|
256 |
||
257 |
^ self formatMethod:nil source:aString in:aClass using:preferencesOrNil |
|
258 |
||
259 |
"Modified: / 28-04-2010 / 13:02:11 / cg" |
|
260 |
! ! |
|
261 |
||
3599 | 262 |
!AbstractSyntaxHighlighter class methodsFor:'highlighting'! |
263 |
||
264 |
colorize:text forErrorAtPosition:pos withOriginal:originalString |
|
265 |
|eColor endPos| |
|
266 |
||
267 |
endPos := pos + 1. |
|
268 |
||
269 |
"/ mhmh - which is better ... |
|
270 |
||
271 |
"/ alternative1: colorize the rest after the error in red |
|
272 |
||
273 |
eColor := UserPreferences current errorColor. |
|
274 |
eColor notNil ifTrue:[ |
|
275 |
^ text |
|
276 |
emphasizeFrom:endPos |
|
277 |
to:text size |
|
278 |
with:(#color->eColor). |
|
279 |
]. |
|
280 |
||
281 |
"/ alternative2: take the original emphasis for the rest |
|
282 |
endPos >= text size ifTrue:[ |
|
283 |
^ text |
|
284 |
] ifFalse:[ |
|
285 |
^ (text copyTo:endPos) , (originalString copyFrom:(endPos+1)) |
|
286 |
]. |
|
287 |
||
288 |
"/ alternative3: no emphasis for rest. |
|
289 |
^ text |
|
290 |
! ! |
|
291 |
||
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
292 |
!AbstractSyntaxHighlighter class methodsFor:'misc'! |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
293 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
294 |
collectionEnumerationSelectors |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
295 |
"these are considered wellknown, builtin selectors of very common |
3469 | 296 |
collection enumeration methods. |
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
297 |
These are optionally shown with another color (dark green)" |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
298 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
299 |
^ #( |
3469 | 300 |
collect: |
301 |
select: |
|
302 |
inject:into: |
|
303 |
count: |
|
304 |
collect:thenSelect: |
|
305 |
select:thenCollect: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
306 |
) |
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 |
"Created: / 14-02-2012 / 15:56:59 / cg" |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
309 |
! |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
310 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
311 |
controlFlowSelectors |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
312 |
"these are considered wellknown, builtin selectors of very common |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
313 |
control flow constructs. Correspond to syntax or special forms in other |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
314 |
languages. These are optionally shown with another color (blue)" |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
315 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
316 |
^ #( |
3977 | 317 |
ifTrue: ifFalse: |
318 |
ifTrue:ifFalse: ifFalse:ifTrue: |
|
319 |
ifNil: ifNotNil: |
|
320 |
ifNil:ifNotNil: ifNotNil:ifNil: |
|
321 |
and: or: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
322 |
|
3977 | 323 |
whileTrue: |
324 |
whileFalse: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
325 |
|
3977 | 326 |
to:do: |
327 |
downTo:do: |
|
328 |
to:by:do: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
329 |
|
3977 | 330 |
loop |
331 |
repeat |
|
332 |
whileTrue |
|
333 |
whileFalse |
|
334 |
doWhile: |
|
335 |
doUntil: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
336 |
|
3977 | 337 |
do: |
338 |
doWithIndex: |
|
339 |
pairWiseDo: |
|
340 |
keysAndValuesDo: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
341 |
|
3977 | 342 |
withPriority:do: |
343 |
handle:do: |
|
344 |
on:do: |
|
345 |
catch: |
|
346 |
ignoreIn: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
347 |
|
3977 | 348 |
"/ newProcess |
349 |
fork: |
|
350 |
ensure: |
|
351 |
ifCurtailed: |
|
352 |
valueOnUnwindDo: |
|
353 |
valueNowOrOnUnwindDo: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
354 |
|
3977 | 355 |
caseOf: |
356 |
caseOf:otherwise: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
357 |
) |
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 |
"Created: / 08-09-2006 / 15:56:47 / cg" |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
360 |
! |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
361 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
362 |
debugSelectors |
3235
6385bfe15842
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3231
diff
changeset
|
363 |
"these are considered harmful if left in a deployed application: |
6385bfe15842
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3231
diff
changeset
|
364 |
selectors for debugging which open a debugger (unless haltSignal is |
3469 | 365 |
caught or disabled, which end-user apps should do). |
3235
6385bfe15842
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3231
diff
changeset
|
366 |
These are optionally shown with another color (redish)" |
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
367 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
368 |
^ #( |
3469 | 369 |
halt halt: |
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
370 |
) |
3235
6385bfe15842
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3231
diff
changeset
|
371 |
|
6385bfe15842
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3231
diff
changeset
|
372 |
"Modified (comment): / 27-07-2013 / 11:45:07 / cg" |
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
373 |
! |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
374 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
375 |
errorRaisingSelectors |
3469 | 376 |
"these are error raisers. |
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
377 |
These are optionally shown with another color (red)" |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
378 |
|
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
379 |
^ #( |
3469 | 380 |
error error: |
381 |
raise raiseRequest: |
|
382 |
raiseErrorString: raiseRequestErrorString: |
|
383 |
raiseWith: raiseRequestWith: |
|
384 |
raiseWith:errorString: raiseRequestWith:errorString: |
|
385 |
subclassResponsibility |
|
386 |
obsoleteMethodWarning obsoleteMethodWarning: |
|
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
387 |
) |
3342
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
388 |
! |
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
389 |
|
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
390 |
isControlFlowSelector:aSelector |
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
391 |
"these are considered wellknown, builtin selectors of very common |
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
392 |
control flow constructs. Correspond to syntax or special forms in other |
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
393 |
languages. These are optionally shown with another color (blue)" |
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 |
(self controlFlowSelectors includesIdentical:aSelector) ifTrue:[^ true]. |
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
396 |
|
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
397 |
true "((aSelector startsWith:'with') or:[ aSelector startsWith:'all'])" ifTrue:[ |
3469 | 398 |
((aSelector endsWith:'do:') or:[ aSelector endsWith:'Do:']) ifTrue:[ |
399 |
^ true |
|
400 |
] |
|
3342
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
401 |
]. |
d7aec03dc509
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3264
diff
changeset
|
402 |
^ false. |
3231
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
403 |
! ! |
44b2709db25e
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3228
diff
changeset
|
404 |
|
3732 | 405 |
!AbstractSyntaxHighlighter class methodsFor:'queries'! |
406 |
||
407 |
isAbstract |
|
408 |
^ self == AbstractSyntaxHighlighter |
|
409 |
! ! |
|
410 |
||
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
411 |
!AbstractSyntaxHighlighter class methodsFor:'utilities'! |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
412 |
|
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
413 |
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
|
414 |
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
|
415 |
|
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
416 |
"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
|
417 |
! |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
418 |
|
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
419 |
mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:clrIn |
3352
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
420 |
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
|
421 |
! |
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
422 |
|
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
423 |
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
|
424 |
|e p2 clr| |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
425 |
|
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
426 |
(clrIn isNil or:[clrIn = Color black]) ifTrue:[ |
3469 | 427 |
e := fontEmp |
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
428 |
] ifFalse:[ |
3469 | 429 |
clr := clrIn onDevice:Screen current. |
430 |
fontEmp isNil ifTrue:[ |
|
431 |
e := (#color->clr) |
|
432 |
] ifFalse:[ |
|
433 |
e := Text addEmphasis:fontEmp to:(#color->clr). |
|
434 |
] |
|
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
435 |
]. |
3352
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
436 |
fontIn notNil ifTrue:[ |
3469 | 437 |
e := Text addEmphasis:e to:(#font->fontIn) |
3352
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
438 |
]. |
42a5ad1adb52
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3345
diff
changeset
|
439 |
|
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
440 |
(p2 := pos2) isNil ifTrue:[ |
3469 | 441 |
p2 := sourceText size |
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
442 |
] ifFalse:[ |
3469 | 443 |
p2 := p2 min:sourceText size |
2872
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 |
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
|
446 |
|
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
447 |
"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
|
448 |
! |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
449 |
|
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
450 |
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
|
451 |
|e p2 clr fgClr| |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
452 |
|
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
453 |
fgClr := fgClr1 ? fgClr2. |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
454 |
(fgClr isNil or:[fgClr = Color black]) ifTrue:[ |
3469 | 455 |
e := fontEmp |
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
456 |
] ifFalse:[ |
3469 | 457 |
clr := fgClr onDevice:Screen current. |
458 |
fontEmp isNil ifTrue:[ |
|
459 |
e := (#color->clr) |
|
460 |
] ifFalse:[ |
|
461 |
e := Text addEmphasis:fontEmp to:(#color->clr). |
|
462 |
] |
|
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
463 |
]. |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
464 |
bgClr notNil ifTrue:[ |
3469 | 465 |
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
|
466 |
]. |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
467 |
(p2 := pos2) isNil ifTrue:[ |
3469 | 468 |
p2 := sourceText size |
2872
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
469 |
] ifFalse:[ |
3469 | 470 |
p2 := p2 min:sourceText size |
2872
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 |
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
|
473 |
|
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
474 |
"Created: / 01-06-2012 / 21:44:17 / cg" |
3561
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
475 |
! |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
476 |
|
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
477 |
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
|
478 |
|e p2 clr fgClr| |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
479 |
|
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
480 |
fgClr := fgClr1 ? fgClr2. |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
481 |
(fgClr isNil or:[fgClr = Color black]) ifTrue:[ |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
482 |
e := fontEmp ? fontEmp2 |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
483 |
] ifFalse:[ |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
484 |
clr := fgClr onDevice:Screen current. |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
485 |
(fontEmp ? fontEmp2) isNil ifTrue:[ |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
486 |
e := (#color->clr) |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
487 |
] ifFalse:[ |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
488 |
e := Text addEmphasis:(fontEmp ? fontEmp2) to:(#color->clr). |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
489 |
] |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
490 |
]. |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
491 |
bgClr notNil ifTrue:[ |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
492 |
e := Text addEmphasis:(#backgroundColor->bgClr) to:e. |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
493 |
]. |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
494 |
(p2 := pos2) isNil ifTrue:[ |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
495 |
p2 := sourceText size |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
496 |
] ifFalse:[ |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
497 |
p2 := p2 min:sourceText size |
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 |
sourceText emphasizeFrom:pos1 to:p2 with:e |
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
500 |
|
f04a8db1590f
class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
501 |
"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
|
502 |
! ! |
f992970ef1cd
refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents:
2817
diff
changeset
|
503 |
|
2371 | 504 |
!AbstractSyntaxHighlighter methodsFor:'accessing'! |
505 |
||
506 |
method:aMethod |
|
2525 | 507 |
"the original method, if known (for subclasses which can make use of it)" |
508 |
||
509 |
method := aMethod. |
|
2371 | 510 |
|
511 |
"Created: / 28-04-2010 / 13:15:33 / cg" |
|
512 |
! |
|
513 |
||
514 |
preferences:something |
|
515 |
preferences := something. |
|
516 |
! |
|
517 |
||
518 |
sourceText |
|
3599 | 519 |
"retrieve the updated source text after the highlighting process" |
520 |
||
2371 | 521 |
^ sourceText |
522 |
||
523 |
"Created: / 31.3.1998 / 11:49:05 / cg" |
|
524 |
! |
|
525 |
||
526 |
sourceText:aString |
|
3599 | 527 |
"this text will be updated by the highlighting process" |
528 |
||
2371 | 529 |
sourceText := aString. |
530 |
||
531 |
"Created: / 31-03-1998 / 11:49:05 / cg" |
|
532 |
"Modified: / 28-04-2010 / 13:22:27 / cg" |
|
533 |
! ! |
|
534 |
||
535 |
!AbstractSyntaxHighlighter methodsFor:'error handling'! |
|
536 |
||
537 |
parseError:aMessage position:position to:endPos |
|
538 |
"/ Transcript showCR:aMessage. |
|
539 |
super parseError:aMessage position:position to:endPos. |
|
540 |
||
3469 | 541 |
self |
542 |
markFrom:position to:endPos |
|
543 |
withEmphasis:nil color:UserPreferences current errorColor |
|
2371 | 544 |
! |
545 |
||
546 |
showErrorMessage:aMessage position:pos |
|
547 |
"/ Transcript showCR:aMessage. |
|
548 |
super showErrorMessage:aMessage position:pos. |
|
549 |
||
3469 | 550 |
self |
551 |
markFrom:pos to:nil |
|
552 |
withEmphasis:nil color:UserPreferences current errorColor |
|
2371 | 553 |
! |
554 |
||
555 |
syntaxError:aMessage position:position to:endPos |
|
556 |
"/ Transcript showCR:aMessage. |
|
557 |
super syntaxError:aMessage position:position to:endPos. |
|
558 |
||
3469 | 559 |
self |
560 |
markFrom:position to:endPos |
|
561 |
withEmphasis:nil color:UserPreferences current errorColor |
|
2371 | 562 |
! |
563 |
||
564 |
warning:msg position:pos1 to:pos2 |
|
565 |
"/ self markUnknownIdentifierFrom:pos1 to:pos2 |
|
566 |
||
567 |
"/ self |
|
3469 | 568 |
"/ markFrom:pos1 to:pos2 |
2371 | 569 |
"/ withEmphasis:nil color:UserPreferences current errorColor |
570 |
||
571 |
"Modified: / 25.9.1999 / 18:42:30 / cg" |
|
572 |
! ! |
|
573 |
||
574 |
!AbstractSyntaxHighlighter methodsFor:'initialization'! |
|
575 |
||
576 |
initialize |
|
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" |
|
584 |
"Modified: / 28-04-2010 / 13:17:45 / cg" |
|
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 |