From ed31687c498f4bbfc6a67f6cd98e86c882379d0a Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Tue, 4 Oct 2016 10:57:59 -0700 Subject: [PATCH] Move helpers. --- .../Core/Portable/Structure/BlockTypes.cs | 53 +++++++++++++++++++ .../Syntax/AbstractBlockStructureProvider.cs | 37 ++----------- 2 files changed, 56 insertions(+), 34 deletions(-) diff --git a/src/Features/Core/Portable/Structure/BlockTypes.cs b/src/Features/Core/Portable/Structure/BlockTypes.cs index b142a41fe8b..355b44fcef6 100644 --- a/src/Features/Core/Portable/Structure/BlockTypes.cs +++ b/src/Features/Core/Portable/Structure/BlockTypes.cs @@ -45,5 +45,58 @@ internal static class BlockTypes // Expressions public const string AnonymousMethod = nameof(AnonymousMethod); public const string Xml = nameof(Xml); + + internal static bool IsCommentOrPreprocessorRegion(string type) + { + switch (type) + { + case BlockTypes.Comment: + case BlockTypes.PreprocessorRegion: + return true; + } + + return false; + } + + internal static bool IsExpressionLevelConstruct(string type) + { + switch (type) + { + case BlockTypes.AnonymousMethod: + case BlockTypes.Xml: + return true; + } + + return false; + } + + internal static bool IsStatementLevelConstruct(string type) + { + switch (type) + { + case BlockTypes.Case: + case BlockTypes.Conditional: + case BlockTypes.LocalFunction: + case BlockTypes.Lock: + case BlockTypes.Loop: + case BlockTypes.TryCatchFinally: + case BlockTypes.Using: + case BlockTypes.Standalone: + case BlockTypes.Switch: + return true; + } + + return false; + } + + internal static bool IsCodeLevelConstruct(string type) + { + return IsExpressionLevelConstruct(type) || IsStatementLevelConstruct(type); + } + + internal static bool IsDeclarationLevelConstruct(string type) + { + return !IsCodeLevelConstruct(type) && !IsCommentOrPreprocessorRegion(type); + } } } \ No newline at end of file diff --git a/src/Features/Core/Portable/Structure/Syntax/AbstractBlockStructureProvider.cs b/src/Features/Core/Portable/Structure/Syntax/AbstractBlockStructureProvider.cs index 4e939cf253b..8e6029793b5 100644 --- a/src/Features/Core/Portable/Structure/Syntax/AbstractBlockStructureProvider.cs +++ b/src/Features/Core/Portable/Structure/Syntax/AbstractBlockStructureProvider.cs @@ -108,9 +108,9 @@ internal static void UpdateAndAddSpans(BlockStructureContext context, ArrayBuild { var type = blockSpan.Type; - var isTopLevel = IsDeclarationLevelConstruct(type); - var isMemberLevel = IsCodeLevelConstruct(type); - var isComment = IsCommentOrPreprocessorRegion(type); + var isTopLevel = BlockTypes.IsDeclarationLevelConstruct(type); + var isMemberLevel = BlockTypes.IsCodeLevelConstruct(type); + var isComment = BlockTypes.IsCommentOrPreprocessorRegion(type); if (!showIndentGuidesForDeclarationLevelConstructs && isTopLevel) { @@ -144,36 +144,5 @@ internal static void UpdateAndAddSpans(BlockStructureContext context, ArrayBuild return blockSpan.With(type: type, isCollapsible: isCollapsible); } - - internal static bool IsCommentOrPreprocessorRegion(string type) - { - return type == BlockTypes.Comment || type == BlockTypes.PreprocessorRegion; - } - - internal static bool IsCodeLevelConstruct(string type) - { - switch (type) - { - case BlockTypes.Case: - case BlockTypes.Conditional: - case BlockTypes.LocalFunction: - case BlockTypes.Lock: - case BlockTypes.Loop: - case BlockTypes.TryCatchFinally: - case BlockTypes.Using: - case BlockTypes.Standalone: - case BlockTypes.Switch: - case BlockTypes.AnonymousMethod: - case BlockTypes.Xml: - return true; - } - - return false; - } - - internal static bool IsDeclarationLevelConstruct(string type) - { - return !IsCodeLevelConstruct(type) && !IsCommentOrPreprocessorRegion(type); - } } } \ No newline at end of file -- GitLab