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 6245x 115x 115x 115x 58x 57x 53x 80x 80x 53x 80x 44x 20x 20x 20x 13x 11x 13x 13x 13x 6245x 5x 2x 2x 2x 2x 2x 6245x 77x 3x 6245x | 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 }
} |