public int GetProximityExpressions(IVsTextBuffer pBuffer, int iLine, int iCol, int cLines, out IVsEnumBSTR ppEnum)
        {
            var textBuffer = _editorAdaptersFactory.GetDataBuffer(pBuffer);

            if (textBuffer == null)
            {
                // Can't resolve the text buffer, let someone else deal with this breakpoint.
                ppEnum = null;
                return(VSConstants.E_NOTIMPL);
            }

            var snapshot = textBuffer.CurrentSnapshot;

            if (!ValidateLocation(snapshot, iLine, iCol))
            {
                // The point disappeared between sessions. Do not evaluate proximity expressions here.
                ppEnum = null;
                return(VSConstants.E_FAIL);
            }

            var dialogResult = _waitDialogFactory.TryCreateWaitDialog(
                title: "Determining proximity expressions...",
                message: "Razor Debugger",
                async(context) =>
            {
                var proximityExpressions = await _proximityExpressionResolver.TryResolveProximityExpressionsAsync(textBuffer, iLine, iCol, context.CancellationToken).ConfigureAwait(false);
                return(proximityExpressions);
            });

            if (dialogResult == null)
            {
                // Failed to create the dialog at all.
                ppEnum = null;
                return(VSConstants.E_FAIL);
            }

            if (dialogResult.Cancelled)
            {
                ppEnum = null;
                return(VSConstants.E_FAIL);
            }

            if (dialogResult.Result == null)
            {
                ppEnum = null;
                return(VSConstants.E_FAIL);
            }

            ppEnum = new VsEnumBSTR(dialogResult.Result);
            return(VSConstants.S_OK);
        }
        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);
        }