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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 this.lineOffset = startLine; | 50 this.lineOffset = startLine; |
51 this.columnOffset = startColumn; | 51 this.columnOffset = startColumn; |
52 this.endLine = endLine; | 52 this.endLine = endLine; |
53 this.endColumn = endColumn; | 53 this.endColumn = endColumn; |
54 this._executionContextId = executionContextId; | 54 this._executionContextId = executionContextId; |
55 this.hash = hash; | 55 this.hash = hash; |
56 this._isContentScript = isContentScript; | 56 this._isContentScript = isContentScript; |
57 this._isLiveEdit = isLiveEdit; | 57 this._isLiveEdit = isLiveEdit; |
58 this.sourceMapURL = sourceMapURL; | 58 this.sourceMapURL = sourceMapURL; |
59 this.hasSourceURL = hasSourceURL; | 59 this.hasSourceURL = hasSourceURL; |
60 } | 60 }; |
61 | 61 |
62 /** @enum {symbol} */ | 62 /** @enum {symbol} */ |
63 WebInspector.Script.Events = { | 63 WebInspector.Script.Events = { |
64 ScriptEdited: Symbol("ScriptEdited"), | 64 ScriptEdited: Symbol("ScriptEdited"), |
65 SourceMapURLAdded: Symbol("SourceMapURLAdded") | 65 SourceMapURLAdded: Symbol("SourceMapURLAdded") |
66 } | 66 }; |
67 | 67 |
68 WebInspector.Script.sourceURLRegex = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$
/m; | 68 WebInspector.Script.sourceURLRegex = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$
/m; |
69 | 69 |
70 /** | 70 /** |
71 * @param {string} source | 71 * @param {string} source |
72 * @return {string} | 72 * @return {string} |
73 */ | 73 */ |
74 WebInspector.Script._trimSourceURLComment = function(source) | 74 WebInspector.Script._trimSourceURLComment = function(source) |
75 { | 75 { |
76 var sourceURLIndex = source.lastIndexOf("//# sourceURL="); | 76 var sourceURLIndex = source.lastIndexOf("//# sourceURL="); |
77 if (sourceURLIndex === -1) { | 77 if (sourceURLIndex === -1) { |
78 sourceURLIndex = source.lastIndexOf("//@ sourceURL="); | 78 sourceURLIndex = source.lastIndexOf("//@ sourceURL="); |
79 if (sourceURLIndex === -1) | 79 if (sourceURLIndex === -1) |
80 return source; | 80 return source; |
81 } | 81 } |
82 var sourceURLLineIndex = source.lastIndexOf("\n", sourceURLIndex); | 82 var sourceURLLineIndex = source.lastIndexOf("\n", sourceURLIndex); |
83 if (sourceURLLineIndex === -1) | 83 if (sourceURLLineIndex === -1) |
84 return source; | 84 return source; |
85 var sourceURLLine = source.substr(sourceURLLineIndex + 1).split("\n", 1)[0]; | 85 var sourceURLLine = source.substr(sourceURLLineIndex + 1).split("\n", 1)[0]; |
86 if (sourceURLLine.search(WebInspector.Script.sourceURLRegex) === -1) | 86 if (sourceURLLine.search(WebInspector.Script.sourceURLRegex) === -1) |
87 return source; | 87 return source; |
88 return source.substr(0, sourceURLLineIndex) + source.substr(sourceURLLineInd
ex + sourceURLLine.length + 1); | 88 return source.substr(0, sourceURLLineIndex) + source.substr(sourceURLLineInd
ex + sourceURLLine.length + 1); |
89 } | 89 }; |
90 | 90 |
91 /** | 91 /** |
92 * @param {!WebInspector.Script} script | 92 * @param {!WebInspector.Script} script |
93 * @param {string} source | 93 * @param {string} source |
94 */ | 94 */ |
95 WebInspector.Script._reportDeprecatedCommentIfNeeded = function(script, source) | 95 WebInspector.Script._reportDeprecatedCommentIfNeeded = function(script, source) |
96 { | 96 { |
97 var consoleModel = script.target().consoleModel; | 97 var consoleModel = script.target().consoleModel; |
98 if (!consoleModel) | 98 if (!consoleModel) |
99 return; | 99 return; |
100 var linesToCheck = 5; | 100 var linesToCheck = 5; |
101 var offset = source.lastIndexOf("\n"); | 101 var offset = source.lastIndexOf("\n"); |
102 while (linesToCheck && offset !== -1) { | 102 while (linesToCheck && offset !== -1) { |
103 offset = source.lastIndexOf("\n", offset - 1); | 103 offset = source.lastIndexOf("\n", offset - 1); |
104 --linesToCheck; | 104 --linesToCheck; |
105 } | 105 } |
106 offset = offset !== -1 ? offset : 0; | 106 offset = offset !== -1 ? offset : 0; |
107 var sourceTail = source.substr(offset); | 107 var sourceTail = source.substr(offset); |
108 if (sourceTail.length > 5000) | 108 if (sourceTail.length > 5000) |
109 return; | 109 return; |
110 if (sourceTail.search(/^[\040\t]*\/\/@ source(mapping)?url=/mi) === -1) | 110 if (sourceTail.search(/^[\040\t]*\/\/@ source(mapping)?url=/mi) === -1) |
111 return; | 111 return; |
112 var text = WebInspector.UIString("'//@ sourceURL' and '//@ sourceMappingURL'
are deprecated, please use '//# sourceURL=' and '//# sourceMappingURL=' instead
."); | 112 var text = WebInspector.UIString("'//@ sourceURL' and '//@ sourceMappingURL'
are deprecated, please use '//# sourceURL=' and '//# sourceMappingURL=' instead
."); |
113 var msg = new WebInspector.ConsoleMessage(script.target(), WebInspector.Cons
oleMessage.MessageSource.JS, WebInspector.ConsoleMessage.MessageLevel.Warning, t
ext, undefined, undefined, undefined, undefined, undefined, undefined, undefined
, undefined, undefined, script.scriptId); | 113 var msg = new WebInspector.ConsoleMessage(script.target(), WebInspector.Cons
oleMessage.MessageSource.JS, WebInspector.ConsoleMessage.MessageLevel.Warning, t
ext, undefined, undefined, undefined, undefined, undefined, undefined, undefined
, undefined, undefined, script.scriptId); |
114 consoleModel.addMessage(msg); | 114 consoleModel.addMessage(msg); |
115 } | 115 }; |
116 | 116 |
117 WebInspector.Script.prototype = { | 117 WebInspector.Script.prototype = { |
118 /** | 118 /** |
119 * @return {boolean} | 119 * @return {boolean} |
120 */ | 120 */ |
121 isContentScript: function() | 121 isContentScript: function() |
122 { | 122 { |
123 return this._isContentScript; | 123 return this._isContentScript; |
124 }, | 124 }, |
125 | 125 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 function callback(error) | 337 function callback(error) |
338 { | 338 { |
339 if (error) | 339 if (error) |
340 console.error(error); | 340 console.error(error); |
341 fulfill(!error); | 341 fulfill(!error); |
342 } | 342 } |
343 } | 343 } |
344 }, | 344 }, |
345 | 345 |
346 __proto__: WebInspector.SDKObject.prototype | 346 __proto__: WebInspector.SDKObject.prototype |
347 } | 347 }; |
OLD | NEW |