Idealization and devaluation
Psychoanalytic theory posits that an individual unable to integrate difficult feelings mobilizes specific defenses to overcome these feelings, which the individual perceives to be unbearable. The defense that effects (brings about) this process is called splitting.
Source: Wikipedia — Idealization and devaluation (CC BY-SA 4.0)