forked from qt-creator/qt-creator
Clang: Create preamble on first parse
...now that parsing and creating the preamble is faster due to the skipped function bodies. As a consequence, we can remove all the extra jobs that were needed to get an initial AST faster. Change-Id: I79a66b8a0e8a180850af6daf353d9a679089bbb1 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -7,7 +7,6 @@ HEADERS += \
|
||||
$$PWD/clangcodecompleteresults.h \
|
||||
$$PWD/clangcodemodelserver.h \
|
||||
$$PWD/clangcompletecodejob.h \
|
||||
$$PWD/clangcreateinitialdocumentpreamblejob.h \
|
||||
$$PWD/clangdocument.h \
|
||||
$$PWD/clangdocumentjob.h \
|
||||
$$PWD/clangdocumentprocessor.h \
|
||||
@@ -26,7 +25,6 @@ HEADERS += \
|
||||
$$PWD/clangjobs.h \
|
||||
$$PWD/clangparsesupportivetranslationunitjob.h \
|
||||
$$PWD/clangreferencescollector.h \
|
||||
$$PWD/clangreparsesupportivetranslationunitjob.h \
|
||||
$$PWD/clangrequestdocumentannotationsjob.h \
|
||||
$$PWD/clangrequestreferencesjob.h \
|
||||
$$PWD/clangrequesttooltipjob.h \
|
||||
@@ -68,7 +66,6 @@ SOURCES += \
|
||||
$$PWD/clangcodecompleteresults.cpp \
|
||||
$$PWD/clangcodemodelserver.cpp \
|
||||
$$PWD/clangcompletecodejob.cpp \
|
||||
$$PWD/clangcreateinitialdocumentpreamblejob.cpp \
|
||||
$$PWD/clangdocument.cpp \
|
||||
$$PWD/clangdocumentprocessor.cpp \
|
||||
$$PWD/clangdocumentprocessors.cpp \
|
||||
@@ -87,7 +84,6 @@ SOURCES += \
|
||||
$$PWD/clangparsesupportivetranslationunitjob.cpp \
|
||||
$$PWD/clangresumedocumentjob.cpp \
|
||||
$$PWD/clangreferencescollector.cpp \
|
||||
$$PWD/clangreparsesupportivetranslationunitjob.cpp \
|
||||
$$PWD/clangrequestdocumentannotationsjob.cpp \
|
||||
$$PWD/clangrequestreferencesjob.cpp \
|
||||
$$PWD/clangrequesttooltipjob.cpp \
|
||||
|
||||
@@ -481,7 +481,6 @@ void ClangCodeModelServer::processInitialJobsForDocuments(const std::vector<Docu
|
||||
DocumentProcessor processor = documentProcessors().processor(document);
|
||||
processor.addJob(JobRequest::Type::UpdateDocumentAnnotations);
|
||||
processor.addJob(JobRequest::Type::UpdateExtraDocumentAnnotations);
|
||||
processor.addJob(JobRequest::Type::CreateInitialDocumentPreamble);
|
||||
processor.process();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "clangcreateinitialdocumentpreamblejob.h"
|
||||
|
||||
#include <clangsupport/clangsupportdebugutils.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
IAsyncJob::AsyncPrepareResult CreateInitialDocumentPreambleJob::prepareAsyncRun()
|
||||
{
|
||||
const JobRequest jobRequest = context().jobRequest;
|
||||
QTC_ASSERT(jobRequest.type == JobRequest::Type::CreateInitialDocumentPreamble, return AsyncPrepareResult());
|
||||
QTC_ASSERT(acquireDocument(), return AsyncPrepareResult());
|
||||
|
||||
const TranslationUnit translationUnit = *m_translationUnit;
|
||||
const TranslationUnitUpdateInput updateInput = m_pinnedDocument.createUpdateInput();
|
||||
setRunner([translationUnit, updateInput]() {
|
||||
TIME_SCOPE_DURATION("CreateInitialDocumentPreambleJobRunner");
|
||||
translationUnit.reparse(updateInput);
|
||||
});
|
||||
|
||||
return AsyncPrepareResult{translationUnit.id()};
|
||||
}
|
||||
|
||||
void CreateInitialDocumentPreambleJob::finalizeAsyncRun()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "clangdocumentjob.h"
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class CreateInitialDocumentPreambleJob : public DocumentJob<void>
|
||||
{
|
||||
public:
|
||||
AsyncPrepareResult prepareAsyncRun() override;
|
||||
void finalizeAsyncRun() override;
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
@@ -26,10 +26,8 @@
|
||||
#include "clangjobrequest.h"
|
||||
|
||||
#include "clangcompletecodejob.h"
|
||||
#include "clangcreateinitialdocumentpreamblejob.h"
|
||||
#include "clangfollowsymboljob.h"
|
||||
#include "clangparsesupportivetranslationunitjob.h"
|
||||
#include "clangreparsesupportivetranslationunitjob.h"
|
||||
#include "clangrequestdocumentannotationsjob.h"
|
||||
#include "clangrequestreferencesjob.h"
|
||||
#include "clangrequesttooltipjob.h"
|
||||
@@ -60,8 +58,6 @@ static const char *JobRequestTypeToText(JobRequest::Type type)
|
||||
RETURN_TEXT_FOR_CASE(UpdateDocumentAnnotations);
|
||||
RETURN_TEXT_FOR_CASE(UpdateExtraDocumentAnnotations);
|
||||
RETURN_TEXT_FOR_CASE(ParseSupportiveTranslationUnit);
|
||||
RETURN_TEXT_FOR_CASE(ReparseSupportiveTranslationUnit);
|
||||
RETURN_TEXT_FOR_CASE(CreateInitialDocumentPreamble);
|
||||
RETURN_TEXT_FOR_CASE(CompleteCode);
|
||||
RETURN_TEXT_FOR_CASE(RequestDocumentAnnotations);
|
||||
RETURN_TEXT_FOR_CASE(RequestReferences);
|
||||
@@ -196,11 +192,9 @@ bool JobRequest::isTakeOverable() const
|
||||
// anyway.
|
||||
case Type::UpdateDocumentAnnotations:
|
||||
case Type::UpdateExtraDocumentAnnotations:
|
||||
case Type::CreateInitialDocumentPreamble:
|
||||
|
||||
// Discard these as they only make sense in a row. Avoid splitting them up.
|
||||
case Type::ParseSupportiveTranslationUnit:
|
||||
case Type::ReparseSupportiveTranslationUnit:
|
||||
|
||||
case Type::Invalid:
|
||||
return false;
|
||||
@@ -231,10 +225,6 @@ IAsyncJob *JobRequest::createJob() const
|
||||
return new UpdateExtraDocumentAnnotationsJob();
|
||||
case JobRequest::Type::ParseSupportiveTranslationUnit:
|
||||
return new ParseSupportiveTranslationUnitJob();
|
||||
case JobRequest::Type::ReparseSupportiveTranslationUnit:
|
||||
return new ReparseSupportiveTranslationUnitJob();
|
||||
case JobRequest::Type::CreateInitialDocumentPreamble:
|
||||
return new CreateInitialDocumentPreambleJob();
|
||||
case JobRequest::Type::CompleteCode:
|
||||
return new CompleteCodeJob();
|
||||
case JobRequest::Type::RequestDocumentAnnotations:
|
||||
@@ -264,8 +254,6 @@ void JobRequest::cancelJob(ClangCodeModelClientInterface &client) const
|
||||
case JobRequest::Type::UpdateDocumentAnnotations:
|
||||
case JobRequest::Type::UpdateExtraDocumentAnnotations:
|
||||
case JobRequest::Type::ParseSupportiveTranslationUnit:
|
||||
case JobRequest::Type::ReparseSupportiveTranslationUnit:
|
||||
case JobRequest::Type::CreateInitialDocumentPreamble:
|
||||
case JobRequest::Type::RequestDocumentAnnotations:
|
||||
case JobRequest::Type::SuspendDocument:
|
||||
case JobRequest::Type::ResumeDocument:
|
||||
|
||||
@@ -51,10 +51,8 @@ public:
|
||||
|
||||
UpdateDocumentAnnotations,
|
||||
UpdateExtraDocumentAnnotations,
|
||||
CreateInitialDocumentPreamble,
|
||||
|
||||
ParseSupportiveTranslationUnit,
|
||||
ReparseSupportiveTranslationUnit,
|
||||
|
||||
CompleteCode,
|
||||
RequestDocumentAnnotations,
|
||||
|
||||
@@ -53,6 +53,10 @@ IAsyncJob::AsyncPrepareResult ParseSupportiveTranslationUnitJob::prepareAsyncRun
|
||||
|
||||
void ParseSupportiveTranslationUnitJob::finalizeAsyncRun()
|
||||
{
|
||||
if (!context().isOutdated()) {
|
||||
const AsyncResult result = asyncResult();
|
||||
m_pinnedDocument.incorporateUpdaterResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "clangreparsesupportivetranslationunitjob.h"
|
||||
|
||||
#include <clangsupport/clangsupportdebugutils.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
IAsyncJob::AsyncPrepareResult ReparseSupportiveTranslationUnitJob::prepareAsyncRun()
|
||||
{
|
||||
const JobRequest jobRequest = context().jobRequest;
|
||||
QTC_ASSERT(jobRequest.type == JobRequest::Type::ReparseSupportiveTranslationUnit, return AsyncPrepareResult());
|
||||
QTC_ASSERT(acquireDocument(), return AsyncPrepareResult());
|
||||
|
||||
const TranslationUnit translationUnit = *m_translationUnit;
|
||||
const TranslationUnitUpdateInput updateInput = m_pinnedDocument.createUpdateInput();
|
||||
setRunner([translationUnit, updateInput]() {
|
||||
TIME_SCOPE_DURATION("ReparseSupportiveTranslationUnitJob");
|
||||
|
||||
TranslationUnitUpdateInput theUpdateInput = updateInput;
|
||||
theUpdateInput.reparseNeeded = true;
|
||||
|
||||
ReparseSupportiveTranslationUnitJob::AsyncResult asyncResult;
|
||||
asyncResult.updateResult = translationUnit.reparse(theUpdateInput);
|
||||
|
||||
return asyncResult;
|
||||
});
|
||||
|
||||
return AsyncPrepareResult{translationUnit.id()};
|
||||
}
|
||||
|
||||
void ReparseSupportiveTranslationUnitJob::finalizeAsyncRun()
|
||||
{
|
||||
if (!context().isOutdated()) {
|
||||
const AsyncResult result = asyncResult();
|
||||
m_pinnedDocument.incorporateUpdaterResult(result.updateResult);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "clangdocumentjob.h"
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
struct ReparseSupportiveTranslationUnitJobResult
|
||||
{
|
||||
TranslationUnitUpdateResult updateResult;
|
||||
};
|
||||
|
||||
class ReparseSupportiveTranslationUnitJob : public DocumentJob<ReparseSupportiveTranslationUnitJobResult>
|
||||
{
|
||||
public:
|
||||
using AsyncResult = ReparseSupportiveTranslationUnitJobResult;
|
||||
|
||||
AsyncPrepareResult prepareAsyncRun() override;
|
||||
void finalizeAsyncRun() override;
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
@@ -82,29 +82,13 @@ void SupportiveTranslationUnitInitializer::checkIfParseJobFinished(const Jobs::R
|
||||
return;
|
||||
|
||||
if (job.jobRequest.type == JobRequest::Type::ParseSupportiveTranslationUnit) {
|
||||
m_jobs.setJobFinishedCallback([this](const Jobs::RunningJob &runningJob) {
|
||||
checkIfReparseJobFinished(runningJob);
|
||||
});
|
||||
|
||||
addJob(JobRequest::Type::ReparseSupportiveTranslationUnit);
|
||||
|
||||
m_state = State::WaitingForReparseJob;
|
||||
}
|
||||
}
|
||||
|
||||
void SupportiveTranslationUnitInitializer::checkIfReparseJobFinished(const Jobs::RunningJob &job)
|
||||
{
|
||||
if (!checkStateAndDocument(State::WaitingForReparseJob))
|
||||
return;
|
||||
|
||||
if (job.jobRequest.type == JobRequest::Type::ReparseSupportiveTranslationUnit) {
|
||||
if (m_document.translationUnits().areAllTranslationUnitsParsed()) {
|
||||
m_jobs.setJobFinishedCallback(nullptr);
|
||||
m_state = State::Initialized;
|
||||
} else {
|
||||
// The supportive translation unit was reparsed, but the document
|
||||
// The supportive translation unit was parsed, but the document
|
||||
// revision changed in the meanwhile, so try again.
|
||||
addJob(JobRequest::Type::ReparseSupportiveTranslationUnit);
|
||||
addJob(JobRequest::Type::ParseSupportiveTranslationUnit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ public:
|
||||
enum class State {
|
||||
NotInitialized,
|
||||
WaitingForParseJob,
|
||||
WaitingForReparseJob,
|
||||
Initialized,
|
||||
Aborted
|
||||
};
|
||||
@@ -57,7 +56,6 @@ public:
|
||||
public: // for tests
|
||||
void setState(const State &state);
|
||||
void checkIfParseJobFinished(const Jobs::RunningJob &job);
|
||||
void checkIfReparseJobFinished(const Jobs::RunningJob &job);
|
||||
|
||||
private:
|
||||
bool checkStateAndDocument(State currentExpectedState);
|
||||
|
||||
@@ -175,6 +175,7 @@ uint TranslationUnitUpdater::defaultParseOptions()
|
||||
{
|
||||
return CXTranslationUnit_CacheCompletionResults
|
||||
| CXTranslationUnit_PrecompiledPreamble
|
||||
| CXTranslationUnit_CreatePreambleOnFirstParse
|
||||
#ifdef CINDEX_VERSION_HAS_LIMITSKIPFUNCTIONBODIESTOPREAMBLE_BACKPORTED
|
||||
| CXTranslationUnit_SkipFunctionBodies
|
||||
| CXTranslationUnit_LimitSkipFunctionBodiesToPreamble
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "clangasyncjob-base.h"
|
||||
|
||||
#include <clangcreateinitialdocumentpreamblejob.h>
|
||||
|
||||
using namespace ClangBackEnd;
|
||||
|
||||
namespace {
|
||||
|
||||
class CreateInitialDocumentPreambleJob : public ClangAsyncJobTest
|
||||
{
|
||||
protected:
|
||||
void SetUp() override { BaseSetUp(JobRequest::Type::CreateInitialDocumentPreamble, job); }
|
||||
|
||||
protected:
|
||||
ClangBackEnd::CreateInitialDocumentPreambleJob job;
|
||||
};
|
||||
|
||||
using CreateInitialDocumentPreambleJobSlowTest = CreateInitialDocumentPreambleJob;
|
||||
|
||||
TEST_F(CreateInitialDocumentPreambleJob, PrepareAsyncRun)
|
||||
{
|
||||
job.setContext(jobContext);
|
||||
|
||||
ASSERT_TRUE(job.prepareAsyncRun());
|
||||
}
|
||||
|
||||
TEST_F(CreateInitialDocumentPreambleJobSlowTest, RunAsync)
|
||||
{
|
||||
document.parse();
|
||||
document.setDirtyIfDependencyIsMet(document.filePath());
|
||||
job.setContext(jobContext);
|
||||
job.prepareAsyncRun();
|
||||
|
||||
job.runAsync();
|
||||
|
||||
ASSERT_TRUE(waitUntilJobFinished(job));
|
||||
}
|
||||
|
||||
} // anonymous
|
||||
@@ -309,7 +309,6 @@ TEST_F(JobQueue, PrioritizeCurrentDocumentOverVisible)
|
||||
TEST_F(JobQueue, RunNothingForNotCurrentOrVisibleDocument)
|
||||
{
|
||||
jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations));
|
||||
jobQueue.add(createJobRequest(filePath1, JobRequest::Type::CreateInitialDocumentPreamble));
|
||||
documents.setVisibleInEditors({});
|
||||
documents.setUsedByCurrentEditor(Utf8StringLiteral("aNonExistingFilePath"));
|
||||
|
||||
@@ -321,7 +320,7 @@ TEST_F(JobQueue, RunNothingForNotCurrentOrVisibleDocument)
|
||||
TEST_F(JobQueue, RunOnlyOneJobPerTranslationUnitIfMultipleAreInQueue)
|
||||
{
|
||||
jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations));
|
||||
jobQueue.add(createJobRequest(filePath1, JobRequest::Type::CreateInitialDocumentPreamble));
|
||||
jobQueue.add(createJobRequest(filePath1, JobRequest::Type::RequestDocumentAnnotations));
|
||||
|
||||
const JobRequests jobsToRun = jobQueue.processQueue();
|
||||
|
||||
@@ -350,7 +349,6 @@ TEST_F(JobQueue, RunJobsForDistinctTranslationUnits)
|
||||
TEST_F(JobQueue, DoNotRunJobForTranslationUnittThatIsBeingProcessed)
|
||||
{
|
||||
jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations));
|
||||
jobQueue.add(createJobRequest(filePath1, JobRequest::Type::CreateInitialDocumentPreamble));
|
||||
JobRequests jobsToRun = jobQueue.processQueue();
|
||||
jobQueue.setIsJobRunningForTranslationUnitHandler([](const Utf8String &) {
|
||||
return true;
|
||||
@@ -443,16 +441,6 @@ TEST_F(JobQueue, RequestCompleteCodeNotOutdatableByDocumentRevisionChange)
|
||||
ASSERT_THAT(jobsToStart.size(), Eq(1));
|
||||
}
|
||||
|
||||
TEST_F(JobQueue, RequestCreateInitialDocumentPreambleOutdatableByDocumentClose)
|
||||
{
|
||||
jobQueue.add(createJobRequest(filePath1, JobRequest::Type::CreateInitialDocumentPreamble));
|
||||
removeDocument();
|
||||
|
||||
const JobRequests jobsToStart = jobQueue.processQueue();
|
||||
|
||||
ASSERT_THAT(jobsToStart.size(), Eq(0));
|
||||
}
|
||||
|
||||
TEST_F(JobQueue, RequestCompleteCodeOutdatableByDocumentRevisionChange)
|
||||
{
|
||||
jobQueue.add(createJobRequest(filePath1, JobRequest::Type::RequestDocumentAnnotations));
|
||||
|
||||
@@ -66,23 +66,4 @@ TEST_F(ParseSupportiveTranslationUnitJobSlowTest, RunAsync)
|
||||
ASSERT_TRUE(waitUntilJobFinished(job));
|
||||
}
|
||||
|
||||
TEST_F(ParseSupportiveTranslationUnitJobSlowTest, DoNotIncorporateUpdaterResult)
|
||||
{
|
||||
const TimePoint parseTimePointBefore = parseTimePointOfDocument();
|
||||
job.setContext(jobContext);
|
||||
job.prepareAsyncRun();
|
||||
|
||||
job.runAsync();
|
||||
|
||||
ASSERT_TRUE(waitUntilJobFinished(job));
|
||||
ASSERT_THAT(parseTimePointOfDocument(), Eq(parseTimePointBefore));
|
||||
}
|
||||
|
||||
TimePoint ParseSupportiveTranslationUnitJob::parseTimePointOfDocument()
|
||||
{
|
||||
const Utf8String translationUnitId = document.translationUnit().id();
|
||||
|
||||
return document.translationUnits().parseTimePoint(translationUnitId);
|
||||
}
|
||||
|
||||
} // anonymous
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "clangasyncjob-base.h"
|
||||
|
||||
#include <clangreparsesupportivetranslationunitjob.h>
|
||||
#include <clangtranslationunits.h>
|
||||
|
||||
using namespace ClangBackEnd;
|
||||
|
||||
using testing::Eq;
|
||||
using testing::Not;
|
||||
using testing::_;
|
||||
|
||||
namespace {
|
||||
|
||||
class ReparseSupportiveTranslationUnitJob : public ClangAsyncJobTest
|
||||
{
|
||||
protected:
|
||||
void SetUp() override { BaseSetUp(JobRequest::Type::ReparseSupportiveTranslationUnit, job); }
|
||||
|
||||
TimePoint parseTimePointOfDocument();
|
||||
void parse();
|
||||
|
||||
protected:
|
||||
ClangBackEnd::ReparseSupportiveTranslationUnitJob job;
|
||||
};
|
||||
|
||||
using ReparseSupportiveTranslationUnitJobSlowTest = ReparseSupportiveTranslationUnitJob;
|
||||
|
||||
TEST_F(ReparseSupportiveTranslationUnitJob, PrepareAsyncRun)
|
||||
{
|
||||
job.setContext(jobContext);
|
||||
|
||||
ASSERT_TRUE(job.prepareAsyncRun());
|
||||
}
|
||||
|
||||
TEST_F(ReparseSupportiveTranslationUnitJobSlowTest, RunAsync)
|
||||
{
|
||||
parse();
|
||||
job.setContext(jobContext);
|
||||
job.prepareAsyncRun();
|
||||
|
||||
job.runAsync();
|
||||
|
||||
ASSERT_TRUE(waitUntilJobFinished(job));
|
||||
}
|
||||
|
||||
TEST_F(ReparseSupportiveTranslationUnitJobSlowTest, IncorporateUpdaterResult)
|
||||
{
|
||||
parse();
|
||||
const TimePoint parseTimePointBefore = parseTimePointOfDocument();
|
||||
job.setContext(jobContext);
|
||||
job.prepareAsyncRun();
|
||||
|
||||
job.runAsync();
|
||||
|
||||
ASSERT_TRUE(waitUntilJobFinished(job));
|
||||
ASSERT_THAT(parseTimePointOfDocument(), Not(Eq(parseTimePointBefore)));
|
||||
}
|
||||
|
||||
TEST_F(ReparseSupportiveTranslationUnitJobSlowTest, DoNotIncorporateUpdaterResultIfDocumentWasClosed)
|
||||
{
|
||||
parse();
|
||||
const TimePoint parseTimePointBefore = parseTimePointOfDocument();
|
||||
job.setContext(jobContext);
|
||||
job.prepareAsyncRun();
|
||||
|
||||
job.runAsync();
|
||||
documents.remove({FileContainer{filePath, projectPartId}});
|
||||
|
||||
ASSERT_TRUE(waitUntilJobFinished(job));
|
||||
ASSERT_THAT(parseTimePointOfDocument(), Eq(parseTimePointBefore));
|
||||
}
|
||||
|
||||
TimePoint ReparseSupportiveTranslationUnitJob::parseTimePointOfDocument()
|
||||
{
|
||||
const Utf8String translationUnitId = document.translationUnit().id();
|
||||
|
||||
return document.translationUnits().parseTimePoint(translationUnitId);
|
||||
}
|
||||
|
||||
void ReparseSupportiveTranslationUnitJob::parse()
|
||||
{
|
||||
projects.createOrUpdate({ProjectPartContainer{projectPartId, Utf8StringVector()}});
|
||||
document.parse();
|
||||
}
|
||||
|
||||
} // anonymous
|
||||
@@ -144,34 +144,8 @@ TEST_F(SupportiveTranslationUnitInitializerSlowTest, CheckIfParseJobFinishedStar
|
||||
initializer.checkIfParseJobFinished(runningJob);
|
||||
jobs.process();
|
||||
|
||||
assertSingleJobRunningAndEmptyQueue();
|
||||
runningJob = jobs.runningJobs().first();
|
||||
ASSERT_THAT(runningJob.jobRequest.type, JobRequest::Type::ReparseSupportiveTranslationUnit);
|
||||
}
|
||||
|
||||
TEST_F(SupportiveTranslationUnitInitializer, CheckIfReparseJobFinishedAbortsIfDocumentIsClosed)
|
||||
{
|
||||
documents.remove({FileContainer(filePath, projectPartId)});
|
||||
initializer.setState(ClangBackEnd::SupportiveTranslationUnitInitializer::State::WaitingForReparseJob);
|
||||
const Jobs::RunningJob runningJob = createRunningJob(JobRequest::Type::ReparseSupportiveTranslationUnit);
|
||||
|
||||
initializer.checkIfReparseJobFinished(runningJob);
|
||||
|
||||
assertNoJobIsRunningAndEmptyQueue();
|
||||
ASSERT_THAT(initializer.state(), Eq(ClangBackEnd::SupportiveTranslationUnitInitializer::State::Aborted));
|
||||
}
|
||||
|
||||
TEST_F(SupportiveTranslationUnitInitializerSlowTest, CheckIfReparseJobFinishedStartsJob)
|
||||
{
|
||||
parse();
|
||||
initializer.setState(ClangBackEnd::SupportiveTranslationUnitInitializer::State::WaitingForReparseJob);
|
||||
Jobs::RunningJob runningJob = createRunningJob(JobRequest::Type::ReparseSupportiveTranslationUnit);
|
||||
|
||||
initializer.checkIfReparseJobFinished(runningJob);
|
||||
jobs.process();
|
||||
|
||||
assertNoJobIsRunningAndEmptyQueue();
|
||||
ASSERT_THAT(initializer.state(), Eq(ClangBackEnd::SupportiveTranslationUnitInitializer::State::Initialized));
|
||||
ASSERT_THAT(jobs.runningJobs(), IsEmpty());
|
||||
ASSERT_THAT(jobs.queue(), IsEmpty());
|
||||
}
|
||||
|
||||
TEST_F(SupportiveTranslationUnitInitializerSlowTest, FullRun)
|
||||
|
||||
@@ -104,7 +104,6 @@ SOURCES += \
|
||||
clangcodemodelserver-test.cpp \
|
||||
clangcompletecodejob-test.cpp \
|
||||
clangcompletioncontextanalyzer-test.cpp \
|
||||
clangcreateinitialdocumentpreamblejob-test.cpp \
|
||||
clangdiagnosticfilter-test.cpp \
|
||||
clangdocumentprocessors-test.cpp \
|
||||
clangdocumentprocessor-test.cpp \
|
||||
@@ -118,7 +117,6 @@ SOURCES += \
|
||||
clangjobs-test.cpp \
|
||||
clangparsesupportivetranslationunitjob-test.cpp \
|
||||
clangreferencescollector-test.cpp \
|
||||
clangreparsesupportivetranslationunitjob-test.cpp \
|
||||
clangrequestdocumentannotationsjob-test.cpp \
|
||||
clangrequestreferencesjob-test.cpp \
|
||||
clangresumedocumentjob-test.cpp \
|
||||
|
||||
Reference in New Issue
Block a user