| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 this.columnOffset = startColumn; | 64 this.columnOffset = startColumn; |
| 65 this.endLine = endLine; | 65 this.endLine = endLine; |
| 66 this.endColumn = endColumn; | 66 this.endColumn = endColumn; |
| 67 | 67 |
| 68 this._executionContextId = executionContextId; | 68 this._executionContextId = executionContextId; |
| 69 this.hash = hash; | 69 this.hash = hash; |
| 70 this._isContentScript = isContentScript; | 70 this._isContentScript = isContentScript; |
| 71 this._isLiveEdit = isLiveEdit; | 71 this._isLiveEdit = isLiveEdit; |
| 72 this.sourceMapURL = sourceMapURL; | 72 this.sourceMapURL = sourceMapURL; |
| 73 this.hasSourceURL = hasSourceURL; | 73 this.hasSourceURL = hasSourceURL; |
| 74 this._originalContentProvider = null; |
| 75 this._originalSource = null; |
| 74 } | 76 } |
| 75 | 77 |
| 76 /** | 78 /** |
| 77 * @param {string} source | 79 * @param {string} source |
| 78 * @return {string} | 80 * @return {string} |
| 79 */ | 81 */ |
| 80 static _trimSourceURLComment(source) { | 82 static _trimSourceURLComment(source) { |
| 81 var sourceURLIndex = source.lastIndexOf('//# sourceURL='); | 83 var sourceURLIndex = source.lastIndexOf('//# sourceURL='); |
| 82 if (sourceURLIndex === -1) { | 84 if (sourceURLIndex === -1) { |
| 83 sourceURLIndex = source.lastIndexOf('//@ sourceURL='); | 85 sourceURLIndex = source.lastIndexOf('//@ sourceURL='); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 * @param {?Protocol.Error} error | 181 * @param {?Protocol.Error} error |
| 180 * @param {string} source | 182 * @param {string} source |
| 181 */ | 183 */ |
| 182 function didGetScriptSource(error, source) { | 184 function didGetScriptSource(error, source) { |
| 183 if (!error) { | 185 if (!error) { |
| 184 SDK.Script._reportDeprecatedCommentIfNeeded(this, source); | 186 SDK.Script._reportDeprecatedCommentIfNeeded(this, source); |
| 185 this._source = SDK.Script._trimSourceURLComment(source); | 187 this._source = SDK.Script._trimSourceURLComment(source); |
| 186 } else { | 188 } else { |
| 187 this._source = ''; | 189 this._source = ''; |
| 188 } | 190 } |
| 191 if (this._originalSource === null) |
| 192 this._originalSource = this._source; |
| 189 callback(this._source); | 193 callback(this._source); |
| 190 } | 194 } |
| 191 } | 195 } |
| 192 | 196 |
| 193 /** | 197 /** |
| 198 * @return {!Common.ContentProvider} |
| 199 */ |
| 200 originalContentProvider() { |
| 201 if (!this._originalContentProvider) { |
| 202 var lazyContent = () => this.requestContent().then(() => this._originalSou
rce); |
| 203 this._originalContentProvider = |
| 204 new Common.StaticContentProvider(this.contentURL(), this.contentType()
, lazyContent); |
| 205 } |
| 206 return this._originalContentProvider; |
| 207 } |
| 208 |
| 209 /** |
| 194 * @override | 210 * @override |
| 195 * @param {string} query | 211 * @param {string} query |
| 196 * @param {boolean} caseSensitive | 212 * @param {boolean} caseSensitive |
| 197 * @param {boolean} isRegex | 213 * @param {boolean} isRegex |
| 198 * @param {function(!Array.<!Protocol.Debugger.SearchMatch>)} callback | 214 * @param {function(!Array.<!Protocol.Debugger.SearchMatch>)} callback |
| 199 */ | 215 */ |
| 200 searchInContent(query, caseSensitive, isRegex, callback) { | 216 searchInContent(query, caseSensitive, isRegex, callback) { |
| 201 /** | 217 /** |
| 202 * @param {?Protocol.Error} error | 218 * @param {?Protocol.Error} error |
| 203 * @param {!Array.<!Protocol.Debugger.SearchMatch>} searchMatches | 219 * @param {!Array.<!Protocol.Debugger.SearchMatch>} searchMatches |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 this._source = newSource; | 270 this._source = newSource; |
| 255 var needsStepIn = !!stackChanged; | 271 var needsStepIn = !!stackChanged; |
| 256 callback(error, exceptionDetails, callFrames, asyncStackTrace, needsStepIn
); | 272 callback(error, exceptionDetails, callFrames, asyncStackTrace, needsStepIn
); |
| 257 } | 273 } |
| 258 | 274 |
| 259 newSource = SDK.Script._trimSourceURLComment(newSource); | 275 newSource = SDK.Script._trimSourceURLComment(newSource); |
| 260 // We append correct sourceURL to script for consistency only. It's not actu
ally needed for things to work correctly. | 276 // We append correct sourceURL to script for consistency only. It's not actu
ally needed for things to work correctly. |
| 261 newSource = this._appendSourceURLCommentIfNeeded(newSource); | 277 newSource = this._appendSourceURLCommentIfNeeded(newSource); |
| 262 | 278 |
| 263 if (this.scriptId) { | 279 if (this.scriptId) { |
| 264 this.debuggerModel.target().debuggerAgent().setScriptSource( | 280 this.requestContent().then( |
| 265 this.scriptId, newSource, undefined, didEditScriptSource.bind(this)); | 281 () => this.debuggerModel.target().debuggerAgent().setScriptSource( |
| 282 this.scriptId, newSource, undefined, didEditScriptSource.bind(this
))); |
| 266 } else { | 283 } else { |
| 267 callback('Script failed to parse'); | 284 callback('Script failed to parse'); |
| 268 } | 285 } |
| 269 } | 286 } |
| 270 | 287 |
| 271 /** | 288 /** |
| 272 * @param {number} lineNumber | 289 * @param {number} lineNumber |
| 273 * @param {number=} columnNumber | 290 * @param {number=} columnNumber |
| 274 * @return {!SDK.DebuggerModel.Location} | 291 * @return {!SDK.DebuggerModel.Location} |
| 275 */ | 292 */ |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 function callback(error) { | 346 function callback(error) { |
| 330 if (error) | 347 if (error) |
| 331 console.error(error); | 348 console.error(error); |
| 332 fulfill(!error); | 349 fulfill(!error); |
| 333 } | 350 } |
| 334 } | 351 } |
| 335 } | 352 } |
| 336 }; | 353 }; |
| 337 | 354 |
| 338 SDK.Script.sourceURLRegex = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m; | 355 SDK.Script.sourceURLRegex = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m; |
| OLD | NEW |