コード例 #1
0
void TranslationUnits::SetUp()
{
    projects.createOrUpdate({ProjectPartContainer(projectPartId)});
    projects.createOrUpdate({ProjectPartContainer(otherProjectPartId)});

    auto callback = [&] (const DiagnosticsChangedMessage &, const HighlightingChangedMessage &) {
        mockSendDocumentAnnotationsCallback.sendDocumentAnnotations();
    };
    translationUnits.setSendDocumentAnnotationsCallback(callback);
}
コード例 #2
0
TEST_F(Documents, SetDocumentsDirtyIfProjectPartChanged_EvenIfAlreadyDirty)
{
    ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
    auto createdDocuments = documents.create({fileContainer});
    projects.createOrUpdate({ProjectPartContainer(projectPartId)});
    documents.setDocumentsDirtyIfProjectPartChanged(); // Make already dirty

    const auto affectedDocuments = documents.setDocumentsDirtyIfProjectPartChanged();

    ASSERT_THAT(affectedDocuments, createdDocuments);
}
コード例 #3
0
TEST_F(Documents, SetDocumentsDirtyIfProjectPartChanged)
{
    ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
    const auto createdDocuments = documents.create({fileContainer});
    ClangBackEnd::FileContainer fileContainerWithOtherProject(filePath, otherProjectPartId, Utf8StringVector(), 74u);
    documents.create({fileContainerWithOtherProject});
    projects.createOrUpdate({ProjectPartContainer(projectPartId)});

    const auto affectedDocuments = documents.setDocumentsDirtyIfProjectPartChanged();

    ASSERT_THAT(affectedDocuments, createdDocuments);
}
コード例 #4
0
TEST_F(Documents, RemoveAllValidIfExceptionIsThrown)
{
    ClangBackEnd::FileContainer fileContainer(filePath, projectPartId);
    documents.create({fileContainer});

    ASSERT_THROW(documents.remove({ClangBackEnd::FileContainer(Utf8StringLiteral("dontextist.pro"), projectPartId), fileContainer}),
                 ClangBackEnd::DocumentDoesNotExistException);

    ASSERT_THAT(documents.documents(),
                Not(Contains(Document(filePath,
                                             projects.project(projectPartId),
                                             Utf8StringVector(),
                                             documents))));
}
コード例 #5
0
TEST_F(TranslationUnits, SendDocumentAnnotationsAfterProjectPartChange)
{
    translationUnits.create({fileContainer, headerContainer});
    auto fileTranslationUnit = translationUnits.translationUnit(fileContainer);
    fileTranslationUnit.setIsVisibleInEditor(true);
    fileTranslationUnit.diagnostics(); // Reset
    fileTranslationUnit.highlightingInformations(); // Reset
    projects.createOrUpdate({ProjectPartContainer(projectPartId, {Utf8StringLiteral("-DNEW")})});
    translationUnits.setTranslationUnitsDirtyIfProjectPartChanged();

    EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(1);

    sendAllDocumentAnnotationsForVisibleEditors();
}
コード例 #6
0
void ProjectUpdater::addToHeaderAndSources(HeaderAndSources &headerAndSources,
                                           const CppTools::ProjectFile &projectFile) const
{
    using ClangBackEnd::FilePathView;

    Utils::PathString path = projectFile.path;
    bool exclude = std::binary_search(m_excludedPaths.begin(), m_excludedPaths.end(), path);

    if (!exclude) {
        ClangBackEnd::FilePathId filePathId = m_filePathCache.filePathId(FilePathView(path));
        if (projectFile.isSource())
            headerAndSources.sources.push_back(filePathId);
        else if (projectFile.isHeader())
            headerAndSources.headers.push_back(filePathId);
    }
}
コード例 #7
0
void Documents::SetUp()
{
    projects.createOrUpdate({ProjectPartContainer(projectPartId)});
    projects.createOrUpdate({ProjectPartContainer(otherProjectPartId)});
}