forked from qt-creator/qt-creator
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:
@@ -23,20 +23,26 @@ static constexpr char16_t arcanaKey[] = u"arcana";
|
||||
|
||||
QString ClangdAstNode::role() const { return typedValue<QString>(roleKey); }
|
||||
QString ClangdAstNode::kind() const { return typedValue<QString>(kindKey); }
|
||||
optional<QString> ClangdAstNode::detail() const { return optionalValue<QString>(detailKey); }
|
||||
optional<QString> ClangdAstNode::arcana() const { return optionalValue<QString>(arcanaKey); }
|
||||
std::optional<QString> ClangdAstNode::detail() const
|
||||
{
|
||||
return optionalValue<QString>(detailKey);
|
||||
}
|
||||
std::optional<QString> ClangdAstNode::arcana() const
|
||||
{
|
||||
return optionalValue<QString>(arcanaKey);
|
||||
}
|
||||
Range ClangdAstNode::range() const { return typedValue<Range>(rangeKey); }
|
||||
bool ClangdAstNode::hasRange() const { return contains(rangeKey); }
|
||||
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);
|
||||
}
|
||||
|
||||
bool ClangdAstNode::arcanaContains(const QString &s) const
|
||||
{
|
||||
const optional<QString> arcanaString = arcana();
|
||||
const std::optional<QString> arcanaString = arcana();
|
||||
return arcanaString && arcanaString->contains(s);
|
||||
}
|
||||
|
||||
@@ -88,7 +94,7 @@ bool ClangdAstNode::isTemplateParameterDeclaration() const
|
||||
|
||||
QString ClangCodeModel::Internal::ClangdAstNode::type() const
|
||||
{
|
||||
const optional<QString> arcanaString = arcana();
|
||||
const std::optional<QString> arcanaString = arcana();
|
||||
if (!arcanaString)
|
||||
return {};
|
||||
return typeFromPos(*arcanaString, 0);
|
||||
@@ -156,7 +162,7 @@ bool ClangdAstNode::hasConstType() 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);
|
||||
}
|
||||
|
||||
@@ -171,7 +177,7 @@ QString ClangdAstNode::operatorString() const
|
||||
if (kind() == "BinaryOperator")
|
||||
return detail().value_or(QString());
|
||||
QTC_ASSERT(kind() == "CXXOperatorCall", return {});
|
||||
const optional<QString> arcanaString = arcana();
|
||||
const std::optional<QString> arcanaString = arcana();
|
||||
if (!arcanaString)
|
||||
return {};
|
||||
const int closingQuoteOffset = arcanaString->lastIndexOf('\'');
|
||||
@@ -186,7 +192,7 @@ QString ClangdAstNode::operatorString() const
|
||||
|
||||
ClangdAstNode::FileStatus ClangdAstNode::fileStatus(const FilePath &thisFile) const
|
||||
{
|
||||
const optional<QString> arcanaString = arcana();
|
||||
const std::optional<QString> arcanaString = arcana();
|
||||
if (!arcanaString)
|
||||
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
|
||||
// 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); }
|
||||
|
||||
bool isValid() const override { return contains(textDocumentKey); }
|
||||
|
||||
@@ -40,11 +40,11 @@ public:
|
||||
QString kind() const;
|
||||
|
||||
// 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.
|
||||
// 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
|
||||
// by macro expansion, etc.
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
|
||||
// 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.
|
||||
Utils::optional<QList<ClangdAstNode>> children() const;
|
||||
std::optional<QList<ClangdAstNode>> children() const;
|
||||
|
||||
bool hasRange() const;
|
||||
bool arcanaContains(const QString &s) const;
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
QString usr() const { return typedValue<QString>(usrKey); }
|
||||
|
||||
// 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
|
||||
{
|
||||
@@ -206,7 +206,7 @@ public:
|
||||
m_data.emplace(std::make_pair(doc, VersionedDocData(doc, data)));
|
||||
}
|
||||
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);
|
||||
if (it == m_data.end())
|
||||
@@ -215,7 +215,7 @@ public:
|
||||
m_data.erase(it);
|
||||
return data;
|
||||
}
|
||||
Utils::optional<DataType> get(const DocType &doc)
|
||||
std::optional<DataType> get(const DocType &doc)
|
||||
{
|
||||
const auto it = m_data.find(doc);
|
||||
if (it == m_data.end())
|
||||
@@ -251,7 +251,7 @@ public:
|
||||
: q(q), settings(CppEditor::ClangdProjectSettings(project).settings()) {}
|
||||
|
||||
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);
|
||||
|
||||
void handleDeclDefSwitchReplies();
|
||||
@@ -275,7 +275,7 @@ public:
|
||||
ClangdFollowSymbol *followSymbol = nullptr;
|
||||
ClangdSwitchDeclDef *switchDeclDef = nullptr;
|
||||
ClangdFindLocalReferences *findLocalRefs = nullptr;
|
||||
Utils::optional<QVersionNumber> versionNumber;
|
||||
std::optional<QVersionNumber> versionNumber;
|
||||
|
||||
QHash<TextDocument *, HighlightingData> highlightingData;
|
||||
QHash<Utils::FilePath, CppEditor::BaseEditorDocumentParser::Configuration> parserConfigs;
|
||||
@@ -354,7 +354,7 @@ ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir)
|
||||
for (const Client *client : clients)
|
||||
qCWarning(clangdLog) << client->name() << client->stateString();
|
||||
ClientCapabilities caps = Client::defaultClientCapabilities();
|
||||
Utils::optional<TextDocumentClientCapabilities> textCaps = caps.textDocument();
|
||||
std::optional<TextDocumentClientCapabilities> textCaps = caps.textDocument();
|
||||
if (textCaps) {
|
||||
ClangdTextDocumentClientCapabilities clangdTextCaps(*textCaps);
|
||||
clangdTextCaps.clearDocumentHighlight();
|
||||
@@ -362,7 +362,7 @@ ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir)
|
||||
diagnostics.enableCategorySupport();
|
||||
diagnostics.enableCodeActionsInline();
|
||||
clangdTextCaps.setPublishDiagnostics(diagnostics);
|
||||
Utils::optional<TextDocumentClientCapabilities::CompletionCapabilities> completionCaps
|
||||
std::optional<TextDocumentClientCapabilities::CompletionCapabilities> completionCaps
|
||||
= textCaps->completion();
|
||||
if (completionCaps)
|
||||
clangdTextCaps.setCompletion(ClangdCompletionCapabilities(*completionCaps));
|
||||
@@ -441,7 +441,7 @@ void ClangdClient::closeExtraFile(const Utils::FilePath &filePath)
|
||||
}
|
||||
|
||||
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?
|
||||
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,
|
||||
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,
|
||||
categorize);
|
||||
@@ -753,7 +753,7 @@ void ClangdClient::clearTasks(const Utils::FilePath &filePath)
|
||||
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 auto highlightingData = d->highlightingData.constFind(doc);
|
||||
@@ -860,7 +860,7 @@ void ClangdClient::switchHeaderSource(const Utils::FilePath &filePath, bool inNe
|
||||
};
|
||||
SwitchSourceHeaderRequest req(filePath);
|
||||
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 Utils::FilePath filePath = uri.toFilePath();
|
||||
if (!filePath.isEmpty())
|
||||
@@ -900,7 +900,7 @@ void ClangdClient::findLocalUsages(TextDocument *document, const QTextCursor &cu
|
||||
void ClangdClient::gatherHelpItemForTooltip(const HoverRequest::Response &hoverResponse,
|
||||
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))) {
|
||||
const HoverContent content = hover->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 MessageId id = hoverResponse.id();
|
||||
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)))
|
||||
range = hover->range().value_or(Range());
|
||||
}
|
||||
@@ -953,12 +953,12 @@ void ClangdClient::gatherHelpItemForTooltip(const HoverRequest::Response &hoverR
|
||||
}
|
||||
ClangdAstNode node = path.last();
|
||||
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())
|
||||
node = children->first();
|
||||
}
|
||||
while (node.kind() == "Qualified") {
|
||||
const Utils::optional<QList<ClangdAstNode>> children = node.children();
|
||||
const std::optional<QList<ClangdAstNode>> children = node.children();
|
||||
if (children && !children->isEmpty())
|
||||
node = children->first();
|
||||
}
|
||||
@@ -1120,7 +1120,7 @@ QTextCursor ClangdClient::Private::adjustedCursor(const QTextCursor &cursor,
|
||||
case T_DOT:
|
||||
break;
|
||||
case T_ARROW: {
|
||||
const Utils::optional<ClangdAstNode> clangdAst = astCache.get(doc);
|
||||
const std::optional<ClangdAstNode> clangdAst = astCache.get(doc);
|
||||
if (!clangdAst)
|
||||
return cursor;
|
||||
const ClangdAstPath clangdAstPath = getAstPath(*clangdAst, Range(cursor));
|
||||
@@ -1289,7 +1289,7 @@ void ClangdClient::Private::handleSemanticTokens(TextDocument *doc,
|
||||
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");
|
||||
if (!actions)
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
#include <cppeditor/cursorineditor.h>
|
||||
#include <languageclient/client.h>
|
||||
#include <utils/link.h>
|
||||
#include <utils/optional.h>
|
||||
|
||||
#include <QVersionNumber>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace CppEditor { class CppEditorWidget; }
|
||||
namespace LanguageServerProtocol { class Range; }
|
||||
namespace ProjectExplorer {
|
||||
@@ -48,7 +49,7 @@ public:
|
||||
void closeExtraFile(const Utils::FilePath &filePath);
|
||||
|
||||
void findUsages(TextEditor::TextDocument *document, const QTextCursor &cursor,
|
||||
const Utils::optional<QString> &replacement);
|
||||
const std::optional<QString> &replacement);
|
||||
void followSymbol(TextEditor::TextDocument *document,
|
||||
const QTextCursor &cursor,
|
||||
CppEditor::CppEditorWidget *editorWidget,
|
||||
@@ -85,7 +86,7 @@ public:
|
||||
void switchIssuePaneEntries(const Utils::FilePath &filePath);
|
||||
void addTask(const ProjectExplorer::Task &task);
|
||||
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);
|
||||
|
||||
using TextDocOrFile = std::variant<const TextEditor::TextDocument *, Utils::FilePath>;
|
||||
@@ -136,7 +137,7 @@ class ClangdDiagnostic : public LanguageServerProtocol::Diagnostic
|
||||
{
|
||||
public:
|
||||
using Diagnostic::Diagnostic;
|
||||
Utils::optional<QList<LanguageServerProtocol::CodeAction>> codeActions() const;
|
||||
std::optional<QList<LanguageServerProtocol::CodeAction>> codeActions() const;
|
||||
QString category() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -336,7 +336,7 @@ void ClangdCompletionItem::apply(TextDocumentManipulatorInterface &manipulator,
|
||||
|
||||
ClangdCompletionItem::SpecialQtType ClangdCompletionItem::getQtType(const CompletionItem &item)
|
||||
{
|
||||
const Utils::optional<MarkupOrString> doc = item.documentation();
|
||||
const std::optional<MarkupOrString> doc = item.documentation();
|
||||
if (!doc)
|
||||
return SpecialQtType::None;
|
||||
QString docText;
|
||||
@@ -612,7 +612,7 @@ ClangdCompletionCapabilities::ClangdCompletionCapabilities(const JsonObject &obj
|
||||
: TextDocumentClientCapabilities::CompletionCapabilities(object)
|
||||
{
|
||||
insert(u"editsNearCursor", true); // For dot-to-arrow correction.
|
||||
if (Utils::optional<CompletionItemCapbilities> completionItemCaps = completionItem()) {
|
||||
if (std::optional<CompletionItemCapbilities> completionItemCaps = completionItem()) {
|
||||
completionItemCaps->setSnippetSupport(false);
|
||||
setCompletionItem(*completionItemCaps);
|
||||
}
|
||||
|
||||
@@ -65,21 +65,21 @@ public:
|
||||
void finishSearch();
|
||||
void reportAllSearchResultsAndFinish();
|
||||
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);
|
||||
|
||||
ClangdFindReferences * const q;
|
||||
QMap<DocumentUri, ReferencesFileData> fileData;
|
||||
QList<MessageId> pendingAstRequests;
|
||||
QPointer<SearchResult> search;
|
||||
Utils::optional<ReplacementData> replacementData;
|
||||
std::optional<ReplacementData> replacementData;
|
||||
bool canceled = false;
|
||||
bool categorize = false;
|
||||
};
|
||||
|
||||
ClangdFindReferences::ClangdFindReferences(ClangdClient *client, TextDocument *document,
|
||||
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))
|
||||
{
|
||||
d->categorize = categorize;
|
||||
@@ -121,7 +121,7 @@ ClangdFindReferences::ClangdFindReferences(ClangdClient *client, TextDocument *d
|
||||
});
|
||||
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) {
|
||||
if (self)
|
||||
self->d->handleFindUsagesResult(locations);
|
||||
@@ -324,7 +324,7 @@ void ClangdFindReferences::Private::addSearchResultsForFile(const FilePath &file
|
||||
search->addResults(items, SearchResult::AddOrdered);
|
||||
}
|
||||
|
||||
Utils::optional<QString> ClangdFindReferences::Private::getContainingFunctionName(
|
||||
std::optional<QString> ClangdFindReferences::Private::getContainingFunctionName(
|
||||
const ClangdAstPath &astPath, const Range& range)
|
||||
{
|
||||
const ClangdAstNode* containingFuncNode{nullptr};
|
||||
@@ -344,7 +344,7 @@ Utils::optional<QString> ClangdFindReferences::Private::getContainingFunctionNam
|
||||
}
|
||||
|
||||
if (!containingFuncNode || !containingFuncNode->isValid())
|
||||
return Utils::nullopt;
|
||||
return std::nullopt;
|
||||
|
||||
return containingFuncNode->detail();
|
||||
}
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
|
||||
#include <coreplugin/find/searchresultitem.h>
|
||||
#include <cppeditor/cursorineditor.h>
|
||||
#include <utils/optional.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <optional>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTextCursor;
|
||||
QT_END_NAMESPACE
|
||||
@@ -24,7 +25,7 @@ class ClangdFindReferences : public QObject
|
||||
public:
|
||||
explicit ClangdFindReferences(ClangdClient *client, TextEditor::TextDocument *document,
|
||||
const QTextCursor &cursor, const QString &searchTerm,
|
||||
const Utils::optional<QString> &replacement, bool categorize);
|
||||
const std::optional<QString> &replacement, bool categorize);
|
||||
~ClangdFindReferences();
|
||||
|
||||
signals:
|
||||
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
Link defLink;
|
||||
Links allLinks;
|
||||
QHash<Link, Link> declDefMap;
|
||||
optional<ClangdAstNode> cursorNode;
|
||||
std::optional<ClangdAstNode> cursorNode;
|
||||
ClangdAstNode defLinkNode;
|
||||
SymbolDataList symbolsToDisplay;
|
||||
std::set<FilePath> openedFiles;
|
||||
@@ -375,7 +375,7 @@ void ClangdFollowSymbol::Private::handleGotoDefinitionResult()
|
||||
void ClangdFollowSymbol::Private::handleGotoImplementationResult(
|
||||
const GotoImplementationRequest::Response &response)
|
||||
{
|
||||
if (const optional<GotoResult> &result = response.result()) {
|
||||
if (const std::optional<GotoResult> &result = response.result()) {
|
||||
QList<Link> newLinks;
|
||||
if (const auto ploc = std::get_if<Location>(&*result))
|
||||
newLinks = {ploc->toLink()};
|
||||
@@ -451,7 +451,7 @@ void ClangdFollowSymbol::Private::handleGotoImplementationResult(
|
||||
if (!sentinel)
|
||||
return;
|
||||
Link newLink;
|
||||
if (optional<GotoResult> _result = response.result()) {
|
||||
if (std::optional<GotoResult> _result = response.result()) {
|
||||
const GotoResult result = _result.value();
|
||||
if (const auto ploc = std::get_if<Location>(&result)) {
|
||||
newLink = ploc->toLink();
|
||||
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
const QPointer<ClangdClient> client;
|
||||
MemoryTreeModel model;
|
||||
TreeView view;
|
||||
Utils::optional<MessageId> currentRequest;
|
||||
std::optional<MessageId> currentRequest;
|
||||
};
|
||||
|
||||
ClangdMemoryUsageWidget::ClangdMemoryUsageWidget(ClangdClient *client)
|
||||
|
||||
@@ -65,7 +65,7 @@ private:
|
||||
auto toOperation =
|
||||
[=](const std::variant<Command, CodeAction> &item) -> QuickFixOperation * {
|
||||
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())
|
||||
return new CodeActionQuickFixOperation(*action, client());
|
||||
}
|
||||
|
||||
@@ -10,12 +10,13 @@
|
||||
#include <languageclient/documentsymbolcache.h>
|
||||
#include <languageserverprotocol/lsptypes.h>
|
||||
#include <texteditor/textdocument.h>
|
||||
#include <utils/optional.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QTextCursor>
|
||||
|
||||
#include <optional>
|
||||
|
||||
using namespace CppEditor;
|
||||
using namespace LanguageClient;
|
||||
using namespace LanguageServerProtocol;
|
||||
@@ -33,7 +34,7 @@ public:
|
||||
cursor(cursor), editorWidget(editorWidget), callback(callback)
|
||||
{}
|
||||
|
||||
optional<ClangdAstNode> getFunctionNode() const;
|
||||
std::optional<ClangdAstNode> getFunctionNode() const;
|
||||
QTextCursor cursorForFunctionName(const ClangdAstNode &functionNode) const;
|
||||
void handleDeclDefSwitchReplies();
|
||||
|
||||
@@ -44,8 +45,8 @@ public:
|
||||
const QTextCursor cursor;
|
||||
const QPointer<CppEditorWidget> editorWidget;
|
||||
const LinkHandler callback;
|
||||
optional<ClangdAstNode> ast;
|
||||
optional<DocumentSymbolsResult> docSymbols;
|
||||
std::optional<ClangdAstNode> ast;
|
||||
std::optional<DocumentSymbolsResult> docSymbols;
|
||||
bool done = false;
|
||||
};
|
||||
|
||||
@@ -110,7 +111,7 @@ void ClangdSwitchDeclDef::emitDone()
|
||||
emit done();
|
||||
}
|
||||
|
||||
optional<ClangdAstNode> ClangdSwitchDeclDef::Private::getFunctionNode() const
|
||||
std::optional<ClangdAstNode> ClangdSwitchDeclDef::Private::getFunctionNode() const
|
||||
{
|
||||
QTC_ASSERT(ast, return {});
|
||||
|
||||
@@ -157,7 +158,7 @@ void ClangdSwitchDeclDef::Private::handleDeclDefSwitchReplies()
|
||||
// on a function return type, or ...
|
||||
if (clangdLogAst().isDebugEnabled())
|
||||
ast->print(0);
|
||||
const Utils::optional<ClangdAstNode> functionNode = getFunctionNode();
|
||||
const std::optional<ClangdAstNode> functionNode = getFunctionNode();
|
||||
if (!functionNode) {
|
||||
q->emitDone();
|
||||
return;
|
||||
|
||||
@@ -215,10 +215,10 @@ ClangDiagnostic convertDiagnostic(const ClangdDiagnostic &src, const FilePath &f
|
||||
if (codeString && codeString->startsWith("-W"))
|
||||
target.enableOption = *codeString;
|
||||
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)
|
||||
continue;
|
||||
const Utils::optional<WorkspaceEdit::Changes> changes = edit->changes();
|
||||
const std::optional<WorkspaceEdit::Changes> changes = edit->changes();
|
||||
if (!changes)
|
||||
continue;
|
||||
ClangDiagnostic fixItDiag;
|
||||
|
||||
Reference in New Issue
Block a user