Code::Blocks  SVN r11506
doxygen_parser.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3  * http://www.gnu.org/licenses/gpl-3.0.html
4  */
5 
6 #ifndef DOXYGENPARSER_H
7 #define DOXYGENPARSER_H
8 
9 #include <set>
10 
11 #if wxUSE_POPUPWIN
12  #include <wx/popupwin.h>
13 #else
14  #include <wx/frame.h>
15 #endif // wxUSE_POPUPWIN
16 
17 #include "parser/token.h" // TokenIdxSet
18 
19 class CodeCompletion;
20 class TokenTree;
21 
22 class cbEditor;
23 class ConfigManager;
24 
25 class wxHtmlLinkEvent;
26 
27 namespace Doxygen
28 {
30  {
32 
36  SA, SEE,
37 
38  // structural keywords:
43 
44  FN,
45  VAR,
46  DEF,
47 
48  // some other keywords:
51 
53 
55 
56  KEYWORDS_COUNT // Always at end
57  };
58 
60  {
66  };
67 
68 
70  {
71  static const wxString Keywords[];
72  static const int KwCount;
74 
75  DoxygenParser();
76 
77  int FindNextKeyword(const wxString& doc);
78  int GetArgument(const wxString& doc, int range, wxString& output);
79  int GetPosition() const;
80  void ReplaceInDoc(wxString& doc, size_t start, size_t count, const wxString& str);
81  void ReplaceCurrentKeyword(wxString& doc, const wxString& str);
82 
83  protected:
84  int CheckKeyword(const wxString& doc);
85  int GetParagraphArgument(const wxString& doc, wxString& output);
86  void GetWordArgument(const wxString& doc, wxString& output);
87  void GetBlockArgument(const wxString& doc, wxString& output);
88  int GetLineArgument(const wxString& doc, wxString& output);
89  bool IsKeywordBegin(const wxString& doc) const;
90  bool IsOneOf(wxChar c, const wxChar* chars) const;
91 
92  protected:
93  bool IsEnd(const wxString& doc) const;
94  int GetEndLine(const wxString& doc) const;
96  bool SkipDecorations(const wxString& doc);
98  bool HandleNewLine(const wxString& doc, wxString& output, const wxString& replaceWith = NewLineReplacment);
99 
100  int m_FoundKw; // index to Keywors array
101  int m_Pos; // index to doc
102  };
103 
104 }//namespace Doxygen
105 
106 
108 {
109 
110 public:
111  enum Command
112  {
114  cmdDisplayToken, // args: token index
115  cmdSearch, // args: token name
116  cmdSearchAll, // args: token name
117  cmdOpenDecl, // args: token index
118  cmdOpenImpl, // args: token index
119  cmdClose // args: -----
120  };
121 
122  //helper functions:
123  static wxString DoxygenToHTML(const wxString& doc);
124  static wxString ConvertTypeToAnchor(wxString fullType);
125  static wxString ConvertArgsToAnchors(wxString args);
127  static wxString ExtractTypeAndName(wxString type, wxString* outName = 0);
128  static wxString CommandToAnchor(Command cmd, const wxString& name, const wxString* args = 0);
129  static wxString CommandToAnchorInt(Command cmd, const wxString& name, int arg0);
130  static Command HrefToCommand(const wxString& href, wxString& args);
131 
132  static const wxChar separatorTag;
133  static const wxString commandTag;
134 
137 
138  void OnAttach();
139  void OnRelease();
140  wxString GenerateHTML(int tokenIdx, TokenTree* tree);
141  wxString GenerateHTML(const TokenIdxSet& tokensIdx, TokenTree* tree);
142  void RereadOptions(ConfigManager* cfg);
143  void WriteOptions(ConfigManager* cfg);
144 
145  bool IsEnabled() { return m_Enabled; }
146  void SetEnabled(bool enabled) { m_Enabled = enabled; }
147 
148 protected:
149  void SaveTokenIdx();
150 public:
151  wxString OnDocumentationLink(wxHtmlLinkEvent& event, bool& dismissPopup);
152 
153  /*Members:*/
154 protected:
158  int m_CurrentTokenIdx, m_LastTokenIdx;
159  // User options
160  bool m_Enabled;
161 };
162 
163 #endif //DOXYGENPARSER_H
void ReplaceInDoc(wxString &doc, size_t start, size_t count, const wxString &str)
int GetEndLine(const wxString &doc) const
a container class to hold all the Tokens getting from parsing stage
Definition: tokentree.h:37
int GetLineArgument(const wxString &doc, wxString &output)
void SetEnabled(bool enabled)
bool IsKeywordBegin(const wxString &doc) const
static const wxString NewLineReplacment
static const int KwCount
static const wxString Keywords[]
void GetWordArgument(const wxString &doc, wxString &output)
Code completion plugin has those features: show tool-tip when the mouse hover over the variables/func...
wxUSE_UNICODE_dependent wxChar
static const wxString commandTag
static const wxChar separatorTag
CodeCompletion * m_CC
Pointer to CodeComplete object.
bool IsEnd(const wxString &doc) const
std::set< int, std::less< int > > TokenIdxSet
Definition: token.h:16
#define arg0
Definition: sqvm.cpp:456
bool IsOneOf(wxChar c, const wxChar *chars) const
A file editor.
Definition: cbeditor.h:43
int FindNextKeyword(const wxString &doc)
void GetBlockArgument(const wxString &doc, wxString &output)
void ReplaceCurrentKeyword(wxString &doc, const wxString &str)
bool HandleNewLine(const wxString &doc, wxString &output, const wxString &replaceWith=NewLineReplacment)
int CheckKeyword(const wxString &doc)
int GetArgument(const wxString &doc, int range, wxString &output)
bool SkipDecorations(const wxString &doc)
int GetParagraphArgument(const wxString &doc, wxString &output)