Add factory methods for parenthesized expressions
This commit is contained in:
@@ -429,4 +429,22 @@ public class JetPsiFactory {
|
|||||||
public static JetWhenExpression createWhenWithoutSubject(Project project, int positiveBranchCount) {
|
public static JetWhenExpression createWhenWithoutSubject(Project project, int positiveBranchCount) {
|
||||||
return new WhenTemplateBuilder(false).addBranchesWithSingleCondition(positiveBranchCount).toExpression(project);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user