Commit de5cbaca authored by Nikolai Kosjar's avatar Nikolai Kosjar

Clang: Rename JobRequest::Requirements to ExpirationsReasons

...to avoid ambiguity in regard to a new enum in a follow-up change.

Change-Id: I4f732b5200ed674b6708510ac8de0a795afe52da
Reviewed-by: Marco Bubke's avatarMarco Bubke <marco.bubke@qt.io>
parent e8ce2e62
......@@ -66,20 +66,20 @@ int JobQueue::size() const
JobRequests JobQueue::processQueue()
{
removeOutDatedRequests();
removeExpiredRequests();
prioritizeRequests();
const JobRequests jobsToRun = takeJobRequestsToRunNow();
return jobsToRun;
}
void JobQueue::removeOutDatedRequests()
void JobQueue::removeExpiredRequests()
{
JobRequests cleanedRequests;
foreach (const JobRequest &jobRequest, m_queue) {
try {
if (!isJobRequestOutDated(jobRequest))
if (!isJobRequestExpired(jobRequest))
cleanedRequests.append(jobRequest);
} catch (const std::exception &exception) {
qWarning() << "Error in Jobs::removeOutDatedRequests for"
......@@ -90,12 +90,12 @@ void JobQueue::removeOutDatedRequests()
m_queue = cleanedRequests;
}
bool JobQueue::isJobRequestOutDated(const JobRequest &jobRequest) const
bool JobQueue::isJobRequestExpired(const JobRequest &jobRequest) const
{
const JobRequest::Requirements requirements = jobRequest.requirements;
const JobRequest::ExpirationReasons expirationReasons = jobRequest.expirationReasons;
const UnsavedFiles unsavedFiles = m_documents.unsavedFiles();
if (requirements.testFlag(JobRequest::CurrentUnsavedFiles)) {
if (expirationReasons.testFlag(JobRequest::UnsavedFilesChanged)) {
if (jobRequest.unsavedFilesChangeTimePoint != unsavedFiles.lastChangeTimePoint()) {
qCDebug(jobsLog) << "Removing due to outdated unsaved files:" << jobRequest;
return true;
......@@ -104,7 +104,7 @@ bool JobQueue::isJobRequestOutDated(const JobRequest &jobRequest) const
bool projectCheckedAndItExists = false;
if (requirements.testFlag(JobRequest::DocumentValid)) {
if (expirationReasons.testFlag(JobRequest::DocumentClosed)) {
if (!m_documents.hasDocument(jobRequest.filePath, jobRequest.projectPartId)) {
qCDebug(jobsLog) << "Removing due to already closed document:" << jobRequest;
return true;
......@@ -123,7 +123,7 @@ bool JobQueue::isJobRequestOutDated(const JobRequest &jobRequest) const
return true;
}
if (requirements.testFlag(JobRequest::CurrentDocumentRevision)) {
if (expirationReasons.testFlag(JobRequest::DocumentRevisionChanged)) {
if (document.documentRevision() != jobRequest.documentRevision) {
qCDebug(jobsLog) << "Removing due to changed document revision:" << jobRequest;
return true;
......@@ -131,7 +131,7 @@ bool JobQueue::isJobRequestOutDated(const JobRequest &jobRequest) const
}
}
if (requirements.testFlag(JobRequest::CurrentProject)) {
if (expirationReasons.testFlag(JobRequest::ProjectChanged)) {
if (!projectCheckedAndItExists && !m_projectParts.hasProjectPart(jobRequest.projectPartId)) {
qCDebug(jobsLog) << "Removing due to already closed project:" << jobRequest;
return true;
......
......@@ -60,8 +60,8 @@ private:
bool isJobRunningForTranslationUnit(const Utf8String &translationUnitId);
bool isJobRunningForJobRequest(const JobRequest &jobRequest);
JobRequests takeJobRequestsToRunNow();
void removeOutDatedRequests();
bool isJobRequestOutDated(const JobRequest &jobRequest) const;
void removeExpiredRequests();
bool isJobRequestExpired(const JobRequest &jobRequest) const;
private:
Documents &m_documents;
......
......@@ -89,7 +89,7 @@ JobRequest::JobRequest()
bool JobRequest::operator==(const JobRequest &other) const
{
return type == other.type
&& requirements == other.requirements
&& expirationReasons == other.expirationReasons
&& filePath == other.filePath
&& projectPartId == other.projectPartId
......@@ -103,22 +103,22 @@ bool JobRequest::operator==(const JobRequest &other) const
&& ticketNumber == other.ticketNumber;
}
JobRequest::Requirements JobRequest::requirementsForType(Type type)
JobRequest::ExpirationReasons JobRequest::expirationReasonsForType(Type type)
{
switch (type) {
case JobRequest::Type::UpdateDocumentAnnotations:
return JobRequest::Requirements(JobRequest::All);
return JobRequest::ExpirationReasons(JobRequest::AnythingChanged);
case JobRequest::Type::RequestDocumentAnnotations:
return JobRequest::Requirements(JobRequest::DocumentValid
|JobRequest::CurrentDocumentRevision);
return JobRequest::ExpirationReasons(JobRequest::DocumentClosed
|JobRequest::DocumentRevisionChanged);
case JobRequest::Type::CompleteCode:
case JobRequest::Type::CreateInitialDocumentPreamble:
case JobRequest::Type::ParseSupportiveTranslationUnit:
case JobRequest::Type::ReparseSupportiveTranslationUnit:
return JobRequest::Requirements(JobRequest::DocumentValid);
return JobRequest::ExpirationReasons(JobRequest::DocumentClosed);
}
return JobRequest::Requirements(JobRequest::DocumentValid);
return JobRequest::ExpirationReasons(JobRequest::DocumentClosed);
}
} // namespace ClangBackEnd
......@@ -54,20 +54,23 @@ public:
RequestDocumentAnnotations,
};
enum Requirement {
None = 1 << 0,
DocumentValid = 1 << 1,
CurrentDocumentRevision = 1 << 3, // Only effective if DocumentValid is also set
CurrentUnsavedFiles = 1 << 2,
CurrentProject = 1 << 4,
All = DocumentValid | CurrentUnsavedFiles | CurrentDocumentRevision | CurrentProject
enum ExpirationReason {
Never = 1 << 0,
DocumentClosed = 1 << 1,
DocumentRevisionChanged = 1 << 2, // Only effective if DocumentIsClosed is also set
UnsavedFilesChanged = 1 << 3,
ProjectChanged = 1 << 4,
AnythingChanged = DocumentClosed
| DocumentRevisionChanged
| UnsavedFilesChanged
| ProjectChanged,
};
Q_DECLARE_FLAGS(Requirements, Requirement)
Q_DECLARE_FLAGS(ExpirationReasons, ExpirationReason)
public:
static Requirements requirementsForType(Type type);
static ExpirationReasons expirationReasonsForType(Type type);
JobRequest();
......@@ -76,7 +79,7 @@ public:
public:
quint64 id = 0;
Type type;
Requirements requirements;
ExpirationReasons expirationReasons;
// General
Utf8String filePath;
......
......@@ -75,7 +75,7 @@ JobRequest Jobs::createJobRequest(const Document &document,
{
JobRequest jobRequest;
jobRequest.type = type;
jobRequest.requirements = JobRequest::requirementsForType(type);
jobRequest.expirationReasons = JobRequest::expirationReasonsForType(type);
jobRequest.filePath = document.filePath();
jobRequest.projectPartId = document.projectPart().id();
jobRequest.unsavedFilesChangeTimePoint = m_unsavedFiles.lastChangeTimePoint();
......
......@@ -51,7 +51,7 @@ JobRequest ClangAsyncJobTest::createJobRequest(const Utf8String &filePath,
{
JobRequest jobRequest;
jobRequest.type = type;
jobRequest.requirements = JobRequest::requirementsForType(type);
jobRequest.expirationReasons = JobRequest::expirationReasonsForType(type);
jobRequest.filePath = filePath;
jobRequest.projectPartId = projectPartId;
jobRequest.unsavedFilesChangeTimePoint = unsavedFiles.lastChangeTimePoint();
......
......@@ -449,7 +449,7 @@ JobRequest JobQueue::createJobRequest(
{
JobRequest jobRequest;
jobRequest.type = type;
jobRequest.requirements = JobRequest::requirementsForType(type);
jobRequest.expirationReasons = JobRequest::expirationReasonsForType(type);
jobRequest.filePath = filePath;
jobRequest.projectPartId = projectPartId;
jobRequest.unsavedFilesChangeTimePoint = unsavedFiles.lastChangeTimePoint();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment