Default implementations for some functions in Diagnostics
This commit is contained in:
@@ -17,27 +17,25 @@
|
|||||||
package org.jetbrains.jet.lang.resolve
|
package org.jetbrains.jet.lang.resolve
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.annotations.ReadOnly
|
|
||||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic
|
import org.jetbrains.jet.lang.diagnostics.Diagnostic
|
||||||
import java.util.Collections
|
|
||||||
|
|
||||||
public trait Diagnostics : Iterable<Diagnostic> {
|
public trait Diagnostics : Iterable<Diagnostic> {
|
||||||
public fun all(): Collection<Diagnostic>
|
public fun all(): Collection<Diagnostic>
|
||||||
|
|
||||||
public fun forElement(psiElement: PsiElement): Collection<Diagnostic>
|
public fun forElement(psiElement: PsiElement): Collection<Diagnostic>
|
||||||
|
|
||||||
public fun isEmpty(): Boolean
|
public fun isEmpty(): Boolean = all().isEmpty()
|
||||||
|
|
||||||
public fun noSuppression(): Diagnostics
|
public fun noSuppression(): Diagnostics
|
||||||
|
|
||||||
|
override fun iterator() = all().iterator()
|
||||||
|
|
||||||
class object {
|
class object {
|
||||||
|
|
||||||
public val EMPTY: Diagnostics = object : Diagnostics {
|
public val EMPTY: Diagnostics = object : Diagnostics {
|
||||||
|
override fun noSuppression(): Diagnostics = this
|
||||||
override fun all() = listOf<Diagnostic>()
|
override fun all() = listOf<Diagnostic>()
|
||||||
override fun forElement(psiElement: PsiElement) = 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 forElement(psiElement: PsiElement) = elementsCache.getDiagnostics(psiElement)
|
||||||
|
|
||||||
override fun noSuppression() = this
|
override fun noSuppression() = this
|
||||||
|
|
||||||
override fun iterator() = all().iterator()
|
|
||||||
|
|
||||||
override fun isEmpty() = all().isEmpty()
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user