次の方法で共有


IVsLanguageDebugInfo.ValidateBreakpointLocation Method

Validates the given position as a place to set a breakpoint.

Namespace:  Microsoft.VisualStudio.TextManager.Interop
Assembly:  Microsoft.VisualStudio.TextManager.Interop (in Microsoft.VisualStudio.TextManager.Interop.dll)

Syntax

'宣言
Function ValidateBreakpointLocation ( _
    pBuffer As IVsTextBuffer, _
    iLine As Integer, _
    iCol As Integer, _
    <OutAttribute> pCodeSpan As TextSpan() _
) As Integer
int ValidateBreakpointLocation(
    IVsTextBuffer pBuffer,
    int iLine,
    int iCol,
    TextSpan[] pCodeSpan
)
int ValidateBreakpointLocation(
    [InAttribute] IVsTextBuffer^ pBuffer, 
    [InAttribute] int iLine, 
    [InAttribute] int iCol, 
    [OutAttribute] array<TextSpan>^ pCodeSpan
)
abstract ValidateBreakpointLocation : 
        pBuffer:IVsTextBuffer * 
        iLine:int * 
        iCol:int * 
        pCodeSpan:TextSpan[] byref -> int 
function ValidateBreakpointLocation(
    pBuffer : IVsTextBuffer, 
    iLine : int, 
    iCol : int, 
    pCodeSpan : TextSpan[]
) : int

Parameters

  • iLine
    Type: System.Int32
    [in] Number of the line containing the breakpoint.
  • iCol
    Type: System.Int32
    [in] Number of the column containing the breakpoint.

Return Value

Type: System.Int32
If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From textmgr.idl:

HRESULT IVsLanguageDebugInfo::ValidateBreakpointLocation(
   [in] IVsTextBuffer *pBuffer, 
   [in] long iLine, 
   [in] long iCol, ]
   [out] TextSpan *pCodeSpan
);

This method validates the given position as a place to set a breakpoint without having to load the debugger. If the location is valid, then the span is filled in with the extent of the statement at which execution would stop. If the position is known to not contain code, this method returns S_FALSE. If the method fails, the breakpoint is set, pending validation during the debugger startup.

Warning

Even if you do not intend to support the ValidateBreakpointLocation method but your language does support breakpoints, you must implement this method and return a span that contains the specified line and column; otherwise, breakpoints cannot be set anywhere except line 1. You can return E_NOTIMPL to indicate that you do not otherwise support this method but the span must always be set. The example shows how this can be done.

Examples

Here is a partial example of how this method can be implemented. This example shows how to set the span to a default value so breakpoints work properly.

using Microsoft.VisualStudio;
using Microsoft.VisualStudio.TextManager.Interop;

namespace MyLanguagePackage
{
    public class MyLanguageService : IVsLanguageInfo, IVsLanguageDebugInfo
    {
        public int ValidateBreakpointLocation(IVsTextBuffer buffer,
                                              int line,
                                              int col,
                                              TextSpan[] pCodeSpan)
        {
            int retval = VSConstants.E_NOTIMPL;
            if (pCodeSpan != null)
            {
                // Make sure the span is set to at least the current
                // position by default.
                pCodeSpan[0].iStartLine = line;
                pCodeSpan[0].iStartIndex = col;
                pCodeSpan[0].iEndLine = line;
                pCodeSpan[0].iEndIndex = col;
            }
            if (buffer != null)
            {
                // Use your parser to obtain the span that describes the
                // the code containing the specified position.  If the span
                // is valid, return S_OK with the valid span; otherwise,
                // returns S_FALSE (leaving the default span alone).
                //
                // GetCodeSpanForLocation() is a helper function not shown.
                retval = VSConstants.S_FALSE;
                TextSpan span = new TextSpan();
                if (GetCodeSpanForLocation(buffer, line, col, out span))
                {
                    pCodeSpan[0] = span;
                    retval = VSConstants.S_OK;
                }
            }
            return retval;
        }
    }
}

.NET Framework Security

See Also

Reference

IVsLanguageDebugInfo Interface

Microsoft.VisualStudio.TextManager.Interop Namespace