clang 19.0.0git
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_REFACTORING_REFACTORINGACTIONRULE_H
10#define LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGACTIONRULE_H
11
12#include "clang/Basic/LLVM.h"
13#include "llvm/ADT/StringRef.h"
14
15namespace clang {
16namespace tooling {
17
18class RefactoringOptionVisitor;
19class RefactoringResultConsumer;
20class RefactoringRuleContext;
21
23 /// A unique identifier for the specific refactoring.
24 StringRef Name;
25 /// A human readable title for the refactoring.
26 StringRef Title;
27 /// A human readable description of what the refactoring does.
28 StringRef Description;
29};
30
31/// A common refactoring action rule interface that defines the 'invoke'
32/// function that performs the refactoring operation (either fully or
33/// partially).
35public:
37
38 /// Initiates and performs a specific refactoring action.
39 ///
40 /// The specific rule will invoke an appropriate \c handle method on a
41 /// consumer to propagate the result of the refactoring action.
42 virtual void invoke(RefactoringResultConsumer &Consumer,
43 RefactoringRuleContext &Context) = 0;
44
45 /// Returns the structure that describes the refactoring.
46 // static const RefactoringDescriptor &describe() = 0;
47};
48
49/// A refactoring action rule is a wrapper class around a specific refactoring
50/// action rule (SourceChangeRefactoringRule, etc) that, in addition to invoking
51/// the action, describes the requirements that determine when the action can be
52/// initiated.
54public:
55 /// Returns true when the rule has a source selection requirement that has
56 /// to be fulfilled before refactoring can be performed.
57 virtual bool hasSelectionRequirement() = 0;
58
59 /// Traverses each refactoring option used by the rule and invokes the
60 /// \c visit callback in the consumer for each option.
61 ///
62 /// Options are visited in the order of use, e.g. if a rule has two
63 /// requirements that use options, the options from the first requirement
64 /// are visited before the options in the second requirement.
66};
67
68} // end namespace tooling
69} // end namespace clang
70
71#endif // LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGACTIONRULE_H
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
A common refactoring action rule interface that defines the 'invoke' function that performs the refac...
virtual void invoke(RefactoringResultConsumer &Consumer, RefactoringRuleContext &Context)=0
Initiates and performs a specific refactoring action.
A refactoring action rule is a wrapper class around a specific refactoring action rule (SourceChangeR...
virtual bool hasSelectionRequirement()=0
Returns true when the rule has a source selection requirement that has to be fulfilled before refacto...
virtual void visitRefactoringOptions(RefactoringOptionVisitor &Visitor)=0
Traverses each refactoring option used by the rule and invokes the visit callback in the consumer for...
An interface that declares functions that handle different refactoring option types.
An abstract interface that consumes the various refactoring results that can be produced by refactori...
The refactoring rule context stores all of the inputs that might be needed by a refactoring action ru...
The JSON file list parser is used to communicate input to InstallAPI.
StringRef Title
A human readable title for the refactoring.
StringRef Name
A unique identifier for the specific refactoring.
StringRef Description
A human readable description of what the refactoring does.