diff options
Diffstat (limited to 'include/clang/Rewrite/Core/Rewriter.h')
-rw-r--r-- | include/clang/Rewrite/Core/Rewriter.h | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/include/clang/Rewrite/Core/Rewriter.h b/include/clang/Rewrite/Core/Rewriter.h index 107968a9fb43..84c5ac3d72ee 100644 --- a/include/clang/Rewrite/Core/Rewriter.h +++ b/include/clang/Rewrite/Core/Rewriter.h @@ -1,9 +1,8 @@ //===- Rewriter.h - Code rewriting interface --------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -85,7 +84,16 @@ public: /// in different buffers, this returns an empty string. /// /// Note that this method is not particularly efficient. - std::string getRewrittenText(SourceRange Range) const; + std::string getRewrittenText(CharSourceRange Range) const; + + /// getRewrittenText - Return the rewritten form of the text in the specified + /// range. If the start or end of the range was unrewritable or if they are + /// in different buffers, this returns an empty string. + /// + /// Note that this method is not particularly efficient. + std::string getRewrittenText(SourceRange Range) const { + return getRewrittenText(CharSourceRange::getTokenRange(Range)); + } /// InsertText - Insert the specified string at the specified location in the /// original buffer. This method returns true (and does nothing) if the input @@ -142,6 +150,13 @@ public: /// ReplaceText - This method replaces a range of characters in the input /// buffer with a new string. This is effectively a combined "remove/insert" /// operation. + bool ReplaceText(CharSourceRange range, StringRef NewStr) { + return ReplaceText(range.getBegin(), getRangeSize(range), NewStr); + } + + /// ReplaceText - This method replaces a range of characters in the input + /// buffer with a new string. This is effectively a combined "remove/insert" + /// operation. bool ReplaceText(SourceRange range, StringRef NewStr) { return ReplaceText(range.getBegin(), getRangeSize(range), NewStr); } |