Exemple #1
0
        protected override void CollectOutliningSpans(
            TypeDeclarationSyntax typeDeclaration,
            List <OutliningSpan> spans,
            CancellationToken cancellationToken)
        {
            CSharpOutliningHelpers.CollectCommentRegions(typeDeclaration, spans);

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

                spans.Add(CSharpOutliningHelpers.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;
                CSharpOutliningHelpers.CollectCommentRegions(leadingTrivia, spans);
            }
        }
 protected override void CollectOutliningSpans(
     FieldDeclarationSyntax fieldDeclaration,
     List <OutliningSpan> spans,
     CancellationToken cancellationToken)
 {
     CSharpOutliningHelpers.CollectCommentRegions(fieldDeclaration, spans);
 }
Exemple #3
0
        protected override void CollectOutliningSpans(
            AccessorDeclarationSyntax accessorDeclaration,
            List <OutliningSpan> spans,
            CancellationToken cancellationToken)
        {
            CSharpOutliningHelpers.CollectCommentRegions(accessorDeclaration, spans);

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

            spans.Add(CSharpOutliningHelpers.CreateRegion(
                          accessorDeclaration,
                          accessorDeclaration.Keyword,
                          autoCollapse: true));
        }
Exemple #4
0
        protected override void CollectOutliningSpans(
            OperatorDeclarationSyntax operatorDeclaration,
            List <OutliningSpan> spans,
            CancellationToken cancellationToken)
        {
            CSharpOutliningHelpers.CollectCommentRegions(operatorDeclaration, spans);

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

            spans.Add(CSharpOutliningHelpers.CreateRegion(
                          operatorDeclaration,
                          operatorDeclaration.ParameterList.GetLastToken(includeZeroWidth: true),
                          autoCollapse: true));
        }
Exemple #5
0
        protected override void CollectOutliningSpans(
            EventDeclarationSyntax eventDeclaration,
            List <OutliningSpan> spans,
            CancellationToken cancellationToken)
        {
            CSharpOutliningHelpers.CollectCommentRegions(eventDeclaration, spans);

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

            spans.Add(CSharpOutliningHelpers.CreateRegion(
                          eventDeclaration,
                          eventDeclaration.Identifier,
                          autoCollapse: true));
        }
        protected override void CollectOutliningSpans(
            EnumDeclarationSyntax enumDeclaration,
            List <OutliningSpan> spans,
            CancellationToken cancellationToken)
        {
            CSharpOutliningHelpers.CollectCommentRegions(enumDeclaration, spans);

            if (!enumDeclaration.OpenBraceToken.IsMissing &&
                !enumDeclaration.CloseBraceToken.IsMissing)
            {
                spans.Add(CSharpOutliningHelpers.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;
                CSharpOutliningHelpers.CollectCommentRegions(leadingTrivia, spans);
            }
        }
Exemple #7
0
        protected override void CollectOutliningSpans(
            CompilationUnitSyntax compilationUnit,
            List <OutliningSpan> spans,
            CancellationToken cancellationToken)
        {
            CSharpOutliningHelpers.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(CSharpOutliningHelpers.CreateRegion(externsAndUsings, autoCollapse: true));

            if (compilationUnit.Usings.Count > 0 ||
                compilationUnit.Externs.Count > 0 ||
                compilationUnit.Members.Count > 0 ||
                compilationUnit.AttributeLists.Count > 0)
            {
                CSharpOutliningHelpers.CollectCommentRegions(compilationUnit.EndOfFileToken.LeadingTrivia, spans);
            }
        }
        protected override void CollectOutliningSpans(
            NamespaceDeclarationSyntax namespaceDeclaration,
            List <OutliningSpan> spans,
            CancellationToken cancellationToken)
        {
            // add leading comments
            CSharpOutliningHelpers.CollectCommentRegions(namespaceDeclaration, spans);

            if (!namespaceDeclaration.OpenBraceToken.IsMissing &&
                !namespaceDeclaration.CloseBraceToken.IsMissing)
            {
                spans.Add(CSharpOutliningHelpers.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)
            {
                CSharpOutliningHelpers.CollectCommentRegions(externsAndUsings.First(), spans);
            }

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

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