Example #1
0
        public static void doCreateXMLDocumentForFunction(EnvDTE.CodeFunction func)
        {
            // probably should use StringBuilder here for better performance/memory use
            // but am not as readability is main purpose of example
            string xmlComments = "";

            xmlComments +=
                "\t\t/// <summary> " + func.Name + "()";

            switch (func.FunctionKind)
            {
            case vsCMFunction.vsCMFunctionConstructor:
                xmlComments += " constructor"; break;

            case vsCMFunction.vsCMFunctionDestructor:
                xmlComments += " destructor"; break;

            default: break;
            }

            if (func.Parameters.Count <= 0)
            {
                xmlComments += ".  No parameters";
            }
            xmlComments += ". </summary> \n";

            foreach (CodeParameter param in func.Parameters)
            {
                xmlComments +=
                    "\t\t/// <param name=\"" + param.Name + "\"> type: " +
                    param.Type.AsString + "</param> \n";
            }
            xmlComments +=
                "\t\t/// <returns> " + func.Type.AsString + "</returns>\n";


            Debug.WriteLine(xmlComments);

            if (func.DocComment.Length <= 1)
            {
                // this does not work: func.DocComment = xmlComments;
                // editing does work
                Debug.WriteLine("writing XML comments to source file...");
                EnvDTE.TextPoint tp = func.GetStartPoint(EnvDTE.vsCMPart.vsCMPartWholeWithAttributes);
                EnvDTE.EditPoint ep = tp.CreateEditPoint();
                ep.StartOfLine();
                ep.Insert(xmlComments);
            }
            else
            {
                Debug.WriteLine("XML comments already present in source file:");
                Debug.WriteLine(func.DocComment);
                Debug.WriteLine("-- end doc comment --");
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="d"></param>
 /// <param name="text"></param>
 public static void InsertTextIntoActiveDocument(EnvDTE.Document d, string text)
 {
     if ((!String.IsNullOrEmpty(text)) && (!String.IsNullOrEmpty(text.Trim())))
     {
         EnvDTE.TextSelection SelectedText = d.Selection as EnvDTE.TextSelection;
         EnvDTE.EditPoint     TopPoint     = SelectedText.TopPoint.CreateEditPoint();
         TopPoint.LineUp(1);
         TopPoint.EndOfLine();
         TopPoint.Insert(text);
     }
 }
Example #3
0
 /// <summary>
 /// Processes the document for the footer comments
 /// </summary>
 /// <param name="endEditPoint">
 /// A edit point pointing at the end of the current document
 /// </param>
 protected abstract void ProcessFoot(EnvDTE.EditPoint endEditPoint);
Example #4
0
        } // end of function - Process

        /// <summary>
        /// Processes the document for the header comments
        /// </summary>
        /// <param name="startEditPoint">
        /// A edit point pointing at the current document
        /// </param>
        /// <param name="headerTemplate"></param>
        protected abstract void ProcessHead(EnvDTE.EditPoint startEditPoint, string headerTemplate);