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 @Override
032 public BindingContext getBindingContext() {
033 return BINDING_CONTEXT_STUB;
034 }
035
036 @Override
037 public <K, V> void record(WritableSlice<K, V> slice, K key, V value) {
038 throw new IllegalStateException();
039 }
040
041 @Override
042 public <K> void record(WritableSlice<K, Boolean> slice, K key) {
043 throw new IllegalStateException();
044 }
045
046 @Nullable
047 @Override
048 public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
049 throw new IllegalStateException();
050 }
051
052 @NotNull
053 @Override
054 public <K, V> Collection<K> getKeys(WritableSlice<K, V> slice) {
055 throw new IllegalStateException();
056 }
057
058 @Override
059 public void report(@NotNull Diagnostic diagnostic) {
060 throw new IllegalStateException();
061 }
062 };
063
064 public final static BindingContext BINDING_CONTEXT_STUB = new BindingContext() {
065 @NotNull
066 @Override
067 public Diagnostics getDiagnostics() {
068 throw new IllegalStateException();
069 }
070
071 @Nullable
072 @Override
073 public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
074 throw new IllegalStateException();
075 }
076
077 @NotNull
078 @Override
079 public <K, V> Collection<K> getKeys(WritableSlice<K, V> slice) {
080 throw new IllegalStateException();
081 }
082
083 @NotNull
084 @Override
085 public <K, V> ImmutableMap<K, V> getSliceContents(@NotNull ReadOnlySlice<K, V> slice) {
086 throw new IllegalStateException();
087 }
088 };
089
090 public final static DelegatingBindingTrace DELEGATING_TRACE_STUB = new DelegatingBindingTrace(BINDING_CONTEXT_STUB, "Delegating trace stub") {
091
092 @Override
093 public <K, V> void record(WritableSlice<K, V> slice, K key, V value) {
094 throw new IllegalStateException();
095 }
096
097 @Override
098 public <K> void record(WritableSlice<K, Boolean> slice, K key) {
099 throw new IllegalStateException();
100 }
101
102 @Nullable
103 @Override
104 public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
105 throw new IllegalStateException();
106 }
107
108 @NotNull
109 @Override
110 public <K, V> Collection<K> getKeys(WritableSlice<K, V> slice) {
111 throw new IllegalStateException();
112 }
113
114 @Override
115 public void report(@NotNull Diagnostic diagnostic) {
116 throw new IllegalStateException();
117 }
118 };
119 }