OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
617 this._uiSourceCodes = this._uiSourceCodes.concat(projects[i].uiSourceCod es()); | 617 this._uiSourceCodes = this._uiSourceCodes.concat(projects[i].uiSourceCod es()); |
618 this._defaultScores = defaultScores; | 618 this._defaultScores = defaultScores; |
619 this._scorer = new WebInspector.FilePathScoreFunction(""); | 619 this._scorer = new WebInspector.FilePathScoreFunction(""); |
620 WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.UISour ceCodeAdded, this._uiSourceCodeAdded, this); | 620 WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.UISour ceCodeAdded, this._uiSourceCodeAdded, this); |
621 } | 621 } |
622 | 622 |
623 WebInspector.SelectUISourceCodeDialog.prototype = { | 623 WebInspector.SelectUISourceCodeDialog.prototype = { |
624 /** | 624 /** |
625 * @param {?WebInspector.UISourceCode} uiSourceCode | 625 * @param {?WebInspector.UISourceCode} uiSourceCode |
626 * @param {number=} lineNumber | 626 * @param {number=} lineNumber |
627 * @param {number=} columnNumber | |
627 */ | 628 */ |
628 uiSourceCodeSelected: function(uiSourceCode, lineNumber) | 629 uiSourceCodeSelected: function(uiSourceCode, lineNumber, columnNumber) |
629 { | 630 { |
630 // Overridden by subclasses | 631 // Overridden by subclasses |
631 }, | 632 }, |
632 | 633 |
633 /** | 634 /** |
634 * @param {!WebInspector.Project} project | 635 * @param {!WebInspector.Project} project |
635 * @return {boolean} | 636 * @return {boolean} |
636 */ | 637 */ |
637 filterProject: function(project) | 638 filterProject: function(project) |
638 { | 639 { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
682 * @param {number} itemIndex | 683 * @param {number} itemIndex |
683 * @param {string} query | 684 * @param {string} query |
684 * @param {!Element} titleElement | 685 * @param {!Element} titleElement |
685 * @param {!Element} subtitleElement | 686 * @param {!Element} subtitleElement |
686 * @return {!Array.<!Element>} | 687 * @return {!Array.<!Element>} |
687 */ | 688 */ |
688 renderItem: function(itemIndex, query, titleElement, subtitleElement) | 689 renderItem: function(itemIndex, query, titleElement, subtitleElement) |
689 { | 690 { |
690 query = this.rewriteQuery(query); | 691 query = this.rewriteQuery(query); |
691 var uiSourceCode = this._uiSourceCodes[itemIndex]; | 692 var uiSourceCode = this._uiSourceCodes[itemIndex]; |
692 titleElement.textContent = uiSourceCode.displayName() + (this._queryLine Number ? this._queryLineNumber : ""); | 693 titleElement.textContent = uiSourceCode.displayName() + (this._queryLine NumberAndColumnNumber || ""); |
693 subtitleElement.textContent = uiSourceCode.fullDisplayName().trimEnd(100 ); | 694 subtitleElement.textContent = uiSourceCode.fullDisplayName().trimEnd(100 ); |
694 | 695 |
695 var indexes = []; | 696 var indexes = []; |
696 var score = new WebInspector.FilePathScoreFunction(query).score(subtitle Element.textContent, indexes); | 697 var score = new WebInspector.FilePathScoreFunction(query).score(subtitle Element.textContent, indexes); |
697 var fileNameIndex = subtitleElement.textContent.lastIndexOf("/"); | 698 var fileNameIndex = subtitleElement.textContent.lastIndexOf("/"); |
698 var ranges = []; | 699 var ranges = []; |
699 for (var i = 0; i < indexes.length; ++i) | 700 for (var i = 0; i < indexes.length; ++i) |
700 ranges.push({offset: indexes[i], length: 1}); | 701 ranges.push({offset: indexes[i], length: 1}); |
701 if (indexes[0] > fileNameIndex) { | 702 if (indexes[0] > fileNameIndex) { |
702 for (var i = 0; i < ranges.length; ++i) | 703 for (var i = 0; i < ranges.length; ++i) |
703 ranges[i].offset -= fileNameIndex + 1; | 704 ranges[i].offset -= fileNameIndex + 1; |
704 return WebInspector.highlightRangesWithStyleClass(titleElement, rang es, "highlight"); | 705 return WebInspector.highlightRangesWithStyleClass(titleElement, rang es, "highlight"); |
705 } else { | 706 } else { |
706 return WebInspector.highlightRangesWithStyleClass(subtitleElement, r anges, "highlight"); | 707 return WebInspector.highlightRangesWithStyleClass(subtitleElement, r anges, "highlight"); |
707 } | 708 } |
708 }, | 709 }, |
709 | 710 |
710 /** | 711 /** |
711 * @param {number} itemIndex | 712 * @param {number} itemIndex |
712 * @param {string} promptValue | 713 * @param {string} promptValue |
713 */ | 714 */ |
714 selectItem: function(itemIndex, promptValue) | 715 selectItem: function(itemIndex, promptValue) |
715 { | 716 { |
716 if (/^:\d+$/.test(promptValue.trimRight())) { | 717 var parsedExpression = promptValue.trimRight().match(/^([^:]*)(:\d+)?(:\ d+)?$/); |
717 var lineNumber = parseInt(promptValue.trimRight().substring(1), 10) - 1; | 718 if (!parsedExpression) |
vsevik
2014/01/28 14:45:41
I don't think this ever happens!
lushnikov
2014/01/28 15:15:09
It does!
| |
718 if (!isNaN(lineNumber) && lineNumber >= 0) | |
719 this.uiSourceCodeSelected(null, lineNumber); | |
720 return; | 719 return; |
721 } | 720 |
722 var lineNumberMatch = promptValue.match(/[^:]+\:([\d]*)$/); | 721 var lineNumber; |
723 var lineNumber = lineNumberMatch ? Math.max(parseInt(lineNumberMatch[1], 10) - 1, 0) : undefined; | 722 var columnNumber; |
724 this.uiSourceCodeSelected(this._uiSourceCodes[itemIndex], lineNumber); | 723 if (parsedExpression[2]) |
724 lineNumber = parseInt(parsedExpression[2].substr(1), 10) - 1; | |
725 if (parsedExpression[3]) | |
726 columnNumber = parseInt(parsedExpression[3].substr(1), 10) - 1; | |
727 var uiSourceCode = parsedExpression[1] ? this._uiSourceCodes[itemIndex] : null; | |
728 this.uiSourceCodeSelected(uiSourceCode, lineNumber, columnNumber); | |
725 }, | 729 }, |
726 | 730 |
727 /** | 731 /** |
728 * @param {string} query | 732 * @param {string} query |
729 * @return {string} | 733 * @return {string} |
730 */ | 734 */ |
731 rewriteQuery: function(query) | 735 rewriteQuery: function(query) |
732 { | 736 { |
733 if (!query) | 737 if (!query) |
734 return query; | 738 return query; |
735 query = query.trim(); | 739 query = query.trim(); |
736 var lineNumberMatch = query.match(/([^:]+)(\:[\d]*)$/); | 740 var lineNumberMatch = query.match(/^([^:]+)((?::[^:]*){0,2})$/); |
737 this._queryLineNumber = lineNumberMatch ? lineNumberMatch[2] : ""; | 741 this._queryLineNumberAndColumnNumber = lineNumberMatch ? lineNumberMatch [2] : ""; |
738 return lineNumberMatch ? lineNumberMatch[1] : query; | 742 return lineNumberMatch ? lineNumberMatch[1] : query; |
739 }, | 743 }, |
740 | 744 |
741 /** | 745 /** |
742 * @param {!WebInspector.Event} event | 746 * @param {!WebInspector.Event} event |
743 */ | 747 */ |
744 _uiSourceCodeAdded: function(event) | 748 _uiSourceCodeAdded: function(event) |
745 { | 749 { |
746 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data ); | 750 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data ); |
747 if (!this.filterProject(uiSourceCode.project())) | 751 if (!this.filterProject(uiSourceCode.project())) |
(...skipping 20 matching lines...) Expand all Loading... | |
768 { | 772 { |
769 WebInspector.SelectUISourceCodeDialog.call(this, defaultScores); | 773 WebInspector.SelectUISourceCodeDialog.call(this, defaultScores); |
770 this._panel = panel; | 774 this._panel = panel; |
771 } | 775 } |
772 | 776 |
773 WebInspector.OpenResourceDialog.prototype = { | 777 WebInspector.OpenResourceDialog.prototype = { |
774 | 778 |
775 /** | 779 /** |
776 * @param {?WebInspector.UISourceCode} uiSourceCode | 780 * @param {?WebInspector.UISourceCode} uiSourceCode |
777 * @param {number=} lineNumber | 781 * @param {number=} lineNumber |
782 * @param {number=} columnNumber | |
778 */ | 783 */ |
779 uiSourceCodeSelected: function(uiSourceCode, lineNumber) | 784 uiSourceCodeSelected: function(uiSourceCode, lineNumber, columnNumber) |
780 { | 785 { |
781 if (!uiSourceCode) | 786 if (!uiSourceCode) |
782 uiSourceCode = this._panel.currentUISourceCode(); | 787 uiSourceCode = this._panel.currentUISourceCode(); |
783 if (!uiSourceCode) | 788 if (!uiSourceCode) |
784 return; | 789 return; |
785 this._panel.showUISourceCode(uiSourceCode, lineNumber); | 790 this._panel.showUISourceCode(uiSourceCode, lineNumber, columnNumber); |
786 }, | 791 }, |
787 | 792 |
788 /** | 793 /** |
789 * @param {string} query | 794 * @param {string} query |
790 * @return {boolean} | 795 * @return {boolean} |
791 */ | 796 */ |
792 shouldShowMatchingItems: function(query) | 797 shouldShowMatchingItems: function(query) |
793 { | 798 { |
794 return !query.startsWith(":"); | 799 return !query.startsWith(":"); |
795 }, | 800 }, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
834 { | 839 { |
835 this._type = type; | 840 this._type = type; |
836 WebInspector.SelectUISourceCodeDialog.call(this); | 841 WebInspector.SelectUISourceCodeDialog.call(this); |
837 this._callback = callback; | 842 this._callback = callback; |
838 } | 843 } |
839 | 844 |
840 WebInspector.SelectUISourceCodeForProjectTypeDialog.prototype = { | 845 WebInspector.SelectUISourceCodeForProjectTypeDialog.prototype = { |
841 /** | 846 /** |
842 * @param {!WebInspector.UISourceCode} uiSourceCode | 847 * @param {!WebInspector.UISourceCode} uiSourceCode |
843 * @param {number=} lineNumber | 848 * @param {number=} lineNumber |
849 * @param {number=} columnNumber | |
844 */ | 850 */ |
845 uiSourceCodeSelected: function(uiSourceCode, lineNumber) | 851 uiSourceCodeSelected: function(uiSourceCode, lineNumber, columnNumber) |
846 { | 852 { |
847 this._callback(uiSourceCode); | 853 this._callback(uiSourceCode); |
848 }, | 854 }, |
849 | 855 |
850 /** | 856 /** |
851 * @param {!WebInspector.Project} project | 857 * @param {!WebInspector.Project} project |
852 * @return {boolean} | 858 * @return {boolean} |
853 */ | 859 */ |
854 filterProject: function(project) | 860 filterProject: function(project) |
855 { | 861 { |
(...skipping 11 matching lines...) Expand all Loading... | |
867 WebInspector.SelectUISourceCodeForProjectTypeDialog.show = function(name, type, callback, relativeToElement) | 873 WebInspector.SelectUISourceCodeForProjectTypeDialog.show = function(name, type, callback, relativeToElement) |
868 { | 874 { |
869 if (WebInspector.Dialog.currentInstance()) | 875 if (WebInspector.Dialog.currentInstance()) |
870 return; | 876 return; |
871 | 877 |
872 var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDial og(new WebInspector.SelectUISourceCodeForProjectTypeDialog(type, callback)); | 878 var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDial og(new WebInspector.SelectUISourceCodeForProjectTypeDialog(type, callback)); |
873 filteredItemSelectionDialog.setQuery(name); | 879 filteredItemSelectionDialog.setQuery(name); |
874 filteredItemSelectionDialog.renderAsTwoRows(); | 880 filteredItemSelectionDialog.renderAsTwoRows(); |
875 WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog); | 881 WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog); |
876 } | 882 } |
OLD | NEW |