forked from qt-creator/qt-creator
Clang: Remove project tracking on clangbackend side
...as it is not needed. Just provide the compilation arguments as part of the Document. As a side effect, re-initializing the backend after a crash is cheaper and will not freeze the UI anymore (referenced bug). Task-number: QTCREATORBUG-21097 Change-Id: I866e25ef1fd5e4d318df16612a7564469e6baa11 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -53,15 +53,13 @@ namespace {
|
||||
|
||||
using namespace ClangBackEnd;
|
||||
|
||||
MATCHER_P5(HasDirtyDocument,
|
||||
MATCHER_P4(HasDirtyDocument,
|
||||
filePath,
|
||||
projectPartId,
|
||||
documentRevision,
|
||||
isDirty,
|
||||
hasNewDiagnostics,
|
||||
std::string(negation ? "isn't" : "is")
|
||||
+ " document with file path "+ PrintToString(filePath)
|
||||
+ " and project " + PrintToString(projectPartId)
|
||||
+ " and document revision " + PrintToString(documentRevision)
|
||||
+ " and isDirty = " + PrintToString(isDirty)
|
||||
+ " and hasNewDiagnostics = " + PrintToString(hasNewDiagnostics)
|
||||
@@ -69,7 +67,7 @@ MATCHER_P5(HasDirtyDocument,
|
||||
{
|
||||
auto &&documents = arg.documentsForTestOnly();
|
||||
try {
|
||||
auto document = documents.document(filePath, projectPartId);
|
||||
auto document = documents.document(filePath);
|
||||
|
||||
if (document.documentRevision() == documentRevision) {
|
||||
if (document.isDirty() && !isDirty) {
|
||||
@@ -114,21 +112,13 @@ protected:
|
||||
protected:
|
||||
bool waitUntilAllJobsFinished(int timeOutInMs = 10000);
|
||||
|
||||
void updateProjectPart();
|
||||
void updateProjectPart(const Utf8String &projectPartId);
|
||||
void updateProjectPartWithArguments();
|
||||
|
||||
void updateProjectAndOpenDocument(const Utf8String &filePath,
|
||||
int expectedAnnotationsMessages = AnnotationJobsMultiplier);
|
||||
void updateProjectAndOpenDocumentAndWaitForFinished(
|
||||
void openDocumentAndWaitForFinished(
|
||||
const Utf8String &filePath, int expectedAnnotationsMessages = AnnotationJobsMultiplier);
|
||||
void updateProjectAndOpenDocumentsAndWaitForFinished(
|
||||
int expectedAnnotationsdMessages = 2 * AnnotationJobsMultiplier);
|
||||
|
||||
void openDocument(const Utf8String &filePath,
|
||||
int expectedAnnotationsMessages = AnnotationJobsMultiplier);
|
||||
void openDocument(const Utf8String &filePath,
|
||||
const Utf8String &projectPartId,
|
||||
const Utf8StringVector &compilationArguments,
|
||||
int expectedAnnotationsMessages = AnnotationJobsMultiplier);
|
||||
void openDocuments(int expectedAnnotationsMessages);
|
||||
void openDocumentWithUnsavedContent(const Utf8String &filePath, const Utf8String &content);
|
||||
@@ -146,10 +136,8 @@ protected:
|
||||
void requestFollowSymbol(quint32 documentRevision = 0);
|
||||
void requestCompletions(const Utf8String &filePath,
|
||||
uint line = 1,
|
||||
uint column = 1,
|
||||
const Utf8String &projectPartId = Utf8String());
|
||||
uint column = 1);
|
||||
void requestCompletionsInFileA();
|
||||
void requestCompletionsInFileB();
|
||||
|
||||
bool isSupportiveTranslationUnitInitialized(const Utf8String &filePath);
|
||||
|
||||
@@ -158,7 +146,6 @@ protected:
|
||||
void expectAnnotations(int count);
|
||||
void expectCompletion(const CodeCompletion &completion);
|
||||
void expectCompletionFromFileA();
|
||||
void expectCompletionFromFileBEnabledByMacro();
|
||||
void expectCompletionFromFileAUnsavedMethodVersion1();
|
||||
void expectCompletionFromFileAUnsavedMethodVersion2();
|
||||
void expectNoCompletionWithUnsavedMethod();
|
||||
@@ -172,8 +159,6 @@ protected:
|
||||
MockClangCodeModelClient mockClangCodeModelClient;
|
||||
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
|
||||
@@ -187,14 +172,13 @@ protected:
|
||||
const Utf8String aFilePath = Utf8StringLiteral("afile.cpp");
|
||||
const Utf8String anExistingFilePath
|
||||
= Utf8StringLiteral(TESTDATA_DIR"/complete_translationunit_parse_error.cpp");
|
||||
const Utf8String aProjectPartId = Utf8StringLiteral("aproject.pro");
|
||||
};
|
||||
|
||||
using ClangCodeModelServerSlowTest = ClangCodeModelServer;
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, GetCodeCompletion)
|
||||
{
|
||||
updateProjectAndOpenDocument(filePathA);
|
||||
openDocument(filePathA);
|
||||
|
||||
expectCompletionFromFileA();
|
||||
requestCompletionsInFileA();
|
||||
@@ -202,7 +186,7 @@ TEST_F(ClangCodeModelServerSlowTest, GetCodeCompletion)
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, RequestAnnotations)
|
||||
{
|
||||
updateProjectAndOpenDocumentAndWaitForFinished(filePathB);
|
||||
openDocumentAndWaitForFinished(filePathB);
|
||||
|
||||
expectAnnotationsForFileBWithSpecificHighlightingMark();
|
||||
requestAnnotations(filePathB);
|
||||
@@ -210,7 +194,7 @@ TEST_F(ClangCodeModelServerSlowTest, RequestAnnotations)
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, RequestReferencesForCurrentDocumentRevision)
|
||||
{
|
||||
updateProjectAndOpenDocumentAndWaitForFinished(filePathC);
|
||||
openDocumentAndWaitForFinished(filePathC);
|
||||
|
||||
expectReferences();
|
||||
requestReferences();
|
||||
@@ -218,7 +202,7 @@ TEST_F(ClangCodeModelServerSlowTest, RequestReferencesForCurrentDocumentRevision
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, RequestReferencesTakesRevisionFromMessage)
|
||||
{
|
||||
updateProjectAndOpenDocumentAndWaitForFinished(filePathC);
|
||||
openDocumentAndWaitForFinished(filePathC);
|
||||
|
||||
requestReferences(/*documentRevision=*/ 99);
|
||||
|
||||
@@ -231,7 +215,7 @@ TEST_F(ClangCodeModelServerSlowTest, RequestReferencesTakesRevisionFromMessage)
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, RequestFollowSymbolForCurrentDocumentRevision)
|
||||
{
|
||||
updateProjectAndOpenDocumentAndWaitForFinished(filePathC);
|
||||
openDocumentAndWaitForFinished(filePathC);
|
||||
|
||||
expectFollowSymbol();
|
||||
requestFollowSymbol();
|
||||
@@ -239,7 +223,7 @@ TEST_F(ClangCodeModelServerSlowTest, RequestFollowSymbolForCurrentDocumentRevisi
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, RequestFollowSymbolTakesRevisionFromMessage)
|
||||
{
|
||||
updateProjectAndOpenDocumentAndWaitForFinished(filePathC);
|
||||
openDocumentAndWaitForFinished(filePathC);
|
||||
|
||||
requestFollowSymbol(/*documentRevision=*/ 99);
|
||||
|
||||
@@ -253,7 +237,7 @@ TEST_F(ClangCodeModelServerSlowTest, RequestFollowSymbolTakesRevisionFromMessage
|
||||
TEST_F(ClangCodeModelServerSlowTest, NoInitialAnnotationsForClosedDocument)
|
||||
{
|
||||
const int expectedAnnotationsCount = 0;
|
||||
updateProjectAndOpenDocument(filePathA, expectedAnnotationsCount);
|
||||
openDocument(filePathA, expectedAnnotationsCount);
|
||||
|
||||
closeDocument(filePathA);
|
||||
}
|
||||
@@ -261,11 +245,10 @@ TEST_F(ClangCodeModelServerSlowTest, NoInitialAnnotationsForClosedDocument)
|
||||
TEST_F(ClangCodeModelServerSlowTest, AnnotationsForInitiallyNotVisibleDocument)
|
||||
{
|
||||
const int expectedAnnotationsCount = 2;
|
||||
updateProjectPart();
|
||||
updateVisibilty(filePathA, filePathA);
|
||||
expectAnnotations(expectedAnnotationsCount);
|
||||
clangServer.documentsOpened( // Open document while another is still visible
|
||||
DocumentsOpenedMessage({FileContainer(filePathB, projectPartId, Utf8String(), false, 1)},
|
||||
DocumentsOpenedMessage({FileContainer(filePathB, Utf8String(), false, 1)},
|
||||
filePathA, {filePathA}));
|
||||
clangServer.unsavedFilesUpdated( // Invalidate added jobs
|
||||
UnsavedFilesUpdatedMessage({FileContainer(Utf8StringLiteral("aFile"), Utf8String())}));
|
||||
@@ -276,7 +259,7 @@ TEST_F(ClangCodeModelServerSlowTest, AnnotationsForInitiallyNotVisibleDocument)
|
||||
TEST_F(ClangCodeModelServerSlowTest, NoAnnotationsForClosedDocument)
|
||||
{
|
||||
const int expectedAnnotationsCount = AnnotationJobsMultiplier; // Only for registration.
|
||||
updateProjectAndOpenDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount);
|
||||
openDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount);
|
||||
updateUnsavedContent(filePathA, Utf8String(), 1);
|
||||
|
||||
closeDocument(filePathA);
|
||||
@@ -285,7 +268,7 @@ TEST_F(ClangCodeModelServerSlowTest, NoAnnotationsForClosedDocument)
|
||||
TEST_F(ClangCodeModelServerSlowTest, NoInitialAnnotationsForOutdatedDocumentRevision)
|
||||
{
|
||||
const int expectedAnnotationsCount = AnnotationJobsMultiplier; // Only for registration.
|
||||
updateProjectAndOpenDocument(filePathA, expectedAnnotationsCount);
|
||||
openDocument(filePathA, expectedAnnotationsCount);
|
||||
|
||||
updateUnsavedContent(filePathA, Utf8String(), 1);
|
||||
}
|
||||
@@ -293,25 +276,14 @@ TEST_F(ClangCodeModelServerSlowTest, NoInitialAnnotationsForOutdatedDocumentRevi
|
||||
TEST_F(ClangCodeModelServerSlowTest, NoCompletionsForClosedDocument)
|
||||
{
|
||||
const int expectedAnnotationsCount = AnnotationJobsMultiplier; // Only for registration.
|
||||
updateProjectAndOpenDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount);
|
||||
openDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount);
|
||||
requestCompletionsInFileA();
|
||||
|
||||
closeDocument(filePathA);
|
||||
}
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, CodeCompletionDependingOnProject)
|
||||
{
|
||||
const int expectedAnnotationsCount = 2 * AnnotationJobsMultiplier; // For registration and due to project change.
|
||||
updateProjectAndOpenDocumentAndWaitForFinished(filePathB, expectedAnnotationsCount);
|
||||
|
||||
expectCompletionFromFileBEnabledByMacro();
|
||||
updateProjectPartWithArguments();
|
||||
requestCompletionsInFileB();
|
||||
}
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, GetCodeCompletionForUnsavedFile)
|
||||
{
|
||||
updateProjectPart();
|
||||
expectAnnotations(AnnotationJobsMultiplier);
|
||||
openDocumentWithUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion1));
|
||||
expectCompletionFromFileAUnsavedMethodVersion1();
|
||||
@@ -322,7 +294,7 @@ TEST_F(ClangCodeModelServerSlowTest, GetCodeCompletionForUnsavedFile)
|
||||
TEST_F(ClangCodeModelServerSlowTest, GetNoCodeCompletionAfterRemovingUnsavedFile)
|
||||
{
|
||||
const int expectedAnnotationsCount = 2 * AnnotationJobsMultiplier; // For registration and update/removal.
|
||||
updateProjectAndOpenDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount);
|
||||
openDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount);
|
||||
removeUnsavedFile(filePathA);
|
||||
|
||||
expectNoCompletionWithUnsavedMethod();
|
||||
@@ -332,7 +304,7 @@ TEST_F(ClangCodeModelServerSlowTest, GetNoCodeCompletionAfterRemovingUnsavedFile
|
||||
TEST_F(ClangCodeModelServerSlowTest, GetNewCodeCompletionAfterUpdatingUnsavedFile)
|
||||
{
|
||||
const int expectedAnnotationsCount = 2 * AnnotationJobsMultiplier; // For registration and update/removal.
|
||||
updateProjectAndOpenDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount);
|
||||
openDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount);
|
||||
updateUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion2), 1);
|
||||
|
||||
expectCompletionFromFileAUnsavedMethodVersion2();
|
||||
@@ -341,16 +313,17 @@ TEST_F(ClangCodeModelServerSlowTest, GetNewCodeCompletionAfterUpdatingUnsavedFil
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, TranslationUnitAfterCreationIsNotDirty)
|
||||
{
|
||||
updateProjectAndOpenDocument(filePathA, AnnotationJobsMultiplier);
|
||||
openDocument(filePathA, AnnotationJobsMultiplier);
|
||||
|
||||
ASSERT_THAT(clangServer, HasDirtyDocument(filePathA, projectPartId, 0U, false, false));
|
||||
ASSERT_THAT(clangServer, HasDirtyDocument(filePathA, 0U, false, false));
|
||||
}
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, SetCurrentAndVisibleEditor)
|
||||
{
|
||||
updateProjectAndOpenDocumentsAndWaitForFinished();
|
||||
auto functionDocument = documents.document(filePathA, projectPartId);
|
||||
auto variableDocument = documents.document(filePathB, projectPartId);
|
||||
openDocuments(2 * AnnotationJobsMultiplier);
|
||||
ASSERT_TRUE(waitUntilAllJobsFinished());
|
||||
auto functionDocument = documents.document(filePathA);
|
||||
auto variableDocument = documents.document(filePathB);
|
||||
|
||||
updateVisibilty(filePathB, filePathA);
|
||||
|
||||
@@ -361,7 +334,7 @@ TEST_F(ClangCodeModelServerSlowTest, SetCurrentAndVisibleEditor)
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, StartCompletionJobFirstOnEditThatTriggersCompletion)
|
||||
{
|
||||
updateProjectAndOpenDocument(filePathA, 2 * AnnotationJobsMultiplier);
|
||||
openDocument(filePathA, 2 * AnnotationJobsMultiplier);
|
||||
ASSERT_TRUE(waitUntilAllJobsFinished());
|
||||
expectCompletionFromFileA();
|
||||
|
||||
@@ -375,7 +348,7 @@ TEST_F(ClangCodeModelServerSlowTest, StartCompletionJobFirstOnEditThatTriggersCo
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, SupportiveTranslationUnitNotInitializedAfterRegister)
|
||||
{
|
||||
updateProjectAndOpenDocument(filePathA, AnnotationJobsMultiplier);
|
||||
openDocument(filePathA, AnnotationJobsMultiplier);
|
||||
|
||||
ASSERT_TRUE(waitUntilAllJobsFinished());
|
||||
ASSERT_FALSE(isSupportiveTranslationUnitInitialized(filePathA));
|
||||
@@ -383,7 +356,7 @@ TEST_F(ClangCodeModelServerSlowTest, SupportiveTranslationUnitNotInitializedAfte
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, SupportiveTranslationUnitIsSetupAfterFirstEdit)
|
||||
{
|
||||
updateProjectAndOpenDocument(filePathA, 2 * AnnotationJobsMultiplier);
|
||||
openDocument(filePathA, 2 * AnnotationJobsMultiplier);
|
||||
ASSERT_TRUE(waitUntilAllJobsFinished());
|
||||
|
||||
updateUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion2), 1);
|
||||
@@ -394,7 +367,7 @@ TEST_F(ClangCodeModelServerSlowTest, SupportiveTranslationUnitIsSetupAfterFirstE
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, DoNotRunDuplicateJobs)
|
||||
{
|
||||
updateProjectAndOpenDocument(filePathA, 3 * AnnotationJobsMultiplier);
|
||||
openDocument(filePathA, 3 * AnnotationJobsMultiplier);
|
||||
ASSERT_TRUE(waitUntilAllJobsFinished());
|
||||
updateUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion2), 1);
|
||||
ASSERT_TRUE(waitUntilAllJobsFinished());
|
||||
@@ -408,7 +381,7 @@ TEST_F(ClangCodeModelServerSlowTest, DoNotRunDuplicateJobs)
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, OpenDocumentAndEdit)
|
||||
{
|
||||
updateProjectAndOpenDocument(filePathA, 4 * AnnotationJobsMultiplier);
|
||||
openDocument(filePathA, 4 * AnnotationJobsMultiplier);
|
||||
ASSERT_TRUE(waitUntilAllJobsFinished());
|
||||
|
||||
for (unsigned revision = 1; revision <= 3; ++revision) {
|
||||
@@ -419,9 +392,11 @@ TEST_F(ClangCodeModelServerSlowTest, OpenDocumentAndEdit)
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, IsNotCurrentCurrentAndVisibleEditorAnymore)
|
||||
{
|
||||
updateProjectAndOpenDocumentsAndWaitForFinished();
|
||||
auto functionDocument = documents.document(filePathA, projectPartId);
|
||||
auto variableDocument = documents.document(filePathB, projectPartId);
|
||||
const int expectedAnnotationsCount = 2 * AnnotationJobsMultiplier;
|
||||
openDocuments(expectedAnnotationsCount);
|
||||
ASSERT_TRUE(waitUntilAllJobsFinished());
|
||||
auto functionDocument = documents.document(filePathA);
|
||||
auto variableDocument = documents.document(filePathB);
|
||||
updateVisibilty(filePathB, filePathA);
|
||||
|
||||
updateVisibilty(filePathB, Utf8String());
|
||||
@@ -434,36 +409,25 @@ TEST_F(ClangCodeModelServerSlowTest, IsNotCurrentCurrentAndVisibleEditorAnymore)
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, TranslationUnitAfterUpdateNeedsReparse)
|
||||
{
|
||||
updateProjectAndOpenDocumentAndWaitForFinished(filePathA, 2 * AnnotationJobsMultiplier);
|
||||
openDocumentAndWaitForFinished(filePathA, 2 * AnnotationJobsMultiplier);
|
||||
|
||||
updateUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion1), 1U);
|
||||
ASSERT_THAT(clangServer, HasDirtyDocument(filePathA, projectPartId, 1U, true, true));
|
||||
ASSERT_THAT(clangServer, HasDirtyDocument(filePathA, 1U, true, true));
|
||||
}
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, TakeOverJobsOnProjectPartChange)
|
||||
TEST_F(ClangCodeModelServerSlowTest, TakeOverJobsOnDocumentChange)
|
||||
{
|
||||
updateProjectAndOpenDocumentAndWaitForFinished(filePathC, 2 * AnnotationJobsMultiplier);
|
||||
openDocument(filePathC, AnnotationJobsMultiplier);
|
||||
ASSERT_TRUE(waitUntilAllJobsFinished());
|
||||
updateVisibilty(filePathB, filePathB); // Disable processing jobs
|
||||
requestReferences();
|
||||
|
||||
expectReferences();
|
||||
|
||||
updateProjectPartWithArguments(); // Here we do not want to loose the RequestReferences job
|
||||
openDocument(filePathC, AnnotationJobsMultiplier); // Do not loose jobs
|
||||
updateVisibilty(filePathC, filePathC); // Enable processing jobs
|
||||
}
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, TakeOverJobsOnProjectPartIdChange)
|
||||
{
|
||||
updateProjectPart(projectPartId);
|
||||
updateProjectPart(projectPartId2);
|
||||
openDocument(filePathC, projectPartId, 0);
|
||||
requestReferences();
|
||||
|
||||
expectReferences();
|
||||
|
||||
openDocument(filePathC, projectPartId2); // Here we do not want to loose the RequestReferences job
|
||||
}
|
||||
|
||||
void ClangCodeModelServer::SetUp()
|
||||
{
|
||||
clangServer.setClient(&mockClangCodeModelClient);
|
||||
@@ -487,25 +451,17 @@ bool ClangCodeModelServer::waitUntilAllJobsFinished(int timeOutInMs)
|
||||
return ProcessEventUtilities::processEventsUntilTrue(noJobsRunningAnymore, timeOutInMs);
|
||||
}
|
||||
|
||||
void ClangCodeModelServer::updateProjectAndOpenDocumentsAndWaitForFinished(int expectedAnnotationsdMessages)
|
||||
{
|
||||
updateProjectPart();
|
||||
openDocuments(expectedAnnotationsdMessages);
|
||||
|
||||
ASSERT_TRUE(waitUntilAllJobsFinished());
|
||||
}
|
||||
|
||||
void ClangCodeModelServer::openDocument(const Utf8String &filePath,
|
||||
int expectedAnnotationsMessages)
|
||||
{
|
||||
openDocument(filePath, projectPartId, expectedAnnotationsMessages);
|
||||
openDocument(filePath, {}, expectedAnnotationsMessages);
|
||||
}
|
||||
|
||||
void ClangCodeModelServer::openDocument(const Utf8String &filePath,
|
||||
const Utf8String &projectPartId,
|
||||
const Utf8StringVector &compilationArguments,
|
||||
int expectedAnnotationsMessages)
|
||||
{
|
||||
const FileContainer fileContainer(filePath, projectPartId);
|
||||
const FileContainer fileContainer(filePath, compilationArguments);
|
||||
const DocumentsOpenedMessage message({fileContainer}, filePath, {filePath});
|
||||
|
||||
expectAnnotations(expectedAnnotationsMessages);
|
||||
@@ -515,8 +471,8 @@ void ClangCodeModelServer::openDocument(const Utf8String &filePath,
|
||||
|
||||
void ClangCodeModelServer::openDocuments(int expectedAnnotationsMessages)
|
||||
{
|
||||
const FileContainer fileContainerA(filePathA, projectPartId);
|
||||
const FileContainer fileContainerB(filePathB, projectPartId);
|
||||
const FileContainer fileContainerA(filePathA);
|
||||
const FileContainer fileContainerB(filePathB);
|
||||
const DocumentsOpenedMessage message({fileContainerA, fileContainerB},
|
||||
filePathA,
|
||||
{filePathA, filePathB});
|
||||
@@ -534,22 +490,15 @@ void ClangCodeModelServer::expectAnnotations(int count)
|
||||
void ClangCodeModelServer::openDocumentWithUnsavedContent(const Utf8String &filePath,
|
||||
const Utf8String &unsavedContent)
|
||||
{
|
||||
const FileContainer fileContainer(filePath, projectPartId, unsavedContent, true);
|
||||
const FileContainer fileContainer(filePath, unsavedContent, true);
|
||||
const DocumentsOpenedMessage message({fileContainer}, filePath, {filePath});
|
||||
|
||||
clangServer.documentsOpened(message);
|
||||
}
|
||||
|
||||
void ClangCodeModelServer::requestCompletions(const Utf8String &filePath,
|
||||
uint line,
|
||||
uint column,
|
||||
const Utf8String &projectPartId)
|
||||
void ClangCodeModelServer::requestCompletions(const Utf8String &filePath, uint line, uint column)
|
||||
{
|
||||
Utf8String theProjectPartId = projectPartId;
|
||||
if (theProjectPartId.isEmpty())
|
||||
theProjectPartId = this->projectPartId;
|
||||
|
||||
const RequestCompletionsMessage message(filePath, line, column, theProjectPartId);
|
||||
const RequestCompletionsMessage message(filePath, line, column);
|
||||
|
||||
clangServer.requestCompletions(message);
|
||||
}
|
||||
@@ -559,14 +508,9 @@ void ClangCodeModelServer::requestCompletionsInFileA()
|
||||
requestCompletions(filePathA, 20, 1);
|
||||
}
|
||||
|
||||
void ClangCodeModelServer::requestCompletionsInFileB()
|
||||
{
|
||||
requestCompletions(filePathB, 35, 1);
|
||||
}
|
||||
|
||||
bool ClangCodeModelServer::isSupportiveTranslationUnitInitialized(const Utf8String &filePath)
|
||||
{
|
||||
Document document = clangServer.documentsForTestOnly().document(filePath, projectPartId);
|
||||
Document document = clangServer.documentsForTestOnly().document(filePath);
|
||||
DocumentProcessor documentProcessor = clangServer.documentProcessors().processor(document);
|
||||
|
||||
return document.translationUnits().size() == 2
|
||||
@@ -576,7 +520,7 @@ bool ClangCodeModelServer::isSupportiveTranslationUnitInitialized(const Utf8Stri
|
||||
|
||||
DocumentProcessor ClangCodeModelServer::documentProcessorForFile(const Utf8String &filePath)
|
||||
{
|
||||
Document document = clangServer.documentsForTestOnly().document(filePath, projectPartId);
|
||||
Document document = clangServer.documentsForTestOnly().document(filePath);
|
||||
DocumentProcessor documentProcessor = clangServer.documentProcessors().processor(document);
|
||||
|
||||
return documentProcessor;
|
||||
@@ -590,15 +534,6 @@ void ClangCodeModelServer::expectCompletion(const CodeCompletion &completion)
|
||||
.Times(1);
|
||||
}
|
||||
|
||||
void ClangCodeModelServer::expectCompletionFromFileBEnabledByMacro()
|
||||
{
|
||||
const CodeCompletion completion(Utf8StringLiteral("ArgumentDefinitionVariable"),
|
||||
34,
|
||||
CodeCompletion::VariableCompletionKind);
|
||||
|
||||
expectCompletion(completion);
|
||||
}
|
||||
|
||||
void ClangCodeModelServer::expectCompletionFromFileAUnsavedMethodVersion1()
|
||||
{
|
||||
const CodeCompletion completion(Utf8StringLiteral("Method2"),
|
||||
@@ -666,15 +601,14 @@ void ClangCodeModelServer::expectCompletionFromFileA()
|
||||
|
||||
void ClangCodeModelServer::requestAnnotations(const Utf8String &filePath)
|
||||
{
|
||||
const RequestAnnotationsMessage message({filePath, projectPartId});
|
||||
const RequestAnnotationsMessage message(FileContainer{filePath});
|
||||
|
||||
clangServer.requestAnnotations(message);
|
||||
}
|
||||
|
||||
void ClangCodeModelServer::requestReferences(quint32 documentRevision)
|
||||
{
|
||||
const FileContainer fileContainer{filePathC, projectPartId, Utf8StringVector(),
|
||||
documentRevision};
|
||||
const FileContainer fileContainer{filePathC, Utf8StringVector(), documentRevision};
|
||||
const RequestReferencesMessage message{fileContainer, 3, 9};
|
||||
|
||||
clangServer.requestReferences(message);
|
||||
@@ -682,8 +616,7 @@ void ClangCodeModelServer::requestReferences(quint32 documentRevision)
|
||||
|
||||
void ClangCodeModelServer::requestFollowSymbol(quint32 documentRevision)
|
||||
{
|
||||
const FileContainer fileContainer{filePathC, projectPartId, Utf8StringVector(),
|
||||
documentRevision};
|
||||
const FileContainer fileContainer{filePathC, Utf8StringVector(), documentRevision};
|
||||
const RequestFollowSymbolMessage message{fileContainer, 43, 9};
|
||||
|
||||
clangServer.requestFollowSymbol(message);
|
||||
@@ -706,7 +639,7 @@ void ClangCodeModelServer::updateUnsavedContent(const Utf8String &filePath,
|
||||
const Utf8String &fileContent,
|
||||
quint32 revisionNumber)
|
||||
{
|
||||
const FileContainer fileContainer(filePath, projectPartId, fileContent, true, revisionNumber);
|
||||
const FileContainer fileContainer(filePath, fileContent, true, revisionNumber);
|
||||
const DocumentsChangedMessage message({fileContainer});
|
||||
|
||||
clangServer.documentsChanged(message);
|
||||
@@ -714,7 +647,7 @@ void ClangCodeModelServer::updateUnsavedContent(const Utf8String &filePath,
|
||||
|
||||
void ClangCodeModelServer::removeUnsavedFile(const Utf8String &filePath)
|
||||
{
|
||||
const FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74);
|
||||
const FileContainer fileContainer(filePath, Utf8StringVector(), 74);
|
||||
const DocumentsChangedMessage message({fileContainer});
|
||||
|
||||
clangServer.documentsChanged(message);
|
||||
@@ -722,47 +655,19 @@ void ClangCodeModelServer::removeUnsavedFile(const Utf8String &filePath)
|
||||
|
||||
void ClangCodeModelServer::closeDocument(const Utf8String &filePath)
|
||||
{
|
||||
const QVector<FileContainer> fileContainers = {FileContainer(filePath, projectPartId)};
|
||||
const QVector<FileContainer> fileContainers = {FileContainer(filePath)};
|
||||
const DocumentsClosedMessage message(fileContainers);
|
||||
|
||||
clangServer.documentsClosed(message);
|
||||
}
|
||||
|
||||
void ClangCodeModelServer::updateProjectPart()
|
||||
{
|
||||
updateProjectPart(projectPartId);
|
||||
}
|
||||
|
||||
void ClangCodeModelServer::updateProjectPart(const Utf8String &projectPartId)
|
||||
{
|
||||
ProjectPartsUpdatedMessage message({ProjectPartContainer(projectPartId)});
|
||||
|
||||
clangServer.projectPartsUpdated(message);
|
||||
}
|
||||
|
||||
void ClangCodeModelServer::updateProjectAndOpenDocument(const Utf8String &filePath,
|
||||
int expectedAnnotationsMessages)
|
||||
{
|
||||
updateProjectPart();
|
||||
openDocument(filePath, expectedAnnotationsMessages);
|
||||
}
|
||||
|
||||
void ClangCodeModelServer::updateProjectAndOpenDocumentAndWaitForFinished(
|
||||
void ClangCodeModelServer::openDocumentAndWaitForFinished(
|
||||
const Utf8String &filePath, int expectedAnnotationsMessages)
|
||||
{
|
||||
updateProjectAndOpenDocument(filePath, expectedAnnotationsMessages);
|
||||
openDocument(filePath, expectedAnnotationsMessages);
|
||||
ASSERT_TRUE(waitUntilAllJobsFinished());
|
||||
}
|
||||
|
||||
void ClangCodeModelServer::updateProjectPartWithArguments()
|
||||
{
|
||||
const ProjectPartContainer projectPartContainer(projectPartId,
|
||||
{Utf8StringLiteral("-DArgumentDefinition")});
|
||||
const ProjectPartsUpdatedMessage message({projectPartContainer});
|
||||
|
||||
clangServer.projectPartsUpdated(message);
|
||||
}
|
||||
|
||||
void ClangCodeModelServer::updateVisibilty(const Utf8String ¤tEditor,
|
||||
const Utf8String &additionalVisibleEditor)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user