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

Side by Side Diff: Source/devtools/front_end/FilteredItemSelectionDialog.js

Issue 131033004: DevTools: introduce goto-column functionality (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/CodeMirrorTextEditor.js ('k') | 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) 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
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
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 gotoLineNumber = promptValue.match(/^(:\d+)(:\d+)?$/);
vsevik 2014/01/27 17:19:11 Let's keep trimRight
lushnikov 2014/01/28 13:27:07 Done; even more: made trim() call here as it makes
717 var lineNumber = parseInt(promptValue.trimRight().substring(1), 10) - 1; 718 if (gotoLineNumber) {
718 if (!isNaN(lineNumber) && lineNumber >= 0) 719 var lineNumber = parseInt(gotoLineNumber[1].substr(1), 10) - 1;
719 this.uiSourceCodeSelected(null, lineNumber); 720 var columnNumber;
721 if (gotoLineNumber[2])
722 columnNumber = parseInt(gotoLineNumber[2].substr(1), 10) - 1;
723 this.uiSourceCodeSelected(null, lineNumber, columnNumber);
720 return; 724 return;
721 } 725 }
722 var lineNumberMatch = promptValue.match(/[^:]+\:([\d]*)$/); 726 var gotoSourceMatch = promptValue.match(/^[^:]+(:\d+)?(:\d+)?$/);
vsevik 2014/01/27 17:19:11 A lot of code duplication here.
lushnikov 2014/01/28 13:27:07 Done.
723 var lineNumber = lineNumberMatch ? Math.max(parseInt(lineNumberMatch[1], 10) - 1, 0) : undefined; 727 var lineNumber;
724 this.uiSourceCodeSelected(this._uiSourceCodes[itemIndex], lineNumber); 728 var columnNumber;
729 if (gotoSourceMatch[1])
730 lineNumber = parseInt(gotoSourceMatch[1].substr(1), 10) - 1;
731 if (gotoSourceMatch[2])
732 columnNumber = parseInt(gotoSourceMatch[2].substr(1), 10) - 1;
733 this.uiSourceCodeSelected(this._uiSourceCodes[itemIndex], lineNumber, co lumnNumber);
725 }, 734 },
726 735
727 /** 736 /**
728 * @param {string} query 737 * @param {string} query
729 * @return {string} 738 * @return {string}
730 */ 739 */
731 rewriteQuery: function(query) 740 rewriteQuery: function(query)
732 { 741 {
733 if (!query) 742 if (!query)
734 return query; 743 return query;
735 query = query.trim(); 744 query = query.trim();
736 var lineNumberMatch = query.match(/([^:]+)(\:[\d]*)$/); 745 var lineNumberMatch = query.match(/^([^:]+)((?::[^:]*){0,2})$/);
737 this._queryLineNumber = lineNumberMatch ? lineNumberMatch[2] : ""; 746 this._queryLineNumberAndColumnNumber = lineNumberMatch ? lineNumberMatch [2] : "";
738 return lineNumberMatch ? lineNumberMatch[1] : query; 747 return lineNumberMatch ? lineNumberMatch[1] : query;
739 }, 748 },
740 749
741 /** 750 /**
742 * @param {!WebInspector.Event} event 751 * @param {!WebInspector.Event} event
743 */ 752 */
744 _uiSourceCodeAdded: function(event) 753 _uiSourceCodeAdded: function(event)
745 { 754 {
746 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data ); 755 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data );
747 if (!this.filterProject(uiSourceCode.project())) 756 if (!this.filterProject(uiSourceCode.project()))
(...skipping 20 matching lines...) Expand all
768 { 777 {
769 WebInspector.SelectUISourceCodeDialog.call(this, defaultScores); 778 WebInspector.SelectUISourceCodeDialog.call(this, defaultScores);
770 this._panel = panel; 779 this._panel = panel;
771 } 780 }
772 781
773 WebInspector.OpenResourceDialog.prototype = { 782 WebInspector.OpenResourceDialog.prototype = {
774 783
775 /** 784 /**
776 * @param {?WebInspector.UISourceCode} uiSourceCode 785 * @param {?WebInspector.UISourceCode} uiSourceCode
777 * @param {number=} lineNumber 786 * @param {number=} lineNumber
787 * @param {number=} columnNumber
778 */ 788 */
779 uiSourceCodeSelected: function(uiSourceCode, lineNumber) 789 uiSourceCodeSelected: function(uiSourceCode, lineNumber, columnNumber)
780 { 790 {
781 if (!uiSourceCode) 791 if (!uiSourceCode)
782 uiSourceCode = this._panel.currentUISourceCode(); 792 uiSourceCode = this._panel.currentUISourceCode();
783 if (!uiSourceCode) 793 if (!uiSourceCode)
784 return; 794 return;
785 this._panel.showUISourceCode(uiSourceCode, lineNumber); 795 this._panel.showUISourceCode(uiSourceCode, lineNumber, columnNumber);
786 }, 796 },
787 797
788 /** 798 /**
789 * @param {string} query 799 * @param {string} query
790 * @return {boolean} 800 * @return {boolean}
791 */ 801 */
792 shouldShowMatchingItems: function(query) 802 shouldShowMatchingItems: function(query)
793 { 803 {
794 return !query.startsWith(":"); 804 return !query.startsWith(":");
795 }, 805 },
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 { 844 {
835 this._type = type; 845 this._type = type;
836 WebInspector.SelectUISourceCodeDialog.call(this); 846 WebInspector.SelectUISourceCodeDialog.call(this);
837 this._callback = callback; 847 this._callback = callback;
838 } 848 }
839 849
840 WebInspector.SelectUISourceCodeForProjectTypeDialog.prototype = { 850 WebInspector.SelectUISourceCodeForProjectTypeDialog.prototype = {
841 /** 851 /**
842 * @param {!WebInspector.UISourceCode} uiSourceCode 852 * @param {!WebInspector.UISourceCode} uiSourceCode
843 * @param {number=} lineNumber 853 * @param {number=} lineNumber
854 * @param {number=} columnNumber
844 */ 855 */
845 uiSourceCodeSelected: function(uiSourceCode, lineNumber) 856 uiSourceCodeSelected: function(uiSourceCode, lineNumber, columnNumber)
846 { 857 {
847 this._callback(uiSourceCode); 858 this._callback(uiSourceCode);
848 }, 859 },
849 860
850 /** 861 /**
851 * @param {!WebInspector.Project} project 862 * @param {!WebInspector.Project} project
852 * @return {boolean} 863 * @return {boolean}
853 */ 864 */
854 filterProject: function(project) 865 filterProject: function(project)
855 { 866 {
(...skipping 11 matching lines...) Expand all
867 WebInspector.SelectUISourceCodeForProjectTypeDialog.show = function(name, type, callback, relativeToElement) 878 WebInspector.SelectUISourceCodeForProjectTypeDialog.show = function(name, type, callback, relativeToElement)
868 { 879 {
869 if (WebInspector.Dialog.currentInstance()) 880 if (WebInspector.Dialog.currentInstance())
870 return; 881 return;
871 882
872 var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDial og(new WebInspector.SelectUISourceCodeForProjectTypeDialog(type, callback)); 883 var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDial og(new WebInspector.SelectUISourceCodeForProjectTypeDialog(type, callback));
873 filteredItemSelectionDialog.setQuery(name); 884 filteredItemSelectionDialog.setQuery(name);
874 filteredItemSelectionDialog.renderAsTwoRows(); 885 filteredItemSelectionDialog.renderAsTwoRows();
875 WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog); 886 WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog);
876 } 887 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/CodeMirrorTextEditor.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698