public int ValidateBreakpointLocation(IVsTextBuffer pBuffer, int iLine, int iCol, TextSpan[] pCodeSpan) { var textBuffer = _editorAdaptersFactory.GetDataBuffer(pBuffer); if (textBuffer == null) { // Can't resolve the text buffer, let someone else deal with this breakpoint. return(VSConstants.E_NOTIMPL); } var snapshot = textBuffer.CurrentSnapshot; if (!ValidBreakpointLocation(snapshot, iLine, iCol)) { // The point disappeared between sessions. Do not allow a breakpoint here. return(VSConstants.E_FAIL); } var dialogResult = _waitDialogFactory.TryCreateWaitDialog( title: "Determining breakpoint location...", message: "Razor Debugger", async(context) => { var breakpointRange = await _breakpointResolver.TryResolveBreakpointRangeAsync(textBuffer, iLine, iCol, context.CancellationToken); if (breakpointRange == null) { // No applicable breakpoint location. return(VSConstants.E_FAIL); } pCodeSpan[0] = new TextSpan() { iStartIndex = breakpointRange.Start.Character, iStartLine = breakpointRange.Start.Line, iEndIndex = breakpointRange.End.Character, iEndLine = breakpointRange.End.Line, }; return(VSConstants.S_OK); }); if (dialogResult == null) { // Failed to create the dialog at all. return(VSConstants.E_FAIL); } if (dialogResult.Cancelled) { return(VSConstants.E_FAIL); } return(dialogResult.Result); }
public int ValidateBreakpointLocation(IVsTextBuffer pBuffer, int iLine, int iCol, TextSpan[] pCodeSpan) { var textBuffer = _editorAdaptersFactory.GetDataBuffer(pBuffer); if (textBuffer is null) { // Can't resolve the text buffer, let someone else deal with this breakpoint. return(VSConstants.E_NOTIMPL); } var snapshot = textBuffer.CurrentSnapshot; if (!ValidateLocation(snapshot, iLine, iCol)) { // The point disappeared between sessions. Do not allow a breakpoint here. return(VSConstants.E_FAIL); } var breakpointRange = _uiThreadOperationExecutor.Execute( title: "Determining breakpoint location...", description: "Razor Debugger", allowCancellation: true, showProgress: true, (cancellationToken) => _breakpointResolver.TryResolveBreakpointRangeAsync(textBuffer, iLine, iCol, cancellationToken), _joinableTaskFactory); if (breakpointRange is null) { // Failed to create the dialog at all or no applicable breakpoint location. return(VSConstants.E_FAIL); } pCodeSpan[0] = new TextSpan() { iStartIndex = breakpointRange.Start.Character, iStartLine = breakpointRange.Start.Line, iEndIndex = breakpointRange.End.Character, iEndLine = breakpointRange.End.Line, }; return(VSConstants.S_OK); }