From cb127a5a62b196fe0da1f8671859fe6ba78a421c Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 24 Apr 2014 15:39:10 +0400 Subject: [PATCH] Diagnostics rewritten in Kotlin --- .../jet/lang/resolve/Diagnostics.java | 70 ------------------- .../jetbrains/jet/lang/resolve/Diagnostics.kt | 43 ++++++++++++ 2 files changed, 43 insertions(+), 70 deletions(-) delete mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/resolve/Diagnostics.java create mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/resolve/Diagnostics.kt diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/Diagnostics.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/Diagnostics.java deleted file mode 100644 index 081177fcd76..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/Diagnostics.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2010-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.lang.resolve; - -import com.intellij.psi.PsiElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.diagnostics.Diagnostic; - -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; - -public interface Diagnostics extends Iterable { - @NotNull - Collection all(); - - @NotNull - Collection forElement(@NotNull PsiElement psiElement); - - boolean isEmpty(); - - @NotNull - Diagnostics noSuppression(); - - Diagnostics EMPTY = new Diagnostics() { - @NotNull - @Override - public Collection all() { - return Collections.emptyList(); - } - - @NotNull - @Override - public Collection forElement(@NotNull PsiElement psiElement) { - return Collections.emptyList(); - } - - @Override - public boolean isEmpty() { - return true; - } - - @NotNull - @Override - public Diagnostics noSuppression() { - return this; - } - - @NotNull - @Override - public Iterator iterator() { - return all().iterator(); - } - }; -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/Diagnostics.kt b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/Diagnostics.kt new file mode 100644 index 00000000000..edd5a418d6d --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/Diagnostics.kt @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +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 { + fun all(): Collection + + fun forElement(psiElement: PsiElement): Collection + + fun isEmpty(): Boolean + + fun noSuppression(): Diagnostics + + class object { + + public val EMPTY: Diagnostics = object : Diagnostics { + override fun all() = listOf() + override fun forElement(psiElement: PsiElement) = listOf() + override fun isEmpty() = true + override fun noSuppression() = this + override fun iterator() = all().iterator() + } + } +}