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);
|
setWorkspaceFolders(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::optional<Utils::variant<bool, QJsonObject>> SemanticTokensClientCapabilities::Requests::range()
|
Utils::optional<std::variant<bool, QJsonObject>> SemanticTokensClientCapabilities::Requests::range()
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
using RetType = Utils::variant<bool, QJsonObject>;
|
using RetType = std::variant<bool, QJsonObject>;
|
||||||
const QJsonValue &rangeOptions = value(rangeKey);
|
const QJsonValue &rangeOptions = value(rangeKey);
|
||||||
if (rangeOptions.isBool())
|
if (rangeOptions.isBool())
|
||||||
return RetType(rangeOptions.toBool());
|
return RetType(rangeOptions.toBool());
|
||||||
@@ -60,15 +60,15 @@ Utils::optional<Utils::variant<bool, QJsonObject>> SemanticTokensClientCapabilit
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SemanticTokensClientCapabilities::Requests::setRange(
|
void SemanticTokensClientCapabilities::Requests::setRange(
|
||||||
const Utils::variant<bool, QJsonObject> &range)
|
const std::variant<bool, QJsonObject> &range)
|
||||||
{
|
{
|
||||||
insertVariant<bool, QJsonObject>(rangeKey, range);
|
insertVariant<bool, QJsonObject>(rangeKey, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::optional<Utils::variant<bool, FullSemanticTokenOptions>>
|
Utils::optional<std::variant<bool, FullSemanticTokenOptions>>
|
||||||
SemanticTokensClientCapabilities::Requests::full() const
|
SemanticTokensClientCapabilities::Requests::full() const
|
||||||
{
|
{
|
||||||
using RetType = Utils::variant<bool, FullSemanticTokenOptions>;
|
using RetType = std::variant<bool, FullSemanticTokenOptions>;
|
||||||
const QJsonValue &fullOptions = value(fullKey);
|
const QJsonValue &fullOptions = value(fullKey);
|
||||||
if (fullOptions.isBool())
|
if (fullOptions.isBool())
|
||||||
return RetType(fullOptions.toBool());
|
return RetType(fullOptions.toBool());
|
||||||
@@ -78,7 +78,7 @@ SemanticTokensClientCapabilities::Requests::full() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SemanticTokensClientCapabilities::Requests::setFull(
|
void SemanticTokensClientCapabilities::Requests::setFull(
|
||||||
const Utils::variant<bool, FullSemanticTokenOptions> &full)
|
const std::variant<bool, FullSemanticTokenOptions> &full)
|
||||||
{
|
{
|
||||||
insertVariant<bool, FullSemanticTokenOptions>(fullKey, full);
|
insertVariant<bool, FullSemanticTokenOptions>(fullKey, full);
|
||||||
}
|
}
|
||||||
|
@@ -78,16 +78,16 @@ public:
|
|||||||
* The client will send the `textDocument/semanticTokens/range` request
|
* The client will send the `textDocument/semanticTokens/range` request
|
||||||
* if the server provides a corresponding handler.
|
* if the server provides a corresponding handler.
|
||||||
*/
|
*/
|
||||||
Utils::optional<Utils::variant<bool, QJsonObject>> range() const;
|
Utils::optional<std::variant<bool, QJsonObject>> range() const;
|
||||||
void setRange(const Utils::variant<bool, QJsonObject> &range);
|
void setRange(const std::variant<bool, QJsonObject> &range);
|
||||||
void clearRange() { remove(rangeKey); }
|
void clearRange() { remove(rangeKey); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The client will send the `textDocument/semanticTokens/full` request
|
* The client will send the `textDocument/semanticTokens/full` request
|
||||||
* if the server provides a corresponding handler.
|
* if the server provides a corresponding handler.
|
||||||
*/
|
*/
|
||||||
Utils::optional<Utils::variant<bool, FullSemanticTokenOptions>> full() const;
|
Utils::optional<std::variant<bool, FullSemanticTokenOptions>> full() const;
|
||||||
void setFull(const Utils::variant<bool, FullSemanticTokenOptions> &full);
|
void setFull(const std::variant<bool, FullSemanticTokenOptions> &full);
|
||||||
void clearFull() { remove(fullKey); }
|
void clearFull() { remove(fullKey); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -263,7 +263,7 @@ public:
|
|||||||
|
|
||||||
/// The result of a completion is CompletionItem[] | CompletionList | null
|
/// The result of a completion is CompletionItem[] | CompletionList | null
|
||||||
class LANGUAGESERVERPROTOCOL_EXPORT CompletionResult
|
class LANGUAGESERVERPROTOCOL_EXPORT CompletionResult
|
||||||
: public Utils::variant<QList<CompletionItem>, CompletionList, std::nullptr_t>
|
: public std::variant<QList<CompletionItem>, CompletionList, std::nullptr_t>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using variant::variant;
|
using variant::variant;
|
||||||
|
@@ -112,7 +112,7 @@ private:
|
|||||||
template<typename T, typename V>
|
template<typename T, typename V>
|
||||||
JsonObject::iterator JsonObject::insertVariant(const QStringView key, const V &variant)
|
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>
|
template<typename T1, typename T2, typename... Args, typename V>
|
||||||
|
@@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
#include <utils/optional.h>
|
#include <utils/optional.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/variant.h>
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
@@ -41,11 +40,13 @@
|
|||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
namespace LanguageServerProtocol {
|
namespace LanguageServerProtocol {
|
||||||
|
|
||||||
class JsonRpcMessage;
|
class JsonRpcMessage;
|
||||||
|
|
||||||
class LANGUAGESERVERPROTOCOL_EXPORT MessageId : public Utils::variant<int, QString>
|
class LANGUAGESERVERPROTOCOL_EXPORT MessageId : public std::variant<int, QString>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MessageId() : variant(QString()) {}
|
MessageId() : variant(QString()) {}
|
||||||
@@ -61,37 +62,37 @@ public:
|
|||||||
|
|
||||||
operator QJsonValue() const
|
operator QJsonValue() const
|
||||||
{
|
{
|
||||||
if (auto id = Utils::get_if<int>(this))
|
if (auto id = std::get_if<int>(this))
|
||||||
return *id;
|
return *id;
|
||||||
if (auto id = Utils::get_if<QString>(this))
|
if (auto id = std::get_if<QString>(this))
|
||||||
return *id;
|
return *id;
|
||||||
return QJsonValue();
|
return QJsonValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isValid() const
|
bool isValid() const
|
||||||
{
|
{
|
||||||
if (Utils::holds_alternative<int>(*this))
|
if (std::holds_alternative<int>(*this))
|
||||||
return true;
|
return true;
|
||||||
const QString *id = Utils::get_if<QString>(this);
|
const QString *id = std::get_if<QString>(this);
|
||||||
QTC_ASSERT(id, return false);
|
QTC_ASSERT(id, return false);
|
||||||
return !id->isEmpty();
|
return !id->isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString toString() const
|
QString toString() const
|
||||||
{
|
{
|
||||||
if (auto id = Utils::get_if<QString>(this))
|
if (auto id = std::get_if<QString>(this))
|
||||||
return *id;
|
return *id;
|
||||||
if (auto id = Utils::get_if<int>(this))
|
if (auto id = std::get_if<int>(this))
|
||||||
return QString::number(*id);
|
return QString::number(*id);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
friend auto qHash(const MessageId &id)
|
friend auto qHash(const MessageId &id)
|
||||||
{
|
{
|
||||||
if (Utils::holds_alternative<int>(id))
|
if (std::holds_alternative<int>(id))
|
||||||
return QT_PREPEND_NAMESPACE(qHash(Utils::get<int>(id)));
|
return QT_PREPEND_NAMESPACE(qHash(std::get<int>(id)));
|
||||||
if (Utils::holds_alternative<QString>(id))
|
if (std::holds_alternative<QString>(id))
|
||||||
return QT_PREPEND_NAMESPACE(qHash(Utils::get<QString>(id)));
|
return QT_PREPEND_NAMESPACE(qHash(std::get<QString>(id)));
|
||||||
return QT_PREPEND_NAMESPACE(qHash(0));
|
return QT_PREPEND_NAMESPACE(qHash(0));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -99,10 +100,10 @@ public:
|
|||||||
template <typename Error>
|
template <typename Error>
|
||||||
inline QDebug operator<<(QDebug stream, const LanguageServerProtocol::MessageId &id)
|
inline QDebug operator<<(QDebug stream, const LanguageServerProtocol::MessageId &id)
|
||||||
{
|
{
|
||||||
if (Utils::holds_alternative<int>(id))
|
if (std::holds_alternative<int>(id))
|
||||||
stream << Utils::get<int>(id);
|
stream << std::get<int>(id);
|
||||||
else
|
else
|
||||||
stream << Utils::get<QString>(id);
|
stream << std::get<QString>(id);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -57,11 +57,11 @@ HoverContent LanguageServerProtocol::Hover::content() const
|
|||||||
|
|
||||||
void Hover::setContent(const HoverContent &content)
|
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);
|
insert(contentsKey, *val);
|
||||||
else if (auto val = Utils::get_if<MarkupContent>(&content))
|
else if (auto val = std::get_if<MarkupContent>(&content))
|
||||||
insert(contentsKey, *val);
|
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());
|
insert(contentsKey, LanguageClientArray<MarkedString>(*val).toJson());
|
||||||
else
|
else
|
||||||
QTC_ASSERT_STRING("LanguageClient Using unknown type Hover::setContent");
|
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)
|
void FormattingOptions::setProperty(const QString &key, const DocumentFormattingProperty &property)
|
||||||
{
|
{
|
||||||
using namespace Utils;
|
using namespace std;
|
||||||
if (auto val = get_if<double>(&property))
|
if (auto val = get_if<double>(&property))
|
||||||
insert(key, *val);
|
insert(key, *val);
|
||||||
else if (auto val = get_if<QString>(&property))
|
else if (auto val = get_if<QString>(&property))
|
||||||
@@ -293,16 +293,16 @@ MarkedString::MarkedString(const QJsonValue &value)
|
|||||||
|
|
||||||
bool MarkedString::isValid() const
|
bool MarkedString::isValid() const
|
||||||
{
|
{
|
||||||
if (auto markedLanguageString = Utils::get_if<MarkedLanguageString>(this))
|
if (auto markedLanguageString = std::get_if<MarkedLanguageString>(this))
|
||||||
return markedLanguageString->isValid();
|
return markedLanguageString->isValid();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LanguageServerProtocol::MarkedString::operator QJsonValue() const
|
LanguageServerProtocol::MarkedString::operator QJsonValue() const
|
||||||
{
|
{
|
||||||
if (auto val = Utils::get_if<QString>(this))
|
if (auto val = std::get_if<QString>(this))
|
||||||
return *val;
|
return *val;
|
||||||
if (auto val = Utils::get_if<MarkedLanguageString>(this))
|
if (auto val = std::get_if<MarkedLanguageString>(this))
|
||||||
return QJsonValue(*val);
|
return QJsonValue(*val);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -325,8 +325,8 @@ HoverContent::HoverContent(const QJsonValue &value)
|
|||||||
|
|
||||||
bool HoverContent::isValid() const
|
bool HoverContent::isValid() const
|
||||||
{
|
{
|
||||||
if (Utils::holds_alternative<MarkedString>(*this))
|
if (std::holds_alternative<MarkedString>(*this))
|
||||||
return Utils::get<MarkedString>(*this).isValid();
|
return std::get<MarkedString>(*this).isValid();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,7 +346,7 @@ SignatureHelpRequest::SignatureHelpRequest(const TextDocumentPositionParams &par
|
|||||||
|
|
||||||
CodeActionResult::CodeActionResult(const QJsonValue &val)
|
CodeActionResult::CodeActionResult(const QJsonValue &val)
|
||||||
{
|
{
|
||||||
using ResultArray = QList<Utils::variant<Command, CodeAction>>;
|
using ResultArray = QList<std::variant<Command, CodeAction>>;
|
||||||
if (val.isArray()) {
|
if (val.isArray()) {
|
||||||
const QJsonArray array = val.toArray();
|
const QJsonArray array = val.toArray();
|
||||||
ResultArray result;
|
ResultArray result;
|
||||||
@@ -368,21 +368,21 @@ CodeActionResult::CodeActionResult(const QJsonValue &val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PrepareRenameResult::PrepareRenameResult()
|
PrepareRenameResult::PrepareRenameResult()
|
||||||
: Utils::variant<PlaceHolderResult, Range, std::nullptr_t>(nullptr)
|
: std::variant<PlaceHolderResult, Range, std::nullptr_t>(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
PrepareRenameResult::PrepareRenameResult(
|
PrepareRenameResult::PrepareRenameResult(
|
||||||
const Utils::variant<PlaceHolderResult, Range, std::nullptr_t> &val)
|
const std::variant<PlaceHolderResult, Range, std::nullptr_t> &val)
|
||||||
: Utils::variant<PlaceHolderResult, Range, std::nullptr_t>(val)
|
: std::variant<PlaceHolderResult, Range, std::nullptr_t>(val)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
PrepareRenameResult::PrepareRenameResult(const PlaceHolderResult &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)
|
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)
|
PrepareRenameResult::PrepareRenameResult(const QJsonValue &val)
|
||||||
@@ -413,7 +413,7 @@ HoverResult::HoverResult(const QJsonValue &value)
|
|||||||
|
|
||||||
bool HoverResult::isValid() const
|
bool HoverResult::isValid() const
|
||||||
{
|
{
|
||||||
if (auto hover = Utils::get_if<Hover>(this))
|
if (auto hover = std::get_if<Hover>(this))
|
||||||
return hover->isValid();
|
return hover->isValid();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -58,7 +58,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class LANGUAGESERVERPROTOCOL_EXPORT MarkedString
|
class LANGUAGESERVERPROTOCOL_EXPORT MarkedString
|
||||||
: public Utils::variant<QString, MarkedLanguageString>
|
: public std::variant<QString, MarkedLanguageString>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkedString() = default;
|
MarkedString() = default;
|
||||||
@@ -75,7 +75,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class LANGUAGESERVERPROTOCOL_EXPORT HoverContent
|
class LANGUAGESERVERPROTOCOL_EXPORT HoverContent
|
||||||
: public Utils::variant<MarkedString, QList<MarkedString>, MarkupContent>
|
: public std::variant<MarkedString, QList<MarkedString>, MarkupContent>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HoverContent() = default;
|
HoverContent() = default;
|
||||||
@@ -101,7 +101,7 @@ public:
|
|||||||
bool isValid() const override { return contains(contentsKey); }
|
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:
|
public:
|
||||||
HoverResult() : variant(nullptr) {}
|
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
|
/// The result of a goto request can either be a location, a list of locations or null
|
||||||
class LANGUAGESERVERPROTOCOL_EXPORT GotoResult
|
class LANGUAGESERVERPROTOCOL_EXPORT GotoResult
|
||||||
: public Utils::variant<Location, QList<Location>, std::nullptr_t>
|
: public std::variant<Location, QList<Location>, std::nullptr_t>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit GotoResult(const QJsonValue &value);
|
explicit GotoResult(const QJsonValue &value);
|
||||||
@@ -307,7 +307,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class LANGUAGESERVERPROTOCOL_EXPORT DocumentHighlightsResult
|
class LANGUAGESERVERPROTOCOL_EXPORT DocumentHighlightsResult
|
||||||
: public Utils::variant<QList<DocumentHighlight>, std::nullptr_t>
|
: public std::variant<QList<DocumentHighlight>, std::nullptr_t>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using variant::variant;
|
using variant::variant;
|
||||||
@@ -343,7 +343,7 @@ public:
|
|||||||
using DocumentSymbolParams = TextDocumentParams;
|
using DocumentSymbolParams = TextDocumentParams;
|
||||||
|
|
||||||
class LANGUAGESERVERPROTOCOL_EXPORT DocumentSymbolsResult
|
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:
|
public:
|
||||||
using variant::variant;
|
using variant::variant;
|
||||||
@@ -468,7 +468,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class LANGUAGESERVERPROTOCOL_EXPORT CodeActionResult
|
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:
|
public:
|
||||||
using variant::variant;
|
using variant::variant;
|
||||||
@@ -658,13 +658,13 @@ public:
|
|||||||
constexpr static const char methodName[] = "textDocument/colorPresentation";
|
constexpr static const char methodName[] = "textDocument/colorPresentation";
|
||||||
};
|
};
|
||||||
|
|
||||||
class DocumentFormattingProperty : public Utils::variant<bool, double, QString>
|
class DocumentFormattingProperty : public std::variant<bool, double, QString>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DocumentFormattingProperty() = default;
|
DocumentFormattingProperty() = default;
|
||||||
explicit DocumentFormattingProperty(const QJsonValue &value);
|
explicit DocumentFormattingProperty(const QJsonValue &value);
|
||||||
explicit DocumentFormattingProperty(const DocumentFormattingProperty &other)
|
explicit DocumentFormattingProperty(const DocumentFormattingProperty &other)
|
||||||
: Utils::variant<bool, double, QString>(other) {}
|
: std::variant<bool, double, QString>(other) {}
|
||||||
|
|
||||||
using variant::variant;
|
using variant::variant;
|
||||||
using variant::operator=;
|
using variant::operator=;
|
||||||
@@ -806,11 +806,11 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class LANGUAGESERVERPROTOCOL_EXPORT PrepareRenameResult
|
class LANGUAGESERVERPROTOCOL_EXPORT PrepareRenameResult
|
||||||
: public Utils::variant<PlaceHolderResult, Range, std::nullptr_t>
|
: public std::variant<PlaceHolderResult, Range, std::nullptr_t>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PrepareRenameResult();
|
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 PlaceHolderResult &val);
|
||||||
explicit PrepareRenameResult(const Range &val);
|
explicit PrepareRenameResult(const Range &val);
|
||||||
explicit PrepareRenameResult(const QJsonValue &val);
|
explicit PrepareRenameResult(const QJsonValue &val);
|
||||||
|
@@ -95,16 +95,16 @@ WorkSpaceFolder::WorkSpaceFolder(const DocumentUri &uri, const QString &name)
|
|||||||
setName(name);
|
setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkupOrString::MarkupOrString(const Utils::variant<QString, MarkupContent> &val)
|
MarkupOrString::MarkupOrString(const std::variant<QString, MarkupContent> &val)
|
||||||
: Utils::variant<QString, MarkupContent>(val)
|
: std::variant<QString, MarkupContent>(val)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
MarkupOrString::MarkupOrString(const QString &val)
|
MarkupOrString::MarkupOrString(const QString &val)
|
||||||
: Utils::variant<QString, MarkupContent>(val)
|
: std::variant<QString, MarkupContent>(val)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
MarkupOrString::MarkupOrString(const MarkupContent &val)
|
MarkupOrString::MarkupOrString(const MarkupContent &val)
|
||||||
: Utils::variant<QString, MarkupContent>(val)
|
: std::variant<QString, MarkupContent>(val)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
MarkupOrString::MarkupOrString(const QJsonValue &val)
|
MarkupOrString::MarkupOrString(const QJsonValue &val)
|
||||||
@@ -120,10 +120,10 @@ MarkupOrString::MarkupOrString(const QJsonValue &val)
|
|||||||
|
|
||||||
QJsonValue MarkupOrString::toJson() const
|
QJsonValue MarkupOrString::toJson() const
|
||||||
{
|
{
|
||||||
if (Utils::holds_alternative<QString>(*this))
|
if (std::holds_alternative<QString>(*this))
|
||||||
return Utils::get<QString>(*this);
|
return std::get<QString>(*this);
|
||||||
if (Utils::holds_alternative<MarkupContent>(*this))
|
if (std::holds_alternative<MarkupContent>(*this))
|
||||||
return QJsonValue(Utils::get<MarkupContent>(*this));
|
return QJsonValue(std::get<MarkupContent>(*this));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,7 +34,6 @@
|
|||||||
#include <utils/mimeutils.h>
|
#include <utils/mimeutils.h>
|
||||||
#include <utils/optional.h>
|
#include <utils/optional.h>
|
||||||
#include <utils/textutils.h>
|
#include <utils/textutils.h>
|
||||||
#include <utils/variant.h>
|
|
||||||
|
|
||||||
#include <QTextCursor>
|
#include <QTextCursor>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
@@ -42,6 +41,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
namespace LanguageServerProtocol {
|
namespace LanguageServerProtocol {
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ public:
|
|||||||
void clearSeverity() { remove(severityKey); }
|
void clearSeverity() { remove(severityKey); }
|
||||||
|
|
||||||
// The diagnostic's code, which might appear in the user interface.
|
// 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;
|
Utils::optional<Code> code() const;
|
||||||
void setCode(const Code &code);
|
void setCode(const Code &code);
|
||||||
void clearCode() { remove(codeKey); }
|
void clearCode() { remove(codeKey); }
|
||||||
@@ -456,11 +456,11 @@ public:
|
|||||||
{ return contains(kindKey) && contains(contentKey); }
|
{ return contains(kindKey) && contains(contentKey); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class LANGUAGESERVERPROTOCOL_EXPORT MarkupOrString : public Utils::variant<QString, MarkupContent>
|
class LANGUAGESERVERPROTOCOL_EXPORT MarkupOrString : public std::variant<QString, MarkupContent>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkupOrString() = default;
|
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 QString &val);
|
||||||
explicit MarkupOrString(const MarkupContent &val);
|
explicit MarkupOrString(const MarkupContent &val);
|
||||||
MarkupOrString(const QJsonValue &val);
|
MarkupOrString(const QJsonValue &val);
|
||||||
|
@@ -30,12 +30,13 @@
|
|||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/optional.h>
|
#include <utils/optional.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/variant.h>
|
|
||||||
|
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
namespace LanguageServerProtocol {
|
namespace LanguageServerProtocol {
|
||||||
|
|
||||||
LANGUAGESERVERPROTOCOL_EXPORT Q_DECLARE_LOGGING_CATEGORY(conversionLog)
|
LANGUAGESERVERPROTOCOL_EXPORT Q_DECLARE_LOGGING_CATEGORY(conversionLog)
|
||||||
@@ -73,11 +74,11 @@ template<>
|
|||||||
LANGUAGESERVERPROTOCOL_EXPORT QJsonValue fromJsonValue<QJsonValue>(const QJsonValue &value);
|
LANGUAGESERVERPROTOCOL_EXPORT QJsonValue fromJsonValue<QJsonValue>(const QJsonValue &value);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class LanguageClientArray : public Utils::variant<QList<T>, std::nullptr_t>
|
class LanguageClientArray : public std::variant<QList<T>, std::nullptr_t>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Utils::variant<QList<T>, std::nullptr_t>::variant;
|
using std::variant<QList<T>, std::nullptr_t>::variant;
|
||||||
using Utils::variant<QList<T>, std::nullptr_t>::operator=;
|
using std::variant<QList<T>, std::nullptr_t>::operator=;
|
||||||
|
|
||||||
LanguageClientArray() {}
|
LanguageClientArray() {}
|
||||||
|
|
||||||
@@ -99,7 +100,7 @@ public:
|
|||||||
|
|
||||||
QJsonValue toJson() const
|
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;
|
QJsonArray array;
|
||||||
for (const T &value : *list)
|
for (const T &value : *list)
|
||||||
array.append(QJsonValue(value));
|
array.append(QJsonValue(value));
|
||||||
@@ -110,20 +111,20 @@ public:
|
|||||||
|
|
||||||
QList<T> toList() const
|
QList<T> toList() const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(Utils::holds_alternative<QList<T>>(*this), return {});
|
QTC_ASSERT(std::holds_alternative<QList<T>>(*this), return {});
|
||||||
return Utils::get<QList<T>>(*this);
|
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>
|
template <typename T>
|
||||||
class LanguageClientValue : public Utils::variant<T, std::nullptr_t>
|
class LanguageClientValue : public std::variant<T, std::nullptr_t>
|
||||||
{
|
{
|
||||||
public:
|
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() : std::variant<T, std::nullptr_t>(nullptr) { }
|
||||||
LanguageClientValue(const T &value) : Utils::variant<T, std::nullptr_t>(value) { }
|
LanguageClientValue(const T &value) : std::variant<T, std::nullptr_t>(value) { }
|
||||||
LanguageClientValue(const QJsonValue &value)
|
LanguageClientValue(const QJsonValue &value)
|
||||||
{
|
{
|
||||||
if (!QTC_GUARD(!value.isUndefined()) || value.isNull())
|
if (!QTC_GUARD(!value.isUndefined()) || value.isNull())
|
||||||
@@ -134,25 +135,25 @@ public:
|
|||||||
|
|
||||||
operator const QJsonValue() const
|
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(*val);
|
||||||
return QJsonValue();
|
return QJsonValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
T value(const T &defaultValue = T()) const
|
T value(const T &defaultValue = T()) const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(Utils::holds_alternative<T>(*this), return defaultValue);
|
QTC_ASSERT(std::holds_alternative<T>(*this), return defaultValue);
|
||||||
return Utils::get<T>(*this);
|
return std::get<T>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
LanguageClientValue<Type> transform()
|
LanguageClientValue<Type> transform()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!Utils::holds_alternative<T>(*this), return LanguageClientValue<Type>());
|
QTC_ASSERT(!std::holds_alternative<T>(*this), return LanguageClientValue<Type>());
|
||||||
return Type(Utils::get<T>(*this));
|
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>
|
template <typename T>
|
||||||
|
@@ -43,9 +43,9 @@ ProgressToken::ProgressToken(const QJsonValue &value)
|
|||||||
|
|
||||||
ProgressToken::operator QJsonValue() const
|
ProgressToken::operator QJsonValue() const
|
||||||
{
|
{
|
||||||
if (Utils::holds_alternative<QString>(*this))
|
if (std::holds_alternative<QString>(*this))
|
||||||
return QJsonValue(Utils::get<QString>(*this));
|
return QJsonValue(std::get<QString>(*this));
|
||||||
return QJsonValue(Utils::get<int>(*this));
|
return QJsonValue(std::get<int>(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressParams::ProgressType ProgressParams::value() const
|
ProgressParams::ProgressType ProgressParams::value() const
|
||||||
|
@@ -27,13 +27,13 @@
|
|||||||
|
|
||||||
#include "jsonrpcmessages.h"
|
#include "jsonrpcmessages.h"
|
||||||
|
|
||||||
#include <utils/variant.h>
|
|
||||||
|
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
|
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
namespace LanguageServerProtocol {
|
namespace LanguageServerProtocol {
|
||||||
|
|
||||||
class LANGUAGESERVERPROTOCOL_EXPORT ProgressToken : public Utils::variant<int, QString>
|
class LANGUAGESERVERPROTOCOL_EXPORT ProgressToken : public std::variant<int, QString>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using variant::variant;
|
using variant::variant;
|
||||||
@@ -124,7 +124,7 @@ public:
|
|||||||
void setToken(const ProgressToken &token) { insert(tokenKey, token); }
|
void setToken(const ProgressToken &token) { insert(tokenKey, token); }
|
||||||
|
|
||||||
using ProgressType
|
using ProgressType
|
||||||
= Utils::variant<WorkDoneProgressBegin, WorkDoneProgressReport, WorkDoneProgressEnd>;
|
= std::variant<WorkDoneProgressBegin, WorkDoneProgressReport, WorkDoneProgressEnd>;
|
||||||
ProgressType value() const;
|
ProgressType value() const;
|
||||||
void setValue(const ProgressType &value);
|
void setValue(const ProgressType &value);
|
||||||
|
|
||||||
|
@@ -164,7 +164,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class LANGUAGESERVERPROTOCOL_EXPORT SemanticTokensResult
|
class LANGUAGESERVERPROTOCOL_EXPORT SemanticTokensResult
|
||||||
: public Utils::variant<SemanticTokens, std::nullptr_t>
|
: public std::variant<SemanticTokens, std::nullptr_t>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using variant::variant;
|
using variant::variant;
|
||||||
@@ -215,7 +215,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class LANGUAGESERVERPROTOCOL_EXPORT SemanticTokensDeltaResult
|
class LANGUAGESERVERPROTOCOL_EXPORT SemanticTokensDeltaResult
|
||||||
: public Utils::variant<SemanticTokens, SemanticTokensDelta, std::nullptr_t>
|
: public std::variant<SemanticTokens, SemanticTokensDelta, std::nullptr_t>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using variant::variant;
|
using variant::variant;
|
||||||
|
@@ -44,9 +44,9 @@ void ServerCapabilities::setTextDocumentSync(const ServerCapabilities::TextDocum
|
|||||||
TextDocumentSyncKind ServerCapabilities::textDocumentSyncKindHelper()
|
TextDocumentSyncKind ServerCapabilities::textDocumentSyncKindHelper()
|
||||||
{
|
{
|
||||||
if (Utils::optional<TextDocumentSync> sync = textDocumentSync()) {
|
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);
|
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())
|
if (const Utils::optional<int> &change = options->change())
|
||||||
return static_cast<TextDocumentSyncKind>(*change);
|
return static_cast<TextDocumentSyncKind>(*change);
|
||||||
}
|
}
|
||||||
@@ -54,10 +54,10 @@ TextDocumentSyncKind ServerCapabilities::textDocumentSyncKindHelper()
|
|||||||
return TextDocumentSyncKind::None;
|
return TextDocumentSyncKind::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> ServerCapabilities::hoverProvider()
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> ServerCapabilities::hoverProvider()
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
using RetType = std::variant<bool, WorkDoneProgressOptions>;
|
||||||
const QJsonValue &provider = value(hoverProviderKey);
|
const QJsonValue &provider = value(hoverProviderKey);
|
||||||
if (provider.isBool())
|
if (provider.isBool())
|
||||||
return Utils::make_optional(RetType(provider.toBool()));
|
return Utils::make_optional(RetType(provider.toBool()));
|
||||||
@@ -67,15 +67,15 @@ Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> ServerCapabilitie
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ServerCapabilities::setHoverProvider(
|
void ServerCapabilities::setHoverProvider(
|
||||||
const Utils::variant<bool, WorkDoneProgressOptions> &hoverProvider)
|
const std::variant<bool, WorkDoneProgressOptions> &hoverProvider)
|
||||||
{
|
{
|
||||||
insertVariant<bool, WorkDoneProgressOptions>(hoverProviderKey, hoverProvider);
|
insertVariant<bool, WorkDoneProgressOptions>(hoverProviderKey, hoverProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::optional<Utils::variant<bool, ServerCapabilities::RegistrationOptions>>
|
Utils::optional<std::variant<bool, ServerCapabilities::RegistrationOptions>>
|
||||||
ServerCapabilities::typeDefinitionProvider() const
|
ServerCapabilities::typeDefinitionProvider() const
|
||||||
{
|
{
|
||||||
using RetType = Utils::variant<bool, ServerCapabilities::RegistrationOptions>;
|
using RetType = std::variant<bool, ServerCapabilities::RegistrationOptions>;
|
||||||
const QJsonValue &provider = value(typeDefinitionProviderKey);
|
const QJsonValue &provider = value(typeDefinitionProviderKey);
|
||||||
if (provider.isUndefined() || !(provider.isBool() || provider.isObject()))
|
if (provider.isUndefined() || !(provider.isBool() || provider.isObject()))
|
||||||
return Utils::nullopt;
|
return Utils::nullopt;
|
||||||
@@ -84,16 +84,16 @@ ServerCapabilities::typeDefinitionProvider() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ServerCapabilities::setTypeDefinitionProvider(
|
void ServerCapabilities::setTypeDefinitionProvider(
|
||||||
const Utils::variant<bool, ServerCapabilities::RegistrationOptions> &typeDefinitionProvider)
|
const std::variant<bool, ServerCapabilities::RegistrationOptions> &typeDefinitionProvider)
|
||||||
{
|
{
|
||||||
insertVariant<bool, ServerCapabilities::RegistrationOptions>(typeDefinitionProviderKey,
|
insertVariant<bool, ServerCapabilities::RegistrationOptions>(typeDefinitionProviderKey,
|
||||||
typeDefinitionProvider);
|
typeDefinitionProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::optional<Utils::variant<bool, ServerCapabilities::RegistrationOptions>>
|
Utils::optional<std::variant<bool, ServerCapabilities::RegistrationOptions>>
|
||||||
ServerCapabilities::implementationProvider() const
|
ServerCapabilities::implementationProvider() const
|
||||||
{
|
{
|
||||||
using RetType = Utils::variant<bool, ServerCapabilities::RegistrationOptions>;
|
using RetType = std::variant<bool, ServerCapabilities::RegistrationOptions>;
|
||||||
const QJsonValue &provider = value(implementationProviderKey);
|
const QJsonValue &provider = value(implementationProviderKey);
|
||||||
if (provider.isUndefined() || !(provider.isBool() || provider.isObject()))
|
if (provider.isUndefined() || !(provider.isBool() || provider.isObject()))
|
||||||
return Utils::nullopt;
|
return Utils::nullopt;
|
||||||
@@ -102,15 +102,15 @@ ServerCapabilities::implementationProvider() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ServerCapabilities::setImplementationProvider(
|
void ServerCapabilities::setImplementationProvider(
|
||||||
const Utils::variant<bool, ServerCapabilities::RegistrationOptions> &implementationProvider)
|
const std::variant<bool, ServerCapabilities::RegistrationOptions> &implementationProvider)
|
||||||
{
|
{
|
||||||
insertVariant<bool, RegistrationOptions>(implementationProviderKey, implementationProvider);
|
insertVariant<bool, RegistrationOptions>(implementationProviderKey, implementationProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>>
|
||||||
ServerCapabilities::referencesProvider() const
|
ServerCapabilities::referencesProvider() const
|
||||||
{
|
{
|
||||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
using RetType = std::variant<bool, WorkDoneProgressOptions>;
|
||||||
const QJsonValue &provider = value(referencesProviderKey);
|
const QJsonValue &provider = value(referencesProviderKey);
|
||||||
if (provider.isBool())
|
if (provider.isBool())
|
||||||
return Utils::make_optional(RetType(provider.toBool()));
|
return Utils::make_optional(RetType(provider.toBool()));
|
||||||
@@ -120,16 +120,16 @@ ServerCapabilities::referencesProvider() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ServerCapabilities::setReferencesProvider(
|
void ServerCapabilities::setReferencesProvider(
|
||||||
const Utils::variant<bool, WorkDoneProgressOptions> &referencesProvider)
|
const std::variant<bool, WorkDoneProgressOptions> &referencesProvider)
|
||||||
{
|
{
|
||||||
insertVariant<bool, WorkDoneProgressOptions>(referencesProviderKey,
|
insertVariant<bool, WorkDoneProgressOptions>(referencesProviderKey,
|
||||||
referencesProvider);
|
referencesProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>>
|
||||||
ServerCapabilities::documentHighlightProvider() const
|
ServerCapabilities::documentHighlightProvider() const
|
||||||
{
|
{
|
||||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
using RetType = std::variant<bool, WorkDoneProgressOptions>;
|
||||||
const QJsonValue &provider = value(documentHighlightProviderKey);
|
const QJsonValue &provider = value(documentHighlightProviderKey);
|
||||||
if (provider.isBool())
|
if (provider.isBool())
|
||||||
return Utils::make_optional(RetType(provider.toBool()));
|
return Utils::make_optional(RetType(provider.toBool()));
|
||||||
@@ -139,16 +139,16 @@ ServerCapabilities::documentHighlightProvider() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ServerCapabilities::setDocumentHighlightProvider(
|
void ServerCapabilities::setDocumentHighlightProvider(
|
||||||
const Utils::variant<bool, WorkDoneProgressOptions> &documentHighlightProvider)
|
const std::variant<bool, WorkDoneProgressOptions> &documentHighlightProvider)
|
||||||
{
|
{
|
||||||
insertVariant<bool, WorkDoneProgressOptions>(documentHighlightProviderKey,
|
insertVariant<bool, WorkDoneProgressOptions>(documentHighlightProviderKey,
|
||||||
documentHighlightProvider);
|
documentHighlightProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>>
|
||||||
ServerCapabilities::documentSymbolProvider() const
|
ServerCapabilities::documentSymbolProvider() const
|
||||||
{
|
{
|
||||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
using RetType = std::variant<bool, WorkDoneProgressOptions>;
|
||||||
const QJsonValue &provider = value(documentSymbolProviderKey);
|
const QJsonValue &provider = value(documentSymbolProviderKey);
|
||||||
if (provider.isBool())
|
if (provider.isBool())
|
||||||
return Utils::make_optional(RetType(provider.toBool()));
|
return Utils::make_optional(RetType(provider.toBool()));
|
||||||
@@ -158,7 +158,7 @@ ServerCapabilities::documentSymbolProvider() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ServerCapabilities::setDocumentSymbolProvider(
|
void ServerCapabilities::setDocumentSymbolProvider(
|
||||||
Utils::variant<bool, WorkDoneProgressOptions> documentSymbolProvider)
|
std::variant<bool, WorkDoneProgressOptions> documentSymbolProvider)
|
||||||
{
|
{
|
||||||
insertVariant<bool, WorkDoneProgressOptions>(documentSymbolProviderKey,
|
insertVariant<bool, WorkDoneProgressOptions>(documentSymbolProviderKey,
|
||||||
documentSymbolProvider);
|
documentSymbolProvider);
|
||||||
@@ -175,10 +175,10 @@ void ServerCapabilities::setSemanticTokensProvider(
|
|||||||
insert(semanticTokensProviderKey, semanticTokensProvider);
|
insert(semanticTokensProviderKey, semanticTokensProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>>
|
||||||
ServerCapabilities::workspaceSymbolProvider() const
|
ServerCapabilities::workspaceSymbolProvider() const
|
||||||
{
|
{
|
||||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
using RetType = std::variant<bool, WorkDoneProgressOptions>;
|
||||||
const QJsonValue &provider = value(workspaceSymbolProviderKey);
|
const QJsonValue &provider = value(workspaceSymbolProviderKey);
|
||||||
if (provider.isBool())
|
if (provider.isBool())
|
||||||
return Utils::make_optional(RetType(provider.toBool()));
|
return Utils::make_optional(RetType(provider.toBool()));
|
||||||
@@ -188,29 +188,29 @@ ServerCapabilities::workspaceSymbolProvider() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ServerCapabilities::setWorkspaceSymbolProvider(
|
void ServerCapabilities::setWorkspaceSymbolProvider(
|
||||||
Utils::variant<bool, WorkDoneProgressOptions> workspaceSymbolProvider)
|
std::variant<bool, WorkDoneProgressOptions> workspaceSymbolProvider)
|
||||||
{
|
{
|
||||||
insertVariant<bool, WorkDoneProgressOptions>(workspaceSymbolProviderKey,
|
insertVariant<bool, WorkDoneProgressOptions>(workspaceSymbolProviderKey,
|
||||||
workspaceSymbolProvider);
|
workspaceSymbolProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::optional<Utils::variant<bool, CodeActionOptions>> ServerCapabilities::codeActionProvider() const
|
Utils::optional<std::variant<bool, CodeActionOptions>> ServerCapabilities::codeActionProvider() const
|
||||||
{
|
{
|
||||||
const QJsonValue &provider = value(codeActionProviderKey);
|
const QJsonValue &provider = value(codeActionProviderKey);
|
||||||
if (provider.isBool())
|
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()) {
|
if (provider.isObject()) {
|
||||||
CodeActionOptions options(provider);
|
CodeActionOptions options(provider);
|
||||||
if (options.isValid())
|
if (options.isValid())
|
||||||
return Utils::make_optional(Utils::variant<bool, CodeActionOptions>(options));
|
return Utils::make_optional(std::variant<bool, CodeActionOptions>(options));
|
||||||
}
|
}
|
||||||
return Utils::nullopt;
|
return Utils::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>>
|
||||||
ServerCapabilities::documentFormattingProvider() const
|
ServerCapabilities::documentFormattingProvider() const
|
||||||
{
|
{
|
||||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
using RetType = std::variant<bool, WorkDoneProgressOptions>;
|
||||||
const QJsonValue &provider = value(documentFormattingProviderKey);
|
const QJsonValue &provider = value(documentFormattingProviderKey);
|
||||||
if (provider.isBool())
|
if (provider.isBool())
|
||||||
return Utils::make_optional(RetType(provider.toBool()));
|
return Utils::make_optional(RetType(provider.toBool()));
|
||||||
@@ -220,16 +220,16 @@ ServerCapabilities::documentFormattingProvider() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ServerCapabilities::setDocumentFormattingProvider(
|
void ServerCapabilities::setDocumentFormattingProvider(
|
||||||
const Utils::variant<bool, WorkDoneProgressOptions> &documentFormattingProvider)
|
const std::variant<bool, WorkDoneProgressOptions> &documentFormattingProvider)
|
||||||
{
|
{
|
||||||
insertVariant<bool, WorkDoneProgressOptions>(documentFormattingProviderKey,
|
insertVariant<bool, WorkDoneProgressOptions>(documentFormattingProviderKey,
|
||||||
documentFormattingProvider);
|
documentFormattingProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>>
|
||||||
ServerCapabilities::documentRangeFormattingProvider() const
|
ServerCapabilities::documentRangeFormattingProvider() const
|
||||||
{
|
{
|
||||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
using RetType = std::variant<bool, WorkDoneProgressOptions>;
|
||||||
const QJsonValue &provider = value(documentRangeFormattingProviderKey);
|
const QJsonValue &provider = value(documentRangeFormattingProviderKey);
|
||||||
if (provider.isBool())
|
if (provider.isBool())
|
||||||
return Utils::make_optional(RetType(provider.toBool()));
|
return Utils::make_optional(RetType(provider.toBool()));
|
||||||
@@ -239,15 +239,15 @@ ServerCapabilities::documentRangeFormattingProvider() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ServerCapabilities::setDocumentRangeFormattingProvider(
|
void ServerCapabilities::setDocumentRangeFormattingProvider(
|
||||||
Utils::variant<bool, WorkDoneProgressOptions> documentRangeFormattingProvider)
|
std::variant<bool, WorkDoneProgressOptions> documentRangeFormattingProvider)
|
||||||
{
|
{
|
||||||
insertVariant<bool, WorkDoneProgressOptions>(documentRangeFormattingProviderKey,
|
insertVariant<bool, WorkDoneProgressOptions>(documentRangeFormattingProviderKey,
|
||||||
documentRangeFormattingProvider);
|
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);
|
const QJsonValue &localValue = value(renameProviderKey);
|
||||||
if (localValue.isBool())
|
if (localValue.isBool())
|
||||||
return RetType(localValue.toBool());
|
return RetType(localValue.toBool());
|
||||||
@@ -256,14 +256,14 @@ Utils::optional<Utils::variant<ServerCapabilities::RenameOptions, bool>> ServerC
|
|||||||
return Utils::nullopt;
|
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);
|
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);
|
const QJsonValue &localValue = value(colorProviderKey);
|
||||||
if (localValue.isBool())
|
if (localValue.isBool())
|
||||||
return RetType(localValue.toBool());
|
return RetType(localValue.toBool());
|
||||||
@@ -272,15 +272,15 @@ Utils::optional<Utils::variant<bool, JsonObject>> ServerCapabilities::colorProvi
|
|||||||
return Utils::nullopt;
|
return Utils::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerCapabilities::setColorProvider(Utils::variant<bool, JsonObject> colorProvider)
|
void ServerCapabilities::setColorProvider(std::variant<bool, JsonObject> colorProvider)
|
||||||
{
|
{
|
||||||
insertVariant<bool, JsonObject>(renameProviderKey, colorProvider);
|
insertVariant<bool, JsonObject>(renameProviderKey, colorProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::optional<Utils::variant<QString, bool> >
|
Utils::optional<std::variant<QString, bool> >
|
||||||
ServerCapabilities::WorkspaceServerCapabilities::WorkspaceFoldersCapabilities::changeNotifications() const
|
ServerCapabilities::WorkspaceServerCapabilities::WorkspaceFoldersCapabilities::changeNotifications() const
|
||||||
{
|
{
|
||||||
using RetType = Utils::variant<QString, bool>;
|
using RetType = std::variant<QString, bool>;
|
||||||
const QJsonValue &change = value(changeNotificationsKey);
|
const QJsonValue &change = value(changeNotificationsKey);
|
||||||
if (change.isUndefined())
|
if (change.isUndefined())
|
||||||
return Utils::nullopt;
|
return Utils::nullopt;
|
||||||
@@ -289,7 +289,7 @@ ServerCapabilities::WorkspaceServerCapabilities::WorkspaceFoldersCapabilities::c
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ServerCapabilities::WorkspaceServerCapabilities::WorkspaceFoldersCapabilities::setChangeNotifications(
|
void ServerCapabilities::WorkspaceServerCapabilities::WorkspaceFoldersCapabilities::setChangeNotifications(
|
||||||
Utils::variant<QString, bool> changeNotifications)
|
std::variant<QString, bool> changeNotifications)
|
||||||
{
|
{
|
||||||
insertVariant<QString, bool>(changeNotificationsKey, changeNotifications);
|
insertVariant<QString, bool>(changeNotificationsKey, changeNotifications);
|
||||||
}
|
}
|
||||||
@@ -315,9 +315,9 @@ bool CodeActionOptions::isValid() const
|
|||||||
return WorkDoneProgressOptions::isValid() && contains(codeActionKindsKey);
|
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);
|
const QJsonValue &rangeOptions = value(rangeKey);
|
||||||
if (rangeOptions.isBool())
|
if (rangeOptions.isBool())
|
||||||
return RetType(rangeOptions.toBool());
|
return RetType(rangeOptions.toBool());
|
||||||
@@ -326,15 +326,15 @@ Utils::optional<Utils::variant<bool, QJsonObject>> SemanticTokensOptions::range(
|
|||||||
return Utils::nullopt;
|
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);
|
insertVariant<bool, QJsonObject>(rangeKey, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::optional<Utils::variant<bool, SemanticTokensOptions::FullSemanticTokenOptions>>
|
Utils::optional<std::variant<bool, SemanticTokensOptions::FullSemanticTokenOptions>>
|
||||||
SemanticTokensOptions::full() const
|
SemanticTokensOptions::full() const
|
||||||
{
|
{
|
||||||
using RetType = Utils::variant<bool, SemanticTokensOptions::FullSemanticTokenOptions>;
|
using RetType = std::variant<bool, SemanticTokensOptions::FullSemanticTokenOptions>;
|
||||||
const QJsonValue &fullOptions = value(fullKey);
|
const QJsonValue &fullOptions = value(fullKey);
|
||||||
if (fullOptions.isBool())
|
if (fullOptions.isBool())
|
||||||
return RetType(fullOptions.toBool());
|
return RetType(fullOptions.toBool());
|
||||||
@@ -344,7 +344,7 @@ SemanticTokensOptions::full() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SemanticTokensOptions::setFull(
|
void SemanticTokensOptions::setFull(
|
||||||
const Utils::variant<bool, SemanticTokensOptions::FullSemanticTokenOptions> &full)
|
const std::variant<bool, SemanticTokensOptions::FullSemanticTokenOptions> &full)
|
||||||
{
|
{
|
||||||
insertVariant<bool, FullSemanticTokenOptions>(fullKey, full);
|
insertVariant<bool, FullSemanticTokenOptions>(fullKey, full);
|
||||||
}
|
}
|
||||||
|
@@ -152,8 +152,8 @@ public:
|
|||||||
void setLegend(const SemanticTokensLegend &legend) { insert(legendKey, legend); }
|
void setLegend(const SemanticTokensLegend &legend) { insert(legendKey, legend); }
|
||||||
|
|
||||||
/// Server supports providing semantic tokens for a specific range of a document.
|
/// Server supports providing semantic tokens for a specific range of a document.
|
||||||
Utils::optional<Utils::variant<bool, QJsonObject>> range() const;
|
Utils::optional<std::variant<bool, QJsonObject>> range() const;
|
||||||
void setRange(const Utils::variant<bool, QJsonObject> &range);
|
void setRange(const std::variant<bool, QJsonObject> &range);
|
||||||
void clearRange() { remove(rangeKey); }
|
void clearRange() { remove(rangeKey); }
|
||||||
|
|
||||||
class FullSemanticTokenOptions : public JsonObject
|
class FullSemanticTokenOptions : public JsonObject
|
||||||
@@ -168,8 +168,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Server supports providing semantic tokens for a full document.
|
/// Server supports providing semantic tokens for a full document.
|
||||||
Utils::optional<Utils::variant<bool, FullSemanticTokenOptions>> full() const;
|
Utils::optional<std::variant<bool, FullSemanticTokenOptions>> full() const;
|
||||||
void setFull(const Utils::variant<bool, FullSemanticTokenOptions> &full);
|
void setFull(const std::variant<bool, FullSemanticTokenOptions> &full);
|
||||||
void clearFull() { remove(fullKey); }
|
void clearFull() { remove(fullKey); }
|
||||||
|
|
||||||
bool isValid() const override { return contains(legendKey); }
|
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
|
// Defines how text documents are synced. Is either a detailed structure defining each
|
||||||
// notification or for backwards compatibility the TextDocumentSyncKind number.
|
// 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;
|
Utils::optional<TextDocumentSync> textDocumentSync() const;
|
||||||
void setTextDocumentSync(const TextDocumentSync &textDocumentSync);
|
void setTextDocumentSync(const TextDocumentSync &textDocumentSync);
|
||||||
void clearTextDocumentSync() { remove(textDocumentSyncKey); }
|
void clearTextDocumentSync() { remove(textDocumentSyncKey); }
|
||||||
@@ -273,8 +273,8 @@ public:
|
|||||||
TextDocumentSyncKind textDocumentSyncKindHelper();
|
TextDocumentSyncKind textDocumentSyncKindHelper();
|
||||||
|
|
||||||
// The server provides hover support.
|
// The server provides hover support.
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> hoverProvider() const;
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> hoverProvider() const;
|
||||||
void setHoverProvider(const Utils::variant<bool, WorkDoneProgressOptions> &hoverProvider);
|
void setHoverProvider(const std::variant<bool, WorkDoneProgressOptions> &hoverProvider);
|
||||||
void clearHoverProvider() { remove(hoverProviderKey); }
|
void clearHoverProvider() { remove(hoverProviderKey); }
|
||||||
|
|
||||||
// The server provides completion support.
|
// The server provides completion support.
|
||||||
@@ -321,29 +321,29 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// The server provides Goto Type Definition support.
|
// The server provides Goto Type Definition support.
|
||||||
Utils::optional<Utils::variant<bool, RegistrationOptions>> typeDefinitionProvider() const;
|
Utils::optional<std::variant<bool, RegistrationOptions>> typeDefinitionProvider() const;
|
||||||
void setTypeDefinitionProvider(const Utils::variant<bool, RegistrationOptions> &typeDefinitionProvider);
|
void setTypeDefinitionProvider(const std::variant<bool, RegistrationOptions> &typeDefinitionProvider);
|
||||||
void clearTypeDefinitionProvider() { remove(typeDefinitionProviderKey); }
|
void clearTypeDefinitionProvider() { remove(typeDefinitionProviderKey); }
|
||||||
|
|
||||||
// The server provides Goto Implementation support.
|
// The server provides Goto Implementation support.
|
||||||
Utils::optional<Utils::variant<bool, RegistrationOptions>> implementationProvider() const;
|
Utils::optional<std::variant<bool, RegistrationOptions>> implementationProvider() const;
|
||||||
void setImplementationProvider(const Utils::variant<bool, RegistrationOptions> &implementationProvider);
|
void setImplementationProvider(const std::variant<bool, RegistrationOptions> &implementationProvider);
|
||||||
void clearImplementationProvider() { remove(implementationProviderKey); }
|
void clearImplementationProvider() { remove(implementationProviderKey); }
|
||||||
|
|
||||||
// The server provides find references support.
|
// The server provides find references support.
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> referencesProvider() const;
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> referencesProvider() const;
|
||||||
void setReferencesProvider(const Utils::variant<bool, WorkDoneProgressOptions> &referencesProvider);
|
void setReferencesProvider(const std::variant<bool, WorkDoneProgressOptions> &referencesProvider);
|
||||||
void clearReferencesProvider() { remove(referencesProviderKey); }
|
void clearReferencesProvider() { remove(referencesProviderKey); }
|
||||||
|
|
||||||
// The server provides document highlight support.
|
// The server provides document highlight support.
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> documentHighlightProvider() const;
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> documentHighlightProvider() const;
|
||||||
void setDocumentHighlightProvider(
|
void setDocumentHighlightProvider(
|
||||||
const Utils::variant<bool, WorkDoneProgressOptions> &documentHighlightProvider);
|
const std::variant<bool, WorkDoneProgressOptions> &documentHighlightProvider);
|
||||||
void clearDocumentHighlightProvider() { remove(documentHighlightProviderKey); }
|
void clearDocumentHighlightProvider() { remove(documentHighlightProviderKey); }
|
||||||
|
|
||||||
// The server provides document symbol support.
|
// The server provides document symbol support.
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> documentSymbolProvider() const;
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> documentSymbolProvider() const;
|
||||||
void setDocumentSymbolProvider(Utils::variant<bool, WorkDoneProgressOptions> documentSymbolProvider);
|
void setDocumentSymbolProvider(std::variant<bool, WorkDoneProgressOptions> documentSymbolProvider);
|
||||||
void clearDocumentSymbolProvider() { remove(documentSymbolProviderKey); }
|
void clearDocumentSymbolProvider() { remove(documentSymbolProviderKey); }
|
||||||
|
|
||||||
Utils::optional<SemanticTokensOptions> semanticTokensProvider() const;
|
Utils::optional<SemanticTokensOptions> semanticTokensProvider() const;
|
||||||
@@ -351,12 +351,12 @@ public:
|
|||||||
void clearSemanticTokensProvider() { remove(semanticTokensProviderKey); }
|
void clearSemanticTokensProvider() { remove(semanticTokensProviderKey); }
|
||||||
|
|
||||||
// The server provides workspace symbol support.
|
// The server provides workspace symbol support.
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> workspaceSymbolProvider() const;
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> workspaceSymbolProvider() const;
|
||||||
void setWorkspaceSymbolProvider(Utils::variant<bool, WorkDoneProgressOptions> workspaceSymbolProvider);
|
void setWorkspaceSymbolProvider(std::variant<bool, WorkDoneProgressOptions> workspaceSymbolProvider);
|
||||||
void clearWorkspaceSymbolProvider() { remove(workspaceSymbolProviderKey); }
|
void clearWorkspaceSymbolProvider() { remove(workspaceSymbolProviderKey); }
|
||||||
|
|
||||||
// The server provides code actions.
|
// 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)
|
void setCodeActionProvider(bool codeActionProvider)
|
||||||
{ insert(codeActionProviderKey, codeActionProvider); }
|
{ insert(codeActionProviderKey, codeActionProvider); }
|
||||||
void setCodeActionProvider(CodeActionOptions options)
|
void setCodeActionProvider(CodeActionOptions options)
|
||||||
@@ -371,14 +371,14 @@ public:
|
|||||||
void clearCodeLensProvider() { remove(codeLensProviderKey); }
|
void clearCodeLensProvider() { remove(codeLensProviderKey); }
|
||||||
|
|
||||||
// The server provides document formatting.
|
// The server provides document formatting.
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> documentFormattingProvider() const;
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> documentFormattingProvider() const;
|
||||||
void setDocumentFormattingProvider(
|
void setDocumentFormattingProvider(
|
||||||
const Utils::variant<bool, WorkDoneProgressOptions> &documentFormattingProvider);
|
const std::variant<bool, WorkDoneProgressOptions> &documentFormattingProvider);
|
||||||
void clearDocumentFormattingProvider() { remove(documentFormattingProviderKey); }
|
void clearDocumentFormattingProvider() { remove(documentFormattingProviderKey); }
|
||||||
|
|
||||||
// The server provides document formatting on typing.
|
// The server provides document formatting on typing.
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> documentRangeFormattingProvider() const;
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> documentRangeFormattingProvider() const;
|
||||||
void setDocumentRangeFormattingProvider(Utils::variant<bool, WorkDoneProgressOptions> documentRangeFormattingProvider);
|
void setDocumentRangeFormattingProvider(std::variant<bool, WorkDoneProgressOptions> documentRangeFormattingProvider);
|
||||||
void clearDocumentRangeFormattingProvider() { remove(documentRangeFormattingProviderKey); }
|
void clearDocumentRangeFormattingProvider() { remove(documentRangeFormattingProviderKey); }
|
||||||
|
|
||||||
class LANGUAGESERVERPROTOCOL_EXPORT RenameOptions : public WorkDoneProgressOptions
|
class LANGUAGESERVERPROTOCOL_EXPORT RenameOptions : public WorkDoneProgressOptions
|
||||||
@@ -393,8 +393,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// The server provides rename support.
|
// The server provides rename support.
|
||||||
Utils::optional<Utils::variant<RenameOptions, bool>> renameProvider() const;
|
Utils::optional<std::variant<RenameOptions, bool>> renameProvider() const;
|
||||||
void setRenameProvider(Utils::variant<RenameOptions,bool> renameProvider);
|
void setRenameProvider(std::variant<RenameOptions,bool> renameProvider);
|
||||||
void clearRenameProvider() { remove(renameProviderKey); }
|
void clearRenameProvider() { remove(renameProviderKey); }
|
||||||
|
|
||||||
// The server provides document link support.
|
// The server provides document link support.
|
||||||
@@ -405,8 +405,8 @@ public:
|
|||||||
void clearDocumentLinkProvider() { remove(documentLinkProviderKey); }
|
void clearDocumentLinkProvider() { remove(documentLinkProviderKey); }
|
||||||
|
|
||||||
// The server provides color provider support.
|
// The server provides color provider support.
|
||||||
Utils::optional<Utils::variant<bool, JsonObject>> colorProvider() const;
|
Utils::optional<std::variant<bool, JsonObject>> colorProvider() const;
|
||||||
void setColorProvider(Utils::variant<bool, JsonObject> colorProvider);
|
void setColorProvider(std::variant<bool, JsonObject> colorProvider);
|
||||||
void clearColorProvider() { remove(colorProviderKey); }
|
void clearColorProvider() { remove(colorProviderKey); }
|
||||||
|
|
||||||
// The server provides execute command support.
|
// The server provides execute command support.
|
||||||
@@ -431,8 +431,8 @@ public:
|
|||||||
void setSupported(bool supported) { insert(supportedKey, supported); }
|
void setSupported(bool supported) { insert(supportedKey, supported); }
|
||||||
void clearSupported() { remove(supportedKey); }
|
void clearSupported() { remove(supportedKey); }
|
||||||
|
|
||||||
Utils::optional<Utils::variant<QString, bool>> changeNotifications() const;
|
Utils::optional<std::variant<QString, bool>> changeNotifications() const;
|
||||||
void setChangeNotifications(Utils::variant<QString, bool> changeNotifications);
|
void setChangeNotifications(std::variant<QString, bool> changeNotifications);
|
||||||
void clearChangeNotifications() { remove(changeNotificationsKey); }
|
void clearChangeNotifications() { remove(changeNotificationsKey); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -86,10 +86,10 @@ ExecuteCommandParams::ExecuteCommandParams(const Command &command)
|
|||||||
|
|
||||||
LanguageServerProtocol::WorkSpaceFolderResult::operator const QJsonValue() const
|
LanguageServerProtocol::WorkSpaceFolderResult::operator const QJsonValue() const
|
||||||
{
|
{
|
||||||
if (!Utils::holds_alternative<QList<WorkSpaceFolder>>(*this))
|
if (!std::holds_alternative<QList<WorkSpaceFolder>>(*this))
|
||||||
return QJsonValue::Null;
|
return QJsonValue::Null;
|
||||||
QJsonArray array;
|
QJsonArray array;
|
||||||
for (const auto &folder : Utils::get<QList<WorkSpaceFolder>>(*this))
|
for (const auto &folder : std::get<QList<WorkSpaceFolder>>(*this))
|
||||||
array.append(QJsonValue(folder));
|
array.append(QJsonValue(folder));
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
namespace LanguageServerProtocol {
|
namespace LanguageServerProtocol {
|
||||||
|
|
||||||
class LANGUAGESERVERPROTOCOL_EXPORT WorkSpaceFolderResult
|
class LANGUAGESERVERPROTOCOL_EXPORT WorkSpaceFolderResult
|
||||||
: public Utils::variant<QList<WorkSpaceFolder>, std::nullptr_t>
|
: public std::variant<QList<WorkSpaceFolder>, std::nullptr_t>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using variant::variant;
|
using variant::variant;
|
||||||
|
@@ -60,7 +60,7 @@ struct ConvertArgValueToString {
|
|||||||
|
|
||||||
std::string Arg::value() const
|
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
|
# define NANOTRACESHARED_EXPORT Q_DECL_IMPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <utils/variant.h> // revert when macos minimum target is >= 10.14
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
#ifdef NANOTRACE_ENABLED
|
#ifdef NANOTRACE_ENABLED
|
||||||
|
|
||||||
#define NANOTRACE_INIT(process, thread, filepath) Nanotrace::init(process, thread, filepath)
|
#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
|
class NANOTRACESHARED_EXPORT Arg
|
||||||
{
|
{
|
||||||
public:
|
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);
|
Arg(const std::string &name, const SupportedType &val);
|
||||||
std::string name() const;
|
std::string name() const;
|
||||||
|
@@ -29,7 +29,8 @@
|
|||||||
|
|
||||||
#include <sqlitevalue.h>
|
#include <sqlitevalue.h>
|
||||||
#include <utils/smallstring.h>
|
#include <utils/smallstring.h>
|
||||||
#include <utils/variant.h>
|
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
namespace Sqlite {
|
namespace Sqlite {
|
||||||
|
|
||||||
@@ -179,7 +180,7 @@ public:
|
|||||||
GeneratedAlwaysStorage storage = {};
|
GeneratedAlwaysStorage storage = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
using Constraint = Utils::variant<Unique,
|
using Constraint = std::variant<Unique,
|
||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
ForeignKey,
|
ForeignKey,
|
||||||
NotNull,
|
NotNull,
|
||||||
|
@@ -294,7 +294,7 @@ private:
|
|||||||
ContraintsVisiter visiter{columnDefinitionString};
|
ContraintsVisiter visiter{columnDefinitionString};
|
||||||
|
|
||||||
for (const Constraint &constraint : column.constraints)
|
for (const Constraint &constraint : column.constraints)
|
||||||
Utils::visit(visiter, constraint);
|
std::visit(visiter, constraint);
|
||||||
|
|
||||||
columnDefinitionStrings.push_back(std::move(columnDefinitionString));
|
columnDefinitionStrings.push_back(std::move(columnDefinitionString));
|
||||||
}
|
}
|
||||||
@@ -303,7 +303,7 @@ private:
|
|||||||
Utils::SmallString columnDefinitionString;
|
Utils::SmallString columnDefinitionString;
|
||||||
|
|
||||||
TableContraintsVisiter visiter{columnDefinitionString};
|
TableContraintsVisiter visiter{columnDefinitionString};
|
||||||
Utils::visit(visiter, constraint);
|
std::visit(visiter, constraint);
|
||||||
|
|
||||||
columnDefinitionStrings.push_back(std::move(columnDefinitionString));
|
columnDefinitionStrings.push_back(std::move(columnDefinitionString));
|
||||||
}
|
}
|
||||||
|
@@ -201,8 +201,8 @@ public:
|
|||||||
return std::find_if(constraints.begin(),
|
return std::find_if(constraints.begin(),
|
||||||
constraints.end(),
|
constraints.end(),
|
||||||
[](const Constraint &constraint) {
|
[](const Constraint &constraint) {
|
||||||
return Utils::holds_alternative<Unique>(constraint)
|
return std::holds_alternative<Unique>(constraint)
|
||||||
|| Utils::holds_alternative<PrimaryKey>(constraint);
|
|| std::holds_alternative<PrimaryKey>(constraint);
|
||||||
})
|
})
|
||||||
!= constraints.end();
|
!= constraints.end();
|
||||||
}
|
}
|
||||||
|
@@ -29,11 +29,11 @@
|
|||||||
#include "sqliteexception.h"
|
#include "sqliteexception.h"
|
||||||
|
|
||||||
#include <utils/smallstring.h>
|
#include <utils/smallstring.h>
|
||||||
#include <utils/variant.h>
|
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
namespace Sqlite {
|
namespace Sqlite {
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ template<typename StringType, typename BlobType>
|
|||||||
class ValueBase
|
class ValueBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using VariantType = Utils::variant<NullValue, long long, double, StringType, BlobType>;
|
using VariantType = std::variant<NullValue, long long, double, StringType, BlobType>;
|
||||||
|
|
||||||
ValueBase() = default;
|
ValueBase() = default;
|
||||||
|
|
||||||
@@ -104,18 +104,18 @@ public:
|
|||||||
|
|
||||||
bool isNull() const { return value.index() == 0; }
|
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
|
Utils::SmallStringView toStringView() const
|
||||||
{
|
{
|
||||||
return Utils::get<int(ValueType::String)>(value);
|
return std::get<int(ValueType::String)>(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlobView toBlobView() const
|
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>) {
|
if constexpr (std::is_same_v<BlobType, Blob>) {
|
||||||
return {blob.bytes};
|
return {blob.bytes};
|
||||||
} else {
|
} else {
|
||||||
@@ -146,7 +146,7 @@ public:
|
|||||||
|
|
||||||
friend bool operator==(const ValueBase &first, long long second)
|
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;
|
return maybeInteger && *maybeInteger == second;
|
||||||
}
|
}
|
||||||
@@ -155,7 +155,7 @@ public:
|
|||||||
|
|
||||||
friend bool operator==(const ValueBase &first, double second)
|
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;
|
return maybeFloat && *maybeFloat == second;
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ public:
|
|||||||
|
|
||||||
friend bool operator==(const ValueBase &first, Utils::SmallStringView second)
|
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;
|
return maybeString && *maybeString == second;
|
||||||
}
|
}
|
||||||
@@ -190,7 +190,7 @@ public:
|
|||||||
|
|
||||||
friend bool operator==(const ValueBase &first, const QString &second)
|
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())};
|
return maybeString && second == QLatin1String{maybeString->data(), int(maybeString->size())};
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,7 @@ public:
|
|||||||
|
|
||||||
friend bool operator==(const ValueBase &first, BlobView second)
|
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;
|
return maybeBlob && *maybeBlob == second;
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,8 @@
|
|||||||
|
|
||||||
#include <sqlitevalue.h>
|
#include <sqlitevalue.h>
|
||||||
#include <utils/smallstringvector.h>
|
#include <utils/smallstringvector.h>
|
||||||
#include <utils/variant.h>
|
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
namespace Sqlite {
|
namespace Sqlite {
|
||||||
class TablePrimaryKey
|
class TablePrimaryKey
|
||||||
@@ -43,7 +44,7 @@ public:
|
|||||||
Utils::SmallStringVector columns;
|
Utils::SmallStringVector columns;
|
||||||
};
|
};
|
||||||
|
|
||||||
using TableConstraint = Utils::variant<TablePrimaryKey>;
|
using TableConstraint = std::variant<TablePrimaryKey>;
|
||||||
using TableConstraints = std::vector<TableConstraint>;
|
using TableConstraints = std::vector<TableConstraint>;
|
||||||
|
|
||||||
} // namespace Sqlite
|
} // namespace Sqlite
|
||||||
|
@@ -5,7 +5,6 @@ add_qtc_library(Utils
|
|||||||
Qt6Core5Compat
|
Qt6Core5Compat
|
||||||
SOURCES
|
SOURCES
|
||||||
../3rdparty/optional/optional.hpp
|
../3rdparty/optional/optional.hpp
|
||||||
../3rdparty/variant/variant.hpp
|
|
||||||
../3rdparty/span/span.hpp
|
../3rdparty/span/span.hpp
|
||||||
QtConcurrentTools
|
QtConcurrentTools
|
||||||
algorithm.h
|
algorithm.h
|
||||||
@@ -182,7 +181,6 @@ add_qtc_library(Utils
|
|||||||
utils_global.h
|
utils_global.h
|
||||||
utilsicons.cpp utilsicons.h
|
utilsicons.cpp utilsicons.h
|
||||||
variablechooser.cpp variablechooser.h
|
variablechooser.cpp variablechooser.h
|
||||||
variant.h
|
|
||||||
winutils.cpp winutils.h
|
winutils.cpp winutils.h
|
||||||
wizard.cpp wizard.h
|
wizard.cpp wizard.h
|
||||||
wizardpage.cpp wizardpage.h
|
wizardpage.cpp wizardpage.h
|
||||||
|
@@ -30,7 +30,6 @@
|
|||||||
#include <utils/mimeutils.h>
|
#include <utils/mimeutils.h>
|
||||||
#include <utils/optional.h>
|
#include <utils/optional.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/variant.h>
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
@@ -43,6 +42,8 @@
|
|||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
Q_LOGGING_CATEGORY(fileIconProvider, "qtc.core.fileiconprovider", QtWarningMsg)
|
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.
|
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 Utils {
|
||||||
namespace FileIconProvider {
|
namespace FileIconProvider {
|
||||||
@@ -75,10 +76,10 @@ static Utils::optional<QIcon> getIcon(QHash<QString, Item> &cache, const QString
|
|||||||
auto it = cache.constFind(key);
|
auto it = cache.constFind(key);
|
||||||
if (it == cache.constEnd())
|
if (it == cache.constEnd())
|
||||||
return {};
|
return {};
|
||||||
if (const QIcon *icon = Utils::get_if<QIcon>(&*it))
|
if (const QIcon *icon = std::get_if<QIcon>(&*it))
|
||||||
return *icon;
|
return *icon;
|
||||||
// need to create icon from file name first
|
// 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 {});
|
QTC_ASSERT(fileName, return {});
|
||||||
const QIcon icon = QIcon(
|
const QIcon icon = QIcon(
|
||||||
FileIconProvider::overlayIcon(QStyle::SP_FileIcon, QIcon(*fileName), QSize(16, 16)));
|
FileIconProvider::overlayIcon(QStyle::SP_FileIcon, QIcon(*fileName), QSize(16, 16)));
|
||||||
|
@@ -327,8 +327,6 @@ Project {
|
|||||||
"utilsicons.cpp",
|
"utilsicons.cpp",
|
||||||
"variablechooser.cpp",
|
"variablechooser.cpp",
|
||||||
"variablechooser.h",
|
"variablechooser.h",
|
||||||
"variant.h",
|
|
||||||
"../3rdparty/variant/variant.hpp",
|
|
||||||
"winutils.cpp",
|
"winutils.cpp",
|
||||||
"winutils.h",
|
"winutils.h",
|
||||||
"wizard.cpp",
|
"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/fileutils.h>
|
||||||
#include <utils/optional.h>
|
#include <utils/optional.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/variant.h>
|
|
||||||
|
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
Q_LOGGING_CATEGORY(avdOutputParserLog, "qtc.android.avdOutputParser", QtWarningMsg)
|
Q_LOGGING_CATEGORY(avdOutputParserLog, "qtc.android.avdOutputParser", QtWarningMsg)
|
||||||
}
|
}
|
||||||
@@ -113,7 +114,7 @@ AndroidDeviceInfoList parseAvdList(const QString &output, QStringList *avdErrorP
|
|||||||
AndroidDeviceInfoList avdList;
|
AndroidDeviceInfoList avdList;
|
||||||
QStringList avdInfo;
|
QStringList avdInfo;
|
||||||
using ErrorPath = QString;
|
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) {
|
const auto parseAvdInfo = [](const QStringList &avdInfo) {
|
||||||
if (!avdInfo.filter(avdManufacturerError).isEmpty()) {
|
if (!avdInfo.filter(avdManufacturerError).isEmpty()) {
|
||||||
for (const QString &line : avdInfo) {
|
for (const QString &line : avdInfo) {
|
||||||
@@ -138,9 +139,9 @@ AndroidDeviceInfoList parseAvdList(const QString &output, QStringList *avdErrorP
|
|||||||
for (const QString &line : lines) {
|
for (const QString &line : lines) {
|
||||||
if (line.startsWith("---------") || line.isEmpty()) {
|
if (line.startsWith("---------") || line.isEmpty()) {
|
||||||
const AvdResult result = parseAvdInfo(avdInfo);
|
const AvdResult result = parseAvdInfo(avdInfo);
|
||||||
if (auto info = Utils::get_if<AndroidDeviceInfo>(&result))
|
if (auto info = std::get_if<AndroidDeviceInfo>(&result))
|
||||||
avdList << *info;
|
avdList << *info;
|
||||||
else if (auto errorPath = Utils::get_if<ErrorPath>(&result))
|
else if (auto errorPath = std::get_if<ErrorPath>(&result))
|
||||||
*avdErrorPaths << *errorPath;
|
*avdErrorPaths << *errorPath;
|
||||||
avdInfo.clear();
|
avdInfo.clear();
|
||||||
} else {
|
} else {
|
||||||
|
@@ -411,7 +411,7 @@ ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir)
|
|||||||
|
|
||||||
connect(this, &Client::workDone, this,
|
connect(this, &Client::workDone, this,
|
||||||
[this, p = QPointer(project)](const ProgressToken &token) {
|
[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()) {
|
if (val && *val == indexingToken()) {
|
||||||
d->isFullyIndexed = true;
|
d->isFullyIndexed = true;
|
||||||
emit indexingFinished();
|
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
|
// We know that there's only one kind of diagnostic for which clangd has
|
||||||
// a quickfix tweak, so let's not be wasteful.
|
// a quickfix tweak, so let's not be wasteful.
|
||||||
const Diagnostic::Code code = diagnostic.code().value_or(Diagnostic::Code());
|
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")
|
if (codeString && *codeString == "-Wswitch")
|
||||||
requestCodeActions(uri, diagnostic);
|
requestCodeActions(uri, diagnostic);
|
||||||
}
|
}
|
||||||
@@ -577,7 +577,7 @@ class ClangdDiagnosticManager : public LanguageClient::DiagnosticManager
|
|||||||
{
|
{
|
||||||
return Utils::filtered(diagnostics, [](const Diagnostic &diag){
|
return Utils::filtered(diagnostics, [](const Diagnostic &diag){
|
||||||
const Diagnostic::Code code = diag.code().value_or(Diagnostic::Code());
|
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";
|
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
|
// According to the documentation, we should receive a single
|
||||||
// object here, but it's a list. No idea what it means if there's
|
// object here, but it's a list. No idea what it means if there's
|
||||||
// more than one entry. We choose the first one.
|
// 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()) {
|
if (!list || list->isEmpty()) {
|
||||||
handler({}, {}, reqId);
|
handler({}, {}, reqId);
|
||||||
return;
|
return;
|
||||||
@@ -922,9 +922,9 @@ void ClangdClient::gatherHelpItemForTooltip(const HoverRequest::Response &hoverR
|
|||||||
const DocumentUri &uri)
|
const DocumentUri &uri)
|
||||||
{
|
{
|
||||||
if (const Utils::optional<HoverResult> result = hoverResponse.result()) {
|
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 HoverContent content = hover->content();
|
||||||
const MarkupContent *const markup = Utils::get_if<MarkupContent>(&content);
|
const MarkupContent *const markup = std::get_if<MarkupContent>(&content);
|
||||||
if (markup) {
|
if (markup) {
|
||||||
const QString markupString = markup->content();
|
const QString markupString = markup->content();
|
||||||
|
|
||||||
@@ -964,7 +964,7 @@ void ClangdClient::gatherHelpItemForTooltip(const HoverRequest::Response &hoverR
|
|||||||
const MessageId id = hoverResponse.id();
|
const MessageId id = hoverResponse.id();
|
||||||
Range range;
|
Range range;
|
||||||
if (const Utils::optional<HoverResult> result = hoverResponse.result()) {
|
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());
|
range = hover->range().value_or(Range());
|
||||||
}
|
}
|
||||||
const ClangdAstPath path = getAstPath(ast, range);
|
const ClangdAstPath path = getAstPath(ast, range);
|
||||||
@@ -1340,10 +1340,10 @@ MessageId ClangdClient::Private::getAndHandleAst(const TextDocOrFile &doc,
|
|||||||
const AstHandler &astHandler,
|
const AstHandler &astHandler,
|
||||||
AstCallbackMode callbackMode, const Range &range)
|
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 TextDocument * const textDoc = textDocPtr ? *textDocPtr : nullptr;
|
||||||
const Utils::FilePath filePath = textDoc ? textDoc->filePath()
|
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,
|
// If the entire AST is requested and the document's AST is in the cache and it is up to date,
|
||||||
// call the handler.
|
// call the handler.
|
||||||
|
@@ -110,7 +110,7 @@ public:
|
|||||||
Utils::optional<bool> hasVirtualFunctionAt(TextEditor::TextDocument *doc, int revision,
|
Utils::optional<bool> hasVirtualFunctionAt(TextEditor::TextDocument *doc, int revision,
|
||||||
const LanguageServerProtocol::Range &range);
|
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,
|
using AstHandler = std::function<void(const ClangdAstNode &ast,
|
||||||
const LanguageServerProtocol::MessageId &)>;
|
const LanguageServerProtocol::MessageId &)>;
|
||||||
enum class AstCallbackMode { SyncIfPossible, AlwaysAsync };
|
enum class AstCallbackMode { SyncIfPossible, AlwaysAsync };
|
||||||
|
@@ -362,10 +362,10 @@ ClangdCompletionItem::SpecialQtType ClangdCompletionItem::getQtType(const Comple
|
|||||||
if (!doc)
|
if (!doc)
|
||||||
return SpecialQtType::None;
|
return SpecialQtType::None;
|
||||||
QString docText;
|
QString docText;
|
||||||
if (Utils::holds_alternative<QString>(*doc))
|
if (std::holds_alternative<QString>(*doc))
|
||||||
docText = Utils::get<QString>(*doc);
|
docText = std::get<QString>(*doc);
|
||||||
else if (Utils::holds_alternative<MarkupContent>(*doc))
|
else if (std::holds_alternative<MarkupContent>(*doc))
|
||||||
docText = Utils::get<MarkupContent>(*doc).content();
|
docText = std::get<MarkupContent>(*doc).content();
|
||||||
if (docText.contains("Annotation: qt_signal"))
|
if (docText.contains("Annotation: qt_signal"))
|
||||||
return SpecialQtType::Signal;
|
return SpecialQtType::Signal;
|
||||||
if (docText.contains("Annotation: qt_slot"))
|
if (docText.contains("Annotation: qt_slot"))
|
||||||
|
@@ -399,9 +399,9 @@ void ClangdFollowSymbol::Private::handleGotoImplementationResult(
|
|||||||
{
|
{
|
||||||
if (const optional<GotoResult> &result = response.result()) {
|
if (const optional<GotoResult> &result = response.result()) {
|
||||||
QList<Link> newLinks;
|
QList<Link> newLinks;
|
||||||
if (const auto ploc = get_if<Location>(&*result))
|
if (const auto ploc = std::get_if<Location>(&*result))
|
||||||
newLinks = {ploc->toLink()};
|
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);
|
newLinks = transform(*plloc, &Location::toLink);
|
||||||
for (const Link &link : qAsConst(newLinks)) {
|
for (const Link &link : qAsConst(newLinks)) {
|
||||||
if (!allLinks.contains(link)) {
|
if (!allLinks.contains(link)) {
|
||||||
@@ -475,9 +475,9 @@ void ClangdFollowSymbol::Private::handleGotoImplementationResult(
|
|||||||
Link newLink;
|
Link newLink;
|
||||||
if (optional<GotoResult> _result = response.result()) {
|
if (optional<GotoResult> _result = response.result()) {
|
||||||
const GotoResult result = _result.value();
|
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();
|
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())
|
if (!plloc->isEmpty())
|
||||||
newLink = plloc->value(0).toLink();
|
newLink = plloc->value(0).toLink();
|
||||||
}
|
}
|
||||||
|
@@ -85,20 +85,20 @@ private:
|
|||||||
TextEditor::GenericProposal *handleCodeActionResult(const CodeActionResult &result) override
|
TextEditor::GenericProposal *handleCodeActionResult(const CodeActionResult &result) override
|
||||||
{
|
{
|
||||||
auto toOperation =
|
auto toOperation =
|
||||||
[=](const Utils::variant<Command, CodeAction> &item) -> QuickFixOperation * {
|
[=](const std::variant<Command, CodeAction> &item) -> QuickFixOperation * {
|
||||||
if (auto action = Utils::get_if<CodeAction>(&item)) {
|
if (auto action = std::get_if<CodeAction>(&item)) {
|
||||||
const Utils::optional<QList<Diagnostic>> diagnostics = action->diagnostics();
|
const Utils::optional<QList<Diagnostic>> diagnostics = action->diagnostics();
|
||||||
if (!diagnostics.has_value() || diagnostics->isEmpty())
|
if (!diagnostics.has_value() || diagnostics->isEmpty())
|
||||||
return new CodeActionQuickFixOperation(*action, client());
|
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 new CommandQuickFixOperation(*command, client());
|
||||||
return nullptr;
|
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;
|
QuickFixOperations ops;
|
||||||
for (const Utils::variant<Command, CodeAction> &item : *list) {
|
for (const std::variant<Command, CodeAction> &item : *list) {
|
||||||
if (QuickFixOperation *op = toOperation(item)) {
|
if (QuickFixOperation *op = toOperation(item)) {
|
||||||
op->setDescription("clangd: " + op->description());
|
op->setDescription("clangd: " + op->description());
|
||||||
ops << op;
|
ops << op;
|
||||||
|
@@ -152,7 +152,7 @@ QTextCursor ClangdSwitchDeclDef::Private::cursorForFunctionName(const ClangdAstN
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(docSymbols, return {});
|
QTC_ASSERT(docSymbols, return {});
|
||||||
|
|
||||||
const auto symbolList = Utils::get_if<QList<DocumentSymbol>>(&*docSymbols);
|
const auto symbolList = std::get_if<QList<DocumentSymbol>>(&*docSymbols);
|
||||||
if (!symbolList)
|
if (!symbolList)
|
||||||
return {};
|
return {};
|
||||||
const Range &astRange = functionNode.range();
|
const Range &astRange = functionNode.range();
|
||||||
|
@@ -233,7 +233,7 @@ ClangDiagnostic convertDiagnostic(const ClangdDiagnostic &src, const FilePath &f
|
|||||||
if (src.severity())
|
if (src.severity())
|
||||||
target.severity = convertSeverity(*src.severity());
|
target.severity = convertSeverity(*src.severity());
|
||||||
const Diagnostic::Code code = src.code().value_or(Diagnostic::Code());
|
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"))
|
if (codeString && codeString->startsWith("-W"))
|
||||||
target.enableOption = *codeString;
|
target.enableOption = *codeString;
|
||||||
for (const CodeAction &codeAction : src.codeActions().value_or(QList<CodeAction>())) {
|
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
|
void insertCodeSnippet(int pos, const QString &text, const SnippetParser &parser) override
|
||||||
{
|
{
|
||||||
const auto parseResult = parser(text);
|
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())
|
if (!snippet->parts.isEmpty())
|
||||||
textCursorAt(pos).insertText(snippet->parts.first().text);
|
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);
|
connect(m_runControl, &RunControl::stopped, this, &ClangTool::onRunControlStopped);
|
||||||
|
|
||||||
// Run worker
|
// Run worker
|
||||||
const bool preventBuild = holds_alternative<FilePath>(fileSelection)
|
const bool preventBuild = std::holds_alternative<FilePath>(fileSelection)
|
||||||
|| get<FileSelectionType>(fileSelection)
|
|| std::get<FileSelectionType>(fileSelection)
|
||||||
== FileSelectionType::CurrentFile;
|
== FileSelectionType::CurrentFile;
|
||||||
const bool buildBeforeAnalysis = !preventBuild && runSettings.buildBeforeAnalysis();
|
const bool buildBeforeAnalysis = !preventBuild && runSettings.buildBeforeAnalysis();
|
||||||
m_runWorker = new ClangToolRunWorker(m_runControl,
|
m_runWorker = new ClangToolRunWorker(m_runControl,
|
||||||
@@ -730,7 +730,7 @@ Diagnostics ClangTool::read(OutputFileFormat outputFileFormat,
|
|||||||
|
|
||||||
FileInfos ClangTool::collectFileInfos(Project *project, FileSelection fileSelection)
|
FileInfos ClangTool::collectFileInfos(Project *project, FileSelection fileSelection)
|
||||||
{
|
{
|
||||||
FileSelectionType *selectionType = get_if<FileSelectionType>(&fileSelection);
|
FileSelectionType *selectionType = std::get_if<FileSelectionType>(&fileSelection);
|
||||||
// early bailout
|
// early bailout
|
||||||
if (selectionType && *selectionType == FileSelectionType::CurrentFile
|
if (selectionType && *selectionType == FileSelectionType::CurrentFile
|
||||||
&& !EditorManager::currentDocument()) {
|
&& !EditorManager::currentDocument()) {
|
||||||
@@ -759,8 +759,8 @@ FileInfos ClangTool::collectFileInfos(Project *project, FileSelection fileSelect
|
|||||||
return dialog.fileInfos();
|
return dialog.fileInfos();
|
||||||
}
|
}
|
||||||
|
|
||||||
const FilePath filePath = holds_alternative<FilePath>(fileSelection)
|
const FilePath filePath = std::holds_alternative<FilePath>(fileSelection)
|
||||||
? get<FilePath>(fileSelection)
|
? std::get<FilePath>(fileSelection)
|
||||||
: EditorManager::currentDocument()->filePath(); // see early bailout
|
: EditorManager::currentDocument()->filePath(); // see early bailout
|
||||||
if (!filePath.isEmpty()) {
|
if (!filePath.isEmpty()) {
|
||||||
const FileInfo fileInfo = Utils::findOrDefault(allFileInfos, [&](const FileInfo &fi) {
|
const FileInfo fileInfo = Utils::findOrDefault(allFileInfos, [&](const FileInfo &fi) {
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
#include <cppeditor/projectinfo.h>
|
#include <cppeditor/projectinfo.h>
|
||||||
|
|
||||||
#include <utils/variant.h>
|
#include <variant>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QFrame;
|
class QFrame;
|
||||||
@@ -87,7 +87,7 @@ public:
|
|||||||
AskUser,
|
AskUser,
|
||||||
};
|
};
|
||||||
|
|
||||||
using FileSelection = Utils::variant<FileSelectionType, Utils::FilePath>;
|
using FileSelection = std::variant<FileSelectionType, Utils::FilePath>;
|
||||||
|
|
||||||
void startTool(FileSelection fileSelection);
|
void startTool(FileSelection fileSelection);
|
||||||
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
|
} else if (Utils::optional<ServerCapabilities::TextDocumentSync> _sync
|
||||||
= d->m_serverCapabilities.textDocumentSync()) {
|
= 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))
|
if (!options->openClose().value_or(true))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -791,11 +791,11 @@ void ClientPrivate::requestDocumentHighlightsNow(TextEditor::TextEditorWidget *w
|
|||||||
if (!option.filterApplies(widget->textDocument()->filePath()))
|
if (!option.filterApplies(widget->textDocument()->filePath()))
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> provider
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> provider
|
||||||
= m_serverCapabilities.documentHighlightProvider();
|
= m_serverCapabilities.documentHighlightProvider();
|
||||||
if (!provider.has_value())
|
if (!provider.has_value())
|
||||||
return;
|
return;
|
||||||
if (Utils::holds_alternative<bool>(*provider) && !Utils::get<bool>(*provider))
|
if (std::holds_alternative<bool>(*provider) && !std::get<bool>(*provider))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -819,7 +819,7 @@ void ClientPrivate::requestDocumentHighlightsNow(TextEditor::TextEditorWidget *w
|
|||||||
const Id &id = TextEditor::TextEditorWidget::CodeSemanticsSelection;
|
const Id &id = TextEditor::TextEditorWidget::CodeSemanticsSelection;
|
||||||
QList<QTextEdit::ExtraSelection> selections;
|
QList<QTextEdit::ExtraSelection> selections;
|
||||||
const Utils::optional<DocumentHighlightsResult> &result = response.result();
|
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);
|
widget->setExtraSelections(id, selections);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -827,7 +827,7 @@ void ClientPrivate::requestDocumentHighlightsNow(TextEditor::TextEditorWidget *w
|
|||||||
const QTextCharFormat &format =
|
const QTextCharFormat &format =
|
||||||
widget->textDocument()->fontSettings().toTextCharFormat(TextEditor::C_OCCURRENCES);
|
widget->textDocument()->fontSettings().toTextCharFormat(TextEditor::C_OCCURRENCES);
|
||||||
QTextDocument *document = widget->document();
|
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};
|
QTextEdit::ExtraSelection selection{widget->textCursor(), format};
|
||||||
const int &start = highlight.range().start().toPositionInDocument(document);
|
const int &start = highlight.range().start().toPositionInDocument(document);
|
||||||
const int &end = highlight.range().end().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
|
} else if (Utils::optional<ServerCapabilities::TextDocumentSync> _sync
|
||||||
= d->m_serverCapabilities.textDocumentSync()) {
|
= 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())
|
if (Utils::optional<SaveOptions> saveOptions = options->save())
|
||||||
includeText = saveOptions->includeText().value_or(includeText);
|
includeText = saveOptions->includeText().value_or(includeText);
|
||||||
}
|
}
|
||||||
@@ -1047,7 +1047,7 @@ void Client::documentWillSave(Core::IDocument *document)
|
|||||||
}
|
}
|
||||||
} else if (Utils::optional<ServerCapabilities::TextDocumentSync> _sync
|
} else if (Utils::optional<ServerCapabilities::TextDocumentSync> _sync
|
||||||
= d->m_serverCapabilities.textDocumentSync()) {
|
= 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);
|
send = options->willSave().value_or(send);
|
||||||
}
|
}
|
||||||
if (!send)
|
if (!send)
|
||||||
@@ -1285,9 +1285,9 @@ void Client::requestCodeActions(const CodeActionRequest &request)
|
|||||||
if (option.isValid() && !option.filterApplies(fileName))
|
if (option.isValid() && !option.filterApplies(fileName))
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
Utils::variant<bool, CodeActionOptions> provider
|
std::variant<bool, CodeActionOptions> provider
|
||||||
= d->m_serverCapabilities.codeActionProvider().value_or(false);
|
= 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1300,12 +1300,12 @@ void Client::handleCodeActionResponse(const CodeActionRequest::Response &respons
|
|||||||
if (const Utils::optional<CodeActionRequest::Response::Error> &error = response.error())
|
if (const Utils::optional<CodeActionRequest::Response::Error> &error = response.error())
|
||||||
log(*error);
|
log(*error);
|
||||||
if (const Utils::optional<CodeActionResult> &result = response.result()) {
|
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;
|
QList<CodeAction> codeActions;
|
||||||
for (const Utils::variant<Command, CodeAction> &item : *list) {
|
for (const std::variant<Command, CodeAction> &item : *list) {
|
||||||
if (auto action = Utils::get_if<CodeAction>(&item))
|
if (auto action = std::get_if<CodeAction>(&item))
|
||||||
codeActions << *action;
|
codeActions << *action;
|
||||||
else if (auto command = Utils::get_if<Command>(&item))
|
else if (auto command = std::get_if<Command>(&item))
|
||||||
Q_UNUSED(command) // todo
|
Q_UNUSED(command) // todo
|
||||||
}
|
}
|
||||||
updateCodeActionRefactoringMarker(this, codeActions, uri);
|
updateCodeActionRefactoringMarker(this, codeActions, uri);
|
||||||
@@ -1506,12 +1506,12 @@ bool Client::supportsDocumentSymbols(const TextEditor::TextDocument *doc) const
|
|||||||
return !options.isValid()
|
return !options.isValid()
|
||||||
|| options.filterApplies(doc->filePath(), Utils::mimeTypeForName(doc->mimeType()));
|
|| 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();
|
= capabilities().documentSymbolProvider();
|
||||||
if (!provider.has_value())
|
if (!provider.has_value())
|
||||||
return false;
|
return false;
|
||||||
if (Utils::holds_alternative<bool>(*provider))
|
if (std::holds_alternative<bool>(*provider))
|
||||||
return Utils::get<bool>(*provider);
|
return std::get<bool>(*provider);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1998,11 +1998,11 @@ void ClientPrivate::initializeCallback(const InitializeRequest::Response &initRe
|
|||||||
qCDebug(LOGLSPCLIENT) << "language server " << m_displayName << " initialized";
|
qCDebug(LOGLSPCLIENT) << "language server " << m_displayName << " initialized";
|
||||||
m_state = Client::Initialized;
|
m_state = Client::Initialized;
|
||||||
q->sendMessage(InitializeNotification(InitializedParams()));
|
q->sendMessage(InitializeNotification(InitializedParams()));
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> documentSymbolProvider
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> documentSymbolProvider
|
||||||
= q->capabilities().documentSymbolProvider();
|
= q->capabilities().documentSymbolProvider();
|
||||||
if (documentSymbolProvider.has_value()) {
|
if (documentSymbolProvider.has_value()) {
|
||||||
if (!Utils::holds_alternative<bool>(*documentSymbolProvider)
|
if (!std::holds_alternative<bool>(*documentSymbolProvider)
|
||||||
|| Utils::get<bool>(*documentSymbolProvider)) {
|
|| std::get<bool>(*documentSymbolProvider)) {
|
||||||
TextEditor::IOutlineWidgetFactory::updateOutline();
|
TextEditor::IOutlineWidgetFactory::updateOutline();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2044,8 +2044,9 @@ bool ClientPrivate::sendWorkspceFolderChanges() const
|
|||||||
if (folder->supported().value_or(false)) {
|
if (folder->supported().value_or(false)) {
|
||||||
// holds either the Id for deregistration or whether it is registered
|
// holds either the Id for deregistration or whether it is registered
|
||||||
auto notification = folder->changeNotifications().value_or(false);
|
auto notification = folder->changeNotifications().value_or(false);
|
||||||
return holds_alternative<QString>(notification)
|
return std::holds_alternative<QString>(notification)
|
||||||
|| (holds_alternative<bool>(notification) && get<bool>(notification));
|
|| (std::holds_alternative<bool>(notification)
|
||||||
|
&& std::get<bool>(notification));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -144,11 +144,11 @@ QString LanguageClientCompletionItem::detail() const
|
|||||||
if (auto _doc = m_item.documentation()) {
|
if (auto _doc = m_item.documentation()) {
|
||||||
auto doc = *_doc;
|
auto doc = *_doc;
|
||||||
QString detailDocText;
|
QString detailDocText;
|
||||||
if (Utils::holds_alternative<QString>(doc)) {
|
if (std::holds_alternative<QString>(doc)) {
|
||||||
detailDocText = Utils::get<QString>(doc);
|
detailDocText = std::get<QString>(doc);
|
||||||
} else if (Utils::holds_alternative<MarkupContent>(doc)) {
|
} else if (std::holds_alternative<MarkupContent>(doc)) {
|
||||||
// TODO markdown parser?
|
// TODO markdown parser?
|
||||||
detailDocText = Utils::get<MarkupContent>(doc).content();
|
detailDocText = std::get<MarkupContent>(doc).content();
|
||||||
}
|
}
|
||||||
if (!detailDocText.isEmpty())
|
if (!detailDocText.isEmpty())
|
||||||
return detailDocText;
|
return detailDocText;
|
||||||
@@ -425,18 +425,18 @@ void LanguageClientCompletionAssistProcessor::handleCompletionResponse(
|
|||||||
m_client->log(*error);
|
m_client->log(*error);
|
||||||
|
|
||||||
const Utils::optional<CompletionResult> &result = response.result();
|
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);
|
setAsyncProposalAvailable(nullptr);
|
||||||
m_client->removeAssistProcessor(this);
|
m_client->removeAssistProcessor(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<CompletionItem> items;
|
QList<CompletionItem> items;
|
||||||
if (Utils::holds_alternative<CompletionList>(*result)) {
|
if (std::holds_alternative<CompletionList>(*result)) {
|
||||||
const auto &list = Utils::get<CompletionList>(*result);
|
const auto &list = std::get<CompletionList>(*result);
|
||||||
items = list.items().value_or(QList<CompletionItem>());
|
items = list.items().value_or(QList<CompletionItem>());
|
||||||
} else if (Utils::holds_alternative<QList<CompletionItem>>(*result)) {
|
} else if (std::holds_alternative<QList<CompletionItem>>(*result)) {
|
||||||
items = Utils::get<QList<CompletionItem>>(*result);
|
items = std::get<QList<CompletionItem>>(*result);
|
||||||
}
|
}
|
||||||
auto proposalItems = generateCompletionItems(items);
|
auto proposalItems = generateCompletionItems(items);
|
||||||
if (!m_snippetsGroup.isEmpty()) {
|
if (!m_snippetsGroup.isEmpty()) {
|
||||||
|
@@ -86,11 +86,11 @@ QFutureWatcher<ChangeSet> *LanguageClientFormatter::format(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> &provider
|
const Utils::optional<std::variant<bool, WorkDoneProgressOptions>> &provider
|
||||||
= m_client->capabilities().documentRangeFormattingProvider();
|
= m_client->capabilities().documentRangeFormattingProvider();
|
||||||
if (!provider.has_value())
|
if (!provider.has_value())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (Utils::holds_alternative<bool>(*provider) && !Utils::get<bool>(*provider))
|
if (std::holds_alternative<bool>(*provider) && !std::get<bool>(*provider))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
DocumentRangeFormattingParams params;
|
DocumentRangeFormattingParams params;
|
||||||
|
@@ -66,7 +66,7 @@ void HoverHandler::setHelpItem(const LanguageServerProtocol::MessageId &msgId,
|
|||||||
{
|
{
|
||||||
if (msgId == m_response.id()) {
|
if (msgId == m_response.id()) {
|
||||||
if (Utils::optional<HoverResult> result = m_response.result()) {
|
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());
|
setContent(hover->content());
|
||||||
}
|
}
|
||||||
m_response = {};
|
m_response = {};
|
||||||
@@ -107,11 +107,11 @@ void HoverHandler::identifyMatch(TextEditor::TextEditorWidget *editorWidget,
|
|||||||
if (m_preferDiagnostics && reportDiagnostics(cursor))
|
if (m_preferDiagnostics && reportDiagnostics(cursor))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> &provider
|
const Utils::optional<std::variant<bool, WorkDoneProgressOptions>> &provider
|
||||||
= m_client->capabilities().hoverProvider();
|
= m_client->capabilities().hoverProvider();
|
||||||
bool sendMessage = provider.has_value();
|
bool sendMessage = provider.has_value();
|
||||||
if (sendMessage && Utils::holds_alternative<bool>(*provider))
|
if (sendMessage && std::holds_alternative<bool>(*provider))
|
||||||
sendMessage = Utils::get<bool>(*provider);
|
sendMessage = std::get<bool>(*provider);
|
||||||
if (Utils::optional<bool> registered = m_client->dynamicCapabilities().isRegistered(
|
if (Utils::optional<bool> registered = m_client->dynamicCapabilities().isRegistered(
|
||||||
HoverRequest::methodName)) {
|
HoverRequest::methodName)) {
|
||||||
sendMessage = *registered;
|
sendMessage = *registered;
|
||||||
@@ -146,7 +146,7 @@ void HoverHandler::handleResponse(const HoverRequest::Response &response, const
|
|||||||
m_client->log(*error);
|
m_client->log(*error);
|
||||||
}
|
}
|
||||||
if (Utils::optional<HoverResult> result = response.result()) {
|
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) {
|
if (m_helpItemProvider) {
|
||||||
m_response = response;
|
m_response = response;
|
||||||
m_helpItemProvider(response, m_uri);
|
m_helpItemProvider(response, m_uri);
|
||||||
@@ -166,9 +166,9 @@ static QString toolTipForMarkedStrings(const QList<MarkedString> &markedStrings)
|
|||||||
for (const MarkedString &markedString : markedStrings) {
|
for (const MarkedString &markedString : markedStrings) {
|
||||||
if (!tooltip.isEmpty())
|
if (!tooltip.isEmpty())
|
||||||
tooltip += '\n';
|
tooltip += '\n';
|
||||||
if (auto string = Utils::get_if<QString>(&markedString))
|
if (auto string = std::get_if<QString>(&markedString))
|
||||||
tooltip += *string;
|
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() + ']';
|
tooltip += string->value() + " [" + string->language() + ']';
|
||||||
}
|
}
|
||||||
return tooltip;
|
return tooltip;
|
||||||
@@ -176,11 +176,11 @@ static QString toolTipForMarkedStrings(const QList<MarkedString> &markedStrings)
|
|||||||
|
|
||||||
void HoverHandler::setContent(const HoverContent &hoverContent)
|
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());
|
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}));
|
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));
|
setToolTip(toolTipForMarkedStrings(*markedStrings));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -296,10 +296,10 @@ void LanguageClientOutlineWidget::handleResponse(const DocumentUri &uri,
|
|||||||
{
|
{
|
||||||
if (uri != m_uri)
|
if (uri != m_uri)
|
||||||
return;
|
return;
|
||||||
if (Utils::holds_alternative<QList<SymbolInformation>>(result))
|
if (std::holds_alternative<QList<SymbolInformation>>(result))
|
||||||
m_model.setInfo(Utils::get<QList<SymbolInformation>>(result));
|
m_model.setInfo(std::get<QList<SymbolInformation>>(result));
|
||||||
else if (Utils::holds_alternative<QList<DocumentSymbol>>(result))
|
else if (std::holds_alternative<QList<DocumentSymbol>>(result))
|
||||||
m_model.setInfo(Utils::get<QList<DocumentSymbol>>(result));
|
m_model.setInfo(std::get<QList<DocumentSymbol>>(result));
|
||||||
else
|
else
|
||||||
m_model.clear();
|
m_model.clear();
|
||||||
|
|
||||||
@@ -440,10 +440,10 @@ void OutlineComboBox::updateModel(const DocumentUri &resultUri, const DocumentSy
|
|||||||
{
|
{
|
||||||
if (m_uri != resultUri)
|
if (m_uri != resultUri)
|
||||||
return;
|
return;
|
||||||
if (Utils::holds_alternative<QList<SymbolInformation>>(result))
|
if (std::holds_alternative<QList<SymbolInformation>>(result))
|
||||||
m_model.setInfo(Utils::get<QList<SymbolInformation>>(result));
|
m_model.setInfo(std::get<QList<SymbolInformation>>(result));
|
||||||
else if (Utils::holds_alternative<QList<DocumentSymbol>>(result))
|
else if (std::holds_alternative<QList<DocumentSymbol>>(result))
|
||||||
m_model.setInfo(Utils::get<QList<DocumentSymbol>>(result));
|
m_model.setInfo(std::get<QList<DocumentSymbol>>(result));
|
||||||
else
|
else
|
||||||
m_model.clear();
|
m_model.clear();
|
||||||
|
|
||||||
|
@@ -124,12 +124,12 @@ void LanguageClientQuickFixAssistProcessor::handleCodeActionResponse(const CodeA
|
|||||||
|
|
||||||
GenericProposal *LanguageClientQuickFixAssistProcessor::handleCodeActionResult(const CodeActionResult &result)
|
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;
|
QuickFixOperations ops;
|
||||||
for (const Utils::variant<Command, CodeAction> &item : *list) {
|
for (const std::variant<Command, CodeAction> &item : *list) {
|
||||||
if (auto action = Utils::get_if<CodeAction>(&item))
|
if (auto action = std::get_if<CodeAction>(&item))
|
||||||
ops << new CodeActionQuickFixOperation(*action, m_client);
|
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);
|
ops << new CommandQuickFixOperation(*command, m_client);
|
||||||
}
|
}
|
||||||
return GenericProposal::createProposal(m_assistInterface.data(), ops);
|
return GenericProposal::createProposal(m_assistInterface.data(), ops);
|
||||||
|
@@ -64,11 +64,11 @@ static void sendTextDocumentPositionParamsRequest(Client *client,
|
|||||||
else
|
else
|
||||||
sendMessage = supportedFile;
|
sendMessage = supportedFile;
|
||||||
} else {
|
} else {
|
||||||
const Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> &provider
|
const Utils::optional<std::variant<bool, WorkDoneProgressOptions>> &provider
|
||||||
= serverCapability.referencesProvider();
|
= serverCapability.referencesProvider();
|
||||||
sendMessage = provider.has_value();
|
sendMessage = provider.has_value();
|
||||||
if (sendMessage && Utils::holds_alternative<bool>(*provider))
|
if (sendMessage && std::holds_alternative<bool>(*provider))
|
||||||
sendMessage = Utils::get<bool>(*provider);
|
sendMessage = std::get<bool>(*provider);
|
||||||
}
|
}
|
||||||
if (sendMessage)
|
if (sendMessage)
|
||||||
client->sendMessage(request);
|
client->sendMessage(request);
|
||||||
@@ -79,11 +79,11 @@ static void handleGotoDefinitionResponse(const GotoDefinitionRequest::Response &
|
|||||||
Utils::optional<Utils::Link> linkUnderCursor)
|
Utils::optional<Utils::Link> linkUnderCursor)
|
||||||
{
|
{
|
||||||
if (Utils::optional<GotoResult> result = response.result()) {
|
if (Utils::optional<GotoResult> result = response.result()) {
|
||||||
if (Utils::holds_alternative<std::nullptr_t>(*result)) {
|
if (std::holds_alternative<std::nullptr_t>(*result)) {
|
||||||
callback({});
|
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()));
|
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())
|
if (!plloc->isEmpty())
|
||||||
callback(linkUnderCursor.value_or(plloc->value(0).toLink()));
|
callback(linkUnderCursor.value_or(plloc->value(0).toLink()));
|
||||||
else
|
else
|
||||||
@@ -260,11 +260,11 @@ static bool supportsRename(Client *client,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (auto renameProvider = client->capabilities().renameProvider()) {
|
if (auto renameProvider = client->capabilities().renameProvider()) {
|
||||||
if (Utils::holds_alternative<bool>(*renameProvider)) {
|
if (std::holds_alternative<bool>(*renameProvider)) {
|
||||||
if (!Utils::get<bool>(*renameProvider))
|
if (!std::get<bool>(*renameProvider))
|
||||||
return false;
|
return false;
|
||||||
} else if (Utils::holds_alternative<ServerCapabilities::RenameOptions>(*renameProvider)) {
|
} else if (std::holds_alternative<ServerCapabilities::RenameOptions>(*renameProvider)) {
|
||||||
prepareSupported = Utils::get<ServerCapabilities::RenameOptions>(*renameProvider)
|
prepareSupported = std::get<ServerCapabilities::RenameOptions>(*renameProvider)
|
||||||
.prepareProvider()
|
.prepareProvider()
|
||||||
.value_or(false);
|
.value_or(false);
|
||||||
}
|
}
|
||||||
@@ -306,11 +306,11 @@ void SymbolSupport::requestPrepareRename(const TextDocumentPositionParams ¶m
|
|||||||
|
|
||||||
const Utils::optional<PrepareRenameResult> &result = response.result();
|
const Utils::optional<PrepareRenameResult> &result = response.result();
|
||||||
if (result.has_value()) {
|
if (result.has_value()) {
|
||||||
if (Utils::holds_alternative<PlaceHolderResult>(*result)) {
|
if (std::holds_alternative<PlaceHolderResult>(*result)) {
|
||||||
auto placeHolderResult = Utils::get<PlaceHolderResult>(*result);
|
auto placeHolderResult = std::get<PlaceHolderResult>(*result);
|
||||||
startRenameSymbol(params, placeHolderResult.placeHolder());
|
startRenameSymbol(params, placeHolderResult.placeHolder());
|
||||||
} else if (Utils::holds_alternative<Range>(*result)) {
|
} else if (std::holds_alternative<Range>(*result)) {
|
||||||
auto range = Utils::get<Range>(*result);
|
auto range = std::get<Range>(*result);
|
||||||
startRenameSymbol(params, placeholder);
|
startRenameSymbol(params, placeholder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -211,9 +211,9 @@ QList<Core::LocatorFilterEntry> DocumentLocatorFilter::matchesFor(
|
|||||||
|
|
||||||
QTC_ASSERT(m_currentSymbols.has_value(), return {});
|
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);
|
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 generateEntries(*list, entry);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
@@ -277,11 +277,11 @@ void WorkspaceLocatorFilter::prepareSearch(const QString &entry,
|
|||||||
continue;
|
continue;
|
||||||
if (!(force || client->locatorsEnabled()))
|
if (!(force || client->locatorsEnabled()))
|
||||||
continue;
|
continue;
|
||||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> capability
|
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> capability
|
||||||
= client->capabilities().workspaceSymbolProvider();
|
= client->capabilities().workspaceSymbolProvider();
|
||||||
if (!capability.has_value())
|
if (!capability.has_value())
|
||||||
continue;
|
continue;
|
||||||
if (Utils::holds_alternative<bool>(*capability) && !Utils::get<bool>(*capability))
|
if (std::holds_alternative<bool>(*capability) && !std::get<bool>(*capability))
|
||||||
continue;
|
continue;
|
||||||
WorkspaceSymbolRequest request(params);
|
WorkspaceSymbolRequest request(params);
|
||||||
request.setResponseCallback(
|
request.setResponseCallback(
|
||||||
|
@@ -45,11 +45,11 @@ void ProgressManager::handleProgress(const LanguageServerProtocol::ProgressParam
|
|||||||
{
|
{
|
||||||
const ProgressToken &token = params.token();
|
const ProgressToken &token = params.token();
|
||||||
ProgressParams::ProgressType value = params.value();
|
ProgressParams::ProgressType value = params.value();
|
||||||
if (auto begin = Utils::get_if<WorkDoneProgressBegin>(&value))
|
if (auto begin = std::get_if<WorkDoneProgressBegin>(&value))
|
||||||
beginProgress(token, *begin);
|
beginProgress(token, *begin);
|
||||||
else if (auto report = Utils::get_if<WorkDoneProgressReport>(&value))
|
else if (auto report = std::get_if<WorkDoneProgressReport>(&value))
|
||||||
reportProgress(token, *report);
|
reportProgress(token, *report);
|
||||||
else if (auto end = Utils::get_if<WorkDoneProgressEnd>(&value))
|
else if (auto end = std::get_if<WorkDoneProgressEnd>(&value))
|
||||||
endProgress(token, *end);
|
endProgress(token, *end);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,16 +68,16 @@ void ProgressManager::reset()
|
|||||||
|
|
||||||
bool ProgressManager::isProgressEndMessage(const LanguageServerProtocol::ProgressParams ¶ms)
|
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)
|
Utils::Id languageClientProgressId(const ProgressToken &token)
|
||||||
{
|
{
|
||||||
constexpr char k_LanguageClientProgressId[] = "LanguageClient.ProgressId.";
|
constexpr char k_LanguageClientProgressId[] = "LanguageClient.ProgressId.";
|
||||||
auto toString = [](const ProgressToken &token){
|
auto toString = [](const ProgressToken &token){
|
||||||
if (Utils::holds_alternative<int>(token))
|
if (std::holds_alternative<int>(token))
|
||||||
return QString::number(Utils::get<int>(token));
|
return QString::number(std::get<int>(token));
|
||||||
return Utils::get<QString>(token);
|
return std::get<QString>(token);
|
||||||
};
|
};
|
||||||
return Utils::Id(k_LanguageClientProgressId).withSuffix(toString(token));
|
return Utils::Id(k_LanguageClientProgressId).withSuffix(toString(token));
|
||||||
}
|
}
|
||||||
|
@@ -356,7 +356,7 @@ void SemanticTokenSupport::handleSemanticTokens(const Utils::FilePath &filePath,
|
|||||||
const SemanticTokensResult &result,
|
const SemanticTokensResult &result,
|
||||||
int documentVersion)
|
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);
|
const bool force = !m_tokens.contains(filePath);
|
||||||
m_tokens[filePath] = {*tokens, documentVersion};
|
m_tokens[filePath] = {*tokens, documentVersion};
|
||||||
highlight(filePath, force);
|
highlight(filePath, force);
|
||||||
@@ -369,10 +369,10 @@ void SemanticTokenSupport::handleSemanticTokensDelta(
|
|||||||
int documentVersion)
|
int documentVersion)
|
||||||
{
|
{
|
||||||
qCDebug(LOGLSPHIGHLIGHT) << "Handle Tokens for " << filePath;
|
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};
|
m_tokens[filePath] = {*tokens, documentVersion};
|
||||||
qCDebug(LOGLSPHIGHLIGHT) << "New Data " << tokens->data();
|
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;
|
m_tokens[filePath].version = documentVersion;
|
||||||
QList<SemanticTokensEdit> edits = tokensDelta->edits();
|
QList<SemanticTokensEdit> edits = tokensDelta->edits();
|
||||||
if (edits.isEmpty()) {
|
if (edits.isEmpty()) {
|
||||||
|
@@ -263,11 +263,11 @@ void LanguageClient::LanguageClientPlugin::testSnippetParsing()
|
|||||||
QFETCH(Parts, parts);
|
QFETCH(Parts, parts);
|
||||||
|
|
||||||
SnippetParseResult result = LanguageClient::parseSnippet(input);
|
SnippetParseResult result = LanguageClient::parseSnippet(input);
|
||||||
QCOMPARE(Utils::holds_alternative<ParsedSnippet>(result), success);
|
QCOMPARE(std::holds_alternative<ParsedSnippet>(result), success);
|
||||||
if (!success)
|
if (!success)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ParsedSnippet snippet = Utils::get<ParsedSnippet>(result);
|
ParsedSnippet snippet = std::get<ParsedSnippet>(result);
|
||||||
|
|
||||||
auto rangesCompare = [&](const ParsedSnippet::Part &actual, const SnippetPart &expected) {
|
auto rangesCompare = [&](const ParsedSnippet::Part &actual, const SnippetPart &expected) {
|
||||||
QCOMPARE(actual.text, expected.text);
|
QCOMPARE(actual.text, expected.text);
|
||||||
|
@@ -470,18 +470,18 @@ QIcon FolderNode::icon() const
|
|||||||
QTC_CHECK(QThread::currentThread() == QCoreApplication::instance()->thread());
|
QTC_CHECK(QThread::currentThread() == QCoreApplication::instance()->thread());
|
||||||
|
|
||||||
// Instantiating the Icon provider is expensive.
|
// 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);
|
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();
|
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)();
|
m_icon = (*creatorPtr)();
|
||||||
} else {
|
} else {
|
||||||
auto iconPtr = Utils::get_if<QIcon>(&m_icon);
|
auto iconPtr = std::get_if<QIcon>(&m_icon);
|
||||||
if (!iconPtr || iconPtr->isNull())
|
if (!iconPtr || iconPtr->isNull())
|
||||||
m_icon = Utils::FileIconProvider::icon(QFileIconProvider::Folder);
|
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)
|
Node *FolderNode::findNode(const std::function<bool(Node *)> &filter)
|
||||||
|
@@ -34,9 +34,9 @@
|
|||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/id.h>
|
#include <utils/id.h>
|
||||||
#include <utils/optional.h>
|
#include <utils/optional.h>
|
||||||
#include <utils/variant.h>
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
namespace Utils { class MimeType; }
|
namespace Utils { class MimeType; }
|
||||||
|
|
||||||
@@ -354,7 +354,7 @@ private:
|
|||||||
|
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
QString m_addFileFilter;
|
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;
|
bool m_showWhenEmpty = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -108,7 +108,7 @@ void ImageCacheCollector::start(Utils::SmallStringView name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is3DRoot) {
|
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,
|
rewriterView.rootModelNode().setAuxiliaryData(AuxiliaryDataType::NodeInstancePropertyOverwrite,
|
||||||
"isLibraryIcon",
|
"isLibraryIcon",
|
||||||
libIcon->enable);
|
libIcon->enable);
|
||||||
|
@@ -128,7 +128,7 @@ void ImageCacheFontCollector::start(Utils::SmallStringView name,
|
|||||||
{
|
{
|
||||||
QFont font;
|
QFont font;
|
||||||
if (resolveFont(QString(name), font) >= 0) {
|
if (resolveFont(QString(name), font) >= 0) {
|
||||||
auto &&auxiliaryData = Utils::get<ImageCache::FontCollectorSizeAuxiliaryData>(auxiliaryDataValue);
|
auto &&auxiliaryData = std::get<ImageCache::FontCollectorSizeAuxiliaryData>(auxiliaryDataValue);
|
||||||
QColor textColor = auxiliaryData.colorName;
|
QColor textColor = auxiliaryData.colorName;
|
||||||
QSize size = auxiliaryData.size;
|
QSize size = auxiliaryData.size;
|
||||||
QString text = font.family() + "\n" + auxiliaryData.text;
|
QString text = font.family() + "\n" + auxiliaryData.text;
|
||||||
@@ -150,7 +150,7 @@ std::pair<QImage, QImage> ImageCacheFontCollector::createImage(
|
|||||||
{
|
{
|
||||||
QFont font;
|
QFont font;
|
||||||
if (resolveFont(QString(name), font) >= 0) {
|
if (resolveFont(QString(name), font) >= 0) {
|
||||||
auto &&auxiliaryData = Utils::get<ImageCache::FontCollectorSizeAuxiliaryData>(auxiliaryDataValue);
|
auto &&auxiliaryData = std::get<ImageCache::FontCollectorSizeAuxiliaryData>(auxiliaryDataValue);
|
||||||
QColor textColor = auxiliaryData.colorName;
|
QColor textColor = auxiliaryData.colorName;
|
||||||
QSize size = auxiliaryData.size;
|
QSize size = auxiliaryData.size;
|
||||||
QString text = font.family() + "\n\n" + auxiliaryData.text;
|
QString text = font.family() + "\n\n" + auxiliaryData.text;
|
||||||
@@ -172,7 +172,7 @@ QIcon ImageCacheFontCollector::createIcon(Utils::SmallStringView name,
|
|||||||
|
|
||||||
QFont font;
|
QFont font;
|
||||||
if (resolveFont(QString(name), font) >= 0) {
|
if (resolveFont(QString(name), font) >= 0) {
|
||||||
auto &&auxiliaryData = Utils::get<ImageCache::FontCollectorSizesAuxiliaryData>(auxiliaryDataValue);
|
auto &&auxiliaryData = std::get<ImageCache::FontCollectorSizesAuxiliaryData>(auxiliaryDataValue);
|
||||||
QColor textColor = auxiliaryData.colorName;
|
QColor textColor = auxiliaryData.colorName;
|
||||||
const auto sizes = auxiliaryData.sizes;
|
const auto sizes = auxiliaryData.sizes;
|
||||||
QString text = auxiliaryData.text;
|
QString text = auxiliaryData.text;
|
||||||
|
@@ -26,20 +26,20 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <auxiliarydata.h>
|
#include <auxiliarydata.h>
|
||||||
#include <utils/variant.h>
|
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
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)
|
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
|
class AuxiliaryDataKeyDefaultValue : public AuxiliaryDataKeyView
|
||||||
|
@@ -26,13 +26,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <utils/span.h>
|
#include <utils/span.h>
|
||||||
#include <utils/variant.h>
|
|
||||||
|
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -60,10 +60,10 @@ public:
|
|||||||
bool enable;
|
bool enable;
|
||||||
};
|
};
|
||||||
|
|
||||||
using AuxiliaryData = Utils::variant<Utils::monostate,
|
using AuxiliaryData = std::variant<std::monostate,
|
||||||
LibraryIconAuxiliaryData,
|
LibraryIconAuxiliaryData,
|
||||||
FontCollectorSizeAuxiliaryData,
|
FontCollectorSizeAuxiliaryData,
|
||||||
FontCollectorSizesAuxiliaryData>;
|
FontCollectorSizesAuxiliaryData>;
|
||||||
|
|
||||||
enum class AbortReason : char { Abort, Failed };
|
enum class AbortReason : char { Abort, Failed };
|
||||||
|
|
||||||
|
@@ -1910,7 +1910,7 @@ private:
|
|||||||
if (type.changeLevel == Storage::Synchronization::ChangeLevel::Minimal)
|
if (type.changeLevel == Storage::Synchronization::ChangeLevel::Minimal)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Utils::visit([](auto &&typeName) -> bool { return typeName.name.isEmpty(); },
|
if (std::visit([](auto &&typeName) -> bool { return typeName.name.isEmpty(); },
|
||||||
type.prototype)) {
|
type.prototype)) {
|
||||||
updatePrototypeStatement.write(type.typeId, Sqlite::NullValue{}, Sqlite::NullValue{});
|
updatePrototypeStatement.write(type.typeId, Sqlite::NullValue{}, Sqlite::NullValue{});
|
||||||
} else {
|
} else {
|
||||||
@@ -1981,7 +1981,7 @@ private:
|
|||||||
SourceId sourceId;
|
SourceId sourceId;
|
||||||
};
|
};
|
||||||
|
|
||||||
return Utils::visit(Inspect{*this, sourceId}, name);
|
return std::visit(Inspect{*this, sourceId}, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Id>
|
template<typename Id>
|
||||||
|
@@ -29,9 +29,9 @@
|
|||||||
#include "projectstorageids.h"
|
#include "projectstorageids.h"
|
||||||
|
|
||||||
#include <utils/smallstring.h>
|
#include <utils/smallstring.h>
|
||||||
#include <utils/variant.h>
|
|
||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
@@ -425,7 +425,7 @@ public:
|
|||||||
ExportedTypeNameId exportedTypeNameId;
|
ExportedTypeNameId exportedTypeNameId;
|
||||||
};
|
};
|
||||||
|
|
||||||
using ImportedTypeName = Utils::variant<ImportedType, QualifiedImportedType>;
|
using ImportedTypeName = std::variant<ImportedType, QualifiedImportedType>;
|
||||||
|
|
||||||
class EnumeratorDeclaration
|
class EnumeratorDeclaration
|
||||||
{
|
{
|
||||||
|
@@ -182,10 +182,10 @@ QString Snippet::generateTip() const
|
|||||||
{
|
{
|
||||||
SnippetParseResult result = Snippet::parse(m_content);
|
SnippetParseResult result = Snippet::parse(m_content);
|
||||||
|
|
||||||
if (Utils::holds_alternative<SnippetParseError>(result))
|
if (std::holds_alternative<SnippetParseError>(result))
|
||||||
return Utils::get<SnippetParseError>(result).htmlMessage();
|
return std::get<SnippetParseError>(result).htmlMessage();
|
||||||
QTC_ASSERT(Utils::holds_alternative<ParsedSnippet>(result), return {});
|
QTC_ASSERT(std::holds_alternative<ParsedSnippet>(result), return {});
|
||||||
const ParsedSnippet parsedSnippet = Utils::get<ParsedSnippet>(result);
|
const ParsedSnippet parsedSnippet = std::get<ParsedSnippet>(result);
|
||||||
|
|
||||||
QString tip("<nobr>");
|
QString tip("<nobr>");
|
||||||
for (const ParsedSnippet::Part &part : parsedSnippet.parts)
|
for (const ParsedSnippet::Part &part : parsedSnippet.parts)
|
||||||
@@ -407,11 +407,11 @@ void Internal::TextEditorPlugin::testSnippetParsing()
|
|||||||
QFETCH(Parts, parts);
|
QFETCH(Parts, parts);
|
||||||
|
|
||||||
SnippetParseResult result = Snippet::parse(input);
|
SnippetParseResult result = Snippet::parse(input);
|
||||||
QCOMPARE(Utils::holds_alternative<ParsedSnippet>(result), success);
|
QCOMPARE(std::holds_alternative<ParsedSnippet>(result), success);
|
||||||
if (!success)
|
if (!success)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ParsedSnippet snippet = Utils::get<ParsedSnippet>(result);
|
ParsedSnippet snippet = std::get<ParsedSnippet>(result);
|
||||||
|
|
||||||
auto rangesCompare = [&](const ParsedSnippet::Part &actual, const SnippetPart &expected) {
|
auto rangesCompare = [&](const ParsedSnippet::Part &actual, const SnippetPart &expected) {
|
||||||
QCOMPARE(actual.text, expected.text);
|
QCOMPARE(actual.text, expected.text);
|
||||||
|
@@ -28,7 +28,8 @@
|
|||||||
#include <texteditor/texteditor_global.h>
|
#include <texteditor/texteditor_global.h>
|
||||||
|
|
||||||
#include <utils/id.h>
|
#include <utils/id.h>
|
||||||
#include <utils/variant.h>
|
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
@@ -67,7 +68,7 @@ public:
|
|||||||
QString htmlMessage() const;
|
QString htmlMessage() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
using SnippetParseResult = Utils::variant<ParsedSnippet, SnippetParseError>;
|
using SnippetParseResult = std::variant<ParsedSnippet, SnippetParseError>;
|
||||||
using SnippetParser = std::function<SnippetParseResult (const QString &)>;
|
using SnippetParser = std::function<SnippetParseResult (const QString &)>;
|
||||||
|
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
|
@@ -2761,13 +2761,13 @@ void TextEditorWidget::insertCodeSnippet(const QTextCursor &cursor_arg,
|
|||||||
const SnippetParser &parse)
|
const SnippetParser &parse)
|
||||||
{
|
{
|
||||||
SnippetParseResult result = parse(snippet);
|
SnippetParseResult result = parse(snippet);
|
||||||
if (Utils::holds_alternative<SnippetParseError>(result)) {
|
if (std::holds_alternative<SnippetParseError>(result)) {
|
||||||
const auto &error = Utils::get<SnippetParseError>(result);
|
const auto &error = std::get<SnippetParseError>(result);
|
||||||
QMessageBox::warning(this, tr("Snippet Parse Error"), error.htmlMessage());
|
QMessageBox::warning(this, tr("Snippet Parse Error"), error.htmlMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QTC_ASSERT(Utils::holds_alternative<ParsedSnippet>(result), return);
|
QTC_ASSERT(std::holds_alternative<ParsedSnippet>(result), return);
|
||||||
ParsedSnippet data = Utils::get<ParsedSnippet>(result);
|
ParsedSnippet data = std::get<ParsedSnippet>(result);
|
||||||
|
|
||||||
QTextCursor cursor = cursor_arg;
|
QTextCursor cursor = cursor_arg;
|
||||||
cursor.beginEditBlock();
|
cursor.beginEditBlock();
|
||||||
|
@@ -62,7 +62,7 @@ TEST_F(AsynchronousImageFactory, RequestImageRequestImageFromCollector)
|
|||||||
EXPECT_CALL(collectorMock,
|
EXPECT_CALL(collectorMock,
|
||||||
start(Eq("/path/to/Component.qml"),
|
start(Eq("/path/to/Component.qml"),
|
||||||
IsEmpty(),
|
IsEmpty(),
|
||||||
VariantWith<Utils::monostate>(Utils::monostate{}),
|
VariantWith<std::monostate>(std::monostate{}),
|
||||||
_,
|
_,
|
||||||
_))
|
_))
|
||||||
.WillRepeatedly([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
.WillRepeatedly([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
||||||
@@ -76,7 +76,7 @@ TEST_F(AsynchronousImageFactory, RequestImageWithExtraIdRequestImageFromCollecto
|
|||||||
EXPECT_CALL(collectorMock,
|
EXPECT_CALL(collectorMock,
|
||||||
start(Eq("/path/to/Component.qml"),
|
start(Eq("/path/to/Component.qml"),
|
||||||
Eq("foo"),
|
Eq("foo"),
|
||||||
VariantWith<Utils::monostate>(Utils::monostate{}),
|
VariantWith<std::monostate>(std::monostate{}),
|
||||||
_,
|
_,
|
||||||
_))
|
_))
|
||||||
.WillRepeatedly([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
.WillRepeatedly([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
||||||
@@ -162,7 +162,7 @@ TEST_F(AsynchronousImageFactory, AfterCleanNewJobsWorks)
|
|||||||
EXPECT_CALL(collectorMock,
|
EXPECT_CALL(collectorMock,
|
||||||
start(Eq("/path/to/Component.qml"),
|
start(Eq("/path/to/Component.qml"),
|
||||||
IsEmpty(),
|
IsEmpty(),
|
||||||
VariantWith<Utils::monostate>(Utils::monostate{}),
|
VariantWith<std::monostate>(std::monostate{}),
|
||||||
_,
|
_,
|
||||||
_))
|
_))
|
||||||
.WillRepeatedly([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
.WillRepeatedly([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
||||||
@@ -181,7 +181,7 @@ TEST_F(AsynchronousImageFactory, CaptureImageCallbackStoresImage)
|
|||||||
ON_CALL(collectorMock,
|
ON_CALL(collectorMock,
|
||||||
start(Eq("/path/to/Component.qml"),
|
start(Eq("/path/to/Component.qml"),
|
||||||
Eq("id"),
|
Eq("id"),
|
||||||
VariantWith<Utils::monostate>(Utils::monostate{}),
|
VariantWith<std::monostate>(std::monostate{}),
|
||||||
_,
|
_,
|
||||||
_))
|
_))
|
||||||
.WillByDefault([&](auto, auto, auto, auto capture, auto) { capture(image1, smallImage1); });
|
.WillByDefault([&](auto, auto, auto, auto capture, auto) { capture(image1, smallImage1); });
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include <clangtools/clangtoolsdiagnostic.h>
|
#include <clangtools/clangtoolsdiagnostic.h>
|
||||||
#include <debugger/analyzer/diagnosticlocation.h>
|
#include <debugger/analyzer/diagnosticlocation.h>
|
||||||
|
#include <imagecacheauxiliarydata.h>
|
||||||
#include <modelnode.h>
|
#include <modelnode.h>
|
||||||
#include <projectstorage/filestatus.h>
|
#include <projectstorage/filestatus.h>
|
||||||
#include <projectstorage/projectstoragepathwatchertypes.h>
|
#include <projectstorage/projectstoragepathwatchertypes.h>
|
||||||
@@ -54,6 +55,12 @@ template <typename T> ostream &operator<<(ostream &out, const QVector<T> &vector
|
|||||||
out << "]";
|
out << "]";
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::ostream &operator<<(std::ostream &out, const monostate &)
|
||||||
|
{
|
||||||
|
return out << "monostate";
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace std
|
} // namespace std
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
@@ -739,6 +746,7 @@ std::ostream &operator<<(std::ostream &out, const QualifiedImportedType &importe
|
|||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const Type &type)
|
std::ostream &operator<<(std::ostream &out, const Type &type)
|
||||||
{
|
{
|
||||||
|
using std::operator<<;
|
||||||
using Utils::operator<<;
|
using Utils::operator<<;
|
||||||
return out << "( typename: \"" << type.typeName << "\", prototype: " << type.prototype << ", "
|
return out << "( typename: \"" << type.typeName << "\", prototype: " << type.prototype << ", "
|
||||||
<< type.prototypeId << ", " << type.traits << ", source: " << type.sourceId
|
<< type.prototypeId << ", " << type.traits << ", source: " << type.sourceId
|
||||||
@@ -813,4 +821,20 @@ std::ostream &operator<<(std::ostream &out, const ModuleExportedImport &import)
|
|||||||
|
|
||||||
} // namespace Storage::Synchronization
|
} // 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
|
} // namespace QmlDesigner
|
||||||
|
@@ -28,11 +28,11 @@
|
|||||||
#include <utils/cpplanguage_details.h>
|
#include <utils/cpplanguage_details.h>
|
||||||
#include <utils/optional.h>
|
#include <utils/optional.h>
|
||||||
#include <utils/smallstringio.h>
|
#include <utils/smallstringio.h>
|
||||||
#include <utils/variant.h>
|
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
#include <gtest/gtest-printers.h>
|
#include <gtest/gtest-printers.h>
|
||||||
|
|
||||||
@@ -77,6 +77,18 @@ std::ostream &operator<<(std::ostream &out, const ValueViews &valueViews);
|
|||||||
} // namespace SessionChangeSetInternal
|
} // namespace SessionChangeSetInternal
|
||||||
} // namespace Sqlite
|
} // 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 {
|
namespace Utils {
|
||||||
class LineColumn;
|
class LineColumn;
|
||||||
class SmallStringView;
|
class SmallStringView;
|
||||||
@@ -103,12 +115,6 @@ void PrintTo(const optional<Type> &optional, ::std::ostream *os)
|
|||||||
*os << optional;
|
*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(Utils::SmallStringView text, ::std::ostream *os);
|
||||||
void PrintTo(const Utils::SmallString &text, ::std::ostream *os);
|
void PrintTo(const Utils::SmallString &text, ::std::ostream *os);
|
||||||
void PrintTo(const Utils::PathString &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);
|
std::ostream &operator<<(std::ostream &out, const SourceContext &sourceContext);
|
||||||
} // namespace Cache
|
} // 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 {
|
namespace Storage {
|
||||||
enum class PropertyDeclarationTraits : int;
|
enum class PropertyDeclarationTraits : int;
|
||||||
enum class TypeTraits : int;
|
enum class TypeTraits : int;
|
||||||
|
Reference in New Issue
Block a user