Default implementations for some functions in Diagnostics

This commit is contained in:
Pavel V. Talanov
2014-10-08 21:30:08 +04:00
parent b98f000c29
commit d7c06f0527
2 changed files with 4 additions and 10 deletions
@@ -17,27 +17,25 @@
package org.jetbrains.jet.lang.resolve
import com.intellij.psi.PsiElement
import org.jetbrains.annotations.ReadOnly
import org.jetbrains.jet.lang.diagnostics.Diagnostic
import java.util.Collections
public trait Diagnostics : Iterable<Diagnostic> {
public fun all(): Collection<Diagnostic>
public fun forElement(psiElement: PsiElement): Collection<Diagnostic>
public fun isEmpty(): Boolean
public fun isEmpty(): Boolean = all().isEmpty()
public fun noSuppression(): Diagnostics
override fun iterator() = all().iterator()
class object {
public val EMPTY: Diagnostics = object : Diagnostics {
override fun noSuppression(): Diagnostics = this
override fun all() = listOf<Diagnostic>()
override fun forElement(psiElement: PsiElement) = listOf<Diagnostic>()
override fun isEmpty() = true
override fun noSuppression() = this
override fun iterator() = all().iterator()
}
}
}
@@ -30,8 +30,4 @@ public class SimpleDiagnostics(diagnostics: Collection<Diagnostic>) : Diagnostic
override fun forElement(psiElement: PsiElement) = elementsCache.getDiagnostics(psiElement)
override fun noSuppression() = this
override fun iterator() = all().iterator()
override fun isEmpty() = all().isEmpty()
}