|
|
|||
File indexing completed on 2026-05-10 08:37:11
0001 //===--- RefactoringAction.h - Clang refactoring library ------------------===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 0009 #ifndef LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGACTION_H 0010 #define LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGACTION_H 0011 0012 #include "clang/Basic/LLVM.h" 0013 #include "clang/Tooling/Refactoring/RefactoringActionRules.h" 0014 #include <vector> 0015 0016 namespace clang { 0017 namespace tooling { 0018 0019 /// A refactoring action is a class that defines a set of related refactoring 0020 /// action rules. These rules get grouped under a common umbrella - a single 0021 /// clang-refactor subcommand. 0022 /// 0023 /// A subclass of \c RefactoringAction is responsible for creating the set of 0024 /// grouped refactoring action rules that represent one refactoring operation. 0025 /// Although the rules in one action may have a number of different 0026 /// implementations, they should strive to produce a similar result. It should 0027 /// be easy for users to identify which refactoring action produced the result 0028 /// regardless of which refactoring action rule was used. 0029 /// 0030 /// The distinction between actions and rules enables the creation of action 0031 /// that uses very different rules, for example: 0032 /// - local vs global: a refactoring operation like 0033 /// "add missing switch cases" can be applied to one switch when it's 0034 /// selected in an editor, or to all switches in a project when an enum 0035 /// constant is added to an enum. 0036 /// - tool vs editor: some refactoring operation can be initiated in the 0037 /// editor when a declaration is selected, or in a tool when the name of 0038 /// the declaration is passed using a command-line argument. 0039 class RefactoringAction { 0040 public: 0041 virtual ~RefactoringAction() {} 0042 0043 /// Returns the name of the subcommand that's used by clang-refactor for this 0044 /// action. 0045 virtual StringRef getCommand() const = 0; 0046 0047 virtual StringRef getDescription() const = 0; 0048 0049 RefactoringActionRules createActiveActionRules(); 0050 0051 protected: 0052 /// Returns a set of refactoring actions rules that are defined by this 0053 /// action. 0054 virtual RefactoringActionRules createActionRules() const = 0; 0055 }; 0056 0057 /// Returns the list of all the available refactoring actions. 0058 std::vector<std::unique_ptr<RefactoringAction>> createRefactoringActions(); 0059 0060 } // end namespace tooling 0061 } // end namespace clang 0062 0063 #endif // LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGACTION_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|