void VisitComment (ParsedDocument result, SpecialsBag.Comment comment, string[] tagComments) { var cmt = new MonoDevelop.Projects.Dom.Comment (comment.Content); cmt.CommentStartsLine = comment.StartsLine; switch (comment.CommentType) { case SpecialsBag.CommentType.Multi: cmt.CommentType = MonoDevelop.Projects.Dom.CommentType.MultiLine; cmt.OpenTag = "/*"; cmt.ClosingTag = "*/"; break; case SpecialsBag.CommentType.Single: cmt.CommentType = MonoDevelop.Projects.Dom.CommentType.SingleLine; cmt.OpenTag = "//"; break; case SpecialsBag.CommentType.Documentation: cmt.CommentType = MonoDevelop.Projects.Dom.CommentType.SingleLine; cmt.IsDocumentation = true; cmt.OpenTag = "///"; break; } cmt.Region = new DomRegion (comment.Line, comment.Col, comment.EndLine, comment.EndCol); result.Comments.Add (cmt); foreach (string tag in tagComments) { int idx = comment.Content.IndexOf (tag); if (idx < 0) continue; result.Add (new Tag (tag, comment.Content, cmt.Region)); } }
void VisitPreprocessorDirective (ParsedDocument result, SpecialsBag.PreProcessorDirective directive) { DomLocation loc = new DomLocation (directive.Line, directive.Col); switch (directive.Cmd) { case Tokenizer.PreprocessorDirective.If: conditionalRegions.Push (new ConditionalRegion (visitor.Text)); ifBlocks.Push (directive); ConditionalRegion.Start = loc; break; case Tokenizer.PreprocessorDirective.Elif: CloseConditionBlock (new DomLocation (directive.EndLine, directive.EndCol)); if (ConditionalRegion != null) ConditionalRegion.ConditionBlocks.Add (new ConditionBlock (visitor.Text, loc)); break; case Tokenizer.PreprocessorDirective.Else: CloseConditionBlock (new DomLocation (directive.EndLine, directive.EndCol)); if (ConditionalRegion != null) ConditionalRegion.ElseBlock = new DomRegion (loc, DomLocation.Empty); break; case Tokenizer.PreprocessorDirective.Endif: DomLocation endLoc = new DomLocation (directive.EndLine, directive.EndCol); CloseConditionBlock (endLoc); if (ConditionalRegion != null && !ConditionalRegion.ElseBlock.Start.IsEmpty) ConditionalRegion.ElseBlock = new DomRegion (ConditionalRegion.ElseBlock.Start, endLoc); AddCurRegion (result, directive.EndLine, directive.EndCol); if (ifBlocks.Count > 0) { var ifBlock = ifBlocks.Pop (); DomRegion dr = new DomRegion (ifBlock.Line, ifBlock.Col, directive.EndLine, directive.EndCol); result.Add (new FoldingRegion ("#if " + ifBlock.Arg.Trim (), dr, FoldType.UserRegion, false)); foreach (var d in elifBlocks) { dr.Start = new DomLocation (d.Line, d.Col); result.Add (new FoldingRegion ("#elif " + ifBlock.Arg.Trim (), dr, FoldType.UserRegion, false)); } if (elseBlock != null) { dr.Start = new DomLocation (elseBlock.Line, elseBlock.Col); result.Add (new FoldingRegion ("#else", dr, FoldType.UserRegion, false)); } } elseBlock = null; break; case Tokenizer.PreprocessorDirective.Define: result.Add (new PreProcessorDefine (directive.Arg, loc)); break; case Tokenizer.PreprocessorDirective.Region: regions.Push (directive); break; case Tokenizer.PreprocessorDirective.Endregion: if (regions.Count > 0) { var start = regions.Pop (); DomRegion dr = new DomRegion (start.Line, start.Col, directive.EndLine, directive.EndCol); result.Add (new FoldingRegion (start.Arg, dr, FoldType.UserRegion, true)); } break; } }
void VisitComment (ParsedDocument result, SpecialsBag.Comment comment) { var cmt = new MonoDevelop.Projects.Dom.Comment (comment.Content); cmt.CommentStartsLine = comment.StartsLine; switch (comment.CommentType) { case SpecialsBag.CommentType.Multi: cmt.CommentType = MonoDevelop.Projects.Dom.CommentType.MultiLine; cmt.OpenTag = "/*"; cmt.ClosingTag = "*/"; break; case SpecialsBag.CommentType.Single: cmt.CommentType = MonoDevelop.Projects.Dom.CommentType.SingleLine; cmt.OpenTag = "//"; break; case SpecialsBag.CommentType.Documentation: cmt.CommentType = MonoDevelop.Projects.Dom.CommentType.SingleLine; cmt.IsDocumentation = true; cmt.OpenTag = "///"; break; } cmt.Region = new DomRegion (comment.Line, comment.Col, comment.EndLine, comment.EndCol); result.Comments.Add (cmt); }