author | Claus Gittinger <cg@exept.de> |
Thu, 29 Oct 2009 11:58:53 +0100 | |
changeset 2227 | 5b45a572dc15 |
parent 2177 | 82f1c329a959 |
child 2228 | a4fefd07cf25 |
permissions | -rw-r--r-- |
662 | 1 |
" |
2 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1110 | 12 |
"{ Package: 'stx:libcomp' }" |
13 |
||
662 | 14 |
Parser subclass:#SyntaxHighlighter |
1526 | 15 |
instanceVariableNames:'sourceText preferences currentSuperclasses currentSubclasses |
1802 | 16 |
fullSelectorCheck cachedLocalIdentifierEmphasis |
17 |
cachedLocalIdentifierColor cachedStringEmphasis cachedStringColor' |
|
662 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'System-Compiler' |
|
21 |
! |
|
22 |
||
23 |
!SyntaxHighlighter class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
||
38 |
||
681 | 39 |
! |
40 |
||
41 |
documentation |
|
42 |
" |
|
43 |
colors a method. |
|
44 |
" |
|
45 |
||
46 |
||
662 | 47 |
! ! |
48 |
||
49 |
!SyntaxHighlighter class methodsFor:'highlighting'! |
|
50 |
||
1527 | 51 |
formatClassDefinition:aString in:aClass |
52 |
"format (recolor) a class definition expression in a given class. |
|
53 |
Return the text containing font changes and color information." |
|
54 |
||
55 |
^ self formatExpression:aString in:aClass |
|
56 |
! |
|
57 |
||
684
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
58 |
formatExpression:aString in:aClass |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
59 |
"format (recolor) an expression in a given class. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
60 |
Return the text containing font changes and color information." |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
61 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
62 |
|parser tree text endPos| |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
63 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
64 |
aString isNil ifTrue:[^ nil]. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
65 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
66 |
parser := self for:(ReadStream on:aString string) in:aClass. |
1365 | 67 |
parser ignoreErrors:true. |
68 |
parser ignoreWarnings:true. |
|
684
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
69 |
parser sourceText:(text := aString string asText). |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
70 |
"/ use an array here - this can be changed much faster using #at:put: |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
71 |
text emphasisCollection:(Array new:aString size). |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
72 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
73 |
parser nextToken. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
74 |
tree := parser expression. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
75 |
"/ now, convert the emphasis-array to a runArray |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
76 |
text emphasisCollection:(text emphasis asRunArray). |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
77 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
78 |
tree == #Error ifTrue:[ |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
79 |
"/ mhmh - which is better ... |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
80 |
"/ alternative1: color rest after error in red |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
81 |
"/ text |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
82 |
"/ emphasizeFrom:(parser sourceStream position) |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
83 |
"/ to:text size |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
84 |
"/ with:(#color->Color red). |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
85 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
86 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
87 |
"/ alternative2: take original emphasis for rest |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
88 |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1365
diff
changeset
|
89 |
endPos := parser sourceStream position1Based. |
684
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
90 |
endPos >= text size ifTrue:[ |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
91 |
^ text |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
92 |
]. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
93 |
^ (text copyTo:endPos) , (aString copyFrom:(endPos+1)) |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
94 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
95 |
"/ alternative3: no emphasis for rest. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
96 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
97 |
"/ ^ text "/ aString |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
98 |
]. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
99 |
^ text |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
100 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
101 |
" |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
102 |
self |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
103 |
formatExpression:'(1 + 2) max:5' |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
104 |
in:UndefinedObject |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
105 |
" |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
106 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
107 |
"Modified: / 7.4.1998 / 09:57:19 / cg" |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
108 |
"Created: / 9.4.1998 / 16:57:16 / cg" |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
109 |
! |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
110 |
|
662 | 111 |
formatMethod:aString in:aClass |
680
ebc432c71aec
much faster (due to runArray changes.
Claus Gittinger <cg@exept.de>
parents:
678
diff
changeset
|
112 |
"format (recolor) a method in a given class. |
ebc432c71aec
much faster (due to runArray changes.
Claus Gittinger <cg@exept.de>
parents:
678
diff
changeset
|
113 |
Return the text containing font changes and color information." |
662 | 114 |
|
1550 | 115 |
^ self formatMethod:aString in:aClass using:nil |
116 |
||
117 |
" |
|
118 |
self |
|
119 |
formatMethod:'foo |
|
120 |
^ self bar:''hello''. |
|
121 |
||
122 |
' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , ' |
|
123 |
' |
|
124 |
in:UndefinedObject |
|
125 |
" |
|
126 |
||
127 |
"Modified: / 23.10.1998 / 22:48:45 / cg" |
|
128 |
! |
|
129 |
||
130 |
formatMethod:aString in:aClass using:preferencesOrNil |
|
131 |
"format (recolor) a method in a given class. |
|
132 |
Return the text containing font changes and color information." |
|
133 |
||
134 |
|highlighter tree text endPos eColor| |
|
662 | 135 |
|
136 |
aString isNil ifTrue:[^ nil]. |
|
137 |
||
1110 | 138 |
Error handle:[:ex | |
1857 | 139 |
ex signal isHandled ifTrue:[ |
140 |
ex reject. |
|
141 |
]. |
|
2087
42c0f2fe415d
Do not write Warning messages about parse errors
Stefan Vogel <sv@exept.de>
parents:
2070
diff
changeset
|
142 |
(self parseErrorSignal handles:ex) ifFalse:[ |
42c0f2fe415d
Do not write Warning messages about parse errors
Stefan Vogel <sv@exept.de>
parents:
2070
diff
changeset
|
143 |
"Parse error may happen when re-formatting incomplete code while editing" |
42c0f2fe415d
Do not write Warning messages about parse errors
Stefan Vogel <sv@exept.de>
parents:
2070
diff
changeset
|
144 |
('SyntaxHighlighter [info]: error during highlight: ' , ex description) infoPrintCR. |
42c0f2fe415d
Do not write Warning messages about parse errors
Stefan Vogel <sv@exept.de>
parents:
2070
diff
changeset
|
145 |
"/ ex suspendedContext fullPrintAll. |
42c0f2fe415d
Do not write Warning messages about parse errors
Stefan Vogel <sv@exept.de>
parents:
2070
diff
changeset
|
146 |
]. |
689 | 147 |
^ aString |
148 |
] do:[ |
|
1550 | 149 |
highlighter := self for:(ReadStream on:aString string) in:aClass. |
150 |
preferencesOrNil notNil ifTrue:[highlighter preferences:preferencesOrNil]. |
|
1857 | 151 |
"/ highlighter ignoreErrors:true. |
1550 | 152 |
highlighter ignoreWarnings:true. |
153 |
highlighter sourceText:(text := aString string asText). |
|
689 | 154 |
"/ use an array here - this can be changed much faster using #at:put: |
155 |
text emphasisCollection:(Array new:aString size). |
|
662 | 156 |
|
1550 | 157 |
tree := highlighter parseMethod. |
689 | 158 |
"/ now, convert the emphasis-array to a runArray |
159 |
text emphasisCollection:(text emphasis asRunArray). |
|
680
ebc432c71aec
much faster (due to runArray changes.
Claus Gittinger <cg@exept.de>
parents:
678
diff
changeset
|
160 |
|
689 | 161 |
tree == #Error ifTrue:[ |
889 | 162 |
eColor := UserPreferences current errorColor. |
163 |
eColor notNil ifTrue:[ |
|
164 |
"/ mhmh - which is better ... |
|
165 |
"/ alternative1: color rest after error in red |
|
166 |
text |
|
1550 | 167 |
emphasizeFrom:(highlighter sourceStream position1Based) |
889 | 168 |
to:text size |
169 |
with:(#color->eColor). |
|
170 |
] ifFalse:[ |
|
171 |
"/ alternative2: take original emphasis for rest |
|
680
ebc432c71aec
much faster (due to runArray changes.
Claus Gittinger <cg@exept.de>
parents:
678
diff
changeset
|
172 |
|
1550 | 173 |
endPos := highlighter sourceStream position1Based. |
889 | 174 |
endPos >= text size ifTrue:[ |
175 |
^ text |
|
176 |
]. |
|
177 |
^ (text copyTo:endPos) , (aString copyFrom:(endPos+1)) |
|
689 | 178 |
]. |
179 |
"/ alternative3: no emphasis for rest. |
|
678 | 180 |
]. |
689 | 181 |
^ text |
182 |
] |
|
662 | 183 |
" |
184 |
self |
|
185 |
formatMethod:'foo |
|
186 |
^ self bar:''hello''. |
|
187 |
||
188 |
' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , ' |
|
189 |
' |
|
190 |
in:UndefinedObject |
|
191 |
" |
|
192 |
||
1857 | 193 |
"Modified: / 22-08-2006 / 13:32:04 / cg" |
662 | 194 |
! ! |
195 |
||
196 |
!SyntaxHighlighter methodsFor:'accessing'! |
|
197 |
||
1550 | 198 |
preferences:something |
199 |
preferences := something. |
|
200 |
! |
|
201 |
||
662 | 202 |
sourceText |
203 |
"return the value of the instance variable 'sourceText' (automatically generated)" |
|
204 |
||
205 |
^ sourceText |
|
206 |
||
207 |
"Created: / 31.3.1998 / 11:49:05 / cg" |
|
208 |
! |
|
209 |
||
210 |
sourceText:something |
|
211 |
"set the value of the instance variable 'sourceText' (automatically generated)" |
|
212 |
||
213 |
sourceText := something. |
|
214 |
||
215 |
"Created: / 31.3.1998 / 11:49:05 / cg" |
|
216 |
! ! |
|
217 |
||
948
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
218 |
!SyntaxHighlighter methodsFor:'error handling'! |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
219 |
|
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
220 |
parseError:aMessage position:position to:endPos |
1174
30ff886ef43e
remove error output on Transcript
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
221 |
"/ Transcript showCR:aMessage. |
948
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
222 |
super parseError:aMessage position:position to:endPos. |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
223 |
|
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
224 |
self |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
225 |
markFrom:position to:endPos |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
226 |
withEmphasis:nil color:UserPreferences current errorColor |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
227 |
! |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
228 |
|
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
229 |
showErrorMessage:aMessage position:pos |
1174
30ff886ef43e
remove error output on Transcript
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
230 |
"/ Transcript showCR:aMessage. |
948
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
231 |
super showErrorMessage:aMessage position:pos. |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
232 |
|
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
233 |
self |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
234 |
markFrom:pos to:nil |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
235 |
withEmphasis:nil color:UserPreferences current errorColor |
978 | 236 |
! |
237 |
||
1169
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1159
diff
changeset
|
238 |
syntaxError:aMessage position:position to:endPos |
1174
30ff886ef43e
remove error output on Transcript
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
239 |
"/ Transcript showCR:aMessage. |
1169
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1159
diff
changeset
|
240 |
super syntaxError:aMessage position:position to:endPos. |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1159
diff
changeset
|
241 |
|
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1159
diff
changeset
|
242 |
self |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1159
diff
changeset
|
243 |
markFrom:position to:endPos |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1159
diff
changeset
|
244 |
withEmphasis:nil color:UserPreferences current errorColor |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1159
diff
changeset
|
245 |
! |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1159
diff
changeset
|
246 |
|
978 | 247 |
warning:msg position:pos1 to:pos2 |
979 | 248 |
"/ self markUnknownIdentifierFrom:pos1 to:pos2 |
249 |
||
978 | 250 |
"/ self |
251 |
"/ markFrom:pos1 to:pos2 |
|
252 |
"/ withEmphasis:nil color:UserPreferences current errorColor |
|
253 |
||
979 | 254 |
"Modified: / 25.9.1999 / 18:42:30 / cg" |
948
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
255 |
! ! |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
256 |
|
662 | 257 |
!SyntaxHighlighter methodsFor:'initialization'! |
258 |
||
259 |
initialize |
|
260 |
super initialize. |
|
261 |
||
990
cd1aa00086fd
dont care to fold constants during syntaxHighlight
Claus Gittinger <cg@exept.de>
parents:
987
diff
changeset
|
262 |
foldConstants := false. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1553
diff
changeset
|
263 |
"/ parserFlags allowDollarInIdentifier:true. |
990
cd1aa00086fd
dont care to fold constants during syntaxHighlight
Claus Gittinger <cg@exept.de>
parents:
987
diff
changeset
|
264 |
|
1526 | 265 |
preferences := UserPreferences current. |
868 | 266 |
|
1526 | 267 |
fullSelectorCheck := preferences fullSelectorCheck. |
662 | 268 |
|
269 |
"Created: / 31.3.1998 / 15:12:55 / cg" |
|
838 | 270 |
"Modified: / 5.1.1980 / 00:44:03 / cg" |
662 | 271 |
! ! |
272 |
||
788
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
273 |
!SyntaxHighlighter methodsFor:'misc'! |
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
274 |
|
1905 | 275 |
controlFlowSelectors |
276 |
^ #( |
|
277 |
ifTrue: |
|
278 |
ifFalse: |
|
279 |
ifTrue:ifFalse: |
|
280 |
ifFalse:ifTrue: |
|
281 |
||
282 |
whileTrue: |
|
283 |
whileFalse: |
|
284 |
||
285 |
to:do: |
|
2170 | 286 |
downTo:do: |
1905 | 287 |
to:by:do: |
288 |
||
289 |
loop |
|
290 |
whileTrue |
|
291 |
whileFalse |
|
292 |
doWhile: |
|
293 |
doUntil: |
|
2177
82f1c329a959
changed #controlFlowSelectors
Claus Gittinger <cg@exept.de>
parents:
2170
diff
changeset
|
294 |
|
82f1c329a959
changed #controlFlowSelectors
Claus Gittinger <cg@exept.de>
parents:
2170
diff
changeset
|
295 |
do: |
82f1c329a959
changed #controlFlowSelectors
Claus Gittinger <cg@exept.de>
parents:
2170
diff
changeset
|
296 |
keysAndValuesDo: |
1905 | 297 |
) |
298 |
||
299 |
"Created: / 08-09-2006 / 15:56:47 / cg" |
|
300 |
! |
|
301 |
||
788
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
302 |
defineAsUndeclaredVariable:aName |
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
303 |
"redefined to NOT declare undefined vars" |
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
304 |
|
1308 | 305 |
^ VariableNode globalNamed:aName |
788
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
306 |
|
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
307 |
"Modified: / 19.10.1998 / 19:38:12 / cg" |
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
308 |
! |
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
309 |
|
884 | 310 |
isSyntaxHighlighter |
311 |
^ true |
|
312 |
||
313 |
! |
|
314 |
||
788
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
315 |
plausibilityCheck:aNode |
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
316 |
"redefined to NOT do checks" |
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
317 |
|
902 | 318 |
^ nil |
788
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
319 |
|
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
320 |
"Modified: / 19.10.1998 / 19:38:12 / cg" |
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
321 |
"Created: / 19.10.1998 / 19:57:18 / cg" |
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
322 |
! ! |
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
323 |
|
662 | 324 |
!SyntaxHighlighter methodsFor:'syntax detection'! |
325 |
||
326 |
markArgumentIdentifierFrom:pos1 to:pos2 |
|
327 |
self |
|
328 |
markFrom:pos1 to:pos2 |
|
1553 | 329 |
withEmphasis:(preferences argumentIdentifierEmphasis) |
330 |
color:(preferences argumentIdentifierColor) |
|
662 | 331 |
|
332 |
"Modified: / 31.3.1998 / 18:01:27 / cg" |
|
333 |
! |
|
334 |
||
884 | 335 |
markBadIdentifierFrom:pos1 to:pos2 |
336 |
self |
|
337 |
markFrom:pos1 to:pos2 |
|
1553 | 338 |
withEmphasis:(preferences badIdentifierEmphasis) |
339 |
color:(preferences badIdentifierColor) |
|
884 | 340 |
! |
341 |
||
2055 | 342 |
markBlockFrom:pos1 to:pos2 |
343 |
#experimental. |
|
344 |
"/ |level color| |
|
345 |
"/ |
|
346 |
"/ level := currentBlock isNil ifTrue:[1] ifFalse:[currentBlock nestingLevel+1]. |
|
347 |
"/ color := (Array |
|
348 |
"/ with:Color yellow |
|
349 |
"/ with:Color lightGrey) at:level\\2+1. |
|
350 |
"/ self |
|
351 |
"/ markFrom:pos1 to:pos2 |
|
352 |
"/ withAddedEmphasis:(#backgroundColor->color) |
|
353 |
||
354 |
"Created: / 15-01-2008 / 11:48:51 / cg" |
|
355 |
! |
|
356 |
||
662 | 357 |
markBooleanConstantFrom:pos1 to:pos2 |
358 |
self |
|
359 |
markFrom:pos1 to:pos2 |
|
1553 | 360 |
withEmphasis:(preferences booleanConstantEmphasis) |
361 |
color:(preferences booleanConstantColor) |
|
662 | 362 |
|
363 |
"Created: / 31.3.1998 / 18:09:01 / cg" |
|
665 | 364 |
"Modified: / 31.3.1998 / 19:36:44 / cg" |
662 | 365 |
! |
366 |
||
673 | 367 |
markBracketAt:pos |
2070 | 368 |
|level colors clr em| |
369 |
||
370 |
preferences emphasizeParenthesisLevel ifFalse:[ |
|
371 |
self |
|
372 |
markFrom:pos to:pos |
|
373 |
withEmphasis:(preferences bracketEmphasis) |
|
374 |
color:(preferences bracketColor). |
|
375 |
||
376 |
^ self |
|
377 |
]. |
|
378 |
||
379 |
level := currentBlock isNil ifTrue:[1] ifFalse:[currentBlock nestingLevel + 2]. |
|
380 |
(sourceText at:pos) = $] ifTrue:[ |
|
381 |
level := level - 1. |
|
382 |
]. |
|
383 |
||
384 |
colors := Array |
|
385 |
with:(Color black) |
|
386 |
with:(Color blue) |
|
387 |
with:(Color green blendWith:(Color grey:30)) |
|
388 |
with:(Color red blendWith:(Color grey:30)) |
|
389 |
with:(Color yellow darkened). |
|
390 |
||
391 |
clr := colors at:((level-1) \\ colors size + 1). |
|
392 |
em := #normal. |
|
393 |
level > 1 ifTrue:[ |
|
394 |
em := #bold. |
|
395 |
]. |
|
673 | 396 |
self |
397 |
markFrom:pos to:pos |
|
2070 | 398 |
withEmphasis:em |
399 |
color:clr |
|
673 | 400 |
! |
401 |
||
870 | 402 |
markClassVariableIdentifierFrom:pos1 to:pos2 |
403 |
self |
|
404 |
markFrom:pos1 to:pos2 |
|
1553 | 405 |
withEmphasis:(preferences classVariableIdentifierEmphasis) |
406 |
color:(preferences classVariableIdentifierColor) |
|
870 | 407 |
|
408 |
"Modified: / 31.3.1998 / 18:02:14 / cg" |
|
409 |
! |
|
410 |
||
662 | 411 |
markCommentFrom:pos1 to:pos2 |
412 |
self |
|
413 |
markFrom:pos1 to:pos2 |
|
1553 | 414 |
withEmphasis:(preferences commentEmphasis) |
415 |
color:(preferences commentColor) |
|
662 | 416 |
|
1550 | 417 |
" |
418 |
UserPreferences current commentEmphasis |
|
419 |
" |
|
420 |
"Modified: / 31.3.1998 / 18:01:55 / cg" |
|
662 | 421 |
! |
422 |
||
423 |
markConstantFrom:pos1 to:pos2 |
|
424 |
self |
|
425 |
markFrom:pos1 to:pos2 |
|
1553 | 426 |
withEmphasis:(preferences constantEmphasis) |
427 |
color:(preferences constantColor) |
|
662 | 428 |
|
429 |
"Modified: / 31.3.1998 / 18:01:44 / cg" |
|
430 |
"Created: / 31.3.1998 / 18:09:22 / cg" |
|
431 |
! |
|
432 |
||
2055 | 433 |
markFrom:pos1 to:pos2 withAddedEmphasis:addedEmphasis |
434 |
sourceText emphasisFrom:pos1 to:pos2 add:addedEmphasis |
|
435 |
||
436 |
"Created: / 15-01-2008 / 11:48:18 / cg" |
|
437 |
! |
|
438 |
||
987
49a05e400448
aquire device colors - faster on pseudoColor devices.
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
439 |
markFrom:pos1 to:pos2 withEmphasis:fontEmp color:clrIn |
49a05e400448
aquire device colors - faster on pseudoColor devices.
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
440 |
|e p2 clr| |
49a05e400448
aquire device colors - faster on pseudoColor devices.
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
441 |
|
49a05e400448
aquire device colors - faster on pseudoColor devices.
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
442 |
clr := clrIn onDevice:Screen current. |
662 | 443 |
|
669 | 444 |
clr = Color black ifTrue:[ |
445 |
e := fontEmp |
|
446 |
] ifFalse:[ |
|
948
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
447 |
fontEmp isNil ifTrue:[ |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
448 |
e := (#color->clr) |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
449 |
] ifFalse:[ |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
450 |
e := Text addEmphasis:fontEmp to:(#color->clr). |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
451 |
] |
669 | 452 |
]. |
948
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
453 |
(p2 := pos2) isNil ifTrue:[ |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
454 |
p2 := sourceText size |
1143 | 455 |
] ifFalse:[ |
456 |
p2 := p2 min:sourceText size |
|
948
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
457 |
]. |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
458 |
sourceText emphasizeFrom:pos1 to:p2 with:e |
662 | 459 |
|
460 |
"Created: / 31.3.1998 / 13:26:53 / cg" |
|
669 | 461 |
"Modified: / 1.4.1998 / 12:51:56 / cg" |
662 | 462 |
! |
463 |
||
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
464 |
markGlobalClassIdentifierFrom:pos1 to:pos2 |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
465 |
self |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
466 |
markFrom:pos1 to:pos2 |
1553 | 467 |
withEmphasis:(preferences globalClassIdentifierEmphasis) |
468 |
color:(preferences globalClassIdentifierColor) |
|
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
469 |
|
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
470 |
"Modified: / 31.3.1998 / 18:02:14 / cg" |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
471 |
"Created: / 4.3.1999 / 12:53:02 / cg" |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
472 |
! |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
473 |
|
662 | 474 |
markGlobalIdentifierFrom:pos1 to:pos2 |
475 |
self |
|
476 |
markFrom:pos1 to:pos2 |
|
1553 | 477 |
withEmphasis:(preferences globalIdentifierEmphasis) |
478 |
color:(preferences globalIdentifierColor) |
|
662 | 479 |
|
480 |
"Modified: / 31.3.1998 / 18:02:14 / cg" |
|
481 |
! |
|
482 |
||
483 |
markHereFrom:pos1 to:pos2 |
|
484 |
self |
|
485 |
markFrom:pos1 to:pos2 |
|
1553 | 486 |
withEmphasis:(preferences hereEmphasis) |
487 |
color:(preferences hereColor) |
|
662 | 488 |
|
489 |
"Modified: / 31.3.1998 / 18:02:25 / cg" |
|
490 |
! |
|
491 |
||
492 |
markIdentifierFrom:pos1 to:pos2 |
|
493 |
self |
|
494 |
markFrom:pos1 to:pos2 |
|
1553 | 495 |
withEmphasis:(preferences identifierEmphasis) |
496 |
color:(preferences identifierColor) |
|
662 | 497 |
|
498 |
"Modified: / 31.3.1998 / 18:02:39 / cg" |
|
499 |
"Created: / 31.3.1998 / 18:04:56 / cg" |
|
500 |
! |
|
501 |
||
686 | 502 |
markInstVarIdentifierFrom:pos1 to:pos2 |
503 |
self |
|
504 |
markFrom:pos1 to:pos2 |
|
1553 | 505 |
withEmphasis:(preferences instVarIdentifierEmphasis) |
506 |
color:(preferences instVarIdentifierColor) |
|
686 | 507 |
|
508 |
"Created: / 16.4.1998 / 18:35:40 / cg" |
|
509 |
"Modified: / 16.4.1998 / 18:37:30 / cg" |
|
510 |
! |
|
511 |
||
662 | 512 |
markLocalIdentifierFrom:pos1 to:pos2 |
1802 | 513 |
cachedLocalIdentifierEmphasis isNil ifTrue:[ |
514 |
cachedLocalIdentifierEmphasis := preferences localIdentifierEmphasis. |
|
515 |
cachedLocalIdentifierColor := preferences localIdentifierColor. |
|
516 |
]. |
|
662 | 517 |
self |
518 |
markFrom:pos1 to:pos2 |
|
1802 | 519 |
withEmphasis:cachedLocalIdentifierEmphasis |
520 |
color:cachedLocalIdentifierColor |
|
662 | 521 |
|
522 |
"Modified: / 31.3.1998 / 18:02:39 / cg" |
|
523 |
! |
|
524 |
||
525 |
markMethodSelectorFrom:pos1 to:pos2 |
|
526 |
self |
|
527 |
markFrom:pos1 to:pos2 |
|
1553 | 528 |
withEmphasis:(preferences methodSelectorEmphasis) |
529 |
color:(preferences methodSelectorColor) |
|
662 | 530 |
|
531 |
"Modified: / 31.3.1998 / 18:02:52 / cg" |
|
532 |
! |
|
533 |
||
1684 | 534 |
markNumberConstantFrom:pos1 to:pos2 |
535 |
self |
|
536 |
markFrom:pos1 to:pos2 |
|
537 |
withEmphasis:(preferences numberConstantEmphasis) |
|
538 |
color:(preferences numberConstantColor) |
|
539 |
||
540 |
"Modified: / 31.3.1998 / 18:01:44 / cg" |
|
541 |
"Created: / 31.3.1998 / 18:09:22 / cg" |
|
542 |
! |
|
543 |
||
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
544 |
markParenthesisAt:pos |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
545 |
|colors clr em| |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
546 |
|
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
547 |
preferences emphasizeParenthesisLevel ifFalse:[^ self]. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
548 |
|
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
549 |
colors := Array |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
550 |
with:(Color black) |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
551 |
with:(Color blue) |
1757 | 552 |
with:(Color green blendWith:(Color grey:30)) |
553 |
with:(Color red blendWith:(Color grey:30)) |
|
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
554 |
with:(Color yellow darkened). |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
555 |
|
1757 | 556 |
clr := colors at:((parenthesisLevel-1) \\ colors size + 1). |
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
557 |
em := #normal. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
558 |
parenthesisLevel > 1 ifTrue:[ |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
559 |
em := #bold. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
560 |
]. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
561 |
self |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
562 |
markFrom:pos to:pos |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
563 |
withEmphasis:em |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
564 |
color:clr |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
565 |
! |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
566 |
|
1553 | 567 |
markPoolVariableIdentifierFrom:pos1 to:pos2 |
568 |
self |
|
569 |
markFrom:pos1 to:pos2 |
|
570 |
withEmphasis:(preferences poolVariableIdentifierEmphasis) |
|
571 |
color:(preferences poolVariableIdentifierColor) |
|
572 |
! |
|
573 |
||
838 | 574 |
markReturnAt:pos |
575 |
self |
|
576 |
markFrom:pos to:pos |
|
1553 | 577 |
withEmphasis:(preferences returnEmphasis) |
578 |
color:(preferences returnColor) |
|
838 | 579 |
|
580 |
"Modified: / 31.3.1998 / 19:36:44 / cg" |
|
581 |
"Created: / 5.1.1980 / 00:44:27 / cg" |
|
582 |
! |
|
583 |
||
863 | 584 |
markSelector:selectorString from:pos1 to:pos2 receiverNode:aReceiverNode |
1498
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
585 |
|fg selectorSymbol check ok rec em| |
863 | 586 |
|
587 |
"/ uncommenting the code below |
|
588 |
"/ will suppress highlighting of common selectors ... |
|
589 |
"/ |
|
590 |
"/ (#( |
|
591 |
"/ 'ifTrue:' |
|
592 |
"/ 'ifFalse:' |
|
593 |
"/ 'not' |
|
594 |
"/ 'and:' |
|
595 |
"/ 'or:' |
|
596 |
"/ '=' |
|
597 |
"/ '==' |
|
598 |
"/ '~=' |
|
599 |
"/ '~~' |
|
600 |
"/ ) includes:sel) ifTrue:[ |
|
601 |
"/ ^ self |
|
602 |
"/ ]. |
|
603 |
||
1526 | 604 |
fg := preferences selectorColor. |
605 |
em := preferences selectorEmphasis. |
|
1498
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
606 |
selectorSymbol := selectorString asSymbolIfInterned. |
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
607 |
selectorSymbol isNil ifTrue:[ |
1905 | 608 |
em := preferences unimplementedSelectorEmphasis. |
609 |
fg := preferences unimplementedSelectorColor. |
|
1498
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
610 |
] ifFalse:[ |
1905 | 611 |
ok := true. |
612 |
||
863 | 613 |
fullSelectorCheck == true ifTrue:[ |
614 |
||
1498
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
615 |
check := [:cls | (cls includesSelector:selectorSymbol) |
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
616 |
or:[cls class includesSelector:selectorSymbol]]. |
863 | 617 |
|
618 |
ok := false. |
|
619 |
||
620 |
"/ limit search if possible |
|
621 |
(classToCompileFor notNil |
|
622 |
and:[aReceiverNode isSelf or:[aReceiverNode isSuper]]) ifTrue:[ |
|
623 |
currentSuperclasses isNil ifTrue:[ |
|
624 |
currentSuperclasses := classToCompileFor withAllSuperclasses. |
|
625 |
]. |
|
626 |
ok := currentSuperclasses contains:check. |
|
627 |
(ok not and:[aReceiverNode isSelf]) ifTrue:[ |
|
628 |
currentSubclasses isNil ifTrue:[ |
|
629 |
currentSubclasses := classToCompileFor allSubclasses. |
|
630 |
]. |
|
631 |
ok := currentSubclasses contains:check. |
|
632 |
]. |
|
633 |
] ifFalse:[ |
|
634 |
aReceiverNode isConstant ifTrue:[ |
|
635 |
ok := aReceiverNode evaluate class withAllSuperclasses contains:check. |
|
636 |
] ifFalse:[ |
|
637 |
(aReceiverNode isGlobal |
|
638 |
and:[(rec := aReceiverNode evaluate) isBehavior]) ifTrue:[ |
|
639 |
ok := rec class withAllSuperclasses contains:check. |
|
640 |
] ifFalse:[ |
|
641 |
ok := Smalltalk allClasses contains:check |
|
642 |
] |
|
643 |
] |
|
644 |
]. |
|
1905 | 645 |
]. |
646 |
ok ifFalse:[ |
|
647 |
em := preferences unimplementedSelectorEmphasis. |
|
648 |
fg := preferences unimplementedSelectorColor. |
|
649 |
] ifTrue:[ |
|
650 |
(self controlFlowSelectors includesIdentical:selectorSymbol) ifTrue:[ |
|
651 |
em := preferences controlFlowSelectorEmphasis. |
|
652 |
fg := preferences controlFlowSelectorColor. |
|
653 |
]. |
|
654 |
]. |
|
863 | 655 |
]. |
656 |
self |
|
657 |
markFrom:pos1 to:pos2 |
|
1553 | 658 |
withEmphasis:em |
659 |
color:fg |
|
863 | 660 |
|
1905 | 661 |
"Modified: / 08-09-2006 / 15:57:02 / cg" |
863 | 662 |
! |
663 |
||
662 | 664 |
markSelfFrom:pos1 to:pos2 |
665 |
self |
|
666 |
markFrom:pos1 to:pos2 |
|
1553 | 667 |
withEmphasis:(preferences selfEmphasis) |
668 |
color:(preferences selfColor) |
|
662 | 669 |
|
670 |
"Modified: / 31.3.1998 / 18:03:10 / cg" |
|
671 |
! |
|
672 |
||
673 |
markStringFrom:pos1 to:pos2 |
|
1802 | 674 |
cachedStringEmphasis isNil ifTrue:[ |
675 |
cachedStringEmphasis := preferences stringEmphasis. |
|
676 |
cachedStringColor := preferences stringColor. |
|
677 |
]. |
|
662 | 678 |
self |
679 |
markFrom:pos1 to:pos2 |
|
1802 | 680 |
withEmphasis:cachedStringEmphasis |
681 |
color:cachedStringColor |
|
662 | 682 |
|
683 |
"Modified: / 31.3.1998 / 18:03:18 / cg" |
|
684 |
! |
|
685 |
||
686 |
markSuperFrom:pos1 to:pos2 |
|
687 |
self |
|
688 |
markFrom:pos1 to:pos2 |
|
1553 | 689 |
withEmphasis:(preferences superEmphasis) |
690 |
color:(preferences superColor) |
|
662 | 691 |
|
692 |
"Modified: / 31.3.1998 / 18:03:26 / cg" |
|
693 |
! |
|
694 |
||
672 | 695 |
markSymbolFrom:pos1 to:pos2 |
696 |
self |
|
697 |
markFrom:pos1 to:pos2 |
|
1553 | 698 |
withEmphasis:(preferences symbolEmphasis) |
699 |
color:(preferences symbolColor) |
|
672 | 700 |
|
701 |
"Created: / 1.4.1998 / 12:56:47 / cg" |
|
702 |
"Modified: / 1.4.1998 / 12:58:00 / cg" |
|
703 |
! |
|
704 |
||
662 | 705 |
markThisContextFrom:pos1 to:pos2 |
706 |
self |
|
707 |
markFrom:pos1 to:pos2 |
|
1553 | 708 |
withEmphasis:(preferences thisContextEmphasis) |
709 |
color:(preferences thisContextColor) |
|
662 | 710 |
|
711 |
"Modified: / 31.3.1998 / 18:03:36 / cg" |
|
665 | 712 |
! |
713 |
||
714 |
markUnknownIdentifierFrom:pos1 to:pos2 |
|
715 |
self |
|
716 |
markFrom:pos1 to:pos2 |
|
1553 | 717 |
withEmphasis:(preferences unknownIdentifierEmphasis) |
718 |
color:(preferences unknownIdentifierColor) |
|
665 | 719 |
|
720 |
"Created: / 31.3.1998 / 19:09:26 / cg" |
|
721 |
"Modified: / 31.3.1998 / 19:10:30 / cg" |
|
686 | 722 |
! |
723 |
||
724 |
markVariable:v |
|
725 |
"support for syntaxColoring" |
|
726 |
||
727 |
|pos endPos| |
|
728 |
||
729 |
pos := tokenPosition. |
|
730 |
endPos := pos+tokenName size-1. |
|
731 |
self markVariable:v from:pos to:endPos |
|
732 |
||
733 |
"Modified: / 16.4.1998 / 18:49:51 / cg" |
|
734 |
! |
|
735 |
||
736 |
markVariable:v from:pos to:endPos |
|
737 |
"support for syntaxColoring" |
|
738 |
||
823 | 739 |
|type globalValue nameSym| |
686 | 740 |
|
741 |
type := v type. |
|
742 |
(type == #BlockArg |
|
743 |
or:[type == #MethodArg]) ifTrue:[ |
|
744 |
self markArgumentIdentifierFrom:pos to:endPos. |
|
745 |
^ self |
|
746 |
]. |
|
747 |
(type == #BlockVariable |
|
748 |
or:[type == #MethodVariable]) ifTrue:[ |
|
749 |
self markLocalIdentifierFrom:pos to:endPos. |
|
750 |
^ self |
|
751 |
]. |
|
752 |
(type == #GlobalVariable) ifTrue:[ |
|
823 | 753 |
nameSym := v name asSymbolIfInterned. |
754 |
nameSym notNil ifTrue:[ |
|
755 |
globalValue := Smalltalk at:nameSym ifAbsent:nil. |
|
756 |
]. |
|
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
757 |
globalValue isBehavior ifTrue:[ |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
758 |
self markGlobalClassIdentifierFrom:pos to:endPos. |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
759 |
] ifFalse:[ |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
760 |
self markGlobalIdentifierFrom:pos to:endPos. |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
761 |
]. |
686 | 762 |
^ self |
763 |
]. |
|
1553 | 764 |
(type == #PoolVariable) ifTrue:[ |
765 |
self markPoolVariableIdentifierFrom:pos to:endPos. |
|
766 |
^ self |
|
767 |
]. |
|
870 | 768 |
(type == #ClassVariable) ifTrue:[ |
769 |
self markClassVariableIdentifierFrom:pos to:endPos. |
|
770 |
^ self |
|
771 |
]. |
|
686 | 772 |
(type == #InstanceVariable) ifTrue:[ |
773 |
self markInstVarIdentifierFrom:pos to:endPos. |
|
774 |
^ self |
|
775 |
]. |
|
776 |
||
777 |
self markIdentifierFrom:pos to:endPos. |
|
778 |
||
779 |
"Created: / 16.4.1998 / 18:49:34 / cg" |
|
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
780 |
"Modified: / 4.3.1999 / 12:56:13 / cg" |
662 | 781 |
! ! |
782 |
||
783 |
!SyntaxHighlighter class methodsFor:'documentation'! |
|
784 |
||
785 |
version |
|
2177
82f1c329a959
changed #controlFlowSelectors
Claus Gittinger <cg@exept.de>
parents:
2170
diff
changeset
|
786 |
^ '$Header: /cvs/stx/stx/libcomp/SyntaxHighlighter.st,v 1.59 2009-05-09 04:55:40 cg Exp $' |
662 | 787 |
! ! |