Ejemplo n.º 1
0
        /// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionProvider.FormatSpan"]/*' />
        public virtual int FormatSpan(IVsTextLines buffer, TextSpan2[] 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 = TextSpanHelper.TextSpanFromTextSpan2(ts[i]);
                        // We should not merge edits in this case because it might clobber the
                        // $varname$ spans which are markers for yellow boxes.
                        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);
        }
Ejemplo n.º 2
0
        /// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionProvider.InTemplateEditingMode"]/*' />
        public virtual TextSpan GetExpansionSpan()
        {
            if (this.expansionSession == null)
            {
                throw new System.InvalidOperationException(SR.GetString(SR.NoExpansionSession));
            }
            TextSpan2[] pts = new TextSpan2[1];
            int         hr  = this.expansionSession.GetSnippetSpan(pts);

            if (NativeMethods.Succeeded(hr))
            {
                return(TextSpanHelper.TextSpanFromTextSpan2(pts[0]));
            }
            return(new TextSpan());
        }