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