reports/Builder__CoverageReportFormat.st
author Claus Gittinger <cg@exept.de>
Thu, 28 Mar 2019 13:54:38 +0100
changeset 542 aa25a71be62a
parent 256 2082732c7c0c
permissions -rw-r--r--
#DOCUMENTATION by cg class: stx_goodies_builder_quickSelfTest class definition class: stx_goodies_builder_quickSelfTest class added:18 methods
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
167
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/builder/reports' }"
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"{ NameSpace: Builder }"
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
ReportFormat subclass:#CoverageReportFormat
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
	instanceVariableNames:''
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	classVariableNames:''
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
	poolDictionaries:''
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
	category:'Builder-Reports-Formats'
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
	classVariableNames:''
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
	poolDictionaries:''
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
	privateIn:CoverageReportFormat
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
!
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
!CoverageReportFormat class methodsFor:'testing'!
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
isAbstract
214
99e04c6e23fb class: Builder::CoverageReportFormat
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 213
diff changeset
    31
167
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
    ^self == CoverageReportFormat
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
    "Created: / 04-08-2011 / 11:44:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
! !
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
!CoverageReportFormat::Cobertura class methodsFor:'accessing'!
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
symbolicNames
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
    "Returns a collection of symbolic names for this format"
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
    ^ self shouldImplement
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
! !
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
!CoverageReportFormat::Cobertura class methodsFor:'documentation'!
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
documentation
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
" }
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
 Replace 'Object', 'NewClass1' and
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
 the empty string arguments by true values.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
 Install (or change) the class by 'accepting',
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
 either via the menu or the keyboard (usually CMD-A).
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
 You can also change the category simply by editing
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
 the categoryString and accepting.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
 To be nice to others (and yourself later), do not forget to
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
 add some documentation; preferably under the classes documentation
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
 protocol.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
 (see the `create documentation stubs' item in the methodList menu;
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
  switch from instance to class to find this menu item.)
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
 Notice, that ST/X uses the convention to document the class using
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
 comment-only class methods (however, ST80 comments are supported and
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
 can be changed via the class-documentation menu).
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
"
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
! !
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
!CoverageReportFormat::Cobertura methodsFor:'accessing - defaults'!
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
defaultFileSuffix
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
    "superclass Builder::ReportFormat says that I am responsible to implement this method"
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
    ^ 'xml'
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
    "Modified: / 25-06-2013 / 02:02:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
! !
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
!CoverageReportFormat::Cobertura methodsFor:'writing'!
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
write: instrumentedMethods
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   114
    | packageMap |
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   115
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
    packageMap := Dictionary new.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   117
    infos := Dictionary new.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   123
    ].
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
    packageMap keys asSortedCollection do:[:package|
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
        | classMap |            
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
        self writePackage: package with:[            
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
            ((classMap := packageMap at: package) keys asSortedCollection:[:a :b| a name < b name ]) do:[:class|
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   130
                self writeClass: class with:[
256
2082732c7c0c Fixes for Lint report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 214
diff changeset
   131
                    | methodSetOrdered |
167
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   136
                        self writeMethod: method.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   137
                    ]                    
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   138
                ]
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   139
            ]
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   140
        ]
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   141
    ]
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   142
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
2082732c7c0c Fixes for Lint report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 214
diff changeset
   145
    "Modified (format): / 15-12-2014 / 10:21:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
167
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   146
!
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   147
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   148
writeClass: class with: content
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   150
    | className classFileName classPathName |
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   151
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   152
    className := class name.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   156
    class package ~~ currentPackage ifTrue:[
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   157
        classFileName := 'extensions.st'
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   158
    ].
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   159
    classPathName := ((currentPackage copyReplaceAll: $: with: Filename separator) replaceAll: $/ with: Filename separator) 
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
                        , Filename separator , classFileName.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   161
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   162
    stream nextPutAll:'        <class name="'; nextPutAll: className; nextPutAll: '" filename="'; nextPutAll: classPathName; nextPutLine:'" line-rate="1.0" branch-rate="1.0" complexity="1.0">'.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   163
    stream nextPutLine:'          <methods>'.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   166
    content value.               
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   167
    currentClass := nil.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   173
    stream nextPutLine:'        </class>'
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   174
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   177
!
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   178
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   179
writeFooter
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   180
    stream nextPutAll:'  </packages>
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   181
</coverage>'
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   182
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   183
    "Modified: / 25-06-2013 / 11:57:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   184
!
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   185
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   186
writeHeader
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   187
    stream nextPutAll:'<?xml version="1.0"?>
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   188
<!!--DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-03.dtd"-->
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   203
!
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   210
!
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   211
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   212
writeMethod: method
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   222
    stream nextPutLine:'          <lines>'.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   223
    currentMethod := method.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   229
    firstCharOffset := info offsetOfMethod: method.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   230
    firstLineNr := (info lineAndColumnOfOffset: firstCharOffset) x.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   231
    lastLineNr := (info lineAndColumnOfOffset: firstCharOffset + method source size) x.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   246
        | startLine endLine |
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   247
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   248
        startLine := (info lineAndColumnOfOffset: firstCharOffset + eachBlockInfo startPosition - 1) x.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   249
        endLine := (info lineAndColumnOfOffset: firstCharOffset + eachBlockInfo endPosition - 1) x.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   257
        ]            
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   258
    ].
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   267
    ].
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   268
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   269
    currentMethod := nil.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   270
    stream nextPutLine:'          </lines>'.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   271
    stream nextPutLine:'        </method>'
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   272
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   275
!
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   276
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   277
writePackage: packageName with: aBlock
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   278
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   279
    stream nextPutAll:'    <package name="'; nextPutAll: packageName; nextPutLine: '" line-rate="1.0" branch-rate="1.0" complexity="1.0">'.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   280
    stream nextPutLine:'      <classes>'.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   281
    currentPackage := packageName.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   282
    aBlock value.               
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   283
    currentPackage := nil.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   284
    stream nextPutLine:'      </classes>'.
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   285
    stream nextPutLine:'    </package>'
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   286
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   287
    "Created: / 25-06-2013 / 11:55:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   288
    "Modified: / 25-06-2013 / 13:24:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   289
! !
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   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
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   323
!CoverageReportFormat class methodsFor:'documentation'!
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   324
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   325
version
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   326
    ^ '$Header$'
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   327
!
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   328
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   329
version_CVS
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   330
    ^ '$Header$'
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   331
! !
394b26be9d47 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   332