File: clFileSystemWorkspace.hpp

package info (click to toggle)
codelite 17.0.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 136,204 kB
  • sloc: cpp: 491,547; ansic: 280,393; php: 10,259; sh: 8,930; lisp: 7,664; vhdl: 6,518; python: 6,020; lex: 4,920; yacc: 3,123; perl: 2,385; javascript: 1,715; cs: 1,193; xml: 1,110; makefile: 804; cobol: 741; sql: 709; ruby: 620; f90: 566; ada: 534; asm: 464; fortran: 350; objc: 289; tcl: 258; java: 157; erlang: 61; pascal: 51; ml: 49; awk: 44; haskell: 36
file content (202 lines) | stat: -rw-r--r-- 6,945 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#ifndef CLFILESYSTEMWORKSPACE_HPP
#define CLFILESYSTEMWORKSPACE_HPP

#include "IWorkspace.h"
#include "asyncprocess.h"
#include "clBacktickCache.hpp"
#include "clConsoleBase.h"
#include "clDebuggerTerminal.h"
#include "clFileCache.hpp"
#include "clFileSystemEvent.h"
#include "clFileSystemWorkspaceConfig.hpp"
#include "clRemoteBuilder.hpp"
#include "clShellHelper.hpp"
#include "cl_command_event.h"
#include "codelite_exports.h"
#include "compiler.h"
#include "macros.h"

#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <wx/arrstr.h>

class clFileSystemWorkspaceView;

class WXDLLIMPEXP_SDK clFileSystemWorkspace : public IWorkspace
{
    clFileCache m_files;
    wxFileName m_filename;
    bool m_isLoaded = false;
    bool m_showWelcomePage = false;
    bool m_dummy = true;
    IProcess* m_buildProcess = nullptr;
    clFileSystemWorkspaceSettings m_settings;
    clFileSystemWorkspaceView* m_view = nullptr;
    bool m_initialized = false;
    std::unordered_map<int, wxString> m_buildTargetMenuIdToName;
    clRemoteBuilder::Ptr_t m_remoteBuilder;
    clDebuggerTerminalPOSIX m_debuggerTerminal;
    int m_execPID = wxNOT_FOUND;
    clBacktickCache::ptr_t m_backtickCache;
    clShellHelper m_shell_helper;

protected:
    void CacheFiles(bool force = false);
    wxString CompileFlagsAsString(const wxArrayString& arr) const;
    wxString GetTargetCommand(const wxString& target) const;
    void DoPrintBuildMessage(const wxString& message);
    clEnvList_t GetEnvList();
    CompilerPtr GetCompiler();

    //===--------------------------
    // Event handlers
    //===--------------------------
    void OnExecProcessTerminated(clProcessEvent& event);
    void OnBuildStarting(clBuildEvent& event);
    void OnBuildEnded(clBuildEvent& event);
    void OnIsBuildInProgress(clBuildEvent& event);
    void OnStopBuild(clBuildEvent& event);
    void OnExecute(clExecuteEvent& event);
    void OnStopExecute(clExecuteEvent& event);
    void OnIsProgramRunning(clExecuteEvent& event);
    void OnNewWorkspace(clCommandEvent& event);
    void OnOpenWorkspace(clCommandEvent& event);
    void OnCloseWorkspace(clCommandEvent& event);
    void OnAllEditorsClosed(wxCommandEvent& event);
    void OnScanCompleted(clFileSystemEvent& event);
    void OnParseWorkspace(wxCommandEvent& event);
    void OnBuildProcessTerminated(clProcessEvent& event);
    void OnBuildProcessOutput(clProcessEvent& event);
    void OnSaveSession(clCommandEvent& event);
    void OnQuickDebugDlgShowing(clDebugEvent& event);
    void OnQuickDebugDlgDismissed(clDebugEvent& event);
    void OnCustomTargetMenu(clContextMenuEvent& event);
    void OnMenuCustomTarget(wxCommandEvent& event);
    void OnFileSaved(clCommandEvent& event);
    void OnSourceControlPulled(clSourceControlEvent& event);
    void OnDebug(clDebugEvent& event);
    void OnFileSystemUpdated(clFileSystemEvent& event);
    void OnReloadWorkspace(clCommandEvent& event);

protected:
    bool Load(const wxFileName& file);
    void DoOpen();
    void DoClose();
    void DoClear();
    void DoCreate(const wxString& name, const wxString& path, bool loadIfExists);
    void RestoreSession();
    void DoBuild(const wxString& target);
    void TriggerQuickParse();
    clFileSystemWorkspaceConfig::Ptr_t GetConfig() const;

public:
    ///===--------------------------
    /// IWorkspace interface
    ///===--------------------------
    wxString GetActiveProjectName() const override;
    wxString GetFileName() const override;
    wxString GetDir() const override;
    wxString GetFilesMask() const override;
    void GetProjectFiles(const wxString& projectName, wxArrayString& files) const override;
    wxString GetProjectFromFile(const wxFileName& filename) const override;
    void GetWorkspaceFiles(wxArrayString& files) const override;
    wxArrayString GetWorkspaceProjects() const override;
    bool IsBuildSupported() const override;
    bool IsProjectSupported() const override;
    wxFileName GetProjectFileName(const wxString& projectName) const override;
    void SetProjectActive(const wxString& project) override;
    wxString GetDebuggerName() const override;
    clEnvList_t GetEnvironment() const override;

    /**
     * @brief return the executable to run + args + working directory
     * this method also expands all macros/env variables
     */
    void GetExecutable(wxString& exe, wxString& args, wxString& wd);

    virtual wxString GetExcludeFolders() const;
    clFileSystemWorkspace(bool dummy);
    virtual ~clFileSystemWorkspace();

    static clFileSystemWorkspace& Get();

    /**
     * @brief open a workspace file. return true if the `filepath` is a valid
     * File System Workspace and the open succeeded
     */
    bool OpenWorkspace(const wxString& filepath);

    /**
     * @brief close the workspace. Return false if the a File System Workspace
     * was not already opened
     */
    bool CloseWorkspace();

    ///===--------------------------
    /// Specific API
    ///===--------------------------
    clFileSystemWorkspaceView* GetView() { return m_view; }

    /**
     * @brief return the backticks cache used by this workspace
     */
    clBacktickCache::ptr_t GetBackticksCache() { return m_backtickCache; }

    /**
     * @brief create an empty workspace at a given folder
     * @param folder
     */
    void New(const wxString& folder, const wxString& name = wxEmptyString);

    /**
     * @brief close the workspace
     */
    void Close();

    /**
     * @brief save the workspace settings
     */
    void Save(bool parse);

    /**
     * @brief parse the workspace
     */
    void Parse(bool fullParse);

    /**
     * @brief is this workspace opened?
     */
    bool IsOpen() const { return m_isLoaded; }

    const std::vector<wxFileName>& GetFiles() const { return m_files.GetFiles(); }

    wxString GetName() const override { return m_filename.GetName(); }
    void SetName(const wxString& name) { m_settings.SetName(name); }

    const clFileSystemWorkspaceSettings& GetSettings() const { return m_settings; }
    clFileSystemWorkspaceSettings& GetSettings() { return m_settings; }

    /**
     * @brief initialise the workspace (Create GUI etc)
     * This function does nothing if the workspace was already initialised
     */
    void Initialise();

    /**
     * @brief call this to update the workspace once a file system changes.
     * this method will re-cache the files + parse the workspace
     * Note that this method does NOT update the UI in anyways.
     */
    void FileSystemUpdated();

    /**
     * @brief create compile_flags.txt for the selected configuration
     * and fire generation event
     */
    void CreateCompileFlagsFile();
};

wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_SDK, wxEVT_FS_SCAN_COMPLETED, clFileSystemEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_SDK, wxEVT_FS_NEW_WORKSPACE_FILE_CREATED, clFileSystemEvent);
#endif // CLFILESYSTEMWORKSPACE_HPP