Rewrite.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*===-- clang-c/Rewrite.h - C CXRewriter --------------------------*- C -*-===*\
  2. |* *|
  3. |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
  4. |* Exceptions. *|
  5. |* See https://llvm.org/LICENSE.txt for license information. *|
  6. |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
  7. |* *|
  8. |*===----------------------------------------------------------------------===*/
  9. #ifndef LLVM_CLANG_C_REWRITE_H
  10. #define LLVM_CLANG_C_REWRITE_H
  11. #include "clang-c/CXString.h"
  12. #include "clang-c/ExternC.h"
  13. #include "clang-c/Index.h"
  14. #include "clang-c/Platform.h"
  15. LLVM_CLANG_C_EXTERN_C_BEGIN
  16. typedef void *CXRewriter;
  17. /**
  18. * Create CXRewriter.
  19. */
  20. CINDEX_LINKAGE CXRewriter clang_CXRewriter_create(CXTranslationUnit TU);
  21. /**
  22. * Insert the specified string at the specified location in the original buffer.
  23. */
  24. CINDEX_LINKAGE void clang_CXRewriter_insertTextBefore(CXRewriter Rew, CXSourceLocation Loc,
  25. const char *Insert);
  26. /**
  27. * Replace the specified range of characters in the input with the specified
  28. * replacement.
  29. */
  30. CINDEX_LINKAGE void clang_CXRewriter_replaceText(CXRewriter Rew, CXSourceRange ToBeReplaced,
  31. const char *Replacement);
  32. /**
  33. * Remove the specified range.
  34. */
  35. CINDEX_LINKAGE void clang_CXRewriter_removeText(CXRewriter Rew, CXSourceRange ToBeRemoved);
  36. /**
  37. * Save all changed files to disk.
  38. * Returns 1 if any files were not saved successfully, returns 0 otherwise.
  39. */
  40. CINDEX_LINKAGE int clang_CXRewriter_overwriteChangedFiles(CXRewriter Rew);
  41. /**
  42. * Write out rewritten version of the main file to stdout.
  43. */
  44. CINDEX_LINKAGE void clang_CXRewriter_writeMainFileToStdOut(CXRewriter Rew);
  45. /**
  46. * Free the given CXRewriter.
  47. */
  48. CINDEX_LINKAGE void clang_CXRewriter_dispose(CXRewriter Rew);
  49. LLVM_CLANG_C_EXTERN_C_END
  50. #endif