clang  14.0.0git
NamespaceEndCommentsFixer.h
Go to the documentation of this file.
1 //===--- NamespaceEndCommentsFixer.h ----------------------------*- C++ -*-===//
2 //
3 // 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
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// This file declares NamespaceEndCommentsFixer, a TokenAnalyzer that
11 /// 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 
20 namespace clang {
21 namespace format {
22 
23 // 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.
29 const FormatToken *
30 getNamespaceToken(const AnnotatedLine *Line,
31  const SmallVectorImpl<AnnotatedLine *> &AnnotatedLines);
32 
34 public:
36 
37  std::pair<tooling::Replacements, unsigned>
38  analyze(TokenAnnotator &Annotator,
39  SmallVectorImpl<AnnotatedLine *> &AnnotatedLines,
40  FormatTokenLexer &Tokens) override;
41 };
42 
43 } // end namespace format
44 } // end namespace clang
45 
46 #endif
clang::format::NamespaceEndCommentsFixer
Definition: NamespaceEndCommentsFixer.h:33
clang::format::TokenAnalyzer::Env
const Environment & Env
Definition: TokenAnalyzer.h:98
clang::format::FormatStyle
The FormatStyle is used to configure the formatting to follow specific guidelines.
Definition: Format.h:59
clang::format::NamespaceEndCommentsFixer::NamespaceEndCommentsFixer
NamespaceEndCommentsFixer(const Environment &Env, const FormatStyle &Style)
Definition: NamespaceEndCommentsFixer.cpp:196
clang::format::Environment
Definition: TokenAnalyzer.h:36
clang::format::TokenAnnotator
Determines extra information about the tokens comprising an UnwrappedLine.
Definition: TokenAnnotator.h:158
Line
const AnnotatedLine * Line
Definition: UsingDeclarationsSorter.cpp:68
clang::format::getNamespaceToken
const FormatToken * getNamespaceToken(const AnnotatedLine *Line, const SmallVectorImpl< AnnotatedLine * > &AnnotatedLines)
Definition: NamespaceEndCommentsFixer.cpp:171
clang
Definition: CalledOnceCheck.h:17
clang::format::TokenAnalyzer
Definition: TokenAnalyzer.h:80
clang::format::FormatTokenLexer
Definition: FormatTokenLexer.h:38
llvm::SmallVectorImpl
Definition: LLVM.h:39
clang::format::NamespaceEndCommentsFixer::analyze
std::pair< tooling::Replacements, unsigned > analyze(TokenAnnotator &Annotator, SmallVectorImpl< AnnotatedLine * > &AnnotatedLines, FormatTokenLexer &Tokens) override
Definition: NamespaceEndCommentsFixer.cpp:200
clang::format::TokenAnalyzer::Style
FormatStyle Style
Definition: TokenAnalyzer.h:96
TokenAnalyzer.h