mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
[uast] UastElementFactory.createReturnExpression: fix incorrect name
GitOrigin-RevId: 0a855337810fc979607b26b54acd1c89342757a0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d242e3fdbc
commit
5c3372c82d
@@ -343,10 +343,10 @@ class KotlinUastElementFactory(project: Project) : UastElementFactory {
|
||||
@Deprecated("use version with context parameter")
|
||||
fun createReturnExpresion(expression: UExpression?, inLambda: Boolean): UReturnExpression {
|
||||
logger<KotlinUastElementFactory>().error("Please switch caller to the version with a context parameter")
|
||||
return createReturnExpresion(expression, inLambda, null)
|
||||
return createReturnExpression(expression, inLambda, null)
|
||||
}
|
||||
|
||||
override fun createReturnExpresion(expression: UExpression?, inLambda: Boolean, context: PsiElement?): UReturnExpression {
|
||||
override fun createReturnExpression(expression: UExpression?, inLambda: Boolean, context: PsiElement?): UReturnExpression {
|
||||
val label = if (inLambda && context != null) getParentLambdaLabelName(context)?.let { "@$it" } ?: "" else ""
|
||||
val returnExpression = psiFactory(context).createExpression("return$label 1") as KtReturnExpression
|
||||
val sourcePsi = expression?.sourcePsi
|
||||
|
||||
@@ -120,7 +120,7 @@ class KotlinUastGenerationTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
val expression = psiFactory.createExpression("a + b").toUElementOfType<UExpression>()
|
||||
?: kfail("Cannot find plugin")
|
||||
|
||||
val returnExpression = uastElementFactory.createReturnExpresion(expression, false, dummyContextFile())
|
||||
val returnExpression = uastElementFactory.createReturnExpression(expression, false, dummyContextFile())
|
||||
TestCase.assertEquals("a + b", returnExpression.returnExpression?.asRenderString())
|
||||
TestCase.assertEquals("return a + b", returnExpression.sourcePsi?.text)
|
||||
}
|
||||
@@ -682,7 +682,7 @@ class KotlinUastGenerationTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
UastBinaryOperator.GREATER,
|
||||
uLambdaExpression.sourcePsi
|
||||
)!!,
|
||||
createReturnExpresion(
|
||||
createReturnExpression(
|
||||
createStringLiteralExpression("exit", uLambdaExpression.sourcePsi), true,
|
||||
uLambdaExpression.sourcePsi
|
||||
),
|
||||
@@ -776,7 +776,7 @@ class KotlinUastGenerationTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
uLambdaExpression.sourcePsi
|
||||
)!!,
|
||||
oldBlockExpression,
|
||||
createReturnExpresion(
|
||||
createReturnExpression(
|
||||
createStringLiteralExpression("exit", uLambdaExpression.sourcePsi), true,
|
||||
uLambdaExpression.sourcePsi
|
||||
),
|
||||
@@ -893,7 +893,7 @@ class KotlinUastGenerationTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
val localVariable = uastElementFactory.createLocalVariable("a", null, uastElementFactory.createNullLiteral(context), true, context)
|
||||
val declarationExpression =
|
||||
uastElementFactory.createDeclarationExpression(listOf(localVariable), context)
|
||||
val returnExpression = uastElementFactory.createReturnExpresion(
|
||||
val returnExpression = uastElementFactory.createReturnExpression(
|
||||
uastElementFactory.createSimpleReference(localVariable, context), false, context
|
||||
)
|
||||
val block = uastElementFactory.createBlockExpression(listOf(declarationExpression, returnExpression), context)
|
||||
|
||||
@@ -133,9 +133,9 @@ interface UastElementFactory {
|
||||
fun createParenthesizedExpression(expression: UExpression,
|
||||
context: PsiElement?): UParenthesizedExpression?
|
||||
|
||||
fun createReturnExpresion(expression: UExpression?,
|
||||
inLambda: Boolean = false,
|
||||
context: PsiElement?): UReturnExpression?
|
||||
fun createReturnExpression(expression: UExpression?,
|
||||
inLambda: Boolean = false,
|
||||
context: PsiElement?): UReturnExpression?
|
||||
|
||||
fun createLocalVariable(suggestedName: String?,
|
||||
type: PsiType?,
|
||||
|
||||
@@ -327,9 +327,9 @@ class JavaUastElementFactory(private val project: Project) : UastElementFactory
|
||||
return JavaUDeclarationsExpression(null, declarations)
|
||||
}
|
||||
|
||||
override fun createReturnExpresion(expression: UExpression?,
|
||||
inLambda: Boolean,
|
||||
context: PsiElement?): UReturnExpression? {
|
||||
override fun createReturnExpression(expression: UExpression?,
|
||||
inLambda: Boolean,
|
||||
context: PsiElement?): UReturnExpression? {
|
||||
val returnStatement = psiFactory.createStatementFromText("return ;", null) as? PsiReturnStatement ?: return null
|
||||
|
||||
expression?.sourcePsi?.node?.let { (returnStatement as CompositeElement).addChild(it, returnStatement.lastChild.node) }
|
||||
|
||||
@@ -88,7 +88,7 @@ class JavaUastGenerationTest : AbstractJavaUastLightTest() {
|
||||
val expression = psiFactory.createExpressionFromText("a + b", null).toUElementOfType<UExpression>()
|
||||
?: fail("Cannot find plugin")
|
||||
|
||||
val returnExpression = uastElementFactory.createReturnExpresion(expression, false, null) ?: fail("cannot create return expression")
|
||||
val returnExpression = uastElementFactory.createReturnExpression(expression, false, null) ?: fail("cannot create return expression")
|
||||
|
||||
TestCase.assertEquals("return a + b;", returnExpression.sourcePsi?.text)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user