Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/JavaScriptCompiler.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 /** 4 /**
5 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 WebInspector.JavaScriptCompiler = class { 7 Sources.JavaScriptCompiler = class {
8 /** 8 /**
9 * @param {!WebInspector.JavaScriptSourceFrame} sourceFrame 9 * @param {!Sources.JavaScriptSourceFrame} sourceFrame
10 */ 10 */
11 constructor(sourceFrame) { 11 constructor(sourceFrame) {
12 this._sourceFrame = sourceFrame; 12 this._sourceFrame = sourceFrame;
13 this._compiling = false; 13 this._compiling = false;
14 } 14 }
15 15
16 scheduleCompile() { 16 scheduleCompile() {
17 if (this._compiling) { 17 if (this._compiling) {
18 this._recompileScheduled = true; 18 this._recompileScheduled = true;
19 return; 19 return;
20 } 20 }
21 if (this._timeout) 21 if (this._timeout)
22 clearTimeout(this._timeout); 22 clearTimeout(this._timeout);
23 this._timeout = setTimeout(this._compile.bind(this), WebInspector.JavaScript Compiler.CompileDelay); 23 this._timeout = setTimeout(this._compile.bind(this), Sources.JavaScriptCompi ler.CompileDelay);
24 } 24 }
25 25
26 /** 26 /**
27 * @return {?WebInspector.Target} 27 * @return {?SDK.Target}
28 */ 28 */
29 _findTarget() { 29 _findTarget() {
30 var targets = WebInspector.targetManager.targets(); 30 var targets = SDK.targetManager.targets();
31 var sourceCode = this._sourceFrame.uiSourceCode(); 31 var sourceCode = this._sourceFrame.uiSourceCode();
32 for (var i = 0; i < targets.length; ++i) { 32 for (var i = 0; i < targets.length; ++i) {
33 var scriptFile = WebInspector.debuggerWorkspaceBinding.scriptFile(sourceCo de, targets[i]); 33 var scriptFile = Bindings.debuggerWorkspaceBinding.scriptFile(sourceCode, targets[i]);
34 if (scriptFile) 34 if (scriptFile)
35 return targets[i]; 35 return targets[i];
36 } 36 }
37 return WebInspector.targetManager.mainTarget(); 37 return SDK.targetManager.mainTarget();
38 } 38 }
39 39
40 _compile() { 40 _compile() {
41 var target = this._findTarget(); 41 var target = this._findTarget();
42 if (!target) 42 if (!target)
43 return; 43 return;
44 var runtimeModel = target.runtimeModel; 44 var runtimeModel = target.runtimeModel;
45 var currentExecutionContext = WebInspector.context.flavor(WebInspector.Execu tionContext); 45 var currentExecutionContext = UI.context.flavor(SDK.ExecutionContext);
46 if (!currentExecutionContext) 46 if (!currentExecutionContext)
47 return; 47 return;
48 48
49 this._compiling = true; 49 this._compiling = true;
50 var code = this._sourceFrame.textEditor.text(); 50 var code = this._sourceFrame.textEditor.text();
51 runtimeModel.compileScript(code, '', false, currentExecutionContext.id, comp ileCallback.bind(this, target)); 51 runtimeModel.compileScript(code, '', false, currentExecutionContext.id, comp ileCallback.bind(this, target));
52 52
53 /** 53 /**
54 * @param {!WebInspector.Target} target 54 * @param {!SDK.Target} target
55 * @param {!Protocol.Runtime.ScriptId=} scriptId 55 * @param {!Protocol.Runtime.ScriptId=} scriptId
56 * @param {?Protocol.Runtime.ExceptionDetails=} exceptionDetails 56 * @param {?Protocol.Runtime.ExceptionDetails=} exceptionDetails
57 * @this {WebInspector.JavaScriptCompiler} 57 * @this {Sources.JavaScriptCompiler}
58 */ 58 */
59 function compileCallback(target, scriptId, exceptionDetails) { 59 function compileCallback(target, scriptId, exceptionDetails) {
60 this._compiling = false; 60 this._compiling = false;
61 if (this._recompileScheduled) { 61 if (this._recompileScheduled) {
62 delete this._recompileScheduled; 62 delete this._recompileScheduled;
63 this.scheduleCompile(); 63 this.scheduleCompile();
64 return; 64 return;
65 } 65 }
66 if (!exceptionDetails) 66 if (!exceptionDetails)
67 return; 67 return;
68 var text = WebInspector.ConsoleMessage.simpleTextFromException(exceptionDe tails); 68 var text = SDK.ConsoleMessage.simpleTextFromException(exceptionDetails);
69 this._sourceFrame.uiSourceCode().addLineMessage( 69 this._sourceFrame.uiSourceCode().addLineMessage(
70 WebInspector.UISourceCode.Message.Level.Error, text, exceptionDetails. lineNumber, 70 Workspace.UISourceCode.Message.Level.Error, text, exceptionDetails.lin eNumber,
71 exceptionDetails.columnNumber); 71 exceptionDetails.columnNumber);
72 this._compilationFinishedForTest(); 72 this._compilationFinishedForTest();
73 } 73 }
74 } 74 }
75 75
76 _compilationFinishedForTest() { 76 _compilationFinishedForTest() {
77 } 77 }
78 }; 78 };
79 79
80 WebInspector.JavaScriptCompiler.CompileDelay = 1000; 80 Sources.JavaScriptCompiler.CompileDelay = 1000;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698