aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Format/FormatToken.cpp
diff options
context:
space:
mode:
authorMarek Kurdej <marek.kurdej+llvm.org@gmail.com>2022-02-10 10:14:36 +0100
committerMarek Kurdej <marek.kurdej+llvm.org@gmail.com>2022-02-10 10:51:03 +0100
commit4efde1e554cce3f017b3d1ce700bd1860eed2ccd (patch)
treecd8e0f26deb96246dfa1fbf31f309402581eb2f2 /clang/lib/Format/FormatToken.cpp
parent34ff99a0b7b18d8242cce7d1fe0e04e003718015 (diff)
downloadllvm-4efde1e554cce3f017b3d1ce700bd1860eed2ccd.zip
llvm-4efde1e554cce3f017b3d1ce700bd1860eed2ccd.tar.gz
llvm-4efde1e554cce3f017b3d1ce700bd1860eed2ccd.tar.bz2
[clang-format] Move FormatToken::opensBlockOrBlockTypeList to source file. NFC.
Diffstat (limited to 'clang/lib/Format/FormatToken.cpp')
-rw-r--r--clang/lib/Format/FormatToken.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp
index 40aa8f5..5577918d 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -74,6 +74,20 @@ bool FormatToken::isTypeOrIdentifier() const {
return isSimpleTypeSpecifier() || Tok.isOneOf(tok::kw_auto, tok::identifier);
}
+bool FormatToken::opensBlockOrBlockTypeList(const FormatStyle &Style) const {
+ // C# Does not indent object initialisers as continuations.
+ if (is(tok::l_brace) && getBlockKind() == BK_BracedInit && Style.isCSharp())
+ return true;
+ if (is(TT_TemplateString) && opensScope())
+ return true;
+ return is(TT_ArrayInitializerLSquare) || is(TT_ProtoExtensionLSquare) ||
+ (is(tok::l_brace) &&
+ (getBlockKind() == BK_Block || is(TT_DictLiteral) ||
+ (!Style.Cpp11BracedListStyle && NestingLevel == 0))) ||
+ (is(tok::less) && (Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TextProto));
+}
+
TokenRole::~TokenRole() {}
void TokenRole::precomputeFormattingInfos(const FormatToken *Token) {}