File indexing completed on 2024-05-05 04:39:25

0001 /*
0002     SPDX-FileCopyrightText: 2020 Milian Wolff <mail@milianw.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QJsonObject>
0010 #include <QDateTime>
0011 
0012 class QString;
0013 
0014 #include <cmakecommonexport.h>
0015 
0016 struct CMakeProjectData;
0017 
0018 namespace KDevelop
0019 {
0020 class Path;
0021 }
0022 
0023 /// see: https://cmake.org/cmake/help/latest/manual/cmake-file-api.7.html
0024 namespace CMake {
0025 namespace FileApi {
0026 /**
0027  * @returns true when the given @p cmakeExecutable supports the cmake-file-api, false otherwise
0028  */
0029 KDEVCMAKECOMMON_EXPORT bool supported(const QString &cmakeExecutable);
0030 
0031 /**
0032  * Write the KDevelop-specific query file into the given @p buildDirectory.
0033  *
0034  * See also: https://cmake.org/cmake/help/latest/manual/cmake-file-api.7.html#v1-client-stateful-query-files
0035  */
0036 KDEVCMAKECOMMON_EXPORT void writeClientQueryFile(const QString &buildDirectory);
0037 
0038 struct ReplyIndex {
0039     QDateTime queryLastModified;
0040     QJsonObject data;
0041 
0042     bool isValid() const
0043     {
0044         return !data.isEmpty();
0045     }
0046     bool isOutdated() const
0047     {
0048         return !queryLastModified.isValid();
0049     }
0050     void markOutdated()
0051     {
0052         queryLastModified = {};
0053     }
0054 };
0055 
0056 /**
0057  * Read and parse latest available reply index file that corresponds to our query in @p buildDirectory.
0058  *
0059  * See also: https://cmake.org/cmake/help/latest/manual/cmake-file-api.7.html#v1-reply-index-file
0060  */
0061 KDEVCMAKECOMMON_EXPORT ReplyIndex findReplyIndexFile(const QString& buildDirectory);
0062 
0063 /**
0064  * Read and parse the code model referenced by the given @p replyIndex
0065  *
0066  * See also: https://cmake.org/cmake/help/latest/manual/cmake-file-api.7.html#id11
0067  */
0068 KDEVCMAKECOMMON_EXPORT CMakeProjectData parseReplyIndexFile(const ReplyIndex& replyIndex,
0069                                                             const KDevelop::Path& sourceDirectory,
0070                                                             const KDevelop::Path& buildDirectory);
0071 }
0072 }