forked from qt-creator/qt-creator
Utils: Remove variant.h
Since we are now requiring macOS 10.14 we can remove our local copy of std::variant and use for macOS std::variant too. Change-Id: I589d03b35fc56878b7392ffa7047a439e588fe43 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -411,7 +411,7 @@ ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir)
|
||||
|
||||
connect(this, &Client::workDone, this,
|
||||
[this, p = QPointer(project)](const ProgressToken &token) {
|
||||
const QString * const val = Utils::get_if<QString>(&token);
|
||||
const QString * const val = std::get_if<QString>(&token);
|
||||
if (val && *val == indexingToken()) {
|
||||
d->isFullyIndexed = true;
|
||||
emit indexingFinished();
|
||||
@@ -511,7 +511,7 @@ void ClangdClient::handleDiagnostics(const PublishDiagnosticsParams ¶ms)
|
||||
// We know that there's only one kind of diagnostic for which clangd has
|
||||
// a quickfix tweak, so let's not be wasteful.
|
||||
const Diagnostic::Code code = diagnostic.code().value_or(Diagnostic::Code());
|
||||
const QString * const codeString = Utils::get_if<QString>(&code);
|
||||
const QString * const codeString = std::get_if<QString>(&code);
|
||||
if (codeString && *codeString == "-Wswitch")
|
||||
requestCodeActions(uri, diagnostic);
|
||||
}
|
||||
@@ -577,7 +577,7 @@ class ClangdDiagnosticManager : public LanguageClient::DiagnosticManager
|
||||
{
|
||||
return Utils::filtered(diagnostics, [](const Diagnostic &diag){
|
||||
const Diagnostic::Code code = diag.code().value_or(Diagnostic::Code());
|
||||
const QString * const codeString = Utils::get_if<QString>(&code);
|
||||
const QString * const codeString = std::get_if<QString>(&code);
|
||||
return !codeString || *codeString != "drv_unknown_argument";
|
||||
});
|
||||
}
|
||||
@@ -809,7 +809,7 @@ MessageId ClangdClient::requestSymbolInfo(const Utils::FilePath &filePath, const
|
||||
// According to the documentation, we should receive a single
|
||||
// object here, but it's a list. No idea what it means if there's
|
||||
// more than one entry. We choose the first one.
|
||||
const auto list = Utils::get_if<QList<SymbolDetails>>(&result.value());
|
||||
const auto list = std::get_if<QList<SymbolDetails>>(&result.value());
|
||||
if (!list || list->isEmpty()) {
|
||||
handler({}, {}, reqId);
|
||||
return;
|
||||
@@ -922,9 +922,9 @@ void ClangdClient::gatherHelpItemForTooltip(const HoverRequest::Response &hoverR
|
||||
const DocumentUri &uri)
|
||||
{
|
||||
if (const Utils::optional<HoverResult> result = hoverResponse.result()) {
|
||||
if (auto hover = Utils::get_if<Hover>(&(*result))) {
|
||||
if (auto hover = std::get_if<Hover>(&(*result))) {
|
||||
const HoverContent content = hover->content();
|
||||
const MarkupContent *const markup = Utils::get_if<MarkupContent>(&content);
|
||||
const MarkupContent *const markup = std::get_if<MarkupContent>(&content);
|
||||
if (markup) {
|
||||
const QString markupString = markup->content();
|
||||
|
||||
@@ -964,7 +964,7 @@ void ClangdClient::gatherHelpItemForTooltip(const HoverRequest::Response &hoverR
|
||||
const MessageId id = hoverResponse.id();
|
||||
Range range;
|
||||
if (const Utils::optional<HoverResult> result = hoverResponse.result()) {
|
||||
if (auto hover = Utils::get_if<Hover>(&(*result)))
|
||||
if (auto hover = std::get_if<Hover>(&(*result)))
|
||||
range = hover->range().value_or(Range());
|
||||
}
|
||||
const ClangdAstPath path = getAstPath(ast, range);
|
||||
@@ -1340,10 +1340,10 @@ MessageId ClangdClient::Private::getAndHandleAst(const TextDocOrFile &doc,
|
||||
const AstHandler &astHandler,
|
||||
AstCallbackMode callbackMode, const Range &range)
|
||||
{
|
||||
const auto textDocPtr = Utils::get_if<const TextDocument *>(&doc);
|
||||
const auto textDocPtr = std::get_if<const TextDocument *>(&doc);
|
||||
const TextDocument * const textDoc = textDocPtr ? *textDocPtr : nullptr;
|
||||
const Utils::FilePath filePath = textDoc ? textDoc->filePath()
|
||||
: Utils::get<Utils::FilePath>(doc);
|
||||
: std::get<Utils::FilePath>(doc);
|
||||
|
||||
// If the entire AST is requested and the document's AST is in the cache and it is up to date,
|
||||
// call the handler.
|
||||
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
Utils::optional<bool> hasVirtualFunctionAt(TextEditor::TextDocument *doc, int revision,
|
||||
const LanguageServerProtocol::Range &range);
|
||||
|
||||
using TextDocOrFile = Utils::variant<const TextEditor::TextDocument *, Utils::FilePath>;
|
||||
using TextDocOrFile = std::variant<const TextEditor::TextDocument *, Utils::FilePath>;
|
||||
using AstHandler = std::function<void(const ClangdAstNode &ast,
|
||||
const LanguageServerProtocol::MessageId &)>;
|
||||
enum class AstCallbackMode { SyncIfPossible, AlwaysAsync };
|
||||
|
||||
@@ -362,10 +362,10 @@ ClangdCompletionItem::SpecialQtType ClangdCompletionItem::getQtType(const Comple
|
||||
if (!doc)
|
||||
return SpecialQtType::None;
|
||||
QString docText;
|
||||
if (Utils::holds_alternative<QString>(*doc))
|
||||
docText = Utils::get<QString>(*doc);
|
||||
else if (Utils::holds_alternative<MarkupContent>(*doc))
|
||||
docText = Utils::get<MarkupContent>(*doc).content();
|
||||
if (std::holds_alternative<QString>(*doc))
|
||||
docText = std::get<QString>(*doc);
|
||||
else if (std::holds_alternative<MarkupContent>(*doc))
|
||||
docText = std::get<MarkupContent>(*doc).content();
|
||||
if (docText.contains("Annotation: qt_signal"))
|
||||
return SpecialQtType::Signal;
|
||||
if (docText.contains("Annotation: qt_slot"))
|
||||
|
||||
@@ -399,9 +399,9 @@ void ClangdFollowSymbol::Private::handleGotoImplementationResult(
|
||||
{
|
||||
if (const optional<GotoResult> &result = response.result()) {
|
||||
QList<Link> newLinks;
|
||||
if (const auto ploc = get_if<Location>(&*result))
|
||||
if (const auto ploc = std::get_if<Location>(&*result))
|
||||
newLinks = {ploc->toLink()};
|
||||
if (const auto plloc = get_if<QList<Location>>(&*result))
|
||||
if (const auto plloc = std::get_if<QList<Location>>(&*result))
|
||||
newLinks = transform(*plloc, &Location::toLink);
|
||||
for (const Link &link : qAsConst(newLinks)) {
|
||||
if (!allLinks.contains(link)) {
|
||||
@@ -475,9 +475,9 @@ void ClangdFollowSymbol::Private::handleGotoImplementationResult(
|
||||
Link newLink;
|
||||
if (optional<GotoResult> _result = response.result()) {
|
||||
const GotoResult result = _result.value();
|
||||
if (const auto ploc = get_if<Location>(&result)) {
|
||||
if (const auto ploc = std::get_if<Location>(&result)) {
|
||||
newLink = ploc->toLink();
|
||||
} else if (const auto plloc = get_if<QList<Location>>(&result)) {
|
||||
} else if (const auto plloc = std::get_if<QList<Location>>(&result)) {
|
||||
if (!plloc->isEmpty())
|
||||
newLink = plloc->value(0).toLink();
|
||||
}
|
||||
|
||||
@@ -85,20 +85,20 @@ private:
|
||||
TextEditor::GenericProposal *handleCodeActionResult(const CodeActionResult &result) override
|
||||
{
|
||||
auto toOperation =
|
||||
[=](const Utils::variant<Command, CodeAction> &item) -> QuickFixOperation * {
|
||||
if (auto action = Utils::get_if<CodeAction>(&item)) {
|
||||
[=](const std::variant<Command, CodeAction> &item) -> QuickFixOperation * {
|
||||
if (auto action = std::get_if<CodeAction>(&item)) {
|
||||
const Utils::optional<QList<Diagnostic>> diagnostics = action->diagnostics();
|
||||
if (!diagnostics.has_value() || diagnostics->isEmpty())
|
||||
return new CodeActionQuickFixOperation(*action, client());
|
||||
}
|
||||
if (auto command = Utils::get_if<Command>(&item))
|
||||
if (auto command = std::get_if<Command>(&item))
|
||||
return new CommandQuickFixOperation(*command, client());
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
if (auto list = Utils::get_if<QList<Utils::variant<Command, CodeAction>>>(&result)) {
|
||||
if (auto list = std::get_if<QList<std::variant<Command, CodeAction>>>(&result)) {
|
||||
QuickFixOperations ops;
|
||||
for (const Utils::variant<Command, CodeAction> &item : *list) {
|
||||
for (const std::variant<Command, CodeAction> &item : *list) {
|
||||
if (QuickFixOperation *op = toOperation(item)) {
|
||||
op->setDescription("clangd: " + op->description());
|
||||
ops << op;
|
||||
|
||||
@@ -152,7 +152,7 @@ QTextCursor ClangdSwitchDeclDef::Private::cursorForFunctionName(const ClangdAstN
|
||||
{
|
||||
QTC_ASSERT(docSymbols, return {});
|
||||
|
||||
const auto symbolList = Utils::get_if<QList<DocumentSymbol>>(&*docSymbols);
|
||||
const auto symbolList = std::get_if<QList<DocumentSymbol>>(&*docSymbols);
|
||||
if (!symbolList)
|
||||
return {};
|
||||
const Range &astRange = functionNode.range();
|
||||
|
||||
@@ -233,7 +233,7 @@ ClangDiagnostic convertDiagnostic(const ClangdDiagnostic &src, const FilePath &f
|
||||
if (src.severity())
|
||||
target.severity = convertSeverity(*src.severity());
|
||||
const Diagnostic::Code code = src.code().value_or(Diagnostic::Code());
|
||||
const QString * const codeString = Utils::get_if<QString>(&code);
|
||||
const QString * const codeString = std::get_if<QString>(&code);
|
||||
if (codeString && codeString->startsWith("-W"))
|
||||
target.enableOption = *codeString;
|
||||
for (const CodeAction &codeAction : src.codeActions().value_or(QList<CodeAction>())) {
|
||||
|
||||
@@ -1464,7 +1464,7 @@ public:
|
||||
void insertCodeSnippet(int pos, const QString &text, const SnippetParser &parser) override
|
||||
{
|
||||
const auto parseResult = parser(text);
|
||||
if (const auto snippet = Utils::get_if<ParsedSnippet>(&parseResult)) {
|
||||
if (const auto snippet = std::get_if<ParsedSnippet>(&parseResult)) {
|
||||
if (!snippet->parts.isEmpty())
|
||||
textCursorAt(pos).insertText(snippet->parts.first().text);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user