mirror of
https://github.com/intel/llvm.git
synced 2026-02-02 02:00:03 +08:00
[clang-format] Move FormatToken::opensBlockOrBlockTypeList to source file. NFC.
This commit is contained in:
@@ -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) {}
|
||||
|
||||
@@ -696,19 +696,7 @@ public:
|
||||
|
||||
/// Returns \c true if this tokens starts a block-type list, i.e. a
|
||||
/// list that should be indented with a block indent.
|
||||
bool 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));
|
||||
}
|
||||
LLVM_NODISCARD bool opensBlockOrBlockTypeList(const FormatStyle &Style) const;
|
||||
|
||||
/// Returns whether the token is the left square bracket of a C++
|
||||
/// structured binding declaration.
|
||||
|
||||
Reference in New Issue
Block a user