OLD | NEW |
---|---|
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 /** | 191 /** |
192 * @param {!SDK.ExecutionContext} executionContext | 192 * @param {!SDK.ExecutionContext} executionContext |
193 * @param {!Workspace.UISourceCode} uiSourceCode | 193 * @param {!Workspace.UISourceCode} uiSourceCode |
194 */ | 194 */ |
195 evaluateScriptSnippet(executionContext, uiSourceCode) { | 195 evaluateScriptSnippet(executionContext, uiSourceCode) { |
196 console.assert(uiSourceCode.project().type() === Workspace.projectTypes.Snip pets); | 196 console.assert(uiSourceCode.project().type() === Workspace.projectTypes.Snip pets); |
197 var breakpointLocations = this._removeBreakpoints(uiSourceCode); | 197 var breakpointLocations = this._removeBreakpoints(uiSourceCode); |
198 this._releaseSnippetScript(uiSourceCode); | 198 this._releaseSnippetScript(uiSourceCode); |
199 this._restoreBreakpoints(uiSourceCode, breakpointLocations); | 199 this._restoreBreakpoints(uiSourceCode, breakpointLocations); |
200 | 200 |
201 var target = executionContext.target(); | 201 var runtimeModel = executionContext.runtimeModel; |
202 var runtimeModel = target.runtimeModel; | 202 var debuggerModel = executionContext.debuggerModel; |
203 var debuggerModel = /** @type {!SDK.DebuggerModel} */ (SDK.DebuggerModel.fro mTarget(target)); | |
204 var evaluationIndex = this._nextEvaluationIndex(); | 203 var evaluationIndex = this._nextEvaluationIndex(); |
205 var mapping = this._mappingForDebuggerModel.get(debuggerModel); | 204 var mapping = this._mappingForDebuggerModel.get(debuggerModel); |
206 mapping._setEvaluationIndex(evaluationIndex, uiSourceCode); | 205 mapping._setEvaluationIndex(evaluationIndex, uiSourceCode); |
207 var evaluationUrl = mapping._evaluationSourceURL(uiSourceCode); | 206 var evaluationUrl = mapping._evaluationSourceURL(uiSourceCode); |
208 uiSourceCode.requestContent().then(compileSnippet.bind(this)); | 207 uiSourceCode.requestContent().then(compileSnippet.bind(this)); |
209 | 208 |
210 /** | 209 /** |
211 * @this {Snippets.ScriptSnippetModel} | 210 * @this {Snippets.ScriptSnippetModel} |
212 */ | 211 */ |
213 function compileSnippet() { | 212 function compileSnippet() { |
214 var expression = uiSourceCode.workingCopy(); | 213 var expression = uiSourceCode.workingCopy(); |
215 Common.console.show(); | 214 Common.console.show(); |
216 runtimeModel.compileScript(expression, '', true, executionContext.id, comp ileCallback.bind(this)); | 215 runtimeModel.compileScript(expression, '', true, executionContext.id, comp ileCallback.bind(this)); |
217 } | 216 } |
218 | 217 |
219 /** | 218 /** |
220 * @param {!Protocol.Runtime.ScriptId=} scriptId | 219 * @param {!Protocol.Runtime.ScriptId=} scriptId |
221 * @param {?Protocol.Runtime.ExceptionDetails=} exceptionDetails | 220 * @param {?Protocol.Runtime.ExceptionDetails=} exceptionDetails |
222 * @this {Snippets.ScriptSnippetModel} | 221 * @this {Snippets.ScriptSnippetModel} |
223 */ | 222 */ |
224 function compileCallback(scriptId, exceptionDetails) { | 223 function compileCallback(scriptId, exceptionDetails) { |
225 var mapping = this._mappingForDebuggerModel.get(debuggerModel); | 224 var mapping = this._mappingForDebuggerModel.get(debuggerModel); |
caseq
2017/03/17 18:30:44
nuke this, use one in closure?
dgozman
2017/03/17 21:43:46
Done.
| |
226 if (mapping.evaluationIndex(uiSourceCode) !== evaluationIndex) | 225 if (mapping.evaluationIndex(uiSourceCode) !== evaluationIndex) |
227 return; | 226 return; |
228 | 227 |
229 var script = /** @type {!SDK.Script} */ ( | 228 var script = /** @type {!SDK.Script} */ ( |
230 executionContext.debuggerModel.scriptForId(/** @type {string} */ (scri ptId || exceptionDetails.scriptId))); | 229 executionContext.debuggerModel.scriptForId(/** @type {string} */ (scri ptId || exceptionDetails.scriptId))); |
caseq
2017/03/17 18:30:44
just debuggerModel
dgozman
2017/03/17 21:43:46
Done.
| |
231 mapping._addScript(script, uiSourceCode); | 230 mapping._addScript(script, uiSourceCode); |
232 if (!scriptId) { | 231 if (!scriptId) { |
233 this._printRunOrCompileScriptResultFailure( | 232 this._printRunOrCompileScriptResultFailure( |
234 target, /** @type {!Protocol.Runtime.ExceptionDetails} */ (exception Details), evaluationUrl); | 233 runtimeModel, /** @type {!Protocol.Runtime.ExceptionDetails} */ (exc eptionDetails), evaluationUrl); |
235 return; | 234 return; |
236 } | 235 } |
237 | 236 |
238 var breakpointLocations = this._removeBreakpoints(uiSourceCode); | 237 var breakpointLocations = this._removeBreakpoints(uiSourceCode); |
239 this._restoreBreakpoints(uiSourceCode, breakpointLocations); | 238 this._restoreBreakpoints(uiSourceCode, breakpointLocations); |
240 | 239 |
241 this._runScript(scriptId, executionContext, evaluationUrl); | 240 this._runScript(scriptId, executionContext, evaluationUrl); |
242 } | 241 } |
243 } | 242 } |
244 | 243 |
245 /** | 244 /** |
246 * @param {!Protocol.Runtime.ScriptId} scriptId | 245 * @param {!Protocol.Runtime.ScriptId} scriptId |
247 * @param {!SDK.ExecutionContext} executionContext | 246 * @param {!SDK.ExecutionContext} executionContext |
248 * @param {?string=} sourceURL | 247 * @param {?string=} sourceURL |
249 */ | 248 */ |
250 _runScript(scriptId, executionContext, sourceURL) { | 249 _runScript(scriptId, executionContext, sourceURL) { |
251 var target = executionContext.target(); | 250 var runtimeModel = executionContext.runtimeModel; |
252 target.runtimeModel.runScript( | 251 runtimeModel.runScript( |
253 scriptId, executionContext.id, 'console', /* silent */ false, /* include CommandLineAPI */ true, | 252 scriptId, executionContext.id, 'console', /* silent */ false, /* include CommandLineAPI */ true, |
254 /* returnByValue */ false, /* generatePreview */ true, /* awaitPromise * / undefined, | 253 /* returnByValue */ false, /* generatePreview */ true, /* awaitPromise * / undefined, runCallback.bind(this)); |
255 runCallback.bind(this, target)); | |
256 | 254 |
257 /** | 255 /** |
258 * @param {!SDK.Target} target | |
259 * @param {?Protocol.Runtime.RemoteObject} result | 256 * @param {?Protocol.Runtime.RemoteObject} result |
260 * @param {?Protocol.Runtime.ExceptionDetails=} exceptionDetails | 257 * @param {?Protocol.Runtime.ExceptionDetails=} exceptionDetails |
261 * @this {Snippets.ScriptSnippetModel} | 258 * @this {Snippets.ScriptSnippetModel} |
262 */ | 259 */ |
263 function runCallback(target, result, exceptionDetails) { | 260 function runCallback(result, exceptionDetails) { |
264 if (!exceptionDetails) | 261 if (!exceptionDetails) |
265 this._printRunScriptResult(target, result, scriptId, sourceURL); | 262 this._printRunScriptResult(runtimeModel, result, scriptId, sourceURL); |
266 else | 263 else |
267 this._printRunOrCompileScriptResultFailure(target, exceptionDetails, sou rceURL); | 264 this._printRunOrCompileScriptResultFailure(runtimeModel, exceptionDetail s, sourceURL); |
268 } | 265 } |
269 } | 266 } |
270 | 267 |
271 /** | 268 /** |
272 * @param {!SDK.Target} target | 269 * @param {!SDK.RuntimeModel} runtimeModel |
273 * @param {?Protocol.Runtime.RemoteObject} result | 270 * @param {?Protocol.Runtime.RemoteObject} result |
274 * @param {!Protocol.Runtime.ScriptId} scriptId | 271 * @param {!Protocol.Runtime.ScriptId} scriptId |
275 * @param {?string=} sourceURL | 272 * @param {?string=} sourceURL |
276 */ | 273 */ |
277 _printRunScriptResult(target, result, scriptId, sourceURL) { | 274 _printRunScriptResult(runtimeModel, result, scriptId, sourceURL) { |
278 var consoleMessage = new ConsoleModel.ConsoleMessage( | 275 var consoleMessage = new ConsoleModel.ConsoleMessage( |
279 target, ConsoleModel.ConsoleMessage.MessageSource.JS, ConsoleModel.Conso leMessage.MessageLevel.Info, '', | 276 runtimeModel.target(), ConsoleModel.ConsoleMessage.MessageSource.JS, |
280 undefined, sourceURL, undefined, undefined, undefined, [result], undefin ed, undefined, undefined, scriptId); | 277 ConsoleModel.ConsoleMessage.MessageLevel.Info, '', undefined, sourceURL, undefined, undefined, undefined, |
278 [result], undefined, undefined, undefined, scriptId); | |
281 ConsoleModel.consoleModel.addMessage(consoleMessage); | 279 ConsoleModel.consoleModel.addMessage(consoleMessage); |
282 } | 280 } |
283 | 281 |
284 /** | 282 /** |
285 * @param {!SDK.Target} target | 283 * @param {!SDK.RuntimeModel} runtimeModel |
286 * @param {!Protocol.Runtime.ExceptionDetails} exceptionDetails | 284 * @param {!Protocol.Runtime.ExceptionDetails} exceptionDetails |
287 * @param {?string=} sourceURL | 285 * @param {?string=} sourceURL |
288 */ | 286 */ |
289 _printRunOrCompileScriptResultFailure(target, exceptionDetails, sourceURL) { | 287 _printRunOrCompileScriptResultFailure(runtimeModel, exceptionDetails, sourceUR L) { |
290 ConsoleModel.consoleModel.addMessage(ConsoleModel.ConsoleMessage.fromExcepti on( | 288 ConsoleModel.consoleModel.addMessage(ConsoleModel.ConsoleMessage.fromExcepti on( |
291 target, exceptionDetails, undefined, undefined, sourceURL || undefined)) ; | 289 runtimeModel, exceptionDetails, undefined, undefined, sourceURL || undef ined)); |
292 } | 290 } |
293 | 291 |
294 /** | 292 /** |
295 * @param {!Workspace.UISourceCode} uiSourceCode | 293 * @param {!Workspace.UISourceCode} uiSourceCode |
296 * @return {!Array.<!{breakpoint: !Bindings.BreakpointManager.Breakpoint, uiLo cation: !Workspace.UILocation}>} | 294 * @return {!Array.<!{breakpoint: !Bindings.BreakpointManager.Breakpoint, uiLo cation: !Workspace.UILocation}>} |
297 */ | 295 */ |
298 _removeBreakpoints(uiSourceCode) { | 296 _removeBreakpoints(uiSourceCode) { |
299 var breakpointLocations = Bindings.breakpointManager.breakpointLocationsForU ISourceCode(uiSourceCode); | 297 var breakpointLocations = Bindings.breakpointManager.breakpointLocationsForU ISourceCode(uiSourceCode); |
300 for (var i = 0; i < breakpointLocations.length; ++i) | 298 for (var i = 0; i < breakpointLocations.length; ++i) |
301 breakpointLocations[i].breakpoint.remove(); | 299 breakpointLocations[i].breakpoint.remove(); |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
613 */ | 611 */ |
614 deleteFile(uiSourceCode) { | 612 deleteFile(uiSourceCode) { |
615 this._model.deleteScriptSnippet(uiSourceCode); | 613 this._model.deleteScriptSnippet(uiSourceCode); |
616 } | 614 } |
617 }; | 615 }; |
618 | 616 |
619 /** | 617 /** |
620 * @type {!Snippets.ScriptSnippetModel} | 618 * @type {!Snippets.ScriptSnippetModel} |
621 */ | 619 */ |
622 Snippets.scriptSnippetModel = new Snippets.ScriptSnippetModel(Workspace.workspac e); | 620 Snippets.scriptSnippetModel = new Snippets.ScriptSnippetModel(Workspace.workspac e); |
OLD | NEW |