1 //===--- RefactoringAction.h - Clang refactoring library ------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_H
11 #define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_H
13 #include "clang/Basic/LLVM.h"
14 #include "clang/Tooling/Refactoring/RefactoringActionRules.h"
20 /// A refactoring action is a class that defines a set of related refactoring
21 /// action rules. These rules get grouped under a common umbrella - a single
22 /// clang-refactor subcommand.
24 /// A subclass of \c RefactoringAction is responsible for creating the set of
25 /// grouped refactoring action rules that represent one refactoring operation.
26 /// Although the rules in one action may have a number of different
27 /// implementations, they should strive to produce a similar result. It should
28 /// be easy for users to identify which refactoring action produced the result
29 /// regardless of which refactoring action rule was used.
31 /// The distinction between actions and rules enables the creation of action
32 /// that uses very different rules, for example:
33 /// - local vs global: a refactoring operation like
34 /// "add missing switch cases" can be applied to one switch when it's
35 /// selected in an editor, or to all switches in a project when an enum
36 /// constant is added to an enum.
37 /// - tool vs editor: some refactoring operation can be initiated in the
38 /// editor when a declaration is selected, or in a tool when the name of
39 /// the declaration is passed using a command-line argument.
40 class RefactoringAction {
42 virtual ~RefactoringAction() {}
44 /// Returns the name of the subcommand that's used by clang-refactor for this
46 virtual StringRef getCommand() const = 0;
48 virtual StringRef getDescription() const = 0;
50 RefactoringActionRules createActiveActionRules();
53 /// Returns a set of refactoring actions rules that are defined by this
55 virtual RefactoringActionRules createActionRules() const = 0;
58 /// Returns the list of all the available refactoring actions.
59 std::vector<std::unique_ptr<RefactoringAction>> createRefactoringActions();
61 } // end namespace tooling
62 } // end namespace clang
64 #endif // LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_H