clang  16.0.0git
DefinitionBlockSeparator.h
Go to the documentation of this file.
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 
16 #ifndef LLVM_CLANG_LIB_FORMAT_DEFINITIONBLOCKSEPARATOR_H
17 #define LLVM_CLANG_LIB_FORMAT_DEFINITIONBLOCKSEPARATOR_H
18 
19 #include "TokenAnalyzer.h"
20 #include "WhitespaceManager.h"
21 
22 namespace clang {
23 namespace format {
25 public:
27  : TokenAnalyzer(Env, Style) {}
28 
29  std::pair<tooling::Replacements, unsigned>
30  analyze(TokenAnnotator &Annotator,
31  SmallVectorImpl<AnnotatedLine *> &AnnotatedLines,
32  FormatTokenLexer &Tokens) override;
33 
34 private:
35  void separateBlocks(SmallVectorImpl<AnnotatedLine *> &Lines,
36  tooling::Replacements &Result, FormatTokenLexer &Tokens);
37 };
38 } // namespace format
39 } // namespace clang
40 
41 #endif
clang::format::TokenAnalyzer::Env
const Environment & Env
Definition: TokenAnalyzer.h:107
clang::tooling::Replacements
Maintains a set of replacements that are conflict-free.
Definition: Replacement.h:209
clang::format::FormatStyle
The FormatStyle is used to configure the formatting to follow specific guidelines.
Definition: Format.h:54
clang::format::DefinitionBlockSeparator::analyze
std::pair< tooling::Replacements, unsigned > analyze(TokenAnnotator &Annotator, SmallVectorImpl< AnnotatedLine * > &AnnotatedLines, FormatTokenLexer &Tokens) override
Definition: DefinitionBlockSeparator.cpp:22
clang::format::Environment
Definition: TokenAnalyzer.h:37
clang::format::DefinitionBlockSeparator::DefinitionBlockSeparator
DefinitionBlockSeparator(const Environment &Env, const FormatStyle &Style)
Definition: DefinitionBlockSeparator.h:26
clang::format::TokenAnnotator
Determines extra information about the tokens comprising an UnwrappedLine.
Definition: TokenAnnotator.h:168
WhitespaceManager.h
clang::format::DefinitionBlockSeparator
Definition: DefinitionBlockSeparator.h:24
clang
Definition: CalledOnceCheck.h:17
clang::format::TokenAnalyzer
Definition: TokenAnalyzer.h:88
clang::format::FormatTokenLexer
Definition: FormatTokenLexer.h:39
llvm::SmallVectorImpl
Definition: Randstruct.h:18
clang::format::TokenAnalyzer::Style
FormatStyle Style
Definition: TokenAnalyzer.h:105
TokenAnalyzer.h