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 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 /** | 31 /** |
32 * @constructor | 32 * @constructor |
33 * @extends {WebInspector.SDKObject} | 33 * @extends {WebInspector.SDKObject} |
34 * @param {!WebInspector.Target} target | 34 * @param {!WebInspector.Target} target |
35 * @param {!WebInspector.Workspace} workspace | 35 * @param {!WebInspector.Workspace} workspace |
| 36 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding |
36 */ | 37 */ |
37 WebInspector.LiveEditSupport = function(target, workspace) | 38 WebInspector.LiveEditSupport = function(target, workspace, debuggerWorkspaceBind
ing) |
38 { | 39 { |
39 WebInspector.SDKObject.call(this, target); | 40 WebInspector.SDKObject.call(this, target); |
40 this._workspace = workspace; | 41 this._workspace = workspace; |
| 42 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; |
41 this._projectId = "liveedit:" + target.id(); | 43 this._projectId = "liveedit:" + target.id(); |
42 this._projectDelegate = new WebInspector.DebuggerProjectDelegate(workspace,
this._projectId, WebInspector.projectTypes.LiveEdit); | 44 this._projectDelegate = new WebInspector.DebuggerProjectDelegate(workspace,
this._projectId, WebInspector.projectTypes.LiveEdit); |
43 target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Glob
alObjectCleared, this._debuggerReset, this); | 45 target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Glob
alObjectCleared, this._debuggerReset, this); |
44 this._debuggerReset(); | 46 this._debuggerReset(); |
45 } | 47 } |
46 | 48 |
47 WebInspector.LiveEditSupport.prototype = { | 49 WebInspector.LiveEditSupport.prototype = { |
48 /** | 50 /** |
49 * @param {!WebInspector.UISourceCode} uiSourceCode | 51 * @param {!WebInspector.UISourceCode} uiSourceCode |
50 * @return {!WebInspector.UISourceCode} | 52 * @return {!WebInspector.UISourceCode} |
51 */ | 53 */ |
52 uiSourceCodeForLiveEdit: function(uiSourceCode) | 54 uiSourceCodeForLiveEdit: function(uiSourceCode) |
53 { | 55 { |
54 var debuggerModelLocation = WebInspector.debuggerWorkspaceBinding.uiLoca
tionToRawLocation(this.target(), uiSourceCode, 0, 0); | 56 var debuggerModelLocation = this._debuggerWorkspaceBinding.uiLocationToR
awLocation(this.target(), uiSourceCode, 0, 0); |
55 var uiLocation = WebInspector.debuggerWorkspaceBinding.rawLocationToUILo
cation(debuggerModelLocation); | 57 var uiLocation = this._debuggerWorkspaceBinding.rawLocationToUILocation(
debuggerModelLocation); |
56 | 58 |
57 // FIXME: Support live editing of scripts mapped to some file. | 59 // FIXME: Support live editing of scripts mapped to some file. |
58 if (uiLocation.uiSourceCode !== uiSourceCode) | 60 if (uiLocation.uiSourceCode !== uiSourceCode) |
59 return uiLocation.uiSourceCode; | 61 return uiLocation.uiSourceCode; |
60 | 62 |
61 var script = debuggerModelLocation.script(); | 63 var script = debuggerModelLocation.script(); |
62 if (this._uiSourceCodeForScriptId[script.scriptId]) | 64 if (this._uiSourceCodeForScriptId[script.scriptId]) |
63 return this._uiSourceCodeForScriptId[script.scriptId]; | 65 return this._uiSourceCodeForScriptId[script.scriptId]; |
64 | 66 |
65 console.assert(!script.isInlineScript()); | 67 console.assert(!script.isInlineScript()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 { | 119 { |
118 var projectId = uiSourceCode.project().id(); | 120 var projectId = uiSourceCode.project().id(); |
119 var target = null; | 121 var target = null; |
120 var targets = WebInspector.targetManager.targets(); | 122 var targets = WebInspector.targetManager.targets(); |
121 for (var i = 0; i < targets.length; ++i) { | 123 for (var i = 0; i < targets.length; ++i) { |
122 if (projectId === WebInspector.DefaultScriptMapping.projectIdForTarget(t
argets[i])) { | 124 if (projectId === WebInspector.DefaultScriptMapping.projectIdForTarget(t
argets[i])) { |
123 target = targets[i]; | 125 target = targets[i]; |
124 break; | 126 break; |
125 } | 127 } |
126 } | 128 } |
127 var mapping = WebInspector.DebuggerScriptMapping.registry.instance(target); | 129 return target ? WebInspector.debuggerWorkspaceBinding.liveEditSupport(target
) : null; |
128 return mapping ? mapping.liveEditSupport() : null; | |
129 } | 130 } |
130 | 131 |
131 /** | 132 /** |
132 * @param {?string} error | 133 * @param {?string} error |
133 * @param {!DebuggerAgent.SetScriptSourceError=} errorData | 134 * @param {!DebuggerAgent.SetScriptSourceError=} errorData |
134 * @param {!WebInspector.Script=} contextScript | 135 * @param {!WebInspector.Script=} contextScript |
135 */ | 136 */ |
136 WebInspector.LiveEditSupport.logDetailedError = function(error, errorData, conte
xtScript) | 137 WebInspector.LiveEditSupport.logDetailedError = function(error, errorData, conte
xtScript) |
137 { | 138 { |
138 var warningLevel = WebInspector.Console.MessageLevel.Warning; | 139 var warningLevel = WebInspector.Console.MessageLevel.Warning; |
139 if (!errorData) { | 140 if (!errorData) { |
140 if (error) | 141 if (error) |
141 WebInspector.console.addMessage(WebInspector.UIString("LiveEdit fail
ed: %s", error), warningLevel); | 142 WebInspector.console.addMessage(WebInspector.UIString("LiveEdit fail
ed: %s", error), warningLevel); |
142 return; | 143 return; |
143 } | 144 } |
144 var compileError = errorData.compileError; | 145 var compileError = errorData.compileError; |
145 if (compileError) { | 146 if (compileError) { |
146 var location = contextScript ? WebInspector.UIString(" at %s:%d:%d", con
textScript.sourceURL, compileError.lineNumber, compileError.columnNumber) : ""; | 147 var location = contextScript ? WebInspector.UIString(" at %s:%d:%d", con
textScript.sourceURL, compileError.lineNumber, compileError.columnNumber) : ""; |
147 var message = WebInspector.UIString("LiveEdit compile failed: %s%s", com
pileError.message, location); | 148 var message = WebInspector.UIString("LiveEdit compile failed: %s%s", com
pileError.message, location); |
148 WebInspector.console.error(message); | 149 WebInspector.console.error(message); |
149 } else { | 150 } else { |
150 WebInspector.console.addMessage(WebInspector.UIString("Unknown LiveEdit
error: %s; %s", JSON.stringify(errorData), error), warningLevel); | 151 WebInspector.console.addMessage(WebInspector.UIString("Unknown LiveEdit
error: %s; %s", JSON.stringify(errorData), error), warningLevel); |
151 } | 152 } |
152 } | 153 } |
153 | 154 |
154 WebInspector.LiveEditSupport.logSuccess = function() | 155 WebInspector.LiveEditSupport.logSuccess = function() |
155 { | 156 { |
156 WebInspector.console.log(WebInspector.UIString("Recompilation and update suc
ceeded.")); | 157 WebInspector.console.log(WebInspector.UIString("Recompilation and update suc
ceeded.")); |
157 } | 158 } |
OLD | NEW |