monocart-coverage-reports 2.3.2 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -19
- package/lib/converter/ast.js +2 -3
- package/lib/converter/branches.js +37 -26
- package/lib/converter/converter.js +91 -71
- package/lib/converter/ignore.js +51 -18
- package/lib/converter/info-line.js +2 -2
- package/lib/packages/monocart-coverage-v8.js +1 -1
- package/lib/platform/share.js +44 -6
- package/package.json +1 -1
- package/lib/converter/find-in-ranges.js +0 -39
package/lib/platform/share.js
CHANGED
|
@@ -241,8 +241,46 @@ const Util = {
|
|
|
241
241
|
},
|
|
242
242
|
|
|
243
243
|
isBlank: (codeStr) => {
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
if (typeof codeStr === 'string') {
|
|
245
|
+
const blankBlock = /\S/;
|
|
246
|
+
return !blankBlock.test(codeStr);
|
|
247
|
+
}
|
|
248
|
+
return false;
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
findInRanges: (startPos, endPos, rangeList, startKey = 'start', endKey = 'end') => {
|
|
252
|
+
if (!Util.isList(rangeList)) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const quickFindRange = (position, ranges) => {
|
|
257
|
+
let start = 0;
|
|
258
|
+
let end = ranges.length - 1;
|
|
259
|
+
while (end - start > 1) {
|
|
260
|
+
const i = Math.floor((start + end) * 0.5);
|
|
261
|
+
const item = ranges[i];
|
|
262
|
+
if (position < item[startKey]) {
|
|
263
|
+
end = i;
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (position > item[endKey]) {
|
|
267
|
+
start = i;
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
return ranges[i];
|
|
271
|
+
}
|
|
272
|
+
// last two items, less is start
|
|
273
|
+
const endItem = ranges[end];
|
|
274
|
+
if (position < endItem[startKey]) {
|
|
275
|
+
return ranges[start];
|
|
276
|
+
}
|
|
277
|
+
return ranges[end];
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
const range = quickFindRange(startPos, rangeList);
|
|
281
|
+
if (startPos >= range[startKey] && endPos <= range[endKey]) {
|
|
282
|
+
return range;
|
|
283
|
+
}
|
|
246
284
|
},
|
|
247
285
|
|
|
248
286
|
getRangeLines: (sLoc, eLoc) => {
|
|
@@ -270,7 +308,7 @@ const Util = {
|
|
|
270
308
|
lines.push({
|
|
271
309
|
line: sLoc.line,
|
|
272
310
|
entire,
|
|
273
|
-
|
|
311
|
+
pieces: {
|
|
274
312
|
start: sLoc.column,
|
|
275
313
|
end: sLoc.length
|
|
276
314
|
}
|
|
@@ -286,7 +324,7 @@ const Util = {
|
|
|
286
324
|
lines.push({
|
|
287
325
|
line: sLoc.line,
|
|
288
326
|
entire,
|
|
289
|
-
|
|
327
|
+
pieces: {
|
|
290
328
|
start: sLoc.column,
|
|
291
329
|
end: eLoc.column
|
|
292
330
|
}
|
|
@@ -304,7 +342,7 @@ const Util = {
|
|
|
304
342
|
lines.push({
|
|
305
343
|
line: eLoc.line,
|
|
306
344
|
entire,
|
|
307
|
-
|
|
345
|
+
pieces: {
|
|
308
346
|
start: eLoc.indent,
|
|
309
347
|
end: eLoc.column
|
|
310
348
|
}
|
|
@@ -329,7 +367,7 @@ const Util = {
|
|
|
329
367
|
lines.push({
|
|
330
368
|
line: i,
|
|
331
369
|
entire: true
|
|
332
|
-
// no
|
|
370
|
+
// no pieces for entire line
|
|
333
371
|
});
|
|
334
372
|
}
|
|
335
373
|
}
|
package/package.json
CHANGED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const Util = require('../utils/util.js');
|
|
2
|
-
|
|
3
|
-
const quickFindRange = (position, ranges) => {
|
|
4
|
-
let start = 0;
|
|
5
|
-
let end = ranges.length - 1;
|
|
6
|
-
while (end - start > 1) {
|
|
7
|
-
const i = Math.floor((start + end) * 0.5);
|
|
8
|
-
const item = ranges[i];
|
|
9
|
-
if (position < item.startOffset) {
|
|
10
|
-
end = i;
|
|
11
|
-
continue;
|
|
12
|
-
}
|
|
13
|
-
if (position > item.endOffset) {
|
|
14
|
-
start = i;
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
return ranges[i];
|
|
18
|
-
}
|
|
19
|
-
// last two items, less is start
|
|
20
|
-
const endItem = ranges[end];
|
|
21
|
-
if (position < endItem.startOffset) {
|
|
22
|
-
return ranges[start];
|
|
23
|
-
}
|
|
24
|
-
return ranges[end];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const findInRanges = (start, end, ranges) => {
|
|
29
|
-
if (!Util.isList(ranges)) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const range = quickFindRange(start, ranges);
|
|
33
|
-
if (start >= range.startOffset && end <= range.endOffset) {
|
|
34
|
-
return range;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
module.exports = findInRanges;
|