-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gh-4] Initial version of breakpoint overlays.
- Loading branch information
Showing
20 changed files
with
285 additions
and
50 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 10 additions & 4 deletions
14
...reakpoints/BreakpointExtraDataProvider.cs → ...r/Breakpoints/BreakpointExtraDataStore.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
ExceptionBreaker/Breakpoints/Glyphs/BreakpointGlyphFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Media.Imaging; | ||
using Microsoft.VisualStudio.Text.Editor; | ||
using Microsoft.VisualStudio.Text.Formatting; | ||
|
||
namespace ExceptionBreaker.Breakpoints.Glyphs { | ||
public class BreakpointGlyphFactory : IGlyphFactory { | ||
public const string Name = "ExceptionBreaker.BreakpointGlyphFactory"; | ||
private const int OverlayGlyphSize = 9; | ||
private readonly double _breakpointGlyphSize; | ||
|
||
private readonly BitmapImage _image; | ||
|
||
public BreakpointGlyphFactory(IWpfTextViewMargin margin) { | ||
_breakpointGlyphSize = margin.MarginSize; | ||
|
||
var assemblyName = Assembly.GetExecutingAssembly().GetName().Name; | ||
_image = new BitmapImage(new Uri("pack://application:,,,/" + assemblyName + ";component/Resources/BreakpointOverlay.png")); | ||
_image.Freeze(); | ||
} | ||
|
||
public UIElement GenerateGlyph(IWpfTextViewLine line, IGlyphTag tag) { | ||
if (!(tag is BreakpointTag)) | ||
return null; | ||
|
||
return new Image { | ||
Source = _image, | ||
Margin = new Thickness { | ||
Left = _breakpointGlyphSize - OverlayGlyphSize, | ||
Top = _breakpointGlyphSize - OverlayGlyphSize | ||
}, | ||
Width = 9, | ||
Height = 9 | ||
}; | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
ExceptionBreaker/Breakpoints/Glyphs/BreakpointGlyphFactoryProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.ComponentModel.Composition; | ||
using Microsoft.VisualStudio.Text.Editor; | ||
using Microsoft.VisualStudio.Text.Tagging; | ||
using Microsoft.VisualStudio.Utilities; | ||
|
||
namespace ExceptionBreaker.Breakpoints.Glyphs { | ||
[Export(typeof(IGlyphFactoryProvider))] | ||
[Name(BreakpointGlyphFactory.Name)] | ||
[Order(After = "VsTextMarker")] | ||
[ContentType("code")] | ||
[TextViewRole(PredefinedTextViewRoles.Debuggable)] | ||
[TagType(typeof(BreakpointTag))] | ||
public class BreakpointGlyphFactoryProvider : IGlyphFactoryProvider { | ||
public IGlyphFactory GetGlyphFactory(IWpfTextView view, IWpfTextViewMargin margin) { | ||
return new BreakpointGlyphFactory(margin); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Microsoft.VisualStudio.Text.Editor; | ||
|
||
namespace ExceptionBreaker.Breakpoints.Glyphs { | ||
public class BreakpointTag : IGlyphTag { | ||
public BreakpointExtraData BreakpointExtraData { get; private set; } | ||
|
||
public BreakpointTag(BreakpointExtraData breakpointExtraData) { | ||
BreakpointExtraData = breakpointExtraData; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.VisualStudio.Text; | ||
using Microsoft.VisualStudio.Text.Tagging; | ||
|
||
namespace ExceptionBreaker.Breakpoints.Glyphs { | ||
public class BreakpointTagger : ITagger<BreakpointTag> { | ||
private readonly ITextDocument _document; | ||
private readonly BreakpointFinder _finder; | ||
private readonly BreakpointExtraDataStore _extraDataStore; | ||
|
||
public BreakpointTagger(ITextDocument document, BreakpointFinder finder, BreakpointExtraDataStore extraDataStore) { | ||
_document = document; | ||
_finder = finder; | ||
_extraDataStore = extraDataStore; | ||
} | ||
|
||
public IEnumerable<ITagSpan<BreakpointTag>> GetTags(NormalizedSnapshotSpanCollection spans) { | ||
foreach (var span in spans) { | ||
var breakpoint = _finder.GetBreakpointFromSpan(span, _document); | ||
if (breakpoint == null) | ||
continue; | ||
|
||
var extraData = _extraDataStore.GetData(breakpoint); | ||
if (extraData.ExceptionBreakChange == ExceptionBreakChange.NoChange) | ||
continue; | ||
|
||
yield return new TagSpan<BreakpointTag>(new SnapshotSpan(span.Start, span.Length), new BreakpointTag(extraData)); | ||
} | ||
} | ||
|
||
public event EventHandler<SnapshotSpanEventArgs> TagsChanged; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
ExceptionBreaker/Breakpoints/Glyphs/BreakpointTaggerProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.Composition; | ||
using System.Linq; | ||
using System.Windows.Media.TextFormatting; | ||
using Microsoft.VisualStudio.Text; | ||
using Microsoft.VisualStudio.Text.Editor; | ||
using Microsoft.VisualStudio.Text.Tagging; | ||
using Microsoft.VisualStudio.Utilities; | ||
|
||
namespace ExceptionBreaker.Breakpoints.Glyphs { | ||
[Export(typeof(ITaggerProvider))] | ||
[Order(After = "VsTextMarker")] | ||
[ContentType("code")] | ||
[TextViewRole(PredefinedTextViewRoles.Debuggable)] | ||
[TagType(typeof(BreakpointTag))] | ||
public class BreakpointTaggerProvider : ITaggerProvider { | ||
private readonly BreakpointFinder _finder; | ||
private readonly BreakpointExtraDataStore _extraDataStore; | ||
|
||
[ImportingConstructor] | ||
public BreakpointTaggerProvider(BreakpointFinder finder, BreakpointExtraDataStore extraDataStore) { | ||
_finder = finder; | ||
_extraDataStore = extraDataStore; | ||
} | ||
|
||
public ITagger<T> CreateTagger<T>(ITextBuffer buffer) where T : ITag { | ||
var document = (ITextDocument)buffer.Properties[typeof(ITextDocument)]; | ||
return (ITagger<T>)new BreakpointTagger(document, _finder, _extraDataStore); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.Composition; | ||
using System.Linq; | ||
using EnvDTE; | ||
using Microsoft.VisualStudio.Shell; | ||
|
||
namespace ExceptionBreaker.Core { | ||
[Export] | ||
public class DTEImport { | ||
[ImportingConstructor] | ||
public DTEImport(SVsServiceProvider serviceProvider) { | ||
DTE = (DTE) serviceProvider.GetService(typeof (DTE)); | ||
} | ||
|
||
public DTE DTE { get; private set; } | ||
} | ||
} |
Oops, something went wrong.