| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | #ifndef LLVM_CLANG_TOOLING_REPLACEMENTSYAML_H |
| 16 | #define LLVM_CLANG_TOOLING_REPLACEMENTSYAML_H |
| 17 | |
| 18 | #include "clang/Tooling/Refactoring.h" |
| 19 | #include "llvm/Support/YAMLTraits.h" |
| 20 | #include <string> |
| 21 | |
| 22 | LLVM_YAML_IS_SEQUENCE_VECTOR(clang::tooling::Replacement) |
| 23 | |
| 24 | namespace llvm { |
| 25 | namespace yaml { |
| 26 | |
| 27 | |
| 28 | |
| 29 | template <> struct MappingTraits<clang::tooling::Replacement> { |
| 30 | |
| 31 | |
| 32 | struct NormalizedReplacement { |
| 33 | NormalizedReplacement(const IO &) |
| 34 | : FilePath(""), Offset(0), Length(0), ReplacementText("") {} |
| 35 | |
| 36 | NormalizedReplacement(const IO &, const clang::tooling::Replacement &R) |
| 37 | : FilePath(R.getFilePath()), Offset(R.getOffset()), |
| 38 | Length(R.getLength()), ReplacementText(R.getReplacementText()) {} |
| 39 | |
| 40 | clang::tooling::Replacement denormalize(const IO &) { |
| 41 | return clang::tooling::Replacement(FilePath, Offset, Length, |
| 42 | ReplacementText); |
| 43 | } |
| 44 | |
| 45 | std::string FilePath; |
| 46 | unsigned int Offset; |
| 47 | unsigned int Length; |
| 48 | std::string ReplacementText; |
| 49 | }; |
| 50 | |
| 51 | static void mapping(IO &Io, clang::tooling::Replacement &R) { |
| 52 | MappingNormalization<NormalizedReplacement, clang::tooling::Replacement> |
| 53 | Keys(Io, R); |
| 54 | Io.mapRequired("FilePath", Keys->FilePath); |
| 55 | Io.mapRequired("Offset", Keys->Offset); |
| 56 | Io.mapRequired("Length", Keys->Length); |
| 57 | Io.mapRequired("ReplacementText", Keys->ReplacementText); |
| 58 | } |
| 59 | }; |
| 60 | |
| 61 | |
| 62 | |
| 63 | template <> struct MappingTraits<clang::tooling::TranslationUnitReplacements> { |
| 64 | static void mapping(IO &Io, |
| 65 | clang::tooling::TranslationUnitReplacements &Doc) { |
| 66 | Io.mapRequired("MainSourceFile", Doc.MainSourceFile); |
| 67 | Io.mapRequired("Replacements", Doc.Replacements); |
| 68 | } |
| 69 | }; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | #endif |
| 74 | |