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.
Ejemplo n.º 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;
 }
 /// <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;
 }
 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), 
     };
 }
 /// <summary>
 /// Creates a comment inspection result.
 /// </summary>
 protected CodeInspectionResultBase(string inspection, CodeInspectionSeverity type, CommentNode comment)
     : this(inspection, type, comment.QualifiedSelection.QualifiedName, null, comment)
 { }
Ejemplo n.º 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()); 
                    }
                }
            }
        }
Ejemplo n.º 6
0
 public ToDoItem(string markerText, CommentNode comment)
 {
     _description = comment.CommentText;
     _selection = comment.QualifiedSelection;
     _type = markerText;
 }
 public ReplaceCommentMarkerQuickFix(ParserRuleContext context, QualifiedSelection selection, CommentNode comment)
     : base(context, selection, InspectionsUI.ReplaceCommentMarkerQuickFix)
 {
     _comment = comment;
 }
 private IEnumerable<ToDoItem> GetToDoMarkers(CommentNode comment)
 {
     return _markers.Where(marker => comment.Comment.ToLowerInvariant()
                                            .Contains(marker.Text.ToLowerInvariant()))
                    .Select(marker => new ToDoItem(marker.Priority, comment));
 }
Ejemplo n.º 9
0
 public ToDoItem(TodoPriority priority, CommentNode comment)
     : this(priority, comment.CommentText, comment.QualifiedSelection)
 {
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates a comment inspection result.
 /// </summary>
 protected InspectionResultBase(IInspection inspection, CommentNode comment)
     : this(inspection, comment.QualifiedSelection.QualifiedName, null, comment)
 { }
 public ObsoleteCommentSyntaxInspectionResult(string inspection, CodeInspectionSeverity type, CommentNode comment) 
     : base(inspection, type, comment)
 {
 }