Converted file to Kotlin (step 2)
This commit is contained in:
+8
-14
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.actions
|
package org.jetbrains.kotlin.idea.actions
|
||||||
|
|
||||||
import com.google.common.collect.Lists
|
|
||||||
import com.intellij.codeInsight.daemon.QuickFixBundle
|
import com.intellij.codeInsight.daemon.QuickFixBundle
|
||||||
import com.intellij.codeInsight.daemon.impl.actions.AddImportAction
|
import com.intellij.codeInsight.daemon.impl.actions.AddImportAction
|
||||||
import com.intellij.codeInsight.hint.QuestionAction
|
import com.intellij.codeInsight.hint.QuestionAction
|
||||||
@@ -29,7 +28,6 @@ import com.intellij.openapi.ui.popup.PopupStep
|
|||||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep
|
import com.intellij.openapi.ui.popup.util.BaseListPopupStep
|
||||||
import com.intellij.psi.PsiDocumentManager
|
import com.intellij.psi.PsiDocumentManager
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.PsiFile
|
|
||||||
import com.intellij.util.PlatformIcons
|
import com.intellij.util.PlatformIcons
|
||||||
import org.jetbrains.kotlin.idea.JetBundle
|
import org.jetbrains.kotlin.idea.JetBundle
|
||||||
import org.jetbrains.kotlin.idea.quickfix.ImportInsertHelper
|
import org.jetbrains.kotlin.idea.quickfix.ImportInsertHelper
|
||||||
@@ -50,11 +48,7 @@ public class JetAddImportAction
|
|||||||
* @param imports Variants for resolution.
|
* @param imports Variants for resolution.
|
||||||
*/
|
*/
|
||||||
(private val myProject: Project, private val myEditor: Editor, private val myElement: PsiElement, imports: Iterable<FqName>) : QuestionAction {
|
(private val myProject: Project, private val myEditor: Editor, private val myElement: PsiElement, imports: Iterable<FqName>) : QuestionAction {
|
||||||
private val possibleImports: List<FqName>
|
private val possibleImports = imports.toList()
|
||||||
|
|
||||||
{
|
|
||||||
possibleImports = Lists.newArrayList<FqName>(imports)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun execute(): Boolean {
|
override fun execute(): Boolean {
|
||||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments()
|
PsiDocumentManager.getInstance(myProject).commitAllDocuments()
|
||||||
@@ -75,20 +69,20 @@ public class JetAddImportAction
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun getImportSelectionPopup(): BaseListPopupStep<Any> {
|
protected fun getImportSelectionPopup(): BaseListPopupStep<FqName> {
|
||||||
return object : BaseListPopupStep<FqName>(JetBundle.message("imports.chooser.title"), possibleImports) {
|
return object : BaseListPopupStep<FqName>(JetBundle.message("imports.chooser.title"), possibleImports) {
|
||||||
override fun isAutoSelectionEnabled(): Boolean {
|
override fun isAutoSelectionEnabled(): Boolean {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onChosen(selectedValue: FqName?, finalChoice: Boolean): PopupStep<Any>? {
|
override fun onChosen(selectedValue: FqName?, finalChoice: Boolean): PopupStep<String>? {
|
||||||
if (selectedValue == null) {
|
if (selectedValue == null) {
|
||||||
return PopupStep.FINAL_CHOICE
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalChoice) {
|
if (finalChoice) {
|
||||||
addImport(myElement, myProject, selectedValue)
|
addImport(myElement, myProject, selectedValue)
|
||||||
return PopupStep.FINAL_CHOICE
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
val toExclude = AddImportAction.getAllExcludableStrings(selectedValue.asString())
|
val toExclude = AddImportAction.getAllExcludableStrings(selectedValue.asString())
|
||||||
@@ -103,7 +97,7 @@ public class JetAddImportAction
|
|||||||
AddImportAction.excludeFromImport(myProject, selectedValue)
|
AddImportAction.excludeFromImport(myProject, selectedValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onChosen(selectedValue, finalChoice)
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,8 +131,8 @@ public class JetAddImportAction
|
|||||||
ApplicationManager.getApplication().runWriteAction(object : Runnable {
|
ApplicationManager.getApplication().runWriteAction(object : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
val file = element.getContainingFile()
|
val file = element.getContainingFile()
|
||||||
if (!(file is JetFile)) return
|
if (file !is JetFile) return
|
||||||
ImportInsertHelper.getInstance().addImportDirectiveIfNeeded(selectedImport, file as JetFile)
|
ImportInsertHelper.getInstance().addImportDirectiveIfNeeded(selectedImport, file)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user