PsiMethodCallExpression methodCallExpression = ...; PsiMethodCallExpression newMethodCallExpression = ...; methodCallExpression.replace(newMethodCallExpression);
PsiVariableDeclarationStatement variableDeclaration = ...; PsiAssignmentStatement newAssignment = ...; variableDeclaration.replace(newAssignment);In this example, we have a PsiVariableDeclarationStatement object called variableDeclaration. We want to replace this statement with a new assignment statement, which is represented by the newAssignment object. We call the replace() method on the variableDeclaration object and pass in the newAssignment object as the parameter. The com.intellij.psi package is a part of the IntelliJ IDEA platform and is not a standalone library/package. It is included as a part of IntelliJ IDEA and other IDEs based on the IntelliJ IDEA platform, such as Android Studio.