Ejemplo n.º 1
0
 protected override void CollectBlockSpans(
     EventFieldDeclarationSyntax eventFieldDeclaration,
     ImmutableArray <BlockSpan> .Builder spans,
     CancellationToken cancellationToken)
 {
     CSharpStructureHelpers.CollectCommentRegions(eventFieldDeclaration, spans);
 }
Ejemplo n.º 2
0
        protected override void CollectBlockSpans(
            TypeDeclarationSyntax typeDeclaration,
            ImmutableArray <BlockSpan> .Builder spans,
            CancellationToken cancellationToken)
        {
            CSharpStructureHelpers.CollectCommentRegions(typeDeclaration, spans);

            if (!typeDeclaration.OpenBraceToken.IsMissing &&
                !typeDeclaration.CloseBraceToken.IsMissing)
            {
                var lastToken = typeDeclaration.TypeParameterList == null
                    ? typeDeclaration.Identifier
                    : typeDeclaration.TypeParameterList.GetLastToken(includeZeroWidth: true);

                spans.Add(CSharpStructureHelpers.CreateRegion(
                              typeDeclaration,
                              lastToken,
                              autoCollapse: false));
            }

            // add any leading comments before the end of the type block
            if (!typeDeclaration.CloseBraceToken.IsMissing)
            {
                var leadingTrivia = typeDeclaration.CloseBraceToken.LeadingTrivia;
                CSharpStructureHelpers.CollectCommentRegions(leadingTrivia, spans);
            }
        }
Ejemplo n.º 3
0
        protected override void CollectBlockSpans(
            EventDeclarationSyntax eventDeclaration,
            ImmutableArray <BlockSpan> .Builder spans,
            CancellationToken cancellationToken)
        {
            CSharpStructureHelpers.CollectCommentRegions(eventDeclaration, spans);

            // fault tolerance
            if (eventDeclaration.AccessorList.IsMissing ||
                eventDeclaration.AccessorList.OpenBraceToken.IsMissing ||
                eventDeclaration.AccessorList.CloseBraceToken.IsMissing)
            {
                return;
            }

            spans.Add(CSharpStructureHelpers.CreateRegion(
                          eventDeclaration,
                          eventDeclaration.Identifier,
                          autoCollapse: true));
        }
        protected override void CollectBlockSpans(
            ConversionOperatorDeclarationSyntax operatorDeclaration,
            ImmutableArray <BlockSpan> .Builder spans,
            CancellationToken cancellationToken)
        {
            CSharpStructureHelpers.CollectCommentRegions(operatorDeclaration, spans);

            // fault tolerance
            if (operatorDeclaration.Body == null ||
                operatorDeclaration.Body.OpenBraceToken.IsMissing ||
                operatorDeclaration.Body.CloseBraceToken.IsMissing)
            {
                return;
            }

            spans.Add(CSharpStructureHelpers.CreateRegion(
                          operatorDeclaration,
                          operatorDeclaration.ParameterList.GetLastToken(includeZeroWidth: true),
                          autoCollapse: true));
        }
        protected override void CollectBlockSpans(
            AccessorDeclarationSyntax accessorDeclaration,
            ImmutableArray <BlockSpan> .Builder spans,
            CancellationToken cancellationToken)
        {
            CSharpStructureHelpers.CollectCommentRegions(accessorDeclaration, spans);

            // fault tolerance
            if (accessorDeclaration.Body == null ||
                accessorDeclaration.Body.OpenBraceToken.IsMissing ||
                accessorDeclaration.Body.CloseBraceToken.IsMissing)
            {
                return;
            }

            spans.Add(CSharpStructureHelpers.CreateRegion(
                          accessorDeclaration,
                          accessorDeclaration.Keyword,
                          autoCollapse: true));
        }
        protected override void CollectBlockSpans(
            EnumDeclarationSyntax enumDeclaration,
            ImmutableArray <BlockSpan> .Builder spans,
            CancellationToken cancellationToken)
        {
            CSharpStructureHelpers.CollectCommentRegions(enumDeclaration, spans);

            if (!enumDeclaration.OpenBraceToken.IsMissing &&
                !enumDeclaration.CloseBraceToken.IsMissing)
            {
                spans.Add(CSharpStructureHelpers.CreateRegion(
                              enumDeclaration,
                              enumDeclaration.Identifier,
                              autoCollapse: false));
            }

            // add any leading comments before the end of the type block
            if (!enumDeclaration.CloseBraceToken.IsMissing)
            {
                var leadingTrivia = enumDeclaration.CloseBraceToken.LeadingTrivia;
                CSharpStructureHelpers.CollectCommentRegions(leadingTrivia, spans);
            }
        }
Ejemplo n.º 7
0
        protected override void CollectBlockSpans(
            CompilationUnitSyntax compilationUnit,
            ImmutableArray <BlockSpan> .Builder spans,
            CancellationToken cancellationToken)
        {
            CSharpStructureHelpers.CollectCommentRegions(compilationUnit, spans);

            // extern aliases and usings are outlined in a single region
            var externsAndUsings = new List <SyntaxNode>();

            externsAndUsings.AddRange(compilationUnit.Externs);
            externsAndUsings.AddRange(compilationUnit.Usings);
            externsAndUsings.Sort((node1, node2) => node1.SpanStart.CompareTo(node2.SpanStart));

            spans.Add(CSharpStructureHelpers.CreateRegion(externsAndUsings, autoCollapse: true));

            if (compilationUnit.Usings.Count > 0 ||
                compilationUnit.Externs.Count > 0 ||
                compilationUnit.Members.Count > 0 ||
                compilationUnit.AttributeLists.Count > 0)
            {
                CSharpStructureHelpers.CollectCommentRegions(compilationUnit.EndOfFileToken.LeadingTrivia, spans);
            }
        }
Ejemplo n.º 8
0
        protected override void CollectBlockSpans(
            NamespaceDeclarationSyntax namespaceDeclaration,
            ImmutableArray <BlockSpan> .Builder spans,
            CancellationToken cancellationToken)
        {
            // add leading comments
            CSharpStructureHelpers.CollectCommentRegions(namespaceDeclaration, spans);

            if (!namespaceDeclaration.OpenBraceToken.IsMissing &&
                !namespaceDeclaration.CloseBraceToken.IsMissing)
            {
                spans.Add(CSharpStructureHelpers.CreateRegion(
                              namespaceDeclaration,
                              namespaceDeclaration.Name.GetLastToken(includeZeroWidth: true),
                              autoCollapse: false));
            }

            // extern aliases and usings are outlined in a single region
            var externsAndUsings = Enumerable.Union <SyntaxNode>(namespaceDeclaration.Externs, namespaceDeclaration.Usings)
                                   .OrderBy(node => node.SpanStart)
                                   .ToList();

            // add any leading comments before the extern aliases and usings
            if (externsAndUsings.Count > 0)
            {
                CSharpStructureHelpers.CollectCommentRegions(externsAndUsings.First(), spans);
            }

            spans.Add(CSharpStructureHelpers.CreateRegion(externsAndUsings, autoCollapse: true));

            // finally, add any leading comments before the end of the namespace block
            if (!namespaceDeclaration.CloseBraceToken.IsMissing)
            {
                CSharpStructureHelpers.CollectCommentRegions(namespaceDeclaration.CloseBraceToken.LeadingTrivia, spans);
            }
        }