22
22
import com .google .common .primitives .UnsignedBytes ;
23
23
import com .google .javascript .rhino .Node ;
24
24
import java .util .BitSet ;
25
- import java .util .HashMap ;
25
+ import java .util .LinkedHashMap ;
26
26
import java .util .Map ;
27
27
28
28
/**
29
- * Holds instrumentation details related to a file, namely, the filename,
30
- * the array name used in instrumentation, and the lines which were
31
- * instrumented (in encoded form).
29
+ * Holds instrumentation details related to a file, namely, the filename, the array name used in
30
+ * instrumentation, and the lines which were instrumented (in encoded form).
32
31
*/
33
32
@ GwtIncompatible ("com.google.common.primitives.UnsignedBytes" )
34
33
class FileInstrumentationData {
@@ -67,8 +66,7 @@ public int hashCode() {
67
66
public boolean equals (Object object ) {
68
67
if (object instanceof BranchIndexPair ) {
69
68
BranchIndexPair that = (BranchIndexPair ) object ;
70
- return this .getLine () == that .getLine ()
71
- && this .getBranch () == that .getBranch ();
69
+ return this .getLine () == that .getLine () && this .getBranch () == that .getBranch ();
72
70
}
73
71
return false ;
74
72
}
@@ -94,11 +92,11 @@ public boolean equals(Object object) {
94
92
instrumentedBits = new BitSet ();
95
93
96
94
branchPresent = new BitSet ();
97
- branchesInLine = new HashMap <>();
98
- branchNodes = new HashMap <>();
95
+ branchesInLine = new LinkedHashMap <>();
96
+ branchNodes = new LinkedHashMap <>();
99
97
}
100
98
101
- String getArrayName () {
99
+ String getArrayName () {
102
100
return arrayName ;
103
101
}
104
102
@@ -116,6 +114,7 @@ int maxBranchPresentLine() {
116
114
117
115
/**
118
116
* Store a node to be instrumented later for branch coverage.
117
+ *
119
118
* @param lineNumber 1-based line number
120
119
* @param branchNumber 1-based branch number
121
120
* @param block the node of the conditional block.
@@ -131,6 +130,7 @@ void putBranchNode(int lineNumber, int branchNumber, Node block) {
131
130
132
131
/**
133
132
* Get the block node to be instrumented for branch coverage.
133
+ *
134
134
* @param lineNumber 1-based line number
135
135
* @param branchNumber 1-based branch number
136
136
* @return the node of the conditional block.
@@ -145,10 +145,9 @@ Node getBranchNode(int lineNumber, int branchNumber) {
145
145
}
146
146
147
147
/**
148
- * Returns a byte-wise hex string representation of the BitField from
149
- * MSB (Most Significant Byte) to LSB (Least Significant Byte).
150
- * Eg. Single byte: a setting of "0001 1111", returns "1f"
151
- * Eg. Multiple bytes: a setting of "0000 0010 0001 1111", returns "1f02"
148
+ * Returns a byte-wise hex string representation of the BitField from MSB (Most Significant Byte)
149
+ * to LSB (Least Significant Byte). Eg. Single byte: a setting of "0001 1111", returns "1f" Eg.
150
+ * Multiple bytes: a setting of "0000 0010 0001 1111", returns "1f02"
152
151
*
153
152
* @return string representation of bits set
154
153
*/
@@ -181,8 +180,8 @@ String getBranchPresentAsHexString() {
181
180
}
182
181
183
182
/**
184
- * Mark given 1-based line number as instrumented. Zero, Negative numbers
185
- * are not allowed.
183
+ * Mark given 1-based line number as instrumented. Zero, Negative numbers are not allowed.
184
+ *
186
185
* @param lineNumber the line number which was instrumented
187
186
*/
188
187
void setLineAsInstrumented (int lineNumber ) {
@@ -195,6 +194,7 @@ void setLineAsInstrumented(int lineNumber) {
195
194
196
195
/**
197
196
* Mark a given 1-based line number has branch presented.
197
+ *
198
198
* @param lineNumber the line number which has conditional branches.
199
199
*/
200
200
void setBranchPresent (int lineNumber ) {
@@ -207,6 +207,7 @@ void setBranchPresent(int lineNumber) {
207
207
208
208
/**
209
209
* Add a number of branches to a line.
210
+ *
210
211
* @param lineNumber the line number that contains the branch statement.
211
212
* @param numberOfBranches the number of branches to add to the record.
212
213
*/
@@ -222,6 +223,7 @@ void addBranches(int lineNumber, int numberOfBranches) {
222
223
223
224
/**
224
225
* Get the number of branches on a line
226
+ *
225
227
* @param lineNumber - the 1-based line number
226
228
* @return the number of branches on the line.
227
229
*/
@@ -233,5 +235,4 @@ int getNumBranches(int lineNumber) {
233
235
return numBranches ;
234
236
}
235
237
}
236
-
237
238
}
0 commit comments