clang  9.0.0
RefactoringActionRule.h
Go to the documentation of this file.
1 //===--- RefactoringActionRule.h - Clang refactoring library -------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_H
10 #define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_H
11 
12 #include "clang/Basic/LLVM.h"
13 #include "llvm/ADT/Optional.h"
14 #include "llvm/ADT/StringRef.h"
15 #include <vector>
16 
17 namespace clang {
18 namespace tooling {
19 
20 class RefactoringOptionVisitor;
21 class RefactoringResultConsumer;
22 class RefactoringRuleContext;
23 
25  /// A unique identifier for the specific refactoring.
26  StringRef Name;
27  /// A human readable title for the refactoring.
28  StringRef Title;
29  /// A human readable description of what the refactoring does.
30  StringRef Description;
31 };
32 
33 /// A common refactoring action rule interface that defines the 'invoke'
34 /// function that performs the refactoring operation (either fully or
35 /// partially).
37 public:
39 
40  /// Initiates and performs a specific refactoring action.
41  ///
42  /// The specific rule will invoke an appropriate \c handle method on a
43  /// consumer to propagate the result of the refactoring action.
44  virtual void invoke(RefactoringResultConsumer &Consumer,
45  RefactoringRuleContext &Context) = 0;
46 
47  /// Returns the structure that describes the refactoring.
48  // static const RefactoringDescriptor &describe() = 0;
49 };
50 
51 /// A refactoring action rule is a wrapper class around a specific refactoring
52 /// action rule (SourceChangeRefactoringRule, etc) that, in addition to invoking
53 /// the action, describes the requirements that determine when the action can be
54 /// initiated.
56 public:
57  /// Returns true when the rule has a source selection requirement that has
58  /// to be fulfilled before refactoring can be performed.
59  virtual bool hasSelectionRequirement() = 0;
60 
61  /// Traverses each refactoring option used by the rule and invokes the
62  /// \c visit callback in the consumer for each option.
63  ///
64  /// Options are visited in the order of use, e.g. if a rule has two
65  /// requirements that use options, the options from the first requirement
66  /// are visited before the options in the second requirement.
67  virtual void visitRefactoringOptions(RefactoringOptionVisitor &Visitor) = 0;
68 };
69 
70 } // end namespace tooling
71 } // end namespace clang
72 
73 #endif // LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_H
A refactoring action rule is a wrapper class around a specific refactoring action rule (SourceChangeR...
An interface that declares functions that handle different refactoring option types.
A common refactoring action rule interface that defines the &#39;invoke&#39; function that performs the refac...
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
StringRef Name
A unique identifier for the specific refactoring.
The refactoring rule context stores all of the inputs that might be needed by a refactoring action ru...
An abstract interface that consumes the various refactoring results that can be produced by refactori...
StringRef Description
A human readable description of what the refactoring does.
Dataflow Directional Tag Classes.
void visitRefactoringOptions(RefactoringOptionVisitor &Visitor, const std::tuple< RequirementTypes... > &Requirements, llvm::index_sequence< Is... >)
StringRef Title
A human readable title for the refactoring.