Ejemplo n.º 1
0
 public override void ReformatSpan(EditArray mgr, TextSpan span)
 {
     var ca = new CompoundAction(this, "Reformat code");
     using(ca)
     {
         ca.FlushEditActions();
         Data.ReformatSpan(mgr, span, _parent.Package.CreateFormattingProvider());
     }
 }
Ejemplo n.º 2
0
 public override void ReformatSpan(EditArray mgr, TextSpan span)
 {
     string description = "Reformat code";
     CompoundAction ca = new CompoundAction(this, description);
     using (ca)
     {
         ca.FlushEditActions();      // Flush any pending edits
         DoFormatting(mgr, span);    // Format the span
     }
 }
Ejemplo n.º 3
0
 void ISource.Save(Action saveAction)
 {
     // Wrap the buffer sync and the formatting in one undo unit.
     using (var ca = new CompoundAction(source, "Synchronize buffer"))
     {
         saveAction();
         /*using (var scope = xmlStore.BeginEditingScope(Resources.SynchronizeBuffer, this))
         {
             //Replace the existing XDocument with the new one we just generated.
             document.Root.ReplaceWith(documentFromDesignerState.Root);
             scope.Complete();
         }*/
         ca.FlushEditActions();
         FormatBuffer(source);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// This method is called when it is time to save the designer values to the
        /// underlying buffer.
        /// </summary>
        /// <param name="undoEntry"></param>
        void SaveModelToXmlModel(string undoEntry)
        {
            LanguageService langsvc = GetXmlLanguageService();

            try
            {
                //We can't edit this file (perhaps the user cancelled a SCC prompt, etc...)
                if (!CanEditFile())
                {
                    DesignerDirty = false;
                    BufferDirty = true;
                    throw new Exception();
                }

                //PopulateModelFromReferencesBindingList();
                //PopulateModelFromContentBindingList();

                XmlSerializer serializer = new XmlSerializer(typeof(VSTemplate));
                XDocument documentFromDesignerState = new XDocument();
                using (XmlWriter w = documentFromDesignerState.CreateWriter())
                {
                    serializer.Serialize(w, _vstemplateModel);
                }

                _synchronizing = true;
                XDocument document = GetParseTree();
                Source src = GetSource();
                if (src == null || langsvc == null)
                {
                    return;
                }

                langsvc.IsParsing = true; // lock out the background parse thread.

                // Wrap the buffer sync and the formatting in one undo unit.
                using (CompoundAction ca = new CompoundAction(src, Resources.SynchronizeBuffer))
                {
                    using (XmlEditingScope scope = _xmlStore.BeginEditingScope(Resources.SynchronizeBuffer, this))
                    {
                        //Replace the existing XDocument with the new one we just generated.
                        document.Root.ReplaceWith(documentFromDesignerState.Root);
                        scope.Complete();
                    }
                    ca.FlushEditActions();
                    FormatBuffer(src);
                }
                DesignerDirty = false;
            }
            catch (Exception)
            {
                // if the synchronization fails then we'll just try again in a second.
                _dirtyTime = Environment.TickCount;
            }
            finally
            {
                langsvc.IsParsing = false;
                _synchronizing = false;
            }
        }