|
|
|||
File indexing completed on 2026-05-10 08:37:11
0001 //===--- RefactoringActionRule.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_REFACTORINGACTIONRULE_H 0010 #define LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGACTIONRULE_H 0011 0012 #include "clang/Basic/LLVM.h" 0013 #include "llvm/ADT/StringRef.h" 0014 0015 namespace clang { 0016 namespace tooling { 0017 0018 class RefactoringOptionVisitor; 0019 class RefactoringResultConsumer; 0020 class RefactoringRuleContext; 0021 0022 struct RefactoringDescriptor { 0023 /// A unique identifier for the specific refactoring. 0024 StringRef Name; 0025 /// A human readable title for the refactoring. 0026 StringRef Title; 0027 /// A human readable description of what the refactoring does. 0028 StringRef Description; 0029 }; 0030 0031 /// A common refactoring action rule interface that defines the 'invoke' 0032 /// function that performs the refactoring operation (either fully or 0033 /// partially). 0034 class RefactoringActionRuleBase { 0035 public: 0036 virtual ~RefactoringActionRuleBase() {} 0037 0038 /// Initiates and performs a specific refactoring action. 0039 /// 0040 /// The specific rule will invoke an appropriate \c handle method on a 0041 /// consumer to propagate the result of the refactoring action. 0042 virtual void invoke(RefactoringResultConsumer &Consumer, 0043 RefactoringRuleContext &Context) = 0; 0044 0045 /// Returns the structure that describes the refactoring. 0046 // static const RefactoringDescriptor &describe() = 0; 0047 }; 0048 0049 /// A refactoring action rule is a wrapper class around a specific refactoring 0050 /// action rule (SourceChangeRefactoringRule, etc) that, in addition to invoking 0051 /// the action, describes the requirements that determine when the action can be 0052 /// initiated. 0053 class RefactoringActionRule : public RefactoringActionRuleBase { 0054 public: 0055 /// Returns true when the rule has a source selection requirement that has 0056 /// to be fulfilled before refactoring can be performed. 0057 virtual bool hasSelectionRequirement() = 0; 0058 0059 /// Traverses each refactoring option used by the rule and invokes the 0060 /// \c visit callback in the consumer for each option. 0061 /// 0062 /// Options are visited in the order of use, e.g. if a rule has two 0063 /// requirements that use options, the options from the first requirement 0064 /// are visited before the options in the second requirement. 0065 virtual void visitRefactoringOptions(RefactoringOptionVisitor &Visitor) = 0; 0066 }; 0067 0068 } // end namespace tooling 0069 } // end namespace clang 0070 0071 #endif // LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGACTIONRULE_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|