more specific uast generation api

IDEA-CR-57459

GitOrigin-RevId: 87b1559ff968f98ee0f732a8406273335ef6f762
This commit is contained in:
Anna Kozlova
2020-01-20 20:05:26 +00:00
committed by intellij-monorepo-bot
parent 25756f2a51
commit 0b5b4c438a
3 changed files with 5 additions and 4 deletions
@@ -119,7 +119,7 @@ public class I18nizeBatchQuickFix extends I18nizeQuickFix implements BatchQuickF
}
UastElementFactory pluginElementFactory = generationPlugin.getElementFactory(project);
List<UExpression> arguments = new ArrayList<>();
arguments.add(pluginElementFactory.createULiteralExpression("\"" + bean.getKey() + "\"", psiElement));
arguments.add(pluginElementFactory.createStringLiteralExpression(bean.getKey(), psiElement));
arguments.addAll(bean.getArgs());
UCallExpression callExpression = pluginElementFactory
.createCallExpression(pluginElementFactory.createQualifiedReference(bundleName, uExpression),
@@ -69,7 +69,7 @@ interface UastElementFactory {
fun createIfExpression(condition: UExpression, thenBranch: UExpression, elseBranch: UExpression? = null): UIfExpression?
fun createULiteralExpression(text: String, context: PsiElement?): ULiteralExpression?
fun createStringLiteralExpression(text: String, context: PsiElement?): ULiteralExpression?
}
@ApiStatus.Experimental
@@ -6,6 +6,7 @@ import com.intellij.lang.Language
import com.intellij.lang.java.JavaLanguage
import com.intellij.lang.jvm.JvmModifier
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.*
import com.intellij.psi.codeStyle.JavaCodeStyleManager
import com.intellij.psi.codeStyle.VariableKind
@@ -144,8 +145,8 @@ class JavaUastElementFactory(private val project: Project) : UastElementFactory
?.let { JavaUCallExpression(it, null) }
}
override fun createULiteralExpression(text: String, context: PsiElement?): ULiteralExpression? {
val literalExpr = psiFactory.createExpressionFromText(text, context)
override fun createStringLiteralExpression(text: String, context: PsiElement?): ULiteralExpression? {
val literalExpr = psiFactory.createExpressionFromText(StringUtil.wrapWithDoubleQuote(text), context)
if (literalExpr !is PsiLiteralExpressionImpl) return null
return JavaULiteralExpression(literalExpr, null)
}