JavaToKotlinAction: fix KNPE
#EA-215300 Fixed
This commit is contained in:
@@ -172,7 +172,9 @@ class JavaToKotlinAction : AnAction() {
|
|||||||
|
|
||||||
var externalCodeUpdate: ((List<KtFile>) -> Unit)? = null
|
var externalCodeUpdate: ((List<KtFile>) -> Unit)? = null
|
||||||
|
|
||||||
if (enableExternalCodeProcessing && converterResult!!.externalCodeProcessing != null) {
|
val result = converterResult ?: return emptyList()
|
||||||
|
val externalCodeProcessing = result.externalCodeProcessing
|
||||||
|
if (enableExternalCodeProcessing && externalCodeProcessing != null) {
|
||||||
val question =
|
val question =
|
||||||
"Some code in the rest of your project may require corrections after performing this conversion. Do you want to find such code and correct it too?"
|
"Some code in the rest of your project may require corrections after performing this conversion. Do you want to find such code and correct it too?"
|
||||||
if (!askExternalCodeProcessing || (Messages.showYesNoDialog(
|
if (!askExternalCodeProcessing || (Messages.showYesNoDialog(
|
||||||
@@ -185,7 +187,7 @@ class JavaToKotlinAction : AnAction() {
|
|||||||
ProgressManager.getInstance().runProcessWithProgressSynchronously(
|
ProgressManager.getInstance().runProcessWithProgressSynchronously(
|
||||||
{
|
{
|
||||||
runReadAction {
|
runReadAction {
|
||||||
externalCodeUpdate = converterResult!!.externalCodeProcessing!!.prepareWriteOperation(
|
externalCodeUpdate = externalCodeProcessing.prepareWriteOperation(
|
||||||
ProgressManager.getInstance().progressIndicator!!
|
ProgressManager.getInstance().progressIndicator!!
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -200,7 +202,7 @@ class JavaToKotlinAction : AnAction() {
|
|||||||
return project.executeWriteCommand("Convert files from Java to Kotlin", null) {
|
return project.executeWriteCommand("Convert files from Java to Kotlin", null) {
|
||||||
CommandProcessor.getInstance().markCurrentCommandAsGlobal(project)
|
CommandProcessor.getInstance().markCurrentCommandAsGlobal(project)
|
||||||
|
|
||||||
val newFiles = saveResults(javaFiles, converterResult!!.results)
|
val newFiles = saveResults(javaFiles, result.results)
|
||||||
.map { it.toPsiFile(project) as KtFile }
|
.map { it.toPsiFile(project) as KtFile }
|
||||||
.onEach { it.commitAndUnblockDocument() }
|
.onEach { it.commitAndUnblockDocument() }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user