Add factory methods for parenthesized expressions

This commit is contained in:
Alexey Sedunov
2013-04-26 13:55:35 +04:00
parent 36b68786b0
commit c054c0cdbe
@@ -429,4 +429,22 @@ public class JetPsiFactory {
public static JetWhenExpression createWhenWithoutSubject(Project project, int positiveBranchCount) {
return new WhenTemplateBuilder(false).addBranchesWithSingleCondition(positiveBranchCount).toExpression(project);
}
public static JetParenthesizedExpression createParenthesizedExpression(Project project, @NotNull String text) {
return (JetParenthesizedExpression)createExpression(project, "(" + text + ")");
}
@SuppressWarnings("ConstantConditions")
public static JetParenthesizedExpression createParenthesizedExpression(Project project, @NotNull JetExpression expression) {
JetParenthesizedExpression parenthesizedExpression = createParenthesizedExpression(project, "_");
parenthesizedExpression.getExpression().replace(expression);
return parenthesizedExpression;
}
public static JetParenthesizedExpression createParenthesizedExpressionIfNeeded(Project project, @NotNull JetExpression expression) {
return (expression instanceof JetParenthesizedExpression) ?
(JetParenthesizedExpression) expression :
createParenthesizedExpression(project, expression);
}
}