@@ -38,9 +38,13 @@ Property MethodEndMap As array Of %Integer;
38
38
/// For routines, map of labels to associated line numbers
39
39
Property LineToMethodMap As array Of %Dictionary .CacheIdentifier [ Private ];
40
40
41
+ /// For each line, whether or not it belongs to a python method, only populated for .cls CodeUnits
42
+ Property LineIsPython As array Of %Boolean ;
43
+
41
44
/// Set to true if this class/routine is generated
42
45
Property Generated As %Boolean [ InitialExpression = 0 ];
43
46
47
+ ///
44
48
/// Methods, branches, etc. within this unit of code.
45
49
Relationship SubUnits As TestCoverage .Data .CodeSubUnit [ Cardinality = children , Inverse = Parent ];
46
50
@@ -129,6 +133,7 @@ ClassMethod GetCurrentByName(pInternalName As %String, pSourceNamespace As %Stri
129
133
130
134
If (tType = " CLS" ) {
131
135
Set pCodeUnit .Generated = ($$$comClassKeyGet(tName ,$$$cCLASSgeneratedby) '= " " )
136
+
132
137
}
133
138
134
139
@@ -170,6 +175,9 @@ ClassMethod GetCurrentByName(pInternalName As %String, pSourceNamespace As %Stri
170
175
Do pCodeUnit .Lines .Insert (tLine )
171
176
172
177
If (tType = " CLS" ) {
178
+ // initialize each line to not python (we'll update this later)
179
+ Do pCodeUnit .LineIsPython .SetAt (0 , tLineNumber )
180
+
173
181
// Extract line offset of methods in classes
174
182
Set tStart = $Piece (tLine ," " )
175
183
If (tStart = " ClassMethod" ) || (tStart = " Method" ) {
@@ -236,6 +244,54 @@ ClassMethod GetCurrentByName(pInternalName As %String, pSourceNamespace As %Stri
236
244
Quit tSC
237
245
}
238
246
247
+ /// Fill in the LineIsPython property of .cls files
248
+ Method UpdatePythonLines (pName As %String , ByRef pPyCodeUnit ) As %Status
249
+ {
250
+
251
+ Set tSC = $$$OK
252
+ Set tOriginalNamespace = $Namespace
253
+ Set tInitTLevel = $TLevel
254
+
255
+ Try {
256
+ TSTART
257
+
258
+ If (##class (TestCoverage.Manager ).HasPython (pName )) {
259
+
260
+ Set tFromHash = pPyCodeUnit .Hash
261
+ Set tToHash = ..Hash
262
+ set sql = " SELECT map.ToLine FROM TestCoverage_Data.CodeUnitMap map " _
263
+ " JOIN TestCoverage_Data.CodeUnit fromCodeUnit " _
264
+ " ON fromCodeUnit.Hash = map.FromHash " _
265
+ " WHERE map.FromHash = ? " _
266
+ " AND map.ToHash = ? "
267
+ set resultSet = ##class (%SQL.Statement ).%ExecDirect (, sql , tFromHash , tToHash )
268
+ If (resultSet .%SQLCODE < 0 ) {
269
+ Throw ##class (%Exception.SQL ).CreateFromSQLCODE (resultSet .%SQLCODE , resultSet .%Message )
270
+ }
271
+ while resultSet .%Next (.tSC ) {
272
+ $$$ThrowOnError(tSC )
273
+ Set hToLine = resultSet .%GetData (1 )
274
+ set ^IRIS .TempCG ($i (^IRIS .TempCG )) = hToLine
275
+ do ..LineIsPython .SetAt (1 , hToLine )
276
+ }
277
+ If (resultSet .%SQLCODE < 0 ) {
278
+ Throw ##class (%Exception.SQL ).CreateFromSQLCODE (resultSet .%SQLCODE , resultSet .%Message )
279
+ }
280
+ }
281
+ Set tSC = ..%Save ()
282
+ $$$ThrowOnError(tSC )
283
+
284
+ TCOMMIT
285
+ } Catch e {
286
+ Set pCodeUnit = $$$NULLOREF
287
+ Set tSC = e .AsStatus ()
288
+ }
289
+ While ($TLevel > tInitTLevel ) {
290
+ TROLLBACK 1
291
+ }
292
+ Quit tSC
293
+ }
294
+
239
295
/// Get the executable lines of code in python over to the .cls CodeUnit
240
296
Method UpdatePyExecutableLines (pName As %String , ByRef pPyCodeUnit ) As %Status
241
297
{
@@ -636,6 +692,11 @@ Storage Default
636
692
<Value >Generated </Value >
637
693
</Value >
638
694
</Data >
695
+ <Data name =" LineIsPython" >
696
+ <Attribute >LineIsPython </Attribute >
697
+ <Structure >subnode </Structure >
698
+ <Subscript >" LineIsPython" </Subscript >
699
+ </Data >
639
700
<Data name =" LineToMethodMap" >
640
701
<Attribute >LineToMethodMap </Attribute >
641
702
<Structure >subnode </Structure >
0 commit comments