From 76690a3debf7d394bad2fcdf2fa6ddbe4eab0cf7 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Mon, 1 Jun 2015 12:05:42 +0100 Subject: [PATCH] renamed Path#isPreviousType to isType --- src/babel/traversal/path/modification.js | 8 ++++---- src/babel/traversal/path/removal.js | 3 ++- src/babel/traversal/path/replacement.js | 4 ++-- src/babel/traversal/path/resolution.js | 16 ++++++++-------- src/babel/traversal/path/verification.js | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/babel/traversal/path/modification.js b/src/babel/traversal/path/modification.js index 0f996a03f2..acabae997d 100644 --- a/src/babel/traversal/path/modification.js +++ b/src/babel/traversal/path/modification.js @@ -11,10 +11,10 @@ export function insertBefore(nodes) { if (this.parentPath.isExpressionStatement() || this.parentPath.isLabeledStatement()) { return this.parentPath.insertBefore(nodes); - } else if (this.isPreviousType("Expression") || (this.parentPath.isForStatement() && this.key === "init")) { + } else if (this.isType("Expression") || (this.parentPath.isForStatement() && this.key === "init")) { if (this.node) nodes.push(this.node); this.replaceExpressionWithStatements(nodes); - } else if (this.isPreviousType("Statement") || !this.type) { + } else if (this.isType("Statement") || !this.type) { this._maybePopFromStatements(nodes); if (Array.isArray(this.container)) { return this._containerInsertBefore(nodes); @@ -82,14 +82,14 @@ export function insertAfter(nodes) { if (this.parentPath.isExpressionStatement() || this.parentPath.isLabeledStatement()) { return this.parentPath.insertAfter(nodes); - } else if (this.isPreviousType("Expression") || (this.parentPath.isForStatement() && this.key === "init")) { + } else if (this.isType("Expression") || (this.parentPath.isForStatement() && this.key === "init")) { if (this.node) { var temp = this.scope.generateDeclaredUidIdentifier(); nodes.unshift(t.expressionStatement(t.assignmentExpression("=", temp, this.node))); nodes.push(t.expressionStatement(temp)); } this.replaceExpressionWithStatements(nodes); - } else if (this.isPreviousType("Statement") || !this.type) { + } else if (this.isType("Statement") || !this.type) { this._maybePopFromStatements(nodes); if (Array.isArray(this.container)) { return this._containerInsertAfter(nodes); diff --git a/src/babel/traversal/path/removal.js b/src/babel/traversal/path/removal.js index 6e89210126..843c442726 100644 --- a/src/babel/traversal/path/removal.js +++ b/src/babel/traversal/path/removal.js @@ -1,7 +1,8 @@ import * as removalHooks from "./lib/removal-hooks"; /** - * Description + * Deprecated in favor of `dangerouslyRemove` as it's far more scary and more accurately portrays + * the risk. */ export function remove() { diff --git a/src/babel/traversal/path/replacement.js b/src/babel/traversal/path/replacement.js index 49b772868f..5595ee9fa2 100644 --- a/src/babel/traversal/path/replacement.js +++ b/src/babel/traversal/path/replacement.js @@ -110,12 +110,12 @@ export function replaceWith(replacement, whateverAllowed) { } // replacing a statement with an expression so wrap it in an expression statement - if (this.isPreviousType("Statement") && t.isExpression(replacement) && !this.canHaveVariableDeclarationOrExpression()) { + if (this.isType("Statement") && t.isExpression(replacement) && !this.canHaveVariableDeclarationOrExpression()) { replacement = t.expressionStatement(replacement); } // replacing an expression with a statement so let's explode it - if (this.isPreviousType("Expression") && t.isStatement(replacement)) { + if (this.isType("Expression") && t.isStatement(replacement)) { return this.replaceExpressionWithStatements([replacement]); } diff --git a/src/babel/traversal/path/resolution.js b/src/babel/traversal/path/resolution.js index bc608c3c49..200c9e8682 100644 --- a/src/babel/traversal/path/resolution.js +++ b/src/babel/traversal/path/resolution.js @@ -101,36 +101,36 @@ export function inferType(path: NodePath): ?Object { path = path.resolve(); if (!path) return; - if (path.isPreviousType("RestElement") || path.parentPath.isPreviousType("RestElement") || path.isPreviousType("ArrayExpression")) { + if (path.isType("RestElement") || path.parentPath.isType("RestElement") || path.isType("ArrayExpression")) { return t.genericTypeAnnotation(t.identifier("Array")); } - if (path.parentPath.isPreviousType("TypeCastExpression")) { + if (path.parentPath.isType("TypeCastExpression")) { return path.parentPath.node.typeAnnotation; } - if (path.isPreviousType("TypeCastExpression")) { + if (path.isType("TypeCastExpression")) { return path.node.typeAnnotation; } - if (path.isPreviousType("ObjectExpression")) { + if (path.isType("ObjectExpression")) { return t.genericTypeAnnotation(t.identifier("Object")); } - if (path.isPreviousType("Function")) { + if (path.isType("Function")) { return t.identifier("Function"); } - if (path.isPreviousType("Literal")) { + if (path.isType("Literal")) { var value = path.node.value; if (isString(value)) return t.stringTypeAnnotation(); if (isNumber(value)) return t.numberTypeAnnotation(); if (isBoolean(value)) return t.booleanTypeAnnotation(); } - if (path.isPreviousType("CallExpression")) { + if (path.isType("CallExpression")) { var callee = path.get("callee").resolve(); - if (callee && callee.isPreviousType("Function")) return callee.node.returnType; + if (callee && callee.isType("Function")) return callee.node.returnType; } } diff --git a/src/babel/traversal/path/verification.js b/src/babel/traversal/path/verification.js index 5ef4caa171..4ba0a6c82f 100644 --- a/src/babel/traversal/path/verification.js +++ b/src/babel/traversal/path/verification.js @@ -99,7 +99,7 @@ export function equals(key, value): boolean { * been removed yet we still internally know the type and need it to calculate node replacement. */ -export function isPreviousType(type: string): boolean { +export function isType(type: string): boolean { return t.isType(this.type, type); }