Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js

Issue 1456943003: Devtools: use TextRange in UISourceCode.Message, allow addMessage to take a TextRange (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 * @return {!Array<!WebInspector.UISourceCode.Message>} 590 * @return {!Array<!WebInspector.UISourceCode.Message>}
591 */ 591 */
592 messages: function() 592 messages: function()
593 { 593 {
594 return this._messages.slice(); 594 return this._messages.slice();
595 }, 595 },
596 596
597 /** 597 /**
598 * @param {!WebInspector.UISourceCode.Message.Level} level 598 * @param {!WebInspector.UISourceCode.Message.Level} level
599 * @param {string} text 599 * @param {string} text
600 * @param {number} lineNumber 600 * @param {number|!WebInspector.TextRange} lineNumberOrRange
pfeldman 2015/11/19 19:18:25 Lets always use the range - we try to not do insta
wes 2015/11/19 22:11:25 Acknowledged.
601 * @param {number=} columnNumber 601 * @param {number=} columnNumber
602 * @return {!WebInspector.UISourceCode.Message} message 602 * @return {!WebInspector.UISourceCode.Message} message
603 */ 603 */
604 addMessage: function(level, text, lineNumber, columnNumber) 604 addMessage: function(level, text, lineNumberOrRange, columnNumber)
605 { 605 {
606 var message = new WebInspector.UISourceCode.Message(this, level, text, l ineNumber, columnNumber); 606 /** @type {!WebInspector.TextRange} */
607 var textRange;
608 if (lineNumberOrRange instanceof WebInspector.TextRange) {
609 textRange = lineNumberOrRange;
610 } else {
611 textRange = new WebInspector.TextRange(lineNumberOrRange, columnNumb er || 0, lineNumberOrRange, columnNumber || 0);
612 }
613 var message = new WebInspector.UISourceCode.Message(this, level, text, t extRange);
607 this._messages.push(message); 614 this._messages.push(message);
608 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.MessageAd ded, message); 615 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.MessageAd ded, message);
609 return message; 616 return message;
610 }, 617 },
611 618
612 /** 619 /**
613 * @param {!WebInspector.UISourceCode.Message} message 620 * @param {!WebInspector.UISourceCode.Message} message
614 */ 621 */
615 removeMessage: function(message) 622 removeMessage: function(message)
616 { 623 {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 { 770 {
764 callback([]); 771 callback([]);
765 } 772 }
766 } 773 }
767 774
768 /** 775 /**
769 * @constructor 776 * @constructor
770 * @param {!WebInspector.UISourceCode} uiSourceCode 777 * @param {!WebInspector.UISourceCode} uiSourceCode
771 * @param {!WebInspector.UISourceCode.Message.Level} level 778 * @param {!WebInspector.UISourceCode.Message.Level} level
772 * @param {string} text 779 * @param {string} text
773 * @param {number} lineNumber 780 * @param {!WebInspector.TextRange} range
774 * @param {number=} columnNumber
775 */ 781 */
776 WebInspector.UISourceCode.Message = function(uiSourceCode, level, text, lineNumb er, columnNumber) 782 WebInspector.UISourceCode.Message = function(uiSourceCode, level, text, range)
777 { 783 {
778 this._uiSourceCode = uiSourceCode; 784 this._uiSourceCode = uiSourceCode;
779 this._level = level; 785 this._level = level;
780 this._text = text; 786 this._text = text;
781 this._lineNumber = lineNumber; 787 this._range = range;
782 this._columnNumber = columnNumber;
783 } 788 }
784 789
785 /** 790 /**
786 * @enum {string} 791 * @enum {string}
787 */ 792 */
788 WebInspector.UISourceCode.Message.Level = { 793 WebInspector.UISourceCode.Message.Level = {
789 Error: "Error", 794 Error: "Error",
790 Warning: "Warning" 795 Warning: "Warning"
791 } 796 }
792 797
(...skipping 16 matching lines...) Expand all
809 814
810 /** 815 /**
811 * @return {string} 816 * @return {string}
812 */ 817 */
813 text: function() 818 text: function()
814 { 819 {
815 return this._text; 820 return this._text;
816 }, 821 },
817 822
818 /** 823 /**
824 * @return {!WebInspector.TextRange}
825 */
826 range: function() {
827 return this._range;
828 },
829
830 /**
819 * @return {number} 831 * @return {number}
820 */ 832 */
821 lineNumber: function() 833 lineNumber: function()
822 { 834 {
823 return this._lineNumber; 835 return this._range.startLine;
824 }, 836 },
825 837
826 /** 838 /**
827 * @return {(number|undefined)} 839 * @return {(number|undefined)}
828 */ 840 */
829 columnNumber: function() 841 columnNumber: function()
830 { 842 {
831 return this._columnNumber; 843 return this._range.startColumn;
832 }, 844 },
833 845
834 /** 846 /**
835 * @param {!WebInspector.UISourceCode.Message} another 847 * @param {!WebInspector.UISourceCode.Message} another
836 * @return {boolean} 848 * @return {boolean}
837 */ 849 */
838 isEqual: function(another) 850 isEqual: function(another)
839 { 851 {
840 return this._uiSourceCode === another._uiSourceCode && this.text() === a nother.text() && this.level() === another.level() && this.lineNumber() === anoth er.lineNumber() && this.columnNumber() === another.columnNumber(); 852 return this._uiSourceCode === another._uiSourceCode && this.text() === a nother.text() && this.level() === another.level() && this.range().equal(another. range());
841 }, 853 },
842 854
843 remove: function() 855 remove: function()
844 { 856 {
845 this._uiSourceCode.removeMessage(this); 857 this._uiSourceCode.removeMessage(this);
846 } 858 }
847 } 859 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698