xref: /netbsd-src/external/apache2/llvm/dist/clang/lib/Format/NamespaceEndCommentsFixer.h (revision 7330f729ccf0bd976a06f95fad452fe774fc7fd1)
1*7330f729Sjoerg //===--- NamespaceEndCommentsFixer.h ----------------------------*- C++ -*-===//
2*7330f729Sjoerg //
3*7330f729Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*7330f729Sjoerg // See https://llvm.org/LICENSE.txt for license information.
5*7330f729Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*7330f729Sjoerg //
7*7330f729Sjoerg //===----------------------------------------------------------------------===//
8*7330f729Sjoerg ///
9*7330f729Sjoerg /// \file
10*7330f729Sjoerg /// This file declares NamespaceEndCommentsFixer, a TokenAnalyzer that
11*7330f729Sjoerg /// fixes namespace end comments.
12*7330f729Sjoerg ///
13*7330f729Sjoerg //===----------------------------------------------------------------------===//
14*7330f729Sjoerg 
15*7330f729Sjoerg #ifndef LLVM_CLANG_LIB_FORMAT_NAMESPACEENDCOMMENTSFIXER_H
16*7330f729Sjoerg #define LLVM_CLANG_LIB_FORMAT_NAMESPACEENDCOMMENTSFIXER_H
17*7330f729Sjoerg 
18*7330f729Sjoerg #include "TokenAnalyzer.h"
19*7330f729Sjoerg 
20*7330f729Sjoerg namespace clang {
21*7330f729Sjoerg namespace format {
22*7330f729Sjoerg 
23*7330f729Sjoerg // Finds the namespace token corresponding to a closing namespace `}`, if that
24*7330f729Sjoerg // is to be formatted.
25*7330f729Sjoerg // If \p Line contains the closing `}` of a namespace, is affected and is not in
26*7330f729Sjoerg // a preprocessor directive, the result will be the matching namespace token.
27*7330f729Sjoerg // Otherwise returns null.
28*7330f729Sjoerg // \p AnnotatedLines is the sequence of lines from which \p Line is a member of.
29*7330f729Sjoerg const FormatToken *
30*7330f729Sjoerg getNamespaceToken(const AnnotatedLine *Line,
31*7330f729Sjoerg                   const SmallVectorImpl<AnnotatedLine *> &AnnotatedLines);
32*7330f729Sjoerg 
33*7330f729Sjoerg class NamespaceEndCommentsFixer : public TokenAnalyzer {
34*7330f729Sjoerg public:
35*7330f729Sjoerg   NamespaceEndCommentsFixer(const Environment &Env, const FormatStyle &Style);
36*7330f729Sjoerg 
37*7330f729Sjoerg   std::pair<tooling::Replacements, unsigned>
38*7330f729Sjoerg   analyze(TokenAnnotator &Annotator,
39*7330f729Sjoerg           SmallVectorImpl<AnnotatedLine *> &AnnotatedLines,
40*7330f729Sjoerg           FormatTokenLexer &Tokens) override;
41*7330f729Sjoerg };
42*7330f729Sjoerg 
43*7330f729Sjoerg } // end namespace format
44*7330f729Sjoerg } // end namespace clang
45*7330f729Sjoerg 
46*7330f729Sjoerg #endif
47