diff --git a/juci/CMakeLists.txt b/juci/CMakeLists.txt index ea09d3c..5995127 100644 --- a/juci/CMakeLists.txt +++ b/juci/CMakeLists.txt @@ -52,7 +52,7 @@ endif() #Boost_INCLUDE_DIRS - Boost include directories #Boost_LIBRARY_DIRS - Link directories for Boost libraries #Boost_LIBRARIES - Boost component libraries to be linked -find_package(Boost 1.5 REQUIRED COMPONENTS python) +find_package(Boost 1.5 REQUIRED COMPONENTS python timer system) #If boost is not found if(${Boost_FOUND}) diff --git a/juci/source.cc b/juci/source.cc index ed2e263..b315dc0 100644 --- a/juci/source.cc +++ b/juci/source.cc @@ -3,6 +3,7 @@ #include "sourcefile.h" #include #include +#include ////////////// //// View //// @@ -185,9 +186,12 @@ void Source::Controller::OnOpenFile(const string &filepath) { int start_offset = buffer()->begin().get_offset(); int end_offset = buffer()->end().get_offset(); + + std::string project_path = filepath.substr(0, filepath.find_last_of('/')); + clang::CompilationDatabase db(project_path); clang::CompileCommands commands(filepath, &db); std::vector cmds = commands.get_commands(); @@ -198,7 +202,10 @@ void Source::Controller::OnOpenFile(const string &filepath) { arguments.emplace_back(lol[a].c_str()); } } + boost::timer::auto_cpu_timer timer; clang::TranslationUnit tu(true, filepath, arguments); + timer.~auto_cpu_timer(); + boost::timer::auto_cpu_timer timer2; clang::SourceLocation start(&tu, filepath, start_offset); clang::SourceLocation end(&tu, filepath, end_offset); clang::SourceRange range(&start, &end); @@ -212,6 +219,8 @@ void Source::Controller::OnOpenFile(const string &filepath) { loc.get_location_info(NULL, &line, &column, NULL); } + timer2.~auto_cpu_timer(); + // std::cout << t.elapsed().user << std::endl; // model().SetSourceLocations(tu.getSourceLocations()); // view().OnOpenFile(model().getSourceLocations(), model().theme()); } diff --git a/juci/source.h b/juci/source.h index e5ba70d..726f9a3 100644 --- a/juci/source.h +++ b/juci/source.h @@ -24,6 +24,24 @@ namespace Source { std::unordered_map typetable_; string background_; }; // class Theme + /* + class BufferLocation { + BufferLocation(const BufferLocation &location); + BufferLocation(int, int); + int line_number() { return line_number_; } + int column_number() { return column_offset_; } + private: + int line_number_; + int column_offset_; + }; + + class BufferRange { + BufferRange(const BufferLocation &start, const BufferLocation &end) : + start_(start), end_(end) { } + private: + BufferLocation start_; + BufferLocation end_; + };*/ class View : public Gtk::TextView { public: