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:
23
src/libs/3rdparty/variant/LICENSE.md
vendored
23
src/libs/3rdparty/variant/LICENSE.md
vendored
@@ -1,23 +0,0 @@
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
37
src/libs/3rdparty/variant/README.md
vendored
37
src/libs/3rdparty/variant/README.md
vendored
@@ -1,37 +0,0 @@
|
||||
# MPark.Variant
|
||||
|
||||
> __C++17__ `std::variant` for __C++11__/__14__/__17__
|
||||
|
||||
[![release][badge.release]][release]
|
||||
[![header][badge.header]][header]
|
||||
[![travis][badge.travis]][travis]
|
||||
[![appveyor][badge.appveyor]][appveyor]
|
||||
[![license][badge.license]][license]
|
||||
[![godbolt][badge.godbolt]][godbolt]
|
||||
[![wandbox][badge.wandbox]][wandbox]
|
||||
|
||||
[badge.release]: https://img.shields.io/github/release/mpark/variant.svg
|
||||
[badge.header]: https://img.shields.io/badge/single%20header-master-blue.svg
|
||||
[badge.travis]: https://travis-ci.org/mpark/variant.svg?branch=master
|
||||
[badge.appveyor]: https://ci.appveyor.com/api/projects/status/github/mpark/variant?branch=master&svg=true
|
||||
[badge.license]: https://img.shields.io/badge/license-boost-blue.svg
|
||||
[badge.godbolt]: https://img.shields.io/badge/try%20it-on%20godbolt-222266.svg
|
||||
[badge.wandbox]: https://img.shields.io/badge/try%20it-on%20wandbox-5cb85c.svg
|
||||
|
||||
[release]: https://github.com/mpark/variant/releases/latest
|
||||
[header]: https://github.com/mpark/variant/blob/single-header/master/variant.hpp
|
||||
[travis]: https://travis-ci.org/mpark/variant
|
||||
[appveyor]: https://ci.appveyor.com/project/mpark/variant
|
||||
[license]: https://github.com/mpark/variant/blob/master/LICENSE.md
|
||||
[godbolt]: https://godbolt.org/g/1qYDAK
|
||||
[wandbox]: https://wandbox.org/permlink/QV3gZ2KQQNwgoFIB
|
||||
|
||||
## Single Header
|
||||
|
||||
This branch provides a standalone `variant.hpp` file for each
|
||||
[release](https://github.com/mpark/variant/releases).
|
||||
Copy it and `#include` away!
|
||||
|
||||
## License
|
||||
|
||||
Distributed under the [Boost Software License, Version 1.0](LICENSE.md).
|
2465
src/libs/3rdparty/variant/variant.hpp
vendored
2465
src/libs/3rdparty/variant/variant.hpp
vendored
File diff suppressed because it is too large
Load Diff
@@ -47,10 +47,10 @@ WorkspaceClientCapabilities::WorkspaceClientCapabilities()
|
||||
setWorkspaceFolders(true);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, QJsonObject>> SemanticTokensClientCapabilities::Requests::range()
|
||||
Utils::optional<std::variant<bool, QJsonObject>> SemanticTokensClientCapabilities::Requests::range()
|
||||
const
|
||||
{
|
||||
using RetType = Utils::variant<bool, QJsonObject>;
|
||||
using RetType = std::variant<bool, QJsonObject>;
|
||||
const QJsonValue &rangeOptions = value(rangeKey);
|
||||
if (rangeOptions.isBool())
|
||||
return RetType(rangeOptions.toBool());
|
||||
@@ -60,15 +60,15 @@ Utils::optional<Utils::variant<bool, QJsonObject>> SemanticTokensClientCapabilit
|
||||
}
|
||||
|
||||
void SemanticTokensClientCapabilities::Requests::setRange(
|
||||
const Utils::variant<bool, QJsonObject> &range)
|
||||
const std::variant<bool, QJsonObject> &range)
|
||||
{
|
||||
insertVariant<bool, QJsonObject>(rangeKey, range);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, FullSemanticTokenOptions>>
|
||||
Utils::optional<std::variant<bool, FullSemanticTokenOptions>>
|
||||
SemanticTokensClientCapabilities::Requests::full() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, FullSemanticTokenOptions>;
|
||||
using RetType = std::variant<bool, FullSemanticTokenOptions>;
|
||||
const QJsonValue &fullOptions = value(fullKey);
|
||||
if (fullOptions.isBool())
|
||||
return RetType(fullOptions.toBool());
|
||||
@@ -78,7 +78,7 @@ SemanticTokensClientCapabilities::Requests::full() const
|
||||
}
|
||||
|
||||
void SemanticTokensClientCapabilities::Requests::setFull(
|
||||
const Utils::variant<bool, FullSemanticTokenOptions> &full)
|
||||
const std::variant<bool, FullSemanticTokenOptions> &full)
|
||||
{
|
||||
insertVariant<bool, FullSemanticTokenOptions>(fullKey, full);
|
||||
}
|
||||
|
@@ -78,16 +78,16 @@ public:
|
||||
* The client will send the `textDocument/semanticTokens/range` request
|
||||
* if the server provides a corresponding handler.
|
||||
*/
|
||||
Utils::optional<Utils::variant<bool, QJsonObject>> range() const;
|
||||
void setRange(const Utils::variant<bool, QJsonObject> &range);
|
||||
Utils::optional<std::variant<bool, QJsonObject>> range() const;
|
||||
void setRange(const std::variant<bool, QJsonObject> &range);
|
||||
void clearRange() { remove(rangeKey); }
|
||||
|
||||
/**
|
||||
* The client will send the `textDocument/semanticTokens/full` request
|
||||
* if the server provides a corresponding handler.
|
||||
*/
|
||||
Utils::optional<Utils::variant<bool, FullSemanticTokenOptions>> full() const;
|
||||
void setFull(const Utils::variant<bool, FullSemanticTokenOptions> &full);
|
||||
Utils::optional<std::variant<bool, FullSemanticTokenOptions>> full() const;
|
||||
void setFull(const std::variant<bool, FullSemanticTokenOptions> &full);
|
||||
void clearFull() { remove(fullKey); }
|
||||
};
|
||||
|
||||
|
@@ -263,7 +263,7 @@ public:
|
||||
|
||||
/// The result of a completion is CompletionItem[] | CompletionList | null
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT CompletionResult
|
||||
: public Utils::variant<QList<CompletionItem>, CompletionList, std::nullptr_t>
|
||||
: public std::variant<QList<CompletionItem>, CompletionList, std::nullptr_t>
|
||||
{
|
||||
public:
|
||||
using variant::variant;
|
||||
|
@@ -112,7 +112,7 @@ private:
|
||||
template<typename T, typename V>
|
||||
JsonObject::iterator JsonObject::insertVariant(const QStringView key, const V &variant)
|
||||
{
|
||||
return Utils::holds_alternative<T>(variant) ? insert(key, Utils::get<T>(variant)) : end();
|
||||
return std::holds_alternative<T>(variant) ? insert(key, std::get<T>(variant)) : end();
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename... Args, typename V>
|
||||
|
@@ -31,7 +31,6 @@
|
||||
|
||||
#include <utils/optional.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/variant.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QElapsedTimer>
|
||||
@@ -41,11 +40,13 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QUuid>
|
||||
|
||||
#include <variant>
|
||||
|
||||
namespace LanguageServerProtocol {
|
||||
|
||||
class JsonRpcMessage;
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT MessageId : public Utils::variant<int, QString>
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT MessageId : public std::variant<int, QString>
|
||||
{
|
||||
public:
|
||||
MessageId() : variant(QString()) {}
|
||||
@@ -61,37 +62,37 @@ public:
|
||||
|
||||
operator QJsonValue() const
|
||||
{
|
||||
if (auto id = Utils::get_if<int>(this))
|
||||
if (auto id = std::get_if<int>(this))
|
||||
return *id;
|
||||
if (auto id = Utils::get_if<QString>(this))
|
||||
if (auto id = std::get_if<QString>(this))
|
||||
return *id;
|
||||
return QJsonValue();
|
||||
}
|
||||
|
||||
bool isValid() const
|
||||
{
|
||||
if (Utils::holds_alternative<int>(*this))
|
||||
if (std::holds_alternative<int>(*this))
|
||||
return true;
|
||||
const QString *id = Utils::get_if<QString>(this);
|
||||
const QString *id = std::get_if<QString>(this);
|
||||
QTC_ASSERT(id, return false);
|
||||
return !id->isEmpty();
|
||||
}
|
||||
|
||||
QString toString() const
|
||||
{
|
||||
if (auto id = Utils::get_if<QString>(this))
|
||||
if (auto id = std::get_if<QString>(this))
|
||||
return *id;
|
||||
if (auto id = Utils::get_if<int>(this))
|
||||
if (auto id = std::get_if<int>(this))
|
||||
return QString::number(*id);
|
||||
return {};
|
||||
}
|
||||
|
||||
friend auto qHash(const MessageId &id)
|
||||
{
|
||||
if (Utils::holds_alternative<int>(id))
|
||||
return QT_PREPEND_NAMESPACE(qHash(Utils::get<int>(id)));
|
||||
if (Utils::holds_alternative<QString>(id))
|
||||
return QT_PREPEND_NAMESPACE(qHash(Utils::get<QString>(id)));
|
||||
if (std::holds_alternative<int>(id))
|
||||
return QT_PREPEND_NAMESPACE(qHash(std::get<int>(id)));
|
||||
if (std::holds_alternative<QString>(id))
|
||||
return QT_PREPEND_NAMESPACE(qHash(std::get<QString>(id)));
|
||||
return QT_PREPEND_NAMESPACE(qHash(0));
|
||||
}
|
||||
};
|
||||
@@ -99,10 +100,10 @@ public:
|
||||
template <typename Error>
|
||||
inline QDebug operator<<(QDebug stream, const LanguageServerProtocol::MessageId &id)
|
||||
{
|
||||
if (Utils::holds_alternative<int>(id))
|
||||
stream << Utils::get<int>(id);
|
||||
if (std::holds_alternative<int>(id))
|
||||
stream << std::get<int>(id);
|
||||
else
|
||||
stream << Utils::get<QString>(id);
|
||||
stream << std::get<QString>(id);
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
@@ -57,11 +57,11 @@ HoverContent LanguageServerProtocol::Hover::content() const
|
||||
|
||||
void Hover::setContent(const HoverContent &content)
|
||||
{
|
||||
if (auto val = Utils::get_if<MarkedString>(&content))
|
||||
if (auto val = std::get_if<MarkedString>(&content))
|
||||
insert(contentsKey, *val);
|
||||
else if (auto val = Utils::get_if<MarkupContent>(&content))
|
||||
else if (auto val = std::get_if<MarkupContent>(&content))
|
||||
insert(contentsKey, *val);
|
||||
else if (auto val = Utils::get_if<QList<MarkedString>>(&content))
|
||||
else if (auto val = std::get_if<QList<MarkedString>>(&content))
|
||||
insert(contentsKey, LanguageClientArray<MarkedString>(*val).toJson());
|
||||
else
|
||||
QTC_ASSERT_STRING("LanguageClient Using unknown type Hover::setContent");
|
||||
@@ -160,7 +160,7 @@ QHash<QString, DocumentFormattingProperty> FormattingOptions::properties() const
|
||||
|
||||
void FormattingOptions::setProperty(const QString &key, const DocumentFormattingProperty &property)
|
||||
{
|
||||
using namespace Utils;
|
||||
using namespace std;
|
||||
if (auto val = get_if<double>(&property))
|
||||
insert(key, *val);
|
||||
else if (auto val = get_if<QString>(&property))
|
||||
@@ -293,16 +293,16 @@ MarkedString::MarkedString(const QJsonValue &value)
|
||||
|
||||
bool MarkedString::isValid() const
|
||||
{
|
||||
if (auto markedLanguageString = Utils::get_if<MarkedLanguageString>(this))
|
||||
if (auto markedLanguageString = std::get_if<MarkedLanguageString>(this))
|
||||
return markedLanguageString->isValid();
|
||||
return true;
|
||||
}
|
||||
|
||||
LanguageServerProtocol::MarkedString::operator QJsonValue() const
|
||||
{
|
||||
if (auto val = Utils::get_if<QString>(this))
|
||||
if (auto val = std::get_if<QString>(this))
|
||||
return *val;
|
||||
if (auto val = Utils::get_if<MarkedLanguageString>(this))
|
||||
if (auto val = std::get_if<MarkedLanguageString>(this))
|
||||
return QJsonValue(*val);
|
||||
return {};
|
||||
}
|
||||
@@ -325,8 +325,8 @@ HoverContent::HoverContent(const QJsonValue &value)
|
||||
|
||||
bool HoverContent::isValid() const
|
||||
{
|
||||
if (Utils::holds_alternative<MarkedString>(*this))
|
||||
return Utils::get<MarkedString>(*this).isValid();
|
||||
if (std::holds_alternative<MarkedString>(*this))
|
||||
return std::get<MarkedString>(*this).isValid();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ SignatureHelpRequest::SignatureHelpRequest(const TextDocumentPositionParams &par
|
||||
|
||||
CodeActionResult::CodeActionResult(const QJsonValue &val)
|
||||
{
|
||||
using ResultArray = QList<Utils::variant<Command, CodeAction>>;
|
||||
using ResultArray = QList<std::variant<Command, CodeAction>>;
|
||||
if (val.isArray()) {
|
||||
const QJsonArray array = val.toArray();
|
||||
ResultArray result;
|
||||
@@ -368,21 +368,21 @@ CodeActionResult::CodeActionResult(const QJsonValue &val)
|
||||
}
|
||||
|
||||
PrepareRenameResult::PrepareRenameResult()
|
||||
: Utils::variant<PlaceHolderResult, Range, std::nullptr_t>(nullptr)
|
||||
: std::variant<PlaceHolderResult, Range, std::nullptr_t>(nullptr)
|
||||
{}
|
||||
|
||||
PrepareRenameResult::PrepareRenameResult(
|
||||
const Utils::variant<PlaceHolderResult, Range, std::nullptr_t> &val)
|
||||
: Utils::variant<PlaceHolderResult, Range, std::nullptr_t>(val)
|
||||
const std::variant<PlaceHolderResult, Range, std::nullptr_t> &val)
|
||||
: std::variant<PlaceHolderResult, Range, std::nullptr_t>(val)
|
||||
{}
|
||||
|
||||
PrepareRenameResult::PrepareRenameResult(const PlaceHolderResult &val)
|
||||
: Utils::variant<PlaceHolderResult, Range, std::nullptr_t>(val)
|
||||
: std::variant<PlaceHolderResult, Range, std::nullptr_t>(val)
|
||||
|
||||
{}
|
||||
|
||||
PrepareRenameResult::PrepareRenameResult(const Range &val)
|
||||
: Utils::variant<PlaceHolderResult, Range, std::nullptr_t>(val)
|
||||
: std::variant<PlaceHolderResult, Range, std::nullptr_t>(val)
|
||||
{}
|
||||
|
||||
PrepareRenameResult::PrepareRenameResult(const QJsonValue &val)
|
||||
@@ -413,7 +413,7 @@ HoverResult::HoverResult(const QJsonValue &value)
|
||||
|
||||
bool HoverResult::isValid() const
|
||||
{
|
||||
if (auto hover = Utils::get_if<Hover>(this))
|
||||
if (auto hover = std::get_if<Hover>(this))
|
||||
return hover->isValid();
|
||||
return true;
|
||||
}
|
||||
|
@@ -58,7 +58,7 @@ public:
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT MarkedString
|
||||
: public Utils::variant<QString, MarkedLanguageString>
|
||||
: public std::variant<QString, MarkedLanguageString>
|
||||
{
|
||||
public:
|
||||
MarkedString() = default;
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT HoverContent
|
||||
: public Utils::variant<MarkedString, QList<MarkedString>, MarkupContent>
|
||||
: public std::variant<MarkedString, QList<MarkedString>, MarkupContent>
|
||||
{
|
||||
public:
|
||||
HoverContent() = default;
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
bool isValid() const override { return contains(contentsKey); }
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT HoverResult : public Utils::variant<Hover, std::nullptr_t>
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT HoverResult : public std::variant<Hover, std::nullptr_t>
|
||||
{
|
||||
public:
|
||||
HoverResult() : variant(nullptr) {}
|
||||
@@ -216,7 +216,7 @@ public:
|
||||
|
||||
/// The result of a goto request can either be a location, a list of locations or null
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT GotoResult
|
||||
: public Utils::variant<Location, QList<Location>, std::nullptr_t>
|
||||
: public std::variant<Location, QList<Location>, std::nullptr_t>
|
||||
{
|
||||
public:
|
||||
explicit GotoResult(const QJsonValue &value);
|
||||
@@ -307,7 +307,7 @@ public:
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT DocumentHighlightsResult
|
||||
: public Utils::variant<QList<DocumentHighlight>, std::nullptr_t>
|
||||
: public std::variant<QList<DocumentHighlight>, std::nullptr_t>
|
||||
{
|
||||
public:
|
||||
using variant::variant;
|
||||
@@ -343,7 +343,7 @@ public:
|
||||
using DocumentSymbolParams = TextDocumentParams;
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT DocumentSymbolsResult
|
||||
: public Utils::variant<QList<SymbolInformation>, QList<DocumentSymbol>, std::nullptr_t>
|
||||
: public std::variant<QList<SymbolInformation>, QList<DocumentSymbol>, std::nullptr_t>
|
||||
{
|
||||
public:
|
||||
using variant::variant;
|
||||
@@ -468,7 +468,7 @@ public:
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT CodeActionResult
|
||||
: public Utils::variant<QList<Utils::variant<Command, CodeAction>>, std::nullptr_t>
|
||||
: public std::variant<QList<std::variant<Command, CodeAction>>, std::nullptr_t>
|
||||
{
|
||||
public:
|
||||
using variant::variant;
|
||||
@@ -658,13 +658,13 @@ public:
|
||||
constexpr static const char methodName[] = "textDocument/colorPresentation";
|
||||
};
|
||||
|
||||
class DocumentFormattingProperty : public Utils::variant<bool, double, QString>
|
||||
class DocumentFormattingProperty : public std::variant<bool, double, QString>
|
||||
{
|
||||
public:
|
||||
DocumentFormattingProperty() = default;
|
||||
explicit DocumentFormattingProperty(const QJsonValue &value);
|
||||
explicit DocumentFormattingProperty(const DocumentFormattingProperty &other)
|
||||
: Utils::variant<bool, double, QString>(other) {}
|
||||
: std::variant<bool, double, QString>(other) {}
|
||||
|
||||
using variant::variant;
|
||||
using variant::operator=;
|
||||
@@ -806,11 +806,11 @@ public:
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT PrepareRenameResult
|
||||
: public Utils::variant<PlaceHolderResult, Range, std::nullptr_t>
|
||||
: public std::variant<PlaceHolderResult, Range, std::nullptr_t>
|
||||
{
|
||||
public:
|
||||
PrepareRenameResult();
|
||||
PrepareRenameResult(const Utils::variant<PlaceHolderResult, Range, std::nullptr_t> &val);
|
||||
PrepareRenameResult(const std::variant<PlaceHolderResult, Range, std::nullptr_t> &val);
|
||||
explicit PrepareRenameResult(const PlaceHolderResult &val);
|
||||
explicit PrepareRenameResult(const Range &val);
|
||||
explicit PrepareRenameResult(const QJsonValue &val);
|
||||
|
@@ -95,16 +95,16 @@ WorkSpaceFolder::WorkSpaceFolder(const DocumentUri &uri, const QString &name)
|
||||
setName(name);
|
||||
}
|
||||
|
||||
MarkupOrString::MarkupOrString(const Utils::variant<QString, MarkupContent> &val)
|
||||
: Utils::variant<QString, MarkupContent>(val)
|
||||
MarkupOrString::MarkupOrString(const std::variant<QString, MarkupContent> &val)
|
||||
: std::variant<QString, MarkupContent>(val)
|
||||
{ }
|
||||
|
||||
MarkupOrString::MarkupOrString(const QString &val)
|
||||
: Utils::variant<QString, MarkupContent>(val)
|
||||
: std::variant<QString, MarkupContent>(val)
|
||||
{ }
|
||||
|
||||
MarkupOrString::MarkupOrString(const MarkupContent &val)
|
||||
: Utils::variant<QString, MarkupContent>(val)
|
||||
: std::variant<QString, MarkupContent>(val)
|
||||
{ }
|
||||
|
||||
MarkupOrString::MarkupOrString(const QJsonValue &val)
|
||||
@@ -120,10 +120,10 @@ MarkupOrString::MarkupOrString(const QJsonValue &val)
|
||||
|
||||
QJsonValue MarkupOrString::toJson() const
|
||||
{
|
||||
if (Utils::holds_alternative<QString>(*this))
|
||||
return Utils::get<QString>(*this);
|
||||
if (Utils::holds_alternative<MarkupContent>(*this))
|
||||
return QJsonValue(Utils::get<MarkupContent>(*this));
|
||||
if (std::holds_alternative<QString>(*this))
|
||||
return std::get<QString>(*this);
|
||||
if (std::holds_alternative<MarkupContent>(*this))
|
||||
return QJsonValue(std::get<MarkupContent>(*this));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,6 @@
|
||||
#include <utils/mimeutils.h>
|
||||
#include <utils/optional.h>
|
||||
#include <utils/textutils.h>
|
||||
#include <utils/variant.h>
|
||||
|
||||
#include <QTextCursor>
|
||||
#include <QJsonObject>
|
||||
@@ -42,6 +41,7 @@
|
||||
#include <QList>
|
||||
|
||||
#include <functional>
|
||||
#include <variant>
|
||||
|
||||
namespace LanguageServerProtocol {
|
||||
|
||||
@@ -190,7 +190,7 @@ public:
|
||||
void clearSeverity() { remove(severityKey); }
|
||||
|
||||
// The diagnostic's code, which might appear in the user interface.
|
||||
using Code = Utils::variant<int, QString>;
|
||||
using Code = std::variant<int, QString>;
|
||||
Utils::optional<Code> code() const;
|
||||
void setCode(const Code &code);
|
||||
void clearCode() { remove(codeKey); }
|
||||
@@ -456,11 +456,11 @@ public:
|
||||
{ return contains(kindKey) && contains(contentKey); }
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT MarkupOrString : public Utils::variant<QString, MarkupContent>
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT MarkupOrString : public std::variant<QString, MarkupContent>
|
||||
{
|
||||
public:
|
||||
MarkupOrString() = default;
|
||||
explicit MarkupOrString(const Utils::variant<QString, MarkupContent> &val);
|
||||
explicit MarkupOrString(const std::variant<QString, MarkupContent> &val);
|
||||
explicit MarkupOrString(const QString &val);
|
||||
explicit MarkupOrString(const MarkupContent &val);
|
||||
MarkupOrString(const QJsonValue &val);
|
||||
|
@@ -30,12 +30,13 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/optional.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/variant.h>
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#include <variant>
|
||||
|
||||
namespace LanguageServerProtocol {
|
||||
|
||||
LANGUAGESERVERPROTOCOL_EXPORT Q_DECLARE_LOGGING_CATEGORY(conversionLog)
|
||||
@@ -73,11 +74,11 @@ template<>
|
||||
LANGUAGESERVERPROTOCOL_EXPORT QJsonValue fromJsonValue<QJsonValue>(const QJsonValue &value);
|
||||
|
||||
template <typename T>
|
||||
class LanguageClientArray : public Utils::variant<QList<T>, std::nullptr_t>
|
||||
class LanguageClientArray : public std::variant<QList<T>, std::nullptr_t>
|
||||
{
|
||||
public:
|
||||
using Utils::variant<QList<T>, std::nullptr_t>::variant;
|
||||
using Utils::variant<QList<T>, std::nullptr_t>::operator=;
|
||||
using std::variant<QList<T>, std::nullptr_t>::variant;
|
||||
using std::variant<QList<T>, std::nullptr_t>::operator=;
|
||||
|
||||
LanguageClientArray() {}
|
||||
|
||||
@@ -99,7 +100,7 @@ public:
|
||||
|
||||
QJsonValue toJson() const
|
||||
{
|
||||
if (const auto list = Utils::get_if<QList<T>>(this)) {
|
||||
if (const auto list = std::get_if<QList<T>>(this)) {
|
||||
QJsonArray array;
|
||||
for (const T &value : *list)
|
||||
array.append(QJsonValue(value));
|
||||
@@ -110,20 +111,20 @@ public:
|
||||
|
||||
QList<T> toList() const
|
||||
{
|
||||
QTC_ASSERT(Utils::holds_alternative<QList<T>>(*this), return {});
|
||||
return Utils::get<QList<T>>(*this);
|
||||
QTC_ASSERT(std::holds_alternative<QList<T>>(*this), return {});
|
||||
return std::get<QList<T>>(*this);
|
||||
}
|
||||
bool isNull() const { return Utils::holds_alternative<std::nullptr_t>(*this); }
|
||||
bool isNull() const { return std::holds_alternative<std::nullptr_t>(*this); }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class LanguageClientValue : public Utils::variant<T, std::nullptr_t>
|
||||
class LanguageClientValue : public std::variant<T, std::nullptr_t>
|
||||
{
|
||||
public:
|
||||
using Utils::variant<T, std::nullptr_t>::operator=;
|
||||
using std::variant<T, std::nullptr_t>::operator=;
|
||||
|
||||
LanguageClientValue() : Utils::variant<T, std::nullptr_t>(nullptr) { }
|
||||
LanguageClientValue(const T &value) : Utils::variant<T, std::nullptr_t>(value) { }
|
||||
LanguageClientValue() : std::variant<T, std::nullptr_t>(nullptr) { }
|
||||
LanguageClientValue(const T &value) : std::variant<T, std::nullptr_t>(value) { }
|
||||
LanguageClientValue(const QJsonValue &value)
|
||||
{
|
||||
if (!QTC_GUARD(!value.isUndefined()) || value.isNull())
|
||||
@@ -134,25 +135,25 @@ public:
|
||||
|
||||
operator const QJsonValue() const
|
||||
{
|
||||
if (auto val = Utils::get_if<T>(this))
|
||||
if (auto val = std::get_if<T>(this))
|
||||
return QJsonValue(*val);
|
||||
return QJsonValue();
|
||||
}
|
||||
|
||||
T value(const T &defaultValue = T()) const
|
||||
{
|
||||
QTC_ASSERT(Utils::holds_alternative<T>(*this), return defaultValue);
|
||||
return Utils::get<T>(*this);
|
||||
QTC_ASSERT(std::holds_alternative<T>(*this), return defaultValue);
|
||||
return std::get<T>(*this);
|
||||
}
|
||||
|
||||
template<typename Type>
|
||||
LanguageClientValue<Type> transform()
|
||||
{
|
||||
QTC_ASSERT(!Utils::holds_alternative<T>(*this), return LanguageClientValue<Type>());
|
||||
return Type(Utils::get<T>(*this));
|
||||
QTC_ASSERT(!std::holds_alternative<T>(*this), return LanguageClientValue<Type>());
|
||||
return Type(std::get<T>(*this));
|
||||
}
|
||||
|
||||
bool isNull() const { return Utils::holds_alternative<std::nullptr_t>(*this); }
|
||||
bool isNull() const { return std::holds_alternative<std::nullptr_t>(*this); }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
@@ -43,9 +43,9 @@ ProgressToken::ProgressToken(const QJsonValue &value)
|
||||
|
||||
ProgressToken::operator QJsonValue() const
|
||||
{
|
||||
if (Utils::holds_alternative<QString>(*this))
|
||||
return QJsonValue(Utils::get<QString>(*this));
|
||||
return QJsonValue(Utils::get<int>(*this));
|
||||
if (std::holds_alternative<QString>(*this))
|
||||
return QJsonValue(std::get<QString>(*this));
|
||||
return QJsonValue(std::get<int>(*this));
|
||||
}
|
||||
|
||||
ProgressParams::ProgressType ProgressParams::value() const
|
||||
|
@@ -27,13 +27,13 @@
|
||||
|
||||
#include "jsonrpcmessages.h"
|
||||
|
||||
#include <utils/variant.h>
|
||||
|
||||
#include <QJsonValue>
|
||||
|
||||
#include <variant>
|
||||
|
||||
namespace LanguageServerProtocol {
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT ProgressToken : public Utils::variant<int, QString>
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT ProgressToken : public std::variant<int, QString>
|
||||
{
|
||||
public:
|
||||
using variant::variant;
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
void setToken(const ProgressToken &token) { insert(tokenKey, token); }
|
||||
|
||||
using ProgressType
|
||||
= Utils::variant<WorkDoneProgressBegin, WorkDoneProgressReport, WorkDoneProgressEnd>;
|
||||
= std::variant<WorkDoneProgressBegin, WorkDoneProgressReport, WorkDoneProgressEnd>;
|
||||
ProgressType value() const;
|
||||
void setValue(const ProgressType &value);
|
||||
|
||||
|
@@ -164,7 +164,7 @@ public:
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT SemanticTokensResult
|
||||
: public Utils::variant<SemanticTokens, std::nullptr_t>
|
||||
: public std::variant<SemanticTokens, std::nullptr_t>
|
||||
{
|
||||
public:
|
||||
using variant::variant;
|
||||
@@ -215,7 +215,7 @@ public:
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT SemanticTokensDeltaResult
|
||||
: public Utils::variant<SemanticTokens, SemanticTokensDelta, std::nullptr_t>
|
||||
: public std::variant<SemanticTokens, SemanticTokensDelta, std::nullptr_t>
|
||||
{
|
||||
public:
|
||||
using variant::variant;
|
||||
|
@@ -44,9 +44,9 @@ void ServerCapabilities::setTextDocumentSync(const ServerCapabilities::TextDocum
|
||||
TextDocumentSyncKind ServerCapabilities::textDocumentSyncKindHelper()
|
||||
{
|
||||
if (Utils::optional<TextDocumentSync> sync = textDocumentSync()) {
|
||||
if (auto kind = Utils::get_if<int>(&*sync))
|
||||
if (auto kind = std::get_if<int>(&*sync))
|
||||
return static_cast<TextDocumentSyncKind>(*kind);
|
||||
if (auto options = Utils::get_if<TextDocumentSyncOptions>(&*sync)) {
|
||||
if (auto options = std::get_if<TextDocumentSyncOptions>(&*sync)) {
|
||||
if (const Utils::optional<int> &change = options->change())
|
||||
return static_cast<TextDocumentSyncKind>(*change);
|
||||
}
|
||||
@@ -54,10 +54,10 @@ TextDocumentSyncKind ServerCapabilities::textDocumentSyncKindHelper()
|
||||
return TextDocumentSyncKind::None;
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> ServerCapabilities::hoverProvider()
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> ServerCapabilities::hoverProvider()
|
||||
const
|
||||
{
|
||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
||||
using RetType = std::variant<bool, WorkDoneProgressOptions>;
|
||||
const QJsonValue &provider = value(hoverProviderKey);
|
||||
if (provider.isBool())
|
||||
return Utils::make_optional(RetType(provider.toBool()));
|
||||
@@ -67,15 +67,15 @@ Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> ServerCapabilitie
|
||||
}
|
||||
|
||||
void ServerCapabilities::setHoverProvider(
|
||||
const Utils::variant<bool, WorkDoneProgressOptions> &hoverProvider)
|
||||
const std::variant<bool, WorkDoneProgressOptions> &hoverProvider)
|
||||
{
|
||||
insertVariant<bool, WorkDoneProgressOptions>(hoverProviderKey, hoverProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, ServerCapabilities::RegistrationOptions>>
|
||||
Utils::optional<std::variant<bool, ServerCapabilities::RegistrationOptions>>
|
||||
ServerCapabilities::typeDefinitionProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, ServerCapabilities::RegistrationOptions>;
|
||||
using RetType = std::variant<bool, ServerCapabilities::RegistrationOptions>;
|
||||
const QJsonValue &provider = value(typeDefinitionProviderKey);
|
||||
if (provider.isUndefined() || !(provider.isBool() || provider.isObject()))
|
||||
return Utils::nullopt;
|
||||
@@ -84,16 +84,16 @@ ServerCapabilities::typeDefinitionProvider() const
|
||||
}
|
||||
|
||||
void ServerCapabilities::setTypeDefinitionProvider(
|
||||
const Utils::variant<bool, ServerCapabilities::RegistrationOptions> &typeDefinitionProvider)
|
||||
const std::variant<bool, ServerCapabilities::RegistrationOptions> &typeDefinitionProvider)
|
||||
{
|
||||
insertVariant<bool, ServerCapabilities::RegistrationOptions>(typeDefinitionProviderKey,
|
||||
typeDefinitionProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, ServerCapabilities::RegistrationOptions>>
|
||||
Utils::optional<std::variant<bool, ServerCapabilities::RegistrationOptions>>
|
||||
ServerCapabilities::implementationProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, ServerCapabilities::RegistrationOptions>;
|
||||
using RetType = std::variant<bool, ServerCapabilities::RegistrationOptions>;
|
||||
const QJsonValue &provider = value(implementationProviderKey);
|
||||
if (provider.isUndefined() || !(provider.isBool() || provider.isObject()))
|
||||
return Utils::nullopt;
|
||||
@@ -102,15 +102,15 @@ ServerCapabilities::implementationProvider() const
|
||||
}
|
||||
|
||||
void ServerCapabilities::setImplementationProvider(
|
||||
const Utils::variant<bool, ServerCapabilities::RegistrationOptions> &implementationProvider)
|
||||
const std::variant<bool, ServerCapabilities::RegistrationOptions> &implementationProvider)
|
||||
{
|
||||
insertVariant<bool, RegistrationOptions>(implementationProviderKey, implementationProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>>
|
||||
ServerCapabilities::referencesProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
||||
using RetType = std::variant<bool, WorkDoneProgressOptions>;
|
||||
const QJsonValue &provider = value(referencesProviderKey);
|
||||
if (provider.isBool())
|
||||
return Utils::make_optional(RetType(provider.toBool()));
|
||||
@@ -120,16 +120,16 @@ ServerCapabilities::referencesProvider() const
|
||||
}
|
||||
|
||||
void ServerCapabilities::setReferencesProvider(
|
||||
const Utils::variant<bool, WorkDoneProgressOptions> &referencesProvider)
|
||||
const std::variant<bool, WorkDoneProgressOptions> &referencesProvider)
|
||||
{
|
||||
insertVariant<bool, WorkDoneProgressOptions>(referencesProviderKey,
|
||||
referencesProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>>
|
||||
ServerCapabilities::documentHighlightProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
||||
using RetType = std::variant<bool, WorkDoneProgressOptions>;
|
||||
const QJsonValue &provider = value(documentHighlightProviderKey);
|
||||
if (provider.isBool())
|
||||
return Utils::make_optional(RetType(provider.toBool()));
|
||||
@@ -139,16 +139,16 @@ ServerCapabilities::documentHighlightProvider() const
|
||||
}
|
||||
|
||||
void ServerCapabilities::setDocumentHighlightProvider(
|
||||
const Utils::variant<bool, WorkDoneProgressOptions> &documentHighlightProvider)
|
||||
const std::variant<bool, WorkDoneProgressOptions> &documentHighlightProvider)
|
||||
{
|
||||
insertVariant<bool, WorkDoneProgressOptions>(documentHighlightProviderKey,
|
||||
documentHighlightProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>>
|
||||
ServerCapabilities::documentSymbolProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
||||
using RetType = std::variant<bool, WorkDoneProgressOptions>;
|
||||
const QJsonValue &provider = value(documentSymbolProviderKey);
|
||||
if (provider.isBool())
|
||||
return Utils::make_optional(RetType(provider.toBool()));
|
||||
@@ -158,7 +158,7 @@ ServerCapabilities::documentSymbolProvider() const
|
||||
}
|
||||
|
||||
void ServerCapabilities::setDocumentSymbolProvider(
|
||||
Utils::variant<bool, WorkDoneProgressOptions> documentSymbolProvider)
|
||||
std::variant<bool, WorkDoneProgressOptions> documentSymbolProvider)
|
||||
{
|
||||
insertVariant<bool, WorkDoneProgressOptions>(documentSymbolProviderKey,
|
||||
documentSymbolProvider);
|
||||
@@ -175,10 +175,10 @@ void ServerCapabilities::setSemanticTokensProvider(
|
||||
insert(semanticTokensProviderKey, semanticTokensProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>>
|
||||
ServerCapabilities::workspaceSymbolProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
||||
using RetType = std::variant<bool, WorkDoneProgressOptions>;
|
||||
const QJsonValue &provider = value(workspaceSymbolProviderKey);
|
||||
if (provider.isBool())
|
||||
return Utils::make_optional(RetType(provider.toBool()));
|
||||
@@ -188,29 +188,29 @@ ServerCapabilities::workspaceSymbolProvider() const
|
||||
}
|
||||
|
||||
void ServerCapabilities::setWorkspaceSymbolProvider(
|
||||
Utils::variant<bool, WorkDoneProgressOptions> workspaceSymbolProvider)
|
||||
std::variant<bool, WorkDoneProgressOptions> workspaceSymbolProvider)
|
||||
{
|
||||
insertVariant<bool, WorkDoneProgressOptions>(workspaceSymbolProviderKey,
|
||||
workspaceSymbolProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, CodeActionOptions>> ServerCapabilities::codeActionProvider() const
|
||||
Utils::optional<std::variant<bool, CodeActionOptions>> ServerCapabilities::codeActionProvider() const
|
||||
{
|
||||
const QJsonValue &provider = value(codeActionProviderKey);
|
||||
if (provider.isBool())
|
||||
return Utils::make_optional(Utils::variant<bool, CodeActionOptions>(provider.toBool()));
|
||||
return Utils::make_optional(std::variant<bool, CodeActionOptions>(provider.toBool()));
|
||||
if (provider.isObject()) {
|
||||
CodeActionOptions options(provider);
|
||||
if (options.isValid())
|
||||
return Utils::make_optional(Utils::variant<bool, CodeActionOptions>(options));
|
||||
return Utils::make_optional(std::variant<bool, CodeActionOptions>(options));
|
||||
}
|
||||
return Utils::nullopt;
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>>
|
||||
ServerCapabilities::documentFormattingProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
||||
using RetType = std::variant<bool, WorkDoneProgressOptions>;
|
||||
const QJsonValue &provider = value(documentFormattingProviderKey);
|
||||
if (provider.isBool())
|
||||
return Utils::make_optional(RetType(provider.toBool()));
|
||||
@@ -220,16 +220,16 @@ ServerCapabilities::documentFormattingProvider() const
|
||||
}
|
||||
|
||||
void ServerCapabilities::setDocumentFormattingProvider(
|
||||
const Utils::variant<bool, WorkDoneProgressOptions> &documentFormattingProvider)
|
||||
const std::variant<bool, WorkDoneProgressOptions> &documentFormattingProvider)
|
||||
{
|
||||
insertVariant<bool, WorkDoneProgressOptions>(documentFormattingProviderKey,
|
||||
documentFormattingProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>>
|
||||
ServerCapabilities::documentRangeFormattingProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
||||
using RetType = std::variant<bool, WorkDoneProgressOptions>;
|
||||
const QJsonValue &provider = value(documentRangeFormattingProviderKey);
|
||||
if (provider.isBool())
|
||||
return Utils::make_optional(RetType(provider.toBool()));
|
||||
@@ -239,15 +239,15 @@ ServerCapabilities::documentRangeFormattingProvider() const
|
||||
}
|
||||
|
||||
void ServerCapabilities::setDocumentRangeFormattingProvider(
|
||||
Utils::variant<bool, WorkDoneProgressOptions> documentRangeFormattingProvider)
|
||||
std::variant<bool, WorkDoneProgressOptions> documentRangeFormattingProvider)
|
||||
{
|
||||
insertVariant<bool, WorkDoneProgressOptions>(documentRangeFormattingProviderKey,
|
||||
documentRangeFormattingProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<ServerCapabilities::RenameOptions, bool>> ServerCapabilities::renameProvider() const
|
||||
Utils::optional<std::variant<ServerCapabilities::RenameOptions, bool>> ServerCapabilities::renameProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<ServerCapabilities::RenameOptions, bool>;
|
||||
using RetType = std::variant<ServerCapabilities::RenameOptions, bool>;
|
||||
const QJsonValue &localValue = value(renameProviderKey);
|
||||
if (localValue.isBool())
|
||||
return RetType(localValue.toBool());
|
||||
@@ -256,14 +256,14 @@ Utils::optional<Utils::variant<ServerCapabilities::RenameOptions, bool>> ServerC
|
||||
return Utils::nullopt;
|
||||
}
|
||||
|
||||
void ServerCapabilities::setRenameProvider(Utils::variant<ServerCapabilities::RenameOptions, bool> renameProvider)
|
||||
void ServerCapabilities::setRenameProvider(std::variant<ServerCapabilities::RenameOptions, bool> renameProvider)
|
||||
{
|
||||
insertVariant<RenameOptions, bool>(renameProviderKey, renameProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, JsonObject>> ServerCapabilities::colorProvider() const
|
||||
Utils::optional<std::variant<bool, JsonObject>> ServerCapabilities::colorProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, JsonObject>;
|
||||
using RetType = std::variant<bool, JsonObject>;
|
||||
const QJsonValue &localValue = value(colorProviderKey);
|
||||
if (localValue.isBool())
|
||||
return RetType(localValue.toBool());
|
||||
@@ -272,15 +272,15 @@ Utils::optional<Utils::variant<bool, JsonObject>> ServerCapabilities::colorProvi
|
||||
return Utils::nullopt;
|
||||
}
|
||||
|
||||
void ServerCapabilities::setColorProvider(Utils::variant<bool, JsonObject> colorProvider)
|
||||
void ServerCapabilities::setColorProvider(std::variant<bool, JsonObject> colorProvider)
|
||||
{
|
||||
insertVariant<bool, JsonObject>(renameProviderKey, colorProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<QString, bool> >
|
||||
Utils::optional<std::variant<QString, bool> >
|
||||
ServerCapabilities::WorkspaceServerCapabilities::WorkspaceFoldersCapabilities::changeNotifications() const
|
||||
{
|
||||
using RetType = Utils::variant<QString, bool>;
|
||||
using RetType = std::variant<QString, bool>;
|
||||
const QJsonValue &change = value(changeNotificationsKey);
|
||||
if (change.isUndefined())
|
||||
return Utils::nullopt;
|
||||
@@ -289,7 +289,7 @@ ServerCapabilities::WorkspaceServerCapabilities::WorkspaceFoldersCapabilities::c
|
||||
}
|
||||
|
||||
void ServerCapabilities::WorkspaceServerCapabilities::WorkspaceFoldersCapabilities::setChangeNotifications(
|
||||
Utils::variant<QString, bool> changeNotifications)
|
||||
std::variant<QString, bool> changeNotifications)
|
||||
{
|
||||
insertVariant<QString, bool>(changeNotificationsKey, changeNotifications);
|
||||
}
|
||||
@@ -315,9 +315,9 @@ bool CodeActionOptions::isValid() const
|
||||
return WorkDoneProgressOptions::isValid() && contains(codeActionKindsKey);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, QJsonObject>> SemanticTokensOptions::range() const
|
||||
Utils::optional<std::variant<bool, QJsonObject>> SemanticTokensOptions::range() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, QJsonObject>;
|
||||
using RetType = std::variant<bool, QJsonObject>;
|
||||
const QJsonValue &rangeOptions = value(rangeKey);
|
||||
if (rangeOptions.isBool())
|
||||
return RetType(rangeOptions.toBool());
|
||||
@@ -326,15 +326,15 @@ Utils::optional<Utils::variant<bool, QJsonObject>> SemanticTokensOptions::range(
|
||||
return Utils::nullopt;
|
||||
}
|
||||
|
||||
void SemanticTokensOptions::setRange(const Utils::variant<bool, QJsonObject> &range)
|
||||
void SemanticTokensOptions::setRange(const std::variant<bool, QJsonObject> &range)
|
||||
{
|
||||
insertVariant<bool, QJsonObject>(rangeKey, range);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, SemanticTokensOptions::FullSemanticTokenOptions>>
|
||||
Utils::optional<std::variant<bool, SemanticTokensOptions::FullSemanticTokenOptions>>
|
||||
SemanticTokensOptions::full() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, SemanticTokensOptions::FullSemanticTokenOptions>;
|
||||
using RetType = std::variant<bool, SemanticTokensOptions::FullSemanticTokenOptions>;
|
||||
const QJsonValue &fullOptions = value(fullKey);
|
||||
if (fullOptions.isBool())
|
||||
return RetType(fullOptions.toBool());
|
||||
@@ -344,7 +344,7 @@ SemanticTokensOptions::full() const
|
||||
}
|
||||
|
||||
void SemanticTokensOptions::setFull(
|
||||
const Utils::variant<bool, SemanticTokensOptions::FullSemanticTokenOptions> &full)
|
||||
const std::variant<bool, SemanticTokensOptions::FullSemanticTokenOptions> &full)
|
||||
{
|
||||
insertVariant<bool, FullSemanticTokenOptions>(fullKey, full);
|
||||
}
|
||||
|
@@ -152,8 +152,8 @@ public:
|
||||
void setLegend(const SemanticTokensLegend &legend) { insert(legendKey, legend); }
|
||||
|
||||
/// Server supports providing semantic tokens for a specific range of a document.
|
||||
Utils::optional<Utils::variant<bool, QJsonObject>> range() const;
|
||||
void setRange(const Utils::variant<bool, QJsonObject> &range);
|
||||
Utils::optional<std::variant<bool, QJsonObject>> range() const;
|
||||
void setRange(const std::variant<bool, QJsonObject> &range);
|
||||
void clearRange() { remove(rangeKey); }
|
||||
|
||||
class FullSemanticTokenOptions : public JsonObject
|
||||
@@ -168,8 +168,8 @@ public:
|
||||
};
|
||||
|
||||
/// Server supports providing semantic tokens for a full document.
|
||||
Utils::optional<Utils::variant<bool, FullSemanticTokenOptions>> full() const;
|
||||
void setFull(const Utils::variant<bool, FullSemanticTokenOptions> &full);
|
||||
Utils::optional<std::variant<bool, FullSemanticTokenOptions>> full() const;
|
||||
void setFull(const std::variant<bool, FullSemanticTokenOptions> &full);
|
||||
void clearFull() { remove(fullKey); }
|
||||
|
||||
bool isValid() const override { return contains(legendKey); }
|
||||
@@ -265,7 +265,7 @@ public:
|
||||
|
||||
// Defines how text documents are synced. Is either a detailed structure defining each
|
||||
// notification or for backwards compatibility the TextDocumentSyncKind number.
|
||||
using TextDocumentSync = Utils::variant<TextDocumentSyncOptions, int>;
|
||||
using TextDocumentSync = std::variant<TextDocumentSyncOptions, int>;
|
||||
Utils::optional<TextDocumentSync> textDocumentSync() const;
|
||||
void setTextDocumentSync(const TextDocumentSync &textDocumentSync);
|
||||
void clearTextDocumentSync() { remove(textDocumentSyncKey); }
|
||||
@@ -273,8 +273,8 @@ public:
|
||||
TextDocumentSyncKind textDocumentSyncKindHelper();
|
||||
|
||||
// The server provides hover support.
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> hoverProvider() const;
|
||||
void setHoverProvider(const Utils::variant<bool, WorkDoneProgressOptions> &hoverProvider);
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> hoverProvider() const;
|
||||
void setHoverProvider(const std::variant<bool, WorkDoneProgressOptions> &hoverProvider);
|
||||
void clearHoverProvider() { remove(hoverProviderKey); }
|
||||
|
||||
// The server provides completion support.
|
||||
@@ -321,29 +321,29 @@ public:
|
||||
};
|
||||
|
||||
// The server provides Goto Type Definition support.
|
||||
Utils::optional<Utils::variant<bool, RegistrationOptions>> typeDefinitionProvider() const;
|
||||
void setTypeDefinitionProvider(const Utils::variant<bool, RegistrationOptions> &typeDefinitionProvider);
|
||||
Utils::optional<std::variant<bool, RegistrationOptions>> typeDefinitionProvider() const;
|
||||
void setTypeDefinitionProvider(const std::variant<bool, RegistrationOptions> &typeDefinitionProvider);
|
||||
void clearTypeDefinitionProvider() { remove(typeDefinitionProviderKey); }
|
||||
|
||||
// The server provides Goto Implementation support.
|
||||
Utils::optional<Utils::variant<bool, RegistrationOptions>> implementationProvider() const;
|
||||
void setImplementationProvider(const Utils::variant<bool, RegistrationOptions> &implementationProvider);
|
||||
Utils::optional<std::variant<bool, RegistrationOptions>> implementationProvider() const;
|
||||
void setImplementationProvider(const std::variant<bool, RegistrationOptions> &implementationProvider);
|
||||
void clearImplementationProvider() { remove(implementationProviderKey); }
|
||||
|
||||
// The server provides find references support.
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> referencesProvider() const;
|
||||
void setReferencesProvider(const Utils::variant<bool, WorkDoneProgressOptions> &referencesProvider);
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> referencesProvider() const;
|
||||
void setReferencesProvider(const std::variant<bool, WorkDoneProgressOptions> &referencesProvider);
|
||||
void clearReferencesProvider() { remove(referencesProviderKey); }
|
||||
|
||||
// The server provides document highlight support.
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> documentHighlightProvider() const;
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> documentHighlightProvider() const;
|
||||
void setDocumentHighlightProvider(
|
||||
const Utils::variant<bool, WorkDoneProgressOptions> &documentHighlightProvider);
|
||||
const std::variant<bool, WorkDoneProgressOptions> &documentHighlightProvider);
|
||||
void clearDocumentHighlightProvider() { remove(documentHighlightProviderKey); }
|
||||
|
||||
// The server provides document symbol support.
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> documentSymbolProvider() const;
|
||||
void setDocumentSymbolProvider(Utils::variant<bool, WorkDoneProgressOptions> documentSymbolProvider);
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> documentSymbolProvider() const;
|
||||
void setDocumentSymbolProvider(std::variant<bool, WorkDoneProgressOptions> documentSymbolProvider);
|
||||
void clearDocumentSymbolProvider() { remove(documentSymbolProviderKey); }
|
||||
|
||||
Utils::optional<SemanticTokensOptions> semanticTokensProvider() const;
|
||||
@@ -351,12 +351,12 @@ public:
|
||||
void clearSemanticTokensProvider() { remove(semanticTokensProviderKey); }
|
||||
|
||||
// The server provides workspace symbol support.
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> workspaceSymbolProvider() const;
|
||||
void setWorkspaceSymbolProvider(Utils::variant<bool, WorkDoneProgressOptions> workspaceSymbolProvider);
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> workspaceSymbolProvider() const;
|
||||
void setWorkspaceSymbolProvider(std::variant<bool, WorkDoneProgressOptions> workspaceSymbolProvider);
|
||||
void clearWorkspaceSymbolProvider() { remove(workspaceSymbolProviderKey); }
|
||||
|
||||
// The server provides code actions.
|
||||
Utils::optional<Utils::variant<bool, CodeActionOptions>> codeActionProvider() const;
|
||||
Utils::optional<std::variant<bool, CodeActionOptions>> codeActionProvider() const;
|
||||
void setCodeActionProvider(bool codeActionProvider)
|
||||
{ insert(codeActionProviderKey, codeActionProvider); }
|
||||
void setCodeActionProvider(CodeActionOptions options)
|
||||
@@ -371,14 +371,14 @@ public:
|
||||
void clearCodeLensProvider() { remove(codeLensProviderKey); }
|
||||
|
||||
// The server provides document formatting.
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> documentFormattingProvider() const;
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> documentFormattingProvider() const;
|
||||
void setDocumentFormattingProvider(
|
||||
const Utils::variant<bool, WorkDoneProgressOptions> &documentFormattingProvider);
|
||||
const std::variant<bool, WorkDoneProgressOptions> &documentFormattingProvider);
|
||||
void clearDocumentFormattingProvider() { remove(documentFormattingProviderKey); }
|
||||
|
||||
// The server provides document formatting on typing.
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> documentRangeFormattingProvider() const;
|
||||
void setDocumentRangeFormattingProvider(Utils::variant<bool, WorkDoneProgressOptions> documentRangeFormattingProvider);
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> documentRangeFormattingProvider() const;
|
||||
void setDocumentRangeFormattingProvider(std::variant<bool, WorkDoneProgressOptions> documentRangeFormattingProvider);
|
||||
void clearDocumentRangeFormattingProvider() { remove(documentRangeFormattingProviderKey); }
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT RenameOptions : public WorkDoneProgressOptions
|
||||
@@ -393,8 +393,8 @@ public:
|
||||
};
|
||||
|
||||
// The server provides rename support.
|
||||
Utils::optional<Utils::variant<RenameOptions, bool>> renameProvider() const;
|
||||
void setRenameProvider(Utils::variant<RenameOptions,bool> renameProvider);
|
||||
Utils::optional<std::variant<RenameOptions, bool>> renameProvider() const;
|
||||
void setRenameProvider(std::variant<RenameOptions,bool> renameProvider);
|
||||
void clearRenameProvider() { remove(renameProviderKey); }
|
||||
|
||||
// The server provides document link support.
|
||||
@@ -405,8 +405,8 @@ public:
|
||||
void clearDocumentLinkProvider() { remove(documentLinkProviderKey); }
|
||||
|
||||
// The server provides color provider support.
|
||||
Utils::optional<Utils::variant<bool, JsonObject>> colorProvider() const;
|
||||
void setColorProvider(Utils::variant<bool, JsonObject> colorProvider);
|
||||
Utils::optional<std::variant<bool, JsonObject>> colorProvider() const;
|
||||
void setColorProvider(std::variant<bool, JsonObject> colorProvider);
|
||||
void clearColorProvider() { remove(colorProviderKey); }
|
||||
|
||||
// The server provides execute command support.
|
||||
@@ -431,8 +431,8 @@ public:
|
||||
void setSupported(bool supported) { insert(supportedKey, supported); }
|
||||
void clearSupported() { remove(supportedKey); }
|
||||
|
||||
Utils::optional<Utils::variant<QString, bool>> changeNotifications() const;
|
||||
void setChangeNotifications(Utils::variant<QString, bool> changeNotifications);
|
||||
Utils::optional<std::variant<QString, bool>> changeNotifications() const;
|
||||
void setChangeNotifications(std::variant<QString, bool> changeNotifications);
|
||||
void clearChangeNotifications() { remove(changeNotificationsKey); }
|
||||
};
|
||||
|
||||
|
@@ -86,10 +86,10 @@ ExecuteCommandParams::ExecuteCommandParams(const Command &command)
|
||||
|
||||
LanguageServerProtocol::WorkSpaceFolderResult::operator const QJsonValue() const
|
||||
{
|
||||
if (!Utils::holds_alternative<QList<WorkSpaceFolder>>(*this))
|
||||
if (!std::holds_alternative<QList<WorkSpaceFolder>>(*this))
|
||||
return QJsonValue::Null;
|
||||
QJsonArray array;
|
||||
for (const auto &folder : Utils::get<QList<WorkSpaceFolder>>(*this))
|
||||
for (const auto &folder : std::get<QList<WorkSpaceFolder>>(*this))
|
||||
array.append(QJsonValue(folder));
|
||||
return array;
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@
|
||||
namespace LanguageServerProtocol {
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT WorkSpaceFolderResult
|
||||
: public Utils::variant<QList<WorkSpaceFolder>, std::nullptr_t>
|
||||
: public std::variant<QList<WorkSpaceFolder>, std::nullptr_t>
|
||||
{
|
||||
public:
|
||||
using variant::variant;
|
||||
|
@@ -60,7 +60,7 @@ struct ConvertArgValueToString {
|
||||
|
||||
std::string Arg::value() const
|
||||
{
|
||||
return Utils::visit(ConvertArgValueToString(), m_value);
|
||||
return std::visit(ConvertArgValueToString(), m_value);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -33,13 +33,11 @@
|
||||
# define NANOTRACESHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#include <utils/variant.h> // revert when macos minimum target is >= 10.14
|
||||
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#ifdef NANOTRACE_ENABLED
|
||||
|
||||
#define NANOTRACE_INIT(process, thread, filepath) Nanotrace::init(process, thread, filepath)
|
||||
@@ -81,7 +79,7 @@ using TimePoint = std::chrono::time_point< Clock >;
|
||||
class NANOTRACESHARED_EXPORT Arg
|
||||
{
|
||||
public:
|
||||
using SupportedType = Utils::variant<int, int64_t, double, std::string>;
|
||||
using SupportedType = std::variant<int, int64_t, double, std::string>;
|
||||
|
||||
Arg(const std::string &name, const SupportedType &val);
|
||||
std::string name() const;
|
||||
|
@@ -29,7 +29,8 @@
|
||||
|
||||
#include <sqlitevalue.h>
|
||||
#include <utils/smallstring.h>
|
||||
#include <utils/variant.h>
|
||||
|
||||
#include <variant>
|
||||
|
||||
namespace Sqlite {
|
||||
|
||||
@@ -179,7 +180,7 @@ public:
|
||||
GeneratedAlwaysStorage storage = {};
|
||||
};
|
||||
|
||||
using Constraint = Utils::variant<Unique,
|
||||
using Constraint = std::variant<Unique,
|
||||
PrimaryKey,
|
||||
ForeignKey,
|
||||
NotNull,
|
||||
|
@@ -294,7 +294,7 @@ private:
|
||||
ContraintsVisiter visiter{columnDefinitionString};
|
||||
|
||||
for (const Constraint &constraint : column.constraints)
|
||||
Utils::visit(visiter, constraint);
|
||||
std::visit(visiter, constraint);
|
||||
|
||||
columnDefinitionStrings.push_back(std::move(columnDefinitionString));
|
||||
}
|
||||
@@ -303,7 +303,7 @@ private:
|
||||
Utils::SmallString columnDefinitionString;
|
||||
|
||||
TableContraintsVisiter visiter{columnDefinitionString};
|
||||
Utils::visit(visiter, constraint);
|
||||
std::visit(visiter, constraint);
|
||||
|
||||
columnDefinitionStrings.push_back(std::move(columnDefinitionString));
|
||||
}
|
||||
|
@@ -201,8 +201,8 @@ public:
|
||||
return std::find_if(constraints.begin(),
|
||||
constraints.end(),
|
||||
[](const Constraint &constraint) {
|
||||
return Utils::holds_alternative<Unique>(constraint)
|
||||
|| Utils::holds_alternative<PrimaryKey>(constraint);
|
||||
return std::holds_alternative<Unique>(constraint)
|
||||
|| std::holds_alternative<PrimaryKey>(constraint);
|
||||
})
|
||||
!= constraints.end();
|
||||
}
|
||||
|
@@ -29,11 +29,11 @@
|
||||
#include "sqliteexception.h"
|
||||
|
||||
#include <utils/smallstring.h>
|
||||
#include <utils/variant.h>
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include <cstddef>
|
||||
#include <variant>
|
||||
|
||||
namespace Sqlite {
|
||||
|
||||
@@ -48,7 +48,7 @@ template<typename StringType, typename BlobType>
|
||||
class ValueBase
|
||||
{
|
||||
public:
|
||||
using VariantType = Utils::variant<NullValue, long long, double, StringType, BlobType>;
|
||||
using VariantType = std::variant<NullValue, long long, double, StringType, BlobType>;
|
||||
|
||||
ValueBase() = default;
|
||||
|
||||
@@ -104,18 +104,18 @@ public:
|
||||
|
||||
bool isNull() const { return value.index() == 0; }
|
||||
|
||||
long long toInteger() const { return Utils::get<int(ValueType::Integer)>(value); }
|
||||
long long toInteger() const { return std::get<int(ValueType::Integer)>(value); }
|
||||
|
||||
double toFloat() const { return Utils::get<int(ValueType::Float)>(value); }
|
||||
double toFloat() const { return std::get<int(ValueType::Float)>(value); }
|
||||
|
||||
Utils::SmallStringView toStringView() const
|
||||
{
|
||||
return Utils::get<int(ValueType::String)>(value);
|
||||
return std::get<int(ValueType::String)>(value);
|
||||
}
|
||||
|
||||
BlobView toBlobView() const
|
||||
{
|
||||
const BlobType &blob = Utils::get<int(ValueType::Blob)>(value);
|
||||
const BlobType &blob = std::get<int(ValueType::Blob)>(value);
|
||||
if constexpr (std::is_same_v<BlobType, Blob>) {
|
||||
return {blob.bytes};
|
||||
} else {
|
||||
@@ -146,7 +146,7 @@ public:
|
||||
|
||||
friend bool operator==(const ValueBase &first, long long second)
|
||||
{
|
||||
auto maybeInteger = Utils::get_if<int(ValueType::Integer)>(&first.value);
|
||||
auto maybeInteger = std::get_if<int(ValueType::Integer)>(&first.value);
|
||||
|
||||
return maybeInteger && *maybeInteger == second;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public:
|
||||
|
||||
friend bool operator==(const ValueBase &first, double second)
|
||||
{
|
||||
auto maybeFloat = Utils::get_if<int(ValueType::Float)>(&first.value);
|
||||
auto maybeFloat = std::get_if<int(ValueType::Float)>(&first.value);
|
||||
|
||||
return maybeFloat && *maybeFloat == second;
|
||||
}
|
||||
@@ -178,7 +178,7 @@ public:
|
||||
|
||||
friend bool operator==(const ValueBase &first, Utils::SmallStringView second)
|
||||
{
|
||||
auto maybeString = Utils::get_if<int(ValueType::String)>(&first.value);
|
||||
auto maybeString = std::get_if<int(ValueType::String)>(&first.value);
|
||||
|
||||
return maybeString && *maybeString == second;
|
||||
}
|
||||
@@ -190,7 +190,7 @@ public:
|
||||
|
||||
friend bool operator==(const ValueBase &first, const QString &second)
|
||||
{
|
||||
auto maybeString = Utils::get_if<int(ValueType::String)>(&first.value);
|
||||
auto maybeString = std::get_if<int(ValueType::String)>(&first.value);
|
||||
|
||||
return maybeString && second == QLatin1String{maybeString->data(), int(maybeString->size())};
|
||||
}
|
||||
@@ -219,7 +219,7 @@ public:
|
||||
|
||||
friend bool operator==(const ValueBase &first, BlobView second)
|
||||
{
|
||||
auto maybeBlob = Utils::get_if<int(ValueType::Blob)>(&first.value);
|
||||
auto maybeBlob = std::get_if<int(ValueType::Blob)>(&first.value);
|
||||
|
||||
return maybeBlob && *maybeBlob == second;
|
||||
}
|
||||
|
@@ -29,7 +29,8 @@
|
||||
|
||||
#include <sqlitevalue.h>
|
||||
#include <utils/smallstringvector.h>
|
||||
#include <utils/variant.h>
|
||||
|
||||
#include <variant>
|
||||
|
||||
namespace Sqlite {
|
||||
class TablePrimaryKey
|
||||
@@ -43,7 +44,7 @@ public:
|
||||
Utils::SmallStringVector columns;
|
||||
};
|
||||
|
||||
using TableConstraint = Utils::variant<TablePrimaryKey>;
|
||||
using TableConstraint = std::variant<TablePrimaryKey>;
|
||||
using TableConstraints = std::vector<TableConstraint>;
|
||||
|
||||
} // namespace Sqlite
|
||||
|
@@ -5,7 +5,6 @@ add_qtc_library(Utils
|
||||
Qt6Core5Compat
|
||||
SOURCES
|
||||
../3rdparty/optional/optional.hpp
|
||||
../3rdparty/variant/variant.hpp
|
||||
../3rdparty/span/span.hpp
|
||||
QtConcurrentTools
|
||||
algorithm.h
|
||||
@@ -182,7 +181,6 @@ add_qtc_library(Utils
|
||||
utils_global.h
|
||||
utilsicons.cpp utilsicons.h
|
||||
variablechooser.cpp variablechooser.h
|
||||
variant.h
|
||||
winutils.cpp winutils.h
|
||||
wizard.cpp wizard.h
|
||||
wizardpage.cpp wizardpage.h
|
||||
|
@@ -30,7 +30,6 @@
|
||||
#include <utils/mimeutils.h>
|
||||
#include <utils/optional.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/variant.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QStyle>
|
||||
@@ -43,6 +42,8 @@
|
||||
#include <QIcon>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#include <variant>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
Q_LOGGING_CATEGORY(fileIconProvider, "qtc.core.fileiconprovider", QtWarningMsg)
|
||||
@@ -65,7 +66,7 @@ Q_LOGGING_CATEGORY(fileIconProvider, "qtc.core.fileiconprovider", QtWarningMsg)
|
||||
retrieve icons via the icon() function.
|
||||
*/
|
||||
|
||||
using Item = Utils::variant<QIcon, QString>; // icon or filename for the icon
|
||||
using Item = std::variant<QIcon, QString>; // icon or filename for the icon
|
||||
|
||||
namespace Utils {
|
||||
namespace FileIconProvider {
|
||||
@@ -75,10 +76,10 @@ static Utils::optional<QIcon> getIcon(QHash<QString, Item> &cache, const QString
|
||||
auto it = cache.constFind(key);
|
||||
if (it == cache.constEnd())
|
||||
return {};
|
||||
if (const QIcon *icon = Utils::get_if<QIcon>(&*it))
|
||||
if (const QIcon *icon = std::get_if<QIcon>(&*it))
|
||||
return *icon;
|
||||
// need to create icon from file name first
|
||||
const QString *fileName = Utils::get_if<QString>(&*it);
|
||||
const QString *fileName = std::get_if<QString>(&*it);
|
||||
QTC_ASSERT(fileName, return {});
|
||||
const QIcon icon = QIcon(
|
||||
FileIconProvider::overlayIcon(QStyle::SP_FileIcon, QIcon(*fileName), QSize(16, 16)));
|
||||
|
@@ -327,8 +327,6 @@ Project {
|
||||
"utilsicons.cpp",
|
||||
"variablechooser.cpp",
|
||||
"variablechooser.h",
|
||||
"variant.h",
|
||||
"../3rdparty/variant/variant.hpp",
|
||||
"winutils.cpp",
|
||||
"winutils.h",
|
||||
"wizard.cpp",
|
||||
|
@@ -1,61 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
See std(::experimental)::variant.
|
||||
*/
|
||||
|
||||
// std::variant from Apple's Clang supports methods that throw std::bad_optional_access only
|
||||
// with deployment target >= macOS 10.14
|
||||
// TODO: Use std::variant everywhere when we can require macOS 10.14
|
||||
#if !defined(__apple_build_version__)
|
||||
#include <variant>
|
||||
|
||||
namespace Utils {
|
||||
using std::get;
|
||||
using std::get_if;
|
||||
using std::holds_alternative;
|
||||
using std::monostate;
|
||||
using std::variant;
|
||||
using std::variant_alternative_t;
|
||||
using std::visit;
|
||||
} // namespace Utils
|
||||
|
||||
#else
|
||||
#include <3rdparty/variant/variant.hpp>
|
||||
|
||||
namespace Utils {
|
||||
using mpark::get;
|
||||
using mpark::get_if;
|
||||
using mpark::holds_alternative;
|
||||
using mpark::monostate;
|
||||
using mpark::variant;
|
||||
using mpark::variant_alternative_t;
|
||||
using mpark::visit;
|
||||
} // namespace Utils
|
||||
|
||||
#endif
|
@@ -30,12 +30,13 @@
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/optional.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/variant.h>
|
||||
|
||||
#include <QLoggingCategory>
|
||||
#include <QRegularExpression>
|
||||
#include <QSettings>
|
||||
|
||||
#include <variant>
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(avdOutputParserLog, "qtc.android.avdOutputParser", QtWarningMsg)
|
||||
}
|
||||
@@ -113,7 +114,7 @@ AndroidDeviceInfoList parseAvdList(const QString &output, QStringList *avdErrorP
|
||||
AndroidDeviceInfoList avdList;
|
||||
QStringList avdInfo;
|
||||
using ErrorPath = QString;
|
||||
using AvdResult = Utils::variant<std::monostate, AndroidDeviceInfo, ErrorPath>;
|
||||
using AvdResult = std::variant<std::monostate, AndroidDeviceInfo, ErrorPath>;
|
||||
const auto parseAvdInfo = [](const QStringList &avdInfo) {
|
||||
if (!avdInfo.filter(avdManufacturerError).isEmpty()) {
|
||||
for (const QString &line : avdInfo) {
|
||||
@@ -138,9 +139,9 @@ AndroidDeviceInfoList parseAvdList(const QString &output, QStringList *avdErrorP
|
||||
for (const QString &line : lines) {
|
||||
if (line.startsWith("---------") || line.isEmpty()) {
|
||||
const AvdResult result = parseAvdInfo(avdInfo);
|
||||
if (auto info = Utils::get_if<AndroidDeviceInfo>(&result))
|
||||
if (auto info = std::get_if<AndroidDeviceInfo>(&result))
|
||||
avdList << *info;
|
||||
else if (auto errorPath = Utils::get_if<ErrorPath>(&result))
|
||||
else if (auto errorPath = std::get_if<ErrorPath>(&result))
|
||||
*avdErrorPaths << *errorPath;
|
||||
avdInfo.clear();
|
||||
} else {
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -680,8 +680,8 @@ void ClangTool::startTool(ClangTool::FileSelection fileSelection,
|
||||
connect(m_runControl, &RunControl::stopped, this, &ClangTool::onRunControlStopped);
|
||||
|
||||
// Run worker
|
||||
const bool preventBuild = holds_alternative<FilePath>(fileSelection)
|
||||
|| get<FileSelectionType>(fileSelection)
|
||||
const bool preventBuild = std::holds_alternative<FilePath>(fileSelection)
|
||||
|| std::get<FileSelectionType>(fileSelection)
|
||||
== FileSelectionType::CurrentFile;
|
||||
const bool buildBeforeAnalysis = !preventBuild && runSettings.buildBeforeAnalysis();
|
||||
m_runWorker = new ClangToolRunWorker(m_runControl,
|
||||
@@ -730,7 +730,7 @@ Diagnostics ClangTool::read(OutputFileFormat outputFileFormat,
|
||||
|
||||
FileInfos ClangTool::collectFileInfos(Project *project, FileSelection fileSelection)
|
||||
{
|
||||
FileSelectionType *selectionType = get_if<FileSelectionType>(&fileSelection);
|
||||
FileSelectionType *selectionType = std::get_if<FileSelectionType>(&fileSelection);
|
||||
// early bailout
|
||||
if (selectionType && *selectionType == FileSelectionType::CurrentFile
|
||||
&& !EditorManager::currentDocument()) {
|
||||
@@ -759,8 +759,8 @@ FileInfos ClangTool::collectFileInfos(Project *project, FileSelection fileSelect
|
||||
return dialog.fileInfos();
|
||||
}
|
||||
|
||||
const FilePath filePath = holds_alternative<FilePath>(fileSelection)
|
||||
? get<FilePath>(fileSelection)
|
||||
const FilePath filePath = std::holds_alternative<FilePath>(fileSelection)
|
||||
? std::get<FilePath>(fileSelection)
|
||||
: EditorManager::currentDocument()->filePath(); // see early bailout
|
||||
if (!filePath.isEmpty()) {
|
||||
const FileInfo fileInfo = Utils::findOrDefault(allFileInfos, [&](const FileInfo &fi) {
|
||||
|
@@ -35,7 +35,7 @@
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <cppeditor/projectinfo.h>
|
||||
|
||||
#include <utils/variant.h>
|
||||
#include <variant>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QFrame;
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
AskUser,
|
||||
};
|
||||
|
||||
using FileSelection = Utils::variant<FileSelectionType, Utils::FilePath>;
|
||||
using FileSelection = std::variant<FileSelectionType, Utils::FilePath>;
|
||||
|
||||
void startTool(FileSelection fileSelection);
|
||||
void startTool(FileSelection fileSelection,
|
||||
|
@@ -623,7 +623,7 @@ void Client::openDocument(TextEditor::TextDocument *document)
|
||||
}
|
||||
} else if (Utils::optional<ServerCapabilities::TextDocumentSync> _sync
|
||||
= d->m_serverCapabilities.textDocumentSync()) {
|
||||
if (auto options = Utils::get_if<TextDocumentSyncOptions>(&*_sync)) {
|
||||
if (auto options = std::get_if<TextDocumentSyncOptions>(&*_sync)) {
|
||||
if (!options->openClose().value_or(true))
|
||||
return;
|
||||
}
|
||||
@@ -791,11 +791,11 @@ void ClientPrivate::requestDocumentHighlightsNow(TextEditor::TextEditorWidget *w
|
||||
if (!option.filterApplies(widget->textDocument()->filePath()))
|
||||
return;
|
||||
} else {
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> provider
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> provider
|
||||
= m_serverCapabilities.documentHighlightProvider();
|
||||
if (!provider.has_value())
|
||||
return;
|
||||
if (Utils::holds_alternative<bool>(*provider) && !Utils::get<bool>(*provider))
|
||||
if (std::holds_alternative<bool>(*provider) && !std::get<bool>(*provider))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -819,7 +819,7 @@ void ClientPrivate::requestDocumentHighlightsNow(TextEditor::TextEditorWidget *w
|
||||
const Id &id = TextEditor::TextEditorWidget::CodeSemanticsSelection;
|
||||
QList<QTextEdit::ExtraSelection> selections;
|
||||
const Utils::optional<DocumentHighlightsResult> &result = response.result();
|
||||
if (!result.has_value() || holds_alternative<std::nullptr_t>(*result)) {
|
||||
if (!result.has_value() || std::holds_alternative<std::nullptr_t>(*result)) {
|
||||
widget->setExtraSelections(id, selections);
|
||||
return;
|
||||
}
|
||||
@@ -827,7 +827,7 @@ void ClientPrivate::requestDocumentHighlightsNow(TextEditor::TextEditorWidget *w
|
||||
const QTextCharFormat &format =
|
||||
widget->textDocument()->fontSettings().toTextCharFormat(TextEditor::C_OCCURRENCES);
|
||||
QTextDocument *document = widget->document();
|
||||
for (const auto &highlight : get<QList<DocumentHighlight>>(*result)) {
|
||||
for (const auto &highlight : std::get<QList<DocumentHighlight>>(*result)) {
|
||||
QTextEdit::ExtraSelection selection{widget->textCursor(), format};
|
||||
const int &start = highlight.range().start().toPositionInDocument(document);
|
||||
const int &end = highlight.range().end().toPositionInDocument(document);
|
||||
@@ -1013,7 +1013,7 @@ void Client::documentContentsSaved(TextEditor::TextDocument *document)
|
||||
}
|
||||
} else if (Utils::optional<ServerCapabilities::TextDocumentSync> _sync
|
||||
= d->m_serverCapabilities.textDocumentSync()) {
|
||||
if (auto options = Utils::get_if<TextDocumentSyncOptions>(&*_sync)) {
|
||||
if (auto options = std::get_if<TextDocumentSyncOptions>(&*_sync)) {
|
||||
if (Utils::optional<SaveOptions> saveOptions = options->save())
|
||||
includeText = saveOptions->includeText().value_or(includeText);
|
||||
}
|
||||
@@ -1047,7 +1047,7 @@ void Client::documentWillSave(Core::IDocument *document)
|
||||
}
|
||||
} else if (Utils::optional<ServerCapabilities::TextDocumentSync> _sync
|
||||
= d->m_serverCapabilities.textDocumentSync()) {
|
||||
if (auto options = Utils::get_if<TextDocumentSyncOptions>(&*_sync))
|
||||
if (auto options = std::get_if<TextDocumentSyncOptions>(&*_sync))
|
||||
send = options->willSave().value_or(send);
|
||||
}
|
||||
if (!send)
|
||||
@@ -1285,9 +1285,9 @@ void Client::requestCodeActions(const CodeActionRequest &request)
|
||||
if (option.isValid() && !option.filterApplies(fileName))
|
||||
return;
|
||||
} else {
|
||||
Utils::variant<bool, CodeActionOptions> provider
|
||||
std::variant<bool, CodeActionOptions> provider
|
||||
= d->m_serverCapabilities.codeActionProvider().value_or(false);
|
||||
if (!(Utils::holds_alternative<CodeActionOptions>(provider) || Utils::get<bool>(provider)))
|
||||
if (!(std::holds_alternative<CodeActionOptions>(provider) || std::get<bool>(provider)))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1300,12 +1300,12 @@ void Client::handleCodeActionResponse(const CodeActionRequest::Response &respons
|
||||
if (const Utils::optional<CodeActionRequest::Response::Error> &error = response.error())
|
||||
log(*error);
|
||||
if (const Utils::optional<CodeActionResult> &result = response.result()) {
|
||||
if (auto list = Utils::get_if<QList<Utils::variant<Command, CodeAction>>>(&*result)) {
|
||||
if (auto list = std::get_if<QList<std::variant<Command, CodeAction>>>(&*result)) {
|
||||
QList<CodeAction> codeActions;
|
||||
for (const Utils::variant<Command, CodeAction> &item : *list) {
|
||||
if (auto action = Utils::get_if<CodeAction>(&item))
|
||||
for (const std::variant<Command, CodeAction> &item : *list) {
|
||||
if (auto action = std::get_if<CodeAction>(&item))
|
||||
codeActions << *action;
|
||||
else if (auto command = Utils::get_if<Command>(&item))
|
||||
else if (auto command = std::get_if<Command>(&item))
|
||||
Q_UNUSED(command) // todo
|
||||
}
|
||||
updateCodeActionRefactoringMarker(this, codeActions, uri);
|
||||
@@ -1506,12 +1506,12 @@ bool Client::supportsDocumentSymbols(const TextEditor::TextDocument *doc) const
|
||||
return !options.isValid()
|
||||
|| options.filterApplies(doc->filePath(), Utils::mimeTypeForName(doc->mimeType()));
|
||||
}
|
||||
const Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> &provider
|
||||
const Utils::optional<std::variant<bool, WorkDoneProgressOptions>> &provider
|
||||
= capabilities().documentSymbolProvider();
|
||||
if (!provider.has_value())
|
||||
return false;
|
||||
if (Utils::holds_alternative<bool>(*provider))
|
||||
return Utils::get<bool>(*provider);
|
||||
if (std::holds_alternative<bool>(*provider))
|
||||
return std::get<bool>(*provider);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1998,11 +1998,11 @@ void ClientPrivate::initializeCallback(const InitializeRequest::Response &initRe
|
||||
qCDebug(LOGLSPCLIENT) << "language server " << m_displayName << " initialized";
|
||||
m_state = Client::Initialized;
|
||||
q->sendMessage(InitializeNotification(InitializedParams()));
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> documentSymbolProvider
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> documentSymbolProvider
|
||||
= q->capabilities().documentSymbolProvider();
|
||||
if (documentSymbolProvider.has_value()) {
|
||||
if (!Utils::holds_alternative<bool>(*documentSymbolProvider)
|
||||
|| Utils::get<bool>(*documentSymbolProvider)) {
|
||||
if (!std::holds_alternative<bool>(*documentSymbolProvider)
|
||||
|| std::get<bool>(*documentSymbolProvider)) {
|
||||
TextEditor::IOutlineWidgetFactory::updateOutline();
|
||||
}
|
||||
}
|
||||
@@ -2044,8 +2044,9 @@ bool ClientPrivate::sendWorkspceFolderChanges() const
|
||||
if (folder->supported().value_or(false)) {
|
||||
// holds either the Id for deregistration or whether it is registered
|
||||
auto notification = folder->changeNotifications().value_or(false);
|
||||
return holds_alternative<QString>(notification)
|
||||
|| (holds_alternative<bool>(notification) && get<bool>(notification));
|
||||
return std::holds_alternative<QString>(notification)
|
||||
|| (std::holds_alternative<bool>(notification)
|
||||
&& std::get<bool>(notification));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -144,11 +144,11 @@ QString LanguageClientCompletionItem::detail() const
|
||||
if (auto _doc = m_item.documentation()) {
|
||||
auto doc = *_doc;
|
||||
QString detailDocText;
|
||||
if (Utils::holds_alternative<QString>(doc)) {
|
||||
detailDocText = Utils::get<QString>(doc);
|
||||
} else if (Utils::holds_alternative<MarkupContent>(doc)) {
|
||||
if (std::holds_alternative<QString>(doc)) {
|
||||
detailDocText = std::get<QString>(doc);
|
||||
} else if (std::holds_alternative<MarkupContent>(doc)) {
|
||||
// TODO markdown parser?
|
||||
detailDocText = Utils::get<MarkupContent>(doc).content();
|
||||
detailDocText = std::get<MarkupContent>(doc).content();
|
||||
}
|
||||
if (!detailDocText.isEmpty())
|
||||
return detailDocText;
|
||||
@@ -425,18 +425,18 @@ void LanguageClientCompletionAssistProcessor::handleCompletionResponse(
|
||||
m_client->log(*error);
|
||||
|
||||
const Utils::optional<CompletionResult> &result = response.result();
|
||||
if (!result || Utils::holds_alternative<std::nullptr_t>(*result)) {
|
||||
if (!result || std::holds_alternative<std::nullptr_t>(*result)) {
|
||||
setAsyncProposalAvailable(nullptr);
|
||||
m_client->removeAssistProcessor(this);
|
||||
return;
|
||||
}
|
||||
|
||||
QList<CompletionItem> items;
|
||||
if (Utils::holds_alternative<CompletionList>(*result)) {
|
||||
const auto &list = Utils::get<CompletionList>(*result);
|
||||
if (std::holds_alternative<CompletionList>(*result)) {
|
||||
const auto &list = std::get<CompletionList>(*result);
|
||||
items = list.items().value_or(QList<CompletionItem>());
|
||||
} else if (Utils::holds_alternative<QList<CompletionItem>>(*result)) {
|
||||
items = Utils::get<QList<CompletionItem>>(*result);
|
||||
} else if (std::holds_alternative<QList<CompletionItem>>(*result)) {
|
||||
items = std::get<QList<CompletionItem>>(*result);
|
||||
}
|
||||
auto proposalItems = generateCompletionItems(items);
|
||||
if (!m_snippetsGroup.isEmpty()) {
|
||||
|
@@ -86,11 +86,11 @@ QFutureWatcher<ChangeSet> *LanguageClientFormatter::format(
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
const Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> &provider
|
||||
const Utils::optional<std::variant<bool, WorkDoneProgressOptions>> &provider
|
||||
= m_client->capabilities().documentRangeFormattingProvider();
|
||||
if (!provider.has_value())
|
||||
return nullptr;
|
||||
if (Utils::holds_alternative<bool>(*provider) && !Utils::get<bool>(*provider))
|
||||
if (std::holds_alternative<bool>(*provider) && !std::get<bool>(*provider))
|
||||
return nullptr;
|
||||
}
|
||||
DocumentRangeFormattingParams params;
|
||||
|
@@ -66,7 +66,7 @@ void HoverHandler::setHelpItem(const LanguageServerProtocol::MessageId &msgId,
|
||||
{
|
||||
if (msgId == m_response.id()) {
|
||||
if (Utils::optional<HoverResult> result = m_response.result()) {
|
||||
if (auto hover = Utils::get_if<Hover>(&(*result)))
|
||||
if (auto hover = std::get_if<Hover>(&(*result)))
|
||||
setContent(hover->content());
|
||||
}
|
||||
m_response = {};
|
||||
@@ -107,11 +107,11 @@ void HoverHandler::identifyMatch(TextEditor::TextEditorWidget *editorWidget,
|
||||
if (m_preferDiagnostics && reportDiagnostics(cursor))
|
||||
return;
|
||||
|
||||
const Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> &provider
|
||||
const Utils::optional<std::variant<bool, WorkDoneProgressOptions>> &provider
|
||||
= m_client->capabilities().hoverProvider();
|
||||
bool sendMessage = provider.has_value();
|
||||
if (sendMessage && Utils::holds_alternative<bool>(*provider))
|
||||
sendMessage = Utils::get<bool>(*provider);
|
||||
if (sendMessage && std::holds_alternative<bool>(*provider))
|
||||
sendMessage = std::get<bool>(*provider);
|
||||
if (Utils::optional<bool> registered = m_client->dynamicCapabilities().isRegistered(
|
||||
HoverRequest::methodName)) {
|
||||
sendMessage = *registered;
|
||||
@@ -146,7 +146,7 @@ void HoverHandler::handleResponse(const HoverRequest::Response &response, const
|
||||
m_client->log(*error);
|
||||
}
|
||||
if (Utils::optional<HoverResult> result = response.result()) {
|
||||
if (auto hover = Utils::get_if<Hover>(&(*result))) {
|
||||
if (auto hover = std::get_if<Hover>(&(*result))) {
|
||||
if (m_helpItemProvider) {
|
||||
m_response = response;
|
||||
m_helpItemProvider(response, m_uri);
|
||||
@@ -166,9 +166,9 @@ static QString toolTipForMarkedStrings(const QList<MarkedString> &markedStrings)
|
||||
for (const MarkedString &markedString : markedStrings) {
|
||||
if (!tooltip.isEmpty())
|
||||
tooltip += '\n';
|
||||
if (auto string = Utils::get_if<QString>(&markedString))
|
||||
if (auto string = std::get_if<QString>(&markedString))
|
||||
tooltip += *string;
|
||||
else if (auto string = Utils::get_if<MarkedLanguageString>(&markedString))
|
||||
else if (auto string = std::get_if<MarkedLanguageString>(&markedString))
|
||||
tooltip += string->value() + " [" + string->language() + ']';
|
||||
}
|
||||
return tooltip;
|
||||
@@ -176,11 +176,11 @@ static QString toolTipForMarkedStrings(const QList<MarkedString> &markedStrings)
|
||||
|
||||
void HoverHandler::setContent(const HoverContent &hoverContent)
|
||||
{
|
||||
if (auto markupContent = Utils::get_if<MarkupContent>(&hoverContent))
|
||||
if (auto markupContent = std::get_if<MarkupContent>(&hoverContent))
|
||||
setToolTip(markupContent->content(), markupContent->textFormat());
|
||||
else if (auto markedString = Utils::get_if<MarkedString>(&hoverContent))
|
||||
else if (auto markedString = std::get_if<MarkedString>(&hoverContent))
|
||||
setToolTip(toolTipForMarkedStrings({*markedString}));
|
||||
else if (auto markedStrings = Utils::get_if<QList<MarkedString>>(&hoverContent))
|
||||
else if (auto markedStrings = std::get_if<QList<MarkedString>>(&hoverContent))
|
||||
setToolTip(toolTipForMarkedStrings(*markedStrings));
|
||||
}
|
||||
|
||||
|
@@ -296,10 +296,10 @@ void LanguageClientOutlineWidget::handleResponse(const DocumentUri &uri,
|
||||
{
|
||||
if (uri != m_uri)
|
||||
return;
|
||||
if (Utils::holds_alternative<QList<SymbolInformation>>(result))
|
||||
m_model.setInfo(Utils::get<QList<SymbolInformation>>(result));
|
||||
else if (Utils::holds_alternative<QList<DocumentSymbol>>(result))
|
||||
m_model.setInfo(Utils::get<QList<DocumentSymbol>>(result));
|
||||
if (std::holds_alternative<QList<SymbolInformation>>(result))
|
||||
m_model.setInfo(std::get<QList<SymbolInformation>>(result));
|
||||
else if (std::holds_alternative<QList<DocumentSymbol>>(result))
|
||||
m_model.setInfo(std::get<QList<DocumentSymbol>>(result));
|
||||
else
|
||||
m_model.clear();
|
||||
|
||||
@@ -440,10 +440,10 @@ void OutlineComboBox::updateModel(const DocumentUri &resultUri, const DocumentSy
|
||||
{
|
||||
if (m_uri != resultUri)
|
||||
return;
|
||||
if (Utils::holds_alternative<QList<SymbolInformation>>(result))
|
||||
m_model.setInfo(Utils::get<QList<SymbolInformation>>(result));
|
||||
else if (Utils::holds_alternative<QList<DocumentSymbol>>(result))
|
||||
m_model.setInfo(Utils::get<QList<DocumentSymbol>>(result));
|
||||
if (std::holds_alternative<QList<SymbolInformation>>(result))
|
||||
m_model.setInfo(std::get<QList<SymbolInformation>>(result));
|
||||
else if (std::holds_alternative<QList<DocumentSymbol>>(result))
|
||||
m_model.setInfo(std::get<QList<DocumentSymbol>>(result));
|
||||
else
|
||||
m_model.clear();
|
||||
|
||||
|
@@ -124,12 +124,12 @@ void LanguageClientQuickFixAssistProcessor::handleCodeActionResponse(const CodeA
|
||||
|
||||
GenericProposal *LanguageClientQuickFixAssistProcessor::handleCodeActionResult(const CodeActionResult &result)
|
||||
{
|
||||
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) {
|
||||
if (auto action = Utils::get_if<CodeAction>(&item))
|
||||
for (const std::variant<Command, CodeAction> &item : *list) {
|
||||
if (auto action = std::get_if<CodeAction>(&item))
|
||||
ops << new CodeActionQuickFixOperation(*action, m_client);
|
||||
else if (auto command = Utils::get_if<Command>(&item))
|
||||
else if (auto command = std::get_if<Command>(&item))
|
||||
ops << new CommandQuickFixOperation(*command, m_client);
|
||||
}
|
||||
return GenericProposal::createProposal(m_assistInterface.data(), ops);
|
||||
|
@@ -64,11 +64,11 @@ static void sendTextDocumentPositionParamsRequest(Client *client,
|
||||
else
|
||||
sendMessage = supportedFile;
|
||||
} else {
|
||||
const Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> &provider
|
||||
const Utils::optional<std::variant<bool, WorkDoneProgressOptions>> &provider
|
||||
= serverCapability.referencesProvider();
|
||||
sendMessage = provider.has_value();
|
||||
if (sendMessage && Utils::holds_alternative<bool>(*provider))
|
||||
sendMessage = Utils::get<bool>(*provider);
|
||||
if (sendMessage && std::holds_alternative<bool>(*provider))
|
||||
sendMessage = std::get<bool>(*provider);
|
||||
}
|
||||
if (sendMessage)
|
||||
client->sendMessage(request);
|
||||
@@ -79,11 +79,11 @@ static void handleGotoDefinitionResponse(const GotoDefinitionRequest::Response &
|
||||
Utils::optional<Utils::Link> linkUnderCursor)
|
||||
{
|
||||
if (Utils::optional<GotoResult> result = response.result()) {
|
||||
if (Utils::holds_alternative<std::nullptr_t>(*result)) {
|
||||
if (std::holds_alternative<std::nullptr_t>(*result)) {
|
||||
callback({});
|
||||
} else if (auto ploc = Utils::get_if<Location>(&*result)) {
|
||||
} else if (auto ploc = std::get_if<Location>(&*result)) {
|
||||
callback(linkUnderCursor.value_or(ploc->toLink()));
|
||||
} else if (auto plloc = Utils::get_if<QList<Location>>(&*result)) {
|
||||
} else if (auto plloc = std::get_if<QList<Location>>(&*result)) {
|
||||
if (!plloc->isEmpty())
|
||||
callback(linkUnderCursor.value_or(plloc->value(0).toLink()));
|
||||
else
|
||||
@@ -260,11 +260,11 @@ static bool supportsRename(Client *client,
|
||||
}
|
||||
}
|
||||
if (auto renameProvider = client->capabilities().renameProvider()) {
|
||||
if (Utils::holds_alternative<bool>(*renameProvider)) {
|
||||
if (!Utils::get<bool>(*renameProvider))
|
||||
if (std::holds_alternative<bool>(*renameProvider)) {
|
||||
if (!std::get<bool>(*renameProvider))
|
||||
return false;
|
||||
} else if (Utils::holds_alternative<ServerCapabilities::RenameOptions>(*renameProvider)) {
|
||||
prepareSupported = Utils::get<ServerCapabilities::RenameOptions>(*renameProvider)
|
||||
} else if (std::holds_alternative<ServerCapabilities::RenameOptions>(*renameProvider)) {
|
||||
prepareSupported = std::get<ServerCapabilities::RenameOptions>(*renameProvider)
|
||||
.prepareProvider()
|
||||
.value_or(false);
|
||||
}
|
||||
@@ -306,11 +306,11 @@ void SymbolSupport::requestPrepareRename(const TextDocumentPositionParams ¶m
|
||||
|
||||
const Utils::optional<PrepareRenameResult> &result = response.result();
|
||||
if (result.has_value()) {
|
||||
if (Utils::holds_alternative<PlaceHolderResult>(*result)) {
|
||||
auto placeHolderResult = Utils::get<PlaceHolderResult>(*result);
|
||||
if (std::holds_alternative<PlaceHolderResult>(*result)) {
|
||||
auto placeHolderResult = std::get<PlaceHolderResult>(*result);
|
||||
startRenameSymbol(params, placeHolderResult.placeHolder());
|
||||
} else if (Utils::holds_alternative<Range>(*result)) {
|
||||
auto range = Utils::get<Range>(*result);
|
||||
} else if (std::holds_alternative<Range>(*result)) {
|
||||
auto range = std::get<Range>(*result);
|
||||
startRenameSymbol(params, placeholder);
|
||||
}
|
||||
}
|
||||
|
@@ -211,9 +211,9 @@ QList<Core::LocatorFilterEntry> DocumentLocatorFilter::matchesFor(
|
||||
|
||||
QTC_ASSERT(m_currentSymbols.has_value(), return {});
|
||||
|
||||
if (auto list = Utils::get_if<QList<DocumentSymbol>>(&*m_currentSymbols))
|
||||
if (auto list = std::get_if<QList<DocumentSymbol>>(&*m_currentSymbols))
|
||||
return generateEntries(*list, entry);
|
||||
else if (auto list = Utils::get_if<QList<SymbolInformation>>(&*m_currentSymbols))
|
||||
else if (auto list = std::get_if<QList<SymbolInformation>>(&*m_currentSymbols))
|
||||
return generateEntries(*list, entry);
|
||||
|
||||
return {};
|
||||
@@ -277,11 +277,11 @@ void WorkspaceLocatorFilter::prepareSearch(const QString &entry,
|
||||
continue;
|
||||
if (!(force || client->locatorsEnabled()))
|
||||
continue;
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> capability
|
||||
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> capability
|
||||
= client->capabilities().workspaceSymbolProvider();
|
||||
if (!capability.has_value())
|
||||
continue;
|
||||
if (Utils::holds_alternative<bool>(*capability) && !Utils::get<bool>(*capability))
|
||||
if (std::holds_alternative<bool>(*capability) && !std::get<bool>(*capability))
|
||||
continue;
|
||||
WorkspaceSymbolRequest request(params);
|
||||
request.setResponseCallback(
|
||||
|
@@ -45,11 +45,11 @@ void ProgressManager::handleProgress(const LanguageServerProtocol::ProgressParam
|
||||
{
|
||||
const ProgressToken &token = params.token();
|
||||
ProgressParams::ProgressType value = params.value();
|
||||
if (auto begin = Utils::get_if<WorkDoneProgressBegin>(&value))
|
||||
if (auto begin = std::get_if<WorkDoneProgressBegin>(&value))
|
||||
beginProgress(token, *begin);
|
||||
else if (auto report = Utils::get_if<WorkDoneProgressReport>(&value))
|
||||
else if (auto report = std::get_if<WorkDoneProgressReport>(&value))
|
||||
reportProgress(token, *report);
|
||||
else if (auto end = Utils::get_if<WorkDoneProgressEnd>(&value))
|
||||
else if (auto end = std::get_if<WorkDoneProgressEnd>(&value))
|
||||
endProgress(token, *end);
|
||||
}
|
||||
|
||||
@@ -68,16 +68,16 @@ void ProgressManager::reset()
|
||||
|
||||
bool ProgressManager::isProgressEndMessage(const LanguageServerProtocol::ProgressParams ¶ms)
|
||||
{
|
||||
return Utils::holds_alternative<WorkDoneProgressEnd>(params.value());
|
||||
return std::holds_alternative<WorkDoneProgressEnd>(params.value());
|
||||
}
|
||||
|
||||
Utils::Id languageClientProgressId(const ProgressToken &token)
|
||||
{
|
||||
constexpr char k_LanguageClientProgressId[] = "LanguageClient.ProgressId.";
|
||||
auto toString = [](const ProgressToken &token){
|
||||
if (Utils::holds_alternative<int>(token))
|
||||
return QString::number(Utils::get<int>(token));
|
||||
return Utils::get<QString>(token);
|
||||
if (std::holds_alternative<int>(token))
|
||||
return QString::number(std::get<int>(token));
|
||||
return std::get<QString>(token);
|
||||
};
|
||||
return Utils::Id(k_LanguageClientProgressId).withSuffix(toString(token));
|
||||
}
|
||||
|
@@ -356,7 +356,7 @@ void SemanticTokenSupport::handleSemanticTokens(const Utils::FilePath &filePath,
|
||||
const SemanticTokensResult &result,
|
||||
int documentVersion)
|
||||
{
|
||||
if (auto tokens = Utils::get_if<SemanticTokens>(&result)) {
|
||||
if (auto tokens = std::get_if<SemanticTokens>(&result)) {
|
||||
const bool force = !m_tokens.contains(filePath);
|
||||
m_tokens[filePath] = {*tokens, documentVersion};
|
||||
highlight(filePath, force);
|
||||
@@ -369,10 +369,10 @@ void SemanticTokenSupport::handleSemanticTokensDelta(
|
||||
int documentVersion)
|
||||
{
|
||||
qCDebug(LOGLSPHIGHLIGHT) << "Handle Tokens for " << filePath;
|
||||
if (auto tokens = Utils::get_if<SemanticTokens>(&result)) {
|
||||
if (auto tokens = std::get_if<SemanticTokens>(&result)) {
|
||||
m_tokens[filePath] = {*tokens, documentVersion};
|
||||
qCDebug(LOGLSPHIGHLIGHT) << "New Data " << tokens->data();
|
||||
} else if (auto tokensDelta = Utils::get_if<SemanticTokensDelta>(&result)) {
|
||||
} else if (auto tokensDelta = std::get_if<SemanticTokensDelta>(&result)) {
|
||||
m_tokens[filePath].version = documentVersion;
|
||||
QList<SemanticTokensEdit> edits = tokensDelta->edits();
|
||||
if (edits.isEmpty()) {
|
||||
|
@@ -263,11 +263,11 @@ void LanguageClient::LanguageClientPlugin::testSnippetParsing()
|
||||
QFETCH(Parts, parts);
|
||||
|
||||
SnippetParseResult result = LanguageClient::parseSnippet(input);
|
||||
QCOMPARE(Utils::holds_alternative<ParsedSnippet>(result), success);
|
||||
QCOMPARE(std::holds_alternative<ParsedSnippet>(result), success);
|
||||
if (!success)
|
||||
return;
|
||||
|
||||
ParsedSnippet snippet = Utils::get<ParsedSnippet>(result);
|
||||
ParsedSnippet snippet = std::get<ParsedSnippet>(result);
|
||||
|
||||
auto rangesCompare = [&](const ParsedSnippet::Part &actual, const SnippetPart &expected) {
|
||||
QCOMPARE(actual.text, expected.text);
|
||||
|
@@ -470,18 +470,18 @@ QIcon FolderNode::icon() const
|
||||
QTC_CHECK(QThread::currentThread() == QCoreApplication::instance()->thread());
|
||||
|
||||
// Instantiating the Icon provider is expensive.
|
||||
if (auto strPtr = Utils::get_if<QString>(&m_icon)) {
|
||||
if (auto strPtr = std::get_if<QString>(&m_icon)) {
|
||||
m_icon = QIcon(*strPtr);
|
||||
} else if (auto directoryIconPtr = Utils::get_if<DirectoryIcon>(&m_icon)) {
|
||||
} else if (auto directoryIconPtr = std::get_if<DirectoryIcon>(&m_icon)) {
|
||||
m_icon = directoryIconPtr->icon();
|
||||
} else if (auto creatorPtr = Utils::get_if<IconCreator>(&m_icon)) {
|
||||
} else if (auto creatorPtr = std::get_if<IconCreator>(&m_icon)) {
|
||||
m_icon = (*creatorPtr)();
|
||||
} else {
|
||||
auto iconPtr = Utils::get_if<QIcon>(&m_icon);
|
||||
auto iconPtr = std::get_if<QIcon>(&m_icon);
|
||||
if (!iconPtr || iconPtr->isNull())
|
||||
m_icon = Utils::FileIconProvider::icon(QFileIconProvider::Folder);
|
||||
}
|
||||
return Utils::get<QIcon>(m_icon);
|
||||
return std::get<QIcon>(m_icon);
|
||||
}
|
||||
|
||||
Node *FolderNode::findNode(const std::function<bool(Node *)> &filter)
|
||||
|
@@ -34,9 +34,9 @@
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/id.h>
|
||||
#include <utils/optional.h>
|
||||
#include <utils/variant.h>
|
||||
|
||||
#include <functional>
|
||||
#include <variant>
|
||||
|
||||
namespace Utils { class MimeType; }
|
||||
|
||||
@@ -354,7 +354,7 @@ private:
|
||||
|
||||
QString m_displayName;
|
||||
QString m_addFileFilter;
|
||||
mutable Utils::variant<QIcon, DirectoryIcon, QString, IconCreator> m_icon;
|
||||
mutable std::variant<QIcon, DirectoryIcon, QString, IconCreator> m_icon;
|
||||
bool m_showWhenEmpty = false;
|
||||
};
|
||||
|
||||
|
@@ -108,7 +108,7 @@ void ImageCacheCollector::start(Utils::SmallStringView name,
|
||||
}
|
||||
|
||||
if (is3DRoot) {
|
||||
if (auto libIcon = Utils::get_if<ImageCache::LibraryIconAuxiliaryData>(&auxiliaryData))
|
||||
if (auto libIcon = std::get_if<ImageCache::LibraryIconAuxiliaryData>(&auxiliaryData))
|
||||
rewriterView.rootModelNode().setAuxiliaryData(AuxiliaryDataType::NodeInstancePropertyOverwrite,
|
||||
"isLibraryIcon",
|
||||
libIcon->enable);
|
||||
|
@@ -128,7 +128,7 @@ void ImageCacheFontCollector::start(Utils::SmallStringView name,
|
||||
{
|
||||
QFont font;
|
||||
if (resolveFont(QString(name), font) >= 0) {
|
||||
auto &&auxiliaryData = Utils::get<ImageCache::FontCollectorSizeAuxiliaryData>(auxiliaryDataValue);
|
||||
auto &&auxiliaryData = std::get<ImageCache::FontCollectorSizeAuxiliaryData>(auxiliaryDataValue);
|
||||
QColor textColor = auxiliaryData.colorName;
|
||||
QSize size = auxiliaryData.size;
|
||||
QString text = font.family() + "\n" + auxiliaryData.text;
|
||||
@@ -150,7 +150,7 @@ std::pair<QImage, QImage> ImageCacheFontCollector::createImage(
|
||||
{
|
||||
QFont font;
|
||||
if (resolveFont(QString(name), font) >= 0) {
|
||||
auto &&auxiliaryData = Utils::get<ImageCache::FontCollectorSizeAuxiliaryData>(auxiliaryDataValue);
|
||||
auto &&auxiliaryData = std::get<ImageCache::FontCollectorSizeAuxiliaryData>(auxiliaryDataValue);
|
||||
QColor textColor = auxiliaryData.colorName;
|
||||
QSize size = auxiliaryData.size;
|
||||
QString text = font.family() + "\n\n" + auxiliaryData.text;
|
||||
@@ -172,7 +172,7 @@ QIcon ImageCacheFontCollector::createIcon(Utils::SmallStringView name,
|
||||
|
||||
QFont font;
|
||||
if (resolveFont(QString(name), font) >= 0) {
|
||||
auto &&auxiliaryData = Utils::get<ImageCache::FontCollectorSizesAuxiliaryData>(auxiliaryDataValue);
|
||||
auto &&auxiliaryData = std::get<ImageCache::FontCollectorSizesAuxiliaryData>(auxiliaryDataValue);
|
||||
QColor textColor = auxiliaryData.colorName;
|
||||
const auto sizes = auxiliaryData.sizes;
|
||||
QString text = auxiliaryData.text;
|
||||
|
@@ -26,20 +26,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <auxiliarydata.h>
|
||||
#include <utils/variant.h>
|
||||
|
||||
#include <QColor>
|
||||
#include <QVariant>
|
||||
|
||||
#include <type_traits>
|
||||
#include <variant>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
using PropertyValue = Utils::variant<int, long long, double, bool, QColor, QStringView, Qt::Corner>;
|
||||
using PropertyValue = std::variant<int, long long, double, bool, QColor, QStringView, Qt::Corner>;
|
||||
|
||||
inline QVariant toQVariant(const PropertyValue &variant)
|
||||
{
|
||||
return Utils::visit([](const auto &value) { return QVariant::fromValue(value); }, variant);
|
||||
return std::visit([](const auto &value) { return QVariant::fromValue(value); }, variant);
|
||||
}
|
||||
|
||||
class AuxiliaryDataKeyDefaultValue : public AuxiliaryDataKeyView
|
||||
|
@@ -26,13 +26,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <utils/span.h>
|
||||
#include <utils/variant.h>
|
||||
|
||||
#include <QImage>
|
||||
#include <QSize>
|
||||
#include <QString>
|
||||
|
||||
#include <functional>
|
||||
#include <variant>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
bool enable;
|
||||
};
|
||||
|
||||
using AuxiliaryData = Utils::variant<Utils::monostate,
|
||||
using AuxiliaryData = std::variant<std::monostate,
|
||||
LibraryIconAuxiliaryData,
|
||||
FontCollectorSizeAuxiliaryData,
|
||||
FontCollectorSizesAuxiliaryData>;
|
||||
|
@@ -1910,7 +1910,7 @@ private:
|
||||
if (type.changeLevel == Storage::Synchronization::ChangeLevel::Minimal)
|
||||
return;
|
||||
|
||||
if (Utils::visit([](auto &&typeName) -> bool { return typeName.name.isEmpty(); },
|
||||
if (std::visit([](auto &&typeName) -> bool { return typeName.name.isEmpty(); },
|
||||
type.prototype)) {
|
||||
updatePrototypeStatement.write(type.typeId, Sqlite::NullValue{}, Sqlite::NullValue{});
|
||||
} else {
|
||||
@@ -1981,7 +1981,7 @@ private:
|
||||
SourceId sourceId;
|
||||
};
|
||||
|
||||
return Utils::visit(Inspect{*this, sourceId}, name);
|
||||
return std::visit(Inspect{*this, sourceId}, name);
|
||||
}
|
||||
|
||||
template<typename Id>
|
||||
|
@@ -29,9 +29,9 @@
|
||||
#include "projectstorageids.h"
|
||||
|
||||
#include <utils/smallstring.h>
|
||||
#include <utils/variant.h>
|
||||
|
||||
#include <tuple>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
namespace QmlDesigner {
|
||||
@@ -425,7 +425,7 @@ public:
|
||||
ExportedTypeNameId exportedTypeNameId;
|
||||
};
|
||||
|
||||
using ImportedTypeName = Utils::variant<ImportedType, QualifiedImportedType>;
|
||||
using ImportedTypeName = std::variant<ImportedType, QualifiedImportedType>;
|
||||
|
||||
class EnumeratorDeclaration
|
||||
{
|
||||
|
@@ -182,10 +182,10 @@ QString Snippet::generateTip() const
|
||||
{
|
||||
SnippetParseResult result = Snippet::parse(m_content);
|
||||
|
||||
if (Utils::holds_alternative<SnippetParseError>(result))
|
||||
return Utils::get<SnippetParseError>(result).htmlMessage();
|
||||
QTC_ASSERT(Utils::holds_alternative<ParsedSnippet>(result), return {});
|
||||
const ParsedSnippet parsedSnippet = Utils::get<ParsedSnippet>(result);
|
||||
if (std::holds_alternative<SnippetParseError>(result))
|
||||
return std::get<SnippetParseError>(result).htmlMessage();
|
||||
QTC_ASSERT(std::holds_alternative<ParsedSnippet>(result), return {});
|
||||
const ParsedSnippet parsedSnippet = std::get<ParsedSnippet>(result);
|
||||
|
||||
QString tip("<nobr>");
|
||||
for (const ParsedSnippet::Part &part : parsedSnippet.parts)
|
||||
@@ -407,11 +407,11 @@ void Internal::TextEditorPlugin::testSnippetParsing()
|
||||
QFETCH(Parts, parts);
|
||||
|
||||
SnippetParseResult result = Snippet::parse(input);
|
||||
QCOMPARE(Utils::holds_alternative<ParsedSnippet>(result), success);
|
||||
QCOMPARE(std::holds_alternative<ParsedSnippet>(result), success);
|
||||
if (!success)
|
||||
return;
|
||||
|
||||
ParsedSnippet snippet = Utils::get<ParsedSnippet>(result);
|
||||
ParsedSnippet snippet = std::get<ParsedSnippet>(result);
|
||||
|
||||
auto rangesCompare = [&](const ParsedSnippet::Part &actual, const SnippetPart &expected) {
|
||||
QCOMPARE(actual.text, expected.text);
|
||||
|
@@ -28,7 +28,8 @@
|
||||
#include <texteditor/texteditor_global.h>
|
||||
|
||||
#include <utils/id.h>
|
||||
#include <utils/variant.h>
|
||||
|
||||
#include <variant>
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
@@ -67,7 +68,7 @@ public:
|
||||
QString htmlMessage() const;
|
||||
};
|
||||
|
||||
using SnippetParseResult = Utils::variant<ParsedSnippet, SnippetParseError>;
|
||||
using SnippetParseResult = std::variant<ParsedSnippet, SnippetParseError>;
|
||||
using SnippetParser = std::function<SnippetParseResult (const QString &)>;
|
||||
|
||||
} // namespace TextEditor
|
||||
|
@@ -2761,13 +2761,13 @@ void TextEditorWidget::insertCodeSnippet(const QTextCursor &cursor_arg,
|
||||
const SnippetParser &parse)
|
||||
{
|
||||
SnippetParseResult result = parse(snippet);
|
||||
if (Utils::holds_alternative<SnippetParseError>(result)) {
|
||||
const auto &error = Utils::get<SnippetParseError>(result);
|
||||
if (std::holds_alternative<SnippetParseError>(result)) {
|
||||
const auto &error = std::get<SnippetParseError>(result);
|
||||
QMessageBox::warning(this, tr("Snippet Parse Error"), error.htmlMessage());
|
||||
return;
|
||||
}
|
||||
QTC_ASSERT(Utils::holds_alternative<ParsedSnippet>(result), return);
|
||||
ParsedSnippet data = Utils::get<ParsedSnippet>(result);
|
||||
QTC_ASSERT(std::holds_alternative<ParsedSnippet>(result), return);
|
||||
ParsedSnippet data = std::get<ParsedSnippet>(result);
|
||||
|
||||
QTextCursor cursor = cursor_arg;
|
||||
cursor.beginEditBlock();
|
||||
|
@@ -62,7 +62,7 @@ TEST_F(AsynchronousImageFactory, RequestImageRequestImageFromCollector)
|
||||
EXPECT_CALL(collectorMock,
|
||||
start(Eq("/path/to/Component.qml"),
|
||||
IsEmpty(),
|
||||
VariantWith<Utils::monostate>(Utils::monostate{}),
|
||||
VariantWith<std::monostate>(std::monostate{}),
|
||||
_,
|
||||
_))
|
||||
.WillRepeatedly([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
||||
@@ -76,7 +76,7 @@ TEST_F(AsynchronousImageFactory, RequestImageWithExtraIdRequestImageFromCollecto
|
||||
EXPECT_CALL(collectorMock,
|
||||
start(Eq("/path/to/Component.qml"),
|
||||
Eq("foo"),
|
||||
VariantWith<Utils::monostate>(Utils::monostate{}),
|
||||
VariantWith<std::monostate>(std::monostate{}),
|
||||
_,
|
||||
_))
|
||||
.WillRepeatedly([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
||||
@@ -162,7 +162,7 @@ TEST_F(AsynchronousImageFactory, AfterCleanNewJobsWorks)
|
||||
EXPECT_CALL(collectorMock,
|
||||
start(Eq("/path/to/Component.qml"),
|
||||
IsEmpty(),
|
||||
VariantWith<Utils::monostate>(Utils::monostate{}),
|
||||
VariantWith<std::monostate>(std::monostate{}),
|
||||
_,
|
||||
_))
|
||||
.WillRepeatedly([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
||||
@@ -181,7 +181,7 @@ TEST_F(AsynchronousImageFactory, CaptureImageCallbackStoresImage)
|
||||
ON_CALL(collectorMock,
|
||||
start(Eq("/path/to/Component.qml"),
|
||||
Eq("id"),
|
||||
VariantWith<Utils::monostate>(Utils::monostate{}),
|
||||
VariantWith<std::monostate>(std::monostate{}),
|
||||
_,
|
||||
_))
|
||||
.WillByDefault([&](auto, auto, auto, auto capture, auto) { capture(image1, smallImage1); });
|
||||
|
@@ -33,6 +33,7 @@
|
||||
|
||||
#include <clangtools/clangtoolsdiagnostic.h>
|
||||
#include <debugger/analyzer/diagnosticlocation.h>
|
||||
#include <imagecacheauxiliarydata.h>
|
||||
#include <modelnode.h>
|
||||
#include <projectstorage/filestatus.h>
|
||||
#include <projectstorage/projectstoragepathwatchertypes.h>
|
||||
@@ -54,6 +55,12 @@ template <typename T> ostream &operator<<(ostream &out, const QVector<T> &vector
|
||||
out << "]";
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const monostate &)
|
||||
{
|
||||
return out << "monostate";
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
||||
namespace Utils {
|
||||
@@ -739,6 +746,7 @@ std::ostream &operator<<(std::ostream &out, const QualifiedImportedType &importe
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const Type &type)
|
||||
{
|
||||
using std::operator<<;
|
||||
using Utils::operator<<;
|
||||
return out << "( typename: \"" << type.typeName << "\", prototype: " << type.prototype << ", "
|
||||
<< type.prototypeId << ", " << type.traits << ", source: " << type.sourceId
|
||||
@@ -813,4 +821,20 @@ std::ostream &operator<<(std::ostream &out, const ModuleExportedImport &import)
|
||||
|
||||
} // namespace Storage::Synchronization
|
||||
|
||||
namespace ImageCache {
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const LibraryIconAuxiliaryData &data)
|
||||
{
|
||||
return out << "(" << data.enable << ")";
|
||||
}
|
||||
std::ostream &operator<<(std::ostream &out, const FontCollectorSizeAuxiliaryData &data)
|
||||
{
|
||||
return out << "(" << data.text << ", " << data.size << ", " << data.colorName << ")";
|
||||
}
|
||||
std::ostream &operator<<(std::ostream &out, const FontCollectorSizesAuxiliaryData &data)
|
||||
{
|
||||
return out << "(" << data.text << ", " << data.colorName << ")";
|
||||
}
|
||||
} // namespace ImageCache
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -28,11 +28,11 @@
|
||||
#include <utils/cpplanguage_details.h>
|
||||
#include <utils/optional.h>
|
||||
#include <utils/smallstringio.h>
|
||||
#include <utils/variant.h>
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <iosfwd>
|
||||
#include <variant>
|
||||
|
||||
#include <gtest/gtest-printers.h>
|
||||
|
||||
@@ -77,6 +77,18 @@ std::ostream &operator<<(std::ostream &out, const ValueViews &valueViews);
|
||||
} // namespace SessionChangeSetInternal
|
||||
} // namespace Sqlite
|
||||
|
||||
namespace std {
|
||||
|
||||
template<typename Type, typename... Types>
|
||||
std::ostream &operator<<(std::ostream &out, const variant<Type, Types...> &v)
|
||||
{
|
||||
return visit([&](auto &&value) -> std::ostream & { return out << value; }, v);
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const monostate &);
|
||||
|
||||
} // namespace std
|
||||
|
||||
namespace Utils {
|
||||
class LineColumn;
|
||||
class SmallStringView;
|
||||
@@ -103,12 +115,6 @@ void PrintTo(const optional<Type> &optional, ::std::ostream *os)
|
||||
*os << optional;
|
||||
}
|
||||
|
||||
template<typename... Type>
|
||||
std::ostream &operator<<(std::ostream &out, const variant<Type...> &variant)
|
||||
{
|
||||
return Utils::visit([&](auto &&value) -> std::ostream & { return out << value; }, variant);
|
||||
}
|
||||
|
||||
void PrintTo(Utils::SmallStringView text, ::std::ostream *os);
|
||||
void PrintTo(const Utils::SmallString &text, ::std::ostream *os);
|
||||
void PrintTo(const Utils::PathString &text, ::std::ostream *os);
|
||||
@@ -152,6 +158,16 @@ class SourceContext;
|
||||
std::ostream &operator<<(std::ostream &out, const SourceContext &sourceContext);
|
||||
} // namespace Cache
|
||||
|
||||
namespace ImageCache {
|
||||
class LibraryIconAuxiliaryData;
|
||||
class FontCollectorSizeAuxiliaryData;
|
||||
class FontCollectorSizesAuxiliaryData;
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const LibraryIconAuxiliaryData &date);
|
||||
std::ostream &operator<<(std::ostream &out, const FontCollectorSizeAuxiliaryData &sourceContext);
|
||||
std::ostream &operator<<(std::ostream &out, const FontCollectorSizesAuxiliaryData &sourceContext);
|
||||
} // namespace ImageCache
|
||||
|
||||
namespace Storage {
|
||||
enum class PropertyDeclarationTraits : int;
|
||||
enum class TypeTraits : int;
|
||||
|
Reference in New Issue
Block a user