clang  6.0.0svn
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"
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.
26 public:
28 
29  /// Handles an initation or an invication error. An initiation error typically
30  /// has a \c DiagnosticError payload that describes why initation 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
std::vector< AtomicChange > AtomicChanges
Definition: AtomicChange.h:141
virtual void handleError(llvm::Error Err)=0
Handles an initation or an invication error.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
virtual void handle(AtomicChanges SourceReplacements)
Handles the source replacements that are produced by a refactoring action.
virtual void handle(SymbolOccurrences Occurrences)
Handles the symbol occurrences that are found by an interactive refactoring action.
An abstract interface that consumes the various refactoring results that can be produced by refactori...
Dataflow Directional Tag Classes.
std::vector< SymbolOccurrence > SymbolOccurrences