Example #1
0
bool JobQueue::isJobRequestOutDated(const JobRequest &jobRequest) const
{
    const JobRequest::Requirements requirements = jobRequest.requirements;
    const UnsavedFiles unsavedFiles = m_translationUnits.unsavedFiles();

    if (requirements.testFlag(JobRequest::CurrentUnsavedFiles)) {
        if (jobRequest.unsavedFilesChangeTimePoint != unsavedFiles.lastChangeTimePoint()) {
            qCDebug(jobsLog) << "Removing due to outdated unsaved files:" << jobRequest;
            return true;
        }
    }

    bool projectCheckedAndItExists = false;

    if (requirements.testFlag(JobRequest::DocumentValid)) {
        if (!m_translationUnits.hasTranslationUnit(jobRequest.filePath, jobRequest.projectPartId)) {
            qCDebug(jobsLog) << "Removing due to already closed document:" << jobRequest;
            return true;
        }

        if (!m_projectParts.hasProjectPart(jobRequest.projectPartId)) {
            qCDebug(jobsLog) << "Removing due to already closed project:" << jobRequest;
            return true;
        }
        projectCheckedAndItExists = true;

        const TranslationUnit translationUnit
                = m_translationUnits.translationUnit(jobRequest.filePath, jobRequest.projectPartId);
        if (!translationUnit.isIntact()) {
            qCDebug(jobsLog) << "Removing due to not intact translation unit:" << jobRequest;
            return true;
        }

        if (requirements.testFlag(JobRequest::CurrentDocumentRevision)) {
            if (translationUnit.documentRevision() != jobRequest.documentRevision) {
                qCDebug(jobsLog) << "Removing due to changed document revision:" << jobRequest;
                return true;
            }
        }
    }

    if (requirements.testFlag(JobRequest::CurrentProject)) {
        if (!projectCheckedAndItExists && !m_projectParts.hasProjectPart(jobRequest.projectPartId)) {
            qCDebug(jobsLog) << "Removing due to already closed project:" << jobRequest;
            return true;
        }

        const ProjectPart &project = m_projectParts.project(jobRequest.projectPartId);
        if (project.lastChangeTimePoint() != jobRequest.projectChangeTimePoint) {
            qCDebug(jobsLog) << "Removing due to outdated project:" << jobRequest;
            return true;
        }
    }

    return false;
}
Example #2
0
bool JobQueue::isJobRequestExpired(const JobRequest &jobRequest, QString &expirationReason)
{
    const JobRequest::ExpirationConditions conditions = jobRequest.expirationConditions;
    const UnsavedFiles unsavedFiles = m_documents.unsavedFiles();
    using Condition = JobRequest::ExpirationCondition;

    if (conditions.testFlag(Condition::UnsavedFilesChanged)) {
        if (jobRequest.unsavedFilesChangeTimePoint != unsavedFiles.lastChangeTimePoint()) {
            expirationReason = "outdated unsaved files";
            return true;
        }
    }

    if (conditions.testFlag(Condition::DocumentClosed)) {
        if (!m_documents.hasDocument(jobRequest.filePath)) {
            expirationReason = "document already closed";
            return true;
        }

        const Document document
                = m_documents.document(jobRequest.filePath);
        if (!document.isIntact()) {
            expirationReason = "document not intact";
            return true;
        }

        if (conditions.testFlag(Condition::DocumentRevisionChanged)) {
            if (document.documentRevision() > jobRequest.documentRevision) {
                expirationReason = "changed document revision";
                return true;
            }
        }
    }

    return false;
}