blob: 64a994d88b9d96bdc81eb8acee25361f4546a27c [file] [log] [blame]
Alex Lorenzf5ca27c2017-10-16 18:28:26 +00001//===--- ToolRefactoringResultConsumer.h - ----------------------*- C++ -*-===//
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_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H
11#define LLVM_CLANG_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H
12
13#include "clang/AST/ASTContext.h"
14#include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
15
16namespace clang {
17namespace refactor {
18
19/// An interface that subclasses the \c RefactoringResultConsumer interface
20/// that stores the reference to the TU-specific diagnostics engine.
21class ClangRefactorToolConsumerInterface
22 : public tooling::RefactoringResultConsumer {
23public:
24 /// Called when a TU is entered.
25 void beginTU(ASTContext &Context) {
26 assert(!Diags && "Diags has been set");
27 Diags = &Context.getDiagnostics();
28 }
29
30 /// Called when the tool is done with a TU.
31 void endTU() {
32 assert(Diags && "Diags unset");
33 Diags = nullptr;
34 }
35
36 DiagnosticsEngine &getDiags() const {
37 assert(Diags && "no diags");
38 return *Diags;
39 }
40
41private:
42 DiagnosticsEngine *Diags = nullptr;
43};
44
45} // end namespace refactor
46} // end namespace clang
47
48#endif // LLVM_CLANG_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H