Skip to content

Commit

Permalink
Clean up some scope methods:
Browse files Browse the repository at this point in the history
* var.scope.isGlobal() => var.isGlobal()
* var.scope.isLocal() => var.isLocal()
* scope.rootNode => scope.getRootNode()

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=180681077
  • Loading branch information
shicks authored and blickly committed Jan 3, 2018
1 parent 41331b3 commit 49281c1
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
Expand Up @@ -295,7 +295,7 @@ private boolean mayBeGlobalAlias(Ref alias) {
String aliasVarName = aliasLhsNode.getString();
Var aliasVar = alias.scope.getVar(aliasVarName);
if (aliasVar != null) {
return aliasVar.scope.isGlobal();
return aliasVar.isGlobal();
}
return true;
}
Expand Down
Expand Up @@ -626,7 +626,7 @@ static class GlobalFunction implements Symbol {

GlobalFunction(Node nameNode, Var var, JSModule module) {
Node parent = nameNode.getParent();
checkState((NodeUtil.isNameDeclaration(parent) && var.scope.isGlobal())
checkState((NodeUtil.isNameDeclaration(parent) && var.isGlobal())
|| NodeUtil.isFunctionDeclaration(parent));
this.nameNode = nameNode;
this.var = var;
Expand Down
Expand Up @@ -75,8 +75,8 @@ public final boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {
for (Var var : fBlockScope.getVarIterable()) {
String oldName = var.getName();
if (collector.currFuncReferences.contains(oldName)
&& !renameTable.contains(fBlockScope.rootNode, oldName)) {
renameTable.put(fBlockScope.rootNode,
&& !renameTable.contains(fBlockScope.getRootNode(), oldName)) {
renameTable.put(fBlockScope.getRootNode(),
oldName, oldName + "$" + compiler.getUniqueNameIdSupplier().get());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/InlineVariables.java
Expand Up @@ -123,7 +123,7 @@ public boolean apply(Var var) {
private static class IdentifyLocals implements Predicate<Var> {
@Override
public boolean apply(Var var) {
return var.scope.isLocal();
return var.isLocal();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/com/google/javascript/jscomp/PureFunctionIdentifier.java
Expand Up @@ -597,8 +597,8 @@ private boolean isVarDeclaredInScope(@Nullable Var v, Scope scope) {
if (v.scope == scope) {
return true;
}
Node declarationRoot = NodeUtil.getEnclosingFunction(v.scope.rootNode);
Node scopeRoot = NodeUtil.getEnclosingFunction(scope.rootNode);
Node declarationRoot = NodeUtil.getEnclosingFunction(v.scope.getRootNode());
Node scopeRoot = NodeUtil.getEnclosingFunction(scope.getRootNode());
return declarationRoot == scopeRoot;
}

Expand Down
6 changes: 3 additions & 3 deletions src/com/google/javascript/jscomp/TypedScope.java
Expand Up @@ -134,11 +134,11 @@ public StaticTypedScope<JSType> getParentScope() {
@Override
public JSType getTypeOfThis() {
if (isGlobal()) {
return ObjectType.cast(rootNode.getJSType());
return ObjectType.cast(getRootNode().getJSType());
}

checkState(rootNode.isFunction());
JSType nodeType = rootNode.getJSType();
checkState(getRootNode().isFunction());
JSType nodeType = getRootNode().getJSType();
if (nodeType != null && nodeType.isFunctionType()) {
return nodeType.toMaybeFunctionType().getTypeOfThis();
} else {
Expand Down

0 comments on commit 49281c1

Please sign in to comment.