private void DocumentSaving(object sender, DocumentEventArgs e)
		{
			var doc = e.Document;
			if (!this.DocumentShouldBeFormatted(doc))
			{
				return;
			}

			lock (this._listSync)
			{
				// If we're already in the process of formatting the doc, bail.
				if (this._docsBeingFormatted.Contains(doc))
				{
					return;
				}

				// We're not already formatting the doc, so add it to the list.
				this._docsBeingFormatted.Add(doc);
			}

			// Execute document formatting after the VsLinkedUndoTransactionManager.CloseLinkedUndo
			// method has finished so we don't mess up IntelliSense or Undo.
			// http://www.devexpress.com/Support/Center/Question/Details/B223163
			SynchronizationContext.Current.Post(state =>
				{
					try
					{
						FormatDocument(e.Document);
					}
					catch (Exception ex)
					{
						// Issue #147: Unhandled exception while attempting to format the document.
						// This happens if the user closes the document and has
						// unsaved changes - they elect to save on close and this
						// will run AFTER the doc is already closed so we can't
						// cause the document to focus and can't format.
						Log.SendException("Error formatting document on save.", ex);
					}
					finally
					{
						lock (this._listSync)
						{
							// Formatting is done; remove the marker.
							this._docsBeingFormatted.Remove(doc);
						}
					}
				}, null);


		}
		private void DocumentSaving(object sender, DocumentEventArgs e)
		{
			var doc = e.Document;
			if (!this.DocumentShouldBeFormatted(doc))
			{
				return;
			}

			lock (this._listSync)
			{
				// If we're already in the process of formatting the doc, bail.
				if (this._docsBeingFormatted.Contains(doc))
				{
					return;
				}

				// We're not already formatting the doc, so add it to the list.
				this._docsBeingFormatted.Add(doc);
			}

			// Execute document formatting after the VsLinkedUndoTransactionManager.CloseLinkedUndo
			// method has finished so we don't mess up IntelliSense or Undo.
			// http://www.devexpress.com/Support/Center/Question/Details/B223163
			SynchronizationContext.Current.Post(state =>
				{
					try
					{
						FormatDocument(e.Document);
					}
					finally
					{
						lock (this._listSync)
						{
							// Formatting is done; remove the marker.
							this._docsBeingFormatted.Remove(doc);
						}
					}
				}, null);


		}
		private void DocumentSaving(object sender, DocumentEventArgs e)
		{
			this.FormatDocument(e.Document);
		}
		private int RaiseEvent(uint docCookie, EventHandler<DocumentEventArgs> eventToRaise)
		{
			if (eventToRaise == null)
			{
				return HResult.S_OK;
			}
			var doc = GetDocumentFromCookie(docCookie);
			if (doc == null)
			{
				return HResult.S_OK;
			}
			try
			{
				var args = new DocumentEventArgs(doc);
				eventToRaise(this, args);
			}
			catch (Exception ex)
			{
				DevExpress.CodeRush.Diagnostics.Interop.Log.SendException("Error in raising event.", ex);
			}
			return HResult.S_OK;
		}