public function getLocations()
    {
        if ($this->locations === null) {
            $positions = $this->getPositions();
            $source    = $this->getSource();
            $nodes     = $this->nodes;

            if ($positions && $source) {
                $this->locations = array_map(
                    static function ($pos) use ($source) {
                        return $source->getLocation($pos);
                    },
                    $positions
                );
            } elseif ($nodes) {
                $locations       = array_filter(
                    array_map(
                        static function ($node) {
                            if ($node->loc && $node->loc->source) {
                                return $node->loc->source->getLocation($node->loc->start);
                            }
                        },
                        $nodes
                    )
                );
                $this->locations = array_values($locations);
            } else {
                $this->locations = [];
            }
        }

        return $this->locations;
    }