src/Misc/EFTools/DesignXmlCore/VisualStudio/VSHelpers.cs
/// <summary>
///     Navigates to the document and places the selection at the specified location.
/// </summary>
Navigates to the document and places the selection at the specified location.
Navigates to the document and places the selection at the specified location .
[SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "Microsoft.VisualStudio.TextManager.Interop.IVsTextManager.NavigateToLineAndColumn(Microsoft.VisualStudio.TextManager.Interop.IVsTextBuffer,System.Guid@,System.Int32,System.Int32,System.Int32,System.Int32)")]
        internal static void TextBufferNavigateTo(
            IServiceProvider serviceProvider, object docData, Guid logicalViewGuid, int lineNumber, int columnNumber)
        {
            var buffer = docData as VsTextBuffer;
            if (buffer == null)
            {
                var bufferProvider = docData as IVsTextBufferProvider;
                if (bufferProvider != null)
                {
                    IVsTextLines lines;
                    NativeMethods.ThrowOnFailure(bufferProvider.GetTextBuffer(out lines));
                    buffer = lines as VsTextBuffer;
                    Debug.Assert(buffer != null, "IVsTextLines does not implement IVsTextBuffer");
                }
            }
            if (buffer == null)
            {
                return;
            }
            var mgr = serviceProvider.GetService(typeof(VsTextManagerClass)) as IVsTextManager;
            if (mgr == null)
            {
                return;
            }
            var logicalView = logicalViewGuid;
            mgr.NavigateToLineAndColumn(buffer, ref logicalView, lineNumber, columnNumber, lineNumber, columnNumber);
        }
[ SuppressMessage ( " " , " " , MessageId = " " ) ] internal static void TextBufferNavigateTo ( IServiceProvider serviceProvider , object docData , Guid logicalViewGuid , int lineNumber , int columnNumber ) { var buffer = docData as VsTextBuffer ; if ( buffer == null ) { var bufferProvider = docData as IVsTextBufferProvider ; if ( bufferProvider != null ) { IVsTextLines lines ; NativeMethods . ThrowOnFailure ( bufferProvider . GetTextBuffer ( out lines ) ) ; buffer = lines as VsTextBuffer ; Debug . Assert ( buffer != null , " " ) ; } } if ( buffer == null ) { return ; } var mgr = serviceProvider . GetService ( typeof ( VsTextManagerClass ) ) as IVsTextManager ; if ( mgr == null ) { return ; } var logicalView = logicalViewGuid ; mgr . NavigateToLineAndColumn ( buffer , ref logicalView , lineNumber , columnNumber , lineNumber , columnNumber ) ; }
Navigates to the document and places the selection at the specified location.
Navigates to the document and places the selection at the specified location .
// get the VsTextBuffer // finally, perform the navigation.
serviceProvider
IServiceProvider
docData
object
logicalViewGuid
Guid
lineNumber
int
columnNumber
int