JetIntentionActionsFactory, JetSingleIntentionActionFactory: Translate to Kotlin

This commit is contained in:
Alexey Sedunov
2014-10-29 16:15:25 +03:00
parent aa2c10446b
commit 850f1ebccd
2 changed files with 18 additions and 38 deletions
@@ -14,16 +14,11 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.plugin.quickfix; package org.jetbrains.jet.plugin.quickfix
import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.intention.IntentionAction
import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.diagnostics.Diagnostic
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
import java.util.List; public trait JetIntentionActionsFactory {
public fun createActions(diagnostic: Diagnostic): List<IntentionAction>
public interface JetIntentionActionsFactory {
@NotNull
List<IntentionAction> createActions(@NotNull Diagnostic diagnostic);
} }
@@ -14,39 +14,24 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.plugin.quickfix; package org.jetbrains.jet.plugin.quickfix
import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.intention.IntentionAction
import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.diagnostics.Diagnostic
import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.psi.JetCodeFragment
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
import org.jetbrains.jet.lang.psi.JetCodeFragment;
import java.util.LinkedList; import java.util.Collections
import java.util.List; import org.jetbrains.jet.utils.addToStdlib.singletonOrEmptyList
public abstract class JetSingleIntentionActionFactory implements JetIntentionActionsFactory { public abstract class JetSingleIntentionActionFactory : JetIntentionActionsFactory {
public abstract fun createAction(diagnostic: Diagnostic): IntentionAction?
@Nullable override fun createActions(diagnostic: Diagnostic): List<IntentionAction> {
public abstract IntentionAction createAction(@NotNull Diagnostic diagnostic); if (diagnostic.getPsiElement().getContainingFile() is JetCodeFragment && !isApplicableForCodeFragment()) {
return Collections.emptyList()
@NotNull
@Override
public final List<IntentionAction> createActions(@NotNull Diagnostic diagnostic) {
List<IntentionAction> intentionActionList = new LinkedList<IntentionAction>();
if (diagnostic.getPsiElement().getContainingFile() instanceof JetCodeFragment && !isApplicableForCodeFragment()) {
return intentionActionList;
} }
return createAction(diagnostic).singletonOrEmptyList()
IntentionAction intentionAction = createAction(diagnostic);
if (intentionAction != null) {
intentionActionList.add(intentionAction);
}
return intentionActionList;
} }
public boolean isApplicableForCodeFragment() { public fun isApplicableForCodeFragment(): Boolean = false
return false;
}
} }