1 //===--- NamespaceEndCommentsFixer.h ----------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file declares NamespaceEndCommentsFixer, a TokenAnalyzer that
12 /// fixes namespace end comments.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_CLANG_LIB_FORMAT_NAMESPACEENDCOMMENTSFIXER_H
17 #define LLVM_CLANG_LIB_FORMAT_NAMESPACEENDCOMMENTSFIXER_H
19 #include "TokenAnalyzer.h"
24 // Finds the namespace token corresponding to a closing namespace `}`, if that
25 // is to be formatted.
26 // If \p Line contains the closing `}` of a namespace, is affected and is not in
27 // a preprocessor directive, the result will be the matching namespace token.
28 // Otherwise returns null.
29 // \p AnnotatedLines is the sequence of lines from which \p Line is a member of.
31 getNamespaceToken(const AnnotatedLine *Line,
32 const SmallVectorImpl<AnnotatedLine *> &AnnotatedLines);
34 class NamespaceEndCommentsFixer : public TokenAnalyzer {
36 NamespaceEndCommentsFixer(const Environment &Env, const FormatStyle &Style);
38 std::pair<tooling::Replacements, unsigned>
39 analyze(TokenAnnotator &Annotator,
40 SmallVectorImpl<AnnotatedLine *> &AnnotatedLines,
41 FormatTokenLexer &Tokens) override;
44 } // end namespace format
45 } // end namespace clang