コード例 #1
0
 public RoslynOutliningRegionTag(
     ITextEditorFactoryService textEditorFactoryService,
     IProjectionBufferFactoryService projectionBufferFactoryService,
     IEditorOptionsFactoryService editorOptionsFactoryService,
     ITextSnapshot snapshot,
     BlockSpan blockSpan)
 {
     _state = new BlockTagState(
         textEditorFactoryService, projectionBufferFactoryService,
         editorOptionsFactoryService, snapshot, blockSpan);
 }
コード例 #2
0
ファイル: BlockSpanTests.cs プロジェクト: orthoxerox/roslyn
        public void TestToStringWithoutHintSpan()
        {
            var span = TextSpan.FromBounds(0, 1);
            var bannerText = "Foo";
            var autoCollapse = true;

            var outliningRegion = new BlockSpan(true, span, 
                bannerText: bannerText, autoCollapse: autoCollapse);

            Assert.Equal("{Span=[0..1), BannerText=\"Foo\", AutoCollapse=True, IsDefaultCollapsed=False}", outliningRegion.ToString());
        }
コード例 #3
0
ファイル: BlockSpanTests.cs プロジェクト: XieShuquan/roslyn
        public void TestToStringWithHintSpan()
        {
            var span = TextSpan.FromBounds(0, 1);
            var hintSpan = TextSpan.FromBounds(2, 3);
            var bannerText = "Foo";
            var autoCollapse = true;

            var outliningRegion = new BlockSpan(
                isCollapsible: true, textSpan: span, hintSpan: hintSpan,
                type: BlockTypes.Nonstructural, bannerText: bannerText, autoCollapse: autoCollapse);

            Assert.Equal("{Span=[0..1), HintSpan=[2..3), BannerText=\"Foo\", AutoCollapse=True, IsDefaultCollapsed=False}", outliningRegion.ToString());
        }
コード例 #4
0
        public RoslynOutliningRegionTag(
            ITextEditorFactoryService textEditorFactoryService,
            IProjectionBufferFactoryService projectionBufferFactoryService,
            IEditorOptionsFactoryService editorOptionsFactoryService,
            ITextSnapshot snapshot,
            BlockSpan outliningSpan)
        {
            _textEditorFactoryService = textEditorFactoryService;
            _projectionBufferFactoryService = projectionBufferFactoryService;
            _editorOptionsFactoryService = editorOptionsFactoryService;
            _subjectBuffer = snapshot.TextBuffer;
            BlockSpan = outliningSpan;

            _hintSpan = snapshot.CreateTrackingSpan(BlockSpan.HintSpan.ToSpan(), SpanTrackingMode.EdgeExclusive);
        }
コード例 #5
0
ファイル: BlockSpanTests.cs プロジェクト: orthoxerox/roslyn
        public void TestProperties()
        {
            var span = TextSpan.FromBounds(0, 1);
            var hintSpan = TextSpan.FromBounds(2, 3);
            var bannerText = "Foo";
            var autoCollapse = true;

            var outliningRegion = new BlockSpan(true, span, hintSpan, 
                bannerText: bannerText, autoCollapse: autoCollapse);

            Assert.Equal(span, outliningRegion.TextSpan);
            Assert.Equal(hintSpan, outliningRegion.HintSpan);
            Assert.Equal(bannerText, outliningRegion.BannerText);
            Assert.Equal(autoCollapse, outliningRegion.AutoCollapse);
        }
コード例 #6
0
ファイル: BlockSpanTests.cs プロジェクト: XieShuquan/roslyn
        public void TestProperties()
        {
            var span = TextSpan.FromBounds(0, 1);
            var hintSpan = TextSpan.FromBounds(2, 3);
            var bannerText = "Foo";
            var autoCollapse = true;

            var outliningRegion = new BlockSpan(
                isCollapsible: true, textSpan: span, hintSpan: hintSpan,
                type: BlockTypes.Nonstructural, bannerText: bannerText, autoCollapse: autoCollapse);

            Assert.Equal(span, outliningRegion.TextSpan);
            Assert.Equal(hintSpan, outliningRegion.HintSpan);
            Assert.Equal(bannerText, outliningRegion.BannerText);
            Assert.Equal(autoCollapse, outliningRegion.AutoCollapse);
        }
コード例 #7
0
        internal static BlockSpan UpdateBlockSpan(BlockSpan blockSpan,
                                                  bool showIndentGuidesForCodeLevelConstructs,
                                                  bool showIndentGuidesForDeclarationLevelConstructs,
                                                  bool showIndentGuidesForCommentsAndPreprocessorRegions,
                                                  bool showOutliningForCodeLevelConstructs,
                                                  bool showOutliningForDeclarationLevelConstructs,
                                                  bool showOutliningForCommentsAndPreprocessorRegions)
        {
            var type = blockSpan.Type;

            var isTopLevel    = BlockTypes.IsDeclarationLevelConstruct(type);
            var isMemberLevel = BlockTypes.IsCodeLevelConstruct(type);
            var isComment     = BlockTypes.IsCommentOrPreprocessorRegion(type);

            if (!showIndentGuidesForDeclarationLevelConstructs && isTopLevel)
            {
                type = BlockTypes.Nonstructural;
            }
            else if (!showIndentGuidesForCodeLevelConstructs && isMemberLevel)
            {
                type = BlockTypes.Nonstructural;
            }
            else if (!showIndentGuidesForCommentsAndPreprocessorRegions && isComment)
            {
                type = BlockTypes.Nonstructural;
            }

            var isCollapsible = blockSpan.IsCollapsible;

            if (isCollapsible)
            {
                if (!showOutliningForDeclarationLevelConstructs && isTopLevel)
                {
                    isCollapsible = false;
                }
                else if (!showOutliningForCodeLevelConstructs && isMemberLevel)
                {
                    isCollapsible = false;
                }
                else if (!showOutliningForCommentsAndPreprocessorRegions && isComment)
                {
                    isCollapsible = false;
                }
            }

            return(blockSpan.With(type: type, isCollapsible: isCollapsible));
        }
コード例 #8
0
ファイル: RoslynBlockTag.cs プロジェクト: XieShuquan/roslyn
 public RoslynBlockTag(
     ITextEditorFactoryService textEditorFactoryService,
     IProjectionBufferFactoryService projectionBufferFactoryService,
     IEditorOptionsFactoryService editorOptionsFactoryService,
     IBlockTag parent,
     ITextSnapshot snapshot,
     BlockSpan blockSpan) :
     base(span: blockSpan.TextSpan.ToSnapshotSpan(snapshot),
          statementSpan: blockSpan.HintSpan.ToSnapshotSpan(snapshot),
          parent: parent,
          type: blockSpan.Type,
          isCollapsible: blockSpan.IsCollapsible,
          isDefaultCollapsed: blockSpan.IsDefaultCollapsed,
          isImplementation: blockSpan.AutoCollapse,
          collapsedForm: null,
          collapsedHintForm: null)
 {
     _state = new BlockTagState(
         textEditorFactoryService, projectionBufferFactoryService,
         editorOptionsFactoryService, snapshot, blockSpan);
     Level = parent == null ? 0 : parent.Level + 1;
 }
コード例 #9
0
 public void AddBlockSpan(BlockSpan span)
 {
     _spans.Add(span);
 }
コード例 #10
0
 public void AddBlockSpan(BlockSpan span)
 => _spans.Add(span);
コード例 #11
0
 internal static void AssertRegion(BlockSpan expected, BlockSpan actual)
 {
     Assert.Equal(expected.TextSpan.Start, actual.TextSpan.Start);
     Assert.Equal(expected.TextSpan.End, actual.TextSpan.End);
     Assert.Equal(expected.HintSpan.Start, actual.HintSpan.Start);
     Assert.Equal(expected.HintSpan.End, actual.HintSpan.End);
     Assert.Equal(expected.BannerText, actual.BannerText);
     Assert.Equal(expected.AutoCollapse, actual.AutoCollapse);
     Assert.Equal(expected.IsDefaultCollapsed, actual.IsDefaultCollapsed);
 }
コード例 #12
0
        internal static BlockSpan UpdateBlockSpan(BlockSpan blockSpan,
            bool showIndentGuidesForCodeLevelConstructs,
            bool showIndentGuidesForDeclarationLevelConstructs,
            bool showIndentGuidesForCommentsAndPreprocessorRegions,
            bool showOutliningForCodeLevelConstructs,
            bool showOutliningForDeclarationLevelConstructs,
            bool showOutliningForCommentsAndPreprocessorRegions)
        {
            var type = blockSpan.Type;

            var isTopLevel = BlockTypes.IsDeclarationLevelConstruct(type);
            var isMemberLevel = BlockTypes.IsCodeLevelConstruct(type);
            var isComment = BlockTypes.IsCommentOrPreprocessorRegion(type);

            if (!showIndentGuidesForDeclarationLevelConstructs && isTopLevel)
            {
                type = BlockTypes.Nonstructural;
            }
            else if (!showIndentGuidesForCodeLevelConstructs && isMemberLevel)
            {
                type = BlockTypes.Nonstructural;
            }
            else if (!showIndentGuidesForCommentsAndPreprocessorRegions && isComment)
            {
                type = BlockTypes.Nonstructural;
            }

            var isCollapsible = blockSpan.IsCollapsible;
            if (isCollapsible)
            {
                if (!showOutliningForDeclarationLevelConstructs && isTopLevel)
                {
                    isCollapsible = false;
                }
                else if (!showOutliningForCodeLevelConstructs && isMemberLevel)
                {
                    isCollapsible = false;
                }
                else if (!showOutliningForCommentsAndPreprocessorRegions && isComment)
                {
                    isCollapsible = false;
                }
            }

            return blockSpan.With(type: type, isCollapsible: isCollapsible);
        }