Added custom NodePath.prototype.toString method as debug utility (#7218)

This commit is contained in:
Mateusz Burzyński 2018-01-15 13:07:05 +01:00 committed by GitHub
parent 79c84f2f9b
commit 0a517b51cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ import traverse from "../index";
import Scope from "../scope"; import Scope from "../scope";
import * as t from "@babel/types"; import * as t from "@babel/types";
import { path as pathCache } from "../cache"; import { path as pathCache } from "../cache";
import generator from "@babel/generator";
// NodePath is split across many files. // NodePath is split across many files.
import * as NodePath_ancestry from "./ancestry"; import * as NodePath_ancestry from "./ancestry";
@ -146,6 +147,10 @@ export default class NodePath {
if (!debug.enabled) return; if (!debug.enabled) return;
debug(`${this.getPathLocation()} ${this.type}: ${message}`); debug(`${this.getPathLocation()} ${this.type}: ${message}`);
} }
toString() {
return generator(this.node).code;
}
} }
Object.assign( Object.assign(