Browse Source

Added TranslationUnit::get_cursor(SourceLocation const&), and some minor cleanup of TranslationUnit

merge-requests/37/head
eidheim 9 years ago
parent
commit
7f5c657f52
  1. 8
      src/TranslationUnit.cc
  2. 15
      src/TranslationUnit.h

8
src/TranslationUnit.cc

@ -113,12 +113,16 @@ std::unique_ptr<clangmm::Tokens> clangmm::TranslationUnit::get_tokens(unsigned s
return std::unique_ptr<Tokens>(new Tokens(cx_tu, range)); return std::unique_ptr<Tokens>(new Tokens(cx_tu, range));
} }
clangmm::Cursor clangmm::TranslationUnit::get_cursor(std::string path, unsigned offset) { clangmm::Cursor clangmm::TranslationUnit::get_cursor(const std::string &path, unsigned offset) {
SourceLocation location(cx_tu, path, offset); SourceLocation location(cx_tu, path, offset);
return Cursor(clang_getCursor(cx_tu, location.cx_location)); return Cursor(clang_getCursor(cx_tu, location.cx_location));
} }
clangmm::Cursor clangmm::TranslationUnit::get_cursor(std::string path, unsigned line, unsigned column) { clangmm::Cursor clangmm::TranslationUnit::get_cursor(const std::string &path, unsigned line, unsigned column) {
SourceLocation location(cx_tu, path, line, column); SourceLocation location(cx_tu, path, line, column);
return Cursor(clang_getCursor(cx_tu, location.cx_location)); return Cursor(clang_getCursor(cx_tu, location.cx_location));
} }
clangmm::Cursor clangmm::TranslationUnit::get_cursor(const SourceLocation &location) {
return Cursor(clang_getCursor(cx_tu, location.cx_location));
}

15
src/TranslationUnit.h

@ -14,13 +14,11 @@
namespace clangmm { namespace clangmm {
class TranslationUnit { class TranslationUnit {
public: public:
TranslationUnit(Index &index, TranslationUnit(Index &index, const std::string &file_path,
const std::string &file_path,
const std::vector<std::string> &command_line_args, const std::vector<std::string> &command_line_args,
const std::string &buffer, const std::string &buffer,
unsigned flags=DefaultFlags()); unsigned flags=DefaultFlags());
TranslationUnit(Index &index, TranslationUnit(Index &index, const std::string &file_path,
const std::string &file_path,
const std::vector<std::string> &command_line_args, const std::vector<std::string> &command_line_args,
unsigned flags=DefaultFlags()); unsigned flags=DefaultFlags());
~TranslationUnit(); ~TranslationUnit();
@ -35,17 +33,18 @@ namespace clangmm {
const std::map<std::string, std::string> &buffers, const std::map<std::string, std::string> &buffers,
unsigned flags=DefaultFlags()); unsigned flags=DefaultFlags());
clangmm::CodeCompleteResults get_code_completions(const std::string &buffer, CodeCompleteResults get_code_completions(const std::string &buffer,
unsigned line_number, unsigned column); unsigned line_number, unsigned column);
std::vector<clangmm::Diagnostic> get_diagnostics(); std::vector<Diagnostic> get_diagnostics();
std::unique_ptr<Tokens> get_tokens(unsigned start_offset, unsigned end_offset); std::unique_ptr<Tokens> get_tokens(unsigned start_offset, unsigned end_offset);
std::unique_ptr<Tokens> get_tokens(unsigned start_line, unsigned start_column, std::unique_ptr<Tokens> get_tokens(unsigned start_line, unsigned start_column,
unsigned end_line, unsigned end_column); unsigned end_line, unsigned end_column);
clangmm::Cursor get_cursor(std::string path, unsigned offset); Cursor get_cursor(const std::string &path, unsigned offset);
clangmm::Cursor get_cursor(std::string path, unsigned line, unsigned column); Cursor get_cursor(const std::string &path, unsigned line, unsigned column);
Cursor get_cursor(const SourceLocation &location);
CXTranslationUnit cx_tu; CXTranslationUnit cx_tu;
}; };

Loading…
Cancel
Save