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

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: Added a shortcut to shortcuts screen 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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 }, 688 },
677 689
678 /** 690 /**
679 * @param {boolean} active 691 * @param {boolean} active
680 */ 692 */
681 toggleBreakpointsActiveState: function(active) 693 toggleBreakpointsActiveState: function(active)
682 { 694 {
683 this._editorContainer.view.element.classList.toggle("breakpoints-deactiv ated", !active); 695 this._editorContainer.view.element.classList.toggle("breakpoints-deactiv ated", !active);
684 }, 696 },
685 697
698 _switchFile: function()
699 {
700 if (!this._currentUISourceCode)
701 return;
702 var uiSourceCodes = this._currentUISourceCode.project().uiSourceCodes();
703 var candidates = [];
704 var path = this._currentUISourceCode.parentPath();
705 var name = this._currentUISourceCode.name();
706 var namePrefix = name.substr(0, name.indexOf(".")) + ".";
apavlov 2014/07/09 14:06:05 var namePrefix = name.substr(0, name.indexOf(".")
lushnikov 2014/07/11 11:47:38 Let's get lastIndexOf
apavlov 2014/07/11 11:49:54 +1 So, var namePrefix = name.substr(0, name.lastIn
707 namePrefix = namePrefix.toLowerCase();
708 for (var i = 0; i < uiSourceCodes.length; ++i) {
709 var uiSourceCode = uiSourceCodes[i]
apavlov 2014/07/09 14:06:05 ';' missing
710 if (path === uiSourceCode.parentPath() && uiSourceCode.name().toLowe rCase().startsWith(namePrefix))
711 candidates.push(uiSourceCode.name());
712 }
713 candidates.sort(String.naturalOrderComparator);
714 var index = mod(candidates.indexOf(name) + 1, candidates.length);
apavlov 2014/07/09 14:06:05 Do we want to be able to set up certain switching
715 var fullPath = path + "/" + candidates[index];
716 var nextUISourceCode = this._currentUISourceCode.project().uiSourceCode( fullPath);
717 if (!nextUISourceCode)
718 return;
719 this.showSourceLocation(nextUISourceCode);
720 },
721
686 __proto__: WebInspector.VBox.prototype 722 __proto__: WebInspector.VBox.prototype
687 } 723 }
688 724
689 /** 725 /**
690 * @interface 726 * @interface
691 */ 727 */
692 WebInspector.SourcesView.EditorAction = function() 728 WebInspector.SourcesView.EditorAction = function()
693 { 729 {
694 } 730 }
695 731
696 WebInspector.SourcesView.EditorAction.prototype = { 732 WebInspector.SourcesView.EditorAction.prototype = {
697 /** 733 /**
698 * @param {!WebInspector.SourcesView} sourcesView 734 * @param {!WebInspector.SourcesView} sourcesView
699 * @return {!Element} 735 * @return {!Element}
700 */ 736 */
701 button: function(sourcesView) { } 737 button: function(sourcesView) { }
702 } 738 }
739
740 /**
741 * @constructor
742 * @implements {WebInspector.ActionDelegate}
743 */
744 WebInspector.SourcesView.SwitchFileActionDelegate = function()
745 {
746 }
747
748 WebInspector.SourcesView.SwitchFileActionDelegate.prototype = {
749 /**
750 * @return {boolean}
751 */
752 handleAction: function()
753 {
754 var sourcesView = WebInspector.context.flavor(WebInspector.SourcesView);
755 if (!sourcesView)
756 return false;
757 sourcesView._switchFile();
758 return true;
759 }
760 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698