diff --git a/src/EditorFeatures/CSharpTest/CSharpEditorServicesTest.csproj b/src/EditorFeatures/CSharpTest/CSharpEditorServicesTest.csproj index 826f0dba2e4ea9a4108741d098bd6e4befaa4dbf..b3d4e38b74c60bde07eb281fa69d6166780ca018 100644 --- a/src/EditorFeatures/CSharpTest/CSharpEditorServicesTest.csproj +++ b/src/EditorFeatures/CSharpTest/CSharpEditorServicesTest.csproj @@ -281,6 +281,7 @@ + diff --git a/src/EditorFeatures/CSharpTest/Structure/ArrowExpressionClauseStructureTests.cs b/src/EditorFeatures/CSharpTest/Structure/ArrowExpressionClauseStructureTests.cs new file mode 100644 index 0000000000000000000000000000000000000000..523a9f6c3eb639e6d95a748426b39a7b28e2f7b6 --- /dev/null +++ b/src/EditorFeatures/CSharpTest/Structure/ArrowExpressionClauseStructureTests.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.CSharp.Structure; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Structure; +using Roslyn.Test.Utilities; +using Xunit; + +namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Structure +{ + public class ArrowExpressionClauseStructureTests : AbstractCSharpSyntaxNodeStructureTests + { + internal override AbstractSyntaxStructureProvider CreateProvider() + => new ArrowExpressionClauseStructureProvider(); + + [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] + public async Task TestArrowExpressionClause1() + { + await VerifyBlockSpansAsync( +@" +class C +{ + {|hintspan:void M(){|textspan: $$=> expression + ? trueCase + : falseCase;|}|}; +} +", + Region("textspan", "hintspan", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); + } + } +} \ No newline at end of file diff --git a/src/Features/CSharp/Portable/CSharpFeatures.csproj b/src/Features/CSharp/Portable/CSharpFeatures.csproj index 5764374fc4d52972da424bd367fadf0bd404cb2c..1e78a0b55b5cbf14be40edcc9974be920bf4eee7 100644 --- a/src/Features/CSharp/Portable/CSharpFeatures.csproj +++ b/src/Features/CSharp/Portable/CSharpFeatures.csproj @@ -55,6 +55,7 @@ InternalUtilities\LambdaUtilities.cs + diff --git a/src/Features/CSharp/Portable/Structure/CSharpBlockStructureProvider.cs b/src/Features/CSharp/Portable/Structure/CSharpBlockStructureProvider.cs index 1d25c2baf49f7b2d07388095e486d911e936c94f..81eab6c1b3dfe2775c0e9c1aee428e1a89263f51 100644 --- a/src/Features/CSharp/Portable/Structure/CSharpBlockStructureProvider.cs +++ b/src/Features/CSharp/Portable/Structure/CSharpBlockStructureProvider.cs @@ -7,7 +7,6 @@ namespace Microsoft.CodeAnalysis.CSharp.Structure { - internal class CSharpBlockStructureProvider : AbstractBlockStructureProvider { private static ImmutableDictionary> CreateDefaultNodeProviderMap() @@ -16,6 +15,7 @@ internal class CSharpBlockStructureProvider : AbstractBlockStructureProvider builder.Add(); builder.Add(); + builder.Add(); builder.Add(); builder.Add(); builder.Add(); diff --git a/src/Features/CSharp/Portable/Structure/Providers/ArrowExpressionClauseStructureProvider.cs b/src/Features/CSharp/Portable/Structure/Providers/ArrowExpressionClauseStructureProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..482ce07a78114787758cb4a420bf03ef67d6b017 --- /dev/null +++ b/src/Features/CSharp/Portable/Structure/Providers/ArrowExpressionClauseStructureProvider.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.Structure; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.CSharp.Structure +{ + internal class ArrowExpressionClauseStructureProvider : AbstractSyntaxNodeStructureProvider + { + protected override void CollectBlockSpans( + ArrowExpressionClauseSyntax node, + ArrayBuilder spans, + OptionSet options, + CancellationToken cancellationToken) + { + var previousToken = node.ArrowToken.GetPreviousToken(); + spans.Add(new BlockSpan( + isCollapsible: true, + textSpan: TextSpan.FromBounds(previousToken.Span.End, node.Parent.Span.End), + hintSpan: node.Parent.Span, + type: BlockTypes.Nonstructural)); + } + } +} \ No newline at end of file