diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-01-10 14:54:45 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-01-22 14:00:03 +0000 |
commit | 30c95c937b8b25ee828eedf449327aab0f35bded (patch) | |
tree | 2147840f590bdc768e7d06fa75fb60518cfc9823 /tests | |
parent | 045cb7a5094de546bfbdd5533cefb8372998e58b (diff) |
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>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/unittest/clangcodemodelserver-test.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/unit/unittest/clangcodemodelserver-test.cpp b/tests/unit/unittest/clangcodemodelserver-test.cpp index edcbcff7ad..df4afa8004 100644 --- a/tests/unit/unittest/clangcodemodelserver-test.cpp +++ b/tests/unit/unittest/clangcodemodelserver-test.cpp @@ -102,6 +102,7 @@ protected: bool waitUntilAllJobsFinished(int timeOutInMs = 10000); void registerProjectPart(); + void registerProjectPart(const Utf8String &projectPartId); void changeProjectPartArguments(); void registerProjectAndFile(const Utf8String &filePath, @@ -111,6 +112,8 @@ protected: void registerProjectAndFilesAndWaitForFinished(int expectedDocumentAnnotationsChangedMessages = 2); void registerFile(const Utf8String &filePath, int expectedDocumentAnnotationsChangedMessages = 1); + void registerFile(const Utf8String &filePath, const Utf8String &projectPartId, + int expectedDocumentAnnotationsChangedMessages = 1); void registerFiles(int expectedDocumentAnnotationsChangedMessages); void registerFileWithUnsavedContent(const Utf8String &filePath, const Utf8String &content); @@ -155,6 +158,7 @@ protected: ClangBackEnd::ClangCodeModelServer clangServer; const ClangBackEnd::Documents &documents = clangServer.documentsForTestOnly(); const Utf8String projectPartId = Utf8StringLiteral("pathToProjectPart.pro"); + const Utf8String projectPartId2 = Utf8StringLiteral("otherPathToProjectPart.pro"); const Utf8String filePathA = Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_function.cpp"); const QString filePathAUnsavedVersion1 @@ -418,6 +422,18 @@ TEST_F(ClangCodeModelServerSlowTest, TakeOverJobsOnProjectPartChange) updateVisibilty(filePathC, filePathC); // Enable processing jobs } +TEST_F(ClangCodeModelServerSlowTest, TakeOverJobsOnProjectPartIdChange) +{ + registerProjectPart(projectPartId); + registerProjectPart(projectPartId2); + registerFile(filePathC, projectPartId, 0); + requestReferences(); + + expectReferences(); + + registerFile(filePathC, projectPartId2); // Here we do not want to loose the RequestReferences job +} + void ClangCodeModelServer::SetUp() { clangServer.setClient(&mockClangCodeModelClient); @@ -453,6 +469,13 @@ void ClangCodeModelServer::registerProjectAndFilesAndWaitForFinished( void ClangCodeModelServer::registerFile(const Utf8String &filePath, int expectedDocumentAnnotationsChangedMessages) { + registerFile(filePath, projectPartId, expectedDocumentAnnotationsChangedMessages); +} + +void ClangCodeModelServer::registerFile(const Utf8String &filePath, + const Utf8String &projectPartId, + int expectedDocumentAnnotationsChangedMessages) +{ const FileContainer fileContainer(filePath, projectPartId); const RegisterTranslationUnitForEditorMessage message({fileContainer}, filePath, {filePath}); @@ -684,6 +707,11 @@ void ClangCodeModelServer::unregisterFile(const Utf8String &filePath) void ClangCodeModelServer::registerProjectPart() { + registerProjectPart(projectPartId); +} + +void ClangCodeModelServer::registerProjectPart(const Utf8String &projectPartId) +{ RegisterProjectPartsForEditorMessage message({ProjectPartContainer(projectPartId)}); clangServer.registerProjectPartsForEditor(message); |