void ClangCodeCompletion::OnBuildStarting(clBuildEvent& e) { e.Skip(); CHECK_CLANG_ENABLED_RET(); // Determine the compilation database CompilationDatabase cdb; cdb.Open(); cdb.Close(); // Set the compilation database environment variable ::wxSetEnv(wxT("CL_COMPILATION_DB"), cdb.GetFileName().GetFullPath()); // If this is NOT a custom project, set the CXX and CC environment wxString project = e.GetProjectName(); wxString config = e.GetConfigurationName(); BuildConfigPtr bldConf = WorkspaceST::Get()->GetProjBuildConf(project, config); if( bldConf && !bldConf->IsCustomBuild()) { wxString cxx = bldConf->GetCompiler()->GetTool(wxT("CXX")); wxString cc = bldConf->GetCompiler()->GetTool(wxT("CC")); cxx.Prepend(wxT("codelitegcc ")); cc.Prepend(wxT("codelitegcc ")); ::wxSetEnv("CXX", cxx); ::wxSetEnv("CC" , cc); } }
void ClangCodeCompletion::OnFileLoaded(wxCommandEvent& e) { e.Skip(); CHECK_CLANG_ENABLED_RET(); if(TagsManagerST::Get()->GetCtagsOptions().GetClangCachePolicy() == TagsOptionsData::CLANG_CACHE_ON_FILE_LOAD) { CL_DEBUG(wxT("ClangCodeCompletion::OnFileLoaded() START")); if(m_clang.IsBusy() || m_allEditorsAreClosing) { CL_DEBUG(wxT("ClangCodeCompletion::OnFileLoaded() ENDED")); return; } if(e.GetClientData()) { IEditor *editor = (IEditor*)e.GetClientData(); // sanity if(editor->GetProjectName().IsEmpty() || editor->GetFileName().GetFullName().IsEmpty()) return; if(!TagsManagerST::Get()->IsValidCtagsFile(editor->GetFileName())) return; m_clang.SetContext(CTX_CachePCH); m_clang.CodeCompletion(editor); } CL_DEBUG(wxT("ClangCodeCompletion::OnFileLoaded() ENDED")); } }
void ClangCodeCompletion::OnBuildEnded(clBuildEvent& e) { e.Skip(); CHECK_CLANG_ENABLED_RET(); // Clear environment variables previously set by this class ::wxUnsetEnv("CL_COMPILATION_DB"); ::wxUnsetEnv("CXX"); ::wxUnsetEnv("CC"); // Clear the TU cache ClearCache(); }
void ClangCodeCompletion::OnFileSaved(wxCommandEvent& e) { e.Skip(); CHECK_CLANG_ENABLED_RET(); if( TagsManagerST::Get()->GetCtagsOptions().GetFlags() & ::CC_DISABLE_AUTO_PARSING) { CL_DEBUG(wxT("ClangCodeCompletion::OnFileSaved: Auto-parsing of saved files is disabled")); return; } // Incase a file has been saved, we need to reparse its translation unit wxFileName fn( e.GetString() ); if(!TagsManagerST::Get()->IsValidCtagsFile(fn)) return; m_clang.ReparseFile( fn.GetFullPath() ); }
void ClangCodeCompletion::OnBuildEnded(clBuildEvent& e) { e.Skip(); CHECK_CLANG_ENABLED_RET(); // Clear environment variables previously set by this class ::wxUnsetEnv(wxT("CL_COMPILATION_DB")); ::wxUnsetEnv(wxT("CXX")); ::wxUnsetEnv(wxT("CC")); // Create a worker thread (detached thread) that // will initialize the database now that the compilation is ended CompilationDatabase db; ClangCompilationDbThread* thr = new ClangCompilationDbThread( db.GetFileName().GetFullPath() ); thr->Start(); // Clear the TU cache ClearCache(); }
void ClangCodeCompletion::CancelCodeComplete() { CHECK_CLANG_ENABLED_RET(); DoCleanUp(); }