예제 #1
0
 public override Declarations GetDeclarations(MVTI.IVsTextView view,
                                              int line,
                                              int col,
                                              TokenInfo info,
                                              ParseReason reason)
 {
     return null;
 }
 public override int SetTextBuffer(VSTextManagerInterop.IVsTextLines pTextBuffer)
 {
     var hr = VSConstants.S_OK;
     _underlyingBuffer = pTextBuffer;
     return hr;
 }
        // this function is fired only for top most transactions
        //private bool CanCommitTransaction(Transaction tx)
        //{
        //    Debug.Assert(tx != null, "tx should not be null");
        //    if (tx.Context.ContextInfo.ContainsKey(EntityDesignerViewModel.TransactionCancelledGuid))
        //    {
        //        return false;
        //    }
        //    return true;
        //}

        /// <summary>
        ///     Loads the text into the buffer. This method will allocate a VSTextManagerInterop::IVsTextLines will be created
        ///     and loaded with the model
        /// </summary>
        /// <param name="ppTextBuffer">newly created buffer loaded with the model file (in XML string form)</param>
        /// <returns>VSConstants.S_OK if operation successful</returns>
        public override int GetTextBuffer(out VSTextManagerInterop.IVsTextLines ppTextBuffer)
        {
            if (VsBuffer == null)
            {
                if (!CreateAndLoadBuffer())
                {
                    ppTextBuffer = null;
                    return VSConstants.E_FAIL;
                }
            }

            ppTextBuffer = VsBuffer;
            return VSConstants.S_OK;
        }
예제 #4
0
 public override string Goto(VSConstants.VSStd97CmdID cmd, MVTI.IVsTextView textView, int line, int col, out MVTI.TextSpan span)
 {
     span = new MVTI.TextSpan();
     return null;
 }
예제 #5
0
 public override string GetDataTipText(int line, int col, out MVTI.TextSpan span)
 {
     span = new MVTI.TextSpan();
     return null;
 }
예제 #6
0
 public static string GetAllTextFromTextLines(VsTextMgr.IVsTextLines textLines)
 {
     string content = null;
     if (textLines != null)
     {
         int line, column;
         var result = textLines.GetLastLineIndex(out line, out column);
         if (result == VSConstants.S_OK)
         {
             result = textLines.GetLineText(0, 0, line, column, out content);
             if (result != VSConstants.S_OK)
             {
                 content = null;
             }
         }
     }
     return content;
 }
예제 #7
0
        /// <summary>
        ///     Open the file in invisible editor in RDT, and get text buffer from it.
        /// </summary>
        /// <remarks>
        ///     This method created for refactoring usage, refactoring will work on all kinds of
        ///     docdata, not only SqlEditorDocData.  If change this method, please get let LiangZ
        ///     know.
        /// </remarks>
        /// <param name="fullPathFileName">File name with full path.</param>
        /// <param name="project">the hierarchy for the document</param>
        /// <param name="spEditor">The result invisible editor.</param>
        /// <param name="textLines">The result text buffer.</param>
        /// <returns>True, if the file is opened correctly in invisible editor.</returns>
        public bool TryGetTextLinesAndInvisibleEditor(
            string fullPathFileName, VsShell.IVsProject project, out VsShell.IVsInvisibleEditor spEditor,
            out VsTextMgr.IVsTextLines textLines)
        {
            spEditor = null;
            textLines = null;

            // Need to open this file.  Use the invisible editor manager to do so.
            VsShell.IVsInvisibleEditorManager invisibleEditorMgr;
            var ppDocData = IntPtr.Zero;
            bool result;

            var iidIVsTextLines = typeof(VsTextMgr.IVsTextLines).GUID;

            try
            {
                invisibleEditorMgr = _invisibleEditorManager;

                NativeMethods.ThrowOnFailure(
                    invisibleEditorMgr.RegisterInvisibleEditor(
                        fullPathFileName, project, (uint)VsShell._EDITORREGFLAGS.RIEF_ENABLECACHING, null, out spEditor));
                if (spEditor != null)
                {
                    var hr = spEditor.GetDocData(0, ref iidIVsTextLines, out ppDocData);
                    if (hr == VSConstants.S_OK
                        && ppDocData != IntPtr.Zero)
                    {
                        textLines = Marshal.GetTypedObjectForIUnknown(ppDocData, typeof(VsTextMgr.IVsTextLines)) as VsTextMgr.IVsTextLines;
                        result = true;
                    }
                    else
                    {
                        result = false;
                    }
                }
                else
                {
                    result = false;
                }
            }
            finally
            {
                if (ppDocData != IntPtr.Zero)
                {
                    Marshal.Release(ppDocData);
                }
            }

            return result;
        }
예제 #8
0
 public bool TryGetTextLinesAndInvisibleEditor(
     string fullPathFileName, out VsShell.IVsInvisibleEditor spEditor, out VsTextMgr.IVsTextLines textLines)
 {
     return TryGetTextLinesAndInvisibleEditor(fullPathFileName, null, out spEditor, out textLines);
 }