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.

2 comments
Comment actions Permalink

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
Comment actions Permalink

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

0

Please sign in to leave a comment.