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

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

Issue 702823002: DevTools: support inplace formatting for workspace scripts/documents. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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 | « no previous file | 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 2014 The Chromium Authors. All rights reserved. 2 // Copyright 2014 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 5
6 /** 6 /**
7 * @constructor 7 * @constructor
8 * @implements {WebInspector.SourcesView.EditorAction} 8 * @implements {WebInspector.SourcesView.EditorAction}
9 */ 9 */
10 WebInspector.InplaceFormatterEditorAction = function() 10 WebInspector.InplaceFormatterEditorAction = function()
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 }, 61 },
62 62
63 /** 63 /**
64 * @param {?WebInspector.UISourceCode} uiSourceCode 64 * @param {?WebInspector.UISourceCode} uiSourceCode
65 * @return {boolean} 65 * @return {boolean}
66 */ 66 */
67 _isFormattable: function(uiSourceCode) 67 _isFormattable: function(uiSourceCode)
68 { 68 {
69 if (!uiSourceCode) 69 if (!uiSourceCode)
70 return false; 70 return false;
71 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst em)
72 return true;
71 return uiSourceCode.contentType() === WebInspector.resourceTypes.Stylesh eet 73 return uiSourceCode.contentType() === WebInspector.resourceTypes.Stylesh eet
72 || uiSourceCode.project().type() === WebInspector.projectTypes.Snipp ets; 74 || uiSourceCode.project().type() === WebInspector.projectTypes.Snipp ets;
73 }, 75 },
74 76
75 _formatSourceInPlace: function() 77 _formatSourceInPlace: function()
76 { 78 {
77 var uiSourceCode = this._sourcesView.currentUISourceCode(); 79 var uiSourceCode = this._sourcesView.currentUISourceCode();
78 if (!this._isFormattable(uiSourceCode)) 80 if (!this._isFormattable(uiSourceCode))
79 return; 81 return;
80 82
(...skipping 26 matching lines...) Expand all
107 var start = [0, 0]; 109 var start = [0, 0];
108 if (sourceFrame) { 110 if (sourceFrame) {
109 var selection = sourceFrame.selection(); 111 var selection = sourceFrame.selection();
110 start = formatterMapping.originalToFormatted(selection.startLine , selection.startColumn); 112 start = formatterMapping.originalToFormatted(selection.startLine , selection.startColumn);
111 } 113 }
112 uiSourceCode.setWorkingCopy(formattedContent); 114 uiSourceCode.setWorkingCopy(formattedContent);
113 this._sourcesView.showSourceLocation(uiSourceCode, start[0], start[1 ]); 115 this._sourcesView.showSourceLocation(uiSourceCode, start[0], start[1 ]);
114 } 116 }
115 }, 117 },
116 } 118 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698