blob: 07a1c7bb0c35e7de795094c8c0209e24954500ef [file] [log] [blame]
Krasimir Georgiev7cb267a2017-02-27 13:28:36 +00001//===--- NamespaceEndCommentsFixer.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/// \file
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000011/// This file declares NamespaceEndCommentsFixer, a TokenAnalyzer that
Krasimir Georgiev7cb267a2017-02-27 13:28:36 +000012/// fixes namespace end comments.
13///
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_CLANG_LIB_FORMAT_NAMESPACEENDCOMMENTSFIXER_H
17#define LLVM_CLANG_LIB_FORMAT_NAMESPACEENDCOMMENTSFIXER_H
18
19#include "TokenAnalyzer.h"
20
21namespace clang {
22namespace format {
23
Krasimir Georgiev62103052018-04-19 13:02:15 +000024// 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.
30const FormatToken *
31getNamespaceToken(const AnnotatedLine *Line,
32 const SmallVectorImpl<AnnotatedLine *> &AnnotatedLines);
33
Krasimir Georgiev7cb267a2017-02-27 13:28:36 +000034class NamespaceEndCommentsFixer : public TokenAnalyzer {
35public:
36 NamespaceEndCommentsFixer(const Environment &Env, const FormatStyle &Style);
37
Krasimir Georgiev9ad83fe2017-10-30 14:01:50 +000038 std::pair<tooling::Replacements, unsigned>
Krasimir Georgiev7cb267a2017-02-27 13:28:36 +000039 analyze(TokenAnnotator &Annotator,
40 SmallVectorImpl<AnnotatedLine *> &AnnotatedLines,
41 FormatTokenLexer &Tokens) override;
42};
43
44} // end namespace format
45} // end namespace clang
46
47#endif