forked from qt-creator/qt-creator
Clang: Rename some enums in JobRequest
...because both are conditions:
ExpirationReason --> ExpirationCondition
Condition --> RunCondition
Change-Id: Iae79b11c20618574fac8142710b11b5c16339127
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -105,11 +105,11 @@ void JobQueue::removeExpiredRequests()
|
|||||||
|
|
||||||
bool JobQueue::isJobRequestExpired(const JobRequest &jobRequest)
|
bool JobQueue::isJobRequestExpired(const JobRequest &jobRequest)
|
||||||
{
|
{
|
||||||
const JobRequest::ExpirationReasons expirationReasons = jobRequest.expirationReasons;
|
const JobRequest::ExpirationConditions conditions = jobRequest.expirationConditions;
|
||||||
const UnsavedFiles unsavedFiles = m_documents.unsavedFiles();
|
const UnsavedFiles unsavedFiles = m_documents.unsavedFiles();
|
||||||
using ExpirationReason = JobRequest::ExpirationReason;
|
using Condition = JobRequest::ExpirationCondition;
|
||||||
|
|
||||||
if (expirationReasons.testFlag(ExpirationReason::UnsavedFilesChanged)) {
|
if (conditions.testFlag(Condition::UnsavedFilesChanged)) {
|
||||||
if (jobRequest.unsavedFilesChangeTimePoint != unsavedFiles.lastChangeTimePoint()) {
|
if (jobRequest.unsavedFilesChangeTimePoint != unsavedFiles.lastChangeTimePoint()) {
|
||||||
qCDebug(jobsLog) << "Removing due to outdated unsaved files:" << jobRequest;
|
qCDebug(jobsLog) << "Removing due to outdated unsaved files:" << jobRequest;
|
||||||
return true;
|
return true;
|
||||||
@@ -118,7 +118,7 @@ bool JobQueue::isJobRequestExpired(const JobRequest &jobRequest)
|
|||||||
|
|
||||||
bool projectCheckedAndItExists = false;
|
bool projectCheckedAndItExists = false;
|
||||||
|
|
||||||
if (expirationReasons.testFlag(ExpirationReason::DocumentClosed)) {
|
if (conditions.testFlag(Condition::DocumentClosed)) {
|
||||||
if (!m_documents.hasDocument(jobRequest.filePath, jobRequest.projectPartId)) {
|
if (!m_documents.hasDocument(jobRequest.filePath, jobRequest.projectPartId)) {
|
||||||
qCDebug(jobsLog) << "Removing due to already closed document:" << jobRequest;
|
qCDebug(jobsLog) << "Removing due to already closed document:" << jobRequest;
|
||||||
return true;
|
return true;
|
||||||
@@ -138,7 +138,7 @@ bool JobQueue::isJobRequestExpired(const JobRequest &jobRequest)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expirationReasons.testFlag(ExpirationReason::DocumentRevisionChanged)) {
|
if (conditions.testFlag(Condition::DocumentRevisionChanged)) {
|
||||||
if (document.documentRevision() > jobRequest.documentRevision) {
|
if (document.documentRevision() > jobRequest.documentRevision) {
|
||||||
qCDebug(jobsLog) << "Removing due to changed document revision:" << jobRequest;
|
qCDebug(jobsLog) << "Removing due to changed document revision:" << jobRequest;
|
||||||
return true;
|
return true;
|
||||||
@@ -146,7 +146,7 @@ bool JobQueue::isJobRequestExpired(const JobRequest &jobRequest)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expirationReasons.testFlag(ExpirationReason::ProjectChanged)) {
|
if (conditions.testFlag(Condition::ProjectChanged)) {
|
||||||
if (!projectCheckedAndItExists && !m_projectParts.hasProjectPart(jobRequest.projectPartId)) {
|
if (!projectCheckedAndItExists && !m_projectParts.hasProjectPart(jobRequest.projectPartId)) {
|
||||||
qCDebug(jobsLog) << "Removing due to already closed project:" << jobRequest;
|
qCDebug(jobsLog) << "Removing due to already closed project:" << jobRequest;
|
||||||
return true;
|
return true;
|
||||||
@@ -194,10 +194,10 @@ void JobQueue::cancelJobRequest(const JobRequest &jobRequest)
|
|||||||
m_cancelJobRequest(jobRequest);
|
m_cancelJobRequest(jobRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool passesPreconditions(const JobRequest &request, const Document &document)
|
static bool areRunConditionsMet(const JobRequest &request, const Document &document)
|
||||||
{
|
{
|
||||||
using Condition = JobRequest::Condition;
|
using Condition = JobRequest::RunCondition;
|
||||||
const JobRequest::Conditions conditions = request.conditions;
|
const JobRequest::RunConditions conditions = request.runConditions;
|
||||||
|
|
||||||
if (conditions.testFlag(Condition::DocumentSuspended) && !document.isSuspended()) {
|
if (conditions.testFlag(Condition::DocumentSuspended) && !document.isSuspended()) {
|
||||||
qCDebug(jobsLog) << "Not choosing due to unsuspended document:" << request;
|
qCDebug(jobsLog) << "Not choosing due to unsuspended document:" << request;
|
||||||
@@ -250,7 +250,7 @@ JobRequests JobQueue::takeJobRequestsToRunNow()
|
|||||||
const Document &document = m_documents.document(request.filePath,
|
const Document &document = m_documents.document(request.filePath,
|
||||||
request.projectPartId);
|
request.projectPartId);
|
||||||
|
|
||||||
if (!passesPreconditions(request, document))
|
if (!areRunConditionsMet(request, document))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const Utf8String id = document.translationUnit(request.preferredTranslationUnit).id();
|
const Utf8String id = document.translationUnit(request.preferredTranslationUnit).id();
|
||||||
|
|||||||
@@ -115,30 +115,30 @@ QDebug operator<<(QDebug debug, const JobRequest &jobRequest)
|
|||||||
return debug.space();
|
return debug.space();
|
||||||
}
|
}
|
||||||
|
|
||||||
static JobRequest::ExpirationReasons expirationReasonsForType(JobRequest::Type type)
|
static JobRequest::ExpirationConditions expirationConditionsForType(JobRequest::Type type)
|
||||||
{
|
{
|
||||||
using Type = JobRequest::Type;
|
using Type = JobRequest::Type;
|
||||||
using ExpirationReason = JobRequest::ExpirationReason;
|
using Condition = JobRequest::ExpirationCondition;
|
||||||
using ExpirationReasons = JobRequest::ExpirationReasons;
|
using Conditions = JobRequest::ExpirationConditions;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Type::UpdateDocumentAnnotations:
|
case Type::UpdateDocumentAnnotations:
|
||||||
return ExpirationReasons(ExpirationReason::AnythingChanged);
|
return Conditions(Condition::AnythingChanged);
|
||||||
case Type::RequestReferences:
|
case Type::RequestReferences:
|
||||||
case Type::RequestDocumentAnnotations:
|
case Type::RequestDocumentAnnotations:
|
||||||
case Type::FollowSymbol:
|
case Type::FollowSymbol:
|
||||||
return ExpirationReasons(ExpirationReason::DocumentClosed)
|
return Conditions(Condition::DocumentClosed)
|
||||||
| ExpirationReasons(ExpirationReason::DocumentRevisionChanged);
|
| Conditions(Condition::DocumentRevisionChanged);
|
||||||
default:
|
default:
|
||||||
return ExpirationReason::DocumentClosed;
|
return Condition::DocumentClosed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static JobRequest::Conditions conditionsForType(JobRequest::Type type)
|
static JobRequest::RunConditions conditionsForType(JobRequest::Type type)
|
||||||
{
|
{
|
||||||
using Type = JobRequest::Type;
|
using Type = JobRequest::Type;
|
||||||
using Condition = JobRequest::Condition;
|
using Condition = JobRequest::RunCondition;
|
||||||
using Conditions = JobRequest::Conditions;
|
using Conditions = JobRequest::RunConditions;
|
||||||
|
|
||||||
if (type == Type::SuspendDocument) {
|
if (type == Type::SuspendDocument) {
|
||||||
return Conditions(Condition::DocumentUnsuspended)
|
return Conditions(Condition::DocumentUnsuspended)
|
||||||
@@ -165,8 +165,8 @@ JobRequest::JobRequest(Type type)
|
|||||||
|
|
||||||
id = ++idCounter;
|
id = ++idCounter;
|
||||||
this->type = type;
|
this->type = type;
|
||||||
conditions = conditionsForType(type);
|
runConditions = conditionsForType(type);
|
||||||
expirationReasons = expirationReasonsForType(type);
|
expirationConditions = expirationConditionsForType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
IAsyncJob *JobRequest::createJob() const
|
IAsyncJob *JobRequest::createJob() const
|
||||||
@@ -238,8 +238,8 @@ void JobRequest::cancelJob(ClangCodeModelClientInterface &client) const
|
|||||||
bool JobRequest::operator==(const JobRequest &other) const
|
bool JobRequest::operator==(const JobRequest &other) const
|
||||||
{
|
{
|
||||||
return type == other.type
|
return type == other.type
|
||||||
&& expirationReasons == other.expirationReasons
|
&& expirationConditions == other.expirationConditions
|
||||||
&& conditions == other.conditions
|
&& runConditions == other.runConditions
|
||||||
|
|
||||||
&& filePath == other.filePath
|
&& filePath == other.filePath
|
||||||
&& projectPartId == other.projectPartId
|
&& projectPartId == other.projectPartId
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public:
|
|||||||
ResumeDocument,
|
ResumeDocument,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class Condition {
|
enum class RunCondition {
|
||||||
NoCondition = 1 << 0,
|
NoCondition = 1 << 0,
|
||||||
DocumentVisible = 1 << 1,
|
DocumentVisible = 1 << 1,
|
||||||
DocumentNotVisible = 1 << 2,
|
DocumentNotVisible = 1 << 2,
|
||||||
@@ -72,9 +72,9 @@ public:
|
|||||||
DocumentUnsuspended = 1 << 4,
|
DocumentUnsuspended = 1 << 4,
|
||||||
CurrentDocumentRevision = 1 << 5,
|
CurrentDocumentRevision = 1 << 5,
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(Conditions, Condition)
|
Q_DECLARE_FLAGS(RunConditions, RunCondition)
|
||||||
|
|
||||||
enum class ExpirationReason {
|
enum class ExpirationCondition {
|
||||||
Never = 1 << 0,
|
Never = 1 << 0,
|
||||||
|
|
||||||
DocumentClosed = 1 << 1,
|
DocumentClosed = 1 << 1,
|
||||||
@@ -87,7 +87,7 @@ public:
|
|||||||
| UnsavedFilesChanged
|
| UnsavedFilesChanged
|
||||||
| ProjectChanged,
|
| ProjectChanged,
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(ExpirationReasons, ExpirationReason)
|
Q_DECLARE_FLAGS(ExpirationConditions, ExpirationCondition)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JobRequest(Type type = Type::Invalid);
|
JobRequest(Type type = Type::Invalid);
|
||||||
@@ -100,8 +100,8 @@ public:
|
|||||||
public:
|
public:
|
||||||
quint64 id = 0;
|
quint64 id = 0;
|
||||||
Type type;
|
Type type;
|
||||||
ExpirationReasons expirationReasons;
|
ExpirationConditions expirationConditions;
|
||||||
Conditions conditions;
|
RunConditions runConditions;
|
||||||
|
|
||||||
// General
|
// General
|
||||||
Utf8String filePath;
|
Utf8String filePath;
|
||||||
|
|||||||
Reference in New Issue
Block a user