Utils: Remove Utils::optional

Since we are now requiring macOS 10.14 we can remove our local
implementation of optional and use std::optional for macOS too.

Change-Id: I2bd018261b68da64f7f031a812045dd7784697e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Eike Ziller
2022-08-26 10:30:00 +02:00
parent 34a9491a08
commit 04e50438eb
247 changed files with 1053 additions and 3751 deletions

View File

@@ -324,24 +324,6 @@ we thank the authors who made this possible:
With backported/additional patches from https://code.qt.io/cgit/clang/llvm-project.git With backported/additional patches from https://code.qt.io/cgit/clang/llvm-project.git
### Optional
A single-header header-only library for representing optional (nullable)
objects for C++14 (and C++11 to some extent) and passing them by value.
https://github.com/akrzemi1/Optional
QtCreator/src/libs/3rdparty/optional
Copyright (C) 2011-2012 Andrzej Krzemienski
Distributed under the Boost Software License, Version 1.0
(see accompanying file LICENSE_1_0.txt or a copy at
http://www.boost.org/LICENSE_1_0.txt)
The idea and interface is based on Boost.Optional library
authored by Fernando Luis Cacciola Carballal
### std::span implementation for C++11 and later ### std::span implementation for C++11 and later
A single-header implementation of C++20's std::span, conforming to the C++20 A single-header implementation of C++20's std::span, conforming to the C++20

View File

@@ -362,29 +362,6 @@
\li \l{https://code.qt.io/cgit/clang/llvm-project.git} \li \l{https://code.qt.io/cgit/clang/llvm-project.git}
\endlist \endlist
\li \b{Optional}
A single-header header-only library for representing optional
(nullable) objects for C++14 (and C++11 to some extent) and passing
them by value.
Copyright (C) 2011-2012 Andrzej Krzemienski
Distributed under the \l {http://boost.org/LICENSE_1_0.txt}
{Boost Software License, Version 1.0}.
(See accompanying file LICENSE_1_0.txt)
The idea and interface is based on Boost.Optional library
authored by Fernando Luis Cacciola Carballal
The source code of std::experimental::optional can be found
here:
\list
\li \l{https://github.com/akrzemi1/Optional}
\li QtCreator/src/libs/3rdparty/optional
\li \l{https://code.qt.io/cgit/qt-creator/qt-creator.git/tree/src/libs/3rdparty/optional}
\endlist
\li \b{std::span implementation for C++11 and later} \li \b{std::span implementation for C++11 and later}
A single-header implementation of C++20's std::span, conforming to A single-header implementation of C++20's std::span, conforming to

View File

@@ -15,7 +15,6 @@
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/fsengine/fsengine.h> #include <utils/fsengine/fsengine.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/optional.h>
#include <utils/qtcsettings.h> #include <utils/qtcsettings.h>
#include <utils/singleton.h> #include <utils/singleton.h>
#include <utils/temporarydirectory.h> #include <utils/temporarydirectory.h>
@@ -47,9 +46,10 @@
#include <QTemporaryDir> #include <QTemporaryDir>
#include <QTextCodec> #include <QTextCodec>
#include <iterator>
#include <optional>
#include <string> #include <string>
#include <vector> #include <vector>
#include <iterator>
#ifdef ENABLE_QT_BREAKPAD #ifdef ENABLE_QT_BREAKPAD
#include <qtsystemexceptionhandler.h> #include <qtsystemexceptionhandler.h>
@@ -295,7 +295,7 @@ struct Options
QStringList preAppArguments; QStringList preAppArguments;
// list of arguments to be passed to the application or plugin manager // list of arguments to be passed to the application or plugin manager
std::vector<char *> appArguments; std::vector<char *> appArguments;
Utils::optional<QString> userLibraryPath; std::optional<QString> userLibraryPath;
bool hasTestOption = false; bool hasTestOption = false;
bool wantsCleanSettings = false; bool wantsCleanSettings = false;
}; };

View File

@@ -1,11 +0,0 @@
project(optional)
cmake_minimum_required(VERSION 2.8)
enable_testing()
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra")
add_executable(test_optional test_optional.cpp)
add_executable(test_type_traits test_type_traits.cpp)
add_test(test_optional test_optional)
add_test(test_type_traits test_type_traits)

View File

@@ -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.

View File

@@ -1,39 +0,0 @@
Optional
========
A single-header header-only library for representing optional (nullable) objects for C++14 (and C++11 to some extent) and passing them by value. This is the reference implementation of proposal N3793 (see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3793.html). Optional is now accepted into Library Fundamentals Technical Specification (see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3848.html). The interface is based on Fernando Cacciola's Boost.Optional library (see http://www.boost.org/doc/libs/1_52_0/libs/optional/doc/html/index.html)
Usage
-----
```cpp
optional<int> readInt(); // this function may return int or a not-an-int
if (optional<int> oi = readInt()) // did I get a real int
cout << "my int is: " << *oi; // use my int
else
cout << "I have no int";
```
For more usage examples and the overview see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3527.html
Supported compilers
-------------------
Clang 3.2, Clang 3.4, G++ 4.7.2, G++ 4.8.1. Tested only with libstdc++, versions 20130531, 20120920, 20110428. Others have reported it also works with libc++.
Known Issues
------------
- Currently, the reference (and the only known) implementation of certain pieces of functionality explore what C++11 identifies as undefined behavior (see national body comment FI 15: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3770.html#FI15). This is mostly why Optional was removed from C++14 and put into Library Fundamentals TS. Luckily what the Standard identifies as UB is well defined on all known platforms. We expect that the C++14 wil fix this problem, so that our trick becomes well-defined.
- In libstdc++ versions below 20130531 the constructor taking `initializer_list` argument is not `constexpr`. This is because `initializer_list` operations are not `constexpr` in C++11. This works however in version 20130531. It is also not enabled for libc++ because I do not have access to it and do nto know if it provides `constexpr` `initializer_list`.
- In G++ 4.7.2 and 4.8.0 member function `value_or` does not have rvalue reference overload. These compilers do not support rvalue overloding on `*this`.
- In order for the library to work with slightly older compilers, we emulate some missing type traits. On some platforms we cannot correctly detect the available features, and attempts at workarounds for missing type trait definitions can cause compile-time errors. Define macro `TR2_OPTIONAL_DISABLE_EMULATION_OF_TYPE_TRAITS` if you know that all the necessary type traits are defined, and no emulation is required.
License
-------
Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).

View File

@@ -1,10 +0,0 @@
Copyright (C) 2011-2012 Andrzej Krzemienski
Distributed under the Boost Software License, Version 1.0
(see accompanying file LICENSE_1_0.txt or a copy at
http://www.boost.org/LICENSE_1_0.txt)
The idea and interface is based on Boost.Optional library
authored by Fernando Luis Cacciola Carballal
Home at https://github.com/akrzemi1/Optional

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,66 +0,0 @@
// Copyright (C) 2011 - 2012 Andrzej Krzemienski.
//
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#if (defined __clang__)
namespace std { class type_info; }
#endif
# include "optional.hpp"
namespace std { namespace experimental {
struct Val
{
Val(){}
Val( Val const & ){}
Val( Val && ) noexcept {}
Val & operator=( Val const & ) = delete;
Val & operator=( Val && ) noexcept = delete;
};
struct Safe
{
Safe(){}
Safe( Safe const & ){}
Safe( Safe && ) noexcept {}
Safe & operator=( Safe const & ){ return *this; }
Safe & operator=( Safe && ) noexcept { return *this; }
};
struct Unsafe
{
Unsafe(){}
Unsafe( Unsafe const & ){}
Unsafe( Unsafe && ){}
Unsafe & operator=( Unsafe const & ){ return *this; }
Unsafe & operator=( Unsafe && ) { return *this; }
};
struct VoidNothrowBoth
{
VoidNothrowBoth(VoidNothrowBoth&&) noexcept(true) {};
void operator=(VoidNothrowBoth&&) noexcept(true) {}; // note void return type
};
static_assert(is_nothrow_move_constructible<Safe>::value, "WTF!");
static_assert(!is_nothrow_move_constructible<Unsafe>::value, "WTF!");
static_assert(is_assignable<Safe&, Safe&&>::value, "WTF!");
static_assert(!is_assignable<Val&, Val&&>::value, "WTF!");
static_assert(is_nothrow_move_assignable<Safe>::value, "WTF!");
static_assert(!is_nothrow_move_assignable<Unsafe>::value, "WTF!");
static_assert(is_nothrow_move_constructible<VoidNothrowBoth>::value, "WTF!");
static_assert(is_nothrow_move_assignable<VoidNothrowBoth>::value, "WTF!");
}} // namespace std::experimental
int main() { }

View File

@@ -16,10 +16,9 @@
#include <cplusplus/TranslationUnit.h> #include <cplusplus/TranslationUnit.h>
#include <cplusplus/TypeOfExpression.h> #include <cplusplus/TypeOfExpression.h>
#include <utils/optional.h>
#include <QDebug> #include <QDebug>
#include <optional>
using namespace CPlusPlus; using namespace CPlusPlus;
@@ -189,7 +188,7 @@ public:
if (const auto binExpr = (*it)->asBinaryExpression()) { if (const auto binExpr = (*it)->asBinaryExpression()) {
if (binExpr->left_expression == *(it - 1) && isAssignment(binExpr->binary_op_token)) if (binExpr->left_expression == *(it - 1) && isAssignment(binExpr->binary_op_token))
return checkPotentialWrite(Usage::Type::Write, it + 1); return checkPotentialWrite(Usage::Type::Write, it + 1);
const Utils::optional<LookupItem> item = getTypeOfExpr(binExpr->left_expression, const std::optional<LookupItem> item = getTypeOfExpr(binExpr->left_expression,
it + 1); it + 1);
if (!item) if (!item)
return Usage::Type::Other; return Usage::Type::Other;
@@ -349,12 +348,12 @@ private:
return m_findUsages->typeofExpression(expr, m_findUsages->_doc, scope); return m_findUsages->typeofExpression(expr, m_findUsages->_doc, scope);
} }
Utils::optional<LookupItem> getTypeOfExpr(ExpressionAST *expr, Iterator scopeSearchPos) const std::optional<LookupItem> getTypeOfExpr(ExpressionAST *expr, Iterator scopeSearchPos) const
{ {
const QList<LookupItem> items = getTypesOfExpr(expr, scopeSearchPos); const QList<LookupItem> items = getTypesOfExpr(expr, scopeSearchPos);
if (items.isEmpty()) if (items.isEmpty())
return {}; return {};
return Utils::optional<LookupItem>(items.first()); return std::optional<LookupItem>(items.first());
} }
Usage::Type getUsageTypeFromLhsAndRhs(const FullySpecifiedType &lhsType, ExpressionAST *rhs, Usage::Type getUsageTypeFromLhsAndRhs(const FullySpecifiedType &lhsType, ExpressionAST *rhs,
@@ -365,7 +364,7 @@ private:
return usageType; return usageType;
// If the lhs has type auto, we use the RHS type. // If the lhs has type auto, we use the RHS type.
const Utils::optional<LookupItem> item = getTypeOfExpr(rhs, scopeSearchPos); const std::optional<LookupItem> item = getTypeOfExpr(rhs, scopeSearchPos);
if (!item) if (!item)
return Usage::Type::Other; return Usage::Type::Other;
return getUsageTypeFromDataType(item->type()); return getUsageTypeFromDataType(item->type());
@@ -385,8 +384,8 @@ private:
continue; continue;
if (memberAccess->member_name == *(it - 1)) if (memberAccess->member_name == *(it - 1))
return Usage::Type::Other; return Usage::Type::Other;
const Utils::optional<LookupItem> item const std::optional<LookupItem> item = getTypeOfExpr(memberAccess->base_expression,
= getTypeOfExpr(memberAccess->base_expression, it); it);
if (!item) if (!item)
return Usage::Type::Other; return Usage::Type::Other;
FullySpecifiedType baseExprType = item->type(); FullySpecifiedType baseExprType = item->type();

View File

@@ -13,7 +13,8 @@
#include <QDebug> #include <QDebug>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/optional.h>
#include <optional>
using namespace CPlusPlus; using namespace CPlusPlus;
@@ -157,7 +158,7 @@ static bool isCursorAtEndOfLineButMaybeBeforeComment(const QTextCursor &cursor)
return Utils::allOf(tokens, [](const Token &token) { return token.isComment(); }); return Utils::allOf(tokens, [](const Token &token) { return token.isComment(); });
} }
using TokenIndexResult = Utils::optional<int>; using TokenIndexResult = std::optional<int>;
// 10.6.1 Attribute syntax and semantics // 10.6.1 Attribute syntax and semantics
// This does not handle alignas() since it is not needed for the namespace case. // This does not handle alignas() since it is not needed for the namespace case.

View File

@@ -1467,7 +1467,7 @@ public:
+ ".lock"; + ".lock";
} }
static Utils::optional<QString> lockedPluginName(PluginManagerPrivate *pm) static std::optional<QString> lockedPluginName(PluginManagerPrivate *pm)
{ {
const QString lockFilePath = LockFile::filePath(pm); const QString lockFilePath = LockFile::filePath(pm);
if (QFile::exists(lockFilePath)) { if (QFile::exists(lockFilePath)) {
@@ -1507,7 +1507,7 @@ void PluginManagerPrivate::checkForProblematicPlugins()
{ {
if (!enableCrashCheck) if (!enableCrashCheck)
return; return;
const Utils::optional<QString> pluginName = LockFile::lockedPluginName(this); const std::optional<QString> pluginName = LockFile::lockedPluginName(this);
if (pluginName) { if (pluginName) {
PluginSpec *spec = pluginByName(*pluginName); PluginSpec *spec = pluginByName(*pluginName);
if (spec && !spec->isRequired()) { if (spec && !spec->isRequired()) {

View File

@@ -6,8 +6,6 @@
#include "pluginspec.h" #include "pluginspec.h"
#include "iplugin.h" #include "iplugin.h"
#include <utils/optional.h>
#include <QJsonObject> #include <QJsonObject>
#include <QObject> #include <QObject>
#include <QPluginLoader> #include <QPluginLoader>
@@ -16,6 +14,8 @@
#include <QVector> #include <QVector>
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include <optional>
namespace ExtensionSystem { namespace ExtensionSystem {
class IPlugin; class IPlugin;
@@ -47,8 +47,8 @@ public:
void setForceEnabled(bool value); void setForceEnabled(bool value);
void setForceDisabled(bool value); void setForceDisabled(bool value);
Utils::optional<QPluginLoader> loader; std::optional<QPluginLoader> loader;
Utils::optional<QStaticPlugin> staticPlugin; std::optional<QStaticPlugin> staticPlugin;
QString name; QString name;
QString version; QString version;

View File

@@ -5,14 +5,13 @@
namespace LanguageServerProtocol { namespace LanguageServerProtocol {
Utils::optional<QList<SymbolKind> > SymbolCapabilities::SymbolKindCapabilities::valueSet() const std::optional<QList<SymbolKind>> SymbolCapabilities::SymbolKindCapabilities::valueSet() const
{ {
if (Utils::optional<QList<int>> array = optionalArray<int>(valueSetKey)) { if (std::optional<QList<int>> array = optionalArray<int>(valueSetKey)) {
return Utils::make_optional(Utils::transform(*array, [] (int value) { return std::make_optional(
return static_cast<SymbolKind>(value); Utils::transform(*array, [](int value) { return static_cast<SymbolKind>(value); }));
}));
} }
return Utils::nullopt; return std::nullopt;
} }
void SymbolCapabilities::SymbolKindCapabilities::setValueSet(const QList<SymbolKind> &valueSet) void SymbolCapabilities::SymbolKindCapabilities::setValueSet(const QList<SymbolKind> &valueSet)
@@ -25,7 +24,7 @@ WorkspaceClientCapabilities::WorkspaceClientCapabilities()
setWorkspaceFolders(true); setWorkspaceFolders(true);
} }
Utils::optional<std::variant<bool, QJsonObject>> SemanticTokensClientCapabilities::Requests::range() std::optional<std::variant<bool, QJsonObject>> SemanticTokensClientCapabilities::Requests::range()
const const
{ {
using RetType = std::variant<bool, QJsonObject>; using RetType = std::variant<bool, QJsonObject>;
@@ -34,7 +33,7 @@ Utils::optional<std::variant<bool, QJsonObject>> SemanticTokensClientCapabilitie
return RetType(rangeOptions.toBool()); return RetType(rangeOptions.toBool());
if (rangeOptions.isObject()) if (rangeOptions.isObject())
return RetType(rangeOptions.toObject()); return RetType(rangeOptions.toObject());
return Utils::nullopt; return std::nullopt;
} }
void SemanticTokensClientCapabilities::Requests::setRange( void SemanticTokensClientCapabilities::Requests::setRange(
@@ -43,7 +42,7 @@ void SemanticTokensClientCapabilities::Requests::setRange(
insertVariant<bool, QJsonObject>(rangeKey, range); insertVariant<bool, QJsonObject>(rangeKey, range);
} }
Utils::optional<std::variant<bool, FullSemanticTokenOptions>> std::optional<std::variant<bool, FullSemanticTokenOptions>>
SemanticTokensClientCapabilities::Requests::full() const SemanticTokensClientCapabilities::Requests::full() const
{ {
using RetType = std::variant<bool, FullSemanticTokenOptions>; using RetType = std::variant<bool, FullSemanticTokenOptions>;
@@ -52,7 +51,7 @@ SemanticTokensClientCapabilities::Requests::full() const
return RetType(fullOptions.toBool()); return RetType(fullOptions.toBool());
if (fullOptions.isObject()) if (fullOptions.isObject())
return RetType(FullSemanticTokenOptions(fullOptions.toObject())); return RetType(FullSemanticTokenOptions(fullOptions.toObject()));
return Utils::nullopt; return std::nullopt;
} }
void SemanticTokensClientCapabilities::Requests::setFull( void SemanticTokensClientCapabilities::Requests::setFull(
@@ -61,8 +60,7 @@ void SemanticTokensClientCapabilities::Requests::setFull(
insertVariant<bool, FullSemanticTokenOptions>(fullKey, full); insertVariant<bool, FullSemanticTokenOptions>(fullKey, full);
} }
Utils::optional<SemanticTokensClientCapabilities> TextDocumentClientCapabilities::semanticTokens() std::optional<SemanticTokensClientCapabilities> TextDocumentClientCapabilities::semanticTokens() const
const
{ {
return optionalValue<SemanticTokensClientCapabilities>(semanticTokensKey); return optionalValue<SemanticTokensClientCapabilities>(semanticTokensKey);
} }

View File

@@ -14,7 +14,10 @@ class LANGUAGESERVERPROTOCOL_EXPORT DynamicRegistrationCapabilities : public Jso
public: public:
using JsonObject::JsonObject; using JsonObject::JsonObject;
Utils::optional<bool> dynamicRegistration() const { return optionalValue<bool>(dynamicRegistrationKey); } std::optional<bool> dynamicRegistration() const
{
return optionalValue<bool>(dynamicRegistrationKey);
}
void setDynamicRegistration(bool dynamicRegistration) { insert(dynamicRegistrationKey, dynamicRegistration); } void setDynamicRegistration(bool dynamicRegistration) { insert(dynamicRegistrationKey, dynamicRegistration); }
void clearDynamicRegistration() { remove(dynamicRegistrationKey); } void clearDynamicRegistration() { remove(dynamicRegistrationKey); }
}; };
@@ -28,7 +31,7 @@ public:
* The client will send the `textDocument/semanticTokens/full/delta` * The client will send the `textDocument/semanticTokens/full/delta`
* request if the server provides a corresponding handler. * request if the server provides a corresponding handler.
*/ */
Utils::optional<bool> delta() const { return optionalValue<bool>(deltaKey); } std::optional<bool> delta() const { return optionalValue<bool>(deltaKey); }
void setDelta(bool delta) { insert(deltaKey, delta); } void setDelta(bool delta) { insert(deltaKey, delta); }
void clearDelta() { remove(deltaKey); } void clearDelta() { remove(deltaKey); }
}; };
@@ -56,7 +59,7 @@ 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<std::variant<bool, QJsonObject>> range() const; std::optional<std::variant<bool, QJsonObject>> range() const;
void setRange(const std::variant<bool, QJsonObject> &range); void setRange(const std::variant<bool, QJsonObject> &range);
void clearRange() { remove(rangeKey); } void clearRange() { remove(rangeKey); }
@@ -64,7 +67,7 @@ public:
* 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<std::variant<bool, FullSemanticTokenOptions>> full() const; std::optional<std::variant<bool, FullSemanticTokenOptions>> full() const;
void setFull(const std::variant<bool, FullSemanticTokenOptions> &full); void setFull(const std::variant<bool, FullSemanticTokenOptions> &full);
void clearFull() { remove(fullKey); } void clearFull() { remove(fullKey); }
}; };
@@ -85,12 +88,18 @@ public:
void setFormats(const QList<QString> &value) { insertArray(formatsKey, value); } void setFormats(const QList<QString> &value) { insertArray(formatsKey, value); }
/// Whether the client supports tokens that can overlap each other. /// Whether the client supports tokens that can overlap each other.
Utils::optional<bool> overlappingTokenSupport() const { return optionalValue<bool>(overlappingTokenSupportKey); } std::optional<bool> overlappingTokenSupport() const
{
return optionalValue<bool>(overlappingTokenSupportKey);
}
void setOverlappingTokenSupport(bool overlappingTokenSupport) { insert(overlappingTokenSupportKey, overlappingTokenSupport); } void setOverlappingTokenSupport(bool overlappingTokenSupport) { insert(overlappingTokenSupportKey, overlappingTokenSupport); }
void clearOverlappingTokenSupport() { remove(overlappingTokenSupportKey); } void clearOverlappingTokenSupport() { remove(overlappingTokenSupportKey); }
/// Whether the client supports tokens that can span multiple lines. /// Whether the client supports tokens that can span multiple lines.
Utils::optional<bool> multiLineTokenSupport() const { return optionalValue<bool>(multiLineTokenSupportKey); } std::optional<bool> multiLineTokenSupport() const
{
return optionalValue<bool>(multiLineTokenSupportKey);
}
void setMultiLineTokenSupport(bool multiLineTokenSupport) { insert(multiLineTokenSupportKey, multiLineTokenSupport); } void setMultiLineTokenSupport(bool multiLineTokenSupport) { insert(multiLineTokenSupportKey, multiLineTokenSupport); }
void clearMultiLineTokenSupport() { remove(multiLineTokenSupportKey); } void clearMultiLineTokenSupport() { remove(multiLineTokenSupportKey); }
@@ -117,18 +126,18 @@ public:
* the symbol kinds from `File` to `Array` as defined in * the symbol kinds from `File` to `Array` as defined in
* the initial version of the protocol. * the initial version of the protocol.
*/ */
Utils::optional<QList<SymbolKind>> valueSet() const; std::optional<QList<SymbolKind>> valueSet() const;
void setValueSet(const QList<SymbolKind> &valueSet); void setValueSet(const QList<SymbolKind> &valueSet);
void clearValueSet() { remove(valueSetKey); } void clearValueSet() { remove(valueSetKey); }
}; };
// Specific capabilities for the `SymbolKind` in the `workspace/symbol` request. // Specific capabilities for the `SymbolKind` in the `workspace/symbol` request.
Utils::optional<SymbolKindCapabilities> symbolKind() const std::optional<SymbolKindCapabilities> symbolKind() const
{ return optionalValue<SymbolKindCapabilities>(symbolKindKey); } { return optionalValue<SymbolKindCapabilities>(symbolKindKey); }
void setSymbolKind(const SymbolKindCapabilities &symbolKind) { insert(symbolKindKey, symbolKind); } void setSymbolKind(const SymbolKindCapabilities &symbolKind) { insert(symbolKindKey, symbolKind); }
void clearSymbolKind() { remove(symbolKindKey); } void clearSymbolKind() { remove(symbolKindKey); }
Utils::optional<bool> hierarchicalDocumentSymbolSupport() const std::optional<bool> hierarchicalDocumentSymbolSupport() const
{ return optionalValue<bool>(hierarchicalDocumentSymbolSupportKey); } { return optionalValue<bool>(hierarchicalDocumentSymbolSupportKey); }
void setHierarchicalDocumentSymbolSupport(bool hierarchicalDocumentSymbolSupport) void setHierarchicalDocumentSymbolSupport(bool hierarchicalDocumentSymbolSupport)
{ insert(hierarchicalDocumentSymbolSupportKey, hierarchicalDocumentSymbolSupport); } { insert(hierarchicalDocumentSymbolSupportKey, hierarchicalDocumentSymbolSupport); }
@@ -146,7 +155,7 @@ public:
using DynamicRegistrationCapabilities::DynamicRegistrationCapabilities; using DynamicRegistrationCapabilities::DynamicRegistrationCapabilities;
// The client supports sending will save notifications. // The client supports sending will save notifications.
Utils::optional<bool> willSave() const { return optionalValue<bool>(willSaveKey); } std::optional<bool> willSave() const { return optionalValue<bool>(willSaveKey); }
void setWillSave(bool willSave) { insert(willSaveKey, willSave); } void setWillSave(bool willSave) { insert(willSaveKey, willSave); }
void clearWillSave() { remove(willSaveKey); } void clearWillSave() { remove(willSaveKey); }
@@ -155,19 +164,19 @@ public:
* waits for a response providing text edits which will * waits for a response providing text edits which will
* be applied to the document before it is saved. * be applied to the document before it is saved.
*/ */
Utils::optional<bool> willSaveWaitUntil() const std::optional<bool> willSaveWaitUntil() const
{ return optionalValue<bool>(willSaveWaitUntilKey); } { return optionalValue<bool>(willSaveWaitUntilKey); }
void setWillSaveWaitUntil(bool willSaveWaitUntil) void setWillSaveWaitUntil(bool willSaveWaitUntil)
{ insert(willSaveWaitUntilKey, willSaveWaitUntil); } { insert(willSaveWaitUntilKey, willSaveWaitUntil); }
void clearWillSaveWaitUntil() { remove(willSaveWaitUntilKey); } void clearWillSaveWaitUntil() { remove(willSaveWaitUntilKey); }
// The client supports did save notifications. // The client supports did save notifications.
Utils::optional<bool> didSave() const { return optionalValue<bool>(didSaveKey); } std::optional<bool> didSave() const { return optionalValue<bool>(didSaveKey); }
void setDidSave(bool didSave) { insert(didSaveKey, didSave); } void setDidSave(bool didSave) { insert(didSaveKey, didSave); }
void clearDidSave() { remove(didSaveKey); } void clearDidSave() { remove(didSaveKey); }
}; };
Utils::optional<SynchronizationCapabilities> synchronization() const std::optional<SynchronizationCapabilities> synchronization() const
{ return optionalValue<SynchronizationCapabilities>(synchronizationKey); } { return optionalValue<SynchronizationCapabilities>(synchronizationKey); }
void setSynchronization(const SynchronizationCapabilities &synchronization) void setSynchronization(const SynchronizationCapabilities &synchronization)
{ insert(synchronizationKey, synchronization); } { insert(synchronizationKey, synchronization); }
@@ -191,14 +200,14 @@ public:
* the end of the snippet. Placeholders with equal identifiers are linked, * the end of the snippet. Placeholders with equal identifiers are linked,
* that is typing in one will update others too. * that is typing in one will update others too.
*/ */
Utils::optional<bool> snippetSupport() const std::optional<bool> snippetSupport() const
{ return optionalValue<bool>(snippetSupportKey); } { return optionalValue<bool>(snippetSupportKey); }
void setSnippetSupport(bool snippetSupport) void setSnippetSupport(bool snippetSupport)
{ insert(snippetSupportKey, snippetSupport); } { insert(snippetSupportKey, snippetSupport); }
void clearSnippetSupport() { remove(snippetSupportKey); } void clearSnippetSupport() { remove(snippetSupportKey); }
// Client supports commit characters on a completion item. // Client supports commit characters on a completion item.
Utils::optional<bool> commitCharacterSupport() const std::optional<bool> commitCharacterSupport() const
{ return optionalValue<bool>(commitCharacterSupportKey); } { return optionalValue<bool>(commitCharacterSupportKey); }
void setCommitCharacterSupport(bool commitCharacterSupport) void setCommitCharacterSupport(bool commitCharacterSupport)
{ insert(commitCharacterSupportKey, commitCharacterSupport); } { insert(commitCharacterSupportKey, commitCharacterSupport); }
@@ -208,13 +217,13 @@ public:
* Client supports the follow content formats for the documentation * Client supports the follow content formats for the documentation
* property. The order describes the preferred format of the client. * property. The order describes the preferred format of the client.
*/ */
Utils::optional<QList<MarkupKind>> documentationFormat() const; std::optional<QList<MarkupKind>> documentationFormat() const;
void setDocumentationFormat(const QList<MarkupKind> &documentationFormat); void setDocumentationFormat(const QList<MarkupKind> &documentationFormat);
void clearDocumentationFormat() { remove(documentationFormatKey); } void clearDocumentationFormat() { remove(documentationFormatKey); }
}; };
// The client supports the following `CompletionItem` specific capabilities. // The client supports the following `CompletionItem` specific capabilities.
Utils::optional<CompletionItemCapbilities> completionItem() const std::optional<CompletionItemCapbilities> completionItem() const
{ return optionalValue<CompletionItemCapbilities>(completionItemKey); } { return optionalValue<CompletionItemCapbilities>(completionItemKey); }
void setCompletionItem(const CompletionItemCapbilities &completionItem) void setCompletionItem(const CompletionItemCapbilities &completionItem)
{ insert(completionItemKey, completionItem); } { insert(completionItemKey, completionItem); }
@@ -235,12 +244,12 @@ public:
* the completion items kinds from `Text` to `Reference` as defined in * the completion items kinds from `Text` to `Reference` as defined in
* the initial version of the protocol. * the initial version of the protocol.
*/ */
Utils::optional<QList<CompletionItemKind::Kind>> valueSet() const; std::optional<QList<CompletionItemKind::Kind>> valueSet() const;
void setValueSet(const QList<CompletionItemKind::Kind> &valueSet); void setValueSet(const QList<CompletionItemKind::Kind> &valueSet);
void clearValueSet() { remove(valueSetKey); } void clearValueSet() { remove(valueSetKey); }
}; };
Utils::optional<CompletionItemKindCapabilities> completionItemKind() const std::optional<CompletionItemKindCapabilities> completionItemKind() const
{ return optionalValue<CompletionItemKindCapabilities>(completionItemKindKey); } { return optionalValue<CompletionItemKindCapabilities>(completionItemKindKey); }
void setCompletionItemKind(const CompletionItemKindCapabilities &completionItemKind) void setCompletionItemKind(const CompletionItemKindCapabilities &completionItemKind)
{ insert(completionItemKindKey, completionItemKind); } { insert(completionItemKindKey, completionItemKind); }
@@ -250,13 +259,16 @@ public:
* The client supports to send additional context information for a * The client supports to send additional context information for a
* `textDocument/completion` request. * `textDocument/completion` request.
*/ */
Utils::optional<bool> contextSupport() const { return optionalValue<bool>(contextSupportKey); } std::optional<bool> contextSupport() const
{
return optionalValue<bool>(contextSupportKey);
}
void setContextSupport(bool contextSupport) { insert(contextSupportKey, contextSupport); } void setContextSupport(bool contextSupport) { insert(contextSupportKey, contextSupport); }
void clearContextSupport() { remove(contextSupportKey); } void clearContextSupport() { remove(contextSupportKey); }
}; };
// Capabilities specific to the `textDocument/completion` // Capabilities specific to the `textDocument/completion`
Utils::optional<CompletionCapabilities> completion() const std::optional<CompletionCapabilities> completion() const
{ return optionalValue<CompletionCapabilities>(completionKey); } { return optionalValue<CompletionCapabilities>(completionKey); }
void setCompletion(const CompletionCapabilities &completion) void setCompletion(const CompletionCapabilities &completion)
{ insert(completionKey, completion); } { insert(completionKey, completion); }
@@ -270,12 +282,15 @@ public:
* Client supports the follow content formats for the content * Client supports the follow content formats for the content
* property. The order describes the preferred format of the client. * property. The order describes the preferred format of the client.
*/ */
Utils::optional<QList<MarkupKind>> contentFormat() const; std::optional<QList<MarkupKind>> contentFormat() const;
void setContentFormat(const QList<MarkupKind> &contentFormat); void setContentFormat(const QList<MarkupKind> &contentFormat);
void clearContentFormat() { remove(contentFormatKey); } void clearContentFormat() { remove(contentFormatKey); }
}; };
Utils::optional<HoverCapabilities> hover() const { return optionalValue<HoverCapabilities>(hoverKey); } std::optional<HoverCapabilities> hover() const
{
return optionalValue<HoverCapabilities>(hoverKey);
}
void setHover(const HoverCapabilities &hover) { insert(hoverKey, hover); } void setHover(const HoverCapabilities &hover) { insert(hoverKey, hover); }
void clearHover() { remove(hoverKey); } void clearHover() { remove(hoverKey); }
@@ -292,11 +307,11 @@ public:
* Client supports the follow content formats for the documentation * Client supports the follow content formats for the documentation
* property. The order describes the preferred format of the client. * property. The order describes the preferred format of the client.
*/ */
Utils::optional<QList<MarkupKind>> documentationFormat() const; std::optional<QList<MarkupKind>> documentationFormat() const;
void setDocumentationFormat(const QList<MarkupKind> &documentationFormat); void setDocumentationFormat(const QList<MarkupKind> &documentationFormat);
void clearDocumentationFormat() { remove(documentationFormatKey); } void clearDocumentationFormat() { remove(documentationFormatKey); }
Utils::optional<bool> activeParameterSupport() const std::optional<bool> activeParameterSupport() const
{ return optionalValue<bool>(activeParameterSupportKey); } { return optionalValue<bool>(activeParameterSupportKey); }
void setActiveParameterSupport(bool activeParameterSupport) void setActiveParameterSupport(bool activeParameterSupport)
{ insert(activeParameterSupportKey, activeParameterSupport); } { insert(activeParameterSupportKey, activeParameterSupport); }
@@ -304,7 +319,7 @@ public:
}; };
// The client supports the following `SignatureInformation` specific properties. // The client supports the following `SignatureInformation` specific properties.
Utils::optional<SignatureInformationCapabilities> signatureInformation() const std::optional<SignatureInformationCapabilities> signatureInformation() const
{ return optionalValue<SignatureInformationCapabilities>(signatureInformationKey); } { return optionalValue<SignatureInformationCapabilities>(signatureInformationKey); }
void setSignatureInformation(const SignatureInformationCapabilities &signatureInformation) void setSignatureInformation(const SignatureInformationCapabilities &signatureInformation)
{ insert(signatureInformationKey, signatureInformation); } { insert(signatureInformationKey, signatureInformation); }
@@ -312,56 +327,56 @@ public:
}; };
// Capabilities specific to the `textDocument/signatureHelp` // Capabilities specific to the `textDocument/signatureHelp`
Utils::optional<SignatureHelpCapabilities> signatureHelp() const std::optional<SignatureHelpCapabilities> signatureHelp() const
{ return optionalValue<SignatureHelpCapabilities>(signatureHelpKey); } { return optionalValue<SignatureHelpCapabilities>(signatureHelpKey); }
void setSignatureHelp(const SignatureHelpCapabilities &signatureHelp) void setSignatureHelp(const SignatureHelpCapabilities &signatureHelp)
{ insert(signatureHelpKey, signatureHelp); } { insert(signatureHelpKey, signatureHelp); }
void clearSignatureHelp() { remove(signatureHelpKey); } void clearSignatureHelp() { remove(signatureHelpKey); }
// Whether references supports dynamic registration. // Whether references supports dynamic registration.
Utils::optional<DynamicRegistrationCapabilities> references() const std::optional<DynamicRegistrationCapabilities> references() const
{ return optionalValue<DynamicRegistrationCapabilities>(referencesKey); } { return optionalValue<DynamicRegistrationCapabilities>(referencesKey); }
void setReferences(const DynamicRegistrationCapabilities &references) void setReferences(const DynamicRegistrationCapabilities &references)
{ insert(referencesKey, references); } { insert(referencesKey, references); }
void clearReferences() { remove(referencesKey); } void clearReferences() { remove(referencesKey); }
// Whether document highlight supports dynamic registration. // Whether document highlight supports dynamic registration.
Utils::optional<DynamicRegistrationCapabilities> documentHighlight() const std::optional<DynamicRegistrationCapabilities> documentHighlight() const
{ return optionalValue<DynamicRegistrationCapabilities>(documentHighlightKey); } { return optionalValue<DynamicRegistrationCapabilities>(documentHighlightKey); }
void setDocumentHighlight(const DynamicRegistrationCapabilities &documentHighlight) void setDocumentHighlight(const DynamicRegistrationCapabilities &documentHighlight)
{ insert(documentHighlightKey, documentHighlight); } { insert(documentHighlightKey, documentHighlight); }
void clearDocumentHighlight() { remove(documentHighlightKey); } void clearDocumentHighlight() { remove(documentHighlightKey); }
// Capabilities specific to the `textDocument/documentSymbol` // Capabilities specific to the `textDocument/documentSymbol`
Utils::optional<SymbolCapabilities> documentSymbol() const std::optional<SymbolCapabilities> documentSymbol() const
{ return optionalValue<SymbolCapabilities>(documentSymbolKey); } { return optionalValue<SymbolCapabilities>(documentSymbolKey); }
void setDocumentSymbol(const SymbolCapabilities &documentSymbol) void setDocumentSymbol(const SymbolCapabilities &documentSymbol)
{ insert(documentSymbolKey, documentSymbol); } { insert(documentSymbolKey, documentSymbol); }
void clearDocumentSymbol() { remove(documentSymbolKey); } void clearDocumentSymbol() { remove(documentSymbolKey); }
// Whether formatting supports dynamic registration. // Whether formatting supports dynamic registration.
Utils::optional<DynamicRegistrationCapabilities> formatting() const std::optional<DynamicRegistrationCapabilities> formatting() const
{ return optionalValue<DynamicRegistrationCapabilities>(formattingKey); } { return optionalValue<DynamicRegistrationCapabilities>(formattingKey); }
void setFormatting(const DynamicRegistrationCapabilities &formatting) void setFormatting(const DynamicRegistrationCapabilities &formatting)
{ insert(formattingKey, formatting); } { insert(formattingKey, formatting); }
void clearFormatting() { remove(formattingKey); } void clearFormatting() { remove(formattingKey); }
// Whether range formatting supports dynamic registration. // Whether range formatting supports dynamic registration.
Utils::optional<DynamicRegistrationCapabilities> rangeFormatting() const std::optional<DynamicRegistrationCapabilities> rangeFormatting() const
{ return optionalValue<DynamicRegistrationCapabilities>(rangeFormattingKey); } { return optionalValue<DynamicRegistrationCapabilities>(rangeFormattingKey); }
void setRangeFormatting(const DynamicRegistrationCapabilities &rangeFormatting) void setRangeFormatting(const DynamicRegistrationCapabilities &rangeFormatting)
{ insert(rangeFormattingKey, rangeFormatting); } { insert(rangeFormattingKey, rangeFormatting); }
void clearRangeFormatting() { remove(rangeFormattingKey); } void clearRangeFormatting() { remove(rangeFormattingKey); }
// Whether on type formatting supports dynamic registration. // Whether on type formatting supports dynamic registration.
Utils::optional<DynamicRegistrationCapabilities> onTypeFormatting() const std::optional<DynamicRegistrationCapabilities> onTypeFormatting() const
{ return optionalValue<DynamicRegistrationCapabilities>(onTypeFormattingKey); } { return optionalValue<DynamicRegistrationCapabilities>(onTypeFormattingKey); }
void setOnTypeFormatting(const DynamicRegistrationCapabilities &onTypeFormatting) void setOnTypeFormatting(const DynamicRegistrationCapabilities &onTypeFormatting)
{ insert(onTypeFormattingKey, onTypeFormatting); } { insert(onTypeFormattingKey, onTypeFormatting); }
void clearOnTypeFormatting() { remove(onTypeFormattingKey); } void clearOnTypeFormatting() { remove(onTypeFormattingKey); }
// Whether definition supports dynamic registration. // Whether definition supports dynamic registration.
Utils::optional<DynamicRegistrationCapabilities> definition() const std::optional<DynamicRegistrationCapabilities> definition() const
{ return optionalValue<DynamicRegistrationCapabilities>(definitionKey); } { return optionalValue<DynamicRegistrationCapabilities>(definitionKey); }
void setDefinition(const DynamicRegistrationCapabilities &definition) void setDefinition(const DynamicRegistrationCapabilities &definition)
{ insert(definitionKey, definition); } { insert(definitionKey, definition); }
@@ -372,7 +387,7 @@ public:
* the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` * the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`
* return value for the corresponding server capability as well. * return value for the corresponding server capability as well.
*/ */
Utils::optional<DynamicRegistrationCapabilities> typeDefinition() const std::optional<DynamicRegistrationCapabilities> typeDefinition() const
{ return optionalValue<DynamicRegistrationCapabilities>(typeDefinitionKey); } { return optionalValue<DynamicRegistrationCapabilities>(typeDefinitionKey); }
void setTypeDefinition(const DynamicRegistrationCapabilities &typeDefinition) void setTypeDefinition(const DynamicRegistrationCapabilities &typeDefinition)
{ insert(typeDefinitionKey, typeDefinition); } { insert(typeDefinitionKey, typeDefinition); }
@@ -383,7 +398,7 @@ public:
* the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` * the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`
* return value for the corresponding server capability as well. * return value for the corresponding server capability as well.
*/ */
Utils::optional<DynamicRegistrationCapabilities> implementation() const std::optional<DynamicRegistrationCapabilities> implementation() const
{ return optionalValue<DynamicRegistrationCapabilities>(implementationKey); } { return optionalValue<DynamicRegistrationCapabilities>(implementationKey); }
void setImplementation(const DynamicRegistrationCapabilities &implementation) void setImplementation(const DynamicRegistrationCapabilities &implementation)
{ insert(implementationKey, implementation); } { insert(implementationKey, implementation); }
@@ -421,7 +436,7 @@ public:
bool isValid() const override { return contains(codeActionKindKey); } bool isValid() const override { return contains(codeActionKindKey); }
}; };
Utils::optional<CodeActionLiteralSupport> codeActionLiteralSupport() const std::optional<CodeActionLiteralSupport> codeActionLiteralSupport() const
{ return optionalValue<CodeActionLiteralSupport>(codeActionLiteralSupportKey); } { return optionalValue<CodeActionLiteralSupport>(codeActionLiteralSupportKey); }
void setCodeActionLiteralSupport(const CodeActionLiteralSupport &codeActionLiteralSupport) void setCodeActionLiteralSupport(const CodeActionLiteralSupport &codeActionLiteralSupport)
{ insert(codeActionLiteralSupportKey, codeActionLiteralSupport); } { insert(codeActionLiteralSupportKey, codeActionLiteralSupport); }
@@ -429,21 +444,21 @@ public:
}; };
// Whether code action supports dynamic registration. // Whether code action supports dynamic registration.
Utils::optional<CodeActionCapabilities> codeAction() const std::optional<CodeActionCapabilities> codeAction() const
{ return optionalValue<CodeActionCapabilities>(codeActionKey); } { return optionalValue<CodeActionCapabilities>(codeActionKey); }
void setCodeAction(const CodeActionCapabilities &codeAction) void setCodeAction(const CodeActionCapabilities &codeAction)
{ insert(codeActionKey, codeAction); } { insert(codeActionKey, codeAction); }
void clearCodeAction() { remove(codeActionKey); } void clearCodeAction() { remove(codeActionKey); }
// Whether code lens supports dynamic registration. // Whether code lens supports dynamic registration.
Utils::optional<DynamicRegistrationCapabilities> codeLens() const std::optional<DynamicRegistrationCapabilities> codeLens() const
{ return optionalValue<DynamicRegistrationCapabilities>(codeLensKey); } { return optionalValue<DynamicRegistrationCapabilities>(codeLensKey); }
void setCodeLens(const DynamicRegistrationCapabilities &codeLens) void setCodeLens(const DynamicRegistrationCapabilities &codeLens)
{ insert(codeLensKey, codeLens); } { insert(codeLensKey, codeLens); }
void clearCodeLens() { remove(codeLensKey); } void clearCodeLens() { remove(codeLensKey); }
// Whether document link supports dynamic registration. // Whether document link supports dynamic registration.
Utils::optional<DynamicRegistrationCapabilities> documentLink() const std::optional<DynamicRegistrationCapabilities> documentLink() const
{ return optionalValue<DynamicRegistrationCapabilities>(documentLinkKey); } { return optionalValue<DynamicRegistrationCapabilities>(documentLinkKey); }
void setDocumentLink(const DynamicRegistrationCapabilities &documentLink) void setDocumentLink(const DynamicRegistrationCapabilities &documentLink)
{ insert(documentLinkKey, documentLink); } { insert(documentLinkKey, documentLink); }
@@ -454,7 +469,7 @@ public:
* the client supports the new `(ColorProviderOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions)` * the client supports the new `(ColorProviderOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions)`
* return value for the corresponding server capability as well. * return value for the corresponding server capability as well.
*/ */
Utils::optional<DynamicRegistrationCapabilities> colorProvider() const std::optional<DynamicRegistrationCapabilities> colorProvider() const
{ return optionalValue<DynamicRegistrationCapabilities>(colorProviderKey); } { return optionalValue<DynamicRegistrationCapabilities>(colorProviderKey); }
void setColorProvider(const DynamicRegistrationCapabilities &colorProvider) void setColorProvider(const DynamicRegistrationCapabilities &colorProvider)
{ insert(colorProviderKey, colorProvider); } { insert(colorProviderKey, colorProvider); }
@@ -471,19 +486,22 @@ public:
* @since version 3.12.0 * @since version 3.12.0
*/ */
Utils::optional<bool> prepareSupport() const { return optionalValue<bool>(prepareSupportKey); } std::optional<bool> prepareSupport() const
{
return optionalValue<bool>(prepareSupportKey);
}
void setPrepareSupport(bool prepareSupport) { insert(prepareSupportKey, prepareSupport); } void setPrepareSupport(bool prepareSupport) { insert(prepareSupportKey, prepareSupport); }
void clearPrepareSupport() { remove(prepareSupportKey); } void clearPrepareSupport() { remove(prepareSupportKey); }
}; };
// Whether rename supports dynamic registration. // Whether rename supports dynamic registration.
Utils::optional<RenameClientCapabilities> rename() const std::optional<RenameClientCapabilities> rename() const
{ return optionalValue<RenameClientCapabilities>(renameKey); } { return optionalValue<RenameClientCapabilities>(renameKey); }
void setRename(const RenameClientCapabilities &rename) void setRename(const RenameClientCapabilities &rename)
{ insert(renameKey, rename); } { insert(renameKey, rename); }
void clearRename() { remove(renameKey); } void clearRename() { remove(renameKey); }
Utils::optional<SemanticTokensClientCapabilities> semanticTokens() const; std::optional<SemanticTokensClientCapabilities> semanticTokens() const;
void setSemanticTokens(const SemanticTokensClientCapabilities &semanticTokens); void setSemanticTokens(const SemanticTokensClientCapabilities &semanticTokens);
void clearSemanticTokens() { remove(semanticTokensKey); } void clearSemanticTokens() { remove(semanticTokensKey); }
}; };
@@ -501,7 +519,7 @@ public:
* and is useful for situation where a server for example detect a project * and is useful for situation where a server for example detect a project
* wide change that requires such a calculation. * wide change that requires such a calculation.
*/ */
Utils::optional<bool> refreshSupport() const { return optionalValue<bool>(refreshSupportKey); } std::optional<bool> refreshSupport() const { return optionalValue<bool>(refreshSupportKey); }
void setRefreshSupport(bool refreshSupport) { insert(refreshSupportKey, refreshSupport); } void setRefreshSupport(bool refreshSupport) { insert(refreshSupportKey, refreshSupport); }
void clearRefreshSupport() { remove(refreshSupportKey); } void clearRefreshSupport() { remove(refreshSupportKey); }
}; };
@@ -516,7 +534,7 @@ public:
* The client supports applying batch edits to the workspace by supporting the request * The client supports applying batch edits to the workspace by supporting the request
* 'workspace/applyEdit' * 'workspace/applyEdit'
*/ */
Utils::optional<bool> applyEdit() const { return optionalValue<bool>(applyEditKey); } std::optional<bool> applyEdit() const { return optionalValue<bool>(applyEditKey); }
void setApplyEdit(bool applyEdit) { insert(applyEditKey, applyEdit); } void setApplyEdit(bool applyEdit) { insert(applyEditKey, applyEdit); }
void clearApplyEdit() { remove(applyEditKey); } void clearApplyEdit() { remove(applyEditKey); }
@@ -526,7 +544,7 @@ public:
using JsonObject::JsonObject; using JsonObject::JsonObject;
// The client supports versioned document changes in `WorkspaceEdit`s // The client supports versioned document changes in `WorkspaceEdit`s
Utils::optional<bool> documentChanges() const std::optional<bool> documentChanges() const
{ return optionalValue<bool>(documentChangesKey); } { return optionalValue<bool>(documentChangesKey); }
void setDocumentChanges(bool documentChanges) void setDocumentChanges(bool documentChanges)
{ insert(documentChangesKey, documentChanges); } { insert(documentChangesKey, documentChanges); }
@@ -534,52 +552,52 @@ public:
}; };
// Capabilities specific to `WorkspaceEdit`s // Capabilities specific to `WorkspaceEdit`s
Utils::optional<WorkspaceEditCapabilities> workspaceEdit() const std::optional<WorkspaceEditCapabilities> workspaceEdit() const
{ return optionalValue<WorkspaceEditCapabilities>(workspaceEditKey); } { return optionalValue<WorkspaceEditCapabilities>(workspaceEditKey); }
void setWorkspaceEdit(const WorkspaceEditCapabilities &workspaceEdit) void setWorkspaceEdit(const WorkspaceEditCapabilities &workspaceEdit)
{ insert(workspaceEditKey, workspaceEdit); } { insert(workspaceEditKey, workspaceEdit); }
void clearWorkspaceEdit() { remove(workspaceEditKey); } void clearWorkspaceEdit() { remove(workspaceEditKey); }
// Capabilities specific to the `workspace/didChangeConfiguration` notification. // Capabilities specific to the `workspace/didChangeConfiguration` notification.
Utils::optional<DynamicRegistrationCapabilities> didChangeConfiguration() const std::optional<DynamicRegistrationCapabilities> didChangeConfiguration() const
{ return optionalValue<DynamicRegistrationCapabilities>(didChangeConfigurationKey); } { return optionalValue<DynamicRegistrationCapabilities>(didChangeConfigurationKey); }
void setDidChangeConfiguration(const DynamicRegistrationCapabilities &didChangeConfiguration) void setDidChangeConfiguration(const DynamicRegistrationCapabilities &didChangeConfiguration)
{ insert(didChangeConfigurationKey, didChangeConfiguration); } { insert(didChangeConfigurationKey, didChangeConfiguration); }
void clearDidChangeConfiguration() { remove(didChangeConfigurationKey); } void clearDidChangeConfiguration() { remove(didChangeConfigurationKey); }
// Capabilities specific to the `workspace/didChangeWatchedFiles` notification. // Capabilities specific to the `workspace/didChangeWatchedFiles` notification.
Utils::optional<DynamicRegistrationCapabilities> didChangeWatchedFiles() const std::optional<DynamicRegistrationCapabilities> didChangeWatchedFiles() const
{ return optionalValue<DynamicRegistrationCapabilities>(didChangeWatchedFilesKey); } { return optionalValue<DynamicRegistrationCapabilities>(didChangeWatchedFilesKey); }
void setDidChangeWatchedFiles(const DynamicRegistrationCapabilities &didChangeWatchedFiles) void setDidChangeWatchedFiles(const DynamicRegistrationCapabilities &didChangeWatchedFiles)
{ insert(didChangeWatchedFilesKey, didChangeWatchedFiles); } { insert(didChangeWatchedFilesKey, didChangeWatchedFiles); }
void clearDidChangeWatchedFiles() { remove(didChangeWatchedFilesKey); } void clearDidChangeWatchedFiles() { remove(didChangeWatchedFilesKey); }
// Specific capabilities for the `SymbolKind` in the `workspace/symbol` request. // Specific capabilities for the `SymbolKind` in the `workspace/symbol` request.
Utils::optional<SymbolCapabilities> symbol() const std::optional<SymbolCapabilities> symbol() const
{ return optionalValue<SymbolCapabilities>(symbolKey); } { return optionalValue<SymbolCapabilities>(symbolKey); }
void setSymbol(const SymbolCapabilities &symbol) { insert(symbolKey, symbol); } void setSymbol(const SymbolCapabilities &symbol) { insert(symbolKey, symbol); }
void clearSymbol() { remove(symbolKey); } void clearSymbol() { remove(symbolKey); }
// Capabilities specific to the `workspace/executeCommand` request. // Capabilities specific to the `workspace/executeCommand` request.
Utils::optional<DynamicRegistrationCapabilities> executeCommand() const std::optional<DynamicRegistrationCapabilities> executeCommand() const
{ return optionalValue<DynamicRegistrationCapabilities>(executeCommandKey); } { return optionalValue<DynamicRegistrationCapabilities>(executeCommandKey); }
void setExecuteCommand(const DynamicRegistrationCapabilities &executeCommand) void setExecuteCommand(const DynamicRegistrationCapabilities &executeCommand)
{ insert(executeCommandKey, executeCommand); } { insert(executeCommandKey, executeCommand); }
void clearExecuteCommand() { remove(executeCommandKey); } void clearExecuteCommand() { remove(executeCommandKey); }
// The client has support for workspace folders. Since 3.6.0 // The client has support for workspace folders. Since 3.6.0
Utils::optional<bool> workspaceFolders() const std::optional<bool> workspaceFolders() const
{ return optionalValue<bool>(workspaceFoldersKey); } { return optionalValue<bool>(workspaceFoldersKey); }
void setWorkspaceFolders(bool workspaceFolders) void setWorkspaceFolders(bool workspaceFolders)
{ insert(workspaceFoldersKey, workspaceFolders); } { insert(workspaceFoldersKey, workspaceFolders); }
void clearWorkspaceFolders() { remove(workspaceFoldersKey); } void clearWorkspaceFolders() { remove(workspaceFoldersKey); }
// The client supports `workspace/configuration` requests. Since 3.6.0 // The client supports `workspace/configuration` requests. Since 3.6.0
Utils::optional<bool> configuration() const { return optionalValue<bool>(configurationKey); } std::optional<bool> configuration() const { return optionalValue<bool>(configurationKey); }
void setConfiguration(bool configuration) { insert(configurationKey, configuration); } void setConfiguration(bool configuration) { insert(configurationKey, configuration); }
void clearConfiguration() { remove(configurationKey); } void clearConfiguration() { remove(configurationKey); }
Utils::optional<SemanticTokensWorkspaceClientCapabilities> semanticTokens() const std::optional<SemanticTokensWorkspaceClientCapabilities> semanticTokens() const
{ return optionalValue<SemanticTokensWorkspaceClientCapabilities>(semanticTokensKey); } { return optionalValue<SemanticTokensWorkspaceClientCapabilities>(semanticTokensKey); }
void setSemanticTokens(const SemanticTokensWorkspaceClientCapabilities &semanticTokens) void setSemanticTokens(const SemanticTokensWorkspaceClientCapabilities &semanticTokens)
{ insert(semanticTokensKey, semanticTokens); } { insert(semanticTokensKey, semanticTokens); }
@@ -597,7 +615,7 @@ public:
* in the request specific server capabilities. * in the request specific server capabilities.
* *
*/ */
Utils::optional<bool> workDoneProgress() const std::optional<bool> workDoneProgress() const
{ return optionalValue<bool>(workDoneProgressKey); } { return optionalValue<bool>(workDoneProgressKey); }
void setWorkDoneProgress(bool workDoneProgress) void setWorkDoneProgress(bool workDoneProgress)
{ insert(workDoneProgressKey, workDoneProgress); } { insert(workDoneProgressKey, workDoneProgress); }
@@ -613,21 +631,21 @@ public:
using JsonObject::JsonObject; using JsonObject::JsonObject;
// Workspace specific client capabilities. // Workspace specific client capabilities.
Utils::optional<WorkspaceClientCapabilities> workspace() const std::optional<WorkspaceClientCapabilities> workspace() const
{ return optionalValue<WorkspaceClientCapabilities>(workspaceKey); } { return optionalValue<WorkspaceClientCapabilities>(workspaceKey); }
void setWorkspace(const WorkspaceClientCapabilities &workspace) void setWorkspace(const WorkspaceClientCapabilities &workspace)
{ insert(workspaceKey, workspace); } { insert(workspaceKey, workspace); }
void clearWorkspace() { remove(workspaceKey); } void clearWorkspace() { remove(workspaceKey); }
// Text document specific client capabilities. // Text document specific client capabilities.
Utils::optional<TextDocumentClientCapabilities> textDocument() const std::optional<TextDocumentClientCapabilities> textDocument() const
{ return optionalValue<TextDocumentClientCapabilities>(textDocumentKey); } { return optionalValue<TextDocumentClientCapabilities>(textDocumentKey); }
void setTextDocument(const TextDocumentClientCapabilities &textDocument) void setTextDocument(const TextDocumentClientCapabilities &textDocument)
{ insert(textDocumentKey, textDocument); } { insert(textDocumentKey, textDocument); }
void clearTextDocument() { remove(textDocumentKey); } void clearTextDocument() { remove(textDocumentKey); }
// Window specific client capabilities. // Window specific client capabilities.
Utils::optional<WindowClientClientCapabilities> window() const std::optional<WindowClientClientCapabilities> window() const
{ return optionalValue<WindowClientClientCapabilities>(windowKey); } { return optionalValue<WindowClientClientCapabilities>(windowKey); }
void setWindow(const WindowClientClientCapabilities &window) void setWindow(const WindowClientClientCapabilities &window)
{ insert(windowKey, window); } { insert(windowKey, window); }

View File

@@ -12,22 +12,22 @@ CompletionRequest::CompletionRequest(const CompletionParams &params)
: Request(methodName, params) : Request(methodName, params)
{ } { }
Utils::optional<MarkupOrString> CompletionItem::documentation() const std::optional<MarkupOrString> CompletionItem::documentation() const
{ {
QJsonValue documentation = value(documentationKey); QJsonValue documentation = value(documentationKey);
if (documentation.isUndefined()) if (documentation.isUndefined())
return Utils::nullopt; return std::nullopt;
return MarkupOrString(documentation); return MarkupOrString(documentation);
} }
Utils::optional<CompletionItem::InsertTextFormat> CompletionItem::insertTextFormat() const std::optional<CompletionItem::InsertTextFormat> CompletionItem::insertTextFormat() const
{ {
if (Utils::optional<int> value = optionalValue<int>(insertTextFormatKey)) if (std::optional<int> value = optionalValue<int>(insertTextFormatKey))
return Utils::make_optional(CompletionItem::InsertTextFormat(*value)); return std::make_optional(CompletionItem::InsertTextFormat(*value));
return Utils::nullopt; return std::nullopt;
} }
Utils::optional<QList<CompletionItem::CompletionItemTag>> CompletionItem::tags() const std::optional<QList<CompletionItem::CompletionItemTag>> CompletionItem::tags() const
{ {
if (const auto value = optionalValue<QJsonArray>(tagsKey)) { if (const auto value = optionalValue<QJsonArray>(tagsKey)) {
QList<CompletionItemTag> tags; QList<CompletionItemTag> tags;

View File

@@ -43,7 +43,7 @@ public:
* The trigger character (a single character) that has trigger code complete. * The trigger character (a single character) that has trigger code complete.
* Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter` * Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`
*/ */
Utils::optional<QString> triggerCharacter() const std::optional<QString> triggerCharacter() const
{ return optionalValue<QString>(triggerCharacterKey); } { return optionalValue<QString>(triggerCharacterKey); }
void setTriggerCharacter(const QString &triggerCharacter) void setTriggerCharacter(const QString &triggerCharacter)
{ insert(triggerCharacterKey, triggerCharacter); } { insert(triggerCharacterKey, triggerCharacter); }
@@ -56,7 +56,7 @@ public:
* The completion context. This is only available it the client specifies * The completion context. This is only available it the client specifies
* to send this using `ClientCapabilities.textDocument.completion.contextSupport === true` * to send this using `ClientCapabilities.textDocument.completion.contextSupport === true`
*/ */
Utils::optional<CompletionContext> context() const std::optional<CompletionContext> context() const
{ return optionalValue<CompletionContext>(contextKey); } { return optionalValue<CompletionContext>(contextKey); }
void setContext(const CompletionContext &context) void setContext(const CompletionContext &context)
{ insert(contextKey, context); } { insert(contextKey, context); }
@@ -79,30 +79,30 @@ public:
void setLabel(const QString &label) { insert(labelKey, label); } void setLabel(const QString &label) { insert(labelKey, label); }
/// The kind of this completion item. Based of the kind an icon is chosen by the editor. /// The kind of this completion item. Based of the kind an icon is chosen by the editor.
Utils::optional<int> kind() const { return optionalValue<int>(kindKey); } std::optional<int> kind() const { return optionalValue<int>(kindKey); }
void setKind(int kind) { insert(kindKey, kind); } void setKind(int kind) { insert(kindKey, kind); }
void clearKind() { remove(kindKey); } void clearKind() { remove(kindKey); }
/// A human-readable string with additional information about this item, like type information. /// A human-readable string with additional information about this item, like type information.
Utils::optional<QString> detail() const { return optionalValue<QString>(detailKey); } std::optional<QString> detail() const { return optionalValue<QString>(detailKey); }
void setDetail(const QString &detail) { insert(detailKey, detail); } void setDetail(const QString &detail) { insert(detailKey, detail); }
void clearDetail() { remove(detailKey); } void clearDetail() { remove(detailKey); }
/// A human-readable string that represents a doc-comment. /// A human-readable string that represents a doc-comment.
Utils::optional<MarkupOrString> documentation() const; std::optional<MarkupOrString> documentation() const;
void setDocumentation(const MarkupOrString &documentation) void setDocumentation(const MarkupOrString &documentation)
{ insert(documentationKey, documentation.toJson()); } { insert(documentationKey, documentation.toJson()); }
void cleatDocumentation() { remove(documentationKey); } void cleatDocumentation() { remove(documentationKey); }
/// A string that should be used when comparing this item /// A string that should be used when comparing this item
/// with other items. When `falsy` the label is used. /// with other items. When `falsy` the label is used.
Utils::optional<QString> sortText() const { return optionalValue<QString>(sortTextKey); } std::optional<QString> sortText() const { return optionalValue<QString>(sortTextKey); }
void setSortText(const QString &sortText) { insert(sortTextKey, sortText); } void setSortText(const QString &sortText) { insert(sortTextKey, sortText); }
void clearSortText() { remove(sortTextKey); } void clearSortText() { remove(sortTextKey); }
/// A string that should be used when filtering a set of /// A string that should be used when filtering a set of
/// completion items. When `falsy` the label is used. /// completion items. When `falsy` the label is used.
Utils::optional<QString> filterText() const { return optionalValue<QString>(filterTextKey); } std::optional<QString> filterText() const { return optionalValue<QString>(filterTextKey); }
void setFilterText(const QString &filterText) { insert(filterTextKey, filterText); } void setFilterText(const QString &filterText) { insert(filterTextKey, filterText); }
void clearFilterText() { remove(filterTextKey); } void clearFilterText() { remove(filterTextKey); }
@@ -119,7 +119,7 @@ public:
* *
* @deprecated Use textEdit instead. * @deprecated Use textEdit instead.
*/ */
Utils::optional<QString> insertText() const { return optionalValue<QString>(insertTextKey); } std::optional<QString> insertText() const { return optionalValue<QString>(insertTextKey); }
void setInsertText(const QString &insertText) { insert(insertTextKey, insertText); } void setInsertText(const QString &insertText) { insert(insertTextKey, insertText); }
void clearInsertText() { remove(insertTextKey); } void clearInsertText() { remove(insertTextKey); }
@@ -140,7 +140,7 @@ public:
/// The format of the insert text. The format applies to both the `insertText` property /// The format of the insert text. The format applies to both the `insertText` property
/// and the `newText` property of a provided `textEdit`. /// and the `newText` property of a provided `textEdit`.
Utils::optional<InsertTextFormat> insertTextFormat() const; std::optional<InsertTextFormat> insertTextFormat() const;
void setInsertTextFormat(const InsertTextFormat &insertTextFormat) void setInsertTextFormat(const InsertTextFormat &insertTextFormat)
{ insert(insertTextFormatKey, insertTextFormat); } { insert(insertTextFormatKey, insertTextFormat); }
void clearInsertTextFormat() { remove(insertTextFormatKey); } void clearInsertTextFormat() { remove(insertTextFormatKey); }
@@ -152,7 +152,7 @@ public:
* *Note:* The range of the edit must be a single line range and it must contain the position at which completion * *Note:* The range of the edit must be a single line range and it must contain the position at which completion
* has been requested. * has been requested.
*/ */
Utils::optional<TextEdit> textEdit() const { return optionalValue<TextEdit>(textEditKey); } std::optional<TextEdit> textEdit() const { return optionalValue<TextEdit>(textEditKey); }
void setTextEdit(const TextEdit &textEdit) { insert(textEditKey, textEdit); } void setTextEdit(const TextEdit &textEdit) { insert(textEditKey, textEdit); }
void clearTextEdit() { remove(textEditKey); } void clearTextEdit() { remove(textEditKey); }
@@ -161,7 +161,7 @@ public:
* selecting this completion. Edits must not overlap with the main edit * selecting this completion. Edits must not overlap with the main edit
* nor with themselves. * nor with themselves.
*/ */
Utils::optional<QList<TextEdit>> additionalTextEdits() const std::optional<QList<TextEdit>> additionalTextEdits() const
{ return optionalArray<TextEdit>(additionalTextEditsKey); } { return optionalArray<TextEdit>(additionalTextEditsKey); }
void setAdditionalTextEdits(const QList<TextEdit> &additionalTextEdits) void setAdditionalTextEdits(const QList<TextEdit> &additionalTextEdits)
{ insertArray(additionalTextEditsKey, additionalTextEdits); } { insertArray(additionalTextEditsKey, additionalTextEdits); }
@@ -172,7 +172,7 @@ public:
* then type that character. *Note* that all commit characters should have `length=1` and that superfluous * then type that character. *Note* that all commit characters should have `length=1` and that superfluous
* characters will be ignored. * characters will be ignored.
*/ */
Utils::optional<QList<QString>> commitCharacters() const std::optional<QList<QString>> commitCharacters() const
{ return optionalArray<QString>(commitCharactersKey); } { return optionalArray<QString>(commitCharactersKey); }
void setCommitCharacters(const QList<QString> &commitCharacters) void setCommitCharacters(const QList<QString> &commitCharacters)
{ insertArray(commitCharactersKey, commitCharacters); } { insertArray(commitCharactersKey, commitCharacters); }
@@ -183,7 +183,7 @@ public:
* additional modifications to the current document should be described with the * additional modifications to the current document should be described with the
* additionalTextEdits-property. * additionalTextEdits-property.
*/ */
Utils::optional<Command> command() const { return optionalValue<Command>(commandKey); } std::optional<Command> command() const { return optionalValue<Command>(commandKey); }
void setCommand(const Command &command) { insert(commandKey, command); } void setCommand(const Command &command) { insert(commandKey, command); }
void clearCommand() { remove(commandKey); } void clearCommand() { remove(commandKey); }
@@ -191,7 +191,7 @@ public:
* An data entry field that is preserved on a completion item between * An data entry field that is preserved on a completion item between
* a completion and a completion resolve request. * a completion and a completion resolve request.
*/ */
Utils::optional<QJsonValue> data() const { return optionalValue<QJsonValue>(dataKey); } std::optional<QJsonValue> data() const { return optionalValue<QJsonValue>(dataKey); }
void setData(const QJsonValue &data) { insert(dataKey, data); } void setData(const QJsonValue &data) { insert(dataKey, data); }
void clearData() { remove(dataKey); } void clearData() { remove(dataKey); }
@@ -208,13 +208,13 @@ public:
* Tags for this completion item. * Tags for this completion item.
* @since 3.15.0 * @since 3.15.0
*/ */
Utils::optional<QList<CompletionItemTag>> tags() const; std::optional<QList<CompletionItemTag>> tags() const;
/** /**
* Indicates if this item is deprecated. * Indicates if this item is deprecated.
* @deprecated Use `tags` instead if supported. * @deprecated Use `tags` instead if supported.
*/ */
Utils::optional<bool> deprecated() const { return optionalValue<bool>(deprecatedKey); } std::optional<bool> deprecated() const { return optionalValue<bool>(deprecatedKey); }
bool isValid() const override { return contains(labelKey); } bool isValid() const override { return contains(labelKey); }
}; };
@@ -232,7 +232,7 @@ public:
void setIsIncomplete(bool isIncomplete) { insert(isIncompleteKey, isIncomplete); } void setIsIncomplete(bool isIncomplete) { insert(isIncompleteKey, isIncomplete); }
/// The completion items. /// The completion items.
Utils::optional<QList<CompletionItem>> items() const { return array<CompletionItem>(itemsKey); } std::optional<QList<CompletionItem>> items() const { return array<CompletionItem>(itemsKey); }
void setItems(const QList<CompletionItem> &items) { insertArray(itemsKey, items); } void setItems(const QList<CompletionItem> &items) { insertArray(itemsKey, items); }
void clearItems() { remove(itemsKey); } void clearItems() { remove(itemsKey); }

View File

@@ -20,7 +20,7 @@ public:
void setDiagnostics(const QList<Diagnostic> &diagnostics) void setDiagnostics(const QList<Diagnostic> &diagnostics)
{ insertArray(diagnosticsKey, diagnostics); } { insertArray(diagnosticsKey, diagnostics); }
Utils::optional<int> version() const { return optionalValue<int>(versionKey); } std::optional<int> version() const { return optionalValue<int>(versionKey); }
void setVersion(int version) { insert(versionKey, version); } void setVersion(int version) { insert(versionKey, version); }
void clearVersion() { remove(versionKey); } void clearVersion() { remove(versionKey); }

View File

@@ -32,7 +32,7 @@ QString Trace::toString() const
} }
#undef RETURN_CASE #undef RETURN_CASE
Utils::optional<QList<MarkupKind>> std::optional<QList<MarkupKind>>
TextDocumentClientCapabilities::CompletionCapabilities::CompletionItemCapbilities:: TextDocumentClientCapabilities::CompletionCapabilities::CompletionItemCapbilities::
documentationFormat() const documentationFormat() const
{ {
@@ -59,16 +59,16 @@ TextDocumentClientCapabilities::CompletionCapabilities::CompletionItemKindCapabi
CompletionItemKind::TypeParameter}); CompletionItemKind::TypeParameter});
} }
Utils::optional<QList<CompletionItemKind::Kind>> std::optional<QList<CompletionItemKind::Kind>>
TextDocumentClientCapabilities::CompletionCapabilities::CompletionItemKindCapabilities:: TextDocumentClientCapabilities::CompletionCapabilities::CompletionItemKindCapabilities::
valueSet() const valueSet() const
{ {
if (Utils::optional<QList<int>> array = optionalArray<int>(valueSetKey)) { if (std::optional<QList<int>> array = optionalArray<int>(valueSetKey)) {
return Utils::make_optional(Utils::transform(*array, [] (int value) { return std::make_optional(Utils::transform(*array, [](int value) {
return static_cast<CompletionItemKind::Kind>(value); return static_cast<CompletionItemKind::Kind>(value);
})); }));
} }
return Utils::nullopt; return std::nullopt;
} }
void void
@@ -78,7 +78,7 @@ setValueSet(const QList<CompletionItemKind::Kind> &valueSet)
insert(valueSetKey, enumArrayToJsonArray<CompletionItemKind::Kind>(valueSet)); insert(valueSetKey, enumArrayToJsonArray<CompletionItemKind::Kind>(valueSet));
} }
Utils::optional<QList<MarkupKind> > TextDocumentClientCapabilities::HoverCapabilities::contentFormat() const std::optional<QList<MarkupKind> > TextDocumentClientCapabilities::HoverCapabilities::contentFormat() const
{ {
return optionalArray<MarkupKind>(contentFormatKey); return optionalArray<MarkupKind>(contentFormatKey);
} }
@@ -88,7 +88,7 @@ void TextDocumentClientCapabilities::HoverCapabilities::setContentFormat(const Q
insertArray(contentFormatKey, contentFormat); insertArray(contentFormatKey, contentFormat);
} }
Utils::optional<QList<MarkupKind>> std::optional<QList<MarkupKind>>
TextDocumentClientCapabilities::SignatureHelpCapabilities::SignatureInformationCapabilities:: TextDocumentClientCapabilities::SignatureHelpCapabilities::SignatureInformationCapabilities::
documentationFormat() const documentationFormat() const
{ {
@@ -110,20 +110,20 @@ InitializeParams::InitializeParams()
setTrace(s_trace); setTrace(s_trace);
} }
Utils::optional<QJsonObject> InitializeParams::initializationOptions() const std::optional<QJsonObject> InitializeParams::initializationOptions() const
{ {
const QJsonValue &optionsValue = value(initializationOptionsKey); const QJsonValue &optionsValue = value(initializationOptionsKey);
if (optionsValue.isObject()) if (optionsValue.isObject())
return optionsValue.toObject(); return optionsValue.toObject();
return Utils::nullopt; return std::nullopt;
} }
Utils::optional<Trace> InitializeParams::trace() const std::optional<Trace> InitializeParams::trace() const
{ {
const QJsonValue &traceValue = value(traceKey); const QJsonValue &traceValue = value(traceKey);
if (traceValue.isUndefined()) if (traceValue.isUndefined())
return Utils::nullopt; return std::nullopt;
return Utils::make_optional(Trace(traceValue.toString())); return std::make_optional(Trace(traceValue.toString()));
} }
InitializeRequest::InitializeRequest(const InitializeParams &params) InitializeRequest::InitializeRequest(const InitializeParams &params)

View File

@@ -39,7 +39,7 @@ public:
QString name() const { return typedValue<QString>(nameKey); } QString name() const { return typedValue<QString>(nameKey); }
void setName(const QString &name) { insert(nameKey, name); } void setName(const QString &name) { insert(nameKey, name); }
Utils::optional<QString> version() const { return optionalValue<QString>(versionKey); } std::optional<QString> version() const { return optionalValue<QString>(versionKey); }
void setVersion(const QString &version) { insert(versionKey, version); } void setVersion(const QString &version) { insert(versionKey, version); }
void clearVersion() { remove(versionKey); } void clearVersion() { remove(versionKey); }
}; };
@@ -65,7 +65,7 @@ public:
* *
* @deprecated in favor of rootUri. * @deprecated in favor of rootUri.
*/ */
Utils::optional<LanguageClientValue<QString>> rootPath() const std::optional<LanguageClientValue<QString>> rootPath() const
{ return optionalClientValue<QString>(rootPathKey); } { return optionalClientValue<QString>(rootPathKey); }
void setRootPath(const LanguageClientValue<QString> &path) void setRootPath(const LanguageClientValue<QString> &path)
{ insert(rootPathKey, path); } { insert(rootPathKey, path); }
@@ -82,7 +82,7 @@ public:
{ insert(rootUriKey, uri); } { insert(rootUriKey, uri); }
// User provided initialization options. // User provided initialization options.
Utils::optional<QJsonObject> initializationOptions() const; std::optional<QJsonObject> initializationOptions() const;
void setInitializationOptions(const QJsonObject &options) void setInitializationOptions(const QJsonObject &options)
{ insert(initializationOptionsKey, options); } { insert(initializationOptionsKey, options); }
void clearInitializationOptions() { remove(initializationOptionsKey); } void clearInitializationOptions() { remove(initializationOptionsKey); }
@@ -93,7 +93,7 @@ public:
{ insert(capabilitiesKey, capabilities); } { insert(capabilitiesKey, capabilities); }
// The initial trace setting. If omitted trace is disabled ('off'). // The initial trace setting. If omitted trace is disabled ('off').
Utils::optional<Trace> trace() const; std::optional<Trace> trace() const;
void setTrace(Trace trace) { insert(traceKey, trace.toString()); } void setTrace(Trace trace) { insert(traceKey, trace.toString()); }
void clearTrace() { remove(traceKey); } void clearTrace() { remove(traceKey); }
@@ -105,13 +105,13 @@ public:
* *
* Since 3.6.0 * Since 3.6.0
*/ */
Utils::optional<LanguageClientArray<WorkSpaceFolder>> workspaceFolders() const std::optional<LanguageClientArray<WorkSpaceFolder>> workspaceFolders() const
{ return optionalClientArray<WorkSpaceFolder>(workspaceFoldersKey); } { return optionalClientArray<WorkSpaceFolder>(workspaceFoldersKey); }
void setWorkSpaceFolders(const LanguageClientArray<WorkSpaceFolder> &folders) void setWorkSpaceFolders(const LanguageClientArray<WorkSpaceFolder> &folders)
{ insert(workspaceFoldersKey, folders.toJson()); } { insert(workspaceFoldersKey, folders.toJson()); }
void clearWorkSpaceFolders() { remove(workspaceFoldersKey); } void clearWorkSpaceFolders() { remove(workspaceFoldersKey); }
Utils::optional<ClientInfo> clientInfo() const { return optionalValue<ClientInfo>(clientInfoKey); } std::optional<ClientInfo> clientInfo() const { return optionalValue<ClientInfo>(clientInfoKey); }
void setClientInfo(const ClientInfo &clientInfo) { insert(clientInfoKey, clientInfo); } void setClientInfo(const ClientInfo &clientInfo) { insert(clientInfoKey, clientInfo); }
void clearClientInfo() { remove(clientInfoKey); } void clearClientInfo() { remove(clientInfoKey); }
@@ -137,7 +137,7 @@ public:
using JsonObject::JsonObject; using JsonObject::JsonObject;
QString name() const { return typedValue<QString>(nameKey); } QString name() const { return typedValue<QString>(nameKey); }
Utils::optional<QString> version() const { return optionalValue<QString>(versionKey); } std::optional<QString> version() const { return optionalValue<QString>(versionKey); }
bool isValid() const override { return contains(nameKey); } bool isValid() const override { return contains(nameKey); }
}; };
@@ -152,7 +152,7 @@ public:
void setCapabilities(const ServerCapabilities &capabilities) void setCapabilities(const ServerCapabilities &capabilities)
{ insert(capabilitiesKey, capabilities); } { insert(capabilitiesKey, capabilities); }
Utils::optional<ServerInfo> serverInfo() const std::optional<ServerInfo> serverInfo() const
{ return optionalValue<ServerInfo>(serverInfoKey); } { return optionalValue<ServerInfo>(serverInfoKey); }
bool isValid() const override { return contains(capabilitiesKey); } bool isValid() const override { return contains(capabilitiesKey); }

View File

@@ -65,19 +65,19 @@ protected:
template<typename T> template<typename T>
T typedValue(const QStringView key) const; T typedValue(const QStringView key) const;
template<typename T> template<typename T>
Utils::optional<T> optionalValue(const QStringView key) const; std::optional<T> optionalValue(const QStringView key) const;
template<typename T> template<typename T>
LanguageClientValue<T> clientValue(const QStringView key) const; LanguageClientValue<T> clientValue(const QStringView key) const;
template<typename T> template<typename T>
Utils::optional<LanguageClientValue<T>> optionalClientValue(const QStringView key) const; std::optional<LanguageClientValue<T>> optionalClientValue(const QStringView key) const;
template<typename T> template<typename T>
QList<T> array(const QStringView key) const; QList<T> array(const QStringView key) const;
template<typename T> template<typename T>
Utils::optional<QList<T>> optionalArray(const QStringView key) const; std::optional<QList<T>> optionalArray(const QStringView key) const;
template<typename T> template<typename T>
LanguageClientArray<T> clientArray(const QStringView key) const; LanguageClientArray<T> clientArray(const QStringView key) const;
template<typename T> template<typename T>
Utils::optional<LanguageClientArray<T>> optionalClientArray(const QStringView key) const; std::optional<LanguageClientArray<T>> optionalClientArray(const QStringView key) const;
template<typename T> template<typename T>
void insertArray(const QStringView key, const QList<T> &array); void insertArray(const QStringView key, const QList<T> &array);
template<typename> template<typename>
@@ -107,10 +107,10 @@ T JsonObject::typedValue(const QStringView key) const
} }
template<typename T> template<typename T>
Utils::optional<T> JsonObject::optionalValue(const QStringView key) const std::optional<T> JsonObject::optionalValue(const QStringView key) const
{ {
const QJsonValue &val = value(key); const QJsonValue &val = value(key);
return val.isUndefined() ? Utils::nullopt : Utils::make_optional(fromJsonValue<T>(val)); return val.isUndefined() ? std::nullopt : std::make_optional(fromJsonValue<T>(val));
} }
template<typename T> template<typename T>
@@ -120,26 +120,26 @@ LanguageClientValue<T> JsonObject::clientValue(const QStringView key) const
} }
template<typename T> template<typename T>
Utils::optional<LanguageClientValue<T>> JsonObject::optionalClientValue(const QStringView key) const std::optional<LanguageClientValue<T>> JsonObject::optionalClientValue(const QStringView key) const
{ {
return contains(key) ? Utils::make_optional(clientValue<T>(key)) : Utils::nullopt; return contains(key) ? std::make_optional(clientValue<T>(key)) : std::nullopt;
} }
template<typename T> template<typename T>
QList<T> JsonObject::array(const QStringView key) const QList<T> JsonObject::array(const QStringView key) const
{ {
if (const Utils::optional<QList<T>> &array = optionalArray<T>(key)) if (const std::optional<QList<T>> &array = optionalArray<T>(key))
return *array; return *array;
qCDebug(conversionLog) << QString("Expected array under %1 in:").arg(key) << *this; qCDebug(conversionLog) << QString("Expected array under %1 in:").arg(key) << *this;
return {}; return {};
} }
template<typename T> template<typename T>
Utils::optional<QList<T>> JsonObject::optionalArray(const QStringView key) const std::optional<QList<T>> JsonObject::optionalArray(const QStringView key) const
{ {
const QJsonValue &jsonValue = value(key); const QJsonValue &jsonValue = value(key);
if (jsonValue.isUndefined()) if (jsonValue.isUndefined())
return Utils::nullopt; return std::nullopt;
return Utils::transform<QList<T>>(jsonValue.toArray(), &fromJsonValue<T>); return Utils::transform<QList<T>>(jsonValue.toArray(), &fromJsonValue<T>);
} }
@@ -150,11 +150,11 @@ LanguageClientArray<T> JsonObject::clientArray(const QStringView key) const
} }
template<typename T> template<typename T>
Utils::optional<LanguageClientArray<T>> JsonObject::optionalClientArray(const QStringView key) const std::optional<LanguageClientArray<T>> JsonObject::optionalClientArray(const QStringView key) const
{ {
const QJsonValue &val = value(key); const QJsonValue &val = value(key);
return !val.isUndefined() ? Utils::make_optional(LanguageClientArray<T>(value(key))) return !val.isUndefined() ? std::make_optional(LanguageClientArray<T>(value(key)))
: Utils::nullopt; : std::nullopt;
} }
template<typename T> template<typename T>

View File

@@ -7,7 +7,6 @@
#include "lsptypes.h" #include "lsptypes.h"
#include "jsonkeys.h" #include "jsonkeys.h"
#include <utils/optional.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QDebug> #include <QDebug>
@@ -18,6 +17,7 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QUuid> #include <QUuid>
#include <optional>
#include <variant> #include <variant>
namespace LanguageServerProtocol { namespace LanguageServerProtocol {
@@ -112,8 +112,7 @@ public:
const QString parseError() { return m_parseError; } const QString parseError() { return m_parseError; }
virtual Utils::optional<ResponseHandler> responseHandler() const virtual std::optional<ResponseHandler> responseHandler() const { return std::nullopt; }
{ return Utils::nullopt; }
BaseMessage toBaseMessage() const BaseMessage toBaseMessage() const
{ return BaseMessage(jsonRpcMimeType(), toRawData()); } { return BaseMessage(jsonRpcMimeType(), toRawData()); }
@@ -143,10 +142,10 @@ public:
void setMethod(const QString &method) void setMethod(const QString &method)
{ m_jsonObject.insert(methodKey, method); } { m_jsonObject.insert(methodKey, method); }
Utils::optional<Params> params() const std::optional<Params> params() const
{ {
const QJsonValue &params = m_jsonObject.value(paramsKey); const QJsonValue &params = m_jsonObject.value(paramsKey);
return params.isUndefined() ? Utils::nullopt : Utils::make_optional(Params(params)); return params.isUndefined() ? std::nullopt : std::make_optional(Params(params));
} }
void setParams(const Params &params) void setParams(const Params &params)
{ m_jsonObject.insert(paramsKey, QJsonValue(params)); } { m_jsonObject.insert(paramsKey, QJsonValue(params)); }
@@ -187,7 +186,7 @@ public:
void setMethod(const QString &method) void setMethod(const QString &method)
{ m_jsonObject.insert(methodKey, method); } { m_jsonObject.insert(methodKey, method); }
Utils::optional<std::nullptr_t> params() const std::optional<std::nullptr_t> params() const
{ return nullptr; } { return nullptr; }
void setParams(const std::nullptr_t &/*params*/) void setParams(const std::nullptr_t &/*params*/)
{ m_jsonObject.insert(paramsKey, QJsonValue::Null); } { m_jsonObject.insert(paramsKey, QJsonValue::Null); }
@@ -216,7 +215,7 @@ public:
QString message() const { return typedValue<QString>(messageKey); } QString message() const { return typedValue<QString>(messageKey); }
void setMessage(const QString &message) { insert(messageKey, message); } void setMessage(const QString &message) { insert(messageKey, message); }
Utils::optional<Error> data() const { return optionalValue<Error>(dataKey); } std::optional<Error> data() const { return optionalValue<Error>(dataKey); }
void setData(const Error &data) { insert(dataKey, data); } void setData(const Error &data) { insert(dataKey, data); }
void clearData() { remove(dataKey); } void clearData() { remove(dataKey); }
@@ -275,22 +274,21 @@ public:
void setId(MessageId id) void setId(MessageId id)
{ this->m_jsonObject.insert(idKey, id); } { this->m_jsonObject.insert(idKey, id); }
Utils::optional<Result> result() const std::optional<Result> result() const
{ {
const QJsonValue &result = m_jsonObject.value(resultKey); const QJsonValue &result = m_jsonObject.value(resultKey);
if (result.isUndefined()) if (result.isUndefined())
return Utils::nullopt; return std::nullopt;
return Utils::make_optional(Result(result)); return std::make_optional(Result(result));
} }
void setResult(const Result &result) { m_jsonObject.insert(resultKey, QJsonValue(result)); } void setResult(const Result &result) { m_jsonObject.insert(resultKey, QJsonValue(result)); }
void clearResult() { m_jsonObject.remove(resultKey); } void clearResult() { m_jsonObject.remove(resultKey); }
using Error = ResponseError<ErrorDataType>; using Error = ResponseError<ErrorDataType>;
Utils::optional<Error> error() const std::optional<Error> error() const
{ {
const QJsonValue &val = m_jsonObject.value(errorKey); const QJsonValue &val = m_jsonObject.value(errorKey);
return val.isUndefined() ? Utils::nullopt return val.isUndefined() ? std::nullopt : std::make_optional(fromJsonValue<Error>(val));
: Utils::make_optional(fromJsonValue<Error>(val));
} }
void setError(const Error &error) void setError(const Error &error)
{ m_jsonObject.insert(errorKey, QJsonValue(error)); } { m_jsonObject.insert(errorKey, QJsonValue(error)); }
@@ -312,20 +310,18 @@ public:
void setId(MessageId id) void setId(MessageId id)
{ this->m_jsonObject.insert(idKey, id); } { this->m_jsonObject.insert(idKey, id); }
Utils::optional<std::nullptr_t> result() const std::optional<std::nullptr_t> result() const
{ {
return m_jsonObject.value(resultKey).isNull() ? Utils::make_optional(nullptr) return m_jsonObject.value(resultKey).isNull() ? std::make_optional(nullptr) : std::nullopt;
: Utils::nullopt;
} }
void setResult(const std::nullptr_t &) { m_jsonObject.insert(resultKey, QJsonValue::Null); } void setResult(const std::nullptr_t &) { m_jsonObject.insert(resultKey, QJsonValue::Null); }
void clearResult() { m_jsonObject.remove(resultKey); } void clearResult() { m_jsonObject.remove(resultKey); }
using Error = ResponseError<ErrorDataType>; using Error = ResponseError<ErrorDataType>;
Utils::optional<Error> error() const std::optional<Error> error() const
{ {
const QJsonValue &val = m_jsonObject.value(errorKey); const QJsonValue &val = m_jsonObject.value(errorKey);
return val.isUndefined() ? Utils::nullopt return val.isUndefined() ? std::nullopt : std::make_optional(fromJsonValue<Error>(val));
: Utils::make_optional(fromJsonValue<Error>(val));
} }
void setError(const Error &error) void setError(const Error &error)
{ m_jsonObject.insert(errorKey, QJsonValue(error)); } { m_jsonObject.insert(errorKey, QJsonValue(error)); }
@@ -357,7 +353,7 @@ public:
void setResponseCallback(const ResponseCallback &callback) void setResponseCallback(const ResponseCallback &callback)
{ m_callBack = callback; } { m_callBack = callback; }
Utils::optional<ResponseHandler> responseHandler() const final std::optional<ResponseHandler> responseHandler() const final
{ {
QElapsedTimer timer; QElapsedTimer timer;
timer.start(); timer.start();
@@ -369,7 +365,7 @@ public:
callback(Response(message.toJsonObject())); callback(Response(message.toJsonObject()));
}; };
return Utils::make_optional(ResponseHandler{id(), callback}); return std::make_optional(ResponseHandler{id(), callback});
} }
bool isValid(QString *errorMessage) const override bool isValid(QString *errorMessage) const override

View File

@@ -49,11 +49,11 @@ HoverRequest::HoverRequest(const TextDocumentPositionParams &params)
: Request(methodName, params) : Request(methodName, params)
{ } { }
Utils::optional<MarkupOrString> ParameterInformation::documentation() const std::optional<MarkupOrString> ParameterInformation::documentation() const
{ {
QJsonValue documentation = value(documentationKey); QJsonValue documentation = value(documentationKey);
if (documentation.isUndefined()) if (documentation.isUndefined())
return Utils::nullopt; return std::nullopt;
return MarkupOrString(documentation); return MarkupOrString(documentation);
} }
@@ -81,7 +81,7 @@ DocumentSymbolsRequest::DocumentSymbolsRequest(const DocumentSymbolParams &param
: Request(methodName, params) : Request(methodName, params)
{ } { }
Utils::optional<QList<CodeActionKind> > CodeActionParams::CodeActionContext::only() const std::optional<QList<CodeActionKind> > CodeActionParams::CodeActionContext::only() const
{ {
return optionalArray<CodeActionKind>(onlyKey); return optionalArray<CodeActionKind>(onlyKey);
} }
@@ -180,16 +180,16 @@ RenameRequest::RenameRequest(const RenameParams &params)
: Request(methodName, params) : Request(methodName, params)
{ } { }
Utils::optional<DocumentUri> DocumentLink::target() const std::optional<DocumentUri> DocumentLink::target() const
{ {
if (Utils::optional<QString> optionalTarget = optionalValue<QString>(targetKey)) if (std::optional<QString> optionalTarget = optionalValue<QString>(targetKey))
return Utils::make_optional(DocumentUri::fromProtocol(*optionalTarget)); return std::make_optional(DocumentUri::fromProtocol(*optionalTarget));
return Utils::nullopt; return std::nullopt;
} }
Utils::optional<QJsonValue> DocumentLink::data() const std::optional<QJsonValue> DocumentLink::data() const
{ {
return contains(dataKey) ? Utils::make_optional(value(dataKey)) : Utils::nullopt; return contains(dataKey) ? std::make_optional(value(dataKey)) : std::nullopt;
} }
TextDocumentParams::TextDocumentParams() TextDocumentParams::TextDocumentParams()
@@ -376,9 +376,9 @@ PrepareRenameResult::PrepareRenameResult(const QJsonValue &val)
} }
} }
Utils::optional<QJsonValue> CodeLens::data() const std::optional<QJsonValue> CodeLens::data() const
{ {
return contains(dataKey) ? Utils::make_optional(value(dataKey)) : Utils::nullopt; return contains(dataKey) ? std::make_optional(value(dataKey)) : std::nullopt;
} }
HoverResult::HoverResult(const QJsonValue &value) HoverResult::HoverResult(const QJsonValue &value)

View File

@@ -72,7 +72,7 @@ public:
HoverContent content() const; HoverContent content() const;
void setContent(const HoverContent &content); void setContent(const HoverContent &content);
Utils::optional<Range> range() const { return optionalValue<Range>(rangeKey); } std::optional<Range> range() const { return optionalValue<Range>(rangeKey); }
void setRange(const Range &range) { insert(rangeKey, range); } void setRange(const Range &range) { insert(rangeKey, range); }
void clearRange() { remove(rangeKey); } void clearRange() { remove(rangeKey); }
@@ -109,7 +109,7 @@ public:
QString label() const { return typedValue<QString>(labelKey); } QString label() const { return typedValue<QString>(labelKey); }
void setLabel(const QString &label) { insert(labelKey, label); } void setLabel(const QString &label) { insert(labelKey, label); }
Utils::optional<MarkupOrString> documentation() const; std::optional<MarkupOrString> documentation() const;
void setDocumentation(const MarkupOrString &documentation) void setDocumentation(const MarkupOrString &documentation)
{ insert(documentationKey, documentation.toJson()); } { insert(documentationKey, documentation.toJson()); }
void clearDocumentation() { remove(documentationKey); } void clearDocumentation() { remove(documentationKey); }
@@ -127,13 +127,13 @@ class LANGUAGESERVERPROTOCOL_EXPORT SignatureInformation : public ParameterInfor
public: public:
using ParameterInformation::ParameterInformation; using ParameterInformation::ParameterInformation;
Utils::optional<QList<ParameterInformation>> parameters() const std::optional<QList<ParameterInformation>> parameters() const
{ return optionalArray<ParameterInformation>(parametersKey); } { return optionalArray<ParameterInformation>(parametersKey); }
void setParameters(const QList<ParameterInformation> &parameters) void setParameters(const QList<ParameterInformation> &parameters)
{ insertArray(parametersKey, parameters); } { insertArray(parametersKey, parameters); }
void clearParameters() { remove(parametersKey); } void clearParameters() { remove(parametersKey); }
Utils::optional<int> activeParameter() const { return optionalValue<int>(activeParameterKey); } std::optional<int> activeParameter() const { return optionalValue<int>(activeParameterKey); }
void setActiveParameter(int activeParameter) { insert(activeParameterKey, activeParameter); } void setActiveParameter(int activeParameter) { insert(activeParameterKey, activeParameter); }
void clearActiveParameter() { remove(activeParameterKey); } void clearActiveParameter() { remove(activeParameterKey); }
}; };
@@ -163,7 +163,7 @@ public:
* In future version of the protocol this property might become * In future version of the protocol this property might become
* mandatory to better express this. * mandatory to better express this.
*/ */
Utils::optional<int> activeSignature() const { return optionalValue<int>(activeSignatureKey); } std::optional<int> activeSignature() const { return optionalValue<int>(activeSignatureKey); }
void setActiveSignature(int activeSignature) { insert(activeSignatureKey, activeSignature); } void setActiveSignature(int activeSignature) { insert(activeSignatureKey, activeSignature); }
void clearActiveSignature() { remove(activeSignatureKey); } void clearActiveSignature() { remove(activeSignatureKey); }
@@ -176,7 +176,7 @@ public:
* mandatory to better express the active parameter if the * mandatory to better express the active parameter if the
* active signature does have any. * active signature does have any.
*/ */
Utils::optional<int> activeParameter() const { return optionalValue<int>(activeParameterKey); } std::optional<int> activeParameter() const { return optionalValue<int>(activeParameterKey); }
void setActiveParameter(int activeParameter) { insert(activeParameterKey, activeParameter); } void setActiveParameter(int activeParameter) { insert(activeParameterKey, activeParameter); }
void clearActiveParameter() { remove(activeParameterKey); } void clearActiveParameter() { remove(activeParameterKey); }
@@ -277,7 +277,7 @@ public:
Range range() const { return typedValue<Range>(rangeKey); } Range range() const { return typedValue<Range>(rangeKey); }
void setRange(const Range &range) { insert(rangeKey, range); } void setRange(const Range &range) { insert(rangeKey, range); }
Utils::optional<int> kind() const { return optionalValue<int>(kindKey); } std::optional<int> kind() const { return optionalValue<int>(kindKey); }
void setKind(int kind) { insert(kindKey, kind); } void setKind(int kind) { insert(kindKey, kind); }
void clearKind() { remove(kindKey); } void clearKind() { remove(kindKey); }
@@ -394,7 +394,7 @@ public:
void setDiagnostics(const QList<Diagnostic> &diagnostics) void setDiagnostics(const QList<Diagnostic> &diagnostics)
{ insertArray(diagnosticsKey, diagnostics); } { insertArray(diagnosticsKey, diagnostics); }
Utils::optional<QList<CodeActionKind>> only() const; std::optional<QList<CodeActionKind>> only() const;
void setOnly(const QList<CodeActionKind> &only); void setOnly(const QList<CodeActionKind> &only);
void clearOnly() { remove(onlyKey); } void clearOnly() { remove(onlyKey); }
@@ -424,21 +424,21 @@ public:
QString title() const { return typedValue<QString>(titleKey); } QString title() const { return typedValue<QString>(titleKey); }
void setTitle(QString title) { insert(titleKey, title); } void setTitle(QString title) { insert(titleKey, title); }
Utils::optional<CodeActionKind> kind() const { return optionalValue<CodeActionKind>(kindKey); } std::optional<CodeActionKind> kind() const { return optionalValue<CodeActionKind>(kindKey); }
void setKind(const CodeActionKind &kind) { insert(kindKey, kind); } void setKind(const CodeActionKind &kind) { insert(kindKey, kind); }
void clearKind() { remove(kindKey); } void clearKind() { remove(kindKey); }
Utils::optional<QList<Diagnostic>> diagnostics() const std::optional<QList<Diagnostic>> diagnostics() const
{ return optionalArray<Diagnostic>(diagnosticsKey); } { return optionalArray<Diagnostic>(diagnosticsKey); }
void setDiagnostics(const QList<Diagnostic> &diagnostics) void setDiagnostics(const QList<Diagnostic> &diagnostics)
{ insertArray(diagnosticsKey, diagnostics); } { insertArray(diagnosticsKey, diagnostics); }
void clearDiagnostics() { remove(diagnosticsKey); } void clearDiagnostics() { remove(diagnosticsKey); }
Utils::optional<WorkspaceEdit> edit() const { return optionalValue<WorkspaceEdit>(editKey); } std::optional<WorkspaceEdit> edit() const { return optionalValue<WorkspaceEdit>(editKey); }
void setEdit(const WorkspaceEdit &edit) { insert(editKey, edit); } void setEdit(const WorkspaceEdit &edit) { insert(editKey, edit); }
void clearEdit() { remove(editKey); } void clearEdit() { remove(editKey); }
Utils::optional<Command> command() const { return optionalValue<Command>(commandKey); } std::optional<Command> command() const { return optionalValue<Command>(commandKey); }
void setCommand(const Command &command) { insert(commandKey, command); } void setCommand(const Command &command) { insert(commandKey, command); }
void clearCommand() { remove(commandKey); } void clearCommand() { remove(commandKey); }
@@ -472,11 +472,11 @@ public:
Range range() const { return typedValue<Range>(rangeKey); } Range range() const { return typedValue<Range>(rangeKey); }
void setRange(const Range &range) { insert(rangeKey, range); } void setRange(const Range &range) { insert(rangeKey, range); }
Utils::optional<Command> command() const { return optionalValue<Command>(commandKey); } std::optional<Command> command() const { return optionalValue<Command>(commandKey); }
void setCommand(const Command &command) { insert(commandKey, command); } void setCommand(const Command &command) { insert(commandKey, command); }
void clearCommand() { remove(commandKey); } void clearCommand() { remove(commandKey); }
Utils::optional<QJsonValue> data() const; std::optional<QJsonValue> data() const;
void setData(const QJsonValue &data) { insert(dataKey, data); } void setData(const QJsonValue &data) { insert(dataKey, data); }
void clearData() { remove(dataKey); } void clearData() { remove(dataKey); }
@@ -509,11 +509,11 @@ public:
Range range() const { return typedValue<Range>(rangeKey); } Range range() const { return typedValue<Range>(rangeKey); }
void setRange(const Range &range) { insert(rangeKey, range); } void setRange(const Range &range) { insert(rangeKey, range); }
Utils::optional<DocumentUri> target() const; std::optional<DocumentUri> target() const;
void setTarget(const DocumentUri &target) { insert(targetKey, target.toString()); } void setTarget(const DocumentUri &target) { insert(targetKey, target.toString()); }
void clearTarget() { remove(targetKey); } void clearTarget() { remove(targetKey); }
Utils::optional<QJsonValue> data() const; std::optional<QJsonValue> data() const;
void setData(const QJsonValue &data) { insert(dataKey, data); } void setData(const QJsonValue &data) { insert(dataKey, data); }
void clearData() { remove(dataKey); } void clearData() { remove(dataKey); }
@@ -614,11 +614,11 @@ public:
QString label() const { return typedValue<QString>(labelKey); } QString label() const { return typedValue<QString>(labelKey); }
void setLabel(const QString &label) { insert(labelKey, label); } void setLabel(const QString &label) { insert(labelKey, label); }
Utils::optional<TextEdit> textEdit() const { return optionalValue<TextEdit>(textEditKey); } std::optional<TextEdit> textEdit() const { return optionalValue<TextEdit>(textEditKey); }
void setTextEdit(const TextEdit &textEdit) { insert(textEditKey, textEdit); } void setTextEdit(const TextEdit &textEdit) { insert(textEditKey, textEdit); }
void clearTextEdit() { remove(textEditKey); } void clearTextEdit() { remove(textEditKey); }
Utils::optional<QList<TextEdit>> additionalTextEdits() const std::optional<QList<TextEdit>> additionalTextEdits() const
{ return optionalArray<TextEdit>(additionalTextEditsKey); } { return optionalArray<TextEdit>(additionalTextEditsKey); }
void setAdditionalTextEdits(const QList<TextEdit> &additionalTextEdits) void setAdditionalTextEdits(const QList<TextEdit> &additionalTextEdits)
{ insertArray(additionalTextEditsKey, additionalTextEdits); } { insertArray(additionalTextEditsKey, additionalTextEdits); }
@@ -659,19 +659,19 @@ public:
bool insertSpace() const { return typedValue<bool>(insertSpaceKey); } bool insertSpace() const { return typedValue<bool>(insertSpaceKey); }
void setInsertSpace(bool insertSpace) { insert(insertSpaceKey, insertSpace); } void setInsertSpace(bool insertSpace) { insert(insertSpaceKey, insertSpace); }
Utils::optional<bool> trimTrailingWhitespace() const std::optional<bool> trimTrailingWhitespace() const
{ return optionalValue<bool>(trimTrailingWhitespaceKey); } { return optionalValue<bool>(trimTrailingWhitespaceKey); }
void setTrimTrailingWhitespace(bool trimTrailingWhitespace) void setTrimTrailingWhitespace(bool trimTrailingWhitespace)
{ insert(trimTrailingWhitespaceKey, trimTrailingWhitespace); } { insert(trimTrailingWhitespaceKey, trimTrailingWhitespace); }
void clearTrimTrailingWhitespace() { remove(trimTrailingWhitespaceKey); } void clearTrimTrailingWhitespace() { remove(trimTrailingWhitespaceKey); }
Utils::optional<bool> insertFinalNewline() const std::optional<bool> insertFinalNewline() const
{ return optionalValue<bool>(insertFinalNewlineKey); } { return optionalValue<bool>(insertFinalNewlineKey); }
void setInsertFinalNewline(bool insertFinalNewline) void setInsertFinalNewline(bool insertFinalNewline)
{ insert(insertFinalNewlineKey, insertFinalNewline); } { insert(insertFinalNewlineKey, insertFinalNewline); }
void clearInsertFinalNewline() { remove(insertFinalNewlineKey); } void clearInsertFinalNewline() { remove(insertFinalNewlineKey); }
Utils::optional<bool> trimFinalNewlines() const std::optional<bool> trimFinalNewlines() const
{ return optionalValue<bool>(trimFinalNewlinesKey); } { return optionalValue<bool>(trimFinalNewlinesKey); }
void setTrimFinalNewlines(bool trimFinalNewlines) void setTrimFinalNewlines(bool trimFinalNewlines)
{ insert(trimFinalNewlinesKey, trimFinalNewlines); } { insert(trimFinalNewlinesKey, trimFinalNewlines); }

View File

@@ -17,23 +17,23 @@
namespace LanguageServerProtocol { namespace LanguageServerProtocol {
Utils::optional<DiagnosticSeverity> Diagnostic::severity() const std::optional<DiagnosticSeverity> Diagnostic::severity() const
{ {
if (auto val = optionalValue<int>(severityKey)) if (auto val = optionalValue<int>(severityKey))
return Utils::make_optional(static_cast<DiagnosticSeverity>(*val)); return std::make_optional(static_cast<DiagnosticSeverity>(*val));
return Utils::nullopt; return std::nullopt;
} }
Utils::optional<Diagnostic::Code> Diagnostic::code() const std::optional<Diagnostic::Code> Diagnostic::code() const
{ {
QJsonValue codeValue = value(codeKey); QJsonValue codeValue = value(codeKey);
auto it = find(codeKey); auto it = find(codeKey);
if (codeValue.isUndefined()) if (codeValue.isUndefined())
return Utils::nullopt; return std::nullopt;
QJsonValue::Type type = it.value().type(); QJsonValue::Type type = it.value().type();
if (type != QJsonValue::String && type != QJsonValue::Double) if (type != QJsonValue::String && type != QJsonValue::Double)
return Utils::make_optional(Code(QString())); return std::make_optional(Code(QString()));
return Utils::make_optional(codeValue.isDouble() ? Code(codeValue.toInt()) return std::make_optional(codeValue.isDouble() ? Code(codeValue.toInt())
: Code(codeValue.toString())); : Code(codeValue.toString()));
} }
@@ -42,16 +42,16 @@ void Diagnostic::setCode(const Diagnostic::Code &code)
insertVariant<int, QString>(codeKey, code); insertVariant<int, QString>(codeKey, code);
} }
Utils::optional<WorkspaceEdit::Changes> WorkspaceEdit::changes() const std::optional<WorkspaceEdit::Changes> WorkspaceEdit::changes() const
{ {
auto it = find(changesKey); auto it = find(changesKey);
if (it == end()) if (it == end())
return Utils::nullopt; return std::nullopt;
const QJsonObject &changesObject = it.value().toObject(); const QJsonObject &changesObject = it.value().toObject();
Changes changesResult; Changes changesResult;
for (const QString &key : changesObject.keys()) for (const QString &key : changesObject.keys())
changesResult[DocumentUri::fromProtocol(key)] = LanguageClientArray<TextEdit>(changesObject.value(key)).toList(); changesResult[DocumentUri::fromProtocol(key)] = LanguageClientArray<TextEdit>(changesObject.value(key)).toList();
return Utils::make_optional(changesResult); return std::make_optional(changesResult);
} }
void WorkspaceEdit::setChanges(const Changes &changes) void WorkspaceEdit::setChanges(const Changes &changes)
@@ -325,7 +325,7 @@ QString expressionForGlob(QString globPattern)
bool DocumentFilter::applies(const Utils::FilePath &fileName, const Utils::MimeType &mimeType) const bool DocumentFilter::applies(const Utils::FilePath &fileName, const Utils::MimeType &mimeType) const
{ {
if (Utils::optional<QString> _pattern = pattern()) { if (std::optional<QString> _pattern = pattern()) {
QRegularExpression::PatternOption option = QRegularExpression::NoPatternOption; QRegularExpression::PatternOption option = QRegularExpression::NoPatternOption;
if (fileName.caseSensitivity() == Qt::CaseInsensitive) if (fileName.caseSensitivity() == Qt::CaseInsensitive)
option = QRegularExpression::CaseInsensitiveOption; option = QRegularExpression::CaseInsensitiveOption;
@@ -333,7 +333,7 @@ bool DocumentFilter::applies(const Utils::FilePath &fileName, const Utils::MimeT
if (regexp.isValid() && regexp.match(fileName.toString()).hasMatch()) if (regexp.isValid() && regexp.match(fileName.toString()).hasMatch())
return true; return true;
} }
if (Utils::optional<QString> _lang = language()) { if (std::optional<QString> _lang = language()) {
auto match = [&_lang](const Utils::MimeType &mimeType){ auto match = [&_lang](const Utils::MimeType &mimeType){
return *_lang == TextDocumentItem::mimeTypeToLanguageId(mimeType); return *_lang == TextDocumentItem::mimeTypeToLanguageId(mimeType);
}; };

View File

@@ -10,7 +10,6 @@
#include <utils/filepath.h> #include <utils/filepath.h>
#include <utils/link.h> #include <utils/link.h>
#include <utils/mimeutils.h> #include <utils/mimeutils.h>
#include <utils/optional.h>
#include <utils/textutils.h> #include <utils/textutils.h>
#include <QTextCursor> #include <QTextCursor>
@@ -19,6 +18,7 @@
#include <QList> #include <QList>
#include <functional> #include <functional>
#include <optional>
#include <variant> #include <variant>
namespace LanguageServerProtocol { namespace LanguageServerProtocol {
@@ -162,20 +162,20 @@ public:
// The diagnostic's severity. Can be omitted. If omitted it is up to the // The diagnostic's severity. Can be omitted. If omitted it is up to the
// client to interpret diagnostics as error, warning, info or hint. // client to interpret diagnostics as error, warning, info or hint.
Utils::optional<DiagnosticSeverity> severity() const; std::optional<DiagnosticSeverity> severity() const;
void setSeverity(const DiagnosticSeverity &severity) void setSeverity(const DiagnosticSeverity &severity)
{ insert(severityKey, static_cast<int>(severity)); } { insert(severityKey, static_cast<int>(severity)); }
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 = std::variant<int, QString>; using Code = std::variant<int, QString>;
Utils::optional<Code> code() const; std::optional<Code> code() const;
void setCode(const Code &code); void setCode(const Code &code);
void clearCode() { remove(codeKey); } void clearCode() { remove(codeKey); }
// A human-readable string describing the source of this // A human-readable string describing the source of this
// diagnostic, e.g. 'typescript' or 'super lint'. // diagnostic, e.g. 'typescript' or 'super lint'.
Utils::optional<QString> source() const std::optional<QString> source() const
{ return optionalValue<QString>(sourceKey); } { return optionalValue<QString>(sourceKey); }
void setSource(const QString &source) { insert(sourceKey, source); } void setSource(const QString &source) { insert(sourceKey, source); }
void clearSource() { remove(sourceKey); } void clearSource() { remove(sourceKey); }
@@ -204,7 +204,7 @@ public:
void clearCommand() { remove(commandKey); } void clearCommand() { remove(commandKey); }
// Arguments that the command handler should be invoked with. // Arguments that the command handler should be invoked with.
Utils::optional<QJsonArray> arguments() const { return typedValue<QJsonArray>(argumentsKey); } std::optional<QJsonArray> arguments() const { return typedValue<QJsonArray>(argumentsKey); }
void setArguments(const QJsonArray &arguments) { insert(argumentsKey, arguments); } void setArguments(const QJsonArray &arguments) { insert(argumentsKey, arguments); }
void clearArguments() { remove(argumentsKey); } void clearArguments() { remove(argumentsKey); }
@@ -291,7 +291,7 @@ public:
// Holds changes to existing resources. // Holds changes to existing resources.
using Changes = QMap<DocumentUri, QList<TextEdit>>; using Changes = QMap<DocumentUri, QList<TextEdit>>;
Utils::optional<Changes> changes() const; std::optional<Changes> changes() const;
void setChanges(const Changes &changes); void setChanges(const Changes &changes);
/* /*
@@ -303,7 +303,7 @@ public:
* Note: If the client can handle versioned document edits and if documentChanges are present, * Note: If the client can handle versioned document edits and if documentChanges are present,
* the latter are preferred over changes. * the latter are preferred over changes.
*/ */
Utils::optional<QList<TextDocumentEdit>> documentChanges() const std::optional<QList<TextDocumentEdit>> documentChanges() const
{ return optionalArray<TextDocumentEdit>(documentChangesKey); } { return optionalArray<TextDocumentEdit>(documentChangesKey); }
void setDocumentChanges(const QList<TextDocumentEdit> &changes) void setDocumentChanges(const QList<TextDocumentEdit> &changes)
{ insertArray(documentChangesKey, changes); } { insertArray(documentChangesKey, changes); }
@@ -363,12 +363,12 @@ public:
using JsonObject::JsonObject; using JsonObject::JsonObject;
// A language id, like `typescript`. // A language id, like `typescript`.
Utils::optional<QString> language() const { return optionalValue<QString>(languageKey); } std::optional<QString> language() const { return optionalValue<QString>(languageKey); }
void setLanguage(const QString &language) { insert(languageKey, language); } void setLanguage(const QString &language) { insert(languageKey, language); }
void clearLanguage() { remove(languageKey); } void clearLanguage() { remove(languageKey); }
// A Uri [scheme](#Uri.scheme), like `file` or `untitled`. // A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
Utils::optional<QString> scheme() const { return optionalValue<QString>(schemeKey); } std::optional<QString> scheme() const { return optionalValue<QString>(schemeKey); }
void setScheme(const QString &scheme) { insert(schemeKey, scheme); } void setScheme(const QString &scheme) { insert(schemeKey, scheme); }
void clearScheme() { remove(schemeKey); } void clearScheme() { remove(schemeKey); }
@@ -387,7 +387,7 @@ public:
* (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but * (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but
* not `example.0`) * not `example.0`)
*/ */
Utils::optional<QString> pattern() const { return optionalValue<QString>(patternKey); } std::optional<QString> pattern() const { return optionalValue<QString>(patternKey); }
void setPattern(const QString &pattern) { insert(patternKey, pattern); } void setPattern(const QString &pattern) { insert(patternKey, pattern); }
void clearPattern() { remove(patternKey); } void clearPattern() { remove(patternKey); }
@@ -478,14 +478,14 @@ public:
int kind() const { return typedValue<int>(kindKey); } int kind() const { return typedValue<int>(kindKey); }
void setKind(int kind) { insert(kindKey, kind); } void setKind(int kind) { insert(kindKey, kind); }
Utils::optional<bool> deprecated() const { return optionalValue<bool>(deprecatedKey); } std::optional<bool> deprecated() const { return optionalValue<bool>(deprecatedKey); }
void setDeprecated(bool deprecated) { insert(deprecatedKey, deprecated); } void setDeprecated(bool deprecated) { insert(deprecatedKey, deprecated); }
void clearDeprecated() { remove(deprecatedKey); } void clearDeprecated() { remove(deprecatedKey); }
Location location() const { return typedValue<Location>(locationKey); } Location location() const { return typedValue<Location>(locationKey); }
void setLocation(const Location &location) { insert(locationKey, location); } void setLocation(const Location &location) { insert(locationKey, location); }
Utils::optional<QString> containerName() const std::optional<QString> containerName() const
{ return optionalValue<QString>(containerNameKey); } { return optionalValue<QString>(containerNameKey); }
void setContainerName(const QString &containerName) { insert(containerNameKey, containerName); } void setContainerName(const QString &containerName) { insert(containerNameKey, containerName); }
void clearContainerName() { remove(containerNameKey); } void clearContainerName() { remove(containerNameKey); }
@@ -502,14 +502,14 @@ public:
QString name() const { return typedValue<QString>(nameKey); } QString name() const { return typedValue<QString>(nameKey); }
void setName(const QString &name) { insert(nameKey, name); } void setName(const QString &name) { insert(nameKey, name); }
Utils::optional<QString> detail() const { return optionalValue<QString>(detailKey); } std::optional<QString> detail() const { return optionalValue<QString>(detailKey); }
void setDetail(const QString &detail) { insert(detailKey, detail); } void setDetail(const QString &detail) { insert(detailKey, detail); }
void clearDetail() { remove(detailKey); } void clearDetail() { remove(detailKey); }
int kind() const { return typedValue<int>(kindKey); } int kind() const { return typedValue<int>(kindKey); }
void setKind(int kind) { insert(kindKey, kind); } void setKind(int kind) { insert(kindKey, kind); }
Utils::optional<bool> deprecated() const { return optionalValue<bool>(deprecatedKey); } std::optional<bool> deprecated() const { return optionalValue<bool>(deprecatedKey); }
void setDeprecated(bool deprecated) { insert(deprecatedKey, deprecated); } void setDeprecated(bool deprecated) { insert(deprecatedKey, deprecated); }
void clearDeprecated() { remove(deprecatedKey); } void clearDeprecated() { remove(deprecatedKey); }
@@ -519,7 +519,7 @@ public:
Range selectionRange() const { return typedValue<Range>(selectionRangeKey); } Range selectionRange() const { return typedValue<Range>(selectionRangeKey); }
void setSelectionRange(Range selectionRange) { insert(selectionRangeKey, selectionRange); } void setSelectionRange(Range selectionRange) { insert(selectionRangeKey, selectionRange); }
Utils::optional<QList<DocumentSymbol>> children() const std::optional<QList<DocumentSymbol>> children() const
{ return optionalArray<DocumentSymbol>(childrenKey); } { return optionalArray<DocumentSymbol>(childrenKey); }
void setChildren(QList<DocumentSymbol> children) { insertArray(childrenKey, children); } void setChildren(QList<DocumentSymbol> children) { insertArray(childrenKey, children); }
void clearChildren() { remove(childrenKey); } void clearChildren() { remove(childrenKey); }

View File

@@ -6,13 +6,13 @@
#include "languageserverprotocol_global.h" #include "languageserverprotocol_global.h"
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/optional.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QJsonArray> #include <QJsonArray>
#include <QJsonObject> #include <QJsonObject>
#include <QLoggingCategory> #include <QLoggingCategory>
#include <optional>
#include <variant> #include <variant>
namespace LanguageServerProtocol { namespace LanguageServerProtocol {

View File

@@ -55,7 +55,7 @@ class LANGUAGESERVERPROTOCOL_EXPORT ShowMessageRequestParams : public ShowMessag
public: public:
using ShowMessageParams::ShowMessageParams; using ShowMessageParams::ShowMessageParams;
Utils::optional<QList<MessageActionItem>> actions() const std::optional<QList<MessageActionItem>> actions() const
{ return optionalArray<MessageActionItem>(actionsKey); } { return optionalArray<MessageActionItem>(actionsKey); }
void setActions(const QList<MessageActionItem> &actions) { insertArray(actionsKey, actions); } void setActions(const QList<MessageActionItem> &actions) { insertArray(actionsKey, actions); }
void clearActions() { remove(actionsKey); } void clearActions() { remove(actionsKey); }

View File

@@ -31,7 +31,7 @@ public:
* long running operation. * long running operation.
* Clients that don't support cancellation can ignore the setting. * Clients that don't support cancellation can ignore the setting.
*/ */
Utils::optional<bool> cancellable() const { return optionalValue<bool>(cancellableKey); } std::optional<bool> cancellable() const { return optionalValue<bool>(cancellableKey); }
void setCancellable(bool cancellable) { insert(cancellableKey, cancellable); } void setCancellable(bool cancellable) { insert(cancellableKey, cancellable); }
void clearCancellable() { remove(cancellableKey); } void clearCancellable() { remove(cancellableKey); }
@@ -42,7 +42,7 @@ public:
* Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". * Examples: "3/25 files", "project/src/module2", "node_modules/some_dep".
* If unset, the previous progress message (if any) is still valid. * If unset, the previous progress message (if any) is still valid.
*/ */
Utils::optional<QString> message() const { return optionalValue<QString>(messageKey); } std::optional<QString> message() const { return optionalValue<QString>(messageKey); }
void setMessage(const QString &message) { insert(messageKey, message); } void setMessage(const QString &message) { insert(messageKey, message); }
void clearMessage() { remove(messageKey); } void clearMessage() { remove(messageKey); }
@@ -58,7 +58,7 @@ public:
// Allthough percentage is defined as an uint by the protocol some server // Allthough percentage is defined as an uint by the protocol some server
// return a double here. Be less strict and also use a double. // return a double here. Be less strict and also use a double.
// CAUTION: the range is still 0 - 100 and not 0 - 1 // CAUTION: the range is still 0 - 100 and not 0 - 1
Utils::optional<double> percentage() const { return optionalValue<double>(percentageKey); } std::optional<double> percentage() const { return optionalValue<double>(percentageKey); }
void setPercentage(double percentage) { insert(percentageKey, percentage); } void setPercentage(double percentage) { insert(percentageKey, percentage); }
void clearPercentage() { remove(percentageKey); } void clearPercentage() { remove(percentageKey); }
}; };
@@ -88,7 +88,7 @@ public:
* Optional, a final message indicating to for example indicate the outcome * Optional, a final message indicating to for example indicate the outcome
* of the operation. * of the operation.
*/ */
Utils::optional<QString> message() const { return optionalValue<QString>(messageKey); } std::optional<QString> message() const { return optionalValue<QString>(messageKey); }
void setMessage(const QString &message) { insert(messageKey, message); } void setMessage(const QString &message) { insert(messageKey, message); }
void clearMessage() { remove(messageKey); } void clearMessage() { remove(messageKey); }
}; };

View File

@@ -125,7 +125,7 @@ public:
* A server can then instead of computing all semantic tokens again simply * A server can then instead of computing all semantic tokens again simply
* send a delta. * send a delta.
*/ */
Utils::optional<QString> resultId() const { return optionalValue<QString>(resultIdKey); } std::optional<QString> resultId() const { return optionalValue<QString>(resultIdKey); }
void setResultId(const QString &resultId) { insert(resultIdKey, resultId); } void setResultId(const QString &resultId) { insert(resultIdKey, resultId); }
void clearResultId() { remove(resultIdKey); } void clearResultId() { remove(resultIdKey); }
@@ -169,7 +169,7 @@ public:
int deleteCount() const { return typedValue<int>(deleteCountKey); } int deleteCount() const { return typedValue<int>(deleteCountKey); }
void setDeleteCount(int deleteCount) { insert(deleteCountKey, deleteCount); } void setDeleteCount(int deleteCount) { insert(deleteCountKey, deleteCount); }
Utils::optional<QList<int>> data() const { return optionalArray<int>(dataKey); } std::optional<QList<int>> data() const { return optionalArray<int>(dataKey); }
void setData(const QList<int> &value) { insertArray(dataKey, value); } void setData(const QList<int> &value) { insertArray(dataKey, value); }
void clearData() { remove(dataKey); } void clearData() { remove(dataKey); }

View File

@@ -5,12 +5,13 @@
namespace LanguageServerProtocol { namespace LanguageServerProtocol {
Utils::optional<ServerCapabilities::TextDocumentSync> ServerCapabilities::textDocumentSync() const std::optional<ServerCapabilities::TextDocumentSync> ServerCapabilities::textDocumentSync() const
{ {
const QJsonValue &sync = value(textDocumentSyncKey); const QJsonValue &sync = value(textDocumentSyncKey);
if (sync.isUndefined()) if (sync.isUndefined())
return Utils::nullopt; return std::nullopt;
return Utils::make_optional(sync.isDouble() ? TextDocumentSync(sync.toInt()) return std::make_optional(sync.isDouble()
? TextDocumentSync(sync.toInt())
: TextDocumentSync(TextDocumentSyncOptions(sync.toObject()))); : TextDocumentSync(TextDocumentSyncOptions(sync.toObject())));
} }
@@ -21,27 +22,27 @@ void ServerCapabilities::setTextDocumentSync(const ServerCapabilities::TextDocum
TextDocumentSyncKind ServerCapabilities::textDocumentSyncKindHelper() TextDocumentSyncKind ServerCapabilities::textDocumentSyncKindHelper()
{ {
if (Utils::optional<TextDocumentSync> sync = textDocumentSync()) { if (std::optional<TextDocumentSync> sync = textDocumentSync()) {
if (auto kind = std::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 = std::get_if<TextDocumentSyncOptions>(&*sync)) { if (auto options = std::get_if<TextDocumentSyncOptions>(&*sync)) {
if (const Utils::optional<int> &change = options->change()) if (const std::optional<int> &change = options->change())
return static_cast<TextDocumentSyncKind>(*change); return static_cast<TextDocumentSyncKind>(*change);
} }
} }
return TextDocumentSyncKind::None; return TextDocumentSyncKind::None;
} }
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> ServerCapabilities::hoverProvider() std::optional<std::variant<bool, WorkDoneProgressOptions>> ServerCapabilities::hoverProvider()
const const
{ {
using RetType = std::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 std::make_optional(RetType(provider.toBool()));
if (provider.isObject()) if (provider.isObject())
return Utils::make_optional(RetType(WorkDoneProgressOptions(provider.toObject()))); return std::make_optional(RetType(WorkDoneProgressOptions(provider.toObject())));
return Utils::nullopt; return std::nullopt;
} }
void ServerCapabilities::setHoverProvider( void ServerCapabilities::setHoverProvider(
@@ -50,14 +51,15 @@ void ServerCapabilities::setHoverProvider(
insertVariant<bool, WorkDoneProgressOptions>(hoverProviderKey, hoverProvider); insertVariant<bool, WorkDoneProgressOptions>(hoverProviderKey, hoverProvider);
} }
Utils::optional<std::variant<bool, ServerCapabilities::RegistrationOptions>> std::optional<std::variant<bool, ServerCapabilities::RegistrationOptions>>
ServerCapabilities::typeDefinitionProvider() const ServerCapabilities::typeDefinitionProvider() const
{ {
using RetType = std::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 std::nullopt;
return Utils::make_optional(provider.isBool() ? RetType(provider.toBool()) return std::make_optional(provider.isBool()
? RetType(provider.toBool())
: RetType(RegistrationOptions(provider.toObject()))); : RetType(RegistrationOptions(provider.toObject())));
} }
@@ -68,14 +70,15 @@ void ServerCapabilities::setTypeDefinitionProvider(
typeDefinitionProvider); typeDefinitionProvider);
} }
Utils::optional<std::variant<bool, ServerCapabilities::RegistrationOptions>> std::optional<std::variant<bool, ServerCapabilities::RegistrationOptions>>
ServerCapabilities::implementationProvider() const ServerCapabilities::implementationProvider() const
{ {
using RetType = std::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 std::nullopt;
return Utils::make_optional(provider.isBool() ? RetType(provider.toBool()) return std::make_optional(provider.isBool()
? RetType(provider.toBool())
: RetType(RegistrationOptions(provider.toObject()))); : RetType(RegistrationOptions(provider.toObject())));
} }
@@ -85,16 +88,16 @@ void ServerCapabilities::setImplementationProvider(
insertVariant<bool, RegistrationOptions>(implementationProviderKey, implementationProvider); insertVariant<bool, RegistrationOptions>(implementationProviderKey, implementationProvider);
} }
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> std::optional<std::variant<bool, WorkDoneProgressOptions>>
ServerCapabilities::referencesProvider() const ServerCapabilities::referencesProvider() const
{ {
using RetType = std::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 std::make_optional(RetType(provider.toBool()));
if (provider.isObject()) if (provider.isObject())
return Utils::make_optional(RetType(WorkDoneProgressOptions(provider.toObject()))); return std::make_optional(RetType(WorkDoneProgressOptions(provider.toObject())));
return Utils::nullopt; return std::nullopt;
} }
void ServerCapabilities::setReferencesProvider( void ServerCapabilities::setReferencesProvider(
@@ -104,16 +107,16 @@ void ServerCapabilities::setReferencesProvider(
referencesProvider); referencesProvider);
} }
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> std::optional<std::variant<bool, WorkDoneProgressOptions>>
ServerCapabilities::documentHighlightProvider() const ServerCapabilities::documentHighlightProvider() const
{ {
using RetType = std::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 std::make_optional(RetType(provider.toBool()));
if (provider.isObject()) if (provider.isObject())
return Utils::make_optional(RetType(WorkDoneProgressOptions(provider.toObject()))); return std::make_optional(RetType(WorkDoneProgressOptions(provider.toObject())));
return Utils::nullopt; return std::nullopt;
} }
void ServerCapabilities::setDocumentHighlightProvider( void ServerCapabilities::setDocumentHighlightProvider(
@@ -123,16 +126,16 @@ void ServerCapabilities::setDocumentHighlightProvider(
documentHighlightProvider); documentHighlightProvider);
} }
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> std::optional<std::variant<bool, WorkDoneProgressOptions>>
ServerCapabilities::documentSymbolProvider() const ServerCapabilities::documentSymbolProvider() const
{ {
using RetType = std::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 std::make_optional(RetType(provider.toBool()));
if (provider.isObject()) if (provider.isObject())
return Utils::make_optional(RetType(WorkDoneProgressOptions(provider.toObject()))); return std::make_optional(RetType(WorkDoneProgressOptions(provider.toObject())));
return Utils::nullopt; return std::nullopt;
} }
void ServerCapabilities::setDocumentSymbolProvider( void ServerCapabilities::setDocumentSymbolProvider(
@@ -142,7 +145,7 @@ void ServerCapabilities::setDocumentSymbolProvider(
documentSymbolProvider); documentSymbolProvider);
} }
Utils::optional<SemanticTokensOptions> ServerCapabilities::semanticTokensProvider() const std::optional<SemanticTokensOptions> ServerCapabilities::semanticTokensProvider() const
{ {
return optionalValue<SemanticTokensOptions>(semanticTokensProviderKey); return optionalValue<SemanticTokensOptions>(semanticTokensProviderKey);
} }
@@ -153,16 +156,16 @@ void ServerCapabilities::setSemanticTokensProvider(
insert(semanticTokensProviderKey, semanticTokensProvider); insert(semanticTokensProviderKey, semanticTokensProvider);
} }
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> std::optional<std::variant<bool, WorkDoneProgressOptions>>
ServerCapabilities::workspaceSymbolProvider() const ServerCapabilities::workspaceSymbolProvider() const
{ {
using RetType = std::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 std::make_optional(RetType(provider.toBool()));
if (provider.isObject()) if (provider.isObject())
return Utils::make_optional(RetType(WorkDoneProgressOptions(provider.toObject()))); return std::make_optional(RetType(WorkDoneProgressOptions(provider.toObject())));
return Utils::nullopt; return std::nullopt;
} }
void ServerCapabilities::setWorkspaceSymbolProvider( void ServerCapabilities::setWorkspaceSymbolProvider(
@@ -172,29 +175,29 @@ void ServerCapabilities::setWorkspaceSymbolProvider(
workspaceSymbolProvider); workspaceSymbolProvider);
} }
Utils::optional<std::variant<bool, CodeActionOptions>> ServerCapabilities::codeActionProvider() const std::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(std::variant<bool, CodeActionOptions>(provider.toBool())); return std::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(std::variant<bool, CodeActionOptions>(options)); return std::make_optional(std::variant<bool, CodeActionOptions>(options));
} }
return Utils::nullopt; return std::nullopt;
} }
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> std::optional<std::variant<bool, WorkDoneProgressOptions>>
ServerCapabilities::documentFormattingProvider() const ServerCapabilities::documentFormattingProvider() const
{ {
using RetType = std::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 std::make_optional(RetType(provider.toBool()));
if (provider.isObject()) if (provider.isObject())
return Utils::make_optional(RetType(WorkDoneProgressOptions(provider.toObject()))); return std::make_optional(RetType(WorkDoneProgressOptions(provider.toObject())));
return Utils::nullopt; return std::nullopt;
} }
void ServerCapabilities::setDocumentFormattingProvider( void ServerCapabilities::setDocumentFormattingProvider(
@@ -204,16 +207,16 @@ void ServerCapabilities::setDocumentFormattingProvider(
documentFormattingProvider); documentFormattingProvider);
} }
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> std::optional<std::variant<bool, WorkDoneProgressOptions>>
ServerCapabilities::documentRangeFormattingProvider() const ServerCapabilities::documentRangeFormattingProvider() const
{ {
using RetType = std::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 std::make_optional(RetType(provider.toBool()));
if (provider.isObject()) if (provider.isObject())
return Utils::make_optional(RetType(WorkDoneProgressOptions(provider.toObject()))); return std::make_optional(RetType(WorkDoneProgressOptions(provider.toObject())));
return Utils::nullopt; return std::nullopt;
} }
void ServerCapabilities::setDocumentRangeFormattingProvider( void ServerCapabilities::setDocumentRangeFormattingProvider(
@@ -223,7 +226,7 @@ void ServerCapabilities::setDocumentRangeFormattingProvider(
documentRangeFormattingProvider); documentRangeFormattingProvider);
} }
Utils::optional<std::variant<ServerCapabilities::RenameOptions, bool>> ServerCapabilities::renameProvider() const std::optional<std::variant<ServerCapabilities::RenameOptions, bool>> ServerCapabilities::renameProvider() const
{ {
using RetType = std::variant<ServerCapabilities::RenameOptions, bool>; using RetType = std::variant<ServerCapabilities::RenameOptions, bool>;
const QJsonValue &localValue = value(renameProviderKey); const QJsonValue &localValue = value(renameProviderKey);
@@ -231,7 +234,7 @@ Utils::optional<std::variant<ServerCapabilities::RenameOptions, bool>> ServerCap
return RetType(localValue.toBool()); return RetType(localValue.toBool());
if (localValue.isObject()) if (localValue.isObject())
return RetType(RenameOptions(localValue.toObject())); return RetType(RenameOptions(localValue.toObject()));
return Utils::nullopt; return std::nullopt;
} }
void ServerCapabilities::setRenameProvider(std::variant<ServerCapabilities::RenameOptions, bool> renameProvider) void ServerCapabilities::setRenameProvider(std::variant<ServerCapabilities::RenameOptions, bool> renameProvider)
@@ -239,7 +242,7 @@ void ServerCapabilities::setRenameProvider(std::variant<ServerCapabilities::Rena
insertVariant<RenameOptions, bool>(renameProviderKey, renameProvider); insertVariant<RenameOptions, bool>(renameProviderKey, renameProvider);
} }
Utils::optional<std::variant<bool, JsonObject>> ServerCapabilities::colorProvider() const std::optional<std::variant<bool, JsonObject>> ServerCapabilities::colorProvider() const
{ {
using RetType = std::variant<bool, JsonObject>; using RetType = std::variant<bool, JsonObject>;
const QJsonValue &localValue = value(colorProviderKey); const QJsonValue &localValue = value(colorProviderKey);
@@ -247,7 +250,7 @@ Utils::optional<std::variant<bool, JsonObject>> ServerCapabilities::colorProvide
return RetType(localValue.toBool()); return RetType(localValue.toBool());
if (localValue.isObject()) if (localValue.isObject())
return RetType(JsonObject(localValue.toObject())); return RetType(JsonObject(localValue.toObject()));
return Utils::nullopt; return std::nullopt;
} }
void ServerCapabilities::setColorProvider(std::variant<bool, JsonObject> colorProvider) void ServerCapabilities::setColorProvider(std::variant<bool, JsonObject> colorProvider)
@@ -255,14 +258,14 @@ void ServerCapabilities::setColorProvider(std::variant<bool, JsonObject> colorPr
insertVariant<bool, JsonObject>(renameProviderKey, colorProvider); insertVariant<bool, JsonObject>(renameProviderKey, colorProvider);
} }
Utils::optional<std::variant<QString, bool> > std::optional<std::variant<QString, bool> >
ServerCapabilities::WorkspaceServerCapabilities::WorkspaceFoldersCapabilities::changeNotifications() const ServerCapabilities::WorkspaceServerCapabilities::WorkspaceFoldersCapabilities::changeNotifications() const
{ {
using RetType = std::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 std::nullopt;
return Utils::make_optional(change.isBool() ? RetType(change.toBool()) return std::make_optional(change.isBool() ? RetType(change.toBool())
: RetType(change.toString())); : RetType(change.toString()));
} }
@@ -293,7 +296,7 @@ bool CodeActionOptions::isValid() const
return WorkDoneProgressOptions::isValid() && contains(codeActionKindsKey); return WorkDoneProgressOptions::isValid() && contains(codeActionKindsKey);
} }
Utils::optional<std::variant<bool, QJsonObject>> SemanticTokensOptions::range() const std::optional<std::variant<bool, QJsonObject>> SemanticTokensOptions::range() const
{ {
using RetType = std::variant<bool, QJsonObject>; using RetType = std::variant<bool, QJsonObject>;
const QJsonValue &rangeOptions = value(rangeKey); const QJsonValue &rangeOptions = value(rangeKey);
@@ -301,7 +304,7 @@ Utils::optional<std::variant<bool, QJsonObject>> SemanticTokensOptions::range()
return RetType(rangeOptions.toBool()); return RetType(rangeOptions.toBool());
if (rangeOptions.isObject()) if (rangeOptions.isObject())
return RetType(rangeOptions.toObject()); return RetType(rangeOptions.toObject());
return Utils::nullopt; return std::nullopt;
} }
void SemanticTokensOptions::setRange(const std::variant<bool, QJsonObject> &range) void SemanticTokensOptions::setRange(const std::variant<bool, QJsonObject> &range)
@@ -309,7 +312,7 @@ void SemanticTokensOptions::setRange(const std::variant<bool, QJsonObject> &rang
insertVariant<bool, QJsonObject>(rangeKey, range); insertVariant<bool, QJsonObject>(rangeKey, range);
} }
Utils::optional<std::variant<bool, SemanticTokensOptions::FullSemanticTokenOptions>> std::optional<std::variant<bool, SemanticTokensOptions::FullSemanticTokenOptions>>
SemanticTokensOptions::full() const SemanticTokensOptions::full() const
{ {
using RetType = std::variant<bool, SemanticTokensOptions::FullSemanticTokenOptions>; using RetType = std::variant<bool, SemanticTokensOptions::FullSemanticTokenOptions>;
@@ -318,7 +321,7 @@ SemanticTokensOptions::full() const
return RetType(fullOptions.toBool()); return RetType(fullOptions.toBool());
if (fullOptions.isObject()) if (fullOptions.isObject())
return RetType(FullSemanticTokenOptions(fullOptions.toObject())); return RetType(FullSemanticTokenOptions(fullOptions.toObject()));
return Utils::nullopt; return std::nullopt;
} }
void SemanticTokensOptions::setFull( void SemanticTokensOptions::setFull(

View File

@@ -13,7 +13,7 @@ class LANGUAGESERVERPROTOCOL_EXPORT WorkDoneProgressOptions : public JsonObject
public: public:
using JsonObject::JsonObject; using JsonObject::JsonObject;
Utils::optional<bool> workDoneProgress() const { return optionalValue<bool>(workDoneProgressKey); } std::optional<bool> workDoneProgress() const { return optionalValue<bool>(workDoneProgressKey); }
void setWorkDoneProgress(bool workDoneProgress) { insert(workDoneProgressKey, workDoneProgress); } void setWorkDoneProgress(bool workDoneProgress) { insert(workDoneProgressKey, workDoneProgress); }
void clearWorkDoneProgress() { remove(workDoneProgressKey); } void clearWorkDoneProgress() { remove(workDoneProgressKey); }
}; };
@@ -23,7 +23,7 @@ class LANGUAGESERVERPROTOCOL_EXPORT ResolveProviderOption : public JsonObject
public: public:
using JsonObject::JsonObject; using JsonObject::JsonObject;
Utils::optional<bool> resolveProvider() const { return optionalValue<bool>(resolveProviderKey); } std::optional<bool> resolveProvider() const { return optionalValue<bool>(resolveProviderKey); }
void setResolveProvider(bool resolveProvider) { insert(resolveProviderKey, resolveProvider); } void setResolveProvider(bool resolveProvider) { insert(resolveProviderKey, resolveProvider); }
void clearResolveProvider() { remove(resolveProviderKey); } void clearResolveProvider() { remove(resolveProviderKey); }
}; };
@@ -50,7 +50,7 @@ public:
using JsonObject::JsonObject; using JsonObject::JsonObject;
// The client is supposed to include the content on save. // The client is supposed to include the content on save.
Utils::optional<bool> includeText() const { return optionalValue<bool>(includeTextKey); } std::optional<bool> includeText() const { return optionalValue<bool>(includeTextKey); }
void setIncludeText(bool includeText) { insert(includeTextKey, includeText); } void setIncludeText(bool includeText) { insert(includeTextKey, includeText); }
void clearIncludeText() { remove(includeTextKey); } void clearIncludeText() { remove(includeTextKey); }
}; };
@@ -61,30 +61,30 @@ public:
using JsonObject::JsonObject; using JsonObject::JsonObject;
// Open and close notifications are sent to the server. // Open and close notifications are sent to the server.
Utils::optional<bool> openClose() const { return optionalValue<bool>(openCloseKey); } std::optional<bool> openClose() const { return optionalValue<bool>(openCloseKey); }
void setOpenClose(bool openClose) { insert(openCloseKey, openClose); } void setOpenClose(bool openClose) { insert(openCloseKey, openClose); }
void clearOpenClose() { remove(openCloseKey); } void clearOpenClose() { remove(openCloseKey); }
// Change notifications are sent to the server. See TextDocumentSyncKind.None, // Change notifications are sent to the server. See TextDocumentSyncKind.None,
// TextDocumentSyncKind.Full and TextDocumentSyncKind.Incremental. // TextDocumentSyncKind.Full and TextDocumentSyncKind.Incremental.
Utils::optional<int> change() const { return optionalValue<int>(changeKey); } std::optional<int> change() const { return optionalValue<int>(changeKey); }
void setChange(int change) { insert(changeKey, change); } void setChange(int change) { insert(changeKey, change); }
void clearChange() { remove(changeKey); } void clearChange() { remove(changeKey); }
// Will save notifications are sent to the server. // Will save notifications are sent to the server.
Utils::optional<bool> willSave() const { return optionalValue<bool>(willSaveKey); } std::optional<bool> willSave() const { return optionalValue<bool>(willSaveKey); }
void setWillSave(bool willSave) { insert(willSaveKey, willSave); } void setWillSave(bool willSave) { insert(willSaveKey, willSave); }
void clearWillSave() { remove(willSaveKey); } void clearWillSave() { remove(willSaveKey); }
// Will save wait until requests are sent to the server. // Will save wait until requests are sent to the server.
Utils::optional<bool> willSaveWaitUntil() const std::optional<bool> willSaveWaitUntil() const
{ return optionalValue<bool>(willSaveWaitUntilKey); } { return optionalValue<bool>(willSaveWaitUntilKey); }
void setWillSaveWaitUntil(bool willSaveWaitUntil) void setWillSaveWaitUntil(bool willSaveWaitUntil)
{ insert(willSaveWaitUntilKey, willSaveWaitUntil); } { insert(willSaveWaitUntilKey, willSaveWaitUntil); }
void clearWillSaveWaitUntil() { remove(willSaveWaitUntilKey); } void clearWillSaveWaitUntil() { remove(willSaveWaitUntilKey); }
// Save notifications are sent to the server. // Save notifications are sent to the server.
Utils::optional<SaveOptions> save() const { return optionalValue<SaveOptions>(saveKey); } std::optional<SaveOptions> save() const { return optionalValue<SaveOptions>(saveKey); }
void setSave(const SaveOptions &save) { insert(saveKey, save); } void setSave(const SaveOptions &save) { insert(saveKey, save); }
void clearSave() { remove(saveKey); } void clearSave() { remove(saveKey); }
}; };
@@ -130,7 +130,7 @@ 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<std::variant<bool, QJsonObject>> range() const; std::optional<std::variant<bool, QJsonObject>> range() const;
void setRange(const std::variant<bool, QJsonObject> &range); void setRange(const std::variant<bool, QJsonObject> &range);
void clearRange() { remove(rangeKey); } void clearRange() { remove(rangeKey); }
@@ -140,13 +140,13 @@ public:
using JsonObject::JsonObject; using JsonObject::JsonObject;
/// The server supports deltas for full documents. /// The server supports deltas for full documents.
Utils::optional<bool> delta() const { return optionalValue<bool>(deltaKey); } std::optional<bool> delta() const { return optionalValue<bool>(deltaKey); }
void setDelta(bool delta) { insert(deltaKey, delta); } void setDelta(bool delta) { insert(deltaKey, delta); }
void clearDelta() { remove(deltaKey); } void clearDelta() { remove(deltaKey); }
}; };
/// Server supports providing semantic tokens for a full document. /// Server supports providing semantic tokens for a full document.
Utils::optional<std::variant<bool, FullSemanticTokenOptions>> full() const; std::optional<std::variant<bool, FullSemanticTokenOptions>> full() const;
void setFull(const std::variant<bool, FullSemanticTokenOptions> &full); void setFull(const std::variant<bool, FullSemanticTokenOptions> &full);
void clearFull() { remove(fullKey); } void clearFull() { remove(fullKey); }
@@ -168,13 +168,13 @@ public:
using WorkDoneProgressOptions::WorkDoneProgressOptions; using WorkDoneProgressOptions::WorkDoneProgressOptions;
// The characters that trigger completion automatically. // The characters that trigger completion automatically.
Utils::optional<QList<QString>> triggerCharacters() const std::optional<QList<QString>> triggerCharacters() const
{ return optionalArray<QString>(triggerCharactersKey); } { return optionalArray<QString>(triggerCharactersKey); }
void setTriggerCharacters(const QList<QString> &triggerCharacters) void setTriggerCharacters(const QList<QString> &triggerCharacters)
{ insertArray(triggerCharactersKey, triggerCharacters); } { insertArray(triggerCharactersKey, triggerCharacters); }
void clearTriggerCharacters() { remove(triggerCharactersKey); } void clearTriggerCharacters() { remove(triggerCharactersKey); }
Utils::optional<bool> resolveProvider() const { return optionalValue<bool>(resolveProviderKey); } std::optional<bool> resolveProvider() const { return optionalValue<bool>(resolveProviderKey); }
void setResolveProvider(bool resolveProvider) { insert(resolveProviderKey, resolveProvider); } void setResolveProvider(bool resolveProvider) { insert(resolveProviderKey, resolveProvider); }
void clearResolveProvider() { remove(resolveProviderKey); } void clearResolveProvider() { remove(resolveProviderKey); }
}; };
@@ -185,7 +185,7 @@ public:
using WorkDoneProgressOptions::WorkDoneProgressOptions; using WorkDoneProgressOptions::WorkDoneProgressOptions;
// The characters that trigger signature help automatically. // The characters that trigger signature help automatically.
Utils::optional<QList<QString>> triggerCharacters() const std::optional<QList<QString>> triggerCharacters() const
{ return optionalArray<QString>(triggerCharactersKey); } { return optionalArray<QString>(triggerCharactersKey); }
void setTriggerCharacters(const QList<QString> &triggerCharacters) void setTriggerCharacters(const QList<QString> &triggerCharacters)
{ insertArray(triggerCharactersKey, triggerCharacters); } { insertArray(triggerCharactersKey, triggerCharacters); }
@@ -205,7 +205,7 @@ public:
{ insert(firstTriggerCharacterKey, firstTriggerCharacter); } { insert(firstTriggerCharacterKey, firstTriggerCharacter); }
// More trigger characters. // More trigger characters.
Utils::optional<QList<QString>> moreTriggerCharacter() const std::optional<QList<QString>> moreTriggerCharacter() const
{ return optionalArray<QString>(moreTriggerCharacterKey); } { return optionalArray<QString>(moreTriggerCharacterKey); }
void setMoreTriggerCharacter(const QList<QString> &moreTriggerCharacter) void setMoreTriggerCharacter(const QList<QString> &moreTriggerCharacter)
{ insertArray(moreTriggerCharacterKey, moreTriggerCharacter); } { insertArray(moreTriggerCharacterKey, moreTriggerCharacter); }
@@ -236,7 +236,7 @@ public:
// The id used to register the request. The id can be used to deregister // The id used to register the request. The id can be used to deregister
// the request again. See also Registration#id. // the request again. See also Registration#id.
Utils::optional<QString> id() const { return optionalValue<QString>(idKey); } std::optional<QString> id() const { return optionalValue<QString>(idKey); }
void setId(const QString &id) { insert(idKey, id); } void setId(const QString &id) { insert(idKey, id); }
void clearId() { remove(idKey); } void clearId() { remove(idKey); }
}; };
@@ -244,33 +244,33 @@ 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 = std::variant<TextDocumentSyncOptions, int>; using TextDocumentSync = std::variant<TextDocumentSyncOptions, int>;
Utils::optional<TextDocumentSync> textDocumentSync() const; std::optional<TextDocumentSync> textDocumentSync() const;
void setTextDocumentSync(const TextDocumentSync &textDocumentSync); void setTextDocumentSync(const TextDocumentSync &textDocumentSync);
void clearTextDocumentSync() { remove(textDocumentSyncKey); } void clearTextDocumentSync() { remove(textDocumentSyncKey); }
TextDocumentSyncKind textDocumentSyncKindHelper(); TextDocumentSyncKind textDocumentSyncKindHelper();
// The server provides hover support. // The server provides hover support.
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> hoverProvider() const; std::optional<std::variant<bool, WorkDoneProgressOptions>> hoverProvider() const;
void setHoverProvider(const std::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.
Utils::optional<CompletionOptions> completionProvider() const std::optional<CompletionOptions> completionProvider() const
{ return optionalValue<CompletionOptions>(completionProviderKey); } { return optionalValue<CompletionOptions>(completionProviderKey); }
void setCompletionProvider(const CompletionOptions &completionProvider) void setCompletionProvider(const CompletionOptions &completionProvider)
{ insert(completionProviderKey, completionProvider); } { insert(completionProviderKey, completionProvider); }
void clearCompletionProvider() { remove(completionProviderKey); } void clearCompletionProvider() { remove(completionProviderKey); }
// The server provides signature help support. // The server provides signature help support.
Utils::optional<SignatureHelpOptions> signatureHelpProvider() const std::optional<SignatureHelpOptions> signatureHelpProvider() const
{ return optionalValue<SignatureHelpOptions>(signatureHelpProviderKey); } { return optionalValue<SignatureHelpOptions>(signatureHelpProviderKey); }
void setSignatureHelpProvider(const SignatureHelpOptions &signatureHelpProvider) void setSignatureHelpProvider(const SignatureHelpOptions &signatureHelpProvider)
{ insert(signatureHelpProviderKey, signatureHelpProvider); } { insert(signatureHelpProviderKey, signatureHelpProvider); }
void clearSignatureHelpProvider() { remove(signatureHelpProviderKey); } void clearSignatureHelpProvider() { remove(signatureHelpProviderKey); }
// The server provides goto definition support. // The server provides goto definition support.
Utils::optional<bool> definitionProvider() const std::optional<bool> definitionProvider() const
{ return optionalValue<bool>(definitionProviderKey); } { return optionalValue<bool>(definitionProviderKey); }
void setDefinitionProvider(bool definitionProvider) void setDefinitionProvider(bool definitionProvider)
{ insert(definitionProviderKey, definitionProvider); } { insert(definitionProviderKey, definitionProvider); }
@@ -291,7 +291,7 @@ public:
// The id used to register the request. The id can be used to deregister // The id used to register the request. The id can be used to deregister
// the request again. See also Registration#id. // the request again. See also Registration#id.
Utils::optional<QString> id() const { return optionalValue<QString>(idKey); } std::optional<QString> id() const { return optionalValue<QString>(idKey); }
void setId(const QString &id) { insert(idKey, id); } void setId(const QString &id) { insert(idKey, id); }
void clearId() { remove(idKey); } void clearId() { remove(idKey); }
@@ -299,42 +299,42 @@ public:
}; };
// The server provides Goto Type Definition support. // The server provides Goto Type Definition support.
Utils::optional<std::variant<bool, RegistrationOptions>> typeDefinitionProvider() const; std::optional<std::variant<bool, RegistrationOptions>> typeDefinitionProvider() const;
void setTypeDefinitionProvider(const std::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<std::variant<bool, RegistrationOptions>> implementationProvider() const; std::optional<std::variant<bool, RegistrationOptions>> implementationProvider() const;
void setImplementationProvider(const std::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<std::variant<bool, WorkDoneProgressOptions>> referencesProvider() const; std::optional<std::variant<bool, WorkDoneProgressOptions>> referencesProvider() const;
void setReferencesProvider(const std::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<std::variant<bool, WorkDoneProgressOptions>> documentHighlightProvider() const; std::optional<std::variant<bool, WorkDoneProgressOptions>> documentHighlightProvider() const;
void setDocumentHighlightProvider( void setDocumentHighlightProvider(
const std::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<std::variant<bool, WorkDoneProgressOptions>> documentSymbolProvider() const; std::optional<std::variant<bool, WorkDoneProgressOptions>> documentSymbolProvider() const;
void setDocumentSymbolProvider(std::variant<bool, WorkDoneProgressOptions> documentSymbolProvider); void setDocumentSymbolProvider(std::variant<bool, WorkDoneProgressOptions> documentSymbolProvider);
void clearDocumentSymbolProvider() { remove(documentSymbolProviderKey); } void clearDocumentSymbolProvider() { remove(documentSymbolProviderKey); }
Utils::optional<SemanticTokensOptions> semanticTokensProvider() const; std::optional<SemanticTokensOptions> semanticTokensProvider() const;
void setSemanticTokensProvider(const SemanticTokensOptions &semanticTokensProvider); void setSemanticTokensProvider(const SemanticTokensOptions &semanticTokensProvider);
void clearSemanticTokensProvider() { remove(semanticTokensProviderKey); } void clearSemanticTokensProvider() { remove(semanticTokensProviderKey); }
// The server provides workspace symbol support. // The server provides workspace symbol support.
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> workspaceSymbolProvider() const; std::optional<std::variant<bool, WorkDoneProgressOptions>> workspaceSymbolProvider() const;
void setWorkspaceSymbolProvider(std::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<std::variant<bool, CodeActionOptions>> codeActionProvider() const; std::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)
@@ -342,20 +342,20 @@ public:
void clearCodeActionProvider() { remove(codeActionProviderKey); } void clearCodeActionProvider() { remove(codeActionProviderKey); }
// The server provides code lens. // The server provides code lens.
Utils::optional<CodeLensOptions> codeLensProvider() const std::optional<CodeLensOptions> codeLensProvider() const
{ return optionalValue<CodeLensOptions>(codeLensProviderKey); } { return optionalValue<CodeLensOptions>(codeLensProviderKey); }
void setCodeLensProvider(CodeLensOptions codeLensProvider) void setCodeLensProvider(CodeLensOptions codeLensProvider)
{ insert(codeLensProviderKey, codeLensProvider); } { insert(codeLensProviderKey, codeLensProvider); }
void clearCodeLensProvider() { remove(codeLensProviderKey); } void clearCodeLensProvider() { remove(codeLensProviderKey); }
// The server provides document formatting. // The server provides document formatting.
Utils::optional<std::variant<bool, WorkDoneProgressOptions>> documentFormattingProvider() const; std::optional<std::variant<bool, WorkDoneProgressOptions>> documentFormattingProvider() const;
void setDocumentFormattingProvider( void setDocumentFormattingProvider(
const std::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<std::variant<bool, WorkDoneProgressOptions>> documentRangeFormattingProvider() const; std::optional<std::variant<bool, WorkDoneProgressOptions>> documentRangeFormattingProvider() const;
void setDocumentRangeFormattingProvider(std::variant<bool, WorkDoneProgressOptions> documentRangeFormattingProvider); void setDocumentRangeFormattingProvider(std::variant<bool, WorkDoneProgressOptions> documentRangeFormattingProvider);
void clearDocumentRangeFormattingProvider() { remove(documentRangeFormattingProviderKey); } void clearDocumentRangeFormattingProvider() { remove(documentRangeFormattingProviderKey); }
@@ -365,30 +365,30 @@ public:
using WorkDoneProgressOptions::WorkDoneProgressOptions; using WorkDoneProgressOptions::WorkDoneProgressOptions;
// Renames should be checked and tested before being executed. // Renames should be checked and tested before being executed.
Utils::optional<bool> prepareProvider() const { return optionalValue<bool>(prepareProviderKey); } std::optional<bool> prepareProvider() const { return optionalValue<bool>(prepareProviderKey); }
void setPrepareProvider(bool prepareProvider) { insert(prepareProviderKey, prepareProvider); } void setPrepareProvider(bool prepareProvider) { insert(prepareProviderKey, prepareProvider); }
void clearPrepareProvider() { remove(prepareProviderKey); } void clearPrepareProvider() { remove(prepareProviderKey); }
}; };
// The server provides rename support. // The server provides rename support.
Utils::optional<std::variant<RenameOptions, bool>> renameProvider() const; std::optional<std::variant<RenameOptions, bool>> renameProvider() const;
void setRenameProvider(std::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.
Utils::optional<DocumentLinkOptions> documentLinkProvider() const std::optional<DocumentLinkOptions> documentLinkProvider() const
{ return optionalValue<DocumentLinkOptions>(documentLinkProviderKey); } { return optionalValue<DocumentLinkOptions>(documentLinkProviderKey); }
void setDocumentLinkProvider(const DocumentLinkOptions &documentLinkProvider) void setDocumentLinkProvider(const DocumentLinkOptions &documentLinkProvider)
{ insert(documentLinkProviderKey, documentLinkProvider); } { insert(documentLinkProviderKey, documentLinkProvider); }
void clearDocumentLinkProvider() { remove(documentLinkProviderKey); } void clearDocumentLinkProvider() { remove(documentLinkProviderKey); }
// The server provides color provider support. // The server provides color provider support.
Utils::optional<std::variant<bool, JsonObject>> colorProvider() const; std::optional<std::variant<bool, JsonObject>> colorProvider() const;
void setColorProvider(std::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.
Utils::optional<ExecuteCommandOptions> executeCommandProvider() const std::optional<ExecuteCommandOptions> executeCommandProvider() const
{ return optionalValue<ExecuteCommandOptions>(executeCommandProviderKey); } { return optionalValue<ExecuteCommandOptions>(executeCommandProviderKey); }
void setExecuteCommandProvider(ExecuteCommandOptions executeCommandProvider) void setExecuteCommandProvider(ExecuteCommandOptions executeCommandProvider)
{ insert(executeCommandProviderKey, executeCommandProvider); } { insert(executeCommandProviderKey, executeCommandProvider); }
@@ -405,29 +405,29 @@ public:
using JsonObject::JsonObject; using JsonObject::JsonObject;
// The server has support for workspace folders // The server has support for workspace folders
Utils::optional<bool> supported() const { return optionalValue<bool>(supportedKey); } std::optional<bool> supported() const { return optionalValue<bool>(supportedKey); }
void setSupported(bool supported) { insert(supportedKey, supported); } void setSupported(bool supported) { insert(supportedKey, supported); }
void clearSupported() { remove(supportedKey); } void clearSupported() { remove(supportedKey); }
Utils::optional<std::variant<QString, bool>> changeNotifications() const; std::optional<std::variant<QString, bool>> changeNotifications() const;
void setChangeNotifications(std::variant<QString, bool> changeNotifications); void setChangeNotifications(std::variant<QString, bool> changeNotifications);
void clearChangeNotifications() { remove(changeNotificationsKey); } void clearChangeNotifications() { remove(changeNotificationsKey); }
}; };
Utils::optional<WorkspaceFoldersCapabilities> workspaceFolders() const std::optional<WorkspaceFoldersCapabilities> workspaceFolders() const
{ return optionalValue<WorkspaceFoldersCapabilities>(workspaceFoldersKey); } { return optionalValue<WorkspaceFoldersCapabilities>(workspaceFoldersKey); }
void setWorkspaceFolders(const WorkspaceFoldersCapabilities &workspaceFolders) void setWorkspaceFolders(const WorkspaceFoldersCapabilities &workspaceFolders)
{ insert(workspaceFoldersKey, workspaceFolders); } { insert(workspaceFoldersKey, workspaceFolders); }
void clearWorkspaceFolders() { remove(workspaceFoldersKey); } void clearWorkspaceFolders() { remove(workspaceFoldersKey); }
}; };
Utils::optional<WorkspaceServerCapabilities> workspace() const std::optional<WorkspaceServerCapabilities> workspace() const
{ return optionalValue<WorkspaceServerCapabilities>(workspaceKey); } { return optionalValue<WorkspaceServerCapabilities>(workspaceKey); }
void setWorkspace(const WorkspaceServerCapabilities &workspace) void setWorkspace(const WorkspaceServerCapabilities &workspace)
{ insert(workspaceKey, workspace); } { insert(workspaceKey, workspace); }
void clearWorkspace() { remove(workspaceKey); } void clearWorkspace() { remove(workspaceKey); }
Utils::optional<JsonObject> experimental() const { return optionalValue<JsonObject>(experimentalKey); } std::optional<JsonObject> experimental() const { return optionalValue<JsonObject>(experimentalKey); }
void setExperimental(const JsonObject &experimental) { insert(experimentalKey, experimental); } void setExperimental(const JsonObject &experimental) { insert(experimentalKey, experimental); }
void clearExperimental() { remove(experimentalKey); } void clearExperimental() { remove(experimentalKey); }
}; };

View File

@@ -70,12 +70,12 @@ public:
using JsonObject::JsonObject; using JsonObject::JsonObject;
// The range of the document that changed. // The range of the document that changed.
Utils::optional<Range> range() const { return optionalValue<Range>(rangeKey); } std::optional<Range> range() const { return optionalValue<Range>(rangeKey); }
void setRange(Range range) { insert(rangeKey, range); } void setRange(Range range) { insert(rangeKey, range); }
void clearRange() { remove(rangeKey); } void clearRange() { remove(rangeKey); }
// The length of the range that got replaced. // The length of the range that got replaced.
Utils::optional<int> rangeLength() const { return optionalValue<int>(rangeLengthKey); } std::optional<int> rangeLength() const { return optionalValue<int>(rangeLengthKey); }
void setRangeLength(int rangeLength) { insert(rangeLengthKey, rangeLength); } void setRangeLength(int rangeLength) { insert(rangeLengthKey, rangeLength); }
void clearRangeLength() { remove(rangeLengthKey); } void clearRangeLength() { remove(rangeLengthKey); }
@@ -155,7 +155,7 @@ class LANGUAGESERVERPROTOCOL_EXPORT TextDocumentSaveRegistrationOptions
public: public:
using TextDocumentRegistrationOptions::TextDocumentRegistrationOptions; using TextDocumentRegistrationOptions::TextDocumentRegistrationOptions;
Utils::optional<bool> includeText() const { return optionalValue<bool>(includeTextKey); } std::optional<bool> includeText() const { return optionalValue<bool>(includeTextKey); }
void setIncludeText(bool includeText) { insert(includeTextKey, includeText); } void setIncludeText(bool includeText) { insert(includeTextKey, includeText); }
void clearIncludeText() { remove(includeTextKey); } void clearIncludeText() { remove(includeTextKey); }
}; };
@@ -172,7 +172,7 @@ public:
void setTextDocument(TextDocumentIdentifier textDocument) void setTextDocument(TextDocumentIdentifier textDocument)
{ insert(textDocumentKey, textDocument); } { insert(textDocumentKey, textDocument); }
Utils::optional<QString> text() const { return optionalValue<QString>(textKey); } std::optional<QString> text() const { return optionalValue<QString>(textKey); }
void setText(const QString &text) { insert(textKey, text); } void setText(const QString &text) { insert(textKey, text); }
void clearText() { remove(textKey); } void clearText() { remove(textKey); }

View File

@@ -92,11 +92,11 @@ public:
public: public:
using JsonObject::JsonObject; using JsonObject::JsonObject;
Utils::optional<QString> scopeUri() const { return optionalValue<QString>(scopeUriKey); } std::optional<QString> scopeUri() const { return optionalValue<QString>(scopeUriKey); }
void setScopeUri(const QString &scopeUri) { insert(scopeUriKey, scopeUri); } void setScopeUri(const QString &scopeUri) { insert(scopeUriKey, scopeUri); }
void clearScopeUri() { remove(scopeUriKey); } void clearScopeUri() { remove(scopeUriKey); }
Utils::optional<QString> section() const { return optionalValue<QString>(sectionKey); } std::optional<QString> section() const { return optionalValue<QString>(sectionKey); }
void setSection(const QString &section) { insert(sectionKey, section); } void setSection(const QString &section) { insert(sectionKey, section); }
void clearSection() { remove(sectionKey); } void clearSection() { remove(sectionKey); }
@@ -191,7 +191,7 @@ public:
void setCommand(const QString &command) { insert(commandKey, command); } void setCommand(const QString &command) { insert(commandKey, command); }
void clearCommand() { remove(commandKey); } void clearCommand() { remove(commandKey); }
Utils::optional<QJsonArray> arguments() const { return typedValue<QJsonArray>(argumentsKey); } std::optional<QJsonArray> arguments() const { return typedValue<QJsonArray>(argumentsKey); }
void setArguments(const QJsonArray &arguments) { insert(argumentsKey, arguments); } void setArguments(const QJsonArray &arguments) { insert(argumentsKey, arguments); }
void clearArguments() { remove(argumentsKey); } void clearArguments() { remove(argumentsKey); }
@@ -212,7 +212,7 @@ class LANGUAGESERVERPROTOCOL_EXPORT ApplyWorkspaceEditParams : public JsonObject
public: public:
using JsonObject::JsonObject; using JsonObject::JsonObject;
Utils::optional<QString> label() const { return optionalValue<QString>(labelKey); } std::optional<QString> label() const { return optionalValue<QString>(labelKey); }
void setLabel(const QString &label) { insert(labelKey, label); } void setLabel(const QString &label) { insert(labelKey, label); }
void clearLabel() { remove(labelKey); } void clearLabel() { remove(labelKey); }

View File

@@ -3,9 +3,9 @@
#pragma once #pragma once
#include <utils/optional.h>
#include <utils/smallstringview.h> #include <utils/smallstringview.h>
#include <optional>
#include <type_traits> #include <type_traits>
namespace Sqlite { namespace Sqlite {
@@ -34,7 +34,7 @@ void insertUpdateDelete(SqliteRange &&sqliteRange,
auto endSqliteIterator = sqliteRange.end(); auto endSqliteIterator = sqliteRange.end();
auto currentValueIterator = values.begin(); auto currentValueIterator = values.begin();
auto endValueIterator = values.end(); auto endValueIterator = values.end();
Utils::optional<std::decay_t<decltype(*currentValueIterator)>> lastValue; std::optional<std::decay_t<decltype(*currentValueIterator)>> lastValue;
while (true) { while (true) {
bool hasMoreValues = currentValueIterator != endValueIterator; bool hasMoreValues = currentValueIterator != endValueIterator;

View File

@@ -14,13 +14,13 @@
#include <utils/smallstringvector.h> #include <utils/smallstringvector.h>
#include <utils/optional.h>
#include <utils/span.h> #include <utils/span.h>
#include <cstdint> #include <cstdint>
#include <exception> #include <exception>
#include <functional> #include <functional>
#include <memory> #include <memory>
#include <optional>
#include <tuple> #include <tuple>
#include <type_traits> #include <type_traits>
@@ -225,12 +225,12 @@ public:
auto optionalValue(const QueryTypes &...queryValues) auto optionalValue(const QueryTypes &...queryValues)
{ {
Resetter resetter{this}; Resetter resetter{this};
Utils::optional<ResultType> resultValue; std::optional<ResultType> resultValue;
bindValues(queryValues...); bindValues(queryValues...);
if (BaseStatement::next()) if (BaseStatement::next())
resultValue = createOptionalValue<Utils::optional<ResultType>>(); resultValue = createOptionalValue<std::optional<ResultType>>();
return resultValue; return resultValue;
} }
@@ -495,7 +495,7 @@ private:
template<typename ResultOptionalType, int... ColumnIndices> template<typename ResultOptionalType, int... ColumnIndices>
ResultOptionalType createOptionalValue(std::integer_sequence<int, ColumnIndices...>) ResultOptionalType createOptionalValue(std::integer_sequence<int, ColumnIndices...>)
{ {
return ResultOptionalType(Utils::in_place, ValueGetter(*this, ColumnIndices)...); return ResultOptionalType(std::in_place, ValueGetter(*this, ColumnIndices)...);
} }
template<typename ResultOptionalType> template<typename ResultOptionalType>

View File

@@ -4,7 +4,6 @@ add_qtc_library(Utils
Qt5::Concurrent Qt5::Core Qt5::Network Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Core Qt5::Network Qt5::Gui Qt5::Widgets
Qt6Core5Compat Qt6Core5Compat
SOURCES SOURCES
../3rdparty/optional/optional.hpp
../3rdparty/span/span.hpp ../3rdparty/span/span.hpp
QtConcurrentTools QtConcurrentTools
algorithm.h algorithm.h
@@ -103,7 +102,6 @@ add_qtc_library(Utils
namevaluevalidator.cpp namevaluevalidator.h namevaluevalidator.cpp namevaluevalidator.h
navigationtreeview.cpp navigationtreeview.h navigationtreeview.cpp navigationtreeview.h
networkaccessmanager.cpp networkaccessmanager.h networkaccessmanager.cpp networkaccessmanager.h
optional.h
osspecificaspects.h osspecificaspects.h
outputformat.h outputformat.h
outputformatter.cpp outputformatter.h outputformatter.cpp outputformatter.h

View File

@@ -4,7 +4,6 @@
#pragma once #pragma once
#include "predicates.h" #include "predicates.h"
#include "optional.h"
#include <qcompilerdetection.h> // for Q_REQUIRED_RESULT #include <qcompilerdetection.h> // for Q_REQUIRED_RESULT
@@ -22,6 +21,7 @@
#include <QStringList> #include <QStringList>
#include <memory> #include <memory>
#include <optional>
#include <type_traits> #include <type_traits>
namespace Utils namespace Utils
@@ -187,7 +187,7 @@ auto toConstReferences(const SourceContainer &sources);
// take // take
///////////////////////// /////////////////////////
template<class C, typename P> template<class C, typename P>
Q_REQUIRED_RESULT optional<typename C::value_type> take(C &container, P predicate); Q_REQUIRED_RESULT std::optional<typename C::value_type> take(C &container, P predicate);
template<typename C, typename R, typename S> template<typename C, typename R, typename S>
Q_REQUIRED_RESULT decltype(auto) take(C &container, R S::*member); Q_REQUIRED_RESULT decltype(auto) take(C &container, R S::*member);
template<typename C, typename R, typename S> template<typename C, typename R, typename S>
@@ -1066,15 +1066,15 @@ auto toConstReferences(const SourceContainer &sources)
///////////////// /////////////////
template<class C, typename P> template<class C, typename P>
Q_REQUIRED_RESULT optional<typename C::value_type> take(C &container, P predicate) Q_REQUIRED_RESULT std::optional<typename C::value_type> take(C &container, P predicate)
{ {
const auto end = std::end(container); const auto end = std::end(container);
const auto it = std::find_if(std::begin(container), end, predicate); const auto it = std::find_if(std::begin(container), end, predicate);
if (it == end) if (it == end)
return nullopt; return std::nullopt;
optional<typename C::value_type> result = Utils::make_optional(std::move(*it)); std::optional<typename C::value_type> result = std::make_optional(std::move(*it));
container.erase(it); container.erase(it);
return result; return result;
} }

View File

@@ -89,20 +89,20 @@ static QVector<Tool> toolsForFilePath(const FilePath &fp)
return toolsForMimeType(mimeTypeForFile(fp)); return toolsForMimeType(mimeTypeForFile(fp));
} }
static Utils::optional<Tool> resolveTool(const Tool &tool) static std::optional<Tool> resolveTool(const Tool &tool)
{ {
const FilePath executable = const FilePath executable =
tool.command.executable().withExecutableSuffix().searchInPath(tool.additionalSearchDirs); tool.command.executable().withExecutableSuffix().searchInPath(tool.additionalSearchDirs);
Tool resolvedTool = tool; Tool resolvedTool = tool;
resolvedTool.command.setExecutable(executable); resolvedTool.command.setExecutable(executable);
return executable.isEmpty() ? Utils::nullopt : Utils::make_optional(resolvedTool); return executable.isEmpty() ? std::nullopt : std::make_optional(resolvedTool);
} }
static Utils::optional<Tool> unzipTool(const FilePath &src, const FilePath &dest) static std::optional<Tool> unzipTool(const FilePath &src, const FilePath &dest)
{ {
const QVector<Tool> tools = toolsForFilePath(src); const QVector<Tool> tools = toolsForFilePath(src);
for (const Tool &tool : tools) { for (const Tool &tool : tools) {
const Utils::optional<Tool> resolvedTool = resolveTool(tool); const std::optional<Tool> resolvedTool = resolveTool(tool);
if (resolvedTool) { if (resolvedTool) {
Tool result = *resolvedTool; Tool result = *resolvedTool;
const QString srcStr = src.toString(); const QString srcStr = src.toString();
@@ -138,7 +138,7 @@ bool Archive::supportsFile(const FilePath &filePath, QString *reason)
Archive::Archive(const FilePath &src, const FilePath &dest) Archive::Archive(const FilePath &src, const FilePath &dest)
{ {
const Utils::optional<Tool> tool = unzipTool(src, dest); const std::optional<Tool> tool = unzipTool(src, dest);
if (!tool) if (!tool)
return; return;
m_commandLine = tool->command; m_commandLine = tool->command;

View File

@@ -656,8 +656,8 @@ public:
class IntegerAspectPrivate class IntegerAspectPrivate
{ {
public: public:
Utils::optional<qint64> m_minimumValue; std::optional<qint64> m_minimumValue;
Utils::optional<qint64> m_maximumValue; std::optional<qint64> m_maximumValue;
int m_displayIntegerBase = 10; int m_displayIntegerBase = 10;
qint64 m_displayScaleFactor = 1; qint64 m_displayScaleFactor = 1;
QString m_prefix; QString m_prefix;
@@ -670,8 +670,8 @@ public:
class DoubleAspectPrivate class DoubleAspectPrivate
{ {
public: public:
Utils::optional<double> m_minimumValue; std::optional<double> m_minimumValue;
Utils::optional<double> m_maximumValue; std::optional<double> m_maximumValue;
QString m_prefix; QString m_prefix;
QString m_suffix; QString m_suffix;
QString m_specialValueText; QString m_specialValueText;
@@ -784,7 +784,7 @@ void StringAspect::setValue(const QString &val)
QString processedValue = val; QString processedValue = val;
if (d->m_valueAcceptor) { if (d->m_valueAcceptor) {
const Utils::optional<QString> tmp = d->m_valueAcceptor(value(), val); const std::optional<QString> tmp = d->m_valueAcceptor(value(), val);
if (!tmp) { if (!tmp) {
update(); // Make sure the original value is retained in the UI update(); // Make sure the original value is retained in the UI
return; return;

View File

@@ -7,11 +7,11 @@
#include "id.h" #include "id.h"
#include "infolabel.h" #include "infolabel.h"
#include "macroexpander.h" #include "macroexpander.h"
#include "optional.h"
#include "pathchooser.h" #include "pathchooser.h"
#include <functional> #include <functional>
#include <memory> #include <memory>
#include <optional>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QAction; class QAction;
@@ -337,7 +337,7 @@ public:
void emitChangedValue() override; void emitChangedValue() override;
// Hook between UI and StringAspect: // Hook between UI and StringAspect:
using ValueAcceptor = std::function<Utils::optional<QString>(const QString &, const QString &)>; using ValueAcceptor = std::function<std::optional<QString>(const QString &, const QString &)>;
void setValueAcceptor(ValueAcceptor &&acceptor); void setValueAcceptor(ValueAcceptor &&acceptor);
QString value() const; QString value() const;
void setValue(const QString &val); void setValue(const QString &val);

View File

@@ -406,12 +406,12 @@ const QVector<EnvironmentProvider> EnvironmentProvider::providers()
return *environmentProviders; return *environmentProviders;
} }
optional<EnvironmentProvider> EnvironmentProvider::provider(const QByteArray &id) std::optional<EnvironmentProvider> EnvironmentProvider::provider(const QByteArray &id)
{ {
const int index = indexOf(*environmentProviders, equal(&EnvironmentProvider::id, id)); const int index = indexOf(*environmentProviders, equal(&EnvironmentProvider::id, id));
if (index >= 0) if (index >= 0)
return make_optional(environmentProviders->at(index)); return std::make_optional(environmentProviders->at(index));
return nullopt; return std::nullopt;
} }
void EnvironmentChange::addSetValue(const QString &key, const QString &value) void EnvironmentChange::addSetValue(const QString &key, const QString &value)

View File

@@ -8,9 +8,9 @@
#include "environmentfwd.h" #include "environmentfwd.h"
#include "filepath.h" #include "filepath.h"
#include "namevaluedictionary.h" #include "namevaluedictionary.h"
#include "optional.h"
#include <functional> #include <functional>
#include <optional>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QProcessEnvironment; class QProcessEnvironment;
@@ -150,7 +150,7 @@ public:
static void addProvider(EnvironmentProvider &&provider); static void addProvider(EnvironmentProvider &&provider);
static const QVector<EnvironmentProvider> providers(); static const QVector<EnvironmentProvider> providers();
static optional<EnvironmentProvider> provider(const QByteArray &id); static std::optional<EnvironmentProvider> provider(const QByteArray &id);
}; };
QTCREATOR_UTILS_EXPORT QString qtcEnvironmentVariable(const QString &key); QTCREATOR_UTILS_EXPORT QString qtcEnvironmentVariable(const QString &key);

View File

@@ -7,7 +7,7 @@
namespace Utils { namespace Utils {
Utils::optional<EnvironmentItems> EnvironmentDialog::getEnvironmentItems( std::optional<EnvironmentItems> EnvironmentDialog::getEnvironmentItems(
QWidget *parent, const EnvironmentItems &initial, const QString &placeholderText, Polisher polisher) QWidget *parent, const EnvironmentItems &initial, const QString &placeholderText, Polisher polisher)
{ {
return getNameValueItems( return getNameValueItems(

View File

@@ -15,7 +15,7 @@ class QTCREATOR_UTILS_EXPORT EnvironmentDialog : public NameValuesDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
static Utils::optional<EnvironmentItems> getEnvironmentItems(QWidget *parent = nullptr, static std::optional<EnvironmentItems> getEnvironmentItems(QWidget *parent = nullptr,
const EnvironmentItems &initial = {}, const EnvironmentItems &initial = {},
const QString &placeholderText = {}, const QString &placeholderText = {},
Polisher polish = {}); Polisher polish = {});

View File

@@ -7,7 +7,6 @@
#include "execmenu.h" #include "execmenu.h"
#include "historycompleter.h" #include "historycompleter.h"
#include "hostosinfo.h" #include "hostosinfo.h"
#include "optional.h"
#include "qtcassert.h" #include "qtcassert.h"
#include "utilsicons.h" #include "utilsicons.h"
@@ -22,6 +21,8 @@
#include <QValidator> #include <QValidator>
#include <QWindow> #include <QWindow>
#include <optional>
/*! /*!
\class Utils::FancyLineEdit \class Utils::FancyLineEdit
@@ -202,7 +203,7 @@ FancyLineEdit::~FancyLineEdit()
void FancyLineEdit::setTextKeepingActiveCursor(const QString &text) void FancyLineEdit::setTextKeepingActiveCursor(const QString &text)
{ {
optional<int> cursor = hasFocus() ? make_optional(cursorPosition()) : nullopt; std::optional<int> cursor = hasFocus() ? std::make_optional(cursorPosition()) : std::nullopt;
setText(text); setText(text);
if (cursor) if (cursor)
setCursorPosition(*cursor); setCursorPosition(*cursor);

View File

@@ -767,7 +767,7 @@ bool isWindowsDriveLetter(QChar ch) {
using RootAndPath = QPair<QStringView, QStringView>; using RootAndPath = QPair<QStringView, QStringView>;
optional<RootAndPath> windowsRootAndPath(const QStringView path) std::optional<RootAndPath> windowsRootAndPath(const QStringView path)
{ {
const QChar slash('/'); const QChar slash('/');
QStringView workPath = path; QStringView workPath = path;
@@ -799,7 +799,9 @@ optional<RootAndPath> windowsRootAndPath(const QStringView path)
void FilePath::setRootAndPath(QStringView path, OsType osType) void FilePath::setRootAndPath(QStringView path, OsType osType)
{ {
optional<RootAndPath> windowsDriveAndPath = osType == OsType::OsTypeWindows ? windowsRootAndPath(path) : nullopt; std::optional<RootAndPath> windowsDriveAndPath = osType == OsType::OsTypeWindows
? windowsRootAndPath(path)
: std::nullopt;
if (path.startsWith(QLatin1String("/./"))) { if (path.startsWith(QLatin1String("/./"))) {
m_root = ""; m_root = "";

View File

@@ -6,7 +6,6 @@
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/mimeutils.h> #include <utils/mimeutils.h>
#include <utils/optional.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QApplication> #include <QApplication>
@@ -20,6 +19,7 @@
#include <QIcon> #include <QIcon>
#include <QLoggingCategory> #include <QLoggingCategory>
#include <optional>
#include <variant> #include <variant>
using namespace Utils; using namespace Utils;
@@ -49,7 +49,7 @@ using Item = std::variant<QIcon, QString>; // icon or filename for the icon
namespace Utils { namespace Utils {
namespace FileIconProvider { namespace FileIconProvider {
static Utils::optional<QIcon> getIcon(QHash<QString, Item> &cache, const QString &key) static std::optional<QIcon> getIcon(QHash<QString, Item> &cache, const QString &key)
{ {
auto it = cache.constFind(key); auto it = cache.constFind(key);
if (it == cache.constEnd()) if (it == cache.constEnd())
@@ -188,14 +188,14 @@ QIcon FileIconProviderImplementation::icon(const FilePath &filePath) const
// Check for cached overlay icons by file suffix. // Check for cached overlay icons by file suffix.
const QString filename = !isDir ? filePath.fileName() : QString(); const QString filename = !isDir ? filePath.fileName() : QString();
if (!filename.isEmpty()) { if (!filename.isEmpty()) {
const Utils::optional<QIcon> icon = getIcon(m_filenameCache, filename); const std::optional<QIcon> icon = getIcon(m_filenameCache, filename);
if (icon) if (icon)
return *icon; return *icon;
} }
const QString suffix = !isDir ? filePath.suffix() : QString(); const QString suffix = !isDir ? filePath.suffix() : QString();
if (!suffix.isEmpty()) { if (!suffix.isEmpty()) {
const Utils::optional<QIcon> icon = getIcon(m_suffixCache, suffix); const std::optional<QIcon> icon = getIcon(m_suffixCache, suffix);
if (icon) if (icon)
return *icon; return *icon;
} }

View File

@@ -94,7 +94,7 @@ bool HostOsInfo::canCreateOpenGLContext(QString *errorMessage)
#endif #endif
} }
optional<quint64> HostOsInfo::totalMemoryInstalledInBytes() std::optional<quint64> HostOsInfo::totalMemoryInstalledInBytes()
{ {
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
struct sysinfo info; struct sysinfo info;

View File

@@ -5,9 +5,10 @@
#include "utils_global.h" #include "utils_global.h"
#include "optional.h"
#include "osspecificaspects.h" #include "osspecificaspects.h"
#include <optional>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QString; class QString;
QT_END_NAMESPACE QT_END_NAMESPACE
@@ -83,7 +84,7 @@ public:
static bool canCreateOpenGLContext(QString *errorMessage); static bool canCreateOpenGLContext(QString *errorMessage);
static optional<quint64> totalMemoryInstalledInBytes(); static std::optional<quint64> totalMemoryInstalledInBytes();
private: private:
static Qt::CaseSensitivity m_overrideFileNameCaseSensitivity; static Qt::CaseSensitivity m_overrideFileNameCaseSensitivity;

View File

@@ -5,12 +5,13 @@
#include "utils_global.h" #include "utils_global.h"
#include "optional.h"
#include <QList> #include <QList>
#include <QString> #include <QString>
#include <QVariant> #include <QVariant>
#include <optional>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QLayout; class QLayout;
class QWidget; class QWidget;
@@ -143,7 +144,7 @@ protected:
LayoutItems m_items; LayoutItems m_items;
LayoutType m_layoutType; LayoutType m_layoutType;
Utils::optional<int> m_spacing; std::optional<int> m_spacing;
}; };
class QTCREATOR_UTILS_EXPORT LayoutExtender : public LayoutBuilder class QTCREATOR_UTILS_EXPORT LayoutExtender : public LayoutBuilder

View File

@@ -5,10 +5,10 @@
#include "utils_global.h" #include "utils_global.h"
#include "optional.h"
#include <QMetaType> #include <QMetaType>
#include <optional>
namespace Utils { namespace Utils {
class QTCREATOR_UTILS_EXPORT LineColumn class QTCREATOR_UTILS_EXPORT LineColumn
@@ -39,7 +39,7 @@ public:
int column = -1; int column = -1;
}; };
using OptionalLineColumn = optional<LineColumn>; using OptionalLineColumn = std::optional<LineColumn>;
} // namespace Utils } // namespace Utils

View File

@@ -106,7 +106,7 @@ void NameValuesDialog::setPlaceholderText(const QString &text)
m_editor->setPlaceholderText(text); m_editor->setPlaceholderText(text);
} }
Utils::optional<NameValueItems> NameValuesDialog::getNameValueItems(QWidget *parent, std::optional<NameValueItems> NameValuesDialog::getNameValueItems(QWidget *parent,
const NameValueItems &initial, const NameValueItems &initial,
const QString &placeholderText, const QString &placeholderText,
Polisher polisher, Polisher polisher,

View File

@@ -6,12 +6,12 @@
#include "utils_global.h" #include "utils_global.h"
#include "namevalueitem.h" #include "namevalueitem.h"
#include "optional.h"
#include <QDialog> #include <QDialog>
#include <functional> #include <functional>
#include <memory> #include <memory>
#include <optional>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QPlainTextEdit; class QPlainTextEdit;
@@ -46,7 +46,7 @@ public:
void setPlaceholderText(const QString &text); void setPlaceholderText(const QString &text);
using Polisher = std::function<void(QWidget *)>; using Polisher = std::function<void(QWidget *)>;
static Utils::optional<NameValueItems> getNameValueItems(QWidget *parent = nullptr, static std::optional<NameValueItems> getNameValueItems(QWidget *parent = nullptr,
const NameValueItems &initial = {}, const NameValueItems &initial = {},
const QString &placeholderText = {}, const QString &placeholderText = {},
Polisher polish = {}, Polisher polish = {},

View File

@@ -1,77 +0,0 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
/*
optional<T>
make_optional(t)
See std(::experimental)::optional.
*/
// std::optional from Apple's Clang supports methods that throw std::bad_optional_access only
// with deployment target >= macOS 10.14
// TODO: Use std::optional everywhere when we can require macOS 10.14
#if !defined(__apple_build_version__)
#include <optional>
namespace Utils {
using std::optional;
using std::nullopt;
using std::nullopt_t;
using std::in_place;
// make_optional is a copy, since there is no sensible way to import functions in C++
template<class T>
constexpr optional<std::decay_t<T>> make_optional(T &&v)
{
return optional<std::decay_t<T>>(std::forward<T>(v));
}
template<class T, class... Args>
optional<T> make_optional(Args &&... args)
{
return optional<T>(in_place, std::forward<Args>(args)...);
}
template<class T, class Up, class... Args>
constexpr optional<T> make_optional(std::initializer_list<Up> il, Args &&... args)
{
return optional<T>(in_place, il, std::forward<Args>(args)...);
}
} // namespace Utils
#else
#include <3rdparty/optional/optional.hpp>
namespace Utils {
// --> Utils::optional
using std::experimental::optional;
// --> Utils::nullopt
using std::experimental::nullopt;
using std::experimental::nullopt_t;
// --> Utils::in_place
using std::experimental::in_place;
// TODO: make_optional is a copy, since there is no sensible way to import functions in C++
template <class T>
constexpr optional<typename std::decay<T>::type> make_optional(T&& v)
{
return optional<typename std::decay<T>::type>(std::experimental::constexpr_forward<T>(v));
}
template <class X>
constexpr optional<X&> make_optional(std::reference_wrapper<X> v)
{
return optional<X&>(v.get());
}
} // Utils
#endif

View File

@@ -197,7 +197,7 @@ public:
QTextCursor cursor; QTextCursor cursor;
AnsiEscapeCodeHandler escapeCodeHandler; AnsiEscapeCodeHandler escapeCodeHandler;
QPair<QString, OutputFormat> incompleteLine; QPair<QString, OutputFormat> incompleteLine;
optional<QTextCharFormat> formatOverride; std::optional<QTextCharFormat> formatOverride;
QList<OutputLineParser *> lineParsers; QList<OutputLineParser *> lineParsers;
OutputLineParser *nextParser = nullptr; OutputLineParser *nextParser = nullptr;
FileInProjectFinder fileFinder; FileInProjectFinder fileFinder;

View File

@@ -6,12 +6,12 @@
#include "utils_global.h" #include "utils_global.h"
#include "filepath.h" #include "filepath.h"
#include "optional.h"
#include "outputformat.h" #include "outputformat.h"
#include <QObject> #include <QObject>
#include <functional> #include <functional>
#include <optional>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QPlainTextEdit; class QPlainTextEdit;
@@ -44,13 +44,19 @@ public:
using LinkSpecs = QList<LinkSpec>; using LinkSpecs = QList<LinkSpec>;
class Result { class Result {
public: public:
Result(Status s, const LinkSpecs &l = {}, const optional<QString> &c = {}, Result(Status s,
const optional<OutputFormat> &f = {}) const LinkSpecs &l = {},
: status(s), linkSpecs(l), newContent(c), formatOverride(f) {} const std::optional<QString> &c = {},
const std::optional<OutputFormat> &f = {})
: status(s)
, linkSpecs(l)
, newContent(c)
, formatOverride(f)
{}
Status status; Status status;
LinkSpecs linkSpecs; LinkSpecs linkSpecs;
optional<QString> newContent; // Hard content override. Only to be used in extreme cases. std::optional<QString> newContent; // Hard content override. Only to be used in extreme cases.
optional<OutputFormat> formatOverride; std::optional<OutputFormat> formatOverride;
}; };
static bool isLinkTarget(const QString &target); static bool isLinkTarget(const QString &target);

View File

@@ -253,13 +253,13 @@ auto toRawPointer(const SourceContainer &sources)
// take: // take:
///////////////// /////////////////
template<typename C> template<typename C>
Q_REQUIRED_RESULT optional<ValueType<C>> take(C &container, PointerType<C> p) Q_REQUIRED_RESULT std::optional<ValueType<C>> take(C &container, PointerType<C> p)
{ {
return take(container, [p](const ValueType<C> &v) { return v.get() == p; }); return take(container, [p](const ValueType<C> &v) { return v.get() == p; });
} }
template <typename C> template<typename C>
Q_REQUIRED_RESULT optional<ValueType<C>> take(C &container, std::nullptr_t) Q_REQUIRED_RESULT std::optional<ValueType<C>> take(C &container, std::nullptr_t)
{ {
return take(container, static_cast<PointerType<C>>(nullptr)); return take(container, static_cast<PointerType<C>>(nullptr));
} }

View File

@@ -6,7 +6,6 @@
#include "utils_global.h" #include "utils_global.h"
#include "functiontraits.h" #include "functiontraits.h"
#include "optional.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QFuture> #include <QFuture>
@@ -17,6 +16,7 @@
#include <QThreadPool> #include <QThreadPool>
#include <functional> #include <functional>
#include <optional>
// hasCallOperator & Co must be outside of any namespace // hasCallOperator & Co must be outside of any namespace
// because of internal compiler error with MSVC2015 Update 2 // because of internal compiler error with MSVC2015 Update 2
@@ -38,7 +38,7 @@ struct hasCallOperator
namespace Utils { namespace Utils {
using StackSizeInBytes = optional<uint>; using StackSizeInBytes = std::optional<uint>;
namespace Internal { namespace Internal {

View File

@@ -68,7 +68,7 @@ QVariantMap SettingsAccessor::restoreSettings(QWidget *parent) const
*/ */
bool SettingsAccessor::saveSettings(const QVariantMap &data, QWidget *parent) const bool SettingsAccessor::saveSettings(const QVariantMap &data, QWidget *parent) const
{ {
const optional<Issue> result = writeData(m_baseFilePath, data, parent); const std::optional<Issue> result = writeData(m_baseFilePath, data, parent);
const ProceedInfo pi = result ? reportIssues(result.value(), m_baseFilePath, parent) : ProceedInfo::Continue; const ProceedInfo pi = result ? reportIssues(result.value(), m_baseFilePath, parent) : ProceedInfo::Continue;
return pi == ProceedInfo::Continue; return pi == ProceedInfo::Continue;
@@ -89,8 +89,9 @@ SettingsAccessor::RestoreData SettingsAccessor::readData(const FilePath &path, Q
/*! /*!
* Store the \a data in \a path on disk. Do all the necessary preprocessing of the data. * Store the \a data in \a path on disk. Do all the necessary preprocessing of the data.
*/ */
optional<SettingsAccessor::Issue> std::optional<SettingsAccessor::Issue> SettingsAccessor::writeData(const FilePath &path,
SettingsAccessor::writeData(const FilePath &path, const QVariantMap &data, QWidget *parent) const const QVariantMap &data,
QWidget *parent) const
{ {
Q_UNUSED(parent) Q_UNUSED(parent)
return writeFile(path, prepareToWriteSettings(data)); return writeFile(path, prepareToWriteSettings(data));
@@ -134,8 +135,8 @@ SettingsAccessor::RestoreData SettingsAccessor::readFile(const FilePath &path) c
* *
* This method does not do *any* processing of the file contents. * This method does not do *any* processing of the file contents.
*/ */
optional<SettingsAccessor::Issue> std::optional<SettingsAccessor::Issue> SettingsAccessor::writeFile(const FilePath &path,
SettingsAccessor::writeFile(const FilePath &path, const QVariantMap &data) const const QVariantMap &data) const
{ {
if (data.isEmpty()) { if (data.isEmpty()) {
return Issue(QCoreApplication::translate("Utils::SettingsAccessor", "Failed to Write File"), return Issue(QCoreApplication::translate("Utils::SettingsAccessor", "Failed to Write File"),
@@ -216,11 +217,12 @@ int BackUpStrategy::compare(const SettingsAccessor::RestoreData &data1,
return 0; return 0;
} }
optional<FilePath> std::optional<FilePath> BackUpStrategy::backupName(const QVariantMap &oldData,
BackUpStrategy::backupName(const QVariantMap &oldData, const FilePath &path, const QVariantMap &data) const const FilePath &path,
const QVariantMap &data) const
{ {
if (oldData == data) if (oldData == data)
return nullopt; return std::nullopt;
return path.stringAppended(".bak"); return path.stringAppended(".bak");
} }
@@ -266,8 +268,8 @@ BackingUpSettingsAccessor::readData(const FilePath &path, QWidget *parent) const
return result; return result;
} }
optional<SettingsAccessor::Issue> std::optional<SettingsAccessor::Issue> BackingUpSettingsAccessor::writeData(const FilePath &path,
BackingUpSettingsAccessor::writeData(const FilePath &path, const QVariantMap &data, const QVariantMap &data,
QWidget *parent) const QWidget *parent) const
{ {
if (data.isEmpty()) if (data.isEmpty())
@@ -307,8 +309,11 @@ void BackingUpSettingsAccessor::backupFile(const FilePath &path, const QVariantM
return; return;
// Do we need to do a backup? // Do we need to do a backup?
if (optional<FilePath> backupFileName = m_strategy->backupName(oldSettings.data, path, data)) if (std::optional<FilePath> backupFileName = m_strategy->backupName(oldSettings.data,
path,
data)) {
path.copyFile(backupFileName.value()); path.copyFile(backupFileName.value());
}
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
@@ -337,8 +342,9 @@ int VersionedBackUpStrategy::compare(const SettingsAccessor::RestoreData &data1,
return -1; return -1;
} }
optional<FilePath> std::optional<FilePath> VersionedBackUpStrategy::backupName(const QVariantMap &oldData,
VersionedBackUpStrategy::backupName(const QVariantMap &oldData, const FilePath &path, const QVariantMap &data) const const FilePath &path,
const QVariantMap &data) const
{ {
Q_UNUSED(data) Q_UNUSED(data)
FilePath backupName = path; FilePath backupName = path;
@@ -356,7 +362,7 @@ VersionedBackUpStrategy::backupName(const QVariantMap &oldData, const FilePath &
backupName = backupName.stringAppended('.' + QString::number(oldVersion)); backupName = backupName.stringAppended('.' + QString::number(oldVersion));
} }
if (backupName == path) if (backupName == path)
return nullopt; return std::nullopt;
return backupName; return backupName;
} }
@@ -590,7 +596,7 @@ SettingsAccessor::RestoreData MergingSettingsAccessor::readData(const FilePath &
if (mainData.hasIssue()) { if (mainData.hasIssue()) {
if (reportIssues(mainData.issue.value(), mainData.path, parent) == DiscardAndContinue) if (reportIssues(mainData.issue.value(), mainData.path, parent) == DiscardAndContinue)
mainData.data.clear(); mainData.data.clear();
mainData.issue = nullopt; mainData.issue = std::nullopt;
} }
RestoreData secondaryData RestoreData secondaryData
@@ -628,7 +634,7 @@ SettingsAccessor::RestoreData MergingSettingsAccessor::readData(const FilePath &
if (secondaryData.hasIssue()) { if (secondaryData.hasIssue()) {
if (reportIssues(secondaryData.issue.value(), secondaryData.path, parent) == DiscardAndContinue) if (reportIssues(secondaryData.issue.value(), secondaryData.path, parent) == DiscardAndContinue)
secondaryData.data.clear(); secondaryData.data.clear();
secondaryData.issue = nullopt; secondaryData.issue = std::nullopt;
} }
if (!secondaryData.data.isEmpty()) if (!secondaryData.data.isEmpty())
@@ -736,7 +742,7 @@ static QVariant mergeQVariantMapsRecursion(const QVariantMap &mainTree, const QV
global.key = keyPrefix + key; global.key = keyPrefix + key;
local.key = key; local.key = key;
optional<QPair<QString, QVariant>> mergeResult = merge(global, local); std::optional<QPair<QString, QVariant>> mergeResult = merge(global, local);
if (!mergeResult) if (!mergeResult)
continue; continue;

View File

@@ -6,13 +6,13 @@
#include "utils_global.h" #include "utils_global.h"
#include "filepath.h" #include "filepath.h"
#include "optional.h"
#include <QHash> #include <QHash>
#include <QMessageBox> #include <QMessageBox>
#include <QVariantMap> #include <QVariantMap>
#include <memory> #include <memory>
#include <optional>
namespace Utils { namespace Utils {
@@ -41,7 +41,7 @@ QTCREATOR_UTILS_EXPORT void setOriginalVersionInMap(QVariantMap &data, int versi
QTCREATOR_UTILS_EXPORT void setSettingsIdInMap(QVariantMap &data, const QByteArray &id); QTCREATOR_UTILS_EXPORT void setSettingsIdInMap(QVariantMap &data, const QByteArray &id);
class PersistentSettingsWriter; class PersistentSettingsWriter;
using SettingsMergeResult = optional<QPair<QString, QVariant>>; using SettingsMergeResult = std::optional<QPair<QString, QVariant>>;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// SettingsAccessor: // SettingsAccessor:
@@ -89,7 +89,7 @@ public:
FilePath path; FilePath path;
QVariantMap data; QVariantMap data;
optional<Issue> issue; std::optional<Issue> issue;
}; };
QVariantMap restoreSettings(QWidget *parent) const; QVariantMap restoreSettings(QWidget *parent) const;
@@ -104,7 +104,9 @@ public:
FilePath baseFilePath() const { return m_baseFilePath; } FilePath baseFilePath() const { return m_baseFilePath; }
virtual RestoreData readData(const FilePath &path, QWidget *parent) const; virtual RestoreData readData(const FilePath &path, QWidget *parent) const;
virtual optional<Issue> writeData(const FilePath &path, const QVariantMap &data, QWidget *parent) const; virtual std::optional<Issue> writeData(const FilePath &path,
const QVariantMap &data,
QWidget *parent) const;
protected: protected:
// Report errors: // Report errors:
@@ -115,7 +117,7 @@ protected:
virtual QVariantMap prepareToWriteSettings(const QVariantMap &data) const; virtual QVariantMap prepareToWriteSettings(const QVariantMap &data) const;
virtual RestoreData readFile(const FilePath &path) const; virtual RestoreData readFile(const FilePath &path) const;
virtual optional<Issue> writeFile(const FilePath &path, const QVariantMap &data) const; virtual std::optional<Issue> writeFile(const FilePath &path, const QVariantMap &data) const;
private: private:
FilePath m_baseFilePath; FilePath m_baseFilePath;
@@ -138,8 +140,9 @@ public:
virtual int compare(const SettingsAccessor::RestoreData &data1, virtual int compare(const SettingsAccessor::RestoreData &data1,
const SettingsAccessor::RestoreData &data2) const; const SettingsAccessor::RestoreData &data2) const;
virtual optional<FilePath> virtual std::optional<FilePath> backupName(const QVariantMap &oldData,
backupName(const QVariantMap &oldData, const FilePath &path, const QVariantMap &data) const; const FilePath &path,
const QVariantMap &data) const;
}; };
class QTCREATOR_UTILS_EXPORT BackingUpSettingsAccessor : public SettingsAccessor class QTCREATOR_UTILS_EXPORT BackingUpSettingsAccessor : public SettingsAccessor
@@ -151,7 +154,8 @@ public:
const QString &displayName, const QString &applicationDisplayName); const QString &displayName, const QString &applicationDisplayName);
RestoreData readData(const FilePath &path, QWidget *parent) const override; RestoreData readData(const FilePath &path, QWidget *parent) const override;
optional<Issue> writeData(const FilePath &path, const QVariantMap &data, std::optional<Issue> writeData(const FilePath &path,
const QVariantMap &data,
QWidget *parent) const override; QWidget *parent) const override;
BackUpStrategy *strategy() const { return m_strategy.get(); } BackUpStrategy *strategy() const { return m_strategy.get(); }
@@ -180,8 +184,9 @@ public:
int compare(const SettingsAccessor::RestoreData &data1, int compare(const SettingsAccessor::RestoreData &data1,
const SettingsAccessor::RestoreData &data2) const override; const SettingsAccessor::RestoreData &data2) const override;
optional<FilePath> std::optional<FilePath> backupName(const QVariantMap &oldData,
backupName(const QVariantMap &oldData, const FilePath &path, const QVariantMap &data) const override; const FilePath &path,
const QVariantMap &data) const override;
const UpgradingSettingsAccessor *accessor() const { return m_accessor; } const UpgradingSettingsAccessor *accessor() const { return m_accessor; }

View File

@@ -202,8 +202,6 @@ Project {
"navigationtreeview.h", "navigationtreeview.h",
"networkaccessmanager.cpp", "networkaccessmanager.cpp",
"networkaccessmanager.h", "networkaccessmanager.h",
"optional.h",
"../3rdparty/optional/optional.hpp",
"osspecificaspects.h", "osspecificaspects.h",
"outputformat.h", "outputformat.h",
"outputformatter.cpp", "outputformatter.cpp",

View File

@@ -6,13 +6,13 @@
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/optional.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QLoggingCategory> #include <QLoggingCategory>
#include <QRegularExpression> #include <QRegularExpression>
#include <QSettings> #include <QSettings>
#include <optional>
#include <variant> #include <variant>
namespace { namespace {
@@ -44,7 +44,7 @@ static bool valueForKey(QString key, const QString &line, QString *value = nullp
return false; return false;
} }
static Utils::optional<AndroidDeviceInfo> parseAvd(const QStringList &deviceInfo) static std::optional<AndroidDeviceInfo> parseAvd(const QStringList &deviceInfo)
{ {
AndroidDeviceInfo avd; AndroidDeviceInfo avd;
for (const QString &line : deviceInfo) { for (const QString &line : deviceInfo) {
@@ -100,7 +100,7 @@ AndroidDeviceInfoList parseAvdList(const QString &output, QStringList *avdErrorP
if (valueForKey(avdInfoPathKey, line, &value)) if (valueForKey(avdInfoPathKey, line, &value))
return AvdResult(value); // error path return AvdResult(value); // error path
} }
} else if (Utils::optional<AndroidDeviceInfo> avd = parseAvd(avdInfo)) { } else if (std::optional<AndroidDeviceInfo> avd = parseAvd(avdInfo)) {
// armeabi-v7a devices can also run armeabi code // armeabi-v7a devices can also run armeabi code
if (avd->cpuAbi.contains(Constants::ANDROID_ABI_ARMEABI_V7A)) if (avd->cpuAbi.contains(Constants::ANDROID_ABI_ARMEABI_V7A))
avd->cpuAbi << Constants::ANDROID_ABI_ARMEABI; avd->cpuAbi << Constants::ANDROID_ABI_ARMEABI;

View File

@@ -6,11 +6,11 @@
#include "itestframework.h" #include "itestframework.h"
#include "testtreeitem.h" #include "testtreeitem.h"
#include <utils/optional.h>
#include <QRegularExpression> #include <QRegularExpression>
#include <QVariantHash> #include <QVariantHash>
#include <optional>
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
@@ -35,13 +35,13 @@ public:
} }
} }
Utils::optional<T> get(ITestTreeItem *item) std::optional<T> get(ITestTreeItem *item)
{ {
auto entry = m_cache.find(item->cacheName()); auto entry = m_cache.find(item->cacheName());
if (entry == m_cache.end()) if (entry == m_cache.end())
return Utils::nullopt; return std::nullopt;
entry->generation = 0; entry->generation = 0;
return Utils::make_optional(entry->value); return std::make_optional(entry->value);
}; };
void clear() { m_cache.clear(); } void clear() { m_cache.clear(); }

View File

@@ -314,7 +314,7 @@ bool QtTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureI
for (const TestCase &testCase : testCaseList) { for (const TestCase &testCase : testCaseList) {
if (!testCase.name.isEmpty()) { if (!testCase.name.isEmpty()) {
TestCaseData data; TestCaseData data;
Utils::optional<bool> earlyReturn = fillTestCaseData(testCase.name, doc, data); std::optional<bool> earlyReturn = fillTestCaseData(testCase.name, doc, data);
if (earlyReturn.has_value() || !data.valid) if (earlyReturn.has_value() || !data.valid)
continue; continue;
@@ -333,7 +333,7 @@ bool QtTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureI
return reported; return reported;
} }
Utils::optional<bool> QtTestParser::fillTestCaseData( std::optional<bool> QtTestParser::fillTestCaseData(
const QString &testCaseName, const CPlusPlus::Document::Ptr &doc, const QString &testCaseName, const CPlusPlus::Document::Ptr &doc,
TestCaseData &data) const TestCaseData &data) const
{ {
@@ -366,7 +366,7 @@ Utils::optional<bool> QtTestParser::fillTestCaseData(
data.fileName = Utils::FilePath::fromString(declaringDoc->fileName()); data.fileName = Utils::FilePath::fromString(declaringDoc->fileName());
data.valid = true; data.valid = true;
return Utils::optional<bool>(); return std::optional<bool>();
} }
QtTestParseResult *QtTestParser::createParseResult( QtTestParseResult *QtTestParser::createParseResult(

View File

@@ -8,7 +8,7 @@
#include "qttest_utils.h" #include "qttest_utils.h"
#include "qttesttreeitem.h" #include "qttesttreeitem.h"
#include <utils/optional.h> #include <optional>
namespace CppEditor { class CppModelManager; } namespace CppEditor { class CppModelManager; }
@@ -53,7 +53,7 @@ private:
bool valid = false; bool valid = false;
}; };
Utils::optional<bool> fillTestCaseData(const QString &testCaseName, std::optional<bool> fillTestCaseData(const QString &testCaseName,
const CPlusPlus::Document::Ptr &doc, const CPlusPlus::Document::Ptr &doc,
TestCaseData &data) const; TestCaseData &data) const;
QtTestParseResult *createParseResult(const QString &testCaseName, const TestCaseData &data, QtTestParseResult *createParseResult(const QString &testCaseName, const TestCaseData &data,

View File

@@ -318,7 +318,8 @@ void TestNavigationWidget::reapplyCachedExpandedState()
using namespace Utils; using namespace Utils;
for (TreeItem *rootNode : *m_model->rootItem()) { for (TreeItem *rootNode : *m_model->rootItem()) {
rootNode->forAllChildren([this](TreeItem *child) { rootNode->forAllChildren([this](TreeItem *child) {
optional<bool> cached = m_expandedStateCache.get(static_cast<ITestTreeItem *>(child)); std::optional<bool> cached = m_expandedStateCache.get(
static_cast<ITestTreeItem *>(child));
if (cached.has_value()) { if (cached.has_value()) {
QModelIndex index = child->index(); QModelIndex index = child->index();
if (m_view->isExpanded(index) != cached.value()) if (m_view->isExpanded(index) != cached.value())

View File

@@ -58,7 +58,7 @@ static QIcon testResultIcon(ResultType result) {
return icons[int(result)]; return icons[int(result)];
} }
static QIcon testSummaryIcon(const Utils::optional<TestResultItem::SummaryEvaluation> &summary) static QIcon testSummaryIcon(const std::optional<TestResultItem::SummaryEvaluation> &summary)
{ {
if (!summary) if (!summary)
return QIcon(); return QIcon();
@@ -114,7 +114,7 @@ static bool isSignificant(ResultType type)
} }
void TestResultItem::updateResult(bool &changed, ResultType addedChildType, void TestResultItem::updateResult(bool &changed, ResultType addedChildType,
const Utils::optional<SummaryEvaluation> &summary) const std::optional<SummaryEvaluation> &summary)
{ {
changed = false; changed = false;
if (m_testResult->result() != ResultType::TestStart) if (m_testResult->result() != ResultType::TestStart)

View File

@@ -10,9 +10,10 @@
#include <QSet> #include <QSet>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <utils/optional.h>
#include <utils/treemodel.h> #include <utils/treemodel.h>
#include <optional>
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
@@ -36,16 +37,16 @@ public:
}; };
void updateResult(bool &changed, ResultType addedChildType, void updateResult(bool &changed, ResultType addedChildType,
const Utils::optional<SummaryEvaluation> &summary); const std::optional<SummaryEvaluation> &summary);
TestResultItem *intermediateFor(const TestResultItem *item) const; TestResultItem *intermediateFor(const TestResultItem *item) const;
TestResultItem *createAndAddIntermediateFor(const TestResultItem *child); TestResultItem *createAndAddIntermediateFor(const TestResultItem *child);
QString resultString() const; QString resultString() const;
Utils::optional<SummaryEvaluation> summaryResult() const { return m_summaryResult; } std::optional<SummaryEvaluation> summaryResult() const { return m_summaryResult; }
private: private:
TestResultPtr m_testResult; TestResultPtr m_testResult;
Utils::optional<SummaryEvaluation> m_summaryResult; std::optional<SummaryEvaluation> m_summaryResult;
}; };
class TestResultModel : public Utils::TreeModel<TestResultItem> class TestResultModel : public Utils::TreeModel<TestResultItem>

View File

@@ -259,7 +259,7 @@ void TestTreeModel::onBuildSystemTestsUpdated()
for (const auto &tci : bs->testcasesInfo()) { for (const auto &tci : bs->testcasesInfo()) {
ITestTreeItem *item = testTool->createItemFromTestCaseInfo(tci); ITestTreeItem *item = testTool->createItemFromTestCaseInfo(tci);
QTC_ASSERT(item, continue); QTC_ASSERT(item, continue);
if (Utils::optional<Qt::CheckState> cached = m_checkStateCache->get(item)) if (std::optional<Qt::CheckState> cached = m_checkStateCache->get(item))
item->setData(0, cached.value(), Qt::CheckStateRole); item->setData(0, cached.value(), Qt::CheckStateRole);
m_checkStateCache->insert(item, item->checked()); m_checkStateCache->insert(item, item->checked());
rootNode->appendChild(item); rootNode->appendChild(item);
@@ -393,7 +393,7 @@ void TestTreeModel::synchronizeTestTools()
for (const auto &tci : bs->testcasesInfo()) { for (const auto &tci : bs->testcasesInfo()) {
ITestTreeItem *item = testTool->createItemFromTestCaseInfo(tci); ITestTreeItem *item = testTool->createItemFromTestCaseInfo(tci);
QTC_ASSERT(item, continue); QTC_ASSERT(item, continue);
if (Utils::optional<Qt::CheckState> cached = m_checkStateCache->get(item)) if (std::optional<Qt::CheckState> cached = m_checkStateCache->get(item))
item->setData(0, cached.value(), Qt::CheckStateRole); item->setData(0, cached.value(), Qt::CheckStateRole);
m_checkStateCache->insert(item, item->checked()); m_checkStateCache->insert(item, item->checked());
rootNode->appendChild(item); rootNode->appendChild(item);
@@ -592,13 +592,13 @@ void TestTreeModel::insertItemInParent(TestTreeItem *item, TestTreeItem *root, b
delete item; delete item;
} else { } else {
// restore former check state if available // restore former check state if available
Utils::optional<Qt::CheckState> cached = m_checkStateCache->get(item); std::optional<Qt::CheckState> cached = m_checkStateCache->get(item);
if (cached.has_value()) if (cached.has_value())
item->setData(0, cached.value(), Qt::CheckStateRole); item->setData(0, cached.value(), Qt::CheckStateRole);
else else
applyParentCheckState(parentNode, item); applyParentCheckState(parentNode, item);
// ..and the failed state if available // ..and the failed state if available
Utils::optional<bool> failed = m_failedStateCache.get(item); std::optional<bool> failed = m_failedStateCache.get(item);
if (failed.has_value()) if (failed.has_value())
item->setData(0, *failed, FailedRole); item->setData(0, *failed, FailedRole);
parentNode->appendChild(item); parentNode->appendChild(item);
@@ -717,10 +717,10 @@ void TestTreeModel::handleParseResult(const TestParseResult *result, TestTreeIte
newItem->forAllChildItems([this](TestTreeItem *childItem) { newItem->forAllChildItems([this](TestTreeItem *childItem) {
if (!m_checkStateCache) // parse results may arrive after session switch / project close if (!m_checkStateCache) // parse results may arrive after session switch / project close
return; return;
Utils::optional<Qt::CheckState> cached = m_checkStateCache->get(childItem); std::optional<Qt::CheckState> cached = m_checkStateCache->get(childItem);
if (cached.has_value()) if (cached.has_value())
childItem->setData(0, cached.value(), Qt::CheckStateRole); childItem->setData(0, cached.value(), Qt::CheckStateRole);
Utils::optional<bool> failed = m_failedStateCache.get(childItem); std::optional<bool> failed = m_failedStateCache.get(childItem);
if (failed.has_value()) if (failed.has_value())
childItem->setData(0, *failed, FailedRole); childItem->setData(0, *failed, FailedRole);
}); });

View File

@@ -536,12 +536,12 @@ QChar BinEditorWidget::displayChar(char ch) const
return uc.at(0); return uc.at(0);
} }
Utils::optional<qint64> BinEditorWidget::posAt(const QPoint &pos, bool includeEmptyArea) const std::optional<qint64> BinEditorWidget::posAt(const QPoint &pos, bool includeEmptyArea) const
{ {
const int xoffset = horizontalScrollBar()->value(); const int xoffset = horizontalScrollBar()->value();
int x = xoffset + pos.x() - m_margin - m_labelWidth; int x = xoffset + pos.x() - m_margin - m_labelWidth;
if (!includeEmptyArea && x < 0) if (!includeEmptyArea && x < 0)
return Utils::nullopt; return std::nullopt;
int column = qMin(15, qMax(0,x) / m_columnWidth); int column = qMin(15, qMax(0,x) / m_columnWidth);
const qint64 topLine = verticalScrollBar()->value(); const qint64 topLine = verticalScrollBar()->value();
const qint64 line = topLine + pos.y() / m_lineHeight; const qint64 line = topLine + pos.y() / m_lineHeight;
@@ -559,12 +559,12 @@ Utils::optional<qint64> BinEditorWidget::posAt(const QPoint &pos, bool includeEm
break; break;
} }
if (!includeEmptyArea && x > 0) // right of the text area if (!includeEmptyArea && x > 0) // right of the text area
return Utils::nullopt; return std::nullopt;
} }
const qint64 bytePos = line * m_bytesPerLine + column; const qint64 bytePos = line * m_bytesPerLine + column;
if (!includeEmptyArea && bytePos >= m_size) if (!includeEmptyArea && bytePos >= m_size)
return Utils::nullopt; return std::nullopt;
return qMin(m_size - 1, bytePos); return qMin(m_size - 1, bytePos);
} }
@@ -1163,7 +1163,7 @@ QString BinEditorWidget::toolTip(const QHelpEvent *helpEvent) const
} while (startInLine <= selEnd); } while (startInLine <= selEnd);
if (!insideSelection) { if (!insideSelection) {
// show popup for byte under cursor // show popup for byte under cursor
Utils::optional<qint64> pos = posAt(helpEvent->pos(), /*includeEmptyArea*/false); std::optional<qint64> pos = posAt(helpEvent->pos(), /*includeEmptyArea*/false);
if (!pos) if (!pos)
return QString(); return QString();
selStart = pos.value(); selStart = pos.value();

View File

@@ -8,7 +8,6 @@
#include "bineditorservice.h" #include "bineditorservice.h"
#include <utils/filepath.h> #include <utils/filepath.h>
#include <utils/optional.h>
#include <QAbstractScrollArea> #include <QAbstractScrollArea>
#include <QBasicTimer> #include <QBasicTimer>
@@ -19,6 +18,8 @@
#include <QTextDocument> #include <QTextDocument>
#include <QTextFormat> #include <QTextFormat>
#include <optional>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QHelpEvent; class QHelpEvent;
class QMenu; class QMenu;
@@ -194,7 +195,7 @@ private:
QBasicTimer m_cursorBlinkTimer; QBasicTimer m_cursorBlinkTimer;
void init(); void init();
Utils::optional<qint64> posAt(const QPoint &pos, bool includeEmptyArea = true) const; std::optional<qint64> posAt(const QPoint &pos, bool includeEmptyArea = true) const;
bool inTextArea(const QPoint &pos) const; bool inTextArea(const QPoint &pos) const;
QRect cursorRect() const; QRect cursorRect() const;
void updateLines(); void updateLines();

View File

@@ -23,20 +23,26 @@ static constexpr char16_t arcanaKey[] = u"arcana";
QString ClangdAstNode::role() const { return typedValue<QString>(roleKey); } QString ClangdAstNode::role() const { return typedValue<QString>(roleKey); }
QString ClangdAstNode::kind() const { return typedValue<QString>(kindKey); } QString ClangdAstNode::kind() const { return typedValue<QString>(kindKey); }
optional<QString> ClangdAstNode::detail() const { return optionalValue<QString>(detailKey); } std::optional<QString> ClangdAstNode::detail() const
optional<QString> ClangdAstNode::arcana() const { return optionalValue<QString>(arcanaKey); } {
return optionalValue<QString>(detailKey);
}
std::optional<QString> ClangdAstNode::arcana() const
{
return optionalValue<QString>(arcanaKey);
}
Range ClangdAstNode::range() const { return typedValue<Range>(rangeKey); } Range ClangdAstNode::range() const { return typedValue<Range>(rangeKey); }
bool ClangdAstNode::hasRange() const { return contains(rangeKey); } bool ClangdAstNode::hasRange() const { return contains(rangeKey); }
bool ClangdAstNode::isValid() const { return contains(roleKey) && contains(kindKey); } bool ClangdAstNode::isValid() const { return contains(roleKey) && contains(kindKey); }
optional<QList<ClangdAstNode> > ClangdAstNode::children() const std::optional<QList<ClangdAstNode>> ClangdAstNode::children() const
{ {
return optionalArray<ClangdAstNode>(childrenKey); return optionalArray<ClangdAstNode>(childrenKey);
} }
bool ClangdAstNode::arcanaContains(const QString &s) const bool ClangdAstNode::arcanaContains(const QString &s) const
{ {
const optional<QString> arcanaString = arcana(); const std::optional<QString> arcanaString = arcana();
return arcanaString && arcanaString->contains(s); return arcanaString && arcanaString->contains(s);
} }
@@ -88,7 +94,7 @@ bool ClangdAstNode::isTemplateParameterDeclaration() const
QString ClangCodeModel::Internal::ClangdAstNode::type() const QString ClangCodeModel::Internal::ClangdAstNode::type() const
{ {
const optional<QString> arcanaString = arcana(); const std::optional<QString> arcanaString = arcana();
if (!arcanaString) if (!arcanaString)
return {}; return {};
return typeFromPos(*arcanaString, 0); return typeFromPos(*arcanaString, 0);
@@ -156,7 +162,7 @@ bool ClangdAstNode::hasConstType() const
bool ClangdAstNode::childContainsRange(int index, const LanguageServerProtocol::Range &range) const bool ClangdAstNode::childContainsRange(int index, const LanguageServerProtocol::Range &range) const
{ {
const optional<QList<ClangdAstNode>> childList = children(); const std::optional<QList<ClangdAstNode>> childList = children();
return childList && childList->size() > index && childList->at(index).range().contains(range); return childList && childList->size() > index && childList->at(index).range().contains(range);
} }
@@ -171,7 +177,7 @@ QString ClangdAstNode::operatorString() const
if (kind() == "BinaryOperator") if (kind() == "BinaryOperator")
return detail().value_or(QString()); return detail().value_or(QString());
QTC_ASSERT(kind() == "CXXOperatorCall", return {}); QTC_ASSERT(kind() == "CXXOperatorCall", return {});
const optional<QString> arcanaString = arcana(); const std::optional<QString> arcanaString = arcana();
if (!arcanaString) if (!arcanaString)
return {}; return {};
const int closingQuoteOffset = arcanaString->lastIndexOf('\''); const int closingQuoteOffset = arcanaString->lastIndexOf('\'');
@@ -186,7 +192,7 @@ QString ClangdAstNode::operatorString() const
ClangdAstNode::FileStatus ClangdAstNode::fileStatus(const FilePath &thisFile) const ClangdAstNode::FileStatus ClangdAstNode::fileStatus(const FilePath &thisFile) const
{ {
const optional<QString> arcanaString = arcana(); const std::optional<QString> arcanaString = arcana();
if (!arcanaString) if (!arcanaString)
return FileStatus::Unknown; return FileStatus::Unknown;
@@ -368,7 +374,7 @@ MessageId requestAst(Client *client, const FilePath &filePath, const Range range
// The region of the source code whose AST is fetched. The highest-level node that entirely // The region of the source code whose AST is fetched. The highest-level node that entirely
// contains the range is returned. // contains the range is returned.
optional<Range> range() const { return optionalValue<Range>(rangeKey); } std::optional<Range> range() const { return optionalValue<Range>(rangeKey); }
void setRange(const Range &range) { insert(rangeKey, range); } void setRange(const Range &range) { insert(rangeKey, range); }
bool isValid() const override { return contains(textDocumentKey); } bool isValid() const override { return contains(textDocumentKey); }

View File

@@ -40,11 +40,11 @@ public:
QString kind() const; QString kind() const;
// Brief additional details, such as ||. Information present here depends on the node kind. // Brief additional details, such as ||. Information present here depends on the node kind.
Utils::optional<QString> detail() const; std::optional<QString> detail() const;
// One line dump of information, similar to that printed by clang -Xclang -ast-dump. // One line dump of information, similar to that printed by clang -Xclang -ast-dump.
// Only available for certain types of nodes. // Only available for certain types of nodes.
Utils::optional<QString> arcana() const; std::optional<QString> arcana() const;
// The part of the code that produced this node. Missing for implicit nodes, nodes produced // The part of the code that produced this node. Missing for implicit nodes, nodes produced
// by macro expansion, etc. // by macro expansion, etc.
@@ -52,7 +52,7 @@ public:
// Descendants describing the internal structure. The tree of nodes is similar to that printed // Descendants describing the internal structure. The tree of nodes is similar to that printed
// by clang -Xclang -ast-dump, or that traversed by clang::RecursiveASTVisitor. // by clang -Xclang -ast-dump, or that traversed by clang::RecursiveASTVisitor.
Utils::optional<QList<ClangdAstNode>> children() const; std::optional<QList<ClangdAstNode>> children() const;
bool hasRange() const; bool hasRange() const;
bool arcanaContains(const QString &s) const; bool arcanaContains(const QString &s) const;

View File

@@ -99,7 +99,7 @@ public:
QString usr() const { return typedValue<QString>(usrKey); } QString usr() const { return typedValue<QString>(usrKey); }
// the clangd-specific opaque symbol ID // the clangd-specific opaque symbol ID
Utils::optional<QString> id() const { return optionalValue<QString>(idKey); } std::optional<QString> id() const { return optionalValue<QString>(idKey); }
bool isValid() const override bool isValid() const override
{ {
@@ -206,7 +206,7 @@ public:
m_data.emplace(std::make_pair(doc, VersionedDocData(doc, data))); m_data.emplace(std::make_pair(doc, VersionedDocData(doc, data)));
} }
void remove(const DocType &doc) { m_data.erase(doc); } void remove(const DocType &doc) { m_data.erase(doc); }
Utils::optional<VersionedDocData<DocType, DataType>> take(const DocType &doc) std::optional<VersionedDocData<DocType, DataType>> take(const DocType &doc)
{ {
const auto it = m_data.find(doc); const auto it = m_data.find(doc);
if (it == m_data.end()) if (it == m_data.end())
@@ -215,7 +215,7 @@ public:
m_data.erase(it); m_data.erase(it);
return data; return data;
} }
Utils::optional<DataType> get(const DocType &doc) std::optional<DataType> get(const DocType &doc)
{ {
const auto it = m_data.find(doc); const auto it = m_data.find(doc);
if (it == m_data.end()) if (it == m_data.end())
@@ -251,7 +251,7 @@ public:
: q(q), settings(CppEditor::ClangdProjectSettings(project).settings()) {} : q(q), settings(CppEditor::ClangdProjectSettings(project).settings()) {}
void findUsages(TextDocument *document, const QTextCursor &cursor, void findUsages(TextDocument *document, const QTextCursor &cursor,
const QString &searchTerm, const Utils::optional<QString> &replacement, const QString &searchTerm, const std::optional<QString> &replacement,
bool categorize); bool categorize);
void handleDeclDefSwitchReplies(); void handleDeclDefSwitchReplies();
@@ -275,7 +275,7 @@ public:
ClangdFollowSymbol *followSymbol = nullptr; ClangdFollowSymbol *followSymbol = nullptr;
ClangdSwitchDeclDef *switchDeclDef = nullptr; ClangdSwitchDeclDef *switchDeclDef = nullptr;
ClangdFindLocalReferences *findLocalRefs = nullptr; ClangdFindLocalReferences *findLocalRefs = nullptr;
Utils::optional<QVersionNumber> versionNumber; std::optional<QVersionNumber> versionNumber;
QHash<TextDocument *, HighlightingData> highlightingData; QHash<TextDocument *, HighlightingData> highlightingData;
QHash<Utils::FilePath, CppEditor::BaseEditorDocumentParser::Configuration> parserConfigs; QHash<Utils::FilePath, CppEditor::BaseEditorDocumentParser::Configuration> parserConfigs;
@@ -354,7 +354,7 @@ ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir)
for (const Client *client : clients) for (const Client *client : clients)
qCWarning(clangdLog) << client->name() << client->stateString(); qCWarning(clangdLog) << client->name() << client->stateString();
ClientCapabilities caps = Client::defaultClientCapabilities(); ClientCapabilities caps = Client::defaultClientCapabilities();
Utils::optional<TextDocumentClientCapabilities> textCaps = caps.textDocument(); std::optional<TextDocumentClientCapabilities> textCaps = caps.textDocument();
if (textCaps) { if (textCaps) {
ClangdTextDocumentClientCapabilities clangdTextCaps(*textCaps); ClangdTextDocumentClientCapabilities clangdTextCaps(*textCaps);
clangdTextCaps.clearDocumentHighlight(); clangdTextCaps.clearDocumentHighlight();
@@ -362,7 +362,7 @@ ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir)
diagnostics.enableCategorySupport(); diagnostics.enableCategorySupport();
diagnostics.enableCodeActionsInline(); diagnostics.enableCodeActionsInline();
clangdTextCaps.setPublishDiagnostics(diagnostics); clangdTextCaps.setPublishDiagnostics(diagnostics);
Utils::optional<TextDocumentClientCapabilities::CompletionCapabilities> completionCaps std::optional<TextDocumentClientCapabilities::CompletionCapabilities> completionCaps
= textCaps->completion(); = textCaps->completion();
if (completionCaps) if (completionCaps)
clangdTextCaps.setCompletion(ClangdCompletionCapabilities(*completionCaps)); clangdTextCaps.setCompletion(ClangdCompletionCapabilities(*completionCaps));
@@ -441,7 +441,7 @@ void ClangdClient::closeExtraFile(const Utils::FilePath &filePath)
} }
void ClangdClient::findUsages(TextDocument *document, const QTextCursor &cursor, void ClangdClient::findUsages(TextDocument *document, const QTextCursor &cursor,
const Utils::optional<QString> &replacement) const std::optional<QString> &replacement)
{ {
// Quick check: Are we even on anything searchable? // Quick check: Are we even on anything searchable?
const QTextCursor adjustedCursor = d->adjustedCursor(cursor, document); const QTextCursor adjustedCursor = d->adjustedCursor(cursor, document);
@@ -615,7 +615,7 @@ CppEditor::ClangdSettings::Data ClangdClient::settingsData() const { return d->s
void ClangdClient::Private::findUsages(TextDocument *document, void ClangdClient::Private::findUsages(TextDocument *document,
const QTextCursor &cursor, const QString &searchTerm, const QTextCursor &cursor, const QString &searchTerm,
const Utils::optional<QString> &replacement, bool categorize) const std::optional<QString> &replacement, bool categorize)
{ {
const auto findRefs = new ClangdFindReferences(q, document, cursor, searchTerm, replacement, const auto findRefs = new ClangdFindReferences(q, document, cursor, searchTerm, replacement,
categorize); categorize);
@@ -753,7 +753,7 @@ void ClangdClient::clearTasks(const Utils::FilePath &filePath)
d->issuePaneEntries[filePath].clear(); d->issuePaneEntries[filePath].clear();
} }
Utils::optional<bool> ClangdClient::hasVirtualFunctionAt(TextDocument *doc, int revision, std::optional<bool> ClangdClient::hasVirtualFunctionAt(TextDocument *doc, int revision,
const Range &range) const Range &range)
{ {
const auto highlightingData = d->highlightingData.constFind(doc); const auto highlightingData = d->highlightingData.constFind(doc);
@@ -860,7 +860,7 @@ void ClangdClient::switchHeaderSource(const Utils::FilePath &filePath, bool inNe
}; };
SwitchSourceHeaderRequest req(filePath); SwitchSourceHeaderRequest req(filePath);
req.setResponseCallback([inNextSplit](const SwitchSourceHeaderRequest::Response &response) { req.setResponseCallback([inNextSplit](const SwitchSourceHeaderRequest::Response &response) {
if (const Utils::optional<QJsonValue> result = response.result()) { if (const std::optional<QJsonValue> result = response.result()) {
const DocumentUri uri = DocumentUri::fromProtocol(result->toString()); const DocumentUri uri = DocumentUri::fromProtocol(result->toString());
const Utils::FilePath filePath = uri.toFilePath(); const Utils::FilePath filePath = uri.toFilePath();
if (!filePath.isEmpty()) if (!filePath.isEmpty())
@@ -900,7 +900,7 @@ void ClangdClient::findLocalUsages(TextDocument *document, const QTextCursor &cu
void ClangdClient::gatherHelpItemForTooltip(const HoverRequest::Response &hoverResponse, void ClangdClient::gatherHelpItemForTooltip(const HoverRequest::Response &hoverResponse,
const DocumentUri &uri) const DocumentUri &uri)
{ {
if (const Utils::optional<HoverResult> result = hoverResponse.result()) { if (const std::optional<HoverResult> result = hoverResponse.result()) {
if (auto hover = std::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 = std::get_if<MarkupContent>(&content); const MarkupContent *const markup = std::get_if<MarkupContent>(&content);
@@ -942,7 +942,7 @@ void ClangdClient::gatherHelpItemForTooltip(const HoverRequest::Response &hoverR
const auto astHandler = [this, uri, hoverResponse](const ClangdAstNode &ast, const MessageId &) { const auto astHandler = [this, uri, hoverResponse](const ClangdAstNode &ast, const MessageId &) {
const MessageId id = hoverResponse.id(); const MessageId id = hoverResponse.id();
Range range; Range range;
if (const Utils::optional<HoverResult> result = hoverResponse.result()) { if (const std::optional<HoverResult> result = hoverResponse.result()) {
if (auto hover = std::get_if<Hover>(&(*result))) if (auto hover = std::get_if<Hover>(&(*result)))
range = hover->range().value_or(Range()); range = hover->range().value_or(Range());
} }
@@ -953,12 +953,12 @@ void ClangdClient::gatherHelpItemForTooltip(const HoverRequest::Response &hoverR
} }
ClangdAstNode node = path.last(); ClangdAstNode node = path.last();
if (node.role() == "expression" && node.kind() == "ImplicitCast") { if (node.role() == "expression" && node.kind() == "ImplicitCast") {
const Utils::optional<QList<ClangdAstNode>> children = node.children(); const std::optional<QList<ClangdAstNode>> children = node.children();
if (children && !children->isEmpty()) if (children && !children->isEmpty())
node = children->first(); node = children->first();
} }
while (node.kind() == "Qualified") { while (node.kind() == "Qualified") {
const Utils::optional<QList<ClangdAstNode>> children = node.children(); const std::optional<QList<ClangdAstNode>> children = node.children();
if (children && !children->isEmpty()) if (children && !children->isEmpty())
node = children->first(); node = children->first();
} }
@@ -1120,7 +1120,7 @@ QTextCursor ClangdClient::Private::adjustedCursor(const QTextCursor &cursor,
case T_DOT: case T_DOT:
break; break;
case T_ARROW: { case T_ARROW: {
const Utils::optional<ClangdAstNode> clangdAst = astCache.get(doc); const std::optional<ClangdAstNode> clangdAst = astCache.get(doc);
if (!clangdAst) if (!clangdAst)
return cursor; return cursor;
const ClangdAstPath clangdAstPath = getAstPath(*clangdAst, Range(cursor)); const ClangdAstPath clangdAstPath = getAstPath(*clangdAst, Range(cursor));
@@ -1289,7 +1289,7 @@ void ClangdClient::Private::handleSemanticTokens(TextDocument *doc,
getAndHandleAst(doc, astHandler, AstCallbackMode::SyncIfPossible); getAndHandleAst(doc, astHandler, AstCallbackMode::SyncIfPossible);
} }
Utils::optional<QList<CodeAction> > ClangdDiagnostic::codeActions() const std::optional<QList<CodeAction> > ClangdDiagnostic::codeActions() const
{ {
auto actions = optionalArray<LanguageServerProtocol::CodeAction>(u"codeActions"); auto actions = optionalArray<LanguageServerProtocol::CodeAction>(u"codeActions");
if (!actions) if (!actions)

View File

@@ -9,10 +9,11 @@
#include <cppeditor/cursorineditor.h> #include <cppeditor/cursorineditor.h>
#include <languageclient/client.h> #include <languageclient/client.h>
#include <utils/link.h> #include <utils/link.h>
#include <utils/optional.h>
#include <QVersionNumber> #include <QVersionNumber>
#include <optional>
namespace CppEditor { class CppEditorWidget; } namespace CppEditor { class CppEditorWidget; }
namespace LanguageServerProtocol { class Range; } namespace LanguageServerProtocol { class Range; }
namespace ProjectExplorer { namespace ProjectExplorer {
@@ -48,7 +49,7 @@ public:
void closeExtraFile(const Utils::FilePath &filePath); void closeExtraFile(const Utils::FilePath &filePath);
void findUsages(TextEditor::TextDocument *document, const QTextCursor &cursor, void findUsages(TextEditor::TextDocument *document, const QTextCursor &cursor,
const Utils::optional<QString> &replacement); const std::optional<QString> &replacement);
void followSymbol(TextEditor::TextDocument *document, void followSymbol(TextEditor::TextDocument *document,
const QTextCursor &cursor, const QTextCursor &cursor,
CppEditor::CppEditorWidget *editorWidget, CppEditor::CppEditorWidget *editorWidget,
@@ -85,7 +86,7 @@ public:
void switchIssuePaneEntries(const Utils::FilePath &filePath); void switchIssuePaneEntries(const Utils::FilePath &filePath);
void addTask(const ProjectExplorer::Task &task); void addTask(const ProjectExplorer::Task &task);
void clearTasks(const Utils::FilePath &filePath); void clearTasks(const Utils::FilePath &filePath);
Utils::optional<bool> hasVirtualFunctionAt(TextEditor::TextDocument *doc, int revision, std::optional<bool> hasVirtualFunctionAt(TextEditor::TextDocument *doc, int revision,
const LanguageServerProtocol::Range &range); const LanguageServerProtocol::Range &range);
using TextDocOrFile = std::variant<const TextEditor::TextDocument *, Utils::FilePath>; using TextDocOrFile = std::variant<const TextEditor::TextDocument *, Utils::FilePath>;
@@ -136,7 +137,7 @@ class ClangdDiagnostic : public LanguageServerProtocol::Diagnostic
{ {
public: public:
using Diagnostic::Diagnostic; using Diagnostic::Diagnostic;
Utils::optional<QList<LanguageServerProtocol::CodeAction>> codeActions() const; std::optional<QList<LanguageServerProtocol::CodeAction>> codeActions() const;
QString category() const; QString category() const;
}; };

View File

@@ -336,7 +336,7 @@ void ClangdCompletionItem::apply(TextDocumentManipulatorInterface &manipulator,
ClangdCompletionItem::SpecialQtType ClangdCompletionItem::getQtType(const CompletionItem &item) ClangdCompletionItem::SpecialQtType ClangdCompletionItem::getQtType(const CompletionItem &item)
{ {
const Utils::optional<MarkupOrString> doc = item.documentation(); const std::optional<MarkupOrString> doc = item.documentation();
if (!doc) if (!doc)
return SpecialQtType::None; return SpecialQtType::None;
QString docText; QString docText;
@@ -612,7 +612,7 @@ ClangdCompletionCapabilities::ClangdCompletionCapabilities(const JsonObject &obj
: TextDocumentClientCapabilities::CompletionCapabilities(object) : TextDocumentClientCapabilities::CompletionCapabilities(object)
{ {
insert(u"editsNearCursor", true); // For dot-to-arrow correction. insert(u"editsNearCursor", true); // For dot-to-arrow correction.
if (Utils::optional<CompletionItemCapbilities> completionItemCaps = completionItem()) { if (std::optional<CompletionItemCapbilities> completionItemCaps = completionItem()) {
completionItemCaps->setSnippetSupport(false); completionItemCaps->setSnippetSupport(false);
setCompletionItem(*completionItemCaps); setCompletionItem(*completionItemCaps);
} }

View File

@@ -65,21 +65,21 @@ public:
void finishSearch(); void finishSearch();
void reportAllSearchResultsAndFinish(); void reportAllSearchResultsAndFinish();
void addSearchResultsForFile(const FilePath &file, const ReferencesFileData &fileData); void addSearchResultsForFile(const FilePath &file, const ReferencesFileData &fileData);
Utils::optional<QString> getContainingFunctionName(const ClangdAstPath &astPath, std::optional<QString> getContainingFunctionName(const ClangdAstPath &astPath,
const Range& range); const Range& range);
ClangdFindReferences * const q; ClangdFindReferences * const q;
QMap<DocumentUri, ReferencesFileData> fileData; QMap<DocumentUri, ReferencesFileData> fileData;
QList<MessageId> pendingAstRequests; QList<MessageId> pendingAstRequests;
QPointer<SearchResult> search; QPointer<SearchResult> search;
Utils::optional<ReplacementData> replacementData; std::optional<ReplacementData> replacementData;
bool canceled = false; bool canceled = false;
bool categorize = false; bool categorize = false;
}; };
ClangdFindReferences::ClangdFindReferences(ClangdClient *client, TextDocument *document, ClangdFindReferences::ClangdFindReferences(ClangdClient *client, TextDocument *document,
const QTextCursor &cursor, const QString &searchTerm, const QTextCursor &cursor, const QString &searchTerm,
const Utils::optional<QString> &replacement, bool categorize) const std::optional<QString> &replacement, bool categorize)
: QObject(client), d(new ClangdFindReferences::Private(this)) : QObject(client), d(new ClangdFindReferences::Private(this))
{ {
d->categorize = categorize; d->categorize = categorize;
@@ -121,7 +121,7 @@ ClangdFindReferences::ClangdFindReferences(ClangdClient *client, TextDocument *d
}); });
SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus); SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
const Utils::optional<MessageId> requestId = client->symbolSupport().findUsages( const std::optional<MessageId> requestId = client->symbolSupport().findUsages(
document, cursor, [self = QPointer(this)](const QList<Location> &locations) { document, cursor, [self = QPointer(this)](const QList<Location> &locations) {
if (self) if (self)
self->d->handleFindUsagesResult(locations); self->d->handleFindUsagesResult(locations);
@@ -324,7 +324,7 @@ void ClangdFindReferences::Private::addSearchResultsForFile(const FilePath &file
search->addResults(items, SearchResult::AddOrdered); search->addResults(items, SearchResult::AddOrdered);
} }
Utils::optional<QString> ClangdFindReferences::Private::getContainingFunctionName( std::optional<QString> ClangdFindReferences::Private::getContainingFunctionName(
const ClangdAstPath &astPath, const Range& range) const ClangdAstPath &astPath, const Range& range)
{ {
const ClangdAstNode* containingFuncNode{nullptr}; const ClangdAstNode* containingFuncNode{nullptr};
@@ -344,7 +344,7 @@ Utils::optional<QString> ClangdFindReferences::Private::getContainingFunctionNam
} }
if (!containingFuncNode || !containingFuncNode->isValid()) if (!containingFuncNode || !containingFuncNode->isValid())
return Utils::nullopt; return std::nullopt;
return containingFuncNode->detail(); return containingFuncNode->detail();
} }

View File

@@ -5,10 +5,11 @@
#include <coreplugin/find/searchresultitem.h> #include <coreplugin/find/searchresultitem.h>
#include <cppeditor/cursorineditor.h> #include <cppeditor/cursorineditor.h>
#include <utils/optional.h>
#include <QObject> #include <QObject>
#include <optional>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QTextCursor; class QTextCursor;
QT_END_NAMESPACE QT_END_NAMESPACE
@@ -24,7 +25,7 @@ class ClangdFindReferences : public QObject
public: public:
explicit ClangdFindReferences(ClangdClient *client, TextEditor::TextDocument *document, explicit ClangdFindReferences(ClangdClient *client, TextEditor::TextDocument *document,
const QTextCursor &cursor, const QString &searchTerm, const QTextCursor &cursor, const QString &searchTerm,
const Utils::optional<QString> &replacement, bool categorize); const std::optional<QString> &replacement, bool categorize);
~ClangdFindReferences(); ~ClangdFindReferences();
signals: signals:

View File

@@ -107,7 +107,7 @@ public:
Link defLink; Link defLink;
Links allLinks; Links allLinks;
QHash<Link, Link> declDefMap; QHash<Link, Link> declDefMap;
optional<ClangdAstNode> cursorNode; std::optional<ClangdAstNode> cursorNode;
ClangdAstNode defLinkNode; ClangdAstNode defLinkNode;
SymbolDataList symbolsToDisplay; SymbolDataList symbolsToDisplay;
std::set<FilePath> openedFiles; std::set<FilePath> openedFiles;
@@ -375,7 +375,7 @@ void ClangdFollowSymbol::Private::handleGotoDefinitionResult()
void ClangdFollowSymbol::Private::handleGotoImplementationResult( void ClangdFollowSymbol::Private::handleGotoImplementationResult(
const GotoImplementationRequest::Response &response) const GotoImplementationRequest::Response &response)
{ {
if (const optional<GotoResult> &result = response.result()) { if (const std::optional<GotoResult> &result = response.result()) {
QList<Link> newLinks; QList<Link> newLinks;
if (const auto ploc = std::get_if<Location>(&*result)) if (const auto ploc = std::get_if<Location>(&*result))
newLinks = {ploc->toLink()}; newLinks = {ploc->toLink()};
@@ -451,7 +451,7 @@ void ClangdFollowSymbol::Private::handleGotoImplementationResult(
if (!sentinel) if (!sentinel)
return; return;
Link newLink; Link newLink;
if (optional<GotoResult> _result = response.result()) { if (std::optional<GotoResult> _result = response.result()) {
const GotoResult result = _result.value(); const GotoResult result = _result.value();
if (const auto ploc = std::get_if<Location>(&result)) { if (const auto ploc = std::get_if<Location>(&result)) {
newLink = ploc->toLink(); newLink = ploc->toLink();

View File

@@ -131,7 +131,7 @@ public:
const QPointer<ClangdClient> client; const QPointer<ClangdClient> client;
MemoryTreeModel model; MemoryTreeModel model;
TreeView view; TreeView view;
Utils::optional<MessageId> currentRequest; std::optional<MessageId> currentRequest;
}; };
ClangdMemoryUsageWidget::ClangdMemoryUsageWidget(ClangdClient *client) ClangdMemoryUsageWidget::ClangdMemoryUsageWidget(ClangdClient *client)

View File

@@ -65,7 +65,7 @@ private:
auto toOperation = auto toOperation =
[=](const std::variant<Command, CodeAction> &item) -> QuickFixOperation * { [=](const std::variant<Command, CodeAction> &item) -> QuickFixOperation * {
if (auto action = std::get_if<CodeAction>(&item)) { if (auto action = std::get_if<CodeAction>(&item)) {
const Utils::optional<QList<Diagnostic>> diagnostics = action->diagnostics(); const std::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());
} }

View File

@@ -10,12 +10,13 @@
#include <languageclient/documentsymbolcache.h> #include <languageclient/documentsymbolcache.h>
#include <languageserverprotocol/lsptypes.h> #include <languageserverprotocol/lsptypes.h>
#include <texteditor/textdocument.h> #include <texteditor/textdocument.h>
#include <utils/optional.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QApplication> #include <QApplication>
#include <QTextCursor> #include <QTextCursor>
#include <optional>
using namespace CppEditor; using namespace CppEditor;
using namespace LanguageClient; using namespace LanguageClient;
using namespace LanguageServerProtocol; using namespace LanguageServerProtocol;
@@ -33,7 +34,7 @@ public:
cursor(cursor), editorWidget(editorWidget), callback(callback) cursor(cursor), editorWidget(editorWidget), callback(callback)
{} {}
optional<ClangdAstNode> getFunctionNode() const; std::optional<ClangdAstNode> getFunctionNode() const;
QTextCursor cursorForFunctionName(const ClangdAstNode &functionNode) const; QTextCursor cursorForFunctionName(const ClangdAstNode &functionNode) const;
void handleDeclDefSwitchReplies(); void handleDeclDefSwitchReplies();
@@ -44,8 +45,8 @@ public:
const QTextCursor cursor; const QTextCursor cursor;
const QPointer<CppEditorWidget> editorWidget; const QPointer<CppEditorWidget> editorWidget;
const LinkHandler callback; const LinkHandler callback;
optional<ClangdAstNode> ast; std::optional<ClangdAstNode> ast;
optional<DocumentSymbolsResult> docSymbols; std::optional<DocumentSymbolsResult> docSymbols;
bool done = false; bool done = false;
}; };
@@ -110,7 +111,7 @@ void ClangdSwitchDeclDef::emitDone()
emit done(); emit done();
} }
optional<ClangdAstNode> ClangdSwitchDeclDef::Private::getFunctionNode() const std::optional<ClangdAstNode> ClangdSwitchDeclDef::Private::getFunctionNode() const
{ {
QTC_ASSERT(ast, return {}); QTC_ASSERT(ast, return {});
@@ -157,7 +158,7 @@ void ClangdSwitchDeclDef::Private::handleDeclDefSwitchReplies()
// on a function return type, or ... // on a function return type, or ...
if (clangdLogAst().isDebugEnabled()) if (clangdLogAst().isDebugEnabled())
ast->print(0); ast->print(0);
const Utils::optional<ClangdAstNode> functionNode = getFunctionNode(); const std::optional<ClangdAstNode> functionNode = getFunctionNode();
if (!functionNode) { if (!functionNode) {
q->emitDone(); q->emitDone();
return; return;

View File

@@ -215,10 +215,10 @@ ClangDiagnostic convertDiagnostic(const ClangdDiagnostic &src, const FilePath &f
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>())) {
const Utils::optional<WorkspaceEdit> edit = codeAction.edit(); const std::optional<WorkspaceEdit> edit = codeAction.edit();
if (!edit) if (!edit)
continue; continue;
const Utils::optional<WorkspaceEdit::Changes> changes = edit->changes(); const std::optional<WorkspaceEdit::Changes> changes = edit->changes();
if (!changes) if (!changes)
continue; continue;
ClangDiagnostic fixItDiag; ClangDiagnostic fixItDiag;

View File

@@ -706,7 +706,7 @@ bool ClangFormatBaseIndenter::isElectricCharacter(const QChar &ch) const
return false; return false;
} }
Utils::optional<int> ClangFormat::ClangFormatBaseIndenter::margin() const std::optional<int> ClangFormat::ClangFormatBaseIndenter::margin() const
{ {
return styleForFile().ColumnLimit; return styleForFile().ColumnLimit;
} }

View File

@@ -44,7 +44,7 @@ public:
bool isElectricCharacter(const QChar &ch) const override; bool isElectricCharacter(const QChar &ch) const override;
Utils::optional<int> margin() const override; std::optional<int> margin() const override;
clang::format::FormatStyle styleForFile() const; clang::format::FormatStyle styleForFile() const;

View File

@@ -55,7 +55,7 @@ bool ClangFormatIndenter::formatCodeInsteadOfIndent() const
return ClangFormatSettings::instance().mode() == ClangFormatSettings::Mode::Formatting; return ClangFormatSettings::instance().mode() == ClangFormatSettings::Mode::Formatting;
} }
Utils::optional<TabSettings> ClangFormatIndenter::tabSettings() const std::optional<TabSettings> ClangFormatIndenter::tabSettings() const
{ {
FormatStyle style = styleForFile(); FormatStyle style = styleForFile();
TabSettings tabSettings; TabSettings tabSettings;

View File

@@ -13,7 +13,7 @@ class ClangFormatIndenter final : public ClangFormatBaseIndenter
{ {
public: public:
ClangFormatIndenter(QTextDocument *doc); ClangFormatIndenter(QTextDocument *doc);
Utils::optional<TextEditor::TabSettings> tabSettings() const override; std::optional<TextEditor::TabSettings> tabSettings() const override;
bool formatOnSave() const override; bool formatOnSave() const override;
private: private:

View File

@@ -7,12 +7,13 @@
#include <texteditor/tabsettings.h> #include <texteditor/tabsettings.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/optional.h>
#include <QTextCursor> #include <QTextCursor>
#include <QTextDocument> #include <QTextDocument>
#include <QtTest> #include <QtTest>
#include <optional>
namespace ClangFormat::Internal { namespace ClangFormat::Internal {
class ClangFormatTestIndenter : public ClangFormatBaseIndenter class ClangFormatTestIndenter : public ClangFormatBaseIndenter
@@ -21,7 +22,7 @@ public:
ClangFormatTestIndenter(QTextDocument *doc) : ClangFormatBaseIndenter(doc) {} ClangFormatTestIndenter(QTextDocument *doc) : ClangFormatBaseIndenter(doc) {}
private: private:
Utils::optional<TextEditor::TabSettings> tabSettings() const override { return {}; } std::optional<TextEditor::TabSettings> tabSettings() const override { return {}; }
}; };
class ClangFormatExtendedTestIndenter : public ClangFormatTestIndenter class ClangFormatExtendedTestIndenter : public ClangFormatTestIndenter

View File

@@ -10,7 +10,6 @@
#include <debugger/analyzer/detailederrorview.h> #include <debugger/analyzer/detailederrorview.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/optional.h>
#include <utils/treemodel.h> #include <utils/treemodel.h>
#include <QFileSystemWatcher> #include <QFileSystemWatcher>
@@ -21,6 +20,7 @@
#include <functional> #include <functional>
#include <map> #include <map>
#include <memory> #include <memory>
#include <optional>
namespace ProjectExplorer { class Project; } namespace ProjectExplorer { class Project; }
@@ -127,7 +127,7 @@ class FilterOptions {
public: public:
QSet<QString> checks; QSet<QString> checks;
}; };
using OptionalFilterOptions = Utils::optional<FilterOptions>; using OptionalFilterOptions = std::optional<FilterOptions>;
class DiagnosticFilterModel : public QSortFilterProxyModel class DiagnosticFilterModel : public QSortFilterProxyModel
{ {

View File

@@ -31,7 +31,7 @@ static bool checkFilePath(const Utils::FilePath &filePath, QString *errorMessage
return true; return true;
} }
Utils::optional<LineColumnInfo> byteOffsetInUtf8TextToLineColumn(const char *text, std::optional<LineColumnInfo> byteOffsetInUtf8TextToLineColumn(const char *text,
int offset, int offset,
int startLine) int startLine)
{ {

View File

@@ -3,10 +3,11 @@
#pragma once #pragma once
#include <utils/optional.h>
#include "clangtoolsdiagnostic.h" #include "clangtoolsdiagnostic.h"
#include <optional>
namespace Utils { class FilePath; } namespace Utils { class FilePath; }
namespace ClangTools { namespace ClangTools {
@@ -27,7 +28,7 @@ struct LineColumnInfo {
int column = 1; // 1-based int column = 1; // 1-based
int lineStartOffset = 0; // for optimiation/caching purposes int lineStartOffset = 0; // for optimiation/caching purposes
}; };
using OptionalLineColumnInfo = Utils::optional<LineColumnInfo>; using OptionalLineColumnInfo = std::optional<LineColumnInfo>;
OptionalLineColumnInfo byteOffsetInUtf8TextToLineColumn(const char *text, OptionalLineColumnInfo byteOffsetInUtf8TextToLineColumn(const char *text,
int offset, int offset,
int startLine = 1); int startLine = 1);

View File

@@ -54,7 +54,7 @@ static QString fixitStatus(FixitStatus status)
QString createDiagnosticToolTipString( QString createDiagnosticToolTipString(
const Diagnostic &diagnostic, const Diagnostic &diagnostic,
Utils::optional<FixitStatus> status, std::optional<FixitStatus> status,
bool showSteps) bool showSteps)
{ {
using StringPair = QPair<QString, QString>; using StringPair = QPair<QString, QString>;

View File

@@ -6,10 +6,11 @@
#include <cppeditor/clangdiagnosticconfig.h> #include <cppeditor/clangdiagnosticconfig.h>
#include <utils/id.h> #include <utils/id.h>
#include <utils/optional.h>
#include <QtGlobal> #include <QtGlobal>
#include <optional>
namespace CppEditor { class ClangDiagnosticConfigsModel; } namespace CppEditor { class ClangDiagnosticConfigsModel; }
namespace Debugger { class DiagnosticLocation; } namespace Debugger { class DiagnosticLocation; }
namespace Utils { class FilePath; } namespace Utils { class FilePath; }
@@ -31,9 +32,8 @@ enum class FixitStatus {
Invalidated, Invalidated,
}; };
QString createDiagnosticToolTipString( QString createDiagnosticToolTipString(const Diagnostic &diagnostic,
const Diagnostic &diagnostic, std::optional<FixitStatus> status = std::nullopt,
Utils::optional<FixitStatus> status = Utils::nullopt,
bool showSteps = true); bool showSteps = true);
CppEditor::ClangDiagnosticConfig builtinConfig(); CppEditor::ClangDiagnosticConfig builtinConfig();

View File

@@ -30,7 +30,7 @@ DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic)
setPriority(TextEditor::TextMark::HighPriority); setPriority(TextEditor::TextMark::HighPriority);
QIcon markIcon = diagnostic.icon(); QIcon markIcon = diagnostic.icon();
setIcon(markIcon.isNull() ? Utils::Icons::CODEMODEL_WARNING.icon() : markIcon); setIcon(markIcon.isNull() ? Utils::Icons::CODEMODEL_WARNING.icon() : markIcon);
setToolTip(createDiagnosticToolTipString(diagnostic, Utils::nullopt, true)); setToolTip(createDiagnosticToolTipString(diagnostic, std::nullopt, true));
setLineAnnotation(diagnostic.description); setLineAnnotation(diagnostic.description);
setActionsProvider([diagnostic] { setActionsProvider([diagnostic] {
// Copy to clipboard action // Copy to clipboard action

View File

@@ -13,7 +13,7 @@
#include <debugger/analyzer/analyzericons.h> #include <debugger/analyzer/analyzericons.h>
#include <utils/optional.h> #include <optional>
using namespace Utils; using namespace Utils;

View File

@@ -1188,7 +1188,7 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Id id)
const auto buildDirAspect = aspect<BuildDirectoryAspect>(); const auto buildDirAspect = aspect<BuildDirectoryAspect>();
buildDirAspect->setValueAcceptor( buildDirAspect->setValueAcceptor(
[](const QString &oldDir, const QString &newDir) -> Utils::optional<QString> { [](const QString &oldDir, const QString &newDir) -> std::optional<QString> {
if (oldDir.isEmpty()) if (oldDir.isEmpty())
return newDir; return newDir;
@@ -1204,7 +1204,7 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Id id)
== QMessageBox::Ok) { == QMessageBox::Ok) {
return newDir; return newDir;
} }
return Utils::nullopt; return std::nullopt;
} }
return newDir; return newDir;
}); });

View File

@@ -166,7 +166,7 @@ QString CMakeConfigItem::typeToTypeString(const CMakeConfigItem::Type t)
return {}; return {};
} }
Utils::optional<bool> CMakeConfigItem::toBool(const QString &value) std::optional<bool> CMakeConfigItem::toBool(const QString &value)
{ {
// Taken from CMakes if(<constant>) documentation: // Taken from CMakes if(<constant>) documentation:
// "Named boolean constants are case-insensitive." // "Named boolean constants are case-insensitive."

View File

@@ -5,11 +5,12 @@
#include "cmake_global.h" #include "cmake_global.h"
#include <utils/optional.h>
#include <QByteArray> #include <QByteArray>
#include <QStringList> #include <QStringList>
#include <optional>
namespace Utils { namespace Utils {
class FilePath; class FilePath;
class MacroExpander; class MacroExpander;
@@ -33,7 +34,7 @@ public:
static QStringList cmakeSplitValue(const QString &in, bool keepEmpty = false); static QStringList cmakeSplitValue(const QString &in, bool keepEmpty = false);
static Type typeStringToType(const QByteArray &typeString); static Type typeStringToType(const QByteArray &typeString);
static QString typeToTypeString(const Type t); static QString typeToTypeString(const Type t);
static Utils::optional<bool> toBool(const QString &value); static std::optional<bool> toBool(const QString &value);
bool isNull() const { return key.isEmpty(); } bool isNull() const { return key.isEmpty(); }
QString expandedValue(const ProjectExplorer::Kit *k) const; QString expandedValue(const ProjectExplorer::Kit *k) const;

Some files were not shown because too many files have changed in this diff Show More