use of com.goide.psi.GoRecvStatement in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoReplaceAssignmentWithDeclarationQuickFix method invoke.
@Override
public void invoke(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) {
if (startElement instanceof GoAssignmentStatement) {
GoAssignmentStatement statement = (GoAssignmentStatement) startElement;
String leftSide = statement.getLeftHandExprList().getText();
String rightSide = GoPsiImplUtil.joinPsiElementText(statement.getExpressionList());
statement.replace(GoElementFactory.createShortVarDeclarationStatement(project, leftSide, rightSide));
} else if (startElement instanceof GoRangeClause) {
GoRangeClause rangeClause = (GoRangeClause) startElement;
String leftSide = GoPsiImplUtil.joinPsiElementText(rangeClause.getLeftExpressionsList());
GoExpression rangeExpression = rangeClause.getRangeExpression();
String rightSide = rangeExpression != null ? rangeExpression.getText() : "";
rangeClause.replace(GoElementFactory.createRangeClause(project, leftSide, rightSide));
} else if (startElement instanceof GoRecvStatement) {
GoRecvStatement recvStatement = (GoRecvStatement) startElement;
String leftSide = GoPsiImplUtil.joinPsiElementText(recvStatement.getLeftExpressionsList());
GoExpression recvExpression = recvStatement.getRecvExpression();
String rightSide = recvExpression != null ? recvExpression.getText() : "";
recvStatement.replace(GoElementFactory.createRecvStatement(project, leftSide, rightSide));
}
}
Aggregations