diff options
| author | Alex Lorenz <arphaman@gmail.com> | 2017-08-28 11:12:05 +0000 |
|---|---|---|
| committer | Alex Lorenz <arphaman@gmail.com> | 2017-08-28 11:12:05 +0000 |
| commit | 1586fa70a631c15374d4aeb22af241ea8672d0d6 (patch) | |
| tree | 2eaf07e54f9029f04cf7548f40ba370bedd5ee1c /clang/lib/Tooling | |
| parent | 0db84863d0da9e9854e07f1d149b12636fc911fa (diff) | |
| download | bcm5719-llvm-1586fa70a631c15374d4aeb22af241ea8672d0d6.tar.gz bcm5719-llvm-1586fa70a631c15374d4aeb22af241ea8672d0d6.zip | |
[refactor] initial support for refactoring action rules
This patch implements the initial support for refactoring action rules. The
first rule that's supported is a "source change" rule that returns a set of
atomic changes. This patch is based on the ideas presented in my RFC:
http://lists.llvm.org/pipermail/cfe-dev/2017-July/054831.html
The following pieces from the RFC are added by this patch:
- `createRefactoringRule` (known as `apply` in the RFC)
- `requiredSelection` refactoring action rule requirement.
- `selection::SourceSelectionRange` selection constraint.
Differential Revision: https://reviews.llvm.org/D36075
llvm-svn: 311884
Diffstat (limited to 'clang/lib/Tooling')
| -rw-r--r-- | clang/lib/Tooling/Refactoring/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | clang/lib/Tooling/Refactoring/SourceSelectionConstraints.cpp | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/clang/lib/Tooling/Refactoring/CMakeLists.txt b/clang/lib/Tooling/Refactoring/CMakeLists.txt index 55e46ee3473..b0b66f16f6d 100644 --- a/clang/lib/Tooling/Refactoring/CMakeLists.txt +++ b/clang/lib/Tooling/Refactoring/CMakeLists.txt @@ -8,6 +8,7 @@ add_clang_library(clangToolingRefactor Rename/USRFinder.cpp Rename/USRFindingAction.cpp Rename/USRLocFinder.cpp + SourceSelectionConstraints.cpp LINK_LIBS clangAST diff --git a/clang/lib/Tooling/Refactoring/SourceSelectionConstraints.cpp b/clang/lib/Tooling/Refactoring/SourceSelectionConstraints.cpp new file mode 100644 index 00000000000..5fbe2946a9d --- /dev/null +++ b/clang/lib/Tooling/Refactoring/SourceSelectionConstraints.cpp @@ -0,0 +1,23 @@ +//===--- SourceSelectionConstraints.cpp - Evaluate selection constraints --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "clang/Tooling/Refactoring/SourceSelectionConstraints.h" +#include "clang/Tooling/Refactoring/RefactoringRuleContext.h" + +using namespace clang; +using namespace tooling; +using namespace selection; + +Optional<SourceSelectionRange> +SourceSelectionRange::evaluate(RefactoringRuleContext &Context) { + SourceRange R = Context.getSelectionRange(); + if (R.isInvalid()) + return None; + return SourceSelectionRange(Context.getSources(), R); +} |

