diff --git a/src/com/google/javascript/jscomp/AbstractScope.java b/src/com/google/javascript/jscomp/AbstractScope.java index 44e4d5531b8..78633f98d7a 100644 --- a/src/com/google/javascript/jscomp/AbstractScope.java +++ b/src/com/google/javascript/jscomp/AbstractScope.java @@ -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, V extends AbstractVar> +public abstract class AbstractScope, V extends AbstractVar> implements StaticScope, Serializable { private final Map vars = new LinkedHashMap<>(); private final Map implicitVars = new EnumMap<>(ImplicitVar.class); @@ -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(); diff --git a/src/com/google/javascript/jscomp/testing/ScopeSubject.java b/src/com/google/javascript/jscomp/testing/ScopeSubject.java index 11013aeea70..8973daad4f4 100644 --- a/src/com/google/javascript/jscomp/testing/ScopeSubject.java +++ b/src/com/google/javascript/jscomp/testing/ScopeSubject.java @@ -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; @@ -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; diff --git a/test/com/google/javascript/jscomp/Es6SyntacticScopeCreatorTest.java b/test/com/google/javascript/jscomp/Es6SyntacticScopeCreatorTest.java index 3750ea3bf82..b9b0edbfcc7 100644 --- a/test/com/google/javascript/jscomp/Es6SyntacticScopeCreatorTest.java +++ b/test/com/google/javascript/jscomp/Es6SyntacticScopeCreatorTest.java @@ -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; diff --git a/test/com/google/javascript/jscomp/IncrementalScopeCreatorTest.java b/test/com/google/javascript/jscomp/IncrementalScopeCreatorTest.java index 79abb576065..571f6388cb3 100644 --- a/test/com/google/javascript/jscomp/IncrementalScopeCreatorTest.java +++ b/test/com/google/javascript/jscomp/IncrementalScopeCreatorTest.java @@ -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; diff --git a/test/com/google/javascript/jscomp/SyntacticScopeCreatorTest.java b/test/com/google/javascript/jscomp/SyntacticScopeCreatorTest.java index d6e19da5622..9814e04c775 100644 --- a/test/com/google/javascript/jscomp/SyntacticScopeCreatorTest.java +++ b/test/com/google/javascript/jscomp/SyntacticScopeCreatorTest.java @@ -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; diff --git a/test/com/google/javascript/jscomp/TypeCheckTest.java b/test/com/google/javascript/jscomp/TypeCheckTest.java index 71af0a7ed63..ee1aa0f9d01 100644 --- a/test/com/google/javascript/jscomp/TypeCheckTest.java +++ b/test/com/google/javascript/jscomp/TypeCheckTest.java @@ -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; diff --git a/test/com/google/javascript/jscomp/TypeInferenceTest.java b/test/com/google/javascript/jscomp/TypeInferenceTest.java index 8a225ad5bec..1745b215773 100644 --- a/test/com/google/javascript/jscomp/TypeInferenceTest.java +++ b/test/com/google/javascript/jscomp/TypeInferenceTest.java @@ -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; @@ -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; diff --git a/test/com/google/javascript/jscomp/TypedScopeCreatorTest.java b/test/com/google/javascript/jscomp/TypedScopeCreatorTest.java index 0410c54cbcc..e340d18f508 100644 --- a/test/com/google/javascript/jscomp/TypedScopeCreatorTest.java +++ b/test/com/google/javascript/jscomp/TypedScopeCreatorTest.java @@ -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; diff --git a/test/com/google/javascript/jscomp/VarCheckTest.java b/test/com/google/javascript/jscomp/VarCheckTest.java index f5b603a20c0..342781cfd08 100644 --- a/test/com/google/javascript/jscomp/VarCheckTest.java +++ b/test/com/google/javascript/jscomp/VarCheckTest.java @@ -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;