forked from qt-creator/qt-creator
Clangd indexing: Hide cancel button, open settings on click
Since we cannot reasonably "cancel" indexing, hide the cancel button from the progress indicator. Open the Clangd settings page when clicking on the progress indicator instead. Fixes: QTCREATORBUG-27744 Change-Id: I625464e7f7456bcf7f01ce7e52f6bd6b53e3d8b2 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -18,18 +18,20 @@
|
|||||||
#include "tasktimers.h"
|
#include "tasktimers.h"
|
||||||
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
#include <cplusplus/AST.h>
|
#include <cplusplus/AST.h>
|
||||||
#include <cplusplus/ASTPath.h>
|
#include <cplusplus/ASTPath.h>
|
||||||
#include <cplusplus/Icons.h>
|
#include <cplusplus/Icons.h>
|
||||||
#include <cppeditor/cppcodemodelsettings.h>
|
#include <cppeditor/cppcodemodelsettings.h>
|
||||||
|
#include <cppeditor/cppeditorconstants.h>
|
||||||
#include <cppeditor/cppeditorwidget.h>
|
#include <cppeditor/cppeditorwidget.h>
|
||||||
#include <cppeditor/cppmodelmanager.h>
|
#include <cppeditor/cppmodelmanager.h>
|
||||||
#include <cppeditor/cpprefactoringchanges.h>
|
#include <cppeditor/cpprefactoringchanges.h>
|
||||||
|
#include <cppeditor/cppsemanticinfo.h>
|
||||||
#include <cppeditor/cpptoolsreuse.h>
|
#include <cppeditor/cpptoolsreuse.h>
|
||||||
#include <cppeditor/cppvirtualfunctionassistprovider.h>
|
#include <cppeditor/cppvirtualfunctionassistprovider.h>
|
||||||
#include <cppeditor/cppvirtualfunctionproposalitem.h>
|
#include <cppeditor/cppvirtualfunctionproposalitem.h>
|
||||||
#include <cppeditor/semantichighlighter.h>
|
#include <cppeditor/semantichighlighter.h>
|
||||||
#include <cppeditor/cppsemanticinfo.h>
|
|
||||||
#include <languageclient/diagnosticmanager.h>
|
#include <languageclient/diagnosticmanager.h>
|
||||||
#include <languageclient/languageclienthoverhandler.h>
|
#include <languageclient/languageclienthoverhandler.h>
|
||||||
#include <languageclient/languageclientinterface.h>
|
#include <languageclient/languageclientinterface.h>
|
||||||
@@ -389,6 +391,9 @@ ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir)
|
|||||||
setProgressTitleForToken(indexingToken(),
|
setProgressTitleForToken(indexingToken(),
|
||||||
project ? tr("Indexing %1 with clangd").arg(project->displayName())
|
project ? tr("Indexing %1 with clangd").arg(project->displayName())
|
||||||
: tr("Indexing session with clangd"));
|
: tr("Indexing session with clangd"));
|
||||||
|
setClickHandlerForToken(indexingToken(), [] {
|
||||||
|
ICore::showOptionsDialog(CppEditor::Constants::CPP_CLANGD_SETTINGS_ID);
|
||||||
|
});
|
||||||
setCurrentProject(project);
|
setCurrentProject(project);
|
||||||
setDocumentChangeUpdateThreshold(d->settings.documentUpdateThreshold);
|
setDocumentChangeUpdateThreshold(d->settings.documentUpdateThreshold);
|
||||||
setSymbolStringifier(displayNameFromDocumentSymbol);
|
setSymbolStringifier(displayNameFromDocumentSymbol);
|
||||||
@@ -430,7 +435,10 @@ ClangdClient::~ClangdClient()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClangdClient::isFullyIndexed() const { return d->isFullyIndexed; }
|
bool ClangdClient::isFullyIndexed() const
|
||||||
|
{
|
||||||
|
return d->isFullyIndexed;
|
||||||
|
}
|
||||||
|
|
||||||
void ClangdClient::openExtraFile(const Utils::FilePath &filePath, const QString &content)
|
void ClangdClient::openExtraFile(const Utils::FilePath &filePath, const QString &content)
|
||||||
{
|
{
|
||||||
|
@@ -121,7 +121,12 @@ FutureProgress::FutureProgress(QWidget *parent) :
|
|||||||
this, &FutureProgress::setProgressValue);
|
this, &FutureProgress::setProgressValue);
|
||||||
connect(&d->m_watcher, &QFutureWatcherBase::progressTextChanged,
|
connect(&d->m_watcher, &QFutureWatcherBase::progressTextChanged,
|
||||||
this, &FutureProgress::setProgressText);
|
this, &FutureProgress::setProgressText);
|
||||||
connect(d->m_progress, &Internal::ProgressBar::clicked, this, &FutureProgress::cancel);
|
connect(d->m_progress, &Internal::ProgressBar::clicked, this, [this] {
|
||||||
|
if (isCancelEnabled())
|
||||||
|
cancel();
|
||||||
|
else
|
||||||
|
emit clicked();
|
||||||
|
});
|
||||||
setMinimumWidth(100);
|
setMinimumWidth(100);
|
||||||
setMaximumWidth(300);
|
setMaximumWidth(300);
|
||||||
}
|
}
|
||||||
@@ -373,6 +378,16 @@ QSize FutureProgress::sizeHint() const
|
|||||||
return QSize(QWidget::sizeHint().width(), minimumHeight());
|
return QSize(QWidget::sizeHint().width(), minimumHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FutureProgress::isCancelEnabled() const
|
||||||
|
{
|
||||||
|
return d->m_progress->isCancelEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FutureProgress::setCancelEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
d->m_progress->setCancelEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
void FutureProgressPrivate::fadeAway()
|
void FutureProgressPrivate::fadeAway()
|
||||||
{
|
{
|
||||||
m_isFading = true;
|
m_isFading = true;
|
||||||
|
@@ -59,6 +59,9 @@ public:
|
|||||||
|
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
|
bool isCancelEnabled() const;
|
||||||
|
void setCancelEnabled(bool enabled);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void clicked();
|
void clicked();
|
||||||
void finished();
|
void finished();
|
||||||
|
@@ -1573,6 +1573,12 @@ void Client::setProgressTitleForToken(const LanguageServerProtocol::ProgressToke
|
|||||||
d->m_progressManager.setTitleForToken(token, message);
|
d->m_progressManager.setTitleForToken(token, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::setClickHandlerForToken(const LanguageServerProtocol::ProgressToken &token,
|
||||||
|
const std::function<void()> &handler)
|
||||||
|
{
|
||||||
|
d->m_progressManager.setClickHandlerForToken(token, handler);
|
||||||
|
}
|
||||||
|
|
||||||
void Client::handleMessage(const LanguageServerProtocol::JsonRpcMessage &message)
|
void Client::handleMessage(const LanguageServerProtocol::JsonRpcMessage &message)
|
||||||
{
|
{
|
||||||
LanguageClientManager::logJsonRpcMessage(LspLogMessage::ServerMessage, name(), message);
|
LanguageClientManager::logJsonRpcMessage(LspLogMessage::ServerMessage, name(), message);
|
||||||
|
@@ -197,6 +197,8 @@ protected:
|
|||||||
void setError(const QString &message);
|
void setError(const QString &message);
|
||||||
void setProgressTitleForToken(const LanguageServerProtocol::ProgressToken &token,
|
void setProgressTitleForToken(const LanguageServerProtocol::ProgressToken &token,
|
||||||
const QString &message);
|
const QString &message);
|
||||||
|
void setClickHandlerForToken(const LanguageServerProtocol::ProgressToken &token,
|
||||||
|
const std::function<void()> &handler);
|
||||||
void handleMessage(const LanguageServerProtocol::JsonRpcMessage &message);
|
void handleMessage(const LanguageServerProtocol::JsonRpcMessage &message);
|
||||||
virtual void handleDiagnostics(const LanguageServerProtocol::PublishDiagnosticsParams ¶ms);
|
virtual void handleDiagnostics(const LanguageServerProtocol::PublishDiagnosticsParams ¶ms);
|
||||||
virtual DiagnosticManager *createDiagnosticManager();
|
virtual DiagnosticManager *createDiagnosticManager();
|
||||||
|
@@ -41,6 +41,12 @@ void ProgressManager::setTitleForToken(const LanguageServerProtocol::ProgressTok
|
|||||||
m_titles.insert(token, message);
|
m_titles.insert(token, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProgressManager::setClickHandlerForToken(const LanguageServerProtocol::ProgressToken &token,
|
||||||
|
const std::function<void()> &handler)
|
||||||
|
{
|
||||||
|
m_clickHandlers.insert(token, handler);
|
||||||
|
}
|
||||||
|
|
||||||
void ProgressManager::reset()
|
void ProgressManager::reset()
|
||||||
{
|
{
|
||||||
const QList<ProgressToken> &tokens = m_progress.keys();
|
const QList<ProgressToken> &tokens = m_progress.keys();
|
||||||
@@ -72,6 +78,10 @@ void ProgressManager::beginProgress(const ProgressToken &token, const WorkDonePr
|
|||||||
const QString title = m_titles.value(token, begin.title());
|
const QString title = m_titles.value(token, begin.title());
|
||||||
Core::FutureProgress *progress = Core::ProgressManager::addTask(
|
Core::FutureProgress *progress = Core::ProgressManager::addTask(
|
||||||
interface->future(), title, languageClientProgressId(token));
|
interface->future(), title, languageClientProgressId(token));
|
||||||
|
progress->setCancelEnabled(false);
|
||||||
|
const std::function<void()> clickHandler = m_clickHandlers.value(token);
|
||||||
|
if (clickHandler)
|
||||||
|
QObject::connect(progress, &Core::FutureProgress::clicked, clickHandler);
|
||||||
m_progress[token] = {progress, interface};
|
m_progress[token] = {progress, interface};
|
||||||
if (LOGPROGRESS().isDebugEnabled())
|
if (LOGPROGRESS().isDebugEnabled())
|
||||||
m_timer[token].start();
|
m_timer[token].start();
|
||||||
|
@@ -27,6 +27,8 @@ public:
|
|||||||
void handleProgress(const LanguageServerProtocol::ProgressParams ¶ms);
|
void handleProgress(const LanguageServerProtocol::ProgressParams ¶ms);
|
||||||
void setTitleForToken(const LanguageServerProtocol::ProgressToken &token,
|
void setTitleForToken(const LanguageServerProtocol::ProgressToken &token,
|
||||||
const QString &message);
|
const QString &message);
|
||||||
|
void setClickHandlerForToken(const LanguageServerProtocol::ProgressToken &token,
|
||||||
|
const std::function<void()> &handler);
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
static bool isProgressEndMessage(const LanguageServerProtocol::ProgressParams ¶ms);
|
static bool isProgressEndMessage(const LanguageServerProtocol::ProgressParams ¶ms);
|
||||||
@@ -48,6 +50,7 @@ private:
|
|||||||
QMap<LanguageServerProtocol::ProgressToken, LanguageClientProgress> m_progress;
|
QMap<LanguageServerProtocol::ProgressToken, LanguageClientProgress> m_progress;
|
||||||
QMap<LanguageServerProtocol::ProgressToken, QString> m_titles;
|
QMap<LanguageServerProtocol::ProgressToken, QString> m_titles;
|
||||||
QMap<LanguageServerProtocol::ProgressToken, QElapsedTimer> m_timer;
|
QMap<LanguageServerProtocol::ProgressToken, QElapsedTimer> m_timer;
|
||||||
|
QMap<LanguageServerProtocol::ProgressToken, std::function<void()>> m_clickHandlers;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace LanguageClient
|
} // namespace LanguageClient
|
||||||
|
Reference in New Issue
Block a user