protected override void CollectBlockSpans( SyntaxToken previousToken, AccessorDeclarationSyntax accessorDeclaration, ref TemporaryArray <BlockSpan> spans, BlockStructureOptions options, CancellationToken cancellationToken) { CSharpStructureHelpers.CollectCommentBlockSpans(accessorDeclaration, ref spans, options); // fault tolerance if (accessorDeclaration.Body == null || accessorDeclaration.Body.OpenBraceToken.IsMissing || accessorDeclaration.Body.CloseBraceToken.IsMissing) { return; } SyntaxNodeOrToken current = accessorDeclaration; var nextSibling = current.GetNextSibling(); // Check IsNode to compress blank lines after this node if it is the last child of the parent. // // All accessor kinds are grouped together in Metadata as Source. var compressEmptyLines = options.IsMetadataAsSource && (!nextSibling.IsNode || nextSibling.AsNode() is AccessorDeclarationSyntax); spans.AddIfNotNull(CSharpStructureHelpers.CreateBlockSpan( accessorDeclaration, accessorDeclaration.Keyword, compressEmptyLines: compressEmptyLines, autoCollapse: true, type: BlockTypes.Member, isCollapsible: true)); }
protected override void CollectBlockSpans( OperatorDeclarationSyntax operatorDeclaration, ArrayBuilder <BlockSpan> spans, bool isMetadataAsSource, OptionSet options, CancellationToken cancellationToken) { CSharpStructureHelpers.CollectCommentBlockSpans(operatorDeclaration, spans, isMetadataAsSource); // fault tolerance if (operatorDeclaration.Body == null || operatorDeclaration.Body.OpenBraceToken.IsMissing || operatorDeclaration.Body.CloseBraceToken.IsMissing) { return; } SyntaxNodeOrToken current = operatorDeclaration; var nextSibling = current.GetNextSibling(); // Check IsNode to compress blank lines after this node if it is the last child of the parent. var compressEmptyLines = !nextSibling.IsNode || nextSibling.IsKind(SyntaxKind.OperatorDeclaration); spans.AddIfNotNull(CSharpStructureHelpers.CreateBlockSpan( operatorDeclaration, operatorDeclaration.ParameterList.GetLastToken(includeZeroWidth: true), compressEmptyLines: compressEmptyLines, autoCollapse: true, type: BlockTypes.Member, isCollapsible: true)); }
protected override void CollectBlockSpans( PropertyDeclarationSyntax propertyDeclaration, ArrayBuilder <BlockSpan> spans, BlockStructureOptionProvider optionProvider, CancellationToken cancellationToken) { CSharpStructureHelpers.CollectCommentBlockSpans(propertyDeclaration, spans, optionProvider); // fault tolerance if (propertyDeclaration.AccessorList == null || propertyDeclaration.AccessorList.OpenBraceToken.IsMissing || propertyDeclaration.AccessorList.CloseBraceToken.IsMissing) { return; } SyntaxNodeOrToken current = propertyDeclaration; var nextSibling = current.GetNextSibling(); // Check IsNode to compress blank lines after this node if it is the last child of the parent. // // Properties are grouped together with indexers in Metadata as Source. var compressEmptyLines = optionProvider.IsMetadataAsSource && (!nextSibling.IsNode || nextSibling.IsKind(SyntaxKind.PropertyDeclaration) || nextSibling.IsKind(SyntaxKind.IndexerDeclaration)); spans.AddIfNotNull(CSharpStructureHelpers.CreateBlockSpan( propertyDeclaration, propertyDeclaration.Identifier, compressEmptyLines: compressEmptyLines, autoCollapse: true, type: BlockTypes.Member, isCollapsible: true)); }
protected override void CollectBlockSpans( ConversionOperatorDeclarationSyntax operatorDeclaration, ref TemporaryArray <BlockSpan> spans, BlockStructureOptionProvider optionProvider, CancellationToken cancellationToken) { CSharpStructureHelpers.CollectCommentBlockSpans(operatorDeclaration, ref spans, optionProvider); // fault tolerance if (operatorDeclaration.Body == null || operatorDeclaration.Body.OpenBraceToken.IsMissing || operatorDeclaration.Body.CloseBraceToken.IsMissing) { return; } SyntaxNodeOrToken current = operatorDeclaration; var nextSibling = current.GetNextSibling(); // Check IsNode to compress blank lines after this node if it is the last child of the parent. // // Whitespace between conversion operators is collapsed in Metadata as Source. var compressEmptyLines = optionProvider.IsMetadataAsSource && (!nextSibling.IsNode || nextSibling.IsKind(SyntaxKind.ConversionOperatorDeclaration)); spans.AddIfNotNull(CSharpStructureHelpers.CreateBlockSpan( operatorDeclaration, operatorDeclaration.ParameterList.GetLastToken(includeZeroWidth: true), compressEmptyLines: compressEmptyLines, autoCollapse: true, type: BlockTypes.Member, isCollapsible: true)); }
protected override void CollectBlockSpans( EnumDeclarationSyntax enumDeclaration, ArrayBuilder <BlockSpan> spans, bool isMetadataAsSource, OptionSet options, CancellationToken cancellationToken) { CSharpStructureHelpers.CollectCommentBlockSpans(enumDeclaration, spans, isMetadataAsSource); if (!enumDeclaration.OpenBraceToken.IsMissing && !enumDeclaration.CloseBraceToken.IsMissing) { SyntaxNodeOrToken current = enumDeclaration; var nextSibling = current.GetNextSibling(); // Check IsNode to compress blank lines after this node if it is the last child of the parent. var compressEmptyLines = !nextSibling.IsNode || nextSibling.AsNode() is BaseTypeDeclarationSyntax; spans.AddIfNotNull(CSharpStructureHelpers.CreateBlockSpan( enumDeclaration, enumDeclaration.Identifier, compressEmptyLines: compressEmptyLines, autoCollapse: false, type: BlockTypes.Member, isCollapsible: true)); } // add any leading comments before the end of the type block if (!enumDeclaration.CloseBraceToken.IsMissing) { var leadingTrivia = enumDeclaration.CloseBraceToken.LeadingTrivia; CSharpStructureHelpers.CollectCommentBlockSpans(leadingTrivia, spans); } }
protected override void CollectBlockSpans( EventDeclarationSyntax eventDeclaration, ArrayBuilder <BlockSpan> spans, bool isMetadataAsSource, OptionSet options, CancellationToken cancellationToken) { CSharpStructureHelpers.CollectCommentBlockSpans(eventDeclaration, spans, isMetadataAsSource); // fault tolerance if (eventDeclaration.AccessorList == null || eventDeclaration.AccessorList.IsMissing || eventDeclaration.AccessorList.OpenBraceToken.IsMissing || eventDeclaration.AccessorList.CloseBraceToken.IsMissing) { return; } SyntaxNodeOrToken current = eventDeclaration; var nextSibling = current.GetNextSibling(); // Check IsNode to compress blank lines after this node if it is the last child of the parent. // // Full events are grouped together with event field definitions in Metadata as Source. var compressEmptyLines = isMetadataAsSource && (!nextSibling.IsNode || nextSibling.IsKind(SyntaxKind.EventDeclaration) || nextSibling.IsKind(SyntaxKind.EventFieldDeclaration)); spans.AddIfNotNull(CSharpStructureHelpers.CreateBlockSpan( eventDeclaration, eventDeclaration.Identifier, compressEmptyLines: compressEmptyLines, autoCollapse: true, type: BlockTypes.Member, isCollapsible: true)); }
protected override void CollectBlockSpans( SyntaxToken previousToken, IndexerDeclarationSyntax indexerDeclaration, ref TemporaryArray <BlockSpan> spans, BlockStructureOptions options, CancellationToken cancellationToken) { CSharpStructureHelpers.CollectCommentBlockSpans(indexerDeclaration, ref spans, options); // fault tolerance if (indexerDeclaration.AccessorList == null || indexerDeclaration.AccessorList.IsMissing || indexerDeclaration.AccessorList.OpenBraceToken.IsMissing || indexerDeclaration.AccessorList.CloseBraceToken.IsMissing) { return; } SyntaxNodeOrToken current = indexerDeclaration; var nextSibling = current.GetNextSibling(); // Check IsNode to compress blank lines after this node if it is the last child of the parent. // // Indexers are grouped together with properties in Metadata as Source. var compressEmptyLines = options.IsMetadataAsSource && (!nextSibling.IsNode || nextSibling.IsKind(SyntaxKind.IndexerDeclaration) || nextSibling.IsKind(SyntaxKind.PropertyDeclaration)); spans.AddIfNotNull(CSharpStructureHelpers.CreateBlockSpan( indexerDeclaration, indexerDeclaration.ParameterList.GetLastToken(includeZeroWidth: true), compressEmptyLines: compressEmptyLines, autoCollapse: true, type: BlockTypes.Member, isCollapsible: true)); }
protected override void CollectBlockSpans( TypeDeclarationSyntax typeDeclaration, ref TemporaryArray <BlockSpan> spans, BlockStructureOptionProvider optionProvider, CancellationToken cancellationToken ) { CSharpStructureHelpers.CollectCommentBlockSpans( typeDeclaration, ref spans, optionProvider ); if ( !typeDeclaration.OpenBraceToken.IsMissing && !typeDeclaration.CloseBraceToken.IsMissing ) { var lastToken = typeDeclaration.TypeParameterList == null ? typeDeclaration.Identifier : typeDeclaration.TypeParameterList.GetLastToken(includeZeroWidth: true); SyntaxNodeOrToken current = typeDeclaration; var nextSibling = current.GetNextSibling(); // Check IsNode to compress blank lines after this node if it is the last child of the parent. // // Collapse to Definitions doesn't collapse type nodes, but a Toggle All Outlining would collapse groups // of types to the compressed form of not showing blank lines. All kinds of types are grouped together // in Metadata as Source. var compressEmptyLines = optionProvider.IsMetadataAsSource && (!nextSibling.IsNode || nextSibling.AsNode() is BaseTypeDeclarationSyntax); spans.AddIfNotNull( CSharpStructureHelpers.CreateBlockSpan( typeDeclaration, lastToken, compressEmptyLines: compressEmptyLines, autoCollapse: false, type: BlockTypes.Type, isCollapsible: true ) ); } // add any leading comments before the end of the type block if (!typeDeclaration.CloseBraceToken.IsMissing) { var leadingTrivia = typeDeclaration.CloseBraceToken.LeadingTrivia; CSharpStructureHelpers.CollectCommentBlockSpans(leadingTrivia, ref spans); } }
protected override void CollectBlockSpans( SyntaxToken previousToken, EnumDeclarationSyntax enumDeclaration, ref TemporaryArray <BlockSpan> spans, BlockStructureOptions options, CancellationToken cancellationToken) { CSharpStructureHelpers.CollectCommentBlockSpans(enumDeclaration, ref spans, options); if (!enumDeclaration.OpenBraceToken.IsMissing && !enumDeclaration.CloseBraceToken.IsMissing) { SyntaxNodeOrToken current = enumDeclaration; var nextSibling = current.GetNextSibling(); // Check IsNode to compress blank lines after this node if it is the last child of the parent. // // Whitespace between type declarations is collapsed in Metadata as Source. var compressEmptyLines = options.IsMetadataAsSource && (!nextSibling.IsNode || nextSibling.AsNode() is BaseTypeDeclarationSyntax); spans.AddIfNotNull(CSharpStructureHelpers.CreateBlockSpan( enumDeclaration, enumDeclaration.Identifier, compressEmptyLines: compressEmptyLines, autoCollapse: false, type: BlockTypes.Member, isCollapsible: true)); } // add any leading comments before the end of the type block if (!enumDeclaration.CloseBraceToken.IsMissing) { var leadingTrivia = enumDeclaration.CloseBraceToken.LeadingTrivia; CSharpStructureHelpers.CollectCommentBlockSpans(leadingTrivia, ref spans); } }