OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 Sources.SourceFormatData = class { | 5 Sources.SourceFormatData = class { |
6 /** | 6 /** |
7 * @param {!Workspace.UISourceCode} originalSourceCode | 7 * @param {!Workspace.UISourceCode} originalSourceCode |
8 * @param {!Workspace.UISourceCode} formattedSourceCode | 8 * @param {!Workspace.UISourceCode} formattedSourceCode |
9 * @param {!Sources.FormatterSourceMapping} mapping | 9 * @param {!Sources.FormatterSourceMapping} mapping |
10 */ | 10 */ |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 var columnNumber = rawLocation.columnNumber || 0; | 148 var columnNumber = rawLocation.columnNumber || 0; |
149 var formattedLocation = formatData.mapping.originalToFormatted(lineNumber, c
olumnNumber); | 149 var formattedLocation = formatData.mapping.originalToFormatted(lineNumber, c
olumnNumber); |
150 return formatData.formattedSourceCode.uiLocation(formattedLocation[0], forma
ttedLocation[1]); | 150 return formatData.formattedSourceCode.uiLocation(formattedLocation[0], forma
ttedLocation[1]); |
151 } | 151 } |
152 | 152 |
153 /** | 153 /** |
154 * @override | 154 * @override |
155 * @param {!Workspace.UISourceCode} uiSourceCode | 155 * @param {!Workspace.UISourceCode} uiSourceCode |
156 * @param {number} lineNumber | 156 * @param {number} lineNumber |
157 * @param {number} columnNumber | 157 * @param {number} columnNumber |
158 * @return {!Array<!SDK.DebuggerModel.Location>} | 158 * @return {?SDK.DebuggerModel.Location} |
159 */ | 159 */ |
160 uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber) { | 160 uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) { |
161 var formatData = Sources.SourceFormatData._for(uiSourceCode); | 161 var formatData = Sources.SourceFormatData._for(uiSourceCode); |
162 if (!formatData) | 162 if (!formatData) |
163 return []; | 163 return null; |
164 var originalLocation = formatData.mapping.formattedToOriginal(lineNumber, co
lumnNumber); | 164 var originalLocation = formatData.mapping.formattedToOriginal(lineNumber, co
lumnNumber); |
165 var scripts = this._scriptsForUISourceCode(formatData.originalSourceCode); | 165 var scripts = this._scriptsForUISourceCode(formatData.originalSourceCode); |
166 if (!scripts.length) | 166 if (!scripts.length) |
167 return []; | 167 return null; |
168 var location = scripts[0].debuggerModel.createRawLocation(scripts[0], origin
alLocation[0], originalLocation[1]); | 168 return scripts[0].debuggerModel.createRawLocation(scripts[0], originalLocati
on[0], originalLocation[1]); |
169 return location ? [location] : []; | |
170 } | 169 } |
171 | 170 |
172 /** | 171 /** |
173 * @override | 172 * @override |
174 * @return {boolean} | 173 * @return {boolean} |
175 */ | 174 */ |
176 isIdentity() { | 175 isIdentity() { |
177 return false; | 176 return false; |
178 } | 177 } |
179 | 178 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 if (uiSourceCode.contentType() === Common.resourceTypes.Document) { | 218 if (uiSourceCode.contentType() === Common.resourceTypes.Document) { |
220 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); | 219 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); |
221 var debuggerModel = target && target.model(SDK.DebuggerModel); | 220 var debuggerModel = target && target.model(SDK.DebuggerModel); |
222 if (debuggerModel) { | 221 if (debuggerModel) { |
223 var scripts = debuggerModel.scriptsForSourceURL(uiSourceCode.url()) | 222 var scripts = debuggerModel.scriptsForSourceURL(uiSourceCode.url()) |
224 .filter(script => script.isInlineScript() && !script.h
asSourceURL); | 223 .filter(script => script.isInlineScript() && !script.h
asSourceURL); |
225 return scripts; | 224 return scripts; |
226 } | 225 } |
227 } | 226 } |
228 if (uiSourceCode.contentType().isScript()) { | 227 if (uiSourceCode.contentType().isScript()) { |
229 return Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiSource
Code, 0, 0) | 228 var rawLocation = Bindings.debuggerWorkspaceBinding.uiLocationToRawLocatio
n(uiSourceCode, 0, 0); |
230 .map(location => location.script()); | 229 if (rawLocation) |
| 230 return [rawLocation.script()]; |
231 } | 231 } |
232 return []; | 232 return []; |
233 } | 233 } |
234 }; | 234 }; |
235 | 235 |
236 /** | 236 /** |
237 * @implements {Bindings.CSSWorkspaceBinding.SourceMapping} | 237 * @implements {Bindings.CSSWorkspaceBinding.SourceMapping} |
238 */ | 238 */ |
239 Sources.SourceFormatter.StyleMapping = class { | 239 Sources.SourceFormatter.StyleMapping = class { |
240 constructor() { | 240 constructor() { |
(...skipping 26 matching lines...) Expand all Loading... |
267 return; | 267 return; |
268 if (enable) | 268 if (enable) |
269 styleHeader[Sources.SourceFormatData._formatDataSymbol] = formatData; | 269 styleHeader[Sources.SourceFormatData._formatDataSymbol] = formatData; |
270 else | 270 else |
271 delete styleHeader[Sources.SourceFormatData._formatDataSymbol]; | 271 delete styleHeader[Sources.SourceFormatData._formatDataSymbol]; |
272 Bindings.cssWorkspaceBinding.updateLocations(styleHeader); | 272 Bindings.cssWorkspaceBinding.updateLocations(styleHeader); |
273 } | 273 } |
274 }; | 274 }; |
275 | 275 |
276 Sources.sourceFormatter = new Sources.SourceFormatter(); | 276 Sources.sourceFormatter = new Sources.SourceFormatter(); |
OLD | NEW |