diff options
Diffstat (limited to 'clang/include')
| -rw-r--r-- | clang/include/clang/Format/Format.h | 22 | ||||
| -rw-r--r-- | clang/include/clang/Tooling/Core/Replacement.h | 7 |
2 files changed, 29 insertions, 0 deletions
diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index b32fc3adbd0..f0636ac3841 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -731,6 +731,28 @@ tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code, StringRef FileName, unsigned *Cursor = nullptr); +/// \brief Returns the replacements corresponding to applying and formatting +/// \p Replaces. +tooling::Replacements formatReplacements(StringRef Code, + const tooling::Replacements &Replaces, + const FormatStyle &Style); + +/// \brief In addition to applying all replacements in \p Replaces to \p Code, +/// this function also reformats the changed code after applying replacements. +/// +/// \pre Replacements must be for the same file and conflict-free. +/// +/// Replacement applications happen independently of the success of +/// other applications. +/// +/// \returns the changed code with all replacements applied and formatted, if +/// successful. An empty string otherwise. +/// +/// See also "include/clang/Tooling/Core/Replacements.h". +std::string applyAllReplacementsAndFormat(StringRef Code, + const tooling::Replacements &Replaces, + const FormatStyle &Style); + /// \brief Reformats the given \p Ranges in the file \p ID. /// /// Each range is extended on either end to its next bigger logic unit, i.e. diff --git a/clang/include/clang/Tooling/Core/Replacement.h b/clang/include/clang/Tooling/Core/Replacement.h index 37389ac9156..4ef7184961f 100644 --- a/clang/include/clang/Tooling/Core/Replacement.h +++ b/clang/include/clang/Tooling/Core/Replacement.h @@ -220,6 +220,13 @@ bool applyAllReplacements(const std::vector<Replacement> &Replaces, /// replacements cannot be applied, this returns an empty \c string. std::string applyAllReplacements(StringRef Code, const Replacements &Replaces); +/// \brief Calculate the ranges in a single file that are affected by the +/// Replacements. +/// +/// \pre Replacements must be for the same file. +std::vector<tooling::Range> +calculateChangedRangesInFile(const tooling::Replacements &Replaces); + /// \brief Merges two sets of replacements with the second set referring to the /// code after applying the first set. Within both 'First' and 'Second', /// replacements must not overlap. |

