DefinitionBlockSeparator.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //===--- DefinitionBlockSeparator.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 DefinitionBlockSeparator, a TokenAnalyzer that inserts or
  11. /// removes empty lines separating definition blocks like classes, structs,
  12. /// functions, enums, and namespaces in between.
  13. ///
  14. //===----------------------------------------------------------------------===//
  15. #ifndef LLVM_CLANG_LIB_FORMAT_DEFINITIONBLOCKSEPARATOR_H
  16. #define LLVM_CLANG_LIB_FORMAT_DEFINITIONBLOCKSEPARATOR_H
  17. #include "TokenAnalyzer.h"
  18. #include "WhitespaceManager.h"
  19. namespace clang {
  20. namespace format {
  21. class DefinitionBlockSeparator : public TokenAnalyzer {
  22. public:
  23. DefinitionBlockSeparator(const Environment &Env, const FormatStyle &Style)
  24. : TokenAnalyzer(Env, Style) {}
  25. std::pair<tooling::Replacements, unsigned>
  26. analyze(TokenAnnotator &Annotator,
  27. SmallVectorImpl<AnnotatedLine *> &AnnotatedLines,
  28. FormatTokenLexer &Tokens) override;
  29. private:
  30. void separateBlocks(SmallVectorImpl<AnnotatedLine *> &Lines,
  31. tooling::Replacements &Result, FormatTokenLexer &Tokens);
  32. };
  33. } // namespace format
  34. } // namespace clang
  35. #endif