1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qt Creator. 7 ** 8 ** Commercial License Usage 9 ** Licensees holding valid commercial Qt licenses may use this file in 10 ** accordance with the commercial license agreement provided with the 11 ** Software or, alternatively, in accordance with the terms contained in 12 ** a written agreement between you and The Qt Company. For licensing terms 13 ** and conditions see https://www.qt.io/terms-conditions. For further 14 ** information use the contact form at https://www.qt.io/contact-us. 15 ** 16 ** GNU General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU 18 ** General Public License version 3 as published by the Free Software 19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 20 ** included in the packaging of this file. Please review the following 21 ** information to ensure the GNU General Public License requirements will 22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 23 ** 24 ****************************************************************************/ 25 26 #pragma once 27 28 #include "clangbackend_global.h" 29 #include "clangclock.h" 30 31 #include <utf8string.h> 32 #include <utf8stringvector.h> 33 34 #include <QFlags> 35 #include <QDebug> 36 #include <QVector> 37 38 #include <functional> 39 40 namespace ClangBackEnd { 41 42 class ClangCodeModelClientInterface; 43 class Document; 44 class IAsyncJob; 45 46 class JobRequest 47 { 48 public: 49 enum class Type { 50 Invalid, 51 52 UpdateAnnotations, 53 UpdateExtraAnnotations, 54 55 ParseSupportiveTranslationUnit, 56 57 RequestCompletions, 58 RequestAnnotations, 59 RequestReferences, 60 RequestFollowSymbol, 61 RequestToolTip, 62 63 SuspendDocument, 64 ResumeDocument, 65 }; 66 67 enum class RunCondition { 68 NoCondition = 1 << 0, 69 DocumentVisible = 1 << 1, 70 DocumentNotVisible = 1 << 2, 71 DocumentSuspended = 1 << 3, 72 DocumentUnsuspended = 1 << 4, 73 DocumentParsed = 1 << 5, 74 CurrentDocumentRevision = 1 << 6, 75 }; 76 Q_DECLARE_FLAGS(RunConditions, RunCondition) 77 78 enum class ExpirationCondition { 79 Never = 1 << 0, 80 81 DocumentClosed = 1 << 1, 82 DocumentRevisionChanged = 1 << 2, // Only effective if DocumentIsClosed is also set 83 UnsavedFilesChanged = 1 << 3, 84 85 AnythingChanged = DocumentClosed 86 | DocumentRevisionChanged 87 | UnsavedFilesChanged, 88 }; 89 Q_DECLARE_FLAGS(ExpirationConditions, ExpirationCondition) 90 91 public: 92 JobRequest(Type type = Type::Invalid); 93 94 IAsyncJob *createJob() const; 95 void cancelJob(ClangCodeModelClientInterface &client) const; 96 bool isTakeOverable() const; 97 98 bool operator==(const JobRequest &other) const; 99 100 public: 101 quint64 id = 0; 102 Type type; 103 ExpirationConditions expirationConditions; 104 RunConditions runConditions; 105 106 // General 107 Utf8String filePath; 108 TimePoint unsavedFilesChangeTimePoint; 109 uint documentRevision = 0; 110 PreferredTranslationUnit preferredTranslationUnit = PreferredTranslationUnit::RecentlyParsed; 111 112 // Specific to some jobs 113 quint32 line = 0; 114 quint32 column = 0; 115 qint32 funcNameStartLine = -1; 116 qint32 funcNameStartColumn = -1; 117 quint64 ticketNumber = 0; 118 Utf8String textCodecName; 119 bool localReferences = false; 120 }; 121 122 using JobRequests = QVector<JobRequest>; 123 124 QDebug operator<<(QDebug debug, const JobRequest &jobRequest); 125 std::ostream &operator<<(std::ostream &os, JobRequest::Type type); 126 std::ostream &operator<<(std::ostream &os, PreferredTranslationUnit preferredTranslationUnit); 127 128 129 } // namespace ClangBackEnd 130