author | Stefan Vogel <sv@exept.de> |
Sat, 19 Apr 2008 14:56:46 +0200 | |
changeset 2087 | 42c0f2fe415d |
parent 2070 | 1f4574d55b53 |
child 2170 | 907aa03513e4 |
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: |
|
286 |
to:by:do: |
|
287 |
||
288 |
loop |
|
289 |
whileTrue |
|
290 |
whileFalse |
|
291 |
doWhile: |
|
292 |
doUntil: |
|
293 |
) |
|
294 |
||
295 |
"Created: / 08-09-2006 / 15:56:47 / cg" |
|
296 |
! |
|
297 |
||
788
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
298 |
defineAsUndeclaredVariable:aName |
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
299 |
"redefined to NOT declare undefined vars" |
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
300 |
|
1308 | 301 |
^ VariableNode globalNamed:aName |
788
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
302 |
|
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
303 |
"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
|
304 |
! |
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
305 |
|
884 | 306 |
isSyntaxHighlighter |
307 |
^ true |
|
308 |
||
309 |
! |
|
310 |
||
788
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
311 |
plausibilityCheck:aNode |
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
312 |
"redefined to NOT do checks" |
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
313 |
|
902 | 314 |
^ nil |
788
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
315 |
|
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
316 |
"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
|
317 |
"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
|
318 |
! ! |
5307f69829c6
do not enter undeclared vars into Undeclared.
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
319 |
|
662 | 320 |
!SyntaxHighlighter methodsFor:'syntax detection'! |
321 |
||
322 |
markArgumentIdentifierFrom:pos1 to:pos2 |
|
323 |
self |
|
324 |
markFrom:pos1 to:pos2 |
|
1553 | 325 |
withEmphasis:(preferences argumentIdentifierEmphasis) |
326 |
color:(preferences argumentIdentifierColor) |
|
662 | 327 |
|
328 |
"Modified: / 31.3.1998 / 18:01:27 / cg" |
|
329 |
! |
|
330 |
||
884 | 331 |
markBadIdentifierFrom:pos1 to:pos2 |
332 |
self |
|
333 |
markFrom:pos1 to:pos2 |
|
1553 | 334 |
withEmphasis:(preferences badIdentifierEmphasis) |
335 |
color:(preferences badIdentifierColor) |
|
884 | 336 |
! |
337 |
||
2055 | 338 |
markBlockFrom:pos1 to:pos2 |
339 |
#experimental. |
|
340 |
"/ |level color| |
|
341 |
"/ |
|
342 |
"/ level := currentBlock isNil ifTrue:[1] ifFalse:[currentBlock nestingLevel+1]. |
|
343 |
"/ color := (Array |
|
344 |
"/ with:Color yellow |
|
345 |
"/ with:Color lightGrey) at:level\\2+1. |
|
346 |
"/ self |
|
347 |
"/ markFrom:pos1 to:pos2 |
|
348 |
"/ withAddedEmphasis:(#backgroundColor->color) |
|
349 |
||
350 |
"Created: / 15-01-2008 / 11:48:51 / cg" |
|
351 |
! |
|
352 |
||
662 | 353 |
markBooleanConstantFrom:pos1 to:pos2 |
354 |
self |
|
355 |
markFrom:pos1 to:pos2 |
|
1553 | 356 |
withEmphasis:(preferences booleanConstantEmphasis) |
357 |
color:(preferences booleanConstantColor) |
|
662 | 358 |
|
359 |
"Created: / 31.3.1998 / 18:09:01 / cg" |
|
665 | 360 |
"Modified: / 31.3.1998 / 19:36:44 / cg" |
662 | 361 |
! |
362 |
||
673 | 363 |
markBracketAt:pos |
2070 | 364 |
|level colors clr em| |
365 |
||
366 |
preferences emphasizeParenthesisLevel ifFalse:[ |
|
367 |
self |
|
368 |
markFrom:pos to:pos |
|
369 |
withEmphasis:(preferences bracketEmphasis) |
|
370 |
color:(preferences bracketColor). |
|
371 |
||
372 |
^ self |
|
373 |
]. |
|
374 |
||
375 |
level := currentBlock isNil ifTrue:[1] ifFalse:[currentBlock nestingLevel + 2]. |
|
376 |
(sourceText at:pos) = $] ifTrue:[ |
|
377 |
level := level - 1. |
|
378 |
]. |
|
379 |
||
380 |
colors := Array |
|
381 |
with:(Color black) |
|
382 |
with:(Color blue) |
|
383 |
with:(Color green blendWith:(Color grey:30)) |
|
384 |
with:(Color red blendWith:(Color grey:30)) |
|
385 |
with:(Color yellow darkened). |
|
386 |
||
387 |
clr := colors at:((level-1) \\ colors size + 1). |
|
388 |
em := #normal. |
|
389 |
level > 1 ifTrue:[ |
|
390 |
em := #bold. |
|
391 |
]. |
|
673 | 392 |
self |
393 |
markFrom:pos to:pos |
|
2070 | 394 |
withEmphasis:em |
395 |
color:clr |
|
673 | 396 |
! |
397 |
||
870 | 398 |
markClassVariableIdentifierFrom:pos1 to:pos2 |
399 |
self |
|
400 |
markFrom:pos1 to:pos2 |
|
1553 | 401 |
withEmphasis:(preferences classVariableIdentifierEmphasis) |
402 |
color:(preferences classVariableIdentifierColor) |
|
870 | 403 |
|
404 |
"Modified: / 31.3.1998 / 18:02:14 / cg" |
|
405 |
! |
|
406 |
||
662 | 407 |
markCommentFrom:pos1 to:pos2 |
408 |
self |
|
409 |
markFrom:pos1 to:pos2 |
|
1553 | 410 |
withEmphasis:(preferences commentEmphasis) |
411 |
color:(preferences commentColor) |
|
662 | 412 |
|
1550 | 413 |
" |
414 |
UserPreferences current commentEmphasis |
|
415 |
" |
|
416 |
"Modified: / 31.3.1998 / 18:01:55 / cg" |
|
662 | 417 |
! |
418 |
||
419 |
markConstantFrom:pos1 to:pos2 |
|
420 |
self |
|
421 |
markFrom:pos1 to:pos2 |
|
1553 | 422 |
withEmphasis:(preferences constantEmphasis) |
423 |
color:(preferences constantColor) |
|
662 | 424 |
|
425 |
"Modified: / 31.3.1998 / 18:01:44 / cg" |
|
426 |
"Created: / 31.3.1998 / 18:09:22 / cg" |
|
427 |
! |
|
428 |
||
2055 | 429 |
markFrom:pos1 to:pos2 withAddedEmphasis:addedEmphasis |
430 |
sourceText emphasisFrom:pos1 to:pos2 add:addedEmphasis |
|
431 |
||
432 |
"Created: / 15-01-2008 / 11:48:18 / cg" |
|
433 |
! |
|
434 |
||
987
49a05e400448
aquire device colors - faster on pseudoColor devices.
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
435 |
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
|
436 |
|e p2 clr| |
49a05e400448
aquire device colors - faster on pseudoColor devices.
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
437 |
|
49a05e400448
aquire device colors - faster on pseudoColor devices.
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
438 |
clr := clrIn onDevice:Screen current. |
662 | 439 |
|
669 | 440 |
clr = Color black ifTrue:[ |
441 |
e := fontEmp |
|
442 |
] ifFalse:[ |
|
948
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
443 |
fontEmp isNil ifTrue:[ |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
444 |
e := (#color->clr) |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
445 |
] ifFalse:[ |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
446 |
e := Text addEmphasis:fontEmp to:(#color->clr). |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
447 |
] |
669 | 448 |
]. |
948
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
449 |
(p2 := pos2) isNil ifTrue:[ |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
450 |
p2 := sourceText size |
1143 | 451 |
] ifFalse:[ |
452 |
p2 := p2 min:sourceText size |
|
948
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
453 |
]. |
6ba29fe774f2
show earliest possible error position.
Claus Gittinger <cg@exept.de>
parents:
902
diff
changeset
|
454 |
sourceText emphasizeFrom:pos1 to:p2 with:e |
662 | 455 |
|
456 |
"Created: / 31.3.1998 / 13:26:53 / cg" |
|
669 | 457 |
"Modified: / 1.4.1998 / 12:51:56 / cg" |
662 | 458 |
! |
459 |
||
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
460 |
markGlobalClassIdentifierFrom:pos1 to:pos2 |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
461 |
self |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
462 |
markFrom:pos1 to:pos2 |
1553 | 463 |
withEmphasis:(preferences globalClassIdentifierEmphasis) |
464 |
color:(preferences globalClassIdentifierColor) |
|
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
465 |
|
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
466 |
"Modified: / 31.3.1998 / 18:02:14 / cg" |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
467 |
"Created: / 4.3.1999 / 12:53:02 / cg" |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
468 |
! |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
469 |
|
662 | 470 |
markGlobalIdentifierFrom:pos1 to:pos2 |
471 |
self |
|
472 |
markFrom:pos1 to:pos2 |
|
1553 | 473 |
withEmphasis:(preferences globalIdentifierEmphasis) |
474 |
color:(preferences globalIdentifierColor) |
|
662 | 475 |
|
476 |
"Modified: / 31.3.1998 / 18:02:14 / cg" |
|
477 |
! |
|
478 |
||
479 |
markHereFrom:pos1 to:pos2 |
|
480 |
self |
|
481 |
markFrom:pos1 to:pos2 |
|
1553 | 482 |
withEmphasis:(preferences hereEmphasis) |
483 |
color:(preferences hereColor) |
|
662 | 484 |
|
485 |
"Modified: / 31.3.1998 / 18:02:25 / cg" |
|
486 |
! |
|
487 |
||
488 |
markIdentifierFrom:pos1 to:pos2 |
|
489 |
self |
|
490 |
markFrom:pos1 to:pos2 |
|
1553 | 491 |
withEmphasis:(preferences identifierEmphasis) |
492 |
color:(preferences identifierColor) |
|
662 | 493 |
|
494 |
"Modified: / 31.3.1998 / 18:02:39 / cg" |
|
495 |
"Created: / 31.3.1998 / 18:04:56 / cg" |
|
496 |
! |
|
497 |
||
686 | 498 |
markInstVarIdentifierFrom:pos1 to:pos2 |
499 |
self |
|
500 |
markFrom:pos1 to:pos2 |
|
1553 | 501 |
withEmphasis:(preferences instVarIdentifierEmphasis) |
502 |
color:(preferences instVarIdentifierColor) |
|
686 | 503 |
|
504 |
"Created: / 16.4.1998 / 18:35:40 / cg" |
|
505 |
"Modified: / 16.4.1998 / 18:37:30 / cg" |
|
506 |
! |
|
507 |
||
662 | 508 |
markLocalIdentifierFrom:pos1 to:pos2 |
1802 | 509 |
cachedLocalIdentifierEmphasis isNil ifTrue:[ |
510 |
cachedLocalIdentifierEmphasis := preferences localIdentifierEmphasis. |
|
511 |
cachedLocalIdentifierColor := preferences localIdentifierColor. |
|
512 |
]. |
|
662 | 513 |
self |
514 |
markFrom:pos1 to:pos2 |
|
1802 | 515 |
withEmphasis:cachedLocalIdentifierEmphasis |
516 |
color:cachedLocalIdentifierColor |
|
662 | 517 |
|
518 |
"Modified: / 31.3.1998 / 18:02:39 / cg" |
|
519 |
! |
|
520 |
||
521 |
markMethodSelectorFrom:pos1 to:pos2 |
|
522 |
self |
|
523 |
markFrom:pos1 to:pos2 |
|
1553 | 524 |
withEmphasis:(preferences methodSelectorEmphasis) |
525 |
color:(preferences methodSelectorColor) |
|
662 | 526 |
|
527 |
"Modified: / 31.3.1998 / 18:02:52 / cg" |
|
528 |
! |
|
529 |
||
1684 | 530 |
markNumberConstantFrom:pos1 to:pos2 |
531 |
self |
|
532 |
markFrom:pos1 to:pos2 |
|
533 |
withEmphasis:(preferences numberConstantEmphasis) |
|
534 |
color:(preferences numberConstantColor) |
|
535 |
||
536 |
"Modified: / 31.3.1998 / 18:01:44 / cg" |
|
537 |
"Created: / 31.3.1998 / 18:09:22 / cg" |
|
538 |
! |
|
539 |
||
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
540 |
markParenthesisAt:pos |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
541 |
|colors clr em| |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
542 |
|
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
543 |
preferences emphasizeParenthesisLevel ifFalse:[^ self]. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
544 |
|
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
545 |
colors := Array |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
546 |
with:(Color black) |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
547 |
with:(Color blue) |
1757 | 548 |
with:(Color green blendWith:(Color grey:30)) |
549 |
with:(Color red blendWith:(Color grey:30)) |
|
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
550 |
with:(Color yellow darkened). |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
551 |
|
1757 | 552 |
clr := colors at:((parenthesisLevel-1) \\ colors size + 1). |
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
553 |
em := #normal. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
554 |
parenthesisLevel > 1 ifTrue:[ |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
555 |
em := #bold. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
556 |
]. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
557 |
self |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
558 |
markFrom:pos to:pos |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
559 |
withEmphasis:em |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
560 |
color:clr |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
561 |
! |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
562 |
|
1553 | 563 |
markPoolVariableIdentifierFrom:pos1 to:pos2 |
564 |
self |
|
565 |
markFrom:pos1 to:pos2 |
|
566 |
withEmphasis:(preferences poolVariableIdentifierEmphasis) |
|
567 |
color:(preferences poolVariableIdentifierColor) |
|
568 |
! |
|
569 |
||
838 | 570 |
markReturnAt:pos |
571 |
self |
|
572 |
markFrom:pos to:pos |
|
1553 | 573 |
withEmphasis:(preferences returnEmphasis) |
574 |
color:(preferences returnColor) |
|
838 | 575 |
|
576 |
"Modified: / 31.3.1998 / 19:36:44 / cg" |
|
577 |
"Created: / 5.1.1980 / 00:44:27 / cg" |
|
578 |
! |
|
579 |
||
863 | 580 |
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
|
581 |
|fg selectorSymbol check ok rec em| |
863 | 582 |
|
583 |
"/ uncommenting the code below |
|
584 |
"/ will suppress highlighting of common selectors ... |
|
585 |
"/ |
|
586 |
"/ (#( |
|
587 |
"/ 'ifTrue:' |
|
588 |
"/ 'ifFalse:' |
|
589 |
"/ 'not' |
|
590 |
"/ 'and:' |
|
591 |
"/ 'or:' |
|
592 |
"/ '=' |
|
593 |
"/ '==' |
|
594 |
"/ '~=' |
|
595 |
"/ '~~' |
|
596 |
"/ ) includes:sel) ifTrue:[ |
|
597 |
"/ ^ self |
|
598 |
"/ ]. |
|
599 |
||
1526 | 600 |
fg := preferences selectorColor. |
601 |
em := preferences selectorEmphasis. |
|
1498
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
602 |
selectorSymbol := selectorString asSymbolIfInterned. |
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
603 |
selectorSymbol isNil ifTrue:[ |
1905 | 604 |
em := preferences unimplementedSelectorEmphasis. |
605 |
fg := preferences unimplementedSelectorColor. |
|
1498
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
606 |
] ifFalse:[ |
1905 | 607 |
ok := true. |
608 |
||
863 | 609 |
fullSelectorCheck == true ifTrue:[ |
610 |
||
1498
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
611 |
check := [:cls | (cls includesSelector:selectorSymbol) |
9b4366551a2a
speed up symbol checking and generation
Stefan Vogel <sv@exept.de>
parents:
1396
diff
changeset
|
612 |
or:[cls class includesSelector:selectorSymbol]]. |
863 | 613 |
|
614 |
ok := false. |
|
615 |
||
616 |
"/ limit search if possible |
|
617 |
(classToCompileFor notNil |
|
618 |
and:[aReceiverNode isSelf or:[aReceiverNode isSuper]]) ifTrue:[ |
|
619 |
currentSuperclasses isNil ifTrue:[ |
|
620 |
currentSuperclasses := classToCompileFor withAllSuperclasses. |
|
621 |
]. |
|
622 |
ok := currentSuperclasses contains:check. |
|
623 |
(ok not and:[aReceiverNode isSelf]) ifTrue:[ |
|
624 |
currentSubclasses isNil ifTrue:[ |
|
625 |
currentSubclasses := classToCompileFor allSubclasses. |
|
626 |
]. |
|
627 |
ok := currentSubclasses contains:check. |
|
628 |
]. |
|
629 |
] ifFalse:[ |
|
630 |
aReceiverNode isConstant ifTrue:[ |
|
631 |
ok := aReceiverNode evaluate class withAllSuperclasses contains:check. |
|
632 |
] ifFalse:[ |
|
633 |
(aReceiverNode isGlobal |
|
634 |
and:[(rec := aReceiverNode evaluate) isBehavior]) ifTrue:[ |
|
635 |
ok := rec class withAllSuperclasses contains:check. |
|
636 |
] ifFalse:[ |
|
637 |
ok := Smalltalk allClasses contains:check |
|
638 |
] |
|
639 |
] |
|
640 |
]. |
|
1905 | 641 |
]. |
642 |
ok ifFalse:[ |
|
643 |
em := preferences unimplementedSelectorEmphasis. |
|
644 |
fg := preferences unimplementedSelectorColor. |
|
645 |
] ifTrue:[ |
|
646 |
(self controlFlowSelectors includesIdentical:selectorSymbol) ifTrue:[ |
|
647 |
em := preferences controlFlowSelectorEmphasis. |
|
648 |
fg := preferences controlFlowSelectorColor. |
|
649 |
]. |
|
650 |
]. |
|
863 | 651 |
]. |
652 |
self |
|
653 |
markFrom:pos1 to:pos2 |
|
1553 | 654 |
withEmphasis:em |
655 |
color:fg |
|
863 | 656 |
|
1905 | 657 |
"Modified: / 08-09-2006 / 15:57:02 / cg" |
863 | 658 |
! |
659 |
||
662 | 660 |
markSelfFrom:pos1 to:pos2 |
661 |
self |
|
662 |
markFrom:pos1 to:pos2 |
|
1553 | 663 |
withEmphasis:(preferences selfEmphasis) |
664 |
color:(preferences selfColor) |
|
662 | 665 |
|
666 |
"Modified: / 31.3.1998 / 18:03:10 / cg" |
|
667 |
! |
|
668 |
||
669 |
markStringFrom:pos1 to:pos2 |
|
1802 | 670 |
cachedStringEmphasis isNil ifTrue:[ |
671 |
cachedStringEmphasis := preferences stringEmphasis. |
|
672 |
cachedStringColor := preferences stringColor. |
|
673 |
]. |
|
662 | 674 |
self |
675 |
markFrom:pos1 to:pos2 |
|
1802 | 676 |
withEmphasis:cachedStringEmphasis |
677 |
color:cachedStringColor |
|
662 | 678 |
|
679 |
"Modified: / 31.3.1998 / 18:03:18 / cg" |
|
680 |
! |
|
681 |
||
682 |
markSuperFrom:pos1 to:pos2 |
|
683 |
self |
|
684 |
markFrom:pos1 to:pos2 |
|
1553 | 685 |
withEmphasis:(preferences superEmphasis) |
686 |
color:(preferences superColor) |
|
662 | 687 |
|
688 |
"Modified: / 31.3.1998 / 18:03:26 / cg" |
|
689 |
! |
|
690 |
||
672 | 691 |
markSymbolFrom:pos1 to:pos2 |
692 |
self |
|
693 |
markFrom:pos1 to:pos2 |
|
1553 | 694 |
withEmphasis:(preferences symbolEmphasis) |
695 |
color:(preferences symbolColor) |
|
672 | 696 |
|
697 |
"Created: / 1.4.1998 / 12:56:47 / cg" |
|
698 |
"Modified: / 1.4.1998 / 12:58:00 / cg" |
|
699 |
! |
|
700 |
||
662 | 701 |
markThisContextFrom:pos1 to:pos2 |
702 |
self |
|
703 |
markFrom:pos1 to:pos2 |
|
1553 | 704 |
withEmphasis:(preferences thisContextEmphasis) |
705 |
color:(preferences thisContextColor) |
|
662 | 706 |
|
707 |
"Modified: / 31.3.1998 / 18:03:36 / cg" |
|
665 | 708 |
! |
709 |
||
710 |
markUnknownIdentifierFrom:pos1 to:pos2 |
|
711 |
self |
|
712 |
markFrom:pos1 to:pos2 |
|
1553 | 713 |
withEmphasis:(preferences unknownIdentifierEmphasis) |
714 |
color:(preferences unknownIdentifierColor) |
|
665 | 715 |
|
716 |
"Created: / 31.3.1998 / 19:09:26 / cg" |
|
717 |
"Modified: / 31.3.1998 / 19:10:30 / cg" |
|
686 | 718 |
! |
719 |
||
720 |
markVariable:v |
|
721 |
"support for syntaxColoring" |
|
722 |
||
723 |
|pos endPos| |
|
724 |
||
725 |
pos := tokenPosition. |
|
726 |
endPos := pos+tokenName size-1. |
|
727 |
self markVariable:v from:pos to:endPos |
|
728 |
||
729 |
"Modified: / 16.4.1998 / 18:49:51 / cg" |
|
730 |
! |
|
731 |
||
732 |
markVariable:v from:pos to:endPos |
|
733 |
"support for syntaxColoring" |
|
734 |
||
823 | 735 |
|type globalValue nameSym| |
686 | 736 |
|
737 |
type := v type. |
|
738 |
(type == #BlockArg |
|
739 |
or:[type == #MethodArg]) ifTrue:[ |
|
740 |
self markArgumentIdentifierFrom:pos to:endPos. |
|
741 |
^ self |
|
742 |
]. |
|
743 |
(type == #BlockVariable |
|
744 |
or:[type == #MethodVariable]) ifTrue:[ |
|
745 |
self markLocalIdentifierFrom:pos to:endPos. |
|
746 |
^ self |
|
747 |
]. |
|
748 |
(type == #GlobalVariable) ifTrue:[ |
|
823 | 749 |
nameSym := v name asSymbolIfInterned. |
750 |
nameSym notNil ifTrue:[ |
|
751 |
globalValue := Smalltalk at:nameSym ifAbsent:nil. |
|
752 |
]. |
|
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
753 |
globalValue isBehavior ifTrue:[ |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
754 |
self markGlobalClassIdentifierFrom:pos to:endPos. |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
755 |
] ifFalse:[ |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
756 |
self markGlobalIdentifierFrom:pos to:endPos. |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
757 |
]. |
686 | 758 |
^ self |
759 |
]. |
|
1553 | 760 |
(type == #PoolVariable) ifTrue:[ |
761 |
self markPoolVariableIdentifierFrom:pos to:endPos. |
|
762 |
^ self |
|
763 |
]. |
|
870 | 764 |
(type == #ClassVariable) ifTrue:[ |
765 |
self markClassVariableIdentifierFrom:pos to:endPos. |
|
766 |
^ self |
|
767 |
]. |
|
686 | 768 |
(type == #InstanceVariable) ifTrue:[ |
769 |
self markInstVarIdentifierFrom:pos to:endPos. |
|
770 |
^ self |
|
771 |
]. |
|
772 |
||
773 |
self markIdentifierFrom:pos to:endPos. |
|
774 |
||
775 |
"Created: / 16.4.1998 / 18:49:34 / cg" |
|
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
776 |
"Modified: / 4.3.1999 / 12:56:13 / cg" |
662 | 777 |
! ! |
778 |
||
779 |
!SyntaxHighlighter class methodsFor:'documentation'! |
|
780 |
||
781 |
version |
|
2087
42c0f2fe415d
Do not write Warning messages about parse errors
Stefan Vogel <sv@exept.de>
parents:
2070
diff
changeset
|
782 |
^ '$Header: /cvs/stx/stx/libcomp/SyntaxHighlighter.st,v 1.57 2008-04-19 12:56:46 stefan Exp $' |
662 | 783 |
! ! |