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