CreateExpectedFix: add escaping for error text

This commit is contained in:
Dmitry Gridin
2019-08-20 19:35:08 +07:00
parent 3617f3d247
commit 7c850e44d2
@@ -12,6 +12,7 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.module.Module import com.intellij.openapi.module.Module
import com.intellij.openapi.project.Project import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.showOkNoDialog import com.intellij.openapi.ui.showOkNoDialog
import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor
@@ -180,10 +181,12 @@ private tailrec fun TypeAccessibilityChecker.findAndApplyExistingClasses(element
private fun showUnknownTypesDialog(project: Project, declarationsWithNonExistentClasses: Collection<KtNamedDeclaration>): Boolean = private fun showUnknownTypesDialog(project: Project, declarationsWithNonExistentClasses: Collection<KtNamedDeclaration>): Boolean =
declarationsWithNonExistentClasses.isEmpty() || showOkNoDialog( declarationsWithNonExistentClasses.isEmpty() || showOkNoDialog(
"Unknown types", "Unknown types",
declarationsWithNonExistentClasses.joinToString( StringUtil.escapeXmlEntities(
prefix = "These declarations cannot be transformed:\n", declarationsWithNonExistentClasses.joinToString(
separator = "\n", prefix = "These declarations cannot be transformed:\n",
transform = ::getExpressionShortText separator = "\n",
transform = ::getExpressionShortText
)
), ),
project project
) )
@@ -193,7 +196,7 @@ private fun showUnknownTypesError(element: KtNamedDeclaration) {
showErrorHint( showErrorHint(
element.project, element.project,
editor, editor,
"You cannot create the expect declaration from:\n${getExpressionShortText(element)}", "You cannot create the expect declaration from:\n${StringUtil.escapeXmlEntities(getExpressionShortText(element))}",
"Unknown types" "Unknown types"
) )
} }