OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 var selection = this.textEditor.copyRange(textSelection); | 273 var selection = this.textEditor.copyRange(textSelection); |
274 var addToWatchLabel = WebInspector.UIString(WebInspector.useLowerCas eMenuTitles() ? "Add to watch" : "Add to Watch"); | 274 var addToWatchLabel = WebInspector.UIString(WebInspector.useLowerCas eMenuTitles() ? "Add to watch" : "Add to Watch"); |
275 contextMenu.appendItem(addToWatchLabel, this._innerAddToWatch.bind(t his, selection)); | 275 contextMenu.appendItem(addToWatchLabel, this._innerAddToWatch.bind(t his, selection)); |
276 var evaluateLabel = WebInspector.UIString(WebInspector.useLowerCaseM enuTitles() ? "Evaluate in console" : "Evaluate in Console"); | 276 var evaluateLabel = WebInspector.UIString(WebInspector.useLowerCaseM enuTitles() ? "Evaluate in console" : "Evaluate in Console"); |
277 contextMenu.appendItem(evaluateLabel, this._evaluateInConsole.bind(t his, selection)); | 277 contextMenu.appendItem(evaluateLabel, this._evaluateInConsole.bind(t his, selection)); |
278 contextMenu.appendSeparator(); | 278 contextMenu.appendSeparator(); |
279 } else if (this._uiSourceCode.project().type() === WebInspector.projectT ypes.Debugger) { | 279 } else if (this._uiSourceCode.project().type() === WebInspector.projectT ypes.Debugger) { |
280 // FIXME: Change condition above to explicitly check that current ui SourceCode is created by default debugger mapping | 280 // FIXME: Change condition above to explicitly check that current ui SourceCode is created by default debugger mapping |
281 // and move the code adding this menu item to generic context menu p rovider for UISourceCode. | 281 // and move the code adding this menu item to generic context menu p rovider for UISourceCode. |
282 var liveEditLabel = WebInspector.UIString(WebInspector.useLowerCaseM enuTitles() ? "Live edit" : "Live Edit"); | 282 var liveEditLabel = WebInspector.UIString(WebInspector.useLowerCaseM enuTitles() ? "Live edit" : "Live Edit"); |
283 contextMenu.appendItem(liveEditLabel, liveEdit.bind(this)); | 283 var projectId = this._uiSourceCode.project().id(); |
vsevik
2014/06/26 14:16:19
Let's make this static method in LiveEditSupport
sergeyv
2014/06/26 14:38:35
Done.
| |
284 var target; | |
285 var targets = WebInspector.targetManager.targets(); | |
286 for (var i = 0; i < targets.length; ++i) { | |
287 if (projectId === WebInspector.DefaultScriptMapping.projectIdFor Target(targets[i])) { | |
288 target = targets[i]; | |
289 break; | |
290 } | |
291 } | |
292 if (!target) | |
293 return; | |
294 | |
295 contextMenu.appendItem(liveEditLabel, liveEdit.bind(this, target.liv eEditSupport)); | |
284 contextMenu.appendSeparator(); | 296 contextMenu.appendSeparator(); |
285 } | 297 } |
286 | 298 |
287 /** | 299 /** |
288 * @this {WebInspector.JavaScriptSourceFrame} | 300 * @this {WebInspector.JavaScriptSourceFrame} |
301 * @param {!WebInspector.LiveEditSupport} liveEditSupport | |
289 */ | 302 */ |
290 function liveEdit() | 303 function liveEdit(liveEditSupport) |
291 { | 304 { |
292 var liveEditUISourceCode = WebInspector.liveEditSupport.uiSourceCode ForLiveEdit(this._uiSourceCode); | 305 var liveEditUISourceCode = liveEditSupport.uiSourceCodeForLiveEdit(t his._uiSourceCode); |
293 WebInspector.Revealer.reveal(liveEditUISourceCode.uiLocation(lineNum ber)); | 306 WebInspector.Revealer.reveal(liveEditUISourceCode.uiLocation(lineNum ber)); |
294 } | 307 } |
295 | 308 |
296 WebInspector.UISourceCodeFrame.prototype.populateTextAreaContextMenu.cal l(this, contextMenu, lineNumber); | 309 WebInspector.UISourceCodeFrame.prototype.populateTextAreaContextMenu.cal l(this, contextMenu, lineNumber); |
297 }, | 310 }, |
298 | 311 |
299 _workingCopyChanged: function(event) | 312 _workingCopyChanged: function(event) |
300 { | 313 { |
301 if (this._supportsEnabledBreakpointsWhileEditing() || this._scriptFileFo rTarget.size()) | 314 if (this._supportsEnabledBreakpointsWhileEditing() || this._scriptFileFo rTarget.size()) |
302 return; | 315 return; |
303 | 316 |
304 if (this._uiSourceCode.isDirty()) | 317 if (this._uiSourceCode.isDirty()) |
305 this._muteBreakpointsWhileEditing(); | 318 this._muteBreakpointsWhileEditing(); |
306 else | 319 else |
307 this._restoreBreakpointsAfterEditing(); | 320 this._restoreBreakpointsAfterEditing(); |
308 }, | 321 }, |
309 | 322 |
310 _workingCopyCommitted: function(event) | 323 _workingCopyCommitted: function(event) |
311 { | 324 { |
325 | |
326 var callbackCount; | |
vsevik
2014/06/26 14:16:19
redundant
sergeyv
2014/06/26 14:38:35
Done.
| |
327 var liveEditError; | |
328 var liveEditErrorData; | |
329 var contextScript; | |
330 var succeededEdits = 0; | |
331 var failedEdits = 0; | |
332 | |
333 /** | |
334 * @param {?string} error | |
335 * @param {!DebuggerAgent.SetScriptSourceError=} errorData | |
336 * @param {!WebInspector.Script=} script | |
337 */ | |
338 function liveEditCallback(error, errorData, script) | |
339 { | |
340 if (error) { | |
341 liveEditError = error; | |
342 liveEditErrorData = errorData; | |
343 contextScript = script; | |
344 failedEdits--; | |
vsevik
2014/06/26 14:16:19
++
sergeyv
2014/06/26 14:38:35
Done.
| |
345 } else | |
346 succeededEdits++; | |
347 | |
348 if (succeededEdits + failedEdits !== callbackCount) | |
349 return; | |
350 | |
351 if (succeededEdits === callbackCount) | |
vsevik
2014/06/26 14:16:19
failedEdits === 0
sergeyv
2014/06/26 14:38:35
Done.
| |
352 WebInspector.LiveEditSupport.logSuccess(); | |
353 else | |
354 WebInspector.LiveEditSupport.logDetailedError(liveEditError, liv eEditErrorData, contextScript) | |
355 | |
356 } | |
357 | |
312 if (this._supportsEnabledBreakpointsWhileEditing()) | 358 if (this._supportsEnabledBreakpointsWhileEditing()) |
313 return; | 359 return; |
314 if (this._scriptFileForTarget.size()) { | 360 if (this._scriptFileForTarget.size()) { |
315 this._hasCommittedLiveEdit = true; | 361 this._hasCommittedLiveEdit = true; |
316 var scriptFiles = this._scriptFileForTarget.values(); | 362 var scriptFiles = this._scriptFileForTarget.values(); |
363 callbackCount = scriptFiles.length; | |
317 for (var i = 0; i < scriptFiles.length; ++i) | 364 for (var i = 0; i < scriptFiles.length; ++i) |
318 scriptFiles[i].commitLiveEdit(); | 365 scriptFiles[i].commitLiveEdit(liveEditCallback); |
319 return; | 366 return; |
320 } | 367 } |
321 this._restoreBreakpointsAfterEditing(); | 368 this._restoreBreakpointsAfterEditing(); |
322 }, | 369 }, |
323 | 370 |
324 _didMergeToVM: function() | 371 _didMergeToVM: function() |
325 { | 372 { |
326 if (this._supportsEnabledBreakpointsWhileEditing()) | 373 if (this._supportsEnabledBreakpointsWhileEditing()) |
327 return; | 374 return; |
328 this._updateDivergedInfobar(); | 375 this._updateDivergedInfobar(); |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
836 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. ConsoleMessageRemoved, this._consoleMessageRemoved, this); | 883 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. ConsoleMessageRemoved, this._consoleMessageRemoved, this); |
837 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. ConsoleMessagesCleared, this._consoleMessagesCleared, this); | 884 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. ConsoleMessagesCleared, this._consoleMessagesCleared, this); |
838 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. SourceMappingChanged, this._onSourceMappingChanged, this); | 885 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. SourceMappingChanged, this._onSourceMappingChanged, this); |
839 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this); | 886 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this); |
840 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyCommitted, this._workingCopyCommitted, this); | 887 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyCommitted, this._workingCopyCommitted, this); |
841 WebInspector.UISourceCodeFrame.prototype.dispose.call(this); | 888 WebInspector.UISourceCodeFrame.prototype.dispose.call(this); |
842 }, | 889 }, |
843 | 890 |
844 __proto__: WebInspector.UISourceCodeFrame.prototype | 891 __proto__: WebInspector.UISourceCodeFrame.prototype |
845 } | 892 } |
OLD | NEW |