clang 8.0.0

RefactoringResultConsumer.h
Go to the documentation of this file.
1 //===--- RefactoringResultConsumer.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_RESULT_CONSUMER_H
11 #define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_RESULT_CONSUMER_H
12
13 #include "clang/Basic/LLVM.h"
14 #include "clang/Tooling/Refactoring/AtomicChange.h"
15 #include "clang/Tooling/Refactoring/Rename/SymbolOccurrences.h"
16 #include "llvm/Support/Error.h"
17
18 namespace clang {
19 namespace tooling {
20
21 /// An abstract interface that consumes the various refactoring results that can
22 /// be produced by refactoring actions.
23 ///
24 /// A valid refactoring result must be handled by a \c handle method.
25 class RefactoringResultConsumer {
26 public:
27 virtual ~RefactoringResultConsumer() {}
28
29 /// Handles an initiation or an invication error. An initiation error typically
30 /// has a \c DiagnosticError payload that describes why initiation failed.
31 virtual void handleError(llvm::Error Err) = 0;
32
33 /// Handles the source replacements that are produced by a refactoring action.
34 virtual void handle(AtomicChanges SourceReplacements) {
35 defaultResultHandler();
36 }
37
38 /// Handles the symbol occurrences that are found by an interactive
39 /// refactoring action.
40 virtual void handle(SymbolOccurrences Occurrences) { defaultResultHandler(); }
41
42 private:
43 void defaultResultHandler() {
44 handleError(llvm::make_error<llvm::StringError>(
45 "unsupported refactoring result", llvm::inconvertibleErrorCode()));
46 }
47 };
48
49 } // end namespace tooling
50 } // end namespace clang
51
52 #endif // LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_RESULT_CONSUMER_H
AtomicChange.h
clang::tooling::AtomicChanges
std::vector< AtomicChange > AtomicChanges
Definition: AtomicChange.h:141
clang::tooling::RefactoringResultConsumer::handleError
virtual void handleError(llvm::Error Err)=0
Handles an initiation or an invication error.
clang::tooling::RefactoringResultConsumer::~RefactoringResultConsumer
virtual ~RefactoringResultConsumer()
Definition: RefactoringResultConsumer.h:27
LLVM.h
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
SymbolOccurrences.h
clang::tooling::RefactoringResultConsumer::handle
virtual void handle(AtomicChanges SourceReplacements)
Handles the source replacements that are produced by a refactoring action.
Definition: RefactoringResultConsumer.h:34
clang::DiagnosticLevelMask::Error
clang::tooling::RefactoringResultConsumer::handle
virtual void handle(SymbolOccurrences Occurrences)
Handles the symbol occurrences that are found by an interactive refactoring action.
Definition: RefactoringResultConsumer.h:40
clang::tooling::RefactoringResultConsumer
An abstract interface that consumes the various refactoring results that can be produced by refactori...
Definition: RefactoringResultConsumer.h:25
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::tooling::SymbolOccurrences
std::vector< SymbolOccurrence > SymbolOccurrences
Definition: SymbolOccurrences.h:86