Skip to content

Commit

Permalink
Move ScopeSubject to the jscomp.testing package
Browse files Browse the repository at this point in the history
I completely missed the package when moving this to the testing/ directory

This makes AbstractScope public, but I'm fine with this since it already has two public subclasses.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=238497946
  • Loading branch information
lauraharker authored and tjgq committed Mar 16, 2019
1 parent a6b5dd3 commit 288468f
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/com/google/javascript/jscomp/AbstractScope.java
Expand Up @@ -52,13 +52,13 @@
* Local variables are declared on the function block, while parameters and optionally the function
* name (if it bleeds, i.e. from a named function expression) are declared on the container scope.
* This is required so that default parameter initializers can refer to names from outside the
* function that could possibly be shadowed in the function block. But these scopes are not fully
* function that could possibly be shadowed in the function block. But these scopes are not fully
* independent of one another, since the language does not allow a top-level local variable to
* shadow a parameter name - so in some situations these scopes must be treated as a single scope.
*
* @see NodeTraversal
*/
abstract class AbstractScope<S extends AbstractScope<S, V>, V extends AbstractVar<S, V>>
public abstract class AbstractScope<S extends AbstractScope<S, V>, V extends AbstractVar<S, V>>
implements StaticScope, Serializable {
private final Map<String, V> vars = new LinkedHashMap<>();
private final Map<ImplicitVar, V> implicitVars = new EnumMap<>(ImplicitVar.class);
Expand Down Expand Up @@ -112,7 +112,7 @@ public Node getRootNode() {
}

/** Walks up the tree to find the global scope. */
final S getGlobalScope() {
public final S getGlobalScope() {
S result = thisScope();
while (result.getParent() != null) {
result = result.getParent();
Expand Down
5 changes: 4 additions & 1 deletion src/com/google/javascript/jscomp/testing/ScopeSubject.java
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.javascript.jscomp;
package com.google.javascript.jscomp.testing;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
Expand All @@ -25,6 +25,9 @@
import com.google.common.collect.ImmutableList;
import com.google.common.truth.FailureMetadata;
import com.google.common.truth.Subject;
import com.google.javascript.jscomp.AbstractScope;
import com.google.javascript.jscomp.AbstractVar;
import com.google.javascript.jscomp.TypedVar;
import com.google.javascript.rhino.Node;
import com.google.javascript.rhino.testing.TypeSubject;
import javax.annotation.CheckReturnValue;
Expand Down
Expand Up @@ -20,7 +20,7 @@
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.truth.Truth.assertThat;
import static com.google.javascript.jscomp.CompilerTestCase.lines;
import static com.google.javascript.jscomp.ScopeSubject.assertScope;
import static com.google.javascript.jscomp.testing.ScopeSubject.assertScope;
import static com.google.javascript.rhino.testing.NodeSubject.assertNode;

import com.google.common.collect.HashMultiset;
Expand Down
Expand Up @@ -19,7 +19,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.truth.Truth.assertThat;
import static com.google.javascript.jscomp.ScopeSubject.assertScope;
import static com.google.javascript.jscomp.testing.ScopeSubject.assertScope;

import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
Expand Down
Expand Up @@ -17,7 +17,7 @@
package com.google.javascript.jscomp;

import static com.google.common.truth.Truth.assertThat;
import static com.google.javascript.jscomp.ScopeSubject.assertScope;
import static com.google.javascript.jscomp.testing.ScopeSubject.assertScope;

import com.google.javascript.rhino.Node;
import com.google.javascript.rhino.Token;
Expand Down
2 changes: 1 addition & 1 deletion test/com/google/javascript/jscomp/TypeCheckTest.java
Expand Up @@ -19,10 +19,10 @@
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.javascript.jscomp.ScopeSubject.assertScope;
import static com.google.javascript.jscomp.TypeCheck.INSTANTIATE_ABSTRACT_CLASS;
import static com.google.javascript.jscomp.TypeCheck.STRICT_INEXISTENT_PROPERTY;
import static com.google.javascript.jscomp.parsing.JsDocInfoParser.BAD_TYPE_WIKI_LINK;
import static com.google.javascript.jscomp.testing.ScopeSubject.assertScope;
import static com.google.javascript.rhino.testing.Asserts.assertThrows;
import static com.google.javascript.rhino.testing.NodeSubject.assertNode;
import static com.google.javascript.rhino.testing.TypeSubject.assertType;
Expand Down
3 changes: 2 additions & 1 deletion test/com/google/javascript/jscomp/TypeInferenceTest.java
Expand Up @@ -21,7 +21,7 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.javascript.jscomp.CompilerTypeTestCase.lines;
import static com.google.javascript.jscomp.ScopeSubject.assertScope;
import static com.google.javascript.jscomp.testing.ScopeSubject.assertScope;
import static com.google.javascript.rhino.jstype.JSTypeNative.ALL_TYPE;
import static com.google.javascript.rhino.jstype.JSTypeNative.ARRAY_TYPE;
import static com.google.javascript.rhino.jstype.JSTypeNative.BOOLEAN_TYPE;
Expand All @@ -48,6 +48,7 @@
import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
import com.google.javascript.jscomp.DataFlowAnalysis.BranchedFlowState;
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback;
import com.google.javascript.jscomp.testing.ScopeSubject;
import com.google.javascript.jscomp.type.FlowScope;
import com.google.javascript.jscomp.type.ReverseAbstractInterpreter;
import com.google.javascript.rhino.IR;
Expand Down
Expand Up @@ -20,9 +20,9 @@
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.javascript.jscomp.ScopeSubject.assertScope;
import static com.google.javascript.jscomp.TypedScopeCreator.CTOR_INITIALIZER;
import static com.google.javascript.jscomp.TypedScopeCreator.IFACE_INITIALIZER;
import static com.google.javascript.jscomp.testing.ScopeSubject.assertScope;
import static com.google.javascript.rhino.jstype.JSTypeNative.BOOLEAN_TYPE;
import static com.google.javascript.rhino.jstype.JSTypeNative.NUMBER_TYPE;
import static com.google.javascript.rhino.jstype.JSTypeNative.OBJECT_TYPE;
Expand Down
2 changes: 1 addition & 1 deletion test/com/google/javascript/jscomp/VarCheckTest.java
Expand Up @@ -18,9 +18,9 @@

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.javascript.jscomp.ScopeSubject.assertScope;
import static com.google.javascript.jscomp.VarCheck.BLOCK_SCOPED_DECL_MULTIPLY_DECLARED_ERROR;
import static com.google.javascript.jscomp.VarCheck.VAR_MULTIPLY_DECLARED_ERROR;
import static com.google.javascript.jscomp.testing.ScopeSubject.assertScope;

import com.google.common.collect.ImmutableList;
import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
Expand Down

0 comments on commit 288468f

Please sign in to comment.