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.
请先登录再写评论。
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.
Thanks. Now I get the point of how `createPhpPsiFromText` works.