Clang: Take over jobs if document gets new project part

We could loose jobs if e.g. the user switched to another parse context
or shuffled project files between targets/products/project-parts while
there were still jobs in the queue.

Previously, changing the project part id of a document was a two step
process:
  1) Unregister document with old project part id
  2) Register document with new project part id
On 1), we have thrown the document processors (and thus the job queue)
away. On 2), we have created a new document. Due to this separation the
backend could not take over jobs to the new document (processor) - it
could not know that these commands belong together.

Now, we avoid the explicit unregister command. On a register command the
backend has enough context to find out what to do, it can take over
relevant jobs.

Task-number: QTCREATORBUG-18856
Change-Id: Ib68a8e62140fcfdb2de58dcd2ae955b4c2e15166
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Nikolai Kosjar
2018-01-10 14:54:45 +01:00
parent 045cb7a509
commit 30c95c937b
5 changed files with 122 additions and 22 deletions

View File

@@ -42,6 +42,12 @@
namespace ClangBackEnd {
struct DocumentResetInfo {
Document documentToRemove;
FileContainer fileContainer;
};
using DocumentResetInfos = QVector<DocumentResetInfo>;
class ClangCodeModelServer : public ClangCodeModelServerInterface,
public IpcClientProvider<ClangCodeModelClientInterface>
{
@@ -79,6 +85,11 @@ private:
void processTimerForVisibleButNotCurrentDocuments();
void processSuspendResumeJobs(const std::vector<Document> &documents);
void categorizeFileContainers(const QVector<FileContainer> &fileContainers,
QVector<FileContainer> &toCreate,
DocumentResetInfos &toReset) const;
std::vector<Document> resetDocuments(const DocumentResetInfos &infos);
void addAndRunUpdateJobs(std::vector<Document> documents);
private: