private function getCompletionsForAliases(
        string $prefix,
        array $aliases,
        bool $requireCanBeInstantiated
    ): \Generator {
        foreach ($aliases as $alias => $aliasFqn) {
            if (!nameStartsWith($alias, $prefix)) {
                continue;
            }
            $definition = $this->index->getDefinition((string)$aliasFqn);
            if ($definition) {
                if ($requireCanBeInstantiated && !$definition->canBeInstantiated) {
                    continue;
                }
                $completionItem = CompletionItemFactory::fromDefinition($definition);
                $completionItem->insertText = $alias;
                yield (string)$aliasFqn => $completionItem;
            }
        }
    }