Browse Source

add vector as parameter

master
Jørgen Lien Sellæg 11 years ago
parent
commit
63d69c6ca3
  1. 7
      juci/notebook.cc
  2. 24
      juci/source.cc
  3. 12
      juci/source.h

7
juci/notebook.cc

@ -393,9 +393,10 @@ void Notebook::Controller::OnBufferChange() {
std::cout << start.get_line_offset() << std::endl; std::cout << start.get_line_offset() << std::endl;
if (word == ".") { if (word == ".") {
// TODO(Forgie) Zalox,Forgie) Remove TEST // TODO(Forgie) Zalox,Forgie) Remove TEST
std::vector<std::string> TEST std::vector<std::string> TEST;
= text_vec_[page]->GetAutoCompleteSuggestions(start.get_line()+1, text_vec_[page]->GetAutoCompleteSuggestions(start.get_line()+1,
start.get_line_offset()+2); start.get_line_offset()+2,
&TEST);
GeneratePopup(TEST); GeneratePopup(TEST);
} }
} }

24
juci/source.cc

@ -132,22 +132,24 @@ ReParse(const std::string &buffer) {
// fired when a line in the buffer is edited // fired when a line in the buffer is edited
void Source::Controller::OnLineEdit() { } void Source::Controller::OnLineEdit() { }
std::vector<std::string> Source::Controller:: void Source::Controller::
GetAutoCompleteSuggestions(int line_number, GetAutoCompleteSuggestions(int line_number,
int column) { int column,
return model().GetAutoCompleteSuggestions(view().get_buffer() std::vector<std::string> *suggestions) {
parsing.lock();
model().GetAutoCompleteSuggestions(view().get_buffer()
->get_text().raw(), ->get_text().raw(),
line_number, line_number,
column); column,
suggestions);
parsing.unlock();
} }
std::vector<std::string> Source::Model:: void Source::Model::
GetAutoCompleteSuggestions(const std::string& buffer, GetAutoCompleteSuggestions(const std::string& buffer,
int line_number, int line_number,
int column) { int column,
std::vector<std::string> *suggestions) {
std::vector<std::string> res;
parsing.lock();
clang::CodeCompleteResults results(&tu_, clang::CodeCompleteResults results(&tu_,
file_path(), file_path(),
buffer, buffer,
@ -159,10 +161,8 @@ GetAutoCompleteSuggestions(const std::string& buffer,
for (auto &stringchunk : c) { for (auto &stringchunk : c) {
ss << stringchunk.chunk(); ss << stringchunk.chunk();
} }
res.emplace_back(ss.str()); suggestions->emplace_back(ss.str());
} }
parsing.unlock();
return res;
} }
// sets the filepath for this mvc // sets the filepath for this mvc

12
juci/source.h

@ -95,10 +95,10 @@ namespace Source {
const string& project_path() const; const string& project_path() const;
// gets the config member // gets the config member
const Config& config() const; const Config& config() const;
std::vector<std::string> void GetAutoCompleteSuggestions(const std::string& buffer,
GetAutoCompleteSuggestions(const std::string& buffer,
int line_number, int line_number,
int column); int column,
std::vector<std::string> *suggestions);
~Model() { } ~Model() { }
int ReParse(const std::string &buffer); int ReParse(const std::string &buffer);
std::vector<Range> ExtractTokens(int, int); std::vector<Range> ExtractTokens(int, int);
@ -125,9 +125,9 @@ namespace Source {
Model& model(); Model& model();
void OnNewEmptyFile(); void OnNewEmptyFile();
void OnOpenFile(const string &filename); void OnOpenFile(const string &filename);
std::vector<std::string> void GetAutoCompleteSuggestions(int line_number,
GetAutoCompleteSuggestions(int line_number, int column,
int column); std::vector<std::string> *suggestions);
Glib::RefPtr<Gtk::TextBuffer> buffer(); Glib::RefPtr<Gtk::TextBuffer> buffer();
private: private:

Loading…
Cancel
Save