/// <summary>
        ///   Writes the attribute specification to a stream.
        /// </summary>
        /// <param name="wr"><see cref="StreamWriter"/> object to write the attribute specification to.</param>
        /// <param name="indentOffset">Number of indents to add before any documentation begins.</param>
        /// <exception cref="ArgumentNullException"><paramref name="wr"/> is a null reference.</exception>
        /// <exception cref="IOException">An error occurred while writing to the <see cref="StreamWriter"/> object.</exception>
        public void Write(StreamWriter wr, int indentOffset)
        {
            if (wr == null)
            {
                throw new ArgumentNullException("wr");
            }

            if (indentOffset < 0)
            {
                indentOffset = 0;
            }

            Dictionary <string, string[]> lookup = new Dictionary <string, string[]>(2);

            lookup.Add("Summary", new string[] { Summary });
            if (!string.IsNullOrWhiteSpace(Remarks))
            {
                lookup.Add("Remarks", new string[] { Remarks });
            }

            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
            DocumentationHelper.WriteGeneralDocumentationElements(wr, lookup, indentOffset);
            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
            DocumentationHelper.WriteLine(wr, string.Format("attribute {0} of {1} : {2} is {3};", Declaration.Name, Item.Name, GetItemString(), Value), indentOffset);
        }
Esempio n. 2
0
        /// <summary>
        ///   Writes the file to the <see cref="StreamWriter"/> object.
        /// </summary>
        /// <param name="wr"><see cref="StreamWriter"/> object to write the code to.</param>
        /// <exception cref="ArgumentNullException"><paramref name="wr"/> is a null reference.</exception>
        /// <exception cref="IOException">An error occurred while writing to the <see cref="StreamWriter"/> object.</exception>
        private void WriteFileSubHeader(StreamWriter wr)
        {
            List <Dictionary <string, List <string> > > subInfo = null;
            List <string> info = null;

            GenerateModuleInfo(Module, out info, out subInfo);

            // Determine the first part maximum string length.
            int maxSizeRegions = 0;

            foreach (Dictionary <string, List <string> > lookup in subInfo)
            {
                foreach (string key in lookup.Keys)
                {
                    MaxStringLength(key, ref maxSizeRegions);
                }
            }

            int col1  = maxSizeRegions + 6;            // 6 is for "--   " and space after.
            int index = 0;

            foreach (string key in info)
            {
                // Write the module of the file.
                StringBuilder sb = new StringBuilder();
                sb.Append("-- ");
                sb.Append(key);
                DocumentationHelper.WriteLine(wr, sb.ToString(), 0);
                Dictionary <string, List <string> > lookup = subInfo[index++];
                int subIndex = 0;
                foreach (string subKey in lookup.Keys)
                {
                    DocumentationHelper.WriteLine(wr, string.Format("--   {0}", subKey), 0);
                    for (int i = 0; i < lookup[subKey].Count; i++)
                    {
                        sb.Clear();
                        sb.Append("--");
                        for (int j = 2; j < col1; j++)
                        {
                            sb.Append(" ");
                        }
                        sb.Append(lookup[subKey][i]);
                        DocumentationHelper.WriteLine(wr, sb.ToString(), 0);
                    }
                    subIndex++;

                    if (subIndex != lookup.Keys.Count)
                    {
                        DocumentationHelper.WriteLine(wr, "--", 0);
                    }
                }
                DocumentationHelper.WriteFlowerLine(wr, 0);
            }
        }
Esempio n. 3
0
        /// <summary>
        ///   Writes the basic file header composed of the summary and remarks section.
        /// </summary>
        /// <param name="wr"><see cref="StreamWriter"/> object to write the header to.</param>
        /// <param name="indentOffset">Number of indents to add before any documentation begins.</param>
        /// <exception cref="ArgumentNullException"><paramref name="wr"/> is a null reference.</exception>
        /// <exception cref="IOException">An error occurred while writing to the <see cref="StreamWriter"/> object.</exception>
        public void WriteBasicHeader(StreamWriter wr, int indentOffset)
        {
            if (wr == null)
            {
                throw new ArgumentNullException("wr");
            }

            if (indentOffset < 0)
            {
                indentOffset = 0;
            }

            Dictionary <string, string[]> lookup = new Dictionary <string, string[]>(2);

            lookup.Add("Summary", new string[] { Summary });
            if (!string.IsNullOrWhiteSpace(Remarks))
            {
                lookup.Add("Remarks", new string[] { Remarks });
            }

            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
            DocumentationHelper.WriteGeneralDocumentationElements(wr, lookup, indentOffset);
            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
        }
Esempio n. 4
0
        /// <summary>
        ///   Writes the entity to a stream.
        /// </summary>
        /// <param name="wr"><see cref="StreamWriter"/> object to write the entity to.</param>
        /// <param name="indentOffset">Number of indents to add before any documentation begins.</param>
        /// <exception cref="ArgumentNullException"><paramref name="wr"/> is a null reference.</exception>
        /// <exception cref="InvalidOperationException">The number of ports and generics is zero.</exception>
        /// <exception cref="IOException">An error occurred while writing to the <see cref="StreamWriter"/> object.</exception>
        public override void Write(StreamWriter wr, int indentOffset)
        {
            if (wr == null)
            {
                throw new ArgumentNullException("wr");
            }

            if (indentOffset < 0)
            {
                indentOffset = 0;
            }

            if (Generics.Count == 0 && Ports.Count == 0)
            {
                throw new InvalidOperationException(string.Format("An attempt was made to write an entity ({0}), but the entity does not have any ports or generics.", Name));
            }

            // Generate the documentation lookup table.
            Dictionary <string, string[]> lookup = new Dictionary <string, string[]>();

            lookup.Add("Summary", new string[] { Summary });

            if (Generics.Count > 0)
            {
                List <string> subItems = new List <string>(Generics.Count);
                foreach (GenericInfo info in Generics)
                {
                    subItems.Add(info.GetDocumentationString());
                }
                lookup.Add("Generics", subItems.ToArray());
            }

            if (Ports.Count > 0)
            {
                List <string> subItems = new List <string>(Ports.Count);
                foreach (PortInfo info in Ports)
                {
                    subItems.Add(info.GetDocumentationString());
                }
                lookup.Add("Ports", subItems.ToArray());
            }

            if (!string.IsNullOrWhiteSpace(Remarks))
            {
                lookup.Add("Remarks", new string[] { Remarks });
            }

            // Write the header.
            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
            DocumentationHelper.WriteGeneralDocumentationElements(wr, lookup, indentOffset);
            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
            DocumentationHelper.WriteLine(wr, string.Format("entity {0} is", Name), indentOffset);

            if (Generics.Count > 0)
            {
                SimplifiedGenericInfo.WriteGenericDeclaration(wr, Generics.ToArray(), indentOffset);
            }

            if (Ports.Count > 0)
            {
                SimplifiedPortInfo.WritePortDeclaration(wr, Ports.ToArray(), indentOffset);
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("end");
            if (DefaultValues.AddOptionalTypeNames)
            {
                sb.Append(" entity");
            }
            if (DefaultValues.AddOptionalNames)
            {
                sb.AppendFormat(" {0}", Name);
            }
            sb.Append(";");
            DocumentationHelper.WriteLine(wr, sb.ToString(), indentOffset);
        }
Esempio n. 5
0
        /// <summary>
        ///   Writes the procedure to a stream.
        /// </summary>
        /// <param name="wr"><see cref="StreamWriter"/> object to write the procedure to.</param>
        /// <param name="indentOffset">Number of indents to add before any documentation begins.</param>
        /// <exception cref="ArgumentNullException"><paramref name="wr"/> is a null reference.</exception>
        /// <exception cref="InvalidOperationException">No code lines were specified or no parameters were specified.</exception>
        /// <exception cref="IOException">An error occurred while writing to the <see cref="StreamWriter"/> object.</exception>
        public override void Write(StreamWriter wr, int indentOffset)
        {
            if (wr == null)
            {
                throw new ArgumentNullException("wr");
            }

            if (indentOffset < 0)
            {
                indentOffset = 0;
            }

            if (CodeLines.Count == 0)
            {
                throw new InvalidOperationException(string.Format("An attempt was made to write a procedure ({0}), but it doesn't have any code associated with it", Name));
            }
            if (Parameters.Count == 0)
            {
                throw new InvalidOperationException(string.Format("An attempt was made to write a procedure ({0}), but it doesn't have any parameters", Name));
            }

            // Generate the documentation lookup table.
            Dictionary <string, string[]> lookup = new Dictionary <string, string[]>();

            lookup.Add("Summary", new string[] { Summary });

            if (Parameters.Count > 0)
            {
                List <string> subItems = new List <string>(Parameters.Count);
                foreach (ProcedureParameterInfo info in Parameters)
                {
                    subItems.Add(info.GetDocumentationString());
                }
                lookup.Add("Parameters", subItems.ToArray());
            }

            if (!string.IsNullOrWhiteSpace(Remarks))
            {
                lookup.Add("Remarks", new string[] { Remarks });
            }

            // Write the header.
            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
            DocumentationHelper.WriteGeneralDocumentationElements(wr, lookup, indentOffset);
            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
            DocumentationHelper.WriteLine(wr, GetSignature(), indentOffset);

            // Write the variable declarations out.
            BaseTypeInfo.WriteBaseTypeInfos(null, wr, Variables.ToArray(), indentOffset + 1, Name, "procedure");

            DocumentationHelper.WriteLine(wr, "begin", indentOffset);

            // Write the code lines.
            foreach (string line in CodeLines)
            {
                DocumentationHelper.WriteLine(wr, line, indentOffset + 1);
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("end");
            if (DefaultValues.AddOptionalTypeNames)
            {
                sb.Append(" procedure");
            }
            if (DefaultValues.AddOptionalNames)
            {
                sb.AppendFormat(" {0}", Name);
            }
            sb.Append(";");
            DocumentationHelper.WriteLine(wr, sb.ToString(), indentOffset);
        }