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
|
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2008 by Eran Ifrah
// file name : parse_thread.h
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifndef CODELITE_PARSE_THREAD_H
#define CODELITE_PARSE_THREAD_H
#include "entry.h"
#include "singleton.h"
#include <map>
#include <vector>
#include <memory>
#include <wx/stopwatch.h>
#include "worker_thread.h"
#include "procutils.h"
#include "tag_tree.h"
#include "istorage.h"
#include "codelite_exports.h"
class ITagsStorage;
/**
* @class ParseRequest
* @author eran
* @date 10/04/09
* @file parse_thread.h
* @brief a class representing a parsing request
*/
class WXDLLIMPEXP_CL ParseRequest : public ThreadRequest
{
wxString _file;
wxString _dbfile;
wxString _tags;
int _type;
public:
wxEvtHandler* _evtHandler;
std::vector<std::string> _workspaceFiles;
bool _quickRetag;
int _uid;
public:
enum {
PR_FILESAVED,
PR_PARSEINCLUDES,
PR_PARSE_AND_STORE,
PR_DELETE_TAGS_OF_FILES,
PR_PARSE_FILE_NO_INCLUDES,
PR_PARSE_INCLUDE_STATEMENTS,
PR_SUGGEST_HIGHLIGHT_WORDS,
};
public:
// ctor/dtor
ParseRequest(wxEvtHandler *handler) : _type (PR_FILESAVED), _evtHandler(handler), _quickRetag(false), _uid(-1) {}
virtual ~ParseRequest() ;
// accessors
void setFile (const wxString &file );
void setDbFile(const wxString &dbfile );
void setTags (const wxString &tags );
//Getters
const wxString& getDbfile() const {
return _dbfile;
}
const wxString& getFile() const {
return _file;
}
const wxString& getTags() const {
return _tags;
}
void setType(int _type) {
this->_type = _type;
}
int getType() const {
return _type;
}
// copy ctor
ParseRequest(const ParseRequest& rhs) ;
// assignment operator
ParseRequest &operator=(const ParseRequest& rhs);
};
/**
* @class ParseThread
* @author eran
* @date 10/04/09
* @file parse_thread.h
* @brief
*/
class WXDLLIMPEXP_CL ParseThread : public WorkerThread
{
friend class ParseThreadST;
wxStopWatch m_watch;
wxArrayString m_searchPaths;
wxArrayString m_excludePaths;
bool m_crawlerEnabled;
public:
void SetCrawlerEnabeld (bool b );
void SetSearchPaths (const wxArrayString &paths, const wxArrayString &exlucdePaths);
void GetSearchPaths (wxArrayString &paths, wxArrayString &excludePaths);
bool IsCrawlerEnabled ();
private:
/**
* Default constructor.
*/
ParseThread();
/**
* Destructor.
*/
virtual ~ParseThread();
void DoStoreTags (const wxString &tags, const wxString &filename, int &count, ITagsStoragePtr db);
TagTreePtr DoTreeFromTags(const wxString &tags, int &count);
void DoNotifyReady(wxEvtHandler* caller, int requestType);
private:
/**
* Process request from the editor.
* \param request the request to process
*/
void ProcessRequest(ThreadRequest *request);
/**
* @brief parse include files and retrieve a list of all
* include files that should be tagged and inserted into
* the external database
* @param filename
*/
void ParseIncludeFiles(ParseRequest *req, const wxString &filename, ITagsStoragePtr db);
void ProcessSimple (ParseRequest *req);
void ProcessIncludes (ParseRequest *req);
void ProcessParseAndStore (ParseRequest *req);
void ProcessDeleteTagsOfFiles (ParseRequest *req);
void ProcessSimpleNoIncludes (ParseRequest *req);
void ProcessIncludeStatements (ParseRequest *req);
void ProcessColourRequest (ParseRequest *req);
void GetFileListToParse(const wxString &filename, wxArrayString &arrFiles);
void ParseAndStoreFiles(ParseRequest *req, const wxArrayString &arrFiles, int initalCount, ITagsStoragePtr db);
void FindIncludedFiles(ParseRequest *req, std::set<wxString> *newSet);
};
class WXDLLIMPEXP_CL ParseThreadST
{
public:
static void Free();
static ParseThread* Get();
};
extern WXDLLIMPEXP_CL const wxEventType wxEVT_PARSE_THREAD_MESSAGE;
extern WXDLLIMPEXP_CL const wxEventType wxEVT_PARSE_THREAD_SCAN_INCLUDES_DONE;
extern WXDLLIMPEXP_CL const wxEventType wxEVT_PARSE_THREAD_CLEAR_TAGS_CACHE;
extern WXDLLIMPEXP_CL const wxEventType wxEVT_PARSE_THREAD_RETAGGING_PROGRESS;
extern WXDLLIMPEXP_CL const wxEventType wxEVT_PARSE_THREAD_RETAGGING_COMPLETED;
extern WXDLLIMPEXP_CL const wxEventType wxEVT_PARSE_INCLUDE_STATEMENTS_DONE;
extern WXDLLIMPEXP_CL const wxEventType wxEVT_PARSE_THREAD_READY;
extern WXDLLIMPEXP_CL const wxEventType wxEVT_PARSE_THREAD_SUGGEST_COLOUR_TOKENS;
#endif // CODELITE_PARSE_THREAD_H
|