remove some dead code

This commit is contained in:
Sebastian McKenzie 2015-03-30 00:18:37 +11:00
parent 52c6fe2bc1
commit 3952eefd01
3 changed files with 28 additions and 19 deletions

View File

@ -65,10 +65,6 @@ export default class Transformer {
}
buildPass(file: File): TransformerPass {
if (!(file instanceof File)) {
throw new Error("Multiple versions of babel are interacting, this is either due to a version mismatch in a plugin or it was resolved incorrectly");
}
return new TransformerPass(file, this);
}
}

View File

@ -1,3 +1,4 @@
import PathHoister from "./hoister";
import isBoolean from "lodash/lang/isBoolean";
import isNumber from "lodash/lang/isNumber";
import isRegExp from "lodash/lang/isRegExp";
@ -10,7 +11,7 @@ import Scope from "../scope";
import * as t from "../../types";
var hoistVariablesVisitor = {
enter(node, parent, scope ) {
enter(node, parent, scope) {
if (this.isFunction()) {
return this.skip();
}
@ -100,7 +101,7 @@ export default class TraversalPath {
if (this.node) nodes.push(this.node);
this.replaceExpressionWithStatements(nodes);
} else {
throw new Error("no idea what to do with this");
throw new Error("no idea what to do with this ");
}
}
@ -258,10 +259,16 @@ export default class TraversalPath {
}
_verifyNodeList(nodes) {
if (typeof nodes === "object") {
nodes = [nodes];
}
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (!node) throw new Error(`Node list has falsy node with the index of ${i}`);
}
return nodes;
}
replaceWithMultiple(nodes: Array<Object>) {
@ -601,10 +608,6 @@ export default class TraversalPath {
return t.isVar(this.node);
}
isScope(): boolean {
return t.isScope(this.node, this.parent);
}
isPreviousType(type: string): boolean {
return t.isType(this.type, type);
}
@ -633,8 +636,9 @@ export default class TraversalPath {
return t.getBindingIdentifiers(this.node);
}
traverse(opts, state) {
traverse(this.node, opts, this.scope, state, this);
traverse(visitor, state) {
traverse(this.node, visitor, this.scope, state, this);
}
/**
* Description

View File

@ -57,7 +57,7 @@ var blockVariableVisitor = {
enter(node, parent, scope, state) {
if (this.isFunctionDeclaration() || this.isBlockScoped()) {
state.registerDeclaration(this);
} else if (t.isScope(node, parent)) {
} else if (this.isScope()) {
this.skip();
}
}
@ -71,11 +71,8 @@ export default class Scope {
*/
constructor(path: TraversalPath, parent?: Scope, file?: File) {
var cached = path.getData("scope");
if (cached) {
return cached;
} else {
//path.setData("scope", this);
if (parent && parent.block === path.node) {
return parent;
}
this.parent = parent;
@ -252,7 +249,7 @@ export default class Scope {
for (var name in ids) {
if (name === oldName) ids[name].name = newName;
}
} else if (t.isScope(node, parent)) {
} else if (this.isScope()) {
if (!scope.bindingIdentifierEquals(oldName, binding)) {
this.skip();
}
@ -266,6 +263,18 @@ export default class Scope {
binding.name = newName;
}
/**
* Description
*/
dump() {
var scope = this;
do {
console.log(scope.block.type, "Bindings:", Object.keys(scope.bindings));
} while(scope = scope.parent);
console.log("-------------");
}
/**
* Description
*/