예제 #1
0
        public void TestConstructorMissingCloseParenAndBody()
        {
            // Expected behavior is that the class should be outlined, but the constructor should not.

            var tree = ParseLines("class C",
                                  "{",
                                  "  C(",
                                  "}");

            var typeDecl         = tree.DigToFirstTypeDeclaration();
            var typeDeclOutliner = new TypeDeclarationOutliner();

            var typeDeclRegions = typeDeclOutliner.GetOutliningSpans(typeDecl, CancellationToken.None).ToList();

            Assert.Equal(1, typeDeclRegions.Count);

            var expectedTypeDeclRegion =
                new OutliningSpan(
                    TextSpan.FromBounds(7, 19),
                    TextSpan.FromBounds(0, 19),
                    CSharpOutliningHelpers.Ellipsis,
                    autoCollapse: false);

            AssertRegion(expectedTypeDeclRegion, typeDeclRegions[0]);

            var consDecl        = typeDecl.DigToFirstNodeOfType <ConstructorDeclarationSyntax>();
            var consDeclRegions = GetRegions(consDecl).ToList();

            Assert.Equal(0, consDeclRegions.Count);
        }
        internal override IEnumerable <OutliningSpan> GetRegions(TypeDeclarationSyntax typeDecl)
        {
            var outliner = new TypeDeclarationOutliner();

            return(outliner.GetOutliningSpans(typeDecl, CancellationToken.None).WhereNotNull());
        }