Refactor LiveVariablesAnalysisEs6 to use the getAllAccessibleVariables() from scope method.
@@ -152,32 +152,13 @@ class LiveVariablesAnalysisEs6
private void addScopeVariables() {
int num = 0;
if (jsScope.isFunctionScope()) {
- for (Var v : jsScope.getVarIterable()) {
+ checkNotNull(jsScopeChild);
+ for (Var v : jsScopeChild.getAllAccessibleVariables()) {
scopeVariables.put(v.getName(), num);
num++;
}
-
- if (jsScopeChild != null) {
- for (Var v : jsScopeChild.getVarIterable()) {
- // add the hoisted variables from this child scope
- if ((v.isLet() || v.isConst()) && !jsScope.isFunctionScope()) {
- continue;
-
- }
- scopeVariables.put(v.getName(), num);
- num++;
- }
- }
} else {
-
- if (jsScope.isFunctionBlockScope()) {
- for (Var v : jsScope.getParent().getVarIterable()) {
- scopeVariables.put(v.getName(), num);
- num++;
- }
- }
-
- for (Var v : jsScope.getVarIterable()) {
+ for (Var v : jsScope.getAllAccessibleVariables()) {
scopeVariables.put(v.getName(), num);
num++;
}
