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

Side by Side Diff: Source/devtools/front_end/sources/SourcesView.js

Issue 378273004: DevTools: Add a shortcut for switching between files with the same name and different extensions. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Comments addressed Created 6 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @implements {WebInspector.TabbedEditorContainerDelegate} 7 * @implements {WebInspector.TabbedEditorContainerDelegate}
8 * @implements {WebInspector.Searchable} 8 * @implements {WebInspector.Searchable}
9 * @implements {WebInspector.Replaceable} 9 * @implements {WebInspector.Replaceable}
10 * @extends {WebInspector.VBox} 10 * @extends {WebInspector.VBox}
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 }, 123 },
124 124
125 _handleKeyDown: function(event) 125 _handleKeyDown: function(event)
126 { 126 {
127 var shortcutKey = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); 127 var shortcutKey = WebInspector.KeyboardShortcut.makeKeyFromEvent(event);
128 var handler = this._shortcuts[shortcutKey]; 128 var handler = this._shortcuts[shortcutKey];
129 if (handler && handler()) 129 if (handler && handler())
130 event.consume(true); 130 event.consume(true);
131 }, 131 },
132 132
133 wasShown: function()
134 {
135 WebInspector.VBox.prototype.wasShown.call(this);
136 WebInspector.context.setFlavor(WebInspector.SourcesView, this);
137 },
138
139 willHide: function()
140 {
141 WebInspector.context.setFlavor(WebInspector.SourcesView, null);
142 WebInspector.VBox.prototype.willHide.call(this);
143 },
144
133 /** 145 /**
134 * @return {!Element} 146 * @return {!Element}
135 */ 147 */
136 statusBarContainerElement: function() 148 statusBarContainerElement: function()
137 { 149 {
138 return this._statusBarContainerElement; 150 return this._statusBarContainerElement;
139 }, 151 },
140 152
141 /** 153 /**
142 * @return {!Element} 154 * @return {!Element}
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 { 705 {
694 } 706 }
695 707
696 WebInspector.SourcesView.EditorAction.prototype = { 708 WebInspector.SourcesView.EditorAction.prototype = {
697 /** 709 /**
698 * @param {!WebInspector.SourcesView} sourcesView 710 * @param {!WebInspector.SourcesView} sourcesView
699 * @return {!Element} 711 * @return {!Element}
700 */ 712 */
701 button: function(sourcesView) { } 713 button: function(sourcesView) { }
702 } 714 }
715
716 /**
717 * @constructor
718 * @implements {WebInspector.ActionDelegate}
719 */
720 WebInspector.SourcesView.SwitchFileActionDelegate = function()
721 {
722 }
723
724 /**
725 * @param {!WebInspector.UISourceCode} currentUISourceCode
726 * @return {?WebInspector.UISourceCode}
727 */
728 WebInspector.SourcesView.SwitchFileActionDelegate._nextFile = function(currentUI SourceCode)
729 {
730 /**
731 * @param {string} name
732 * @return {string}
733 */
734 function fileNamePrefix(name)
735 {
736 var lastDotIndex = name.lastIndexOf(".");
737 var namePrefix = name.substr(0, lastDotIndex !== -1 ? lastDotIndex : nam e.length);
738 return namePrefix.toLowerCase();
739 }
740
741 var uiSourceCodes = currentUISourceCode.project().uiSourceCodes();
742 var candidates = [];
743 var path = currentUISourceCode.parentPath();
744 var name = currentUISourceCode.name();
745 var namePrefix = fileNamePrefix(name);
746 for (var i = 0; i < uiSourceCodes.length; ++i) {
747 var uiSourceCode = uiSourceCodes[i];
748 if (path !== uiSourceCode.parentPath())
749 continue;
750 if (fileNamePrefix(uiSourceCode.name()) === namePrefix)
751 candidates.push(uiSourceCode.name());
752 }
753 candidates.sort(String.naturalOrderComparator);
754 var index = mod(candidates.indexOf(name) + 1, candidates.length);
755 var fullPath = (path ? path + "/" : "") + candidates[index];
756 var nextUISourceCode = currentUISourceCode.project().uiSourceCode(fullPath);
757 return nextUISourceCode !== currentUISourceCode ? nextUISourceCode : null;
758 },
759
760
761 WebInspector.SourcesView.SwitchFileActionDelegate.prototype = {
762 /**
763 * @return {boolean}
764 */
765 handleAction: function()
766 {
767 var sourcesView = WebInspector.context.flavor(WebInspector.SourcesView);
768 if (!sourcesView)
769 return false;
770 var currentUISourceCode = sourcesView.currentUISourceCode();
771 if (!currentUISourceCode)
772 return true;
773 var nextUISourceCode = WebInspector.SourcesView.SwitchFileActionDelegate ._nextFile(currentUISourceCode);
774 if (!nextUISourceCode)
775 return true;
776 sourcesView.showSourceLocation(nextUISourceCode);
777 return true;
778 }
779 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/components/ShortcutsScreen.js ('k') | Source/devtools/front_end/sources/module.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698