|
|
@ -7,13 +7,10 @@ import addToSet from '../../utils/addToSet';
|
|
|
|
|
|
|
|
|
|
|
|
export default class DebugTag extends Node {
|
|
|
|
export default class DebugTag extends Node {
|
|
|
|
expressions: Expression[];
|
|
|
|
expressions: Expression[];
|
|
|
|
shouldSkip: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(compiler, parent, scope, info) {
|
|
|
|
constructor(compiler, parent, scope, info) {
|
|
|
|
super(compiler, parent, scope, info);
|
|
|
|
super(compiler, parent, scope, info);
|
|
|
|
|
|
|
|
|
|
|
|
this.shouldSkip = !compiler.options.dev;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.expressions = info.identifiers.map(node => {
|
|
|
|
this.expressions = info.identifiers.map(node => {
|
|
|
|
return new Expression(compiler, parent, scope, node);
|
|
|
|
return new Expression(compiler, parent, scope, node);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -24,13 +21,26 @@ export default class DebugTag extends Node {
|
|
|
|
parentNode: string,
|
|
|
|
parentNode: string,
|
|
|
|
parentNodes: string,
|
|
|
|
parentNodes: string,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
if (this.shouldSkip) return;
|
|
|
|
if (!this.compiler.options.dev) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { code } = this.compiler;
|
|
|
|
|
|
|
|
|
|
|
|
// Debug all
|
|
|
|
// Debug all
|
|
|
|
if (this.expressions.length === 0) {
|
|
|
|
if (this.expressions.length === 0) {
|
|
|
|
block.builders.create.addLine('debugger;');
|
|
|
|
code.overwrite(this.start + 1, this.start + 7, 'debugger', {
|
|
|
|
block.builders.update.addLine('debugger;');
|
|
|
|
storeName: true
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const statement = `[✂${this.start + 1}-${this.start + 7}✂];`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
block.builders.create.addLine(statement);
|
|
|
|
|
|
|
|
block.builders.update.addLine(statement);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const { code } = this.compiler;
|
|
|
|
|
|
|
|
code.overwrite(this.start + 1, this.start + 7, 'log', {
|
|
|
|
|
|
|
|
storeName: true
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const log = `[✂${this.start + 1}-${this.start + 7}✂]`;
|
|
|
|
|
|
|
|
|
|
|
|
const dependencies = new Set();
|
|
|
|
const dependencies = new Set();
|
|
|
|
this.expressions.forEach(expression => {
|
|
|
|
this.expressions.forEach(expression => {
|
|
|
|
addToSet(dependencies, expression.dependencies);
|
|
|
|
addToSet(dependencies, expression.dependencies);
|
|
|
@ -43,15 +53,17 @@ export default class DebugTag extends Node {
|
|
|
|
block.builders.update.addBlock(deindent`
|
|
|
|
block.builders.update.addBlock(deindent`
|
|
|
|
if (${condition}) {
|
|
|
|
if (${condition}) {
|
|
|
|
const { ${identifiers} } = ctx;
|
|
|
|
const { ${identifiers} } = ctx;
|
|
|
|
console.log({ ${identifiers} });
|
|
|
|
console.${log}({ ${identifiers} });
|
|
|
|
debugger;
|
|
|
|
debugger;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
`);
|
|
|
|
|
|
|
|
|
|
|
|
block.builders.create.addBlock(deindent`
|
|
|
|
block.builders.create.addBlock(deindent`
|
|
|
|
const { ${identifiers} } = ctx;
|
|
|
|
{
|
|
|
|
console.log({ ${identifiers} });
|
|
|
|
const { ${identifiers} } = ctx;
|
|
|
|
debugger;
|
|
|
|
console.${log}({ ${identifiers} });
|
|
|
|
|
|
|
|
debugger;
|
|
|
|
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|