Create Expression from text OpenApi Follow
Answered
How can I create a simple PsiExpression like the one below?
String variable = "hello";
--> "myString"+variable+"otherString"
After having created it I would like to parse it with the following command:
(String) JavaConstantExpressionEvaluator.computeConstantExpression(
(PsiExpression) expression, true);
Please sign in to leave a comment.
JavaPsiFacade.getElementFactory(project).createExpressionFromText creates a PsiExpression object. To make the reference inside resolve to a specific variable, please pass some context that has the variable declaration in its scope.
Solved