Browse Source

Merge pull request #21 from eidheim/master

Most notably, added Fix-its to diagnostics.
merge-requests/37/head v0.9.3
Ole Christian Eidheim 10 years ago
parent
commit
f1f784dd02
  1. 4
      README.md
  2. 7
      src/Diagnostic.cc
  3. 9
      src/Diagnostic.h

4
README.md

@ -1,8 +1,10 @@
# libclangmm - An easy to use C++-wrapper for libclang #
# libclangmm - an easy to use C++-wrapper for libclang #
## About ##
Provides C++ bindings and class structure to the [libclang](http://www.llvm.org) C library.
Developed for [juCi++](https://github.com/cppit/jucipp) - a lightweight platform independent C++-IDE.
## Dependencies ##
* libclang

7
src/Diagnostic.cc

@ -14,6 +14,13 @@ clang::Diagnostic::Diagnostic(CXTranslationUnit& cx_tu, CXDiagnostic& cx_diagnos
clang::Tokens tokens(cx_tu, SourceRange(start_location, start_location));
if(tokens.size()==1)
offsets={start_offset, tokens.begin()->offsets.second};
unsigned num_fix_its=clang_getDiagnosticNumFixIts(cx_diagnostic);
for(unsigned c=0;c<num_fix_its;c++) {
CXSourceRange fix_it_range;
auto source=clang::to_string(clang_getDiagnosticFixIt(cx_diagnostic, c, &fix_it_range));
fix_its.emplace_back(source, clang::SourceRange(fix_it_range).get_offsets());
}
}
const std::string clang::Diagnostic::get_severity_spelling(unsigned severity) {

9
src/Diagnostic.h

@ -10,6 +10,14 @@ namespace clang {
friend class TranslationUnit;
Diagnostic(CXTranslationUnit& cx_tu, CXDiagnostic& cx_diagnostic);
public:
class FixIt {
public:
FixIt(const std::string &source, const std::pair<clang::Offset, clang::Offset> &offsets):
source(source), offsets(offsets) {}
std::string source;
std::pair<clang::Offset, clang::Offset> offsets;
};
static const std::string get_severity_spelling(unsigned severity);
unsigned severity;
@ -17,6 +25,7 @@ namespace clang {
std::string spelling;
std::string path;
std::pair<clang::Offset, clang::Offset> offsets;
std::vector<FixIt> fix_its;
};
}

Loading…
Cancel
Save