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

Side by Side Diff: Source/devtools/front_end/sdk/RuntimeModel.js

Issue 300393002: Merge DevTools Refactor CL to Blink36 (Closed) Base URL: svn://svn.chromium.org/blink/branches/dart/1985
Patch Set: PTAL Created 6 years, 6 months 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 | Annotate | Revision Log
OLDNEW
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 this.dispatchEventToListeners(WebInspector.RuntimeModel.Events.Execu tionContextDestroyed, contexts[i]); 90 this.dispatchEventToListeners(WebInspector.RuntimeModel.Events.Execu tionContextDestroyed, contexts[i]);
91 }, 91 },
92 92
93 /** 93 /**
94 * @param {!RuntimeAgent.RemoteObject} payload 94 * @param {!RuntimeAgent.RemoteObject} payload
95 * @return {!WebInspector.RemoteObject} 95 * @return {!WebInspector.RemoteObject}
96 */ 96 */
97 createRemoteObject: function(payload) 97 createRemoteObject: function(payload)
98 { 98 {
99 console.assert(typeof payload === "object", "Remote object payload shoul d only be an object"); 99 console.assert(typeof payload === "object", "Remote object payload shoul d only be an object");
100 return new WebInspector.RemoteObjectImpl(this.target(), payload.objectId , payload.type, payload.subtype, payload.value, payload.description, payload.pre view); 100 return new WebInspector.RemoteObjectImpl(this.target(), payload.objectId , payload.type, payload.subtype, payload.value, payload.description, payload.pre view, payload.language);
101 }, 101 },
102 102
103 /** 103 /**
104 * @param {!RuntimeAgent.RemoteObject} payload 104 * @param {!RuntimeAgent.RemoteObject} payload
105 * @param {!WebInspector.ScopeRef} scopeRef 105 * @param {!WebInspector.ScopeRef} scopeRef
106 * @return {!WebInspector.RemoteObject} 106 * @return {!WebInspector.RemoteObject}
107 */ 107 */
108 createScopeRemoteObject: function(payload, scopeRef) 108 createScopeRemoteObject: function(payload, scopeRef)
109 { 109 {
110 return new WebInspector.ScopeRemoteObject(this.target(), payload.objectI d, scopeRef, payload.type, payload.subtype, payload.value, payload.description, payload.preview); 110 return new WebInspector.ScopeRemoteObject(this.target(), payload.objectI d, scopeRef, payload.type, payload.subtype, payload.value, payload.description, payload.preview, payload.language);
111 }, 111 },
112 112
113 /** 113 /**
114 * @param {number|string|boolean} value 114 * @param {number|string|boolean} value
115 * @return {!WebInspector.RemoteObject} 115 * @return {!WebInspector.RemoteObject}
116 */ 116 */
117 createRemoteObjectFromPrimitiveValue: function(value) 117 createRemoteObjectFromPrimitiveValue: function(value)
118 { 118 {
119 return new WebInspector.RemoteObjectImpl(this.target(), undefined, typeo f value, undefined, value); 119 return new WebInspector.RemoteObjectImpl(this.target(), undefined, typeo f value, undefined, value);
120 }, 120 },
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 233
234 if (returnByValue) 234 if (returnByValue)
235 callback(null, !!wasThrown, wasThrown ? null : result); 235 callback(null, !!wasThrown, wasThrown ? null : result);
236 else 236 else
237 callback(this.target().runtimeModel.createRemoteObject(result), !!wasThrown); 237 callback(this.target().runtimeModel.createRemoteObject(result), !!wasThrown);
238 } 238 }
239 this.target().runtimeAgent().evaluate(expression, objectGroup, includeCo mmandLineAPI, doNotPauseOnExceptionsAndMuteConsole, this.id, returnByValue, gene ratePreview, evalCallback.bind(this)); 239 this.target().runtimeAgent().evaluate(expression, objectGroup, includeCo mmandLineAPI, doNotPauseOnExceptionsAndMuteConsole, this.id, returnByValue, gene ratePreview, evalCallback.bind(this));
240 }, 240 },
241 241
242 /** 242 /**
243 * @param {string} expression
244 * @param {function(?Protocol.Error, !Array.<!string>)} callback
245 */
246 getCompletions: function(expression, callback)
247 {
248 var selectedCallFrame = WebInspector.debuggerModel.selectedCallFrame();
249
250 // Dart/Modules specific tweak: don't use the call frame if we are
251 // we have explicitly selected an execution context for the console
252 // that is part of a different library than the current call frame.
253
254 if (selectedCallFrame &&
255 (!selectedCallFrame.script || this.libraryId == selectedCallFrame.sc ript.libraryId)) {
256 selectedCallFrame.getCompletions(expression, callback);
257 return;
258 }
259
260 this.target().runtimeAgent().getCompletions(expression, this.id, callbac k);
261 },
262
263 /**
243 * @param {string} expressionString 264 * @param {string} expressionString
244 * @param {string} prefix 265 * @param {string} prefix
245 * @param {boolean} force 266 * @param {boolean} force
246 * @param {function(!Array.<string>, number=)} completionsReadyCallback 267 * @param {function(!Array.<string>, number=)} completionsReadyCallback
247 */ 268 */
248 completionsForExpression: function(expressionString, prefix, force, completi onsReadyCallback) 269 completionsForExpression: function(expressionString, prefix, force, completi onsReadyCallback)
249 { 270 {
250 var lastIndex = expressionString.length - 1; 271 var lastIndex = expressionString.length - 1;
251 272
252 var dotNotation = (expressionString[lastIndex] === "."); 273 var dotNotation = (expressionString[lastIndex] === ".");
253 var bracketNotation = (expressionString[lastIndex] === "["); 274 var bracketNotation = (expressionString[lastIndex] === "[");
254 275
255 if (dotNotation || bracketNotation) 276 if (dotNotation || bracketNotation)
256 expressionString = expressionString.substr(0, lastIndex); 277 expressionString = expressionString.substr(0, lastIndex);
257 278
258 if (expressionString && parseInt(expressionString, 10) == expressionStri ng) { 279 if (expressionString && parseInt(expressionString, 10) == expressionStri ng) {
259 // User is entering float value, do not suggest anything. 280 // User is entering float value, do not suggest anything.
260 completionsReadyCallback([]); 281 completionsReadyCallback([]);
261 return; 282 return;
262 } 283 }
263 284
264 if (!prefix && !expressionString && !force) { 285 if (!prefix && !expressionString && !force) {
265 completionsReadyCallback([]); 286 completionsReadyCallback([]);
266 return; 287 return;
267 } 288 }
268 289
269 if (!expressionString && this._debuggerModel.selectedCallFrame()) 290 this.getCompletions(expressionString, receivedPropertyNames.bind(this));
270 this._debuggerModel.getSelectedCallFrameVariables(receivedPropertyNa mes.bind(this));
271 else
272 this.evaluate(expressionString, "completion", true, true, false, fal se, evaluated.bind(this));
273 291
274 /** 292 /**
293 * @param {?Protocol.Error} error
294 * @param {!Array.<string>} propertyNamesArray
275 * @this {WebInspector.ExecutionContext} 295 * @this {WebInspector.ExecutionContext}
276 */ 296 */
277 function evaluated(result, wasThrown) 297 function receivedPropertyNames(error, propertyNamesArray)
278 { 298 {
279 if (!result || wasThrown) { 299 this.target().runtimeAgent().releaseObjectGroup("completion");
300 if (error) {
280 completionsReadyCallback([]); 301 completionsReadyCallback([]);
281 return; 302 return;
282 } 303 }
304 var propertyNames = {};
305 for (var i = 0; i < propertyNamesArray.length; ++i)
306 propertyNames[propertyNamesArray[i]] = true;
283 307
284 /**
285 * @param {string} primitiveType
286 * @suppressReceiverCheck
287 * @this {WebInspector.ExecutionContext}
288 */
289 function getCompletions(primitiveType)
290 {
291 var object;
292 if (primitiveType === "string")
293 object = new String("");
294 else if (primitiveType === "number")
295 object = new Number(0);
296 else if (primitiveType === "boolean")
297 object = new Boolean(false);
298 else
299 object = this;
300
301 var resultSet = {};
302 for (var o = object; o; o = o.__proto__) {
303 try {
304 var names = Object.getOwnPropertyNames(o);
305 for (var i = 0; i < names.length; ++i)
306 resultSet[names[i]] = true;
307 } catch (e) {
308 }
309 }
310 return resultSet;
311 }
312
313 if (result.type === "object" || result.type === "function")
314 result.callFunctionJSON(getCompletions, undefined, receivedPrope rtyNames.bind(this));
315 else if (result.type === "string" || result.type === "number" || res ult.type === "boolean")
316 this.evaluate("(" + getCompletions + ")(\"" + result.type + "\") ", "completion", false, true, true, false, receivedPropertyNamesFromEval.bind(th is));
317 }
318
319 /**
320 * @param {?WebInspector.RemoteObject} notRelevant
321 * @param {boolean} wasThrown
322 * @param {?RuntimeAgent.RemoteObject=} result
323 * @this {WebInspector.ExecutionContext}
324 */
325 function receivedPropertyNamesFromEval(notRelevant, wasThrown, result)
326 {
327 if (result && !wasThrown)
328 receivedPropertyNames.call(this, result.value);
329 else
330 completionsReadyCallback([]);
331 }
332
333 /**
334 * @this {WebInspector.ExecutionContext}
335 */
336 function receivedPropertyNames(propertyNames)
337 {
338 this.target().runtimeAgent().releaseObjectGroup("completion");
339 if (!propertyNames) {
340 completionsReadyCallback([]);
341 return;
342 }
343 var includeCommandLineAPI = (!dotNotation && !bracketNotation); 308 var includeCommandLineAPI = (!dotNotation && !bracketNotation);
344 if (includeCommandLineAPI) { 309 if (includeCommandLineAPI) {
345 const commandLineAPI = ["dir", "dirxml", "keys", "values", "prof ile", "profileEnd", "monitorEvents", "unmonitorEvents", "inspect", "copy", "clea r", 310 const commandLineAPI = ["dir", "dirxml", "keys", "values", "prof ile", "profileEnd", "monitorEvents", "unmonitorEvents", "inspect", "copy", "clea r",
346 "getEventListeners", "debug", "undebug", "monitor", "unmonit or", "table", "$", "$$", "$x"]; 311 "getEventListeners", "debug", "undebug", "monitor", "unmonit or", "table", "$", "$$", "$x"];
347 for (var i = 0; i < commandLineAPI.length; ++i) 312 for (var i = 0; i < commandLineAPI.length; ++i)
348 propertyNames[commandLineAPI[i]] = true; 313 propertyNames[commandLineAPI[i]] = true;
349 } 314 }
350 this._reportCompletions(completionsReadyCallback, dotNotation, brack etNotation, expressionString, prefix, Object.keys(propertyNames)); 315 this._reportCompletions(completionsReadyCallback, dotNotation, brack etNotation, expressionString, prefix, Object.keys(propertyNames));
351 } 316 }
352 }, 317 },
(...skipping 15 matching lines...) Expand all
368 } 333 }
369 334
370 var results = []; 335 var results = [];
371 336
372 if (!expressionString) { 337 if (!expressionString) {
373 var selectedCallFrame = WebInspector.debuggerModel.selectedCallFrame (); 338 var selectedCallFrame = WebInspector.debuggerModel.selectedCallFrame ();
374 var dartContext = false; 339 var dartContext = false;
375 if (selectedCallFrame) { 340 if (selectedCallFrame) {
376 dartContext = selectedCallFrame.script && selectedCallFrame.scri pt.language == "Dart"; 341 dartContext = selectedCallFrame.script && selectedCallFrame.scri pt.language == "Dart";
377 } else { 342 } else {
378 dartContext = WebInspector.runtimeModel.currentExecutionContext( ).language == "Dart"; 343 dartContext = this.language == "Dart";
379 } 344 }
380 345
381 if (dartContext) { 346 if (dartContext) {
382 // Note we omit get, set, final, class, import, and library as t hose 347 // Note we omit get, set, final, class, import, and library as t hose
383 // keywords cannot yet be used from the REPL. 348 // keywords cannot yet be used from the REPL.
384 const dartKeywords = ["as", "case", "catch", "const", "continue" , "default", "dynamic", "else", "finally", "for", "if", "in", 349 const dartKeywords = ["as", "case", "catch", "const", "continue" , "default", "dynamic", "else", "finally", "for", "if", "in",
385 "is", "new", "return", "switch", "this", " throw", "try", "var", "void", "while"]; 350 "is", "new", "return", "switch", "this", " throw", "try", "var", "void", "while"];
386 properties = properties.concat(dartKeywords); 351 properties = properties.concat(dartKeywords);
387 } else { 352 } else {
388 const keywords = ["break", "case", "catch", "continue", "default ", "delete", "do", "else", "finally", "for", "function", "if", "in", 353 const keywords = ["break", "case", "catch", "continue", "default ", "delete", "do", "else", "finally", "for", "function", "if", "in",
(...skipping 27 matching lines...) Expand all
416 completionsReadyCallback(results); 381 completionsReadyCallback(results);
417 }, 382 },
418 383
419 __proto__: WebInspector.TargetAware.prototype 384 __proto__: WebInspector.TargetAware.prototype
420 } 385 }
421 386
422 /** 387 /**
423 * @type {!WebInspector.RuntimeModel} 388 * @type {!WebInspector.RuntimeModel}
424 */ 389 */
425 WebInspector.runtimeModel; 390 WebInspector.runtimeModel;
OLDNEW
« no previous file with comments | « Source/devtools/front_end/sdk/RemoteObject.js ('k') | Source/devtools/front_end/sources/SourcesPanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698