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.java.resolver;
018
019 import com.intellij.openapi.vfs.VirtualFile;
020 import org.jetbrains.annotations.NotNull;
021 import org.jetbrains.jet.lang.resolve.BindingTrace;
022 import org.jetbrains.jet.lang.resolve.name.FqName;
023 import org.jetbrains.jet.util.slicedmap.BasicWritableSlice;
024 import org.jetbrains.jet.util.slicedmap.Slices;
025 import org.jetbrains.jet.util.slicedmap.WritableSlice;
026
027 import javax.inject.Inject;
028
029 public class TraceBasedErrorReporter implements ErrorReporter {
030 public static final WritableSlice<AbiVersionErrorLocation, Integer> ABI_VERSION_ERRORS =
031 new BasicWritableSlice<AbiVersionErrorLocation, Integer>(Slices.ONLY_REWRITE_TO_EQUAL, true);
032 private BindingTrace trace;
033
034 @Inject
035 public void setTrace(BindingTrace trace) {
036 this.trace = trace;
037 }
038
039 @Override
040 public void reportIncompatibleAbiVersion(@NotNull FqName fqName, @NotNull VirtualFile file, int actualVersion) {
041 trace.record(ABI_VERSION_ERRORS, new AbiVersionErrorLocation(fqName, file), actualVersion);
042 }
043
044 public static final class AbiVersionErrorLocation {
045 @NotNull
046 private final FqName classFqName;
047 @NotNull
048 private final VirtualFile file;
049
050 public AbiVersionErrorLocation(@NotNull FqName name, @NotNull VirtualFile file) {
051 this.classFqName = name;
052 this.file = file;
053 }
054
055 @NotNull
056 public FqName getClassFqName() {
057 return classFqName;
058 }
059
060 @NotNull
061 public String getPath() {
062 return file.getPath();
063 }
064 }
065 }