001 /*
002 * Copyright 2010-2013 JetBrains s.r.o.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package org.jetbrains.jet.lang.resolve;
018
019 import com.google.common.collect.ImmutableMap;
020 import org.jetbrains.annotations.NotNull;
021 import org.jetbrains.annotations.Nullable;
022 import org.jetbrains.jet.lang.diagnostics.Diagnostic;
023 import org.jetbrains.jet.util.slicedmap.ReadOnlySlice;
024 import org.jetbrains.jet.util.slicedmap.WritableSlice;
025
026 import java.util.Collection;
027
028 public class TraceUtil {
029 public final static BindingTrace TRACE_STUB = new BindingTrace() {
030
031 @NotNull
032 @Override
033 public BindingContext getBindingContext() {
034 return BINDING_CONTEXT_STUB;
035 }
036
037 @Override
038 public <K, V> void record(WritableSlice<K, V> slice, K key, V value) {
039 throw new IllegalStateException();
040 }
041
042 @Override
043 public <K> void record(WritableSlice<K, Boolean> slice, K key) {
044 throw new IllegalStateException();
045 }
046
047 @Nullable
048 @Override
049 public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
050 throw new IllegalStateException();
051 }
052
053 @NotNull
054 @Override
055 public <K, V> Collection<K> getKeys(WritableSlice<K, V> slice) {
056 throw new IllegalStateException();
057 }
058
059 @Override
060 public void report(@NotNull Diagnostic diagnostic) {
061 throw new IllegalStateException();
062 }
063 };
064
065 public final static BindingContext BINDING_CONTEXT_STUB = new BindingContext() {
066 @NotNull
067 @Override
068 public Diagnostics getDiagnostics() {
069 throw new IllegalStateException();
070 }
071
072 @Nullable
073 @Override
074 public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
075 throw new IllegalStateException();
076 }
077
078 @NotNull
079 @Override
080 public <K, V> Collection<K> getKeys(WritableSlice<K, V> slice) {
081 throw new IllegalStateException();
082 }
083
084 @NotNull
085 @Override
086 public <K, V> ImmutableMap<K, V> getSliceContents(@NotNull ReadOnlySlice<K, V> slice) {
087 throw new IllegalStateException();
088 }
089 };
090
091 public final static DelegatingBindingTrace DELEGATING_TRACE_STUB = new DelegatingBindingTrace(BINDING_CONTEXT_STUB, "Delegating trace stub") {
092
093 @Override
094 public <K, V> void record(WritableSlice<K, V> slice, K key, V value) {
095 throw new IllegalStateException();
096 }
097
098 @Override
099 public <K> void record(WritableSlice<K, Boolean> slice, K key) {
100 throw new IllegalStateException();
101 }
102
103 @Nullable
104 @Override
105 public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
106 throw new IllegalStateException();
107 }
108
109 @NotNull
110 @Override
111 public <K, V> Collection<K> getKeys(WritableSlice<K, V> slice) {
112 throw new IllegalStateException();
113 }
114
115 @Override
116 public void report(@NotNull Diagnostic diagnostic) {
117 throw new IllegalStateException();
118 }
119 };
120 }