author | Jan Vrany <jan.vrany@labware.com> |
Thu, 27 Oct 2022 14:53:59 +0100 | |
branch | jv |
changeset 4735 | 3b11fb3ede98 |
parent 4315 | 734f7d2b6efe |
permissions | -rw-r--r-- |
2372 | 1 |
" |
2 |
COPYRIGHT (c) 2010 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 |
" |
|
12 |
"{ Package: 'stx:libcomp' }" |
|
13 |
||
3606
d5540813bb30
class: CodeCoverageHighlighter
Claus Gittinger <cg@exept.de>
parents:
3496
diff
changeset
|
14 |
"{ NameSpace: Smalltalk }" |
d5540813bb30
class: CodeCoverageHighlighter
Claus Gittinger <cg@exept.de>
parents:
3496
diff
changeset
|
15 |
|
2372 | 16 |
AbstractSyntaxHighlighter subclass:#CodeCoverageHighlighter |
2524 | 17 |
instanceVariableNames:'methodInvocationInfo cachedColorForCoveredCode |
2372 | 18 |
cachedColorForUncoveredCode' |
19 |
classVariableNames:'' |
|
20 |
poolDictionaries:'' |
|
21 |
category:'System-Compiler' |
|
22 |
! |
|
23 |
||
24 |
!CodeCoverageHighlighter class methodsFor:'documentation'! |
|
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 2010 by eXept Software AG |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
colors a method according to some methodInvocationInfo. |
|
43 |
" |
|
44 |
! ! |
|
45 |
||
46 |
!CodeCoverageHighlighter methodsFor:'accessing'! |
|
47 |
||
48 |
colorForCoveredCode |
|
49 |
cachedColorForCoveredCode isNil ifTrue:[ |
|
50 |
cachedColorForCoveredCode := UserPreferences current colorForInstrumentedFullyCoveredCode |
|
51 |
]. |
|
52 |
^ cachedColorForCoveredCode |
|
53 |
||
54 |
"Created: / 28-04-2010 / 12:38:51 / cg" |
|
55 |
"Modified: / 28-04-2010 / 14:08:10 / cg" |
|
56 |
! |
|
57 |
||
58 |
colorForUncoveredCode |
|
59 |
cachedColorForUncoveredCode isNil ifTrue:[ |
|
60 |
cachedColorForUncoveredCode := UserPreferences current colorForInstrumentedNeverCalledCode |
|
61 |
]. |
|
62 |
^ cachedColorForUncoveredCode |
|
63 |
||
64 |
"Created: / 28-04-2010 / 12:38:51 / cg" |
|
65 |
"Modified: / 28-04-2010 / 14:08:16 / cg" |
|
66 |
! |
|
67 |
||
68 |
method:aMethod |
|
69 |
method := aMethod. |
|
70 |
self updateMethodInvocationInfo. |
|
71 |
||
72 |
"Modified: / 28-04-2010 / 13:22:16 / cg" |
|
73 |
! |
|
74 |
||
75 |
methodInvocationInfo:something |
|
76 |
methodInvocationInfo := something. |
|
77 |
||
78 |
"Modified: / 28-04-2010 / 13:38:56 / cg" |
|
79 |
! |
|
80 |
||
81 |
sourceText:aString |
|
82 |
sourceText := aString. |
|
83 |
self updateMethodInvocationInfo. |
|
84 |
||
85 |
"Created: / 28-04-2010 / 13:22:35 / cg" |
|
86 |
! |
|
87 |
||
88 |
updateMethodInvocationInfo |
|
89 |
(method notNil |
|
90 |
and:[ method isInstrumented |
|
91 |
and:[ method source asString string asStringCollection withTabsExpanded asString |
|
92 |
= sourceText asString string asStringCollection withTabsExpanded asString]]) ifTrue:[ |
|
93 |
methodInvocationInfo := method methodInvocationInfo |
|
94 |
] ifFalse:[ |
|
95 |
methodInvocationInfo := nil |
|
96 |
]. |
|
97 |
||
98 |
"Created: / 28-04-2010 / 13:22:02 / cg" |
|
99 |
"Modified: / 28-04-2010 / 14:32:02 / cg" |
|
100 |
! ! |
|
101 |
||
102 |
!CodeCoverageHighlighter methodsFor:'syntax detection'! |
|
103 |
||
104 |
markArgumentIdentifierFrom:pos1 to:pos2 |
|
3606
d5540813bb30
class: CodeCoverageHighlighter
Claus Gittinger <cg@exept.de>
parents:
3496
diff
changeset
|
105 |
"intentionally left empty" |
2372 | 106 |
! |
107 |
||
108 |
markBlockFrom:pos1 to:pos2 |
|
109 |
"/ methodInvocationInfo notNil ifTrue:[ |
|
110 |
"/ method blockInvocationInfo do:[:eachBlockInfo | |
|
111 |
"/ eachBlockInfo characterPosition = pos1 ifTrue:[ |
|
112 |
"/ eachBlockInfo hasBeenExecuted ifTrue:[ |
|
113 |
"/ sourceText |
|
114 |
"/ emphasizeFrom:pos1 to:pos2 |
|
115 |
"/ with:#color->self colorForCoveredCode. |
|
116 |
"/ "/ with:#backgroundColor->self colorForCoveredCode lightened lightened lightened. |
|
117 |
"/ ^ self. |
|
118 |
"/ ]. |
|
119 |
"/ ]. |
|
120 |
"/ ]. |
|
121 |
"/ ]. |
|
122 |
"/ |
|
123 |
"/ sourceText |
|
124 |
"/ emphasizeFrom:pos1 to:pos2 |
|
125 |
"/ with:#color->self colorForUncoveredCode. |
|
126 |
"/ "/ with:#backgroundColor->self colorForUncoveredCode lightened lightened lightened. |
|
127 |
"/ |
|
128 |
"/ |
|
129 |
||
130 |
"Modified: / 28-04-2010 / 15:49:34 / cg" |
|
131 |
! |
|
132 |
||
133 |
markBracketAt:pos |
|
134 |
|level colors clr em| |
|
135 |
||
136 |
preferences emphasizeParenthesisLevel ifFalse:[ |
|
137 |
self |
|
138 |
markFrom:pos to:pos |
|
139 |
withEmphasis:(preferences bracketEmphasis) |
|
140 |
color:(preferences bracketColor). |
|
141 |
||
142 |
^ self |
|
143 |
]. |
|
144 |
||
145 |
level := currentBlock isNil ifTrue:[1] ifFalse:[currentBlock nestingLevel + 2]. |
|
146 |
(sourceText at:pos) = $] ifTrue:[ |
|
147 |
level := level - 1. |
|
148 |
]. |
|
149 |
||
150 |
colors := Array |
|
151 |
with:(Color black) |
|
152 |
with:(Color blue) |
|
153 |
with:(Color green blendWith:(Color grey:30)) |
|
154 |
with:(Color red blendWith:(Color grey:30)) |
|
155 |
with:(Color yellow darkened). |
|
156 |
||
157 |
clr := colors at:((level-1) \\ colors size + 1). |
|
158 |
em := #normal. |
|
159 |
level > 1 ifTrue:[ |
|
160 |
em := #bold. |
|
161 |
]. |
|
162 |
self |
|
163 |
markFrom:pos to:pos |
|
164 |
withEmphasis:em |
|
165 |
color:clr |
|
166 |
! |
|
167 |
||
168 |
markCommentFrom:pos1 to:pos2 |
|
169 |
self |
|
170 |
markFrom:pos1 to:pos2 |
|
171 |
withEmphasis:(preferences commentEmphasis) |
|
3496
0c9b5f469f78
class: CodeCoverageHighlighter
Claus Gittinger <cg@exept.de>
parents:
2670
diff
changeset
|
172 |
color:(Color gray "preferences commentColor") |
2372 | 173 |
|
174 |
" |
|
175 |
UserPreferences current commentEmphasis |
|
176 |
" |
|
2495
41b9af0fcb20
changed: #markCommentFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2372
diff
changeset
|
177 |
|
41b9af0fcb20
changed: #markCommentFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2372
diff
changeset
|
178 |
"Modified: / 24-05-2011 / 19:43:31 / cg" |
2372 | 179 |
! |
180 |
||
2670
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
181 |
markMethodArgumentIdentifierFrom:pos1 to:pos2 |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
182 |
self |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
183 |
markFrom:pos1 to:pos2 |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
184 |
withEmphasis:(preferences argumentIdentifierEmphasis) |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
185 |
color:(preferences argumentIdentifierColor) |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
186 |
|
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
187 |
"Created: / 21-08-2011 / 08:12:29 / cg" |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
188 |
! |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
189 |
|
2372 | 190 |
markMethodSelectorFrom:pos1 to:pos2 |
191 |
|clr| |
|
192 |
||
2670
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
193 |
"/ methodInvocationInfo notNil ifTrue:[ |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
194 |
"/ methodInvocationInfo hasBeenCalled ifTrue:[ |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
195 |
"/ clr := self colorForCoveredCode |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
196 |
"/ ] ifFalse:[ |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
197 |
"/ clr := self colorForUncoveredCode |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
198 |
"/ ]. |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
199 |
"/ ]. |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
200 |
"/ clr notNil ifTrue:[ |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
201 |
"/ "/ sourceText emphasizeFrom:1 to:sourceText size with:(#backgroundColor "#color" -> clr lightened lightened). |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
202 |
"/ sourceText emphasizeFrom:1 to:sourceText size with:(#color -> clr). |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
203 |
"/ ]. |
2372 | 204 |
|
205 |
self |
|
206 |
markFrom:pos1 to:pos2 |
|
207 |
withEmphasis:(preferences methodSelectorEmphasis) |
|
2670
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
208 |
color:(clr ? preferences methodSelectorColor). |
2372 | 209 |
|
210 |
"/ emp notNil ifTrue:[ |
|
211 |
"/ sourceText emphasisFrom:1 to:sourceText size add:emp. |
|
212 |
"/ ]. |
|
213 |
||
2670
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
214 |
"Modified: / 21-08-2011 / 08:10:36 / cg" |
2372 | 215 |
! |
216 |
||
217 |
markUnknownIdentifierFrom:pos1 to:pos2 |
|
218 |
self |
|
219 |
markFrom:pos1 to:pos2 |
|
220 |
withEmphasis:(preferences unknownIdentifierEmphasis) |
|
221 |
color:(preferences unknownIdentifierColor) |
|
222 |
||
223 |
"Created: / 31.3.1998 / 19:09:26 / cg" |
|
224 |
"Modified: / 31.3.1998 / 19:10:30 / cg" |
|
225 |
! |
|
226 |
||
227 |
parseMethod |
|
2670
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
228 |
|clr| |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
229 |
|
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
230 |
methodInvocationInfo notNil ifTrue:[ |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
231 |
methodInvocationInfo hasBeenCalled ifTrue:[ |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
232 |
clr := self colorForCoveredCode |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
233 |
] ifFalse:[ |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
234 |
clr := self colorForUncoveredCode |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
235 |
]. |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
236 |
"/ sourceText emphasizeFrom:1 to:sourceText size with:(#backgroundColor "#color" -> clr lightened lightened). |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
237 |
sourceText emphasizeFrom:1 to:sourceText size with:(#color -> clr). |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
238 |
]. |
5e72a9b660d3
added: #markMethodArgumentIdentifierFrom:to:
Claus Gittinger <cg@exept.de>
parents:
2581
diff
changeset
|
239 |
|
2372 | 240 |
super parseMethod. |
241 |
||
242 |
methodInvocationInfo notNil ifTrue:[ |
|
243 |
(method blockInvocationInfo copy sort:[:a :b | a startPosition < b startPosition]) |
|
244 |
do:[:eachBlockInfo | |
|
245 |
|pos clr| |
|
246 |
||
247 |
clr := eachBlockInfo hasBeenExecuted |
|
248 |
ifTrue:[ self colorForCoveredCode ] |
|
249 |
ifFalse:[ self colorForUncoveredCode ]. |
|
250 |
sourceText |
|
251 |
emphasizeFrom:eachBlockInfo startPosition to:eachBlockInfo endPosition |
|
2581
4a9ed916d6f1
experimented with background color - but it looks ugly
Claus Gittinger <cg@exept.de>
parents:
2524
diff
changeset
|
252 |
"/ with:(#backgroundColor "#color" -> clr lightened lightened) |
2372 | 253 |
with:#color->clr. |
254 |
] |
|
255 |
]. |
|
256 |
||
257 |
"Created: / 28-04-2010 / 15:49:27 / cg" |
|
258 |
! ! |
|
259 |
||
260 |
!CodeCoverageHighlighter class methodsFor:'documentation'! |
|
261 |
||
262 |
version_CVS |
|
3606
d5540813bb30
class: CodeCoverageHighlighter
Claus Gittinger <cg@exept.de>
parents:
3496
diff
changeset
|
263 |
^ '$Header: /cvs/stx/stx/libcomp/CodeCoverageHighlighter.st,v 1.7 2015-02-28 00:54:47 cg Exp $' |
2372 | 264 |
! ! |
3496
0c9b5f469f78
class: CodeCoverageHighlighter
Claus Gittinger <cg@exept.de>
parents:
2670
diff
changeset
|
265 |