add comments and remove dead code
This commit is contained in:
parent
ed156a8ca5
commit
3df5d31cee
@ -1,5 +1,12 @@
|
||||
/**
|
||||
* [Please add a description.]
|
||||
* This class is responsible for a binding inside of a scope.
|
||||
*
|
||||
* It tracks the following:
|
||||
*
|
||||
* * Node path.
|
||||
* * Amount of times referenced by other nodes.
|
||||
* * Paths to nodes that reassign or modify this binding.
|
||||
* * The kind of binding. (Is it a parameter, declaration etc)
|
||||
*/
|
||||
|
||||
export default class Binding {
|
||||
@ -60,7 +67,7 @@ export default class Binding {
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
* Register a constant violation with the provided `path`.
|
||||
*/
|
||||
|
||||
reassign(path: Object) {
|
||||
@ -69,7 +76,7 @@ export default class Binding {
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
* Increment the amount of references to this binding.
|
||||
*/
|
||||
|
||||
reference() {
|
||||
@ -78,19 +85,11 @@ export default class Binding {
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
* Decrement the amount of references to this binding.
|
||||
*/
|
||||
|
||||
dereference() {
|
||||
this.references--;
|
||||
this.referenced = !!this.references;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
|
||||
isCompatibleWithType(): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,19 +187,14 @@ var renameVisitor = {
|
||||
if (!scope.bindingIdentifierEquals(state.oldName, state.binding)) {
|
||||
this.skip();
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
"AssignmentExpression|Declaration"(node, parent, scope, state) {
|
||||
var ids = this.getBindingIdentifiers();
|
||||
|
||||
renameVisitor.AssignmentExpression =
|
||||
renameVisitor.Declaration = function (node, parent, scope, state) {
|
||||
var ids = this.getBindingIdentifiers();
|
||||
|
||||
for (var name in ids) {
|
||||
if (name === state.oldName) ids[name].name = state.newName;
|
||||
for (var name in ids) {
|
||||
if (name === state.oldName) ids[name].name = state.newName;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -237,11 +232,13 @@ export default class Scope {
|
||||
/**
|
||||
* Globals.
|
||||
*/
|
||||
|
||||
static globals = flatten([globals.builtin, globals.browser, globals.node].map(Object.keys));
|
||||
|
||||
/**
|
||||
* Variables available in current context.
|
||||
*/
|
||||
|
||||
static contextVariables = [
|
||||
"arguments",
|
||||
"undefined",
|
||||
@ -555,14 +552,7 @@ export default class Scope {
|
||||
var ids = left.getBindingIdentifiers();
|
||||
for (var name in ids) {
|
||||
var binding = this.getBinding(name);
|
||||
if (!binding) continue;
|
||||
|
||||
if (right) {
|
||||
var rightType = right.typeAnnotation;
|
||||
if (rightType && binding.isCompatibleWithType(rightType)) continue;
|
||||
}
|
||||
|
||||
binding.reassign(root, left, right);
|
||||
if (binding) binding.reassign(root, left, right);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user