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