File indexing completed on 2024-05-19 05:42:27
0001 // ct_lvtqtw_parse_codebase.h -*-C++-*- 0002 0003 /* 0004 // Copyright 2023 Codethink Ltd <codethink@codethink.co.uk> 0005 // SPDX-License-Identifier: Apache-2.0 0006 // 0007 // Licensed under the Apache License, Version 2.0 (the "License"); 0008 // you may not use this file except in compliance with the License. 0009 // You may obtain a copy of the License at 0010 // 0011 // http://www.apache.org/licenses/LICENSE-2.0 0012 // 0013 // Unless required by applicable law or agreed to in writing, software 0014 // distributed under the License is distributed on an "AS IS" BASIS, 0015 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0016 // See the License for the specific language governing permissions and 0017 // limitations under the License. 0018 */ 0019 0020 #ifndef INCLUDED_LVTQTW_PARSECODEBASE 0021 #define INCLUDED_LVTQTW_PARSECODEBASE 0022 0023 #include <lvtqtw_export.h> 0024 0025 #include <ct_lvtplg_pluginmanager.h> 0026 0027 #include <QDialog> 0028 #include <QProcess> 0029 #include <QString> 0030 0031 #include <filesystem> 0032 #include <memory> 0033 #include <string> 0034 #include <vector> 0035 0036 namespace Ui { 0037 class ParseCodebaseDialog; 0038 } 0039 0040 namespace Codethink::lvtqtw { 0041 0042 class LVTQTW_EXPORT ParseCodebaseDialog : public QDialog { 0043 Q_OBJECT 0044 public: 0045 enum class State { 0046 Idle, // before or after any parse has run 0047 Killed, // we are in the process of cancelling a parse 0048 RunPhysicalOnly, // we are doing a physical only parse 0049 RunAllPhysical, // we are doing the physical stage of a full parse 0050 RunAllLogical, // we are doing the logical stage of a full parse 0051 }; 0052 0053 explicit ParseCodebaseDialog(QWidget *parent = nullptr); 0054 ~ParseCodebaseDialog() override; 0055 0056 Q_SIGNAL void parseStarted(Codethink::lvtqtw::ParseCodebaseDialog::State currentState); 0057 Q_SIGNAL void 0058 parseStep(Codethink::lvtqtw::ParseCodebaseDialog::State currentState, int currentProgress, int maxProgress); 0059 Q_SIGNAL void parseFinished(Codethink::lvtqtw::ParseCodebaseDialog::State state); 0060 Q_SIGNAL void readyForDbUpdate(); 0061 0062 void setCodebasePath(const QString& path); 0063 [[nodiscard]] QString codebasePath() const; 0064 [[nodiscard]] std::filesystem::path buildPath() const; 0065 [[nodiscard]] std::filesystem::path sourcePath() const; 0066 0067 Q_SLOT void updateDatabase(); 0068 0069 void setPluginManager(lvtplg::PluginManager& pluginManager); 0070 0071 protected: 0072 void showEvent(QShowEvent *event) override; 0073 0074 void initParse(); 0075 // Sets up everything needed for the parse. 0076 0077 void runCMakeAndInitParse_Step2(const std::string& compileCommandsJson, 0078 const std::vector<std::string>& ignoreList, 0079 const std::vector<std::filesystem::path>& nonLakosianDirs); 0080 // Runs CMake to generate compile_commands.json file before starting parse step 2 0081 0082 void initParse_Step2(const std::string& compileCommandsJson, 0083 const std::vector<std::string>& ignoreList, 0084 const std::vector<std::filesystem::path>& nonLakosianDirs); 0085 // Actually starts the parsing process. 0086 0087 void endParse(); 0088 void validate(); 0089 0090 Q_SLOT void processingFileNotification(const QString& path); 0091 Q_SLOT void aboutToCallClangNotification(int size); 0092 Q_SLOT void receivedMessage(const QString& message, long threadId); 0093 Q_SLOT void saveOutput(); 0094 // creates a zip file containing all the information from the system 0095 // plus all the texts from the thread-tabs. 0096 0097 Q_SLOT void searchForBuildFolder(); 0098 // called when one clicks on the `search` button for the build folder. 0099 0100 Q_SLOT void searchForNonLakosianDir(); 0101 // called when one clicks on the 'search' button for the non-lakosian dirs 0102 0103 Q_SLOT void searchForSourceFolder(); 0104 // called when one clicks on the `search` button for the source folder. 0105 0106 void selectThirdPartyPkgMapping(); 0107 0108 [[nodiscard]] static QString getNonLakosianDirSettings(const QString& buildDir); 0109 // Get the non-lakosian dir information from QSettings 0110 0111 static void setNonLakosianDirSettings(const QString& buildDir, const QString& nonLakosianDirs); 0112 // Sore this information in QSettings 0113 0114 void removeParseMessageTabs(); 0115 0116 void reset(); 0117 0118 std::vector<std::string> ignoredItemsAsStdVec(); 0119 std::vector<std::filesystem::path> nonLakosianDirsAsStdVec(); 0120 0121 struct Private; 0122 std::unique_ptr<Private> d; 0123 std::unique_ptr<Ui::ParseCodebaseDialog> ui; 0124 }; 0125 0126 } // namespace Codethink::lvtqtw 0127 0128 #endif