clang  6.0.0svn
RefactoringActionRule.h
Go to the documentation of this file.
1 //===--- RefactoringActionRule.h - Clang refactoring library -------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_H
11 #define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_H
12 
13 #include "clang/Basic/LLVM.h"
14 #include "llvm/ADT/Optional.h"
15 #include "llvm/ADT/StringRef.h"
16 #include <vector>
17 
18 namespace clang {
19 namespace tooling {
20 
21 class RefactoringOptionVisitor;
22 class RefactoringResultConsumer;
23 class RefactoringRuleContext;
24 
26  /// A unique identifier for the specific refactoring.
27  StringRef Name;
28  /// A human readable title for the refactoring.
29  StringRef Title;
30  /// A human readable description of what the refactoring does.
31  StringRef Description;
32 };
33 
34 /// A common refactoring action rule interface that defines the 'invoke'
35 /// function that performs the refactoring operation (either fully or
36 /// partially).
38 public:
40 
41  /// Initiates and performs a specific refactoring action.
42  ///
43  /// The specific rule will invoke an appropriate \c handle method on a
44  /// consumer to propagate the result of the refactoring action.
45  virtual void invoke(RefactoringResultConsumer &Consumer,
46  RefactoringRuleContext &Context) = 0;
47 
48  /// Returns the structure that describes the refactoring.
49  // static const RefactoringDescriptor &describe() = 0;
50 };
51 
52 /// A refactoring action rule is a wrapper class around a specific refactoring
53 /// action rule (SourceChangeRefactoringRule, etc) that, in addition to invoking
54 /// the action, describes the requirements that determine when the action can be
55 /// initiated.
57 public:
58  /// Returns true when the rule has a source selection requirement that has
59  /// to be fullfilled before refactoring can be performed.
60  virtual bool hasSelectionRequirement() = 0;
61 
62  /// Traverses each refactoring option used by the rule and invokes the
63  /// \c visit callback in the consumer for each option.
64  ///
65  /// Options are visited in the order of use, e.g. if a rule has two
66  /// requirements that use options, the options from the first requirement
67  /// are visited before the options in the second requirement.
68  virtual void visitRefactoringOptions(RefactoringOptionVisitor &Visitor) = 0;
69 };
70 
71 } // end namespace tooling
72 } // end namespace clang
73 
74 #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.