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.diagnostic.Logger;
020 import org.jetbrains.annotations.NotNull;
021 import org.jetbrains.annotations.Nullable;
022 import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor;
023 import org.jetbrains.jet.lang.resolve.BindingTrace;
024 import org.jetbrains.jet.lang.resolve.OverrideResolver;
025 import org.jetbrains.jet.lang.resolve.kotlin.KotlinJvmBinaryClass;
026 import org.jetbrains.jet.lang.resolve.kotlin.VirtualFileKotlinClass;
027 import org.jetbrains.jet.util.slicedmap.Slices;
028 import org.jetbrains.jet.util.slicedmap.WritableSlice;
029
030 import javax.inject.Inject;
031
032 public class TraceBasedErrorReporter implements ErrorReporter {
033 private static final Logger LOG = Logger.getInstance(TraceBasedErrorReporter.class);
034
035 public static final WritableSlice<VirtualFileKotlinClass, Integer> ABI_VERSION_ERRORS = Slices.createCollectiveSlice();
036
037 private BindingTrace trace;
038
039 @Inject
040 public void setTrace(BindingTrace trace) {
041 this.trace = trace;
042 }
043
044 @Override
045 public void reportIncompatibleAbiVersion(@NotNull KotlinJvmBinaryClass kotlinClass, int actualVersion) {
046 trace.record(ABI_VERSION_ERRORS, (VirtualFileKotlinClass) kotlinClass, actualVersion);
047 }
048
049 @Override
050 public void reportCannotInferVisibility(@NotNull CallableMemberDescriptor descriptor) {
051 OverrideResolver.createCannotInferVisibilityReporter(trace).invoke(descriptor);
052 }
053
054 @Override
055 public void reportLoadingError(@NotNull String message, @Nullable Exception exception) {
056 LOG.error(message, exception);
057 }
058 }