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 setMessagesForSource: function(messages) { | |
|
pfeldman
2015/10/21 23:47:53
This requires JSDoc and { to be on the next line.
wes
2015/10/23 20:35:30
Acknowledged.
| |
| 610 this.clearMessages(); | |
| 611 for (var index = 0; index < messages.length; index++) { | |
| 612 var message = messages[index]; | |
| 613 this.addMessageToSource(message); | |
| 614 } | |
| 615 }, | |
| 616 | |
| 609 populateLineGutterContextMenu: function(contextMenu, lineNumber) | 617 populateLineGutterContextMenu: function(contextMenu, lineNumber) |
| 610 { | 618 { |
| 611 }, | 619 }, |
| 612 | 620 |
| 613 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber) | 621 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber) |
| 614 { | 622 { |
| 615 }, | 623 }, |
| 616 | 624 |
| 617 /** | 625 /** |
| 618 * @param {?WebInspector.TextRange} from | 626 * @param {?WebInspector.TextRange} from |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 e.consume(true); | 691 e.consume(true); |
| 684 }, | 692 }, |
| 685 | 693 |
| 686 __proto__: WebInspector.VBox.prototype | 694 __proto__: WebInspector.VBox.prototype |
| 687 } | 695 } |
| 688 | 696 |
| 689 /** | 697 /** |
| 690 * @constructor | 698 * @constructor |
| 691 * @param {string} messageText | 699 * @param {string} messageText |
| 692 * @param {!WebInspector.SourceFrameMessage.Level} level | 700 * @param {!WebInspector.SourceFrameMessage.Level} level |
| 693 * @param {number} lineNumber | 701 * @param {{line: number, column: (number|undefined)}} start |
| 694 * @param {number=} columnNumber | 702 * @param {{line: number, column: (number|undefined)}} end |
| 695 */ | 703 */ |
| 696 WebInspector.SourceFrameMessage = function(messageText, level, lineNumber, colum nNumber) | 704 WebInspector.SourceFrameMessage = function(messageText, level, start, end) |
| 697 { | 705 { |
| 698 this._messageText = messageText; | 706 this._messageText = messageText; |
| 699 this._level = level; | 707 this._level = level; |
| 700 this._lineNumber = lineNumber; | 708 this._start = { |
|
pfeldman
2015/10/21 23:47:53
We have WebInspector.TextRange that could be reuse
wes
2015/10/23 20:35:30
Acknowledged.
| |
| 701 this._columnNumber = columnNumber; | 709 line: start.line, |
| 710 column: start.column | |
| 711 }; | |
| 712 this._end = { | |
| 713 line: end.line, | |
| 714 column: end.column | |
| 715 }; | |
| 702 } | 716 } |
| 703 | 717 |
| 704 /** | 718 /** |
| 705 * @enum {string} | 719 * @enum {string} |
| 706 */ | 720 */ |
| 707 WebInspector.SourceFrameMessage.Level = { | 721 WebInspector.SourceFrameMessage.Level = { |
| 708 Error: "Error", | 722 Error: "Error", |
| 709 Warning: "Warning" | 723 Warning: "Warning" |
| 710 } | 724 } |
| 711 | 725 |
| 712 /** | 726 /** |
| 713 * @param {!WebInspector.ConsoleMessage} consoleMessage | 727 * @param {!WebInspector.ConsoleMessage} consoleMessage |
| 714 * @param {number} lineNumber | 728 * @param {number} lineNumber |
| 715 * @param {number} columnNumber | 729 * @param {number} columnNumber |
| 716 * @return {!WebInspector.SourceFrameMessage} | 730 * @return {!WebInspector.SourceFrameMessage} |
| 717 */ | 731 */ |
| 718 WebInspector.SourceFrameMessage.fromConsoleMessage = function(consoleMessage, li neNumber, columnNumber) | 732 WebInspector.SourceFrameMessage.fromConsoleMessage = function(consoleMessage, li neNumber, columnNumber) |
| 719 { | 733 { |
| 720 console.assert(consoleMessage.level === WebInspector.ConsoleMessage.MessageL evel.Error || consoleMessage.level === WebInspector.ConsoleMessage.MessageLevel. Warning); | 734 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; | 735 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); | 736 var location = {line: lineNumber, column: columnNumber}; |
|
pfeldman
2015/10/21 23:47:53
Should this also be a range now?
wes
2015/10/23 20:35:29
Yep.
| |
| 737 return new WebInspector.SourceFrameMessage(consoleMessage.messageText, level , location, location); | |
| 723 } | 738 } |
| 724 | 739 |
| 725 WebInspector.SourceFrameMessage.prototype = { | 740 WebInspector.SourceFrameMessage.prototype = { |
| 726 /** | 741 /** |
| 727 * @return {string} | 742 * @return {string} |
| 728 */ | 743 */ |
| 729 messageText: function() | 744 messageText: function() |
| 730 { | 745 { |
| 731 return this._messageText; | 746 return this._messageText; |
| 732 }, | 747 }, |
| 733 | 748 |
| 734 /** | 749 /** |
| 735 * @return {!WebInspector.SourceFrameMessage.Level} | 750 * @return {!WebInspector.SourceFrameMessage.Level} |
| 736 */ | 751 */ |
| 737 level: function() | 752 level: function() |
| 738 { | 753 { |
| 739 return this._level; | 754 return this._level; |
| 740 }, | 755 }, |
| 741 | 756 |
| 742 /** | 757 /** |
| 758 * @return {{line: number, column: (number|undefined)}} | |
| 759 */ | |
| 760 start: function() { | |
|
pfeldman
2015/10/21 23:47:53
{ goes the next line.
wes
2015/10/23 20:35:29
Acknowledged.
| |
| 761 return this._start; | |
| 762 }, | |
| 763 | |
| 764 /** | |
| 765 * @return {{line: number, column: (number|undefined)}} | |
| 766 */ | |
| 767 end: function() { | |
| 768 return this._end; | |
| 769 }, | |
| 770 | |
| 771 /** | |
| 743 * @return {number} | 772 * @return {number} |
| 744 */ | 773 */ |
| 745 lineNumber: function() | 774 lineNumber: function() |
| 746 { | 775 { |
| 747 return this._lineNumber; | 776 return this._start.line; |
| 748 }, | 777 }, |
| 749 | 778 |
| 750 /** | 779 /** |
| 751 * @return {(number|undefined)} | 780 * @return {(number|undefined)} |
| 752 */ | 781 */ |
| 753 columnNumber: function() | 782 columnNumber: function() |
| 754 { | 783 { |
| 755 return this._columnNumber; | 784 return this._start.column; |
| 756 }, | 785 }, |
| 757 | 786 |
| 758 /** | 787 /** |
| 759 * @param {!WebInspector.SourceFrameMessage} another | 788 * @param {!WebInspector.SourceFrameMessage} another |
| 760 * @return {boolean} | 789 * @return {boolean} |
| 761 */ | 790 */ |
| 762 isEqual: function(another) | 791 isEqual: function(another) |
| 763 { | 792 { |
| 764 return this.messageText() === another.messageText() && this.level() === another.level() && this.lineNumber() === another.lineNumber() && this.columnNumb er() === another.columnNumber(); | 793 return this.messageText() === another.messageText() && |
| 794 this.level() === another.level() && | |
| 795 this.lineNumber() === another.lineNumber() && | |
| 796 this.columnNumber() === another.columnNumber() && | |
| 797 this.end().line === another.end().line && | |
| 798 this.end().column === another.end().column; | |
| 765 } | 799 } |
| 766 } | 800 } |
| 767 | 801 |
| 768 WebInspector.SourceFrame._iconClassPerLevel = {}; | 802 WebInspector.SourceFrame._iconClassPerLevel = {}; |
| 769 WebInspector.SourceFrame._iconClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Error] = "error-icon"; | 803 WebInspector.SourceFrame._iconClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Error] = "error-icon"; |
| 770 WebInspector.SourceFrame._iconClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Warning] = "warning-icon"; | 804 WebInspector.SourceFrame._iconClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Warning] = "warning-icon"; |
| 771 | 805 |
| 772 WebInspector.SourceFrame._lineClassPerLevel = {}; | 806 WebInspector.SourceFrame._lineClassPerLevel = {}; |
| 773 WebInspector.SourceFrame._lineClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Error] = "text-editor-line-with-error"; | 807 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"; | 808 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 */ | 893 */ |
| 860 _updateWavePosition: function(lineNumber, columnNumber) | 894 _updateWavePosition: function(lineNumber, columnNumber) |
| 861 { | 895 { |
| 862 lineNumber = Math.min(lineNumber, this._textEditor.linesCount - 1); | 896 lineNumber = Math.min(lineNumber, this._textEditor.linesCount - 1); |
| 863 var lineText = this._textEditor.line(lineNumber); | 897 var lineText = this._textEditor.line(lineNumber); |
| 864 columnNumber = Math.min(columnNumber, lineText.length); | 898 columnNumber = Math.min(columnNumber, lineText.length); |
| 865 var lineIndent = WebInspector.TextUtils.lineIndent(lineText).length; | 899 var lineIndent = WebInspector.TextUtils.lineIndent(lineText).length; |
| 866 var base = this._textEditor.cursorPositionToCoordinates(lineNumber, 0); | 900 var base = this._textEditor.cursorPositionToCoordinates(lineNumber, 0); |
| 867 | 901 |
| 868 var start = this._textEditor.cursorPositionToCoordinates(lineNumber, Mat h.max(columnNumber - 1, lineIndent)); | 902 var start = this._textEditor.cursorPositionToCoordinates(lineNumber, Mat h.max(columnNumber - 1, lineIndent)); |
| 903 if (!start) { | |
|
pfeldman
2015/10/21 23:47:53
drop {}
wes
2015/10/23 20:35:29
Acknowledged.
| |
| 904 return; //stale data - columnNumber is already gone, wait for future update and for UI to settle | |
| 905 } | |
| 869 var end = this._textEditor.cursorPositionToCoordinates(lineNumber, lineT ext.length); | 906 var end = this._textEditor.cursorPositionToCoordinates(lineNumber, lineT ext.length); |
| 870 /** @const */ | 907 /** @const */ |
| 871 var codeMirrorLinesLeftPadding = 4; | 908 var codeMirrorLinesLeftPadding = 4; |
| 872 this._wave.style.left = (start.x - base.x + codeMirrorLinesLeftPadding) + "px"; | 909 this._wave.style.left = (start.x - base.x + codeMirrorLinesLeftPadding) + "px"; |
| 873 this._wave.style.width = (end.x - start.x) + "px"; | 910 this._wave.style.width = (end.x - start.x) + "px"; |
| 874 }, | 911 }, |
| 875 | 912 |
| 876 /** | 913 /** |
| 877 * @return {!Element} | 914 * @return {!Element} |
| 878 */ | 915 */ |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1050 | 1087 |
| 1051 /** | 1088 /** |
| 1052 * @param {!WebInspector.SourceFrameMessage} a | 1089 * @param {!WebInspector.SourceFrameMessage} a |
| 1053 * @param {!WebInspector.SourceFrameMessage} b | 1090 * @param {!WebInspector.SourceFrameMessage} b |
| 1054 * @return {number} | 1091 * @return {number} |
| 1055 */ | 1092 */ |
| 1056 WebInspector.SourceFrameMessage.messageLevelComparator = function(a, b) | 1093 WebInspector.SourceFrameMessage.messageLevelComparator = function(a, b) |
| 1057 { | 1094 { |
| 1058 return WebInspector.SourceFrameMessage._messageLevelPriority[a.level()] - We bInspector.SourceFrameMessage._messageLevelPriority[b.level()]; | 1095 return WebInspector.SourceFrameMessage._messageLevelPriority[a.level()] - We bInspector.SourceFrameMessage._messageLevelPriority[b.level()]; |
| 1059 } | 1096 } |
| OLD | NEW |