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