forked from killswitch1111/powerguivsx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugEventManager.cs
More file actions
69 lines (57 loc) · 2.13 KB
/
Copy pathDebugEventManager.cs
File metadata and controls
69 lines (57 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
using System.Management.Automation.Runspaces;
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.Debugger.Interop;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio;
using PowerShellTools.DebugEngine;
namespace PowerShellTools
{
/// <summary>
/// Manages events coming from the debug engine.
/// </summary>
public class DebugEventManager : IVsDebuggerEvents, IDebugEventCallback2
{
private Runspace _runspace;
private List<PendingBreakpoint> _breakpoints;
public DebugEventManager(Runspace runspace)
{
_runspace = runspace;
_breakpoints = new List<PendingBreakpoint>();
var dte2 = Package.GetGlobalService(typeof(DTE)) as DTE2;
foreach (Breakpoint bp in dte2.Debugger.Breakpoints)
{
if (bp.File.ToLower().EndsWith(".ps1"))
{
var pbp = new PendingBreakpoint
{
BreakpointType = BreakpointType.Line,
Column = bp.FileColumn,
Line = bp.FileLine,
Context = bp.File,
Language = bp.Language
};
_breakpoints.Add(pbp);
}
}
}
#region Methods
public int OnModeChange(DBGMODE dbgmodeNew)
{
return VSConstants.S_OK;
}
public int Event(IDebugEngine2 pEngine, IDebugProcess2 pProcess, IDebugProgram2 pProgram, IDebugThread2 pThread, IDebugEvent2 pEvent, ref Guid riidEvent, uint dwAttrib)
{
if (pEvent is IRunspaceRequest)
{
var request = pEvent as IRunspaceRequest;
request.SetRunspace(_runspace, _breakpoints);
}
return VSConstants.S_OK;
}
#endregion
}
}