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 @Override
066 public Collection<Diagnostic> getDiagnostics() {
067 throw new IllegalStateException();
068 }
069
070 @Nullable
071 @Override
072 public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
073 throw new IllegalStateException();
074 }
075
076 @NotNull
077 @Override
078 public <K, V> Collection<K> getKeys(WritableSlice<K, V> slice) {
079 throw new IllegalStateException();
080 }
081
082 @NotNull
083 @Override
084 public <K, V> ImmutableMap<K, V> getSliceContents(@NotNull ReadOnlySlice<K, V> slice) {
085 throw new IllegalStateException();
086 }
087 };
088
089 public final static DelegatingBindingTrace DELEGATING_TRACE_STUB = new DelegatingBindingTrace(BINDING_CONTEXT_STUB, "Delegating trace stub") {
090
091 @Override
092 public <K, V> void record(WritableSlice<K, V> slice, K key, V value) {
093 throw new IllegalStateException();
094 }
095
096 @Override
097 public <K> void record(WritableSlice<K, Boolean> slice, K key) {
098 throw new IllegalStateException();
099 }
100
101 @Nullable
102 @Override
103 public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
104 throw new IllegalStateException();
105 }
106
107 @NotNull
108 @Override
109 public <K, V> Collection<K> getKeys(WritableSlice<K, V> slice) {
110 throw new IllegalStateException();
111 }
112
113 @Override
114 public void report(@NotNull Diagnostic diagnostic) {
115 throw new IllegalStateException();
116 }
117 };
118 }