summaryrefslogtreecommitdiffstats
path: root/include/clang/Tooling/Refactoring/RefactoringActionRule.h
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2017-09-01 09:16:02 +0000
committerAlex Lorenz <arphaman@gmail.com>2017-09-01 09:16:02 +0000
commit9b13d907c509a53fd938dcc777bb7dd097cea4c0 (patch)
treefa26f812bf08c329c859f8df1e5b62695b96daf3 /include/clang/Tooling/Refactoring/RefactoringActionRule.h
parent618f522e3f279b7d9e106d91610586996451700b (diff)
[refactor] Use a RefactoringResultConsumer instead of tagged refactoring
rule classes This commit changes the way that the refactoring results are produced. Instead of using different `RefactoringActionRule` subclasses for each result type, Clang now use a single `RefactoringResultConsumer`. This was suggested by Manuel in https://reviews.llvm.org/D36075. Differential Revision: https://reviews.llvm.org/D37291 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@312316 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Tooling/Refactoring/RefactoringActionRule.h')
-rw-r--r--include/clang/Tooling/Refactoring/RefactoringActionRule.h39
1 files changed, 6 insertions, 33 deletions
diff --git a/include/clang/Tooling/Refactoring/RefactoringActionRule.h b/include/clang/Tooling/Refactoring/RefactoringActionRule.h
index 0887a6177b..dbf6574b25 100644
--- a/include/clang/Tooling/Refactoring/RefactoringActionRule.h
+++ b/include/clang/Tooling/Refactoring/RefactoringActionRule.h
@@ -11,52 +11,25 @@
#define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_H
#include "clang/Basic/LLVM.h"
-#include "clang/Tooling/Refactoring/AtomicChange.h"
-#include "llvm/Support/Error.h"
#include <vector>
namespace clang {
namespace tooling {
+class RefactoringResultConsumer;
class RefactoringRuleContext;
/// A common refactoring action rule interface.
class RefactoringActionRule {
public:
- enum RuleKind { SourceChangeRefactoringRuleKind };
-
- RuleKind getRuleKind() const { return Kind; }
-
virtual ~RefactoringActionRule() {}
-protected:
- RefactoringActionRule(RuleKind Kind) : Kind(Kind) {}
-
-private:
- RuleKind Kind;
-};
-
-/// A type of refactoring action rule that produces source replacements in the
-/// form of atomic changes.
-///
-/// This action rule is typically used for local refactorings that replace
-/// source in a single AST unit.
-class SourceChangeRefactoringRule : public RefactoringActionRule {
-public:
- SourceChangeRefactoringRule()
- : RefactoringActionRule(SourceChangeRefactoringRuleKind) {}
-
- /// Initiates and performs a refactoring action that modifies the sources.
+ /// Initiates and performs a specific refactoring action.
///
- /// The specific rule must return an llvm::Error with a DiagnosticError
- /// payload or None when the refactoring action couldn't be initiated/
- /// performed, or \c AtomicChanges when the action was performed successfully.
- virtual Expected<Optional<AtomicChanges>>
- createSourceReplacements(RefactoringRuleContext &Context) = 0;
-
- static bool classof(const RefactoringActionRule *Rule) {
- return Rule->getRuleKind() == SourceChangeRefactoringRuleKind;
- }
+ /// The specific rule will invoke an appropriate \c handle method on a
+ /// consumer to propagate the result of the refactoring action.
+ virtual void invoke(RefactoringResultConsumer &Consumer,
+ RefactoringRuleContext &Context) = 0;
};
/// A set of refactoring action rules that should have unique initiation