author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 29 Jul 2013 20:55:42 +0200 | |
changeset 213 | 2c6346e43dc0 |
parent 193 | 9171e507b523 |
child 214 | 99e04c6e23fb |
permissions | -rw-r--r-- |
167 | 1 |
"{ Package: 'stx:goodies/builder/reports' }" |
2 |
||
3 |
"{ NameSpace: Builder }" |
|
4 |
||
5 |
ReportFormat subclass:#CoverageReportFormat |
|
6 |
instanceVariableNames:'' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'Builder-Reports-Formats' |
|
10 |
! |
|
11 |
||
12 |
CoverageReportFormat subclass:#Cobertura |
|
183
4e6fc1b6c282
Fixes in Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
182
diff
changeset
|
13 |
instanceVariableNames:'currentPackage currentClass currentClassLinesBuffer currentMethod |
4e6fc1b6c282
Fixes in Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
182
diff
changeset
|
14 |
infos' |
167 | 15 |
classVariableNames:'' |
16 |
poolDictionaries:'' |
|
17 |
privateIn:CoverageReportFormat |
|
18 |
! |
|
19 |
||
193
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
20 |
Parser subclass:#MethodAnalyzer |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
21 |
instanceVariableNames:'intervals branches' |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
22 |
classVariableNames:'' |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
23 |
poolDictionaries:'' |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
24 |
privateIn:CoverageReportFormat::Cobertura |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
25 |
! |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
26 |
|
167 | 27 |
|
28 |
!CoverageReportFormat class methodsFor:'testing'! |
|
29 |
||
30 |
isAbstract |
|
31 |
^self == CoverageReportFormat |
|
32 |
||
33 |
"Created: / 04-08-2011 / 11:44:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
34 |
"Modified: / 25-06-2013 / 01:26:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
213
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
35 |
"Modified (format): / 29-07-2013 / 19:55:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
167 | 36 |
! ! |
37 |
||
38 |
!CoverageReportFormat::Cobertura class methodsFor:'accessing'! |
|
39 |
||
40 |
symbolicNames |
|
41 |
"Returns a collection of symbolic names for this format" |
|
42 |
||
43 |
^ self shouldImplement |
|
44 |
! ! |
|
45 |
||
46 |
!CoverageReportFormat::Cobertura class methodsFor:'documentation'! |
|
47 |
||
48 |
documentation |
|
49 |
" } |
|
50 |
||
51 |
Replace 'Object', 'NewClass1' and |
|
52 |
the empty string arguments by true values. |
|
53 |
||
54 |
Install (or change) the class by 'accepting', |
|
55 |
either via the menu or the keyboard (usually CMD-A). |
|
56 |
||
57 |
You can also change the category simply by editing |
|
58 |
the categoryString and accepting. |
|
59 |
||
60 |
To be nice to others (and yourself later), do not forget to |
|
61 |
add some documentation; preferably under the classes documentation |
|
62 |
protocol. |
|
63 |
(see the `create documentation stubs' item in the methodList menu; |
|
64 |
switch from instance to class to find this menu item.) |
|
65 |
||
66 |
Notice, that ST/X uses the convention to document the class using |
|
67 |
comment-only class methods (however, ST80 comments are supported and |
|
68 |
can be changed via the class-documentation menu). |
|
69 |
||
70 |
" |
|
71 |
! ! |
|
72 |
||
73 |
!CoverageReportFormat::Cobertura methodsFor:'accessing - defaults'! |
|
74 |
||
75 |
defaultFileSuffix |
|
76 |
"superclass Builder::ReportFormat says that I am responsible to implement this method" |
|
77 |
||
78 |
^ 'xml' |
|
79 |
||
80 |
"Modified: / 25-06-2013 / 02:02:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
81 |
! ! |
|
82 |
||
213
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
83 |
!CoverageReportFormat::Cobertura methodsFor:'private'! |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
84 |
|
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
85 |
sourceInfoForClass: class inPackage: package |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
86 |
| infosPerPackage cls | |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
87 |
|
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
88 |
cls := class. |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
89 |
cls isMetaclass ifTrue:[ |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
90 |
cls := cls theNonMetaclass |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
91 |
]. |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
92 |
cls isPrivate ifTrue:[ |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
93 |
cls := cls topOwningClass. |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
94 |
]. |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
95 |
infosPerPackage := infos at: package ifAbsentPut:[Dictionary new]. |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
96 |
^ infosPerPackage at: class ifAbsentPut: [ReportSourceInfo forClass: cls inPackage: package]. |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
97 |
|
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
98 |
"Created: / 29-07-2013 / 18:43:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
99 |
! |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
100 |
|
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
101 |
sourceInfoForExtensionsinPackage: package |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
102 |
| infosPerPackage | |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
103 |
|
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
104 |
infosPerPackage := infos at: package ifAbsentPut:[Dictionary new]. |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
105 |
^ infosPerPackage at: 'extensions.st' ifAbsentPut: [ReportSourceInfo forExtensionsInPackage: package]. |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
106 |
|
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
107 |
"Created: / 29-07-2013 / 18:43:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
108 |
! ! |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
109 |
|
167 | 110 |
!CoverageReportFormat::Cobertura methodsFor:'writing'! |
111 |
||
112 |
write: instrumentedMethods |
|
113 |
| packageMap | |
|
114 |
||
115 |
packageMap := Dictionary new. |
|
116 |
infos := Dictionary new. |
|
117 |
instrumentedMethods do:[:method| |
|
183
4e6fc1b6c282
Fixes in Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
182
diff
changeset
|
118 |
| classMap methodSet | |
167 | 119 |
classMap := packageMap at: method package ifAbsentPut: [ Dictionary new ]. |
186
b53f4cc947e1
Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
183
diff
changeset
|
120 |
methodSet := classMap at: method mclass theNonMetaclass ifAbsentPut: [ Set new ]. |
183
4e6fc1b6c282
Fixes in Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
182
diff
changeset
|
121 |
methodSet add: method. |
167 | 122 |
]. |
123 |
||
124 |
packageMap keys asSortedCollection do:[:package| |
|
125 |
| classMap | |
|
126 |
||
127 |
self writePackage: package with:[ |
|
128 |
((classMap := packageMap at: package) keys asSortedCollection:[:a :b| a name < b name ]) do:[:class| |
|
183
4e6fc1b6c282
Fixes in Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
182
diff
changeset
|
129 |
| methodSet | |
167 | 130 |
self writeClass: class with:[ |
183
4e6fc1b6c282
Fixes in Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
182
diff
changeset
|
131 |
| methodSetOrdered info | |
167 | 132 |
|
213
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
133 |
"/ methodSetOrdered := (classMap at: class) asSortedCollection:[:a :b | (info offsetOfMethod: a) < (info offsetOfMethod: b)]. |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
134 |
methodSetOrdered := (classMap at: class) asSortedCollection:[:a :b | a selector < b selector]. |
183
4e6fc1b6c282
Fixes in Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
182
diff
changeset
|
135 |
methodSetOrdered do:[:method| |
167 | 136 |
self writeMethod: method. |
137 |
] |
|
138 |
] |
|
139 |
] |
|
140 |
] |
|
141 |
] |
|
142 |
||
143 |
"Created: / 25-06-2013 / 13:17:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
213
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
144 |
"Modified: / 29-07-2013 / 18:49:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
167 | 145 |
! |
146 |
||
147 |
writeClass: class with: content |
|
148 |
||
149 |
| className classFileName classPathName | |
|
150 |
||
151 |
className := class name. |
|
152 |
classFileName := class isPrivate |
|
182
556ad4c2c381
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
167
diff
changeset
|
153 |
ifTrue:[(Smalltalk fileNameForClass: class topOwningClass) , '.st'] |
556ad4c2c381
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
167
diff
changeset
|
154 |
ifFalse:[(Smalltalk fileNameForClass: class) , '.st']. |
167 | 155 |
class package ~~ currentPackage ifTrue:[ |
156 |
classFileName := 'extensions.st' |
|
157 |
]. |
|
158 |
classPathName := ((currentPackage copyReplaceAll: $: with: Filename separator) replaceAll: $/ with: Filename separator) |
|
159 |
, Filename separator , classFileName. |
|
160 |
||
161 |
stream nextPutAll:' <class name="'; nextPutAll: className; nextPutAll: '" filename="'; nextPutAll: classPathName; nextPutLine:'" line-rate="1.0" branch-rate="1.0" complexity="1.0">'. |
|
162 |
stream nextPutLine:' <methods>'. |
|
163 |
currentClass := class. |
|
183
4e6fc1b6c282
Fixes in Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
182
diff
changeset
|
164 |
currentClassLinesBuffer := String new writeStream. |
167 | 165 |
content value. |
166 |
currentClass := nil. |
|
167 |
stream nextPutLine:' </methods>'. |
|
183
4e6fc1b6c282
Fixes in Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
182
diff
changeset
|
168 |
stream nextPutLine:' <lines>'. |
4e6fc1b6c282
Fixes in Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
182
diff
changeset
|
169 |
stream nextPutAll: currentClassLinesBuffer contents. |
4e6fc1b6c282
Fixes in Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
182
diff
changeset
|
170 |
stream nextPutLine:' </lines>'. |
4e6fc1b6c282
Fixes in Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
182
diff
changeset
|
171 |
currentClassLinesBuffer := nil. |
167 | 172 |
stream nextPutLine:' </class>' |
173 |
||
174 |
"Created: / 25-06-2013 / 12:29:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
183
4e6fc1b6c282
Fixes in Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
182
diff
changeset
|
175 |
"Modified: / 27-06-2013 / 00:05:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
167 | 176 |
! |
177 |
||
178 |
writeFooter |
|
179 |
stream nextPutAll:' </packages> |
|
180 |
</coverage>' |
|
181 |
||
182 |
"Modified: / 25-06-2013 / 11:57:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
183 |
! |
|
184 |
||
185 |
writeHeader |
|
186 |
stream nextPutAll:'<?xml version="1.0"?> |
|
187 |
<!!--DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-03.dtd"--> |
|
188 |
||
182
556ad4c2c381
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
167
diff
changeset
|
189 |
<coverage line-rate="1.0" branch-rate="1.0" version="1.9" timestamp="'; nextPutAll: Timestamp now utcSecondsSince1970 printString; nextPutLine:'">'. |
556ad4c2c381
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
167
diff
changeset
|
190 |
stream nextPutLine:' <sources>'. |
556ad4c2c381
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
167
diff
changeset
|
191 |
Smalltalk packagePath do:[:each| |
556ad4c2c381
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
167
diff
changeset
|
192 |
stream |
556ad4c2c381
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
167
diff
changeset
|
193 |
nextPutAll: '<source>'; |
556ad4c2c381
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
167
diff
changeset
|
194 |
nextPutAll: each asFilename asAbsoluteFilename pathName; |
556ad4c2c381
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
167
diff
changeset
|
195 |
nextPutAll: '</source>'; |
556ad4c2c381
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
167
diff
changeset
|
196 |
cr. |
556ad4c2c381
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
167
diff
changeset
|
197 |
]. |
556ad4c2c381
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
167
diff
changeset
|
198 |
stream nextPutLine:' </sources>'. |
556ad4c2c381
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
167
diff
changeset
|
199 |
stream nextPutLine:' <packages>'. |
167 | 200 |
|
182
556ad4c2c381
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
167
diff
changeset
|
201 |
"Modified: / 26-06-2013 / 17:50:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
167 | 202 |
! |
203 |
||
183
4e6fc1b6c282
Fixes in Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
182
diff
changeset
|
204 |
writeLine: lineNr hits: nhits on: s |
167 | 205 |
|
183
4e6fc1b6c282
Fixes in Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
182
diff
changeset
|
206 |
s nextPutAll:' <line number="'; nextPutAll: lineNr printString; nextPutAll:'" hits="'; nextPutAll: nhits printString; nextPutLine:'" branch="false" />'. |
167 | 207 |
|
183
4e6fc1b6c282
Fixes in Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
182
diff
changeset
|
208 |
"Created: / 27-06-2013 / 00:03:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
167 | 209 |
! |
210 |
||
211 |
writeMethod: method |
|
212 |
||
193
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
213 |
| info firstCharOffset firstLineNr lastLineNr analyzer lines name | |
167 | 214 |
|
186
b53f4cc947e1
Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
183
diff
changeset
|
215 |
name := method selector. |
b53f4cc947e1
Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
183
diff
changeset
|
216 |
method mclass isMetaclass ifTrue:[ |
b53f4cc947e1
Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
183
diff
changeset
|
217 |
name := name , ' [class method]'. |
b53f4cc947e1
Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
183
diff
changeset
|
218 |
]. |
b53f4cc947e1
Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
183
diff
changeset
|
219 |
|
b53f4cc947e1
Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
183
diff
changeset
|
220 |
stream nextPutAll:' <method name="'; nextPutAll: name; nextPutLine: '" signature="" line-rate="1.0" branch-rate="1.0" complexity="1.0">'. |
167 | 221 |
stream nextPutLine:' <lines>'. |
222 |
currentMethod := method. |
|
223 |
||
213
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
224 |
info := method package == method mclass package |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
225 |
ifTrue:[self sourceInfoForClass: method mclass inPackage: method package] |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
226 |
ifFalse:[self sourceInfoForExtensionsinPackage: method package]. |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
227 |
|
167 | 228 |
firstCharOffset := info offsetOfMethod: method. |
229 |
firstLineNr := (info lineAndColumnOfOffset: firstCharOffset) x. |
|
230 |
lastLineNr := (info lineAndColumnOfOffset: firstCharOffset + method source size) x. |
|
231 |
||
192
c1bb8ec592e1
Update after changes in InstrumentingCompiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
186
diff
changeset
|
232 |
lines := Array new: lastLineNr - firstLineNr + 1 withAll: nil. |
193
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
233 |
analyzer := MethodAnalyzer new. |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
234 |
analyzer parseMethod: method source in: method mclass. |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
235 |
analyzer intervals do:[:interval| |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
236 |
| start stop | |
213
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
237 |
start := info lineAndColumnOfOffset: firstCharOffset + interval first - 1. |
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
238 |
stop := info lineAndColumnOfOffset: firstCharOffset + interval last - 1. |
193
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
239 |
start x to: stop x do:[:lineNr| |
213
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
240 |
lines at: lineNr - firstLineNr + 1 put: -1. |
193
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
241 |
]. |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
242 |
]. |
167 | 243 |
|
192
c1bb8ec592e1
Update after changes in InstrumentingCompiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
186
diff
changeset
|
244 |
(method statementInvocationInfo copy sort:[:a :b | a startPosition < b startPosition]) do:[:eachBlockInfo | |
167 | 245 |
| startLine endLine | |
246 |
||
247 |
startLine := (info lineAndColumnOfOffset: firstCharOffset + eachBlockInfo startPosition - 1) x. |
|
248 |
endLine := (info lineAndColumnOfOffset: firstCharOffset + eachBlockInfo endPosition - 1) x. |
|
249 |
startLine to: endLine do:[:lineNr| |
|
213
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
250 |
|
193
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
251 |
(lines at: (lineNr - firstLineNr + 1)) == -1 ifTrue:[ |
192
c1bb8ec592e1
Update after changes in InstrumentingCompiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
186
diff
changeset
|
252 |
lines at: (lineNr - firstLineNr + 1) put: (eachBlockInfo count) |
c1bb8ec592e1
Update after changes in InstrumentingCompiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
186
diff
changeset
|
253 |
] ifFalse:[ |
213
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
254 |
lines at: (lineNr - firstLineNr + 1) put: (((lines at: (lineNr - firstLineNr + 1)) ? (SmallInteger maxVal)) min: eachBlockInfo count) |
192
c1bb8ec592e1
Update after changes in InstrumentingCompiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
186
diff
changeset
|
255 |
] |
167 | 256 |
] |
257 |
]. |
|
258 |
1 to: lines size do:[:i| |
|
193
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
259 |
(lines at: i) notNil ifTrue:[ |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
260 |
(lines at: i) == -1 ifTrue:[ |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
261 |
lines at: i put: 0. |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
262 |
]. |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
263 |
self writeLine: (i + firstLineNr - 1) hits: ((lines at: i)) on: stream. |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
264 |
self writeLine: (i + firstLineNr - 1) hits: ((lines at: i)) on: currentClassLinesBuffer. |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
265 |
] |
167 | 266 |
]. |
267 |
||
268 |
currentMethod := nil. |
|
269 |
stream nextPutLine:' </lines>'. |
|
270 |
stream nextPutLine:' </method>' |
|
271 |
||
272 |
"Created: / 25-06-2013 / 13:17:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
213
2c6346e43dc0
class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
193
diff
changeset
|
273 |
"Modified: / 29-07-2013 / 18:57:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
167 | 274 |
! |
275 |
||
276 |
writePackage: packageName with: aBlock |
|
277 |
||
278 |
stream nextPutAll:' <package name="'; nextPutAll: packageName; nextPutLine: '" line-rate="1.0" branch-rate="1.0" complexity="1.0">'. |
|
279 |
stream nextPutLine:' <classes>'. |
|
280 |
currentPackage := packageName. |
|
281 |
aBlock value. |
|
282 |
currentPackage := nil. |
|
283 |
stream nextPutLine:' </classes>'. |
|
284 |
stream nextPutLine:' </package>' |
|
285 |
||
286 |
"Created: / 25-06-2013 / 11:55:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
287 |
"Modified: / 25-06-2013 / 13:24:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
288 |
! ! |
|
289 |
||
193
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
290 |
!CoverageReportFormat::Cobertura::MethodAnalyzer methodsFor:'accessing'! |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
291 |
|
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
292 |
branches |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
293 |
^ branches |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
294 |
! |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
295 |
|
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
296 |
intervals |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
297 |
^ intervals |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
298 |
! ! |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
299 |
|
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
300 |
!CoverageReportFormat::Cobertura::MethodAnalyzer methodsFor:'code generation hooks'! |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
301 |
|
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
302 |
statementListRewriteHookFor:aStatementNode |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
303 |
"invoked whenever a statement list node has been generated; |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
304 |
gives subclasses a chance to rewrite (instrument) it" |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
305 |
|
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
306 |
| stmt | |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
307 |
|
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
308 |
intervals isNil ifTrue:[ |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
309 |
intervals := OrderedCollection new. |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
310 |
]. |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
311 |
stmt := aStatementNode. |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
312 |
[ stmt notNil ] whileTrue:[ |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
313 |
intervals add: (stmt startPosition to: stmt endPosition). |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
314 |
stmt := stmt nextStatement. |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
315 |
]. |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
316 |
^ aStatementNode |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
317 |
|
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
318 |
"Created: / 29-07-2013 / 10:16:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
319 |
"Modified: / 29-07-2013 / 11:25:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
320 |
! ! |
9171e507b523
Report only lines which contains real code (ignoring comments, method signature and so on)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
321 |
|
167 | 322 |
!CoverageReportFormat class methodsFor:'documentation'! |
323 |
||
324 |
version |
|
325 |
^ '$Header$' |
|
326 |
! |
|
327 |
||
328 |
version_CVS |
|
329 |
^ '$Header$' |
|
330 |
! ! |
|
331 |