use of org.jetbrains.kotlin.psi.KtParenthesizedExpression in project kotlin by JetBrains.
the class KotlinNotSurrounder method surroundExpression.
@Nullable
@Override
public TextRange surroundExpression(@NotNull Project project, @NotNull Editor editor, @NotNull KtExpression expression) {
KtPrefixExpression prefixExpr = (KtPrefixExpression) KtPsiFactoryKt.KtPsiFactory(expression).createExpression("!(a)");
KtParenthesizedExpression parenthesizedExpression = (KtParenthesizedExpression) prefixExpr.getBaseExpression();
assert parenthesizedExpression != null : "JetParenthesizedExpression should exists for " + prefixExpr.getText() + " expression";
KtExpression expressionWithoutParentheses = parenthesizedExpression.getExpression();
assert expressionWithoutParentheses != null : "JetExpression should exists for " + parenthesizedExpression.getText() + " expression";
expressionWithoutParentheses.replace(expression);
expression = (KtExpression) expression.replace(prefixExpr);
CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(expression);
int offset = expression.getTextRange().getEndOffset();
return new TextRange(offset, offset);
}
use of org.jetbrains.kotlin.psi.KtParenthesizedExpression in project kotlin by JetBrains.
the class KotlinParenthesesSurrounder method surroundExpression.
@Nullable
@Override
public TextRange surroundExpression(@NotNull Project project, @NotNull Editor editor, @NotNull KtExpression expression) {
KtParenthesizedExpression parenthesizedExpression = (KtParenthesizedExpression) KtPsiFactoryKt.KtPsiFactory(expression).createExpression("(a)");
KtExpression expressionWithoutParentheses = parenthesizedExpression.getExpression();
assert expressionWithoutParentheses != null : "JetExpression should exists for " + parenthesizedExpression.getText() + " expression";
expressionWithoutParentheses.replace(expression);
expression = (KtExpression) expression.replace(parenthesizedExpression);
CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(expression);
int offset = expression.getTextRange().getEndOffset();
return new TextRange(offset, offset);
}
Aggregations