Share via


IVsLanguageDebugInfo2.ValidateInstructionpointLocation Method

Definition

Validates the given position as a place to set an instruction or break point.

public:
 int ValidateInstructionpointLocation(Microsoft::VisualStudio::TextManager::Interop::IVsTextBuffer ^ pBuffer, int iLine, int iCol, cli::array <Microsoft::VisualStudio::TextManager::Interop::TextSpan> ^ pCodeSpan);
public:
 int ValidateInstructionpointLocation(Microsoft::VisualStudio::TextManager::Interop::IVsTextBuffer ^ pBuffer, int iLine, int iCol, Platform::Array <Microsoft::VisualStudio::TextManager::Interop::TextSpan> ^ pCodeSpan);
int ValidateInstructionpointLocation(Microsoft::VisualStudio::TextManager::Interop::IVsTextBuffer const & pBuffer, int iLine, int iCol, std::Array <Microsoft::VisualStudio::TextManager::Interop::TextSpan> const & pCodeSpan);
public int ValidateInstructionpointLocation (Microsoft.VisualStudio.TextManager.Interop.IVsTextBuffer pBuffer, int iLine, int iCol, Microsoft.VisualStudio.TextManager.Interop.TextSpan[] pCodeSpan);
abstract member ValidateInstructionpointLocation : Microsoft.VisualStudio.TextManager.Interop.IVsTextBuffer * int * int * Microsoft.VisualStudio.TextManager.Interop.TextSpan[] -> int
Public Function ValidateInstructionpointLocation (pBuffer As IVsTextBuffer, iLine As Integer, iCol As Integer, pCodeSpan As TextSpan()) As Integer

Parameters

pBuffer
IVsTextBuffer

[in] An IVsTextBuffer containing the text to examine.

iLine
Int32

[in] Line to examine.

iCol
Int32

[in] Column to examine.

pCodeSpan
TextSpan[]

[out] Returns a TextSpan object containing the span of the code surrounding the specified location.

Returns

If the method succeeds, it returns S_OK. If the location cannot contain an instruction point, returns S_FALSE; otherwise, returns an error code.

Examples

Here is an implementation of this method that shows how to set the span.

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

namespace MyLanguagePackage  
{  
    public class MyLanguageService  
        : IVsLanguageInfo, IVsLanguageDebugInfo, IVsLanguageDebugInfo2  
    {  
        public int ValidateInstructionpointLocation(IVsTextBuffer buffer,  
                                              int line,  
                                              int col,  
                                              TextSpan2[] 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].iStartLine = span.iStartLine;  
                    pCodeSpan[0].iStartIndex = span.iStartIndex;  
                    pCodeSpan[0].iEndLine = span.iEndLine;  
                    pCodeSpan[0].iEndIndex = span.iEndIndex  
                    retval = VSConstants.S_OK;  
                }  
            }  
            return retval;  
        }  
    }  
}  

Remarks

COM Signature

From textmgr.idl:

HRESULT IVsLanguageDebugInfo2::ValidateInstructionpointLocation(  
   [in] IVsTextBuffer *pBuffer,  
   [in] long iLine,  
   [in] long iCol,  
   [out] TextSpan2 *pCodeSpan  
);  

This method validates the given position as a place to set an instruction point. If the location is valid, and pCodeSpan is non-null, the span is filled in with the extent of the statement at which execution would stop. If the position is known not to contain code, this method returns S_FALSE.

Warning

Even if you do not intend to support the ValidateInstructionpointLocation method, you must implement this method and return a span that contains the specified line and column; otherwise, instruction or 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.

Applies to