clang 10.0.0git

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