public RoslynOutliningRegionTag( ITextEditorFactoryService textEditorFactoryService, IProjectionBufferFactoryService projectionBufferFactoryService, IEditorOptionsFactoryService editorOptionsFactoryService, ITextSnapshot snapshot, BlockSpan blockSpan) { _state = new BlockTagState( textEditorFactoryService, projectionBufferFactoryService, editorOptionsFactoryService, snapshot, blockSpan); }
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()); }
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()); }
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); }
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); }
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); }
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)); }
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; }
public void AddBlockSpan(BlockSpan span) { _spans.Add(span); }
public void AddBlockSpan(BlockSpan span) => _spans.Add(span);
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); }
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); }