Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | 37x 37x 6236x 114x 114x 114x 58x 56x 52x 79x 79x 52x 79x 43x 19x 19x 19x 12x 10x 12x 12x 12x 6236x 5x 2x 2x 2x 2x 2x 6236x 77x 3x 6236x | const generate = require('../generate')
module.exports = function handleSpecific({ full, partial, prop, extraData, Expando, find$$$ } = {}) {
let specific, result;
if (prop == 'body') {
// 匹配一块代码
try {
let bodyContent = partial.body;
if (Array.isArray(partial.body)) {
bodyContent = partial.body[0] || partial.body.body[0];
} else if (partial.body && partial.body.body) {
bodyContent = partial.body.body[0]
}
let name = ''
if (bodyContent) {
name = bodyContent.expression ? bodyContent.expression.name : bodyContent.name ? bodyContent.name : ''
}
if (name && name.match) {
if (name.match(Expando)) {
const expandoKey = name.replace(Expando, '') || '0';
extraData[expandoKey] = extraData[expandoKey] || [];
// 去掉首尾花括号
let bodyStr = generate(full.body) || '';
if (bodyStr.trim()[0] == '{') {
bodyStr = bodyStr.slice(1, -2);
}
extraData[expandoKey].push({ node: full.body, value: bodyStr });
specific = 'body';
result = true;
}
}
} catch (e) {
// console.log(e)
}
}
if (partial && partial.typeName && !partial.typeParameters) {
if (partial.typeName.name.match(Expando)) {
specific = 'TypeAnnotation';
const expandoKey = partial.typeName.name.replace(Expando, '') || '0';
extraData[expandoKey] = extraData[expandoKey] || [];
extraData[expandoKey].push(full);
result = true;
}
}
if (prop == 'specifiers') {
if ((!full[prop] || full[prop].length == 0) && partial[prop].length > 0) {
specific = 'specifiers',
result = false;
}
}
return { specific, result }
} |