1 /* 2 * This file is licensed under the GNU General Public License, version 3 3 * http://www.gnu.org/licenses/gpl-3.0.html 4 */ 5 6 #ifndef NATIVEPARSERF_H 7 #define NATIVEPARSERF_H 8 9 #include <sdk.h> 10 #ifndef CB_PRECOMP 11 #include <wx/string.h> 12 #include <wx/event.h> 13 14 #include <cbthreadpool.h> 15 #endif 16 #include <map> 17 #include <set> 18 19 #include "jumptracker.h" 20 #include "parserf.h" 21 #include "projectdependencies.h" 22 #include "workspacebrowserf.h" 23 #include "workspaceparserthread.h" 24 25 typedef std::map<wxString,ProjectDependencies*> WSDependencyMap; 26 27 // forward decls 28 class EditorBase; 29 class cbProject; 30 class TokenF; 31 class FortranProject; 32 33 class NativeParserF : public wxEvtHandler 34 { 35 public: 36 NativeParserF(FortranProject* forproj); 37 ~NativeParserF(); 38 39 void AddParser(cbProject* project); 40 void ClearParser(); 41 void RemoveFromParser(cbProject* project); 42 void AddFileToParser(const wxString& projectFilename, const wxString& filename); 43 void RemoveFileFromParser(const wxString& filename); 44 void ReparseFile(const wxString& projectFilename, const wxString& filename); 45 void ReparseProject(cbProject* project); 46 void ParseProject(cbProject* project); 47 void ForceReparseWorkspace(); 48 void OnReparseWorkspaceTimer(wxTimerEvent& event); 49 void UpdateProjectFilesDependency(cbProject* project); 50 ParserF* GetParser(); 51 bool IsFileFortran(const wxString& filename); 52 53 void CreateWorkspaceBrowser(); 54 WorkspaceBrowserF* GetWorkspaceBrowser(); 55 void RemoveWorkspaceBrowser(); 56 void UpdateWorkspaceBrowser(bool selectCurrentSymbol=false); 57 int GetTokenKindImageIdx(TokenF* token); 58 void GetCallTips(const wxString& name, bool onlyUseAssoc, bool onlyPublicNames, wxArrayString& callTips, TokensArrayFlat* result); 59 void GetCallTipsForGenericTypeBoundProc(TokensArrayFlat* result, wxArrayString& callTips, wxArrayInt& idxFuncSub); 60 void GetCallTipsForTypeBoundProc(TokensArrayFlat* result, wxArrayString& callTips); 61 void GetCallTipsForVariable(TokenFlat* token, wxString& callTip); 62 void GetCallTipsForType(TokenFlat* token, wxString& callTip); 63 int CountCommas(const wxString& lineText, int start, bool nesting=true); 64 void CollectInformationForCallTip(int& commasAll, int& commasUntilPos, wxString& argNameUnderCursor, wxString& lastName, bool& isAfterPercent, int& argsPos, TokensArrayFlat* result); 65 void CountCommasInEditor(int& commasAll, int& commasUntilPos, wxString& lastName, wxString& lineText, int& pos); 66 void GetCallTipHighlight(const wxString& calltip, int commasWas, int& start, int& end); 67 void MarkCurrentSymbol(bool selectCurrentSymbol); 68 void RereadOptions(); 69 JumpTracker* GetJumpTracker(); 70 FortranProject* GetFortranProject(); 71 void GenMakefile(); 72 wxArrayString* GetWSFiles(); 73 ArrayOfFortranSourceForm* GetWSFileForms(); 74 wxArrayString* GetWSFileProjFilenames(); 75 wxArrayString* GetADirFiles(); 76 ArrayOfFortranSourceForm* GetADirFileForms(); 77 void GetCurrentBuffer(wxString& buffer, wxString& filename, wxString& projFilename); 78 void ReparseCurrentEditor(); 79 wxArrayString GetProjectSearchDirs(cbProject* project); 80 void SetProjectSearchDirs(cbProject* project, wxArrayString& searchDirs); 81 bool HasFortranFiles(cbProject* project); 82 void DelProjectSearchDirs(cbProject* project); 83 void ForceReparseProjectSearchDirs(); 84 void OnASearchDirsReparseTimer(wxTimerEvent& event); 85 86 protected: 87 private: 88 friend class FortranProject; 89 90 void OnEditorActivated(EditorBase* editor); 91 void OnEditorClose(EditorBase* editor); 92 void OnProjectActivated(cbProject* project); 93 void UpdateWorkspaceFilesDependency(); 94 void ClearWSDependency(); 95 void RemoveProjectFilesDependency(cbProject* project); 96 97 bool IsFileFortran(const wxString& filename, FortranSourceForm& fsForm); 98 //void BreakUpInLines(wxString& str, const wxString& original_str, int chars_per_line); 99 wxString GetLastName(const wxString& line); 100 101 void MakeWSFileList(); 102 void MakeADirFileList(); 103 104 void OnUpdateWorkspaceBrowser(wxCommandEvent& event); 105 void OnUpdateADirTokens(wxCommandEvent& event); 106 void OnUpdateCurrentFileTokens(wxCommandEvent& event); 107 108 void GetDummyVarName(cbEditor* ed, wxString& lastDummyVar); 109 110 ParserF m_Parser; 111 WorkspaceBrowserF* m_pWorkspaceBrowser; 112 bool m_WorkspaceBrowserIsFloating; 113 FortranProject* m_pFortranProject; 114 wxTimer m_WorkspaceReparseTimer; 115 116 WSDependencyMap m_WSDependency; 117 118 JumpTracker m_JumpTracker; 119 120 cbThreadPool m_ThreadPool; 121 122 wxArrayString m_WSFiles; ///< list of workspace filenames 123 ArrayOfFortranSourceForm m_WSFileForms; ///< sorce form of each WS file 124 wxArrayString m_WSFilePFN; ///< to which project depands each WS file 125 126 wxArrayString m_ADirFiles; ///< list of filenames from additional directories 127 ArrayOfFortranSourceForm m_ADirFileForms; ///< sorce form of each additional file 128 wxTimer m_ASearchDirsReparseTimer; 129 130 wxString m_CurrentEditorBuffer; 131 wxString m_CurrentEditorFilename; 132 wxString m_CurrentEditorProjectFN; 133 134 std::map<wxString,wxArrayString> m_ASearchDirs; 135 std::map<wxString,wxArrayString> m_ADirFNameToProjMap; 136 137 DECLARE_EVENT_TABLE(); 138 }; 139 140 #endif // NATIVEPARSERF_H 141 142