New J2K: pass converter context to postprocessing
This commit is contained in:
committed by
Ilya Kirillov
parent
c4a238cca4
commit
39b09b39ff
+9
-2
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
|
||||
import org.jetbrains.kotlin.idea.debugger.KotlinEditorTextProvider
|
||||
import org.jetbrains.kotlin.idea.debugger.evaluate.compilation.DebugLabelPropertyDescriptorProvider
|
||||
import org.jetbrains.kotlin.idea.j2k.JavaToKotlinConverterFactory
|
||||
import org.jetbrains.kotlin.idea.refactoring.convertToKotlin
|
||||
import org.jetbrains.kotlin.idea.refactoring.j2k
|
||||
import org.jetbrains.kotlin.idea.refactoring.j2kText
|
||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||
@@ -242,7 +243,8 @@ class KotlinCodeFragmentFactory : CodeFragmentFactory() {
|
||||
var convertedFragment: KtExpressionCodeFragment? = null
|
||||
project.executeWriteCommand("Convert java expression to kotlin in Evaluate Expression") {
|
||||
try {
|
||||
val newText = javaExpression.j2kText()
|
||||
val (elementResults, _, conversionContext) = javaExpression.convertToKotlin() ?: return@executeWriteCommand
|
||||
val newText = elementResults.singleOrNull()?.text
|
||||
val newImports = importList?.j2kText()
|
||||
if (newText != null) {
|
||||
convertedFragment = KtExpressionCodeFragment(
|
||||
@@ -253,7 +255,12 @@ class KotlinCodeFragmentFactory : CodeFragmentFactory() {
|
||||
kotlinCodeFragment.context
|
||||
)
|
||||
|
||||
AfterConversionPass(project, JavaToKotlinConverterFactory.createPostProcessor(formatCode = false)).run(convertedFragment!!, range = null)
|
||||
AfterConversionPass(project, JavaToKotlinConverterFactory.createPostProcessor(formatCode = false))
|
||||
.run(
|
||||
convertedFragment!!,
|
||||
conversionContext,
|
||||
range = null
|
||||
)
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
// ignored because text can be invalid
|
||||
|
||||
Reference in New Issue
Block a user