Browse Source

Language protocol: Go to Method: methods are now sorted by offset

merge-requests/398/head
eidheim 7 years ago
parent
commit
aea7fb4668
  1. 15
      src/source.h
  2. 3
      src/source_language_protocol.cc

15
src/source.h

@ -27,12 +27,15 @@ namespace Source {
class Offset {
public:
Offset() = default;
Offset(unsigned line, unsigned index, boost::filesystem::path file_path_ = "") : line(line), index(index), file_path(std::move(file_path_)) {}
operator bool() { return !file_path.empty(); }
bool operator==(const Offset &o) { return (line == o.line && index == o.index); }
unsigned line;
unsigned index;
Offset(unsigned line, unsigned index, boost::filesystem::path file_path_ = {}) : line(line), index(index), file_path(std::move(file_path_)) {}
operator bool() const { return !file_path.empty(); }
bool operator<(const Offset &rhs) const {
return file_path < rhs.file_path || (file_path == rhs.file_path && (line < rhs.line || (line == rhs.line && index < rhs.index)));
}
bool operator==(const Offset &rhs) const { return (file_path == rhs.file_path && line == rhs.line && index == rhs.index); }
unsigned line = 0;
unsigned index = 0;
boost::filesystem::path file_path;
};

3
src/source_language_protocol.cc

@ -881,6 +881,9 @@ void Source::LanguageProtocolView::setup_navigation_and_refactoring() {
});
result_processed.get_future().get();
std::sort(methods.begin(), methods.end(), [](const std::pair<Offset, std::string> &a, const std::pair<Offset, std::string> &b) {
return a.first < b.first;
});
return methods;
};
}

Loading…
Cancel
Save