Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System
- Imports System.IO
- Imports System.Text.RegularExpressions
- Imports EnvDTE
- Imports EnvDTE80
- Imports EnvDTE90
- Imports System.Diagnostics
- Public Module CustomMacros
- Sub BreakpointFindResults()
- Dim findResultsWindow As Window = DTE.Windows.Item(Constants.vsWindowKindFindResults1)
- Dim selection As TextSelection
- selection = findResultsWindow.Selection
- selection.SelectAll()
- Dim findResultsReader As New StringReader(selection.Text)
- Dim findResult As String = findResultsReader.ReadLine()
- Dim findResultRegex As New Regex("(?<Path>.*?)((?<LineNumber>d+)):")
- While Not findResult Is Nothing
- Dim findResultMatch As Match = findResultRegex.Match(findResult)
- If findResultMatch.Success Then
- Dim path As String = findResultMatch.Groups.Item("Path").Value
- Dim lineNumber As Integer = Integer.Parse(findResultMatch.Groups.Item("LineNumber").Value)
- Try
- DTE.Debugger.Breakpoints.Add("", path, lineNumber)
- Catch ex As Exception
- ' breakpoints can't be added everywhere
- End Try
- End If
- findResult = findResultsReader.ReadLine()
- End While
- End Sub
- End Module
- Sub BreakPointAtString()
- Try
- DTE.ExecuteCommand("Debug.DisableAllBreakpoints")
- Catch ex As Exception
- End Try
- Dim tsSelection As String = DTE.ActiveDocument.Selection.text
- DTE.ActiveDocument.Selection.selectall()
- Dim AllText As String = DTE.ActiveDocument.Selection.Text
- Dim findResultsReader As New StringReader(AllText)
- Dim findResult As String = findResultsReader.ReadLine()
- Dim lineNum As Integer = 1
- Do Until findResultsReader.Peek = -1
- lineNum += 1
- findResult = findResultsReader.ReadLine()
- If Trim(findResult) = Trim(tsSelection) Then
- DTE.ActiveDocument.Selection.GotoLine(lineNum)
- DTE.ExecuteCommand("Debug.ToggleBreakpoint")
- End If
- Loop
- End Sub
- Error
- ---------------------------
- Error HRESULT E_FAIL has been returned from a call to a COM component.
- ---------------------------
- OK
- ---------------------------
- Sub BreakPointsFromSearch()
- Dim n As Integer = InputBox("Enter the number of search results")
- For i = 1 To n
- DTE.ExecuteCommand("Edit.GoToNextLocation")
- DTE.ExecuteCommand("Debug.ToggleBreakpoint")
- Next
- End Sub
Add Comment
Please, Sign In to add comment