Example #1
0
 // Tokenizer callback. Extracts comment tasks (like "TODO" or "HACK") from comments.
 private void ProcessComment(List<TaskProviderItem> commentTasks, ITextSnapshot snapshot, SourceSpan span, string text) {
     if (text.Length > 0) {
         var tokens = _commentTaskProvider.Tokens;
         if (tokens != null) {
             foreach (var kv in tokens) {
                 if (text.IndexOf(kv.Key, StringComparison.OrdinalIgnoreCase) >= 0) {
                     commentTasks.Add(new TaskProviderItem(_serviceProvider, text.Substring(1).Trim(), span, kv.Value, VSTASKCATEGORY.CAT_COMMENTS, false, snapshot));
                 }
             }
         }
     }
 }
Example #2
0
 public CommentEventArgs(SourceSpan span, string text) {
     Span = span;
     Text = text;
 }
Example #3
0
 // Tokenizer callback. Extracts comment tasks (like "TODO" or "HACK") from comments.
 private void ProcessComment(List<AP.TaskItem> commentTasks, SourceSpan span, string text) {
     if (text.Length > 0) {
         var tokens = _commentPriorityMap;
         if (tokens != null) {
             foreach (var kv in tokens) {
                 if (text.IndexOf(kv.Key, StringComparison.OrdinalIgnoreCase) >= 0) {
                     commentTasks.Add(
                         new AP.TaskItem() {
                             message = text.Substring(1).Trim(),
                             startLine = span.Start.Line,
                             startColumn = span.Start.Column,
                             startIndex = span.Start.Index,
                             endLine = span.End.Line,
                             endColumn = span.End.Column,
                             length = span.Length,
                             priority = kv.Value,
                             category = AP.TaskCategory.comments,
                             squiggle = false
                         }
                     );
                 }
             }
         }
     }
 }
Example #4
0
 public ErrorInfo(string msg, int startIndex, int startLine, int startCol, int endIndex, int endLine, int endCol) {
     Message = msg;
     Span = new SourceSpan(new SourceLocation(startIndex, startLine, startCol), new SourceLocation(endIndex, endLine, endCol));
 }
Example #5
0
        private static void DeleteStatement(VisualStudio.Text.ITextEdit edit, SourceSpan span, bool insertPass) {
            // remove the entire node, leave any trailing whitespace/comments, but include the
            // newline and any indentation.


            int start = span.Start.Index;
            int length = span.Length;
            int cur = start - 1;
            if (!insertPass) {
                // backup to remove any indentation
                while (start - 1 > 0) {
                    var curChar = edit.Snapshot.GetText(start - 1, 1);
                    if (curChar[0] == ' ' || curChar[0] == '\t' || curChar[0] == '\f') {
                        length++;
                        start--;
                    } else {
                        break;
                    }
                }
            }

            // extend past any trailing whitespace characters
            while (start + length < edit.Snapshot.Length) {
                var curChar = edit.Snapshot.GetText(start + length, 1);
                if (curChar[0] == ' ' || curChar[0] == '\t' || curChar[0] == '\f') {
                    length++;
                } else {
                    break;
                }
            }

            // remove the trailing newline as well.
            if (!insertPass) {
                if (start + length < edit.Snapshot.Length) {
                    var newlineText = edit.Snapshot.GetText(start + length, 1);
                    if (newlineText == "\r") {
                        if (start + length + 1 < edit.Snapshot.Length) {
                            newlineText = edit.Snapshot.GetText(start + length + 1, 1);
                            if (newlineText == "\n") {
                                length += 2;
                            } else {
                                length++;
                            }
                        } else {
                            length++;
                        }
                    } else if (newlineText == "\n") {
                        length++;
                    }
                }
            }
            edit.Delete(start, length);

            if (insertPass) {
                edit.Insert(start, "pass");
            }
        }
Example #6
0
        private void DeleteStatement(List<AP.ChangeInfo> changes, SourceSpan span, bool insertPass) {
            // remove the entire node, leave any trailing whitespace/comments, but include the
            // newline and any indentation.


            int start = span.Start.Index;
            int length = span.Length;
            int cur = start - 1;
            if (!insertPass) {
                // backup to remove any indentation
                while (start - 1 > 0) {
                    var curChar = _code[start - 1];
                    if (curChar == ' ' || curChar == '\t' || curChar == '\f') {
                        length++;
                        start--;
                    } else {
                        break;
                    }
                }
            }

            // extend past any trailing whitespace characters
            while (start + length < _code.Length) {
                var curChar = _code[start + length];
                if (curChar == ' ' || curChar == '\t' || curChar == '\f') {
                    length++;
                } else {
                    break;
                }
            }

            // remove the trailing newline as well.
            if (!insertPass) {
                if (start + length < _code.Length) {
                    var newlineText = _code[start + length];
                    if (newlineText == '\r') {
                        if (start + length + 1 < _code.Length) {
                            newlineText = _code[start + length + 1];
                            if (newlineText == '\n') {
                                length += 2;
                            } else {
                                length++;
                            }
                        } else {
                            length++;
                        }
                    } else if (newlineText == '\n') {
                        length++;
                    }
                }
            }

            changes.Add(
                new AP.ChangeInfo() {
                    start = start,
                    length = length,
                    newText = insertPass ? "pass" : ""
                }
            );
            
        }