| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 renderAsTwoRows: function() | 112 renderAsTwoRows: function() |
| 113 { | 113 { |
| 114 this._renderAsTwoRows = true; | 114 this._renderAsTwoRows = true; |
| 115 }, | 115 }, |
| 116 | 116 |
| 117 onEnter: function() | 117 onEnter: function() |
| 118 { | 118 { |
| 119 if (!this._delegate.itemCount()) | 119 if (!this._delegate.itemCount()) |
| 120 return; | 120 return; |
| 121 this._delegate.selectItem(this._filteredItems[this._selectedIndexInFilte
red], this._promptElement.value.trim()); | 121 var selectedIndex = this._selectedIndexInFiltered < this._filteredItems.
length ? this._filteredItems[this._selectedIndexInFiltered] : null; |
| 122 this._delegate.selectItem(selectedIndex, this._promptElement.value.trim(
)); |
| 122 }, | 123 }, |
| 123 | 124 |
| 124 _itemsLoaded: function() | 125 _itemsLoaded: function() |
| 125 { | 126 { |
| 126 | 127 |
| 127 if (this._loadTimeout) | 128 if (this._loadTimeout) |
| 128 return; | 129 return; |
| 129 this._loadTimeout = setTimeout(this._updateAfterItemsLoaded.bind(this),
0); | 130 this._loadTimeout = setTimeout(this._updateAfterItemsLoaded.bind(this),
0); |
| 130 }, | 131 }, |
| 131 | 132 |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 if (!ranges) | 450 if (!ranges) |
| 450 ranges = rangesForMatch(text.toUpperCase(), query.toUpperCase()); | 451 ranges = rangesForMatch(text.toUpperCase(), query.toUpperCase()); |
| 451 if (ranges) { | 452 if (ranges) { |
| 452 WebInspector.highlightRangesWithStyleClass(element, ranges, "highlig
ht"); | 453 WebInspector.highlightRangesWithStyleClass(element, ranges, "highlig
ht"); |
| 453 return true; | 454 return true; |
| 454 } | 455 } |
| 455 return false; | 456 return false; |
| 456 }, | 457 }, |
| 457 | 458 |
| 458 /** | 459 /** |
| 459 * @param {number} itemIndex | 460 * @param {?number} itemIndex |
| 460 * @param {string} promptValue | 461 * @param {string} promptValue |
| 461 */ | 462 */ |
| 462 selectItem: function(itemIndex, promptValue) | 463 selectItem: function(itemIndex, promptValue) |
| 463 { | 464 { |
| 464 }, | 465 }, |
| 465 | 466 |
| 466 refresh: function() | 467 refresh: function() |
| 467 { | 468 { |
| 468 this._refreshCallback(); | 469 this._refreshCallback(); |
| 469 }, | 470 }, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 */ | 574 */ |
| 574 renderItem: function(itemIndex, query, titleElement, subtitleElement) | 575 renderItem: function(itemIndex, query, titleElement, subtitleElement) |
| 575 { | 576 { |
| 576 var item = this._functionItems[itemIndex]; | 577 var item = this._functionItems[itemIndex]; |
| 577 titleElement.textContent = item.name + (item.arguments ? item.arguments
: ""); | 578 titleElement.textContent = item.name + (item.arguments ? item.arguments
: ""); |
| 578 this.highlightRanges(titleElement, query); | 579 this.highlightRanges(titleElement, query); |
| 579 subtitleElement.textContent = ":" + (item.line + 1); | 580 subtitleElement.textContent = ":" + (item.line + 1); |
| 580 }, | 581 }, |
| 581 | 582 |
| 582 /** | 583 /** |
| 583 * @param {number} itemIndex | 584 * @param {?number} itemIndex |
| 584 * @param {string} promptValue | 585 * @param {string} promptValue |
| 585 */ | 586 */ |
| 586 selectItem: function(itemIndex, promptValue) | 587 selectItem: function(itemIndex, promptValue) |
| 587 { | 588 { |
| 589 if (itemIndex === null) |
| 590 return; |
| 588 var lineNumber = this._functionItems[itemIndex].line; | 591 var lineNumber = this._functionItems[itemIndex].line; |
| 589 if (!isNaN(lineNumber) && lineNumber >= 0) | 592 if (!isNaN(lineNumber) && lineNumber >= 0) |
| 590 this._selectItemCallback(lineNumber, this._functionItems[itemIndex].
column); | 593 this._selectItemCallback(lineNumber, this._functionItems[itemIndex].
column); |
| 591 }, | 594 }, |
| 592 | 595 |
| 593 dispose: function() | 596 dispose: function() |
| 594 { | 597 { |
| 595 if (this._outlineWorker) { | 598 if (this._outlineWorker) { |
| 596 this._outlineWorker.terminate(); | 599 this._outlineWorker.terminate(); |
| 597 delete this._outlineWorker; | 600 delete this._outlineWorker; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 617 this._uiSourceCodes = this._uiSourceCodes.concat(projects[i].uiSourceCod
es()); | 620 this._uiSourceCodes = this._uiSourceCodes.concat(projects[i].uiSourceCod
es()); |
| 618 this._defaultScores = defaultScores; | 621 this._defaultScores = defaultScores; |
| 619 this._scorer = new WebInspector.FilePathScoreFunction(""); | 622 this._scorer = new WebInspector.FilePathScoreFunction(""); |
| 620 WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.UISour
ceCodeAdded, this._uiSourceCodeAdded, this); | 623 WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.UISour
ceCodeAdded, this._uiSourceCodeAdded, this); |
| 621 } | 624 } |
| 622 | 625 |
| 623 WebInspector.SelectUISourceCodeDialog.prototype = { | 626 WebInspector.SelectUISourceCodeDialog.prototype = { |
| 624 /** | 627 /** |
| 625 * @param {?WebInspector.UISourceCode} uiSourceCode | 628 * @param {?WebInspector.UISourceCode} uiSourceCode |
| 626 * @param {number=} lineNumber | 629 * @param {number=} lineNumber |
| 630 * @param {number=} columnNumber |
| 627 */ | 631 */ |
| 628 uiSourceCodeSelected: function(uiSourceCode, lineNumber) | 632 uiSourceCodeSelected: function(uiSourceCode, lineNumber, columnNumber) |
| 629 { | 633 { |
| 630 // Overridden by subclasses | 634 // Overridden by subclasses |
| 631 }, | 635 }, |
| 632 | 636 |
| 633 /** | 637 /** |
| 634 * @param {!WebInspector.Project} project | 638 * @param {!WebInspector.Project} project |
| 635 * @return {boolean} | 639 * @return {boolean} |
| 636 */ | 640 */ |
| 637 filterProject: function(project) | 641 filterProject: function(project) |
| 638 { | 642 { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 * @param {number} itemIndex | 686 * @param {number} itemIndex |
| 683 * @param {string} query | 687 * @param {string} query |
| 684 * @param {!Element} titleElement | 688 * @param {!Element} titleElement |
| 685 * @param {!Element} subtitleElement | 689 * @param {!Element} subtitleElement |
| 686 * @return {!Array.<!Element>} | 690 * @return {!Array.<!Element>} |
| 687 */ | 691 */ |
| 688 renderItem: function(itemIndex, query, titleElement, subtitleElement) | 692 renderItem: function(itemIndex, query, titleElement, subtitleElement) |
| 689 { | 693 { |
| 690 query = this.rewriteQuery(query); | 694 query = this.rewriteQuery(query); |
| 691 var uiSourceCode = this._uiSourceCodes[itemIndex]; | 695 var uiSourceCode = this._uiSourceCodes[itemIndex]; |
| 692 titleElement.textContent = uiSourceCode.displayName() + (this._queryLine
Number ? this._queryLineNumber : ""); | 696 titleElement.textContent = uiSourceCode.displayName() + (this._queryLine
NumberAndColumnNumber || ""); |
| 693 subtitleElement.textContent = uiSourceCode.fullDisplayName().trimEnd(100
); | 697 subtitleElement.textContent = uiSourceCode.fullDisplayName().trimEnd(100
); |
| 694 | 698 |
| 695 var indexes = []; | 699 var indexes = []; |
| 696 var score = new WebInspector.FilePathScoreFunction(query).score(subtitle
Element.textContent, indexes); | 700 var score = new WebInspector.FilePathScoreFunction(query).score(subtitle
Element.textContent, indexes); |
| 697 var fileNameIndex = subtitleElement.textContent.lastIndexOf("/"); | 701 var fileNameIndex = subtitleElement.textContent.lastIndexOf("/"); |
| 698 var ranges = []; | 702 var ranges = []; |
| 699 for (var i = 0; i < indexes.length; ++i) | 703 for (var i = 0; i < indexes.length; ++i) |
| 700 ranges.push({offset: indexes[i], length: 1}); | 704 ranges.push({offset: indexes[i], length: 1}); |
| 701 if (indexes[0] > fileNameIndex) { | 705 if (indexes[0] > fileNameIndex) { |
| 702 for (var i = 0; i < ranges.length; ++i) | 706 for (var i = 0; i < ranges.length; ++i) |
| 703 ranges[i].offset -= fileNameIndex + 1; | 707 ranges[i].offset -= fileNameIndex + 1; |
| 704 return WebInspector.highlightRangesWithStyleClass(titleElement, rang
es, "highlight"); | 708 return WebInspector.highlightRangesWithStyleClass(titleElement, rang
es, "highlight"); |
| 705 } else { | 709 } else { |
| 706 return WebInspector.highlightRangesWithStyleClass(subtitleElement, r
anges, "highlight"); | 710 return WebInspector.highlightRangesWithStyleClass(subtitleElement, r
anges, "highlight"); |
| 707 } | 711 } |
| 708 }, | 712 }, |
| 709 | 713 |
| 710 /** | 714 /** |
| 711 * @param {number} itemIndex | 715 * @param {?number} itemIndex |
| 712 * @param {string} promptValue | 716 * @param {string} promptValue |
| 713 */ | 717 */ |
| 714 selectItem: function(itemIndex, promptValue) | 718 selectItem: function(itemIndex, promptValue) |
| 715 { | 719 { |
| 716 if (/^:\d+$/.test(promptValue.trimRight())) { | 720 var parsedExpression = promptValue.trim().match(/^([^:]*)(:\d+)?(:\d+)?$
/); |
| 717 var lineNumber = parseInt(promptValue.trimRight().substring(1), 10)
- 1; | 721 if (!parsedExpression) |
| 718 if (!isNaN(lineNumber) && lineNumber >= 0) | |
| 719 this.uiSourceCodeSelected(null, lineNumber); | |
| 720 return; | 722 return; |
| 721 } | 723 |
| 722 var lineNumberMatch = promptValue.match(/[^:]+\:([\d]*)$/); | 724 var lineNumber; |
| 723 var lineNumber = lineNumberMatch ? Math.max(parseInt(lineNumberMatch[1],
10) - 1, 0) : undefined; | 725 var columnNumber; |
| 724 this.uiSourceCodeSelected(this._uiSourceCodes[itemIndex], lineNumber); | 726 if (parsedExpression[2]) |
| 727 lineNumber = parseInt(parsedExpression[2].substr(1), 10) - 1; |
| 728 if (parsedExpression[3]) |
| 729 columnNumber = parseInt(parsedExpression[3].substr(1), 10) - 1; |
| 730 var uiSourceCode = itemIndex !== null ? this._uiSourceCodes[itemIndex] :
null; |
| 731 this.uiSourceCodeSelected(uiSourceCode, lineNumber, columnNumber); |
| 725 }, | 732 }, |
| 726 | 733 |
| 727 /** | 734 /** |
| 728 * @param {string} query | 735 * @param {string} query |
| 729 * @return {string} | 736 * @return {string} |
| 730 */ | 737 */ |
| 731 rewriteQuery: function(query) | 738 rewriteQuery: function(query) |
| 732 { | 739 { |
| 733 if (!query) | 740 if (!query) |
| 734 return query; | 741 return query; |
| 735 query = query.trim(); | 742 query = query.trim(); |
| 736 var lineNumberMatch = query.match(/([^:]+)(\:[\d]*)$/); | 743 var lineNumberMatch = query.match(/^([^:]+)((?::[^:]*){0,2})$/); |
| 737 this._queryLineNumber = lineNumberMatch ? lineNumberMatch[2] : ""; | 744 this._queryLineNumberAndColumnNumber = lineNumberMatch ? lineNumberMatch
[2] : ""; |
| 738 return lineNumberMatch ? lineNumberMatch[1] : query; | 745 return lineNumberMatch ? lineNumberMatch[1] : query; |
| 739 }, | 746 }, |
| 740 | 747 |
| 741 /** | 748 /** |
| 742 * @param {!WebInspector.Event} event | 749 * @param {!WebInspector.Event} event |
| 743 */ | 750 */ |
| 744 _uiSourceCodeAdded: function(event) | 751 _uiSourceCodeAdded: function(event) |
| 745 { | 752 { |
| 746 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); | 753 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); |
| 747 if (!this.filterProject(uiSourceCode.project())) | 754 if (!this.filterProject(uiSourceCode.project())) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 768 { | 775 { |
| 769 WebInspector.SelectUISourceCodeDialog.call(this, defaultScores); | 776 WebInspector.SelectUISourceCodeDialog.call(this, defaultScores); |
| 770 this._panel = panel; | 777 this._panel = panel; |
| 771 } | 778 } |
| 772 | 779 |
| 773 WebInspector.OpenResourceDialog.prototype = { | 780 WebInspector.OpenResourceDialog.prototype = { |
| 774 | 781 |
| 775 /** | 782 /** |
| 776 * @param {?WebInspector.UISourceCode} uiSourceCode | 783 * @param {?WebInspector.UISourceCode} uiSourceCode |
| 777 * @param {number=} lineNumber | 784 * @param {number=} lineNumber |
| 785 * @param {number=} columnNumber |
| 778 */ | 786 */ |
| 779 uiSourceCodeSelected: function(uiSourceCode, lineNumber) | 787 uiSourceCodeSelected: function(uiSourceCode, lineNumber, columnNumber) |
| 780 { | 788 { |
| 781 if (!uiSourceCode) | 789 if (!uiSourceCode) |
| 782 uiSourceCode = this._panel.currentUISourceCode(); | 790 uiSourceCode = this._panel.currentUISourceCode(); |
| 783 if (!uiSourceCode) | 791 if (!uiSourceCode) |
| 784 return; | 792 return; |
| 785 this._panel.showUISourceCode(uiSourceCode, lineNumber); | 793 this._panel.showUISourceCode(uiSourceCode, lineNumber, columnNumber); |
| 786 }, | 794 }, |
| 787 | 795 |
| 788 /** | 796 /** |
| 789 * @param {string} query | 797 * @param {string} query |
| 790 * @return {boolean} | 798 * @return {boolean} |
| 791 */ | 799 */ |
| 792 shouldShowMatchingItems: function(query) | 800 shouldShowMatchingItems: function(query) |
| 793 { | 801 { |
| 794 return !query.startsWith(":"); | 802 return !query.startsWith(":"); |
| 795 }, | 803 }, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 { | 842 { |
| 835 this._type = type; | 843 this._type = type; |
| 836 WebInspector.SelectUISourceCodeDialog.call(this); | 844 WebInspector.SelectUISourceCodeDialog.call(this); |
| 837 this._callback = callback; | 845 this._callback = callback; |
| 838 } | 846 } |
| 839 | 847 |
| 840 WebInspector.SelectUISourceCodeForProjectTypeDialog.prototype = { | 848 WebInspector.SelectUISourceCodeForProjectTypeDialog.prototype = { |
| 841 /** | 849 /** |
| 842 * @param {!WebInspector.UISourceCode} uiSourceCode | 850 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 843 * @param {number=} lineNumber | 851 * @param {number=} lineNumber |
| 852 * @param {number=} columnNumber |
| 844 */ | 853 */ |
| 845 uiSourceCodeSelected: function(uiSourceCode, lineNumber) | 854 uiSourceCodeSelected: function(uiSourceCode, lineNumber, columnNumber) |
| 846 { | 855 { |
| 847 this._callback(uiSourceCode); | 856 this._callback(uiSourceCode); |
| 848 }, | 857 }, |
| 849 | 858 |
| 850 /** | 859 /** |
| 851 * @param {!WebInspector.Project} project | 860 * @param {!WebInspector.Project} project |
| 852 * @return {boolean} | 861 * @return {boolean} |
| 853 */ | 862 */ |
| 854 filterProject: function(project) | 863 filterProject: function(project) |
| 855 { | 864 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 867 WebInspector.SelectUISourceCodeForProjectTypeDialog.show = function(name, type,
callback, relativeToElement) | 876 WebInspector.SelectUISourceCodeForProjectTypeDialog.show = function(name, type,
callback, relativeToElement) |
| 868 { | 877 { |
| 869 if (WebInspector.Dialog.currentInstance()) | 878 if (WebInspector.Dialog.currentInstance()) |
| 870 return; | 879 return; |
| 871 | 880 |
| 872 var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDial
og(new WebInspector.SelectUISourceCodeForProjectTypeDialog(type, callback)); | 881 var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDial
og(new WebInspector.SelectUISourceCodeForProjectTypeDialog(type, callback)); |
| 873 filteredItemSelectionDialog.setQuery(name); | 882 filteredItemSelectionDialog.setQuery(name); |
| 874 filteredItemSelectionDialog.renderAsTwoRows(); | 883 filteredItemSelectionDialog.renderAsTwoRows(); |
| 875 WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog); | 884 WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog); |
| 876 } | 885 } |
| OLD | NEW |