blob: eba24236f268ce47c18347d0b8b84dc1042c9e65 [file] [log] [blame]
Krasimir Georgiev7cb267a2017-02-27 13:28:36 +00001//===--- NamespaceEndCommentsFixer.h ----------------------------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Krasimir Georgiev7cb267a2017-02-27 13:28:36 +00006//
7//===----------------------------------------------------------------------===//
8///
9/// \file
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000010/// This file declares NamespaceEndCommentsFixer, a TokenAnalyzer that
Krasimir Georgiev7cb267a2017-02-27 13:28:36 +000011/// fixes namespace end comments.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_LIB_FORMAT_NAMESPACEENDCOMMENTSFIXER_H
16#define LLVM_CLANG_LIB_FORMAT_NAMESPACEENDCOMMENTSFIXER_H
17
18#include "TokenAnalyzer.h"
19
20namespace clang {
21namespace format {
22
Krasimir Georgiev62103052018-04-19 13:02:15 +000023// Finds the namespace token corresponding to a closing namespace `}`, if that
24// is to be formatted.
25// If \p Line contains the closing `}` of a namespace, is affected and is not in
26// a preprocessor directive, the result will be the matching namespace token.
27// Otherwise returns null.
28// \p AnnotatedLines is the sequence of lines from which \p Line is a member of.
29const FormatToken *
30getNamespaceToken(const AnnotatedLine *Line,
31 const SmallVectorImpl<AnnotatedLine *> &AnnotatedLines);
32
Krasimir Georgiev7cb267a2017-02-27 13:28:36 +000033class NamespaceEndCommentsFixer : public TokenAnalyzer {
34public:
35 NamespaceEndCommentsFixer(const Environment &Env, const FormatStyle &Style);
36
Krasimir Georgiev9ad83fe2017-10-30 14:01:50 +000037 std::pair<tooling::Replacements, unsigned>
Krasimir Georgiev7cb267a2017-02-27 13:28:36 +000038 analyze(TokenAnnotator &Annotator,
39 SmallVectorImpl<AnnotatedLine *> &AnnotatedLines,
40 FormatTokenLexer &Tokens) override;
41};
42
43} // end namespace format
44} // end namespace clang
45
46#endif