Code::Blocks  SVN r11506
parser_base.h
Go to the documentation of this file.
1 #ifndef PARSER_BASE_H
2 #define PARSER_BASE_H
3 
4 
5 #include <wx/arrstr.h>
6 #include <wx/event.h>
7 #include <wx/file.h>
8 #include <wx/filefn.h> // wxPathList
9 #include <wx/imaglist.h>
10 #include <wx/string.h>
11 #include <wx/thread.h>
12 #include <wx/timer.h>
13 #include <wx/treectrl.h>
14 
15 #include "parserthread.h"
16 
17 // no browser related class!
18 
19 typedef std::set<wxString> StringSet;
20 typedef std::list<wxString> StringList;
21 
22 namespace ParserCommon
23 {
25  enum EFileType
26  {
30  };
31 
36  EFileType FileType(const wxString& filename, bool force_refresh = false);
37 }// namespace ParserCommon
38 
41 {
42  bdfFile = 0,
46 };
47 
50 {
56 };
57 
60 {
62  showInheritance(false),
63  expandNS(false),
64  treeMembers(true),
65  displayFilter(bdfFile),
66  sortType(bstKind)
67  {}
68 
73 
79  bool expandNS;
80 
83 
89 
94 };
95 
98 {
100  followLocalIncludes(true),
101  followGlobalIncludes(true),
102  caseSensitive(true),
103  wantPreprocessor(true),
104  useSmartSense(true),
105  whileTyping(true),
106  parseComplexMacros(true),
107  platformCheck(true),
108  storeDocumentation(true)
109  {}
110 
116  bool whileTyping;
120 };
121 
122 // both the CodeCompletion plugin and the cc_test project share this class, this class hold a Token
123 // Tree.
124 class ParserBase : public wxEvtHandler
125 {
126  friend class ParserThread;
127 
128 public:
129  ParserBase();
130  virtual ~ParserBase();
131 
132  virtual void AddBatchParse(cb_unused const StringList& filenames) { ; }
133  virtual void AddParse(cb_unused const wxString& filename) { ; }
134  virtual void AddPredefinedMacros(cb_unused const wxString& defs) { ; }
135  virtual bool UpdateParsingProject(cb_unused cbProject* project) { return false; }
136 
137  virtual bool ParseBuffer(const wxString& buffer, bool isLocal, bool bufferSkipBlocks = false,
138  bool isTemp = false, const wxString& filename = wxEmptyString,
139  int parentIdx = -1, int initLine = 0);
140  virtual bool ParseBufferForFunctions(cb_unused const wxString& buffer) { return false; }
141  virtual bool ParseBufferForNamespaces(cb_unused const wxString& buffer, cb_unused NameSpaceVec& result) { return false; }
142  virtual bool ParseBufferForUsingNamespace(cb_unused const wxString& buffer, cb_unused wxArrayString& result,
143  cb_unused bool bufferSkipBlocks = true) { return false; }
144 
145  virtual bool Reparse(cb_unused const wxString& filename, cb_unused bool isLocal = true); // allow other implementations of derived (dummy) classes
146  virtual bool AddFile(cb_unused const wxString& filename, cb_unused cbProject* project, cb_unused bool isLocal = true) { return false; }
147  virtual bool RemoveFile(cb_unused const wxString& filename) { return false; }
148  virtual bool IsFileParsed(cb_unused const wxString& filename) { return false; }
149 
150  virtual bool Done() { return true; }
151  virtual wxString NotDoneReason() { return wxEmptyString; }
152 
153  virtual TokenTree* GetTokenTree() const; // allow other implementations of derived (dummy) classes
154  TokenTree* GetTempTokenTree() { return m_TempTokenTree; }
155 
156  virtual const wxString GetPredefinedMacros() const { return wxEmptyString; } // allow other implementations of derived (dummy) classes
157 
159  void AddIncludeDir(const wxString& dir);
160  const wxArrayString& GetIncludeDirs() const { return m_IncludeDirs; }
161  wxString GetFullFileName(const wxString& src, const wxString& tgt, bool isGlobal);
166  wxArrayString FindFileInIncludeDirs(const wxString& file, bool firstonly = false);
167 
169  virtual void ReadOptions() {}
171  virtual void WriteOptions() {}
172 
173  // make them virtual, so Parser class can overwrite then!
174  virtual ParserOptions& Options() { return m_Options; }
175  virtual BrowserOptions& ClassBrowserOptions() { return m_BrowserOptions; }
176 
177  size_t FindTokensInFile(const wxString& filename, TokenIdxSet& result, short int kindMask);
178 
179 private:
180  virtual bool ParseFile(const wxString& filename, bool isGlobal, bool locked = false);
181  wxString FindFirstFileInIncludeDirs(const wxString& file);
182 
183 protected:
188 
194 
197 
200 
201 
202 
203 private:
206 
213 };
214 
215 #endif
virtual BrowserOptions & ClassBrowserOptions()
Definition: parser_base.h:175
BrowserSortType
specify the sort order of the symbol tree nodes
Definition: parser_base.h:49
A parser threaded task, which can be assigned to the thread task pool, and run there.
Definition: parserthread.h:138
bool caseSensitive
parse XXX.h in directive #include <XXX.h>
Definition: parser_base.h:113
bool whileTyping
use real AI(scope sequence match) or not(plain text match)
Definition: parser_base.h:116
Setting of the Parser, some of them will be passed down to ParserThreadOptions.
Definition: parser_base.h:97
virtual void WriteOptions()
write Parse options to configure file
Definition: parser_base.h:171
bool useSmartSense
handle preprocessor directive in Tokenizer class
Definition: parser_base.h:115
bool followLocalIncludes
Definition: parser_base.h:111
ParserOptions m_Options
options for how the parser try to parse files
Definition: parser_base.h:196
virtual bool AddFile(cb_unused const wxString &filename, cb_unused cbProject *project, cb_unused bool isLocal=true)
Definition: parser_base.h:146
bool storeDocumentation
this will check for the platform of the project/target when adding include folders to the parser ...
Definition: parser_base.h:119
virtual bool ParseBufferForFunctions(cb_unused const wxString &buffer)
Definition: parser_base.h:140
a container class to hold all the Tokens getting from parsing stage
Definition: tokentree.h:37
bool showInheritance
whether the base class or derive class information is shown as a child node default: false ...
Definition: parser_base.h:72
BrowserOptions m_BrowserOptions
options for how the symbol browser was shown
Definition: parser_base.h:199
alphabetical
Definition: parser_base.h:52
bool platformCheck
this will let the Tokenizer to recursive expand macros
Definition: parser_base.h:118
std::list< wxString > StringList
Definition: parser_base.h:20
virtual bool RemoveFile(cb_unused const wxString &filename)
Definition: parser_base.h:147
virtual ParserOptions & Options()
Definition: parser_base.h:174
TokenTree * GetTempTokenTree()
Definition: parser_base.h:154
EFileType FileType(const wxString &filename, bool force_refresh=false)
return a file type, which can be either header files or implementation files or other files ...
bool expandNS
whether a namespaces node is auto-expand auto-expand means the child of the namespace is automaticall...
Definition: parser_base.h:79
const wxArrayString & GetIncludeDirs() const
Definition: parser_base.h:160
std::vector< NameSpace > NameSpaceVec
Definition: parserthread.h:34
Represents a Code::Blocks project.
Definition: cbproject.h:96
display symbols of current project
Definition: parser_base.h:44
TokenTree * m_TempTokenTree
a temp Token tree hold some temporary tokens, e.g.
Definition: parser_base.h:193
std::set< int, std::less< int > > TokenIdxSet
Definition: token.h:16
display symbols of current file
Definition: parser_base.h:43
virtual void AddPredefinedMacros(cb_unused const wxString &defs)
Definition: parser_base.h:134
virtual void AddBatchParse(cb_unused const StringList &filenames)
Definition: parser_base.h:132
EFileType
the enum type of the file type
Definition: parser_base.h:25
Options for the symbol browser, this specify how the symbol browser will shown.
Definition: parser_base.h:59
virtual bool IsFileParsed(cb_unused const wxString &filename)
Definition: parser_base.h:148
TokenTree * m_TokenTree
each Parser class contains a TokenTree object which used to record tokens per project this tree will ...
Definition: parser_base.h:187
virtual wxString NotDoneReason()
Definition: parser_base.h:151
bool wantPreprocessor
case sensitive in MarkItemsByAI
Definition: parser_base.h:114
wxString wxEmptyString
bool followGlobalIncludes
parse XXX.h in directive #include "XXX.h"
Definition: parser_base.h:112
wxArrayString m_IncludeDirs
the include directories can be either three kinds below: 1, compiler&#39;s default search paths...
Definition: parser_base.h:212
virtual bool ParseBufferForNamespaces(cb_unused const wxString &buffer, cb_unused NameSpaceVec &result)
Definition: parser_base.h:141
code like order
Definition: parser_base.h:55
BrowserDisplayFilter displayFilter
token filter option
Definition: parser_base.h:88
virtual bool Done()
Definition: parser_base.h:150
BrowserDisplayFilter
specify the scope of the shown symbols
Definition: parser_base.h:40
bool treeMembers
show members in the bottom tree.
Definition: parser_base.h:82
virtual bool ParseBufferForUsingNamespace(cb_unused const wxString &buffer, cb_unused wxArrayString &result, cb_unused bool bufferSkipBlocks=true)
Definition: parser_base.h:142
bool parseComplexMacros
reparse the active editor while editing
Definition: parser_base.h:117
BrowserSortType sortType
token sort option in the tree default: bstKind
Definition: parser_base.h:93
virtual const wxString GetPredefinedMacros() const
Definition: parser_base.h:156
public, protected, private
Definition: parser_base.h:54
display symbols of current workspace
Definition: parser_base.h:45
virtual void ReadOptions()
read Parser options from configure file
Definition: parser_base.h:169
SearchTree< wxString > m_GlobalIncludes
wxString -> wxString map
Definition: parser_base.h:205
class, function, macros
Definition: parser_base.h:53
virtual bool UpdateParsingProject(cb_unused cbProject *project)
Definition: parser_base.h:135
virtual void AddParse(cb_unused const wxString &filename)
Definition: parser_base.h:133
ParserThreadOptions m_Options
parser options, see the ParserThreadOptions structure
Definition: parserthread.h:438
std::set< wxString > StringSet
Definition: parser_base.h:19