Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 599 var messageBucket = this._rowMessageBuckets[lineNumber]; | 599 var messageBucket = this._rowMessageBuckets[lineNumber]; |
| 600 if (!messageBucket) | 600 if (!messageBucket) |
| 601 return; | 601 return; |
| 602 messageBucket.removeMessage(message); | 602 messageBucket.removeMessage(message); |
| 603 if (!messageBucket.uniqueMessagesCount()) { | 603 if (!messageBucket.uniqueMessagesCount()) { |
| 604 messageBucket.detachFromEditor(); | 604 messageBucket.detachFromEditor(); |
| 605 delete this._rowMessageBuckets[lineNumber]; | 605 delete this._rowMessageBuckets[lineNumber]; |
| 606 } | 606 } |
| 607 }, | 607 }, |
| 608 | 608 |
| 609 /** | |
| 610 * @param {!Array<!WebInspector.SourceFrameMessage>} messages | |
| 611 */ | |
| 612 setMessagesForSource: function(messages) | |
| 613 { | |
| 614 this.clearMessages(); | |
|
pfeldman
2015/10/26 18:08:49
We should allow for concurrent error messages, you
wes
2015/10/26 22:16:32
Acknowledged.
| |
| 615 for (var index = 0; index < messages.length; index++) { | |
| 616 var message = messages[index]; | |
| 617 this.addMessageToSource(message); | |
| 618 } | |
| 619 }, | |
| 620 | |
| 609 populateLineGutterContextMenu: function(contextMenu, lineNumber) | 621 populateLineGutterContextMenu: function(contextMenu, lineNumber) |
| 610 { | 622 { |
| 611 }, | 623 }, |
| 612 | 624 |
| 613 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber) | 625 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber) |
| 614 { | 626 { |
| 615 }, | 627 }, |
| 616 | 628 |
| 617 /** | 629 /** |
| 618 * @param {?WebInspector.TextRange} from | 630 * @param {?WebInspector.TextRange} from |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 e.consume(true); | 695 e.consume(true); |
| 684 }, | 696 }, |
| 685 | 697 |
| 686 __proto__: WebInspector.VBox.prototype | 698 __proto__: WebInspector.VBox.prototype |
| 687 } | 699 } |
| 688 | 700 |
| 689 /** | 701 /** |
| 690 * @constructor | 702 * @constructor |
| 691 * @param {string} messageText | 703 * @param {string} messageText |
| 692 * @param {!WebInspector.SourceFrameMessage.Level} level | 704 * @param {!WebInspector.SourceFrameMessage.Level} level |
| 693 * @param {number} lineNumber | 705 * @param {!WebInspector.TextRange} range |
| 694 * @param {number=} columnNumber | |
| 695 */ | 706 */ |
| 696 WebInspector.SourceFrameMessage = function(messageText, level, lineNumber, colum nNumber) | 707 WebInspector.SourceFrameMessage = function(messageText, level, range) |
| 697 { | 708 { |
| 698 this._messageText = messageText; | 709 this._messageText = messageText; |
| 699 this._level = level; | 710 this._level = level; |
| 700 this._lineNumber = lineNumber; | 711 this._range = range; |
| 701 this._columnNumber = columnNumber; | |
| 702 } | 712 } |
| 703 | 713 |
| 704 /** | 714 /** |
| 705 * @enum {string} | 715 * @enum {string} |
| 706 */ | 716 */ |
| 707 WebInspector.SourceFrameMessage.Level = { | 717 WebInspector.SourceFrameMessage.Level = { |
| 708 Error: "Error", | 718 Error: "Error", |
| 709 Warning: "Warning" | 719 Warning: "Warning" |
| 710 } | 720 } |
| 711 | 721 |
| 712 /** | 722 /** |
| 713 * @param {!WebInspector.ConsoleMessage} consoleMessage | 723 * @param {!WebInspector.ConsoleMessage} consoleMessage |
| 714 * @param {number} lineNumber | 724 * @param {number} lineNumber |
| 715 * @param {number} columnNumber | 725 * @param {number} columnNumber |
| 716 * @return {!WebInspector.SourceFrameMessage} | 726 * @return {!WebInspector.SourceFrameMessage} |
| 717 */ | 727 */ |
| 718 WebInspector.SourceFrameMessage.fromConsoleMessage = function(consoleMessage, li neNumber, columnNumber) | 728 WebInspector.SourceFrameMessage.fromConsoleMessage = function(consoleMessage, li neNumber, columnNumber) |
| 719 { | 729 { |
| 720 console.assert(consoleMessage.level === WebInspector.ConsoleMessage.MessageL evel.Error || consoleMessage.level === WebInspector.ConsoleMessage.MessageLevel. Warning); | 730 console.assert(consoleMessage.level === WebInspector.ConsoleMessage.MessageL evel.Error || consoleMessage.level === WebInspector.ConsoleMessage.MessageLevel. Warning); |
| 721 var level = consoleMessage.level === WebInspector.ConsoleMessage.MessageLeve l.Error ? WebInspector.SourceFrameMessage.Level.Error : WebInspector.SourceFrame Message.Level.Warning; | 731 var level = consoleMessage.level === WebInspector.ConsoleMessage.MessageLeve l.Error ? WebInspector.SourceFrameMessage.Level.Error : WebInspector.SourceFrame Message.Level.Warning; |
| 722 return new WebInspector.SourceFrameMessage(consoleMessage.messageText, level , lineNumber, columnNumber); | 732 var location = new WebInspector.TextRange(lineNumber, columnNumber, lineNumb er, columnNumber); |
| 733 return new WebInspector.SourceFrameMessage(consoleMessage.messageText, level , location); | |
| 723 } | 734 } |
| 724 | 735 |
| 725 WebInspector.SourceFrameMessage.prototype = { | 736 WebInspector.SourceFrameMessage.prototype = { |
| 726 /** | 737 /** |
| 727 * @return {string} | 738 * @return {string} |
| 728 */ | 739 */ |
| 729 messageText: function() | 740 messageText: function() |
| 730 { | 741 { |
| 731 return this._messageText; | 742 return this._messageText; |
| 732 }, | 743 }, |
| 733 | 744 |
| 734 /** | 745 /** |
| 735 * @return {!WebInspector.SourceFrameMessage.Level} | 746 * @return {!WebInspector.SourceFrameMessage.Level} |
| 736 */ | 747 */ |
| 737 level: function() | 748 level: function() |
| 738 { | 749 { |
| 739 return this._level; | 750 return this._level; |
| 740 }, | 751 }, |
| 741 | 752 |
| 742 /** | 753 /** |
| 754 * @return {!WebInspector.TextRange} | |
| 755 */ | |
| 756 range: function() | |
| 757 { | |
| 758 return this._range; | |
| 759 }, | |
| 760 | |
| 761 /** | |
| 743 * @return {number} | 762 * @return {number} |
| 744 */ | 763 */ |
| 745 lineNumber: function() | 764 lineNumber: function() |
|
pfeldman
2015/10/26 18:08:49
We can not remove these in favor of the one above.
wes
2015/10/26 22:16:32
Is there an action for me on this comment, or is t
| |
| 746 { | 765 { |
| 747 return this._lineNumber; | 766 return this._range.startLine; |
| 748 }, | 767 }, |
| 749 | 768 |
| 750 /** | 769 /** |
| 751 * @return {(number|undefined)} | 770 * @return {(number|undefined)} |
| 752 */ | 771 */ |
| 753 columnNumber: function() | 772 columnNumber: function() |
|
pfeldman
2015/10/26 18:08:49
We can not remove these in favor of the one above.
wes
2015/10/26 22:16:32
Same as above?
| |
| 754 { | 773 { |
| 755 return this._columnNumber; | 774 return this._range.startColumn; |
| 756 }, | 775 }, |
| 757 | 776 |
| 758 /** | 777 /** |
| 759 * @param {!WebInspector.SourceFrameMessage} another | 778 * @param {!WebInspector.SourceFrameMessage} another |
| 760 * @return {boolean} | 779 * @return {boolean} |
| 761 */ | 780 */ |
| 762 isEqual: function(another) | 781 isEqual: function(another) |
| 763 { | 782 { |
| 764 return this.messageText() === another.messageText() && this.level() === another.level() && this.lineNumber() === another.lineNumber() && this.columnNumb er() === another.columnNumber(); | 783 return this.messageText() === another.messageText() && |
|
pfeldman
2015/10/26 18:08:49
poor formatting.
wes
2015/10/26 22:16:32
Acknowledged.
| |
| 784 this.level() === another.level() && | |
| 785 this.range().equal(another.range()); | |
| 765 } | 786 } |
| 766 } | 787 } |
| 767 | 788 |
| 768 WebInspector.SourceFrame._iconClassPerLevel = {}; | 789 WebInspector.SourceFrame._iconClassPerLevel = {}; |
| 769 WebInspector.SourceFrame._iconClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Error] = "error-icon"; | 790 WebInspector.SourceFrame._iconClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Error] = "error-icon"; |
| 770 WebInspector.SourceFrame._iconClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Warning] = "warning-icon"; | 791 WebInspector.SourceFrame._iconClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Warning] = "warning-icon"; |
| 771 | 792 |
| 772 WebInspector.SourceFrame._lineClassPerLevel = {}; | 793 WebInspector.SourceFrame._lineClassPerLevel = {}; |
| 773 WebInspector.SourceFrame._lineClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Error] = "text-editor-line-with-error"; | 794 WebInspector.SourceFrame._lineClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Error] = "text-editor-line-with-error"; |
| 774 WebInspector.SourceFrame._lineClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Warning] = "text-editor-line-with-warning"; | 795 WebInspector.SourceFrame._lineClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Warning] = "text-editor-line-with-warning"; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 859 */ | 880 */ |
| 860 _updateWavePosition: function(lineNumber, columnNumber) | 881 _updateWavePosition: function(lineNumber, columnNumber) |
| 861 { | 882 { |
| 862 lineNumber = Math.min(lineNumber, this._textEditor.linesCount - 1); | 883 lineNumber = Math.min(lineNumber, this._textEditor.linesCount - 1); |
| 863 var lineText = this._textEditor.line(lineNumber); | 884 var lineText = this._textEditor.line(lineNumber); |
| 864 columnNumber = Math.min(columnNumber, lineText.length); | 885 columnNumber = Math.min(columnNumber, lineText.length); |
| 865 var lineIndent = WebInspector.TextUtils.lineIndent(lineText).length; | 886 var lineIndent = WebInspector.TextUtils.lineIndent(lineText).length; |
| 866 var base = this._textEditor.cursorPositionToCoordinates(lineNumber, 0); | 887 var base = this._textEditor.cursorPositionToCoordinates(lineNumber, 0); |
| 867 | 888 |
| 868 var start = this._textEditor.cursorPositionToCoordinates(lineNumber, Mat h.max(columnNumber - 1, lineIndent)); | 889 var start = this._textEditor.cursorPositionToCoordinates(lineNumber, Mat h.max(columnNumber - 1, lineIndent)); |
| 890 if (!start) | |
| 891 return; //stale data - columnNumber is already gone, wait for future update and for UI to settle | |
| 869 var end = this._textEditor.cursorPositionToCoordinates(lineNumber, lineT ext.length); | 892 var end = this._textEditor.cursorPositionToCoordinates(lineNumber, lineT ext.length); |
| 870 /** @const */ | 893 /** @const */ |
| 871 var codeMirrorLinesLeftPadding = 4; | 894 var codeMirrorLinesLeftPadding = 4; |
| 872 this._wave.style.left = (start.x - base.x + codeMirrorLinesLeftPadding) + "px"; | 895 this._wave.style.left = (start.x - base.x + codeMirrorLinesLeftPadding) + "px"; |
| 873 this._wave.style.width = (end.x - start.x) + "px"; | 896 this._wave.style.width = (end.x - start.x) + "px"; |
| 874 }, | 897 }, |
| 875 | 898 |
| 876 /** | 899 /** |
| 877 * @return {!Element} | 900 * @return {!Element} |
| 878 */ | 901 */ |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1050 | 1073 |
| 1051 /** | 1074 /** |
| 1052 * @param {!WebInspector.SourceFrameMessage} a | 1075 * @param {!WebInspector.SourceFrameMessage} a |
| 1053 * @param {!WebInspector.SourceFrameMessage} b | 1076 * @param {!WebInspector.SourceFrameMessage} b |
| 1054 * @return {number} | 1077 * @return {number} |
| 1055 */ | 1078 */ |
| 1056 WebInspector.SourceFrameMessage.messageLevelComparator = function(a, b) | 1079 WebInspector.SourceFrameMessage.messageLevelComparator = function(a, b) |
| 1057 { | 1080 { |
| 1058 return WebInspector.SourceFrameMessage._messageLevelPriority[a.level()] - We bInspector.SourceFrameMessage._messageLevelPriority[b.level()]; | 1081 return WebInspector.SourceFrameMessage._messageLevelPriority[a.level()] - We bInspector.SourceFrameMessage._messageLevelPriority[b.level()]; |
| 1059 } | 1082 } |
| OLD | NEW |