forked from qt-creator/qt-creator
ClangCodeModel: reuse Id for restarted clients
This is needed to keep annotations hidden after the restart of clangd if the user disabled them in the text mark tooltip. Change-Id: I69a668f2ba71f1dda83eca74a064af7ec1f92e77 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -355,8 +355,8 @@ static void addCompilationDb(QJsonObject &parentObject, const QJsonObject &cdb)
|
||||
parentObject.insert("compilationDatabaseChanges", cdb);
|
||||
}
|
||||
|
||||
ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir)
|
||||
: Client(clientInterface(project, jsonDbDir)), d(new Private(this, project))
|
||||
ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir, const Id &id)
|
||||
: Client(clientInterface(project, jsonDbDir), id), d(new Private(this, project))
|
||||
{
|
||||
setName(tr("clangd"));
|
||||
LanguageFilter langFilter;
|
||||
|
@@ -41,7 +41,9 @@ class ClangdClient : public LanguageClient::Client
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ClangdClient(ProjectExplorer::Project *project, const Utils::FilePath &jsonDbDir);
|
||||
ClangdClient(ProjectExplorer::Project *project,
|
||||
const Utils::FilePath &jsonDbDir,
|
||||
const Utils::Id &id = {});
|
||||
~ClangdClient() override;
|
||||
|
||||
bool isFullyIndexed() const;
|
||||
|
@@ -494,9 +494,12 @@ void ClangModelManagerSupport::updateLanguageClient(ProjectExplorer::Project *pr
|
||||
.arg(result.error));
|
||||
return;
|
||||
}
|
||||
if (Client * const oldClient = clientForProject(project))
|
||||
Utils::Id previousId;
|
||||
if (Client * const oldClient = clientForProject(project)) {
|
||||
previousId = oldClient->id();
|
||||
LanguageClientManager::shutdownClient(oldClient);
|
||||
ClangdClient * const client = new ClangdClient(project, jsonDbDir);
|
||||
}
|
||||
ClangdClient * const client = new ClangdClient(project, jsonDbDir, previousId);
|
||||
connect(client, &Client::shadowDocumentSwitched, this, [](const Utils::FilePath &fp) {
|
||||
ClangdClient::handleUiHeaderChange(fp.fileName());
|
||||
});
|
||||
|
@@ -130,9 +130,9 @@ class ClientPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ClientPrivate(Client *client, BaseClientInterface *clientInterface)
|
||||
ClientPrivate(Client *client, BaseClientInterface *clientInterface, const Utils::Id &id)
|
||||
: q(client)
|
||||
, m_id(Utils::Id::fromString(QUuid::createUuid().toString()))
|
||||
, m_id(id.isValid() ? id : Utils::Id::fromString(QUuid::createUuid().toString()))
|
||||
, m_clientCapabilities(q->defaultClientCapabilities())
|
||||
, m_clientInterface(new InterfaceController(clientInterface))
|
||||
, m_documentSymbolCache(q)
|
||||
@@ -333,8 +333,8 @@ public:
|
||||
const Utils::FilePath m_serverDeviceTemplate;
|
||||
};
|
||||
|
||||
Client::Client(BaseClientInterface *clientInterface)
|
||||
: d(new ClientPrivate(this, clientInterface))
|
||||
Client::Client(BaseClientInterface *clientInterface, const Utils::Id &id)
|
||||
: d(new ClientPrivate(this, clientInterface, id))
|
||||
{}
|
||||
|
||||
Id Client::id() const
|
||||
|
@@ -49,7 +49,7 @@ class LANGUAGECLIENT_EXPORT Client : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Client(BaseClientInterface *clientInterface); // takes ownership
|
||||
explicit Client(BaseClientInterface *clientInterface, const Utils::Id &id = {}); // takes ownership
|
||||
~Client() override;
|
||||
|
||||
Client(const Client &) = delete;
|
||||
|
Reference in New Issue
Block a user