Represents a comment.
This is working around the limitations of the .g4 grammar file in use, which ignores comments. Ideally comments would be part of the grammar, and parsed along with the rest of the language syntax into an IParseTree.
コード例 #1
0
 /// <summary>
 /// Creates an inspection result.
 /// </summary>
 protected InspectionResultBase(IInspection inspection, QualifiedModuleName qualifiedName, ParserRuleContext context, CommentNode comment = null)
 {
     _inspection = inspection;
     _qualifiedName = qualifiedName;
     _context = context;
     _comment = comment;
 }
コード例 #2
0
 /// <summary>
 /// Creates an inspection result.
 /// </summary>
 protected CodeInspectionResultBase(string inspection, CodeInspectionSeverity type, QualifiedModuleName qualifiedName, ParserRuleContext context, CommentNode comment = null)
 {
     _name = inspection;
     _type = type;
     _qualifiedName = qualifiedName;
     _context = context;
     _comment = comment;
 }
コード例 #3
0
 public ObsoleteCommentSyntaxInspectionResult(IInspection inspection, CommentNode comment) 
     : base(inspection, comment)
 {
     _quickFixes = new CodeInspectionQuickFix[]
     {
         new ReplaceCommentMarkerQuickFix(Context, QualifiedSelection, comment),
         new RemoveCommentQuickFix(Context, QualifiedSelection, comment), 
         new IgnoreOnceQuickFix(Context, QualifiedSelection, Inspection.AnnotationName), 
     };
 }
コード例 #4
0
 /// <summary>
 /// Creates a comment inspection result.
 /// </summary>
 protected CodeInspectionResultBase(string inspection, CodeInspectionSeverity type, CommentNode comment)
     : this(inspection, type, comment.QualifiedSelection.QualifiedName, null, comment)
 { }
コード例 #5
0
        private IEnumerable<CommentNode> ParseComments(QualifiedModuleName qualifiedName)
        {
            var code = qualifiedName.Component.CodeModule.Code();
            var commentBuilder = new StringBuilder();
            var continuing = false;

            var startLine = 0;
            var startColumn = 0;

            for (var i = 0; i < code.Length; i++)
            {
                var line = code[i];                
                var index = 0;

                if (continuing || line.HasComment(out index))
                {
                    startLine = continuing ? startLine : i;
                    startColumn = continuing ? startColumn : index;

                    var commentLength = line.Length - index;

                    continuing = line.EndsWith("_");
                    if (!continuing)
                    {
                        commentBuilder.Append(line.Substring(index, commentLength).TrimStart());
                        var selection = new Selection(startLine + 1, startColumn + 1, i + 1, line.Length + 1);

                        var result = new CommentNode(commentBuilder.ToString(), new QualifiedSelection(qualifiedName, selection));
                        commentBuilder.Clear();
                        
                        yield return result;
                    }
                    else
                    {
                        // ignore line continuations in comment text:
                        commentBuilder.Append(line.Substring(index, commentLength).TrimStart()); 
                    }
                }
            }
        }
コード例 #6
0
ファイル: ToDoItem.cs プロジェクト: retailcoder/Rubberduck
 public ToDoItem(string markerText, CommentNode comment)
 {
     _description = comment.CommentText;
     _selection = comment.QualifiedSelection;
     _type = markerText;
 }
コード例 #7
0
 public ReplaceCommentMarkerQuickFix(ParserRuleContext context, QualifiedSelection selection, CommentNode comment)
     : base(context, selection, InspectionsUI.ReplaceCommentMarkerQuickFix)
 {
     _comment = comment;
 }
コード例 #8
0
 private IEnumerable<ToDoItem> GetToDoMarkers(CommentNode comment)
 {
     return _markers.Where(marker => comment.Comment.ToLowerInvariant()
                                            .Contains(marker.Text.ToLowerInvariant()))
                    .Select(marker => new ToDoItem(marker.Priority, comment));
 }
コード例 #9
0
ファイル: ToDoItem.cs プロジェクト: ThunderFrame/Rubberduck
 public ToDoItem(TodoPriority priority, CommentNode comment)
     : this(priority, comment.CommentText, comment.QualifiedSelection)
 {
 }
コード例 #10
0
 private IEnumerable<ToDoItem> GetToDoMarkers(CommentNode comment)
 {
     var markers = _configService.LoadConfiguration().UserSettings.ToDoListSettings.ToDoMarkers;
     return markers.Where(marker => !string.IsNullOrEmpty(marker.Text)
                                  && comment.CommentText.ToLowerInvariant().Contains(marker.Text.ToLowerInvariant()))
                    .Select(marker => new ToDoItem(marker.Text, comment));
 }
コード例 #11
0
 /// <summary>
 /// Creates a comment inspection result.
 /// </summary>
 protected InspectionResultBase(IInspection inspection, CommentNode comment)
     : this(inspection, comment.QualifiedSelection.QualifiedName, null, comment)
 { }
コード例 #12
0
 public ObsoleteCommentSyntaxInspectionResult(string inspection, CodeInspectionSeverity type, CommentNode comment) 
     : base(inspection, type, comment)
 {
 }