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.intellij.psi.PsiElement;
020 import org.jetbrains.annotations.NotNull;
021 import org.jetbrains.annotations.Nullable;
022 import org.jetbrains.jet.lang.diagnostics.Diagnostic;
023
024 import java.util.Collection;
025 import java.util.Collections;
026 import java.util.Iterator;
027
028 public interface Diagnostics extends Iterable<Diagnostic> {
029 @NotNull
030 Collection<Diagnostic> all();
031
032 @NotNull
033 Collection<Diagnostic> forElement(@NotNull PsiElement psiElement);
034
035 boolean isEmpty();
036
037 @NotNull
038 Diagnostics noSuppression();
039
040 Diagnostics EMPTY = new Diagnostics() {
041 @NotNull
042 @Override
043 public Collection<Diagnostic> all() {
044 return Collections.emptyList();
045 }
046
047 @NotNull
048 @Override
049 public Collection<Diagnostic> forElement(@NotNull PsiElement psiElement) {
050 return Collections.emptyList();
051 }
052
053 @Override
054 public boolean isEmpty() {
055 return true;
056 }
057
058 @NotNull
059 @Override
060 public Diagnostics noSuppression() {
061 return this;
062 }
063
064 @NotNull
065 @Override
066 public Iterator<Diagnostic> iterator() {
067 return all().iterator();
068 }
069 };
070 }