From 2fbb3cad9f67a5bb5e9f9f768d69cd10141c0035 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Fri, 8 May 2015 00:23:28 +0100 Subject: [PATCH] add isUser and isGenerated path methods --- src/babel/traversal/path/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/babel/traversal/path/index.js b/src/babel/traversal/path/index.js index 6ac9cc1819..68735963d8 100644 --- a/src/babel/traversal/path/index.js +++ b/src/babel/traversal/path/index.js @@ -125,6 +125,22 @@ export default class TraversalPath { return false; } + /** + * Check whether this node was a part of the original AST. + */ + + isUser() { + return this.node && !!this.node.loc; + } + + /** + * Check whether this node was generated by us and not a part of the original AST. + */ + + isGenerated() { + return !this.isUser(); + } + /** * Description */