private void ApplyEdits()
        {
            if (textDocument != null)
            {
                textDocument.QueueInsert(GetClassStartPoint(), codeToInsert.ToString());
                textDocument.ApplyQueuedEdits("Organize");

                Utilities.DeleteWhitespace(textDocument);
            }
        }
예제 #2
0
        /// <summary>
        /// Add a developer comment.
        /// </summary>
        /// <param name="ea"></param>
        /// <developer>Paul Mrozowski</developer>
        /// <created>08/04/2006</created>
        private void actInitials_Execute(ExecuteEventArgs ea)
        {
            TextDocument doc = TextDocument.Active;
            SourcePoint  sp  = CodeRush.Caret.SourcePoint;

            string line       = doc.GetText(sp.Line);
            string xmlDoc     = CodeRush.Language.ActiveExtension.XMLDocCommentBegin;
            bool   xmlComment = line.TrimStart().StartsWith(xmlDoc);

            if (xmlDoc == null)
            {
                xmlDoc = "///";
            }

            if (xmlComment)
            {
                doc.QueueInsert(sp, String.Format("<developer>{0}</developer>\r\n{1}{2} <created>{3:" + m_dateformat + "}</created>",
                                                  this.m_devName,
                                                  line.Substring(0, line.IndexOf(xmlDoc)),
                                                  xmlDoc,
                                                  System.DateTime.Now));
            }
            else
            {
                string commentLine = CodeRush.Language.ActiveExtension.SingleLineCommentBegin;
                if (commentLine == null)
                {
                    commentLine = "//";
                }

                string comment = "";

                if (this.m_fullName)
                {
                    comment = String.Format("{0} {1} - {2:" + m_dateformat + "} - ", commentLine, this.m_devName, System.DateTime.Now);
                }
                else
                {
                    comment = String.Format("{0} {1} - {2:" + m_dateformat + "} - ", commentLine, this.m_devInitials, System.DateTime.Now);
                }

                doc.QueueInsert(sp, comment);
                CodeRush.Caret.MoveToEndOfLine();
                CodeRush.Caret.DeleteLeftWhiteSpace();
            }

            doc.ApplyQueuedEdits("Developer Comment");
        }