void (@NotNull PsiVariable qualifier, @NotNull PsiMethodCallExpression oldExpression) { String qualifierPresentableText = qualifier.getName(); PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(qualifier.getProject()); PsiMethodCallExpression expression = (PsiMethodCallExpression)elementFactory .createExpressionFromText(qualifierPresentableText + "." + oldExpression.getMethodExpression().getReferenceName() + "()", null); oldExpression.getMethodExpression().replace(expression.getMethodExpression()); }