コード例 #1
0
        public virtual int FormatSpan(IVsTextLines buffer, TextSpan[] ts)
        {
            if (this.source.GetTextLines() != buffer)
            {
                throw new System.ArgumentException(SR.GetString(SR.UnknownBuffer), "buffer");
            }
            int rc = NativeMethods.E_NOTIMPL;

            if (ts != null)
            {
                for (int i = 0, n = ts.Length; i < n; i++)
                {
                    if (this.source.LanguageService.Preferences.EnableFormatSelection)
                    {
                        TextSpan span = ts[i];
                        // We should not merge edits in this case because it might clobber the
                        // $varname$ spans which are markers for yellow boxes.
                        using (EditArray edits = new EditArray(this.source, this.view, false, SR.GetString(SR.FormatSpan))) {
                            this.source.ReformatSpan(edits, span);
                            edits.ApplyEdits();
                        }
                        rc = NativeMethods.S_OK;
                    }
                }
            }
            return(rc);
        }
コード例 #2
0
ファイル: Source.cs プロジェクト: svick/visualfsharp
 /// <summary>
 /// This method formats the given span using the given EditArray. The default behavior does nothing.  
 /// So you need to override this method if you want formatting to work.  
 /// An empty input span means reformat the entire document.
 /// You also need to turn on Preferences.EnableFormatSelection.
 /// </summary>
 public void ReformatSpan(EditArray mgr, TextSpan span)
 {
 }
コード例 #3
0
 public virtual void ReformatDocument() {
     if (this.CanReformat()) {
         Debug.Assert(this.source != null);
         if (this.source != null) {
             TextSpan span = this.source.GetDocumentSpan();
             using (EditArray mgr = new EditArray(this.source, this.TextView, true, SR.GetString(SR.FormatSpan))) {
                 this.source.ReformatSpan(mgr, span);
                 mgr.ApplyEdits();
             }
         }
     }
 }
コード例 #4
0
 public virtual void ReformatSelection() {
     if (this.CanReformat()) {
         Debug.Assert(this.source != null);
         if (this.source != null) {
             TextSpan ts = GetSelection();
             if (TextSpanHelper.IsEmpty(ts)) {
                 // format just this current line.
                 ts.iStartIndex = 0;
                 ts.iEndLine = ts.iStartLine;
                 ts.iEndIndex = this.source.GetLineLength(ts.iStartLine);
             }
             using (EditArray mgr = new EditArray(this.source, this.TextView, true, SR.GetString(SR.FormatSpan))) {
                 this.source.ReformatSpan(mgr, ts);
                 mgr.ApplyEdits();
             }
         }
     }
 }
コード例 #5
0
 public virtual int FormatSpan(IVsTextLines buffer, TextSpan[] ts) {
     if (this.source.GetTextLines() != buffer) {
         throw new System.ArgumentException(SR.GetString(SR.UnknownBuffer), "buffer");
     }
     int rc = NativeMethods.E_NOTIMPL;
     if (ts != null) {
         for (int i = 0, n = ts.Length; i < n; i++) {
             if (this.source.LanguageService.Preferences.EnableFormatSelection) {
                 TextSpan span = ts[i];
                 // We should not merge edits in this case because it might clobber the
                 // $varname$ spans which are markers for yellow boxes.
                 using (EditArray edits = new EditArray(this.source, this.view, false, SR.GetString(SR.FormatSpan))) {
                     this.source.ReformatSpan(edits, span);
                     edits.ApplyEdits();
                 }
                 rc = NativeMethods.S_OK;
             }
         }
     }
     return rc;
 }