diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java index a82dcc47615..4d2d57f4017 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java @@ -16,9 +16,11 @@ package org.jetbrains.jet.lang.resolve; +import com.google.common.collect.ImmutableMap; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.diagnostics.Diagnostic; @@ -59,6 +61,13 @@ public interface BindingContext { public Collection getKeys(WritableSlice slice) { return Collections.emptyList(); } + + @NotNull + @TestOnly + @Override + public ImmutableMap getSliceContents(@NotNull ReadOnlySlice slice) { + return ImmutableMap.of(); + } }; WritableSlice ANNOTATION_DESCRIPTOR_TO_PSI_ELEMENT = Slices.createSimpleSlice(); @@ -253,4 +262,9 @@ public interface BindingContext { // slice.isCollective() must be true @NotNull Collection getKeys(WritableSlice slice); + + /** This method should be used only for debug and testing */ + @TestOnly + @NotNull + ImmutableMap getSliceContents(@NotNull ReadOnlySlice slice); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java index 3eddd9bf206..e22ae473589 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java @@ -16,8 +16,10 @@ package org.jetbrains.jet.lang.resolve; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; import org.jetbrains.jet.lang.diagnostics.Diagnostic; import org.jetbrains.jet.util.slicedmap.MutableSlicedMap; import org.jetbrains.jet.util.slicedmap.ReadOnlySlice; @@ -52,6 +54,13 @@ public class BindingTraceContext implements BindingTrace { public Collection getKeys(WritableSlice slice) { return BindingTraceContext.this.getKeys(slice); } + + @NotNull + @TestOnly + @Override + public ImmutableMap getSliceContents(@NotNull ReadOnlySlice slice) { + return map.getSliceContents(slice); + } }; @Override diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DelegatingBindingTrace.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DelegatingBindingTrace.java index a31a5581000..110abc5c45e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DelegatingBindingTrace.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DelegatingBindingTrace.java @@ -16,10 +16,11 @@ package org.jetbrains.jet.lang.resolve; -import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; import org.jetbrains.jet.lang.diagnostics.Diagnostic; import org.jetbrains.jet.util.slicedmap.*; @@ -55,6 +56,15 @@ public class DelegatingBindingTrace implements BindingTrace { return DelegatingBindingTrace.this.getKeys(slice); } + + @NotNull + @TestOnly + @Override + public ImmutableMap getSliceContents(@NotNull ReadOnlySlice slice) { + ImmutableMap parentContents = parentContext.getSliceContents(slice); + ImmutableMap currentContents = map.getSliceContents(slice); + return ImmutableMap.builder().putAll(parentContents).putAll(currentContents).build(); + } }; public DelegatingBindingTrace(BindingContext parentContext) { diff --git a/compiler/tests/org/jetbrains/jet/JetTestUtils.java b/compiler/tests/org/jetbrains/jet/JetTestUtils.java index 6a9f2c3c717..1e1ce1b16cc 100644 --- a/compiler/tests/org/jetbrains/jet/JetTestUtils.java +++ b/compiler/tests/org/jetbrains/jet/JetTestUtils.java @@ -16,6 +16,7 @@ package org.jetbrains.jet; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.intellij.openapi.Disposable; @@ -30,6 +31,7 @@ import com.intellij.testFramework.LightVirtualFile; import junit.framework.TestCase; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; import org.jetbrains.jet.analyzer.AnalyzeExhaust; import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; import org.jetbrains.jet.lang.BuiltinsScopeExtensionMode; @@ -87,6 +89,13 @@ public class JetTestUtils { public Collection getKeys(WritableSlice slice) { return DUMMY_TRACE.getKeys(slice); } + + @NotNull + @TestOnly + @Override + public ImmutableMap getSliceContents(@NotNull ReadOnlySlice slice) { + return ImmutableMap.of(); + } }; } @@ -138,6 +147,13 @@ public class JetTestUtils { public Collection getKeys(WritableSlice slice) { return DUMMY_EXCEPTION_ON_ERROR_TRACE.getKeys(slice); } + + @NotNull + @TestOnly + @Override + public ImmutableMap getSliceContents(@NotNull ReadOnlySlice slice) { + return ImmutableMap.of(); + } }; }