NamespaceEndCommentsFixer.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #ifndef LLVM_CLANG_LIB_FORMAT_NAMESPACEENDCOMMENTSFIXER_H
  15. #define LLVM_CLANG_LIB_FORMAT_NAMESPACEENDCOMMENTSFIXER_H
  16. #include "TokenAnalyzer.h"
  17. namespace clang {
  18. namespace format {
  19. // Finds the namespace token corresponding to a closing namespace `}`, if that
  20. // is to be formatted.
  21. // If \p Line contains the closing `}` of a namespace, is affected and is not in
  22. // a preprocessor directive, the result will be the matching namespace token.
  23. // Otherwise returns null.
  24. // \p AnnotatedLines is the sequence of lines from which \p Line is a member of.
  25. const FormatToken *
  26. getNamespaceToken(const AnnotatedLine *Line,
  27. const SmallVectorImpl<AnnotatedLine *> &AnnotatedLines);
  28. class NamespaceEndCommentsFixer : public TokenAnalyzer {
  29. public:
  30. NamespaceEndCommentsFixer(const Environment &Env, const FormatStyle &Style);
  31. std::pair<tooling::Replacements, unsigned>
  32. analyze(TokenAnnotator &Annotator,
  33. SmallVectorImpl<AnnotatedLine *> &AnnotatedLines,
  34. FormatTokenLexer &Tokens) override;
  35. };
  36. } // end namespace format
  37. } // end namespace clang
  38. #endif