Inject wrapped expression into braces

Hello. I`m trying to change PHP file content on QF. 

val code = PhpPsiElementFactory.createPhpPsiFromText(
project,
NewExpressionImpl::class.java,
"new $selectFqn()"
)
reference.replace(code)

it works great. But in some cases i need to inject wrapped expression. 

Instead of `new UserSelect()` i need `(new UserSelect())`.

How can I create and insert this expression (surrounded by braces)? Thanks for the help.

0

Try to brace it in text and ask for appropriate element type - e.g. parenthesised expression... PsiViewer plugin will help you to found relevant element types.

0

Thanks. Now I get the point of how `createPhpPsiFromText` works.

0

请先登录再写评论。