Esempio n. 1
0
        private CodeCommentStatement AddComment()
        {
            CodeComment          comm = new CodeComment("This custom member was added by TypedDataSetGenerator tool.", false);
            CodeCommentStatement cst  = new CodeCommentStatement(comm);

            return(cst);
        }
Esempio n. 2
0
 private void UpdatePreviewText()
 {
     //TODO: Preview functionality used to work against CodeCommentOptions, but now is
     // working directly against the Settings object which is not updated until save.
     // Utilize an alternate Settings object to show settings on the fly?
     CommentPreviewText = CodeComment.FormatXml(UnformattedPreviewText);
 }
Esempio n. 3
0
        /// <summary>
        /// Reformat all comments between the specified start and end point. Comments that start
        /// within the range, even if they overlap the end are included.
        /// </summary>
        /// <param name="textDocument">The text document.</param>
        /// <param name="start">The start point.</param>
        /// <param name="end">The end point.</param>
        public bool FormatComments(TextDocument textDocument, EditPoint start, EditPoint end)
        {
            var options = new CodeCommentOptions(Settings.Default, _package, textDocument);

            bool foundComments = false;

            while (start.Line <= end.Line)
            {
                if (CodeCommentHelper.IsCommentLine(start))
                {
                    var comment = new CodeComment(start);
                    if (comment.IsValid)
                    {
                        comment.Format(options);
                        foundComments = true;
                    }

                    if (comment.EndPoint != null)
                    {
                        start = comment.EndPoint.CreateEditPoint();
                    }
                }

                if (start.Line == textDocument.EndPoint.Line)
                {
                    break;
                }

                start.LineDown();
                start.StartOfLine();
            }

            return(foundComments);
        }
        public void Ctor_CodeComment(string text, bool docComment)
        {
            CodeComment          codeComment = new CodeComment(text, docComment);
            CodeCommentStatement comment     = new CodeCommentStatement(codeComment);

            Assert.Same(codeComment, comment.Comment);
        }
Esempio n. 5
0
        /// <summary>
        /// Generate the members of the container
        /// </summary>
        /// <param name="nt"></param>
        /// <param name="ctd"></param>
        /// <remarks></remarks>
        private void GenerateContainerMembers(NativeDefinedType nt, CodeTypeDeclaration ctd)
        {
            ThrowIfNull(nt);
            ThrowIfNull(ctd);

            int bitVectorCount = 0;

            for (int i = 0; i <= nt.Members.Count - 1; i++)
            {
                NativeMember member = nt.Members[i];

                // Don't process unnamed container members
                if (string.IsNullOrEmpty(member.Name))
                {
                    continue;
                }


                if (IsBitVector(member.NativeType))
                {
                    // Get the list of bitvectors that will fit into the next int
                    int bitCount                  = 0;
                    List <NativeMember> list      = new List <NativeMember>();
                    NativeBitVector     bitVector = null;

                    while ((i < nt.Members.Count && IsBitVector(nt.Members[i].NativeType, ref bitVector) && bitCount + bitVector.Size <= 32))
                    {
                        list.Add(nt.Members[i]);
                        i += 1;
                    }
                    i -= 1;

                    // Generate the int for the list of bit vectors
                    bitVectorCount += 1;

                    CodeMemberField cMember = GenerateContainerMember(new NativeMember("bitvector" + bitVectorCount, new NativeBuiltinType(BuiltinType.NativeInt32, true)), ctd);
                    cMember.Comments.Clear();

                    CodeComment comment = new CodeComment(string.Empty, true);
                    int         offset  = 0;
                    for (int j = 0; j <= list.Count - 1; j++)
                    {
                        if (j > 0)
                        {
                            comment.Text += Environment.NewLine;
                        }

                        IsBitVector(list[j].NativeType, ref bitVector);
                        comment.Text += list[j].Name + " : " + bitVector.Size;
                        GenerateBitVectorProperty(list[j], offset, ctd, cMember);
                        offset += bitVector.Size;
                    }
                    cMember.Comments.Add(new CodeCommentStatement(comment));
                }
                else
                {
                    GenerateContainerMember(member, ctd);
                }
            }
        }
        public CodeNamespace GetCodeNamespaceForXmltargetNamespace(string xmlNamespace)
        {
            if (xml2CSharpNamespaceDictionary.ContainsKey(xmlNamespace))
            {
                string               csScopeName   = xml2CSharpNamespaceDictionary[xmlNamespace];
                CodeNamespace        codeNs        = new CodeNamespace(csScopeName);
                string               commentLine   = GetCommentTextForScope(csScopeName);
                CodeComment          headerComment = new CodeComment(string.Format(nsHeaderComment, commentLine));
                CodeCommentStatement fileHeader    = new CodeCommentStatement(headerComment);
                codeNs.Comments.Add(fileHeader);

                // HACK! Do a hardcore swap if it is basedoc
                if (xmlNamespace.Equals(Constants.BaseDocumentTargetNamespace))
                {
                    csScopeName += ".Abs";
                }

                // figure out what using statements to add
                if (codeNamespaceUsings.ContainsKey(csScopeName))
                {
                    foreach (string usingNamespace in codeNamespaceUsings[csScopeName])
                    {
                        codeNs.Imports.Add(new CodeNamespaceImport(usingNamespace));
                    }
                }
                return(codeNs);
            }
            else
            {
                //throw new ApplicationException(string.Format("Don't know how to handle xml namespace {0}", xmlNamespace));
                Console.WriteLine($"Don't know how to handle xml namespace {xmlNamespace}");
                return(new CodeNamespace("BogusDontKnowHowToHandle"));
            }
        }
Esempio n. 7
0
        protected override void GenerateComment(CodeComment comment)
        {
            TextWriter output = Output;

            string [] lines = comment.Text.Split('\n');
            bool      first = true;

            foreach (string line in lines)
            {
                if (comment.DocComment)
                {
                    output.Write("#");                      // no doc comment format in boo ( yet ?? )
                }
                else
                {
                    output.Write("#");
                }
                if (first)
                {
                    output.Write(' ');
                    first = false;
                }
                output.WriteLine(line);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Reformat all comments between the specified start and end point. Comments that start
        /// within the range, even if they overlap the end are included.
        /// </summary>
        /// <param name="textDocument">The text document.</param>
        /// <param name="start">The start point.</param>
        /// <param name="end">The end point.</param>
        public bool FormatComments(TextDocument textDocument, EditPoint start, EditPoint end)
        {
            bool foundComments = false;
            int  tabSize       = CodeCommentHelper.GetTabSize(_package, textDocument);

            while (start.Line <= end.Line)
            {
                if (CodeCommentHelper.IsCommentLine(start))
                {
                    var comment = new CodeComment(start, tabSize);
                    if (comment.IsValid)
                    {
                        comment.Format();
                        foundComments = true;
                    }

                    if (comment.EndPoint != null)
                    {
                        start = comment.EndPoint.CreateEditPoint();
                    }
                }

                if (start.Line == textDocument.EndPoint.Line)
                {
                    break;
                }

                start.LineDown();
                start.StartOfLine();
            }

            return(foundComments);
        }
        /// <summary>
        /// This method is used to compare a regular expression with a line of source code.
        /// </summary>
        /// <param name="comment"></param>
        /// <param name="sourceCode"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public bool IsMatch(CodeComment comment, string sourceCode, ref string target, ref string target2)
        {
            // initial value
            bool isMatch = false;

            // if the pattern matches
            if (Regex.IsMatch(sourceCode, comment.Pattern, RegexOptions.IgnoreCase))
            {
                // set to true
                isMatch = true;

                // if the comment has a TargetPattern
                if (comment.HasTargetPattern)
                {
                    // Set the target
                    target = SetTarget(comment.TargetPattern, sourceCode);
                }

                // if the comment has a TargetPattern
                if (comment.HasTargetPattern2)
                {
                    // set target2
                    target2 = SetTarget(comment.TargetPattern2, sourceCode);
                }
            }

            // return value
            return(isMatch);
        }
        public void Comment_Set_Get_ReturnsExpected(string text, bool docComment)
        {
            CodeComment          codeComment = new CodeComment(text, docComment);
            CodeCommentStatement comment     = new CodeCommentStatement();

            comment.Comment = codeComment;
            Assert.Same(codeComment, comment.Comment);
        }
        public void Constructor1_Deny_Unrestricted()
        {
            CodeComment          cc  = new CodeComment("mono");
            CodeCommentStatement ccs = new CodeCommentStatement(cc);

            Assert.AreEqual("mono", ccs.Comment.Text, "Comment.Text");
            Assert.IsFalse(ccs.Comment.DocComment, "Comment.DocComment");
        }
        /// <summary>
        /// This event is fired AFTER the codeComment is parsed.
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <param name="codeComment"></param>
        /// <returns>True if cancelled else false if not.</returns>
        public bool Parsed(XmlNode xmlNode, ref CodeComment codeComment)
        {
            // initial value
            bool cancel = false;

            // if the comment is not valid
            if (!codeComment.IsValid)
            {
                // since the comment is not valid, cancel the adding of this comment
                cancel = true;
            }
            else
            {
                // for debugging only
                string name = codeComment.Name;

                // if the Pattern exists
                if (codeComment.HasPattern)
                {
                    // we need to replace out any reserve word characters for the following items (<,>,&,%)
                    codeComment.Pattern = ReplaceReserveCharacters(codeComment.Pattern);
                }

                // if the TargetPattern exists
                if (codeComment.HasTargetPattern)
                {
                    // we need to replace out any reserve word characters for the following items (<,>,&,%)
                    codeComment.TargetPattern = ReplaceReserveCharacters(codeComment.TargetPattern);
                }

                // if the TargetPattern2 exists
                if (codeComment.HasTargetPattern2)
                {
                    // we need to replace out any reserve word characters for the following items (<,>,&,%)
                    codeComment.TargetPattern2 = ReplaceReserveCharacters(codeComment.TargetPattern2);
                }

                // if the codeComment has a Replacements collection, we must load it.
                if (codeComment.HasReplacements)
                {
                    // Create a new instance of a 'ReplacementParser' object.
                    ReplacementParser replacementParser = new ReplacementParser();

                    // If the replacementParser object exists
                    if (replacementParser != null)
                    {
                        // set the CommentID so we know which set of Replacements to load
                        replacementParser.CommentID = codeComment.ID;

                        // parse the replacements
                        codeComment.Replacements = replacementParser.ParseReplacements(xmlNode.RootNode);
                    }
                }
            }

            // return value
            return(cancel);
        }
Esempio n. 13
0
        protected override void GenerateCommentCode(CodeComment commentDecl)
        {
            if (commentDecl.IsXml)
            {
                return;
            }

            GenerateCommentCode(commentDecl.Text);
        }
Esempio n. 14
0
 public void VisitComment(CodeComment comment)
 {
     foreach (var line in Lines(comment.Text))
     {
         writer.Indent();
         writer.WriteComment($"// {line}");
         writer.Terminate();
     }
 }
        public static CodeCommentStatement CommentStatement(CodeComment comment, CodeDirective[] startDirectives, CodeDirective[] endDirectives, CodeLinePragma linePragma)
        {
            var result = new CodeCommentStatement(comment);

            result.StartDirectives.AddRange(startDirectives);
            result.EndDirectives.AddRange(endDirectives);
            result.LinePragma = linePragma;
            return(result);
        }
Esempio n. 16
0
        protected static bool IsNotXmlTagComment(CodeComment c)
        {
            if (!c.IsXml)
            {
                return(true);
            }
            string s = c.Text;

            return(!(s.StartsWith('<') && s.EndsWith('>')));
        }
        /// <inheritdoc />
        public override void WriteComments(CodeComment codeComment)
        {
            foreach (string enumLineComment in codeComment.Summary.Split(new[] { Environment.NewLine }, StringSplitOptions.None))
            {
                string lineComment = $" {enumLineComment.Trim()}";
                WriteLine($"//{lineComment.TrimEnd()}");
            }

            WriteLine("//");
        }
Esempio n. 18
0
        public bool VisitComment(CodeComment comment)
        {
            var commentPat = pattern as CodeComment;

            if (commentPat == null)
            {
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// This event is fired when a single object is initialized.
        /// An example of this is the codeComment (singlular) node.
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <param name="codeComment"></param>
        /// <returns>True if cancelled else false if not.</returns>
        public bool Parsing(XmlNode xmlNode, ref CodeComment codeComment)
        {
            // initial value
            bool cancel = false;

            // Add any pre processing code here. Set cancel to true to abort adding this object.

            // return value
            return(cancel);
        }
        public static string AssertEqualAfterFormat(
            string text,
            string expected,
            string prefix,
            Action <FormatterOptions> options = null)
        {
            var result = CodeComment.Format(text, prefix, options);

            Assert.AreEqual(expected ?? text, result);
            return(result);
        }
Esempio n. 21
0
 protected override void Visit(CodeComment comment)
 {
     base.Visit(comment);
     if (comment.Text.Contains(s_microsoftXml) && _xmlTypes.ContainsKey(comment.Text))
     {
         comment.Text = comment.Text.Replace(s_microsoftXml, s_systemXml);
     }
     if (comment.Text.Contains(s_microsoftCodeDom) && _codeDomTypes.ContainsKey(comment.Text))
     {
         comment.Text = comment.Text.Replace(s_microsoftCodeDom, s_systemCodeDom);
     }
 }
Esempio n. 22
0
        private void UpdatePreviewText()
        {
            var temp = _options.WrapAtColumn;

            _options.WrapAtColumn = 75; // Override to fit preview text better

            CommentPreviewText = CodeComment.FormatXml(
                UnformattedPreviewText,
                _options);

            _options.WrapAtColumn = temp;
        }
Esempio n. 23
0
        /// <summary>
        ///     Generates a field.
        /// </summary>
        /// <param name="wiTypeClass">The wi type class.</param>
        /// <param name="fieldDefinition">The field definition.</param>
        private void GenerateField(CodeTypeDeclaration wiTypeClass, ModelFieldDefinition fieldDefinition)
        {
            var property = new CodeMemberProperty {
                HasGet = true
            };

            var propName = GeneratePropertyName(fieldDefinition);

            property.Name = propName;

            var propertyType = fieldDefinition.Type;

            if (!propertyType.IsClass)
            {
                var nullableType = typeof(Nullable <>);
                propertyType = nullableType.MakeGenericType(propertyType);
            }
            property.Type       = new CodeTypeReference(propertyType);
            property.Attributes = MemberAttributes.Public;

            property.CustomAttributes.Add(new CodeAttributeDeclaration(
                                              new CodeTypeReference(typeof(FieldAttribute)),
                                              new CodeAttributeArgument(new CodePrimitiveExpression(fieldDefinition.ReferenceName))));


            if (!string.IsNullOrEmpty(fieldDefinition.Description))
            {
                var comment = new CodeComment($"<summary>{fieldDefinition.Description}</summary>", true);
                property.Comments.Add(new CodeCommentStatement(comment));
            }

            var fieldMethod = new CodeMethodReferenceExpression(new CodeThisReferenceExpression(),
                                                                propertyType.IsClass ? "GetRefField" : "GetStructField", new CodeTypeReference(fieldDefinition.Type));
            var fieldMethodInvoke = new CodeMethodInvokeExpression(fieldMethod,
                                                                   new CodePrimitiveExpression(fieldDefinition.ReferenceName));

            property.GetStatements.Add(new CodeMethodReturnStatement(fieldMethodInvoke));


            if (!fieldDefinition.IsReadOnly)
            {
                var setFieldMethod = new CodeMethodReferenceExpression(new CodeThisReferenceExpression(),
                                                                       propertyType.IsClass ? "SetRefField" : "SetStructField",
                                                                       new CodeTypeReference(fieldDefinition.Type));
                var setFielMethodInvoke = new CodeMethodInvokeExpression(setFieldMethod,
                                                                         new CodePrimitiveExpression(fieldDefinition.ReferenceName),
                                                                         new CodePropertySetValueReferenceExpression());
                property.SetStatements.Add(setFielMethodInvoke);
            }
            wiTypeClass.Members.Add(property);
            _definedPropertyList.Add(property.Name);
        }
Esempio n. 24
0
        public override void VisitCode(CodeComment comment, CommentRendererContext context)
        {
            if (!string.IsNullOrWhiteSpace(comment.Code))
            {
                var code = comment.Code;
                code = code.Replace("{", "{{").Replace("}", "}}");
                code = code.UnintendCode();

                context.Builder.AppendRaw("<code>");
                context.Builder.AppendEncoded(code);
                context.Builder.AppendRaw("</code>");
            }
        }
Esempio n. 25
0
        public void CfComment_Multiline()
        {
            formatter.Indentation = 1;
            var cmt = new CodeComment(
                @"First line
Second line");

            cmt.Accept(cf);
            var expected =
                @" // First line
 // Second line
";

            Assert.AreEqual(expected, sw.ToString());
        }
        /// <summary>
        /// Generates the specified dictionary.
        /// </summary>
        /// <param name="dictionary">The dictionary.</param>
        /// <param name="classType">Type of the class.</param>
        /// <param name="initMethod">The initialize method.</param>
        /// <param name="fieldReference">The field reference.</param>
        /// <param name="elemName">The element name.</param>
        public void Generate(ResourceDictionary dictionary,
                             CodeTypeDeclaration classType, CodeMemberMethod initMethod, CodeExpression fieldReference, string elemName)
        {
            foreach (var mergedDict in dictionary.MergedDictionaries)
            {
                string name = string.Empty;
                if (mergedDict.Source.IsAbsoluteUri)
                {
                    name = Path.GetFileNameWithoutExtension(mergedDict.Source.LocalPath);
                }
                else
                {
                    name = Path.GetFileNameWithoutExtension(mergedDict.Source.OriginalString);
                }

                if (string.IsNullOrEmpty(name))
                {
                    Console.WriteLine("Dictionary name not found.");
                    continue;
                }

                CodeMethodInvokeExpression addMergedDictionary = new CodeMethodInvokeExpression(
                    fieldReference, "MergedDictionaries.Add", new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(name), "Instance"));
                initMethod.Statements.Add(addMergedDictionary);
            }

            ValueGenerator valueGenerator = new ValueGenerator();
            List <object>  keys           = dictionary.Keys.Cast <object>().OrderBy(k => k.ToString(), StringComparer.InvariantCulture).ToList();

            foreach (var resourceKey in keys)
            {
                object resourceValue = dictionary[resourceKey];

                CodeComment comment = new CodeComment("Resource - [" + resourceKey.ToString() + "] " + resourceValue.GetType().Name);
                initMethod.Statements.Add(new CodeCommentStatement(comment));

                CodeExpression keyExpression   = CodeComHelper.GetResourceKeyExpression(resourceKey);
                CodeExpression valueExpression = valueGenerator.ProcessGenerators(classType, initMethod, resourceValue, elemName + "r_" + uniqueId, dictionary);

                if (valueExpression != null)
                {
                    CodeMethodInvokeExpression addResourceMethod = new CodeMethodInvokeExpression(fieldReference, "Add", keyExpression, valueExpression);
                    initMethod.Statements.Add(addResourceMethod);
                }

                uniqueId++;
            }
        }
Esempio n. 27
0
        public override void VisitCode(CodeComment comment, CommentRendererContext context)
        {
            if (!string.IsNullOrWhiteSpace(comment.Code))
            {
                var code = comment.Code ?? string.Empty;
                code = code.UnintendCode();

                context.Writer.Write("<div class=\"panel-body comment-code-box\">");
                context.Writer.Write("<pre>");
                context.Writer.Write("<code class=\"language-csharp\">");
                context.Writer.WriteEncodedText(code);
                context.Writer.Write("</code>");
                context.Writer.Write("</pre>");
                context.Writer.Write("</div>");
            }
        }
Esempio n. 28
0
        public static void Rule(Clause lhs, OptionalProcedureComments optionalProcedureComments, Term term, OptionalRuleBody optionalBody)
        {
            IEnumerable <CodeComment> comments = optionalProcedureComments.Comments;

            if (comments == null)
            {
                comments = new CodeComment[] { };
            }

            IEnumerable <CodeCompoundTerm> codeCompoundTerms = optionalBody.CodeCompoundTerms;

            if (codeCompoundTerms == null)
            {
                codeCompoundTerms = new CodeCompoundTerm[] { };
            }

            lhs.CodeSentence = new CodeSentence(comments, term.CodeCompoundTerm, codeCompoundTerms);
        }
        /// <summary>
        /// Reformat all comments between the specified start and end point. Comments that start
        /// within the range, even if they overlap the end are included.
        /// </summary>
        /// <param name="textDocument">The text document.</param>
        /// <param name="start">The start point.</param>
        /// <param name="end">The end point.</param>
        public bool FormatComments(TextDocument textDocument, EditPoint start, EditPoint end)
        {
            bool foundComments = false;

            var options = FormatterOptions
                          .FromSettings(Settings.Default)
                          .Set(o =>
            {
                o.TabSize      = textDocument.TabSize;
                o.IgnoreTokens = CodeCommentHelper
                                 .GetTaskListTokens(_package)
                                 .Concat(Settings.Default.Formatting_IgnoreLinesStartingWith.Cast <string>())
                                 .ToArray();
            });

            while (start.Line <= end.Line)
            {
                if (CodeCommentHelper.IsCommentLine(start))
                {
                    var comment = new CodeComment(start, options);

                    if (comment.IsValid)
                    {
                        comment.Format();
                        foundComments = true;
                    }

                    if (comment.EndPoint != null)
                    {
                        start = comment.EndPoint.CreateEditPoint();
                    }
                }

                if (start.Line == textDocument.EndPoint.Line)
                {
                    break;
                }

                start.LineDown();
                start.StartOfLine();
            }

            return(foundComments);
        }
        /// <summary>
        /// Generates control fields
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="classType">Type of the class.</param>
        /// <param name="method">The initialize method.</param>
        /// <param name="generateField">if set to <c>true</c> [generate field].</param>
        /// <returns></returns>
        public virtual CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField)
        {
            SeriesPoint point    = source as SeriesPoint;
            string      typeName = point.GetType().Name;
            string      name     = "p_" + ElementGeneratorType.NameUniqueId;

            ElementGeneratorType.NameUniqueId++;

            /*
             * if (generateField)
             * {
             *  CodeMemberField field = new CodeMemberField(typeName, name);
             *  classType.Members.Add(field);
             * }
             */

            CodeComment comment = new CodeComment(name + " point");

            method.Statements.Add(new CodeCommentStatement(comment));

            CodeExpression fieldReference = null;

            //if (!generateField)
            {
                fieldReference = new CodeVariableReferenceExpression(name);
                CodeTypeReference variableType = new CodeTypeReference(typeName);
                CodeVariableDeclarationStatement declaration = new CodeVariableDeclarationStatement(variableType, name);
                declaration.InitExpression = new CodeObjectCreateExpression(typeName);
                method.Statements.Add(declaration);
            }

            /*
             * else
             * {
             *  fieldReference = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), name);
             *  method.Statements.Add(new CodeAssignStatement(fieldReference, new CodeObjectCreateExpression(typeName)));
             * }
             */

            CodeComHelper.GenerateField <float>(method, fieldReference, source, SeriesPoint.ArgumentProperty);
            CodeComHelper.GenerateField <float>(method, fieldReference, source, SeriesPoint.ValueProperty);

            return(fieldReference);
        }
Esempio n. 31
0
        private CodeObject ParseComment(StreamReader sr)
        {
            char ch1 = ' ';
            if (!sr.EndOfStream)
            { ch1 = (char)sr.Read(); }
            char ch2 = ' ';
            if (!sr.EndOfStream)
            { ch2 = (char)sr.Read(); }
            bool endOfComment = ((ch1 == '*') && (ch2 == '/'));

            StringBuilder sbComment = new StringBuilder();
            while ((!sr.EndOfStream) && (!endOfComment))
            {
                sbComment.Append(ch1);
                ch1 = ch2;
                ch2 = (char)sr.Read();
                endOfComment = ((ch1 == '*') && (ch2 == '/'));
            }
            CodeComment cComment = new CodeComment();
            cComment.Value = sbComment.ToString().Trim();
            return cComment;
        }
Esempio n. 32
0
 private void ValidateComment(CodeComment e)
 {
 }
Esempio n. 33
0
 private void GenerateComment(CodeComment e)
 {
     String commentLineStart = (e.DocComment) ? " * " : "//";
     Output.WriteLine(commentLineStart + e.Text);
 }
	public CodeCommentStatement(CodeComment comment) {}
Esempio n. 35
0
 public CodeCommentStatement(string text, bool docComment)
 {
     Comment = new CodeComment(text, docComment);
 }
Esempio n. 36
0
 public CodeCommentStatement(string text)
 {
     Comment = new CodeComment(text);
 }
Esempio n. 37
0
 public CodeCommentStatement(CodeComment comment)
 {
     Comment = comment;
 }
Esempio n. 38
0
 protected abstract void GenerateComment(CodeComment e);
Esempio n. 39
0
        private CodeObject ParsePreprocessorIf(StreamReader sr)
        {
            char ch1 = ' ';
            if (!sr.EndOfStream)
            { ch1 = (char)sr.Read(); }
            char ch2 = ' ';
            if (!sr.EndOfStream)
            { ch2 = (char)sr.Read(); }
            bool endOfComment = ((ch1 == '*') && (ch2 == '/'));

            char[] ddd = { ' ', '\n' };

            StringBuilder sbComment = new StringBuilder();
            while ((!sr.EndOfStream) && (ddd.Where(d => d.Equals(ch1)).Count() == 0))
            {
                sbComment.Append(ch1);
                ch1 = ch2;
                ch2 = (char)sr.Read();
                endOfComment = ((ch1 == '*') && (ch2 == '/'));
            }
            CodeComment cComment = new CodeComment();
            cComment.Value = sbComment.ToString().Trim();
            return cComment;
        }
	// Generate various misc categories.
	protected override void GenerateComment(CodeComment e)
			{
				String text = e.Text;
				String commentSeq = (e.DocComment ? "/// " : "// ");
				if(text == null)
				{
					return;
				}
				int posn = 0;
				int end, next;
				while(posn < text.Length)
				{
					end = posn;
					next = end;
					while(end < text.Length)
					{
						if(text[end] == '\r')
						{
							if((end + 1) < text.Length &&
							   text[end + 1] == '\n')
							{
								next = end + 1;
							}
							break;
						}
						else if(text[end] == '\n' ||
								text[end] == '\u2028' ||
								text[end] == '\u2029')
						{
							break;
						}
						++end;
						next = end;
					}
					Output.Write(commentSeq);
					Output.WriteLine(text.Substring(posn, end - posn));
					posn = next + 1;
				}
			}