| Index: Source/devtools/front_end/sdk/RuntimeModel.js
|
| diff --git a/Source/devtools/front_end/sdk/RuntimeModel.js b/Source/devtools/front_end/sdk/RuntimeModel.js
|
| index 9c79876c2b9425ed2abb6da4866d175a61b2772c..7b40f65fb5743763230cd752d3a595e7c4c94165 100644
|
| --- a/Source/devtools/front_end/sdk/RuntimeModel.js
|
| +++ b/Source/devtools/front_end/sdk/RuntimeModel.js
|
| @@ -97,7 +97,7 @@ WebInspector.RuntimeModel.prototype = {
|
| createRemoteObject: function(payload)
|
| {
|
| console.assert(typeof payload === "object", "Remote object payload should only be an object");
|
| - return new WebInspector.RemoteObjectImpl(this.target(), payload.objectId, payload.type, payload.subtype, payload.value, payload.description, payload.preview);
|
| + return new WebInspector.RemoteObjectImpl(this.target(), payload.objectId, payload.type, payload.subtype, payload.value, payload.description, payload.preview, payload.language);
|
| },
|
|
|
| /**
|
| @@ -107,7 +107,7 @@ WebInspector.RuntimeModel.prototype = {
|
| */
|
| createScopeRemoteObject: function(payload, scopeRef)
|
| {
|
| - return new WebInspector.ScopeRemoteObject(this.target(), payload.objectId, scopeRef, payload.type, payload.subtype, payload.value, payload.description, payload.preview);
|
| + return new WebInspector.ScopeRemoteObject(this.target(), payload.objectId, scopeRef, payload.type, payload.subtype, payload.value, payload.description, payload.preview, payload.language);
|
| },
|
|
|
| /**
|
| @@ -240,6 +240,27 @@ WebInspector.ExecutionContext.prototype = {
|
| },
|
|
|
| /**
|
| + * @param {string} expression
|
| + * @param {function(?Protocol.Error, !Array.<!string>)} callback
|
| + */
|
| + getCompletions: function(expression, callback)
|
| + {
|
| + var selectedCallFrame = WebInspector.debuggerModel.selectedCallFrame();
|
| +
|
| + // Dart/Modules specific tweak: don't use the call frame if we are
|
| + // we have explicitly selected an execution context for the console
|
| + // that is part of a different library than the current call frame.
|
| +
|
| + if (selectedCallFrame &&
|
| + (!selectedCallFrame.script || this.libraryId == selectedCallFrame.script.libraryId)) {
|
| + selectedCallFrame.getCompletions(expression, callback);
|
| + return;
|
| + }
|
| +
|
| + this.target().runtimeAgent().getCompletions(expression, this.id, callback);
|
| + },
|
| +
|
| + /**
|
| * @param {string} expressionString
|
| * @param {string} prefix
|
| * @param {boolean} force
|
| @@ -266,80 +287,24 @@ WebInspector.ExecutionContext.prototype = {
|
| return;
|
| }
|
|
|
| - if (!expressionString && this._debuggerModel.selectedCallFrame())
|
| - this._debuggerModel.getSelectedCallFrameVariables(receivedPropertyNames.bind(this));
|
| - else
|
| - this.evaluate(expressionString, "completion", true, true, false, false, evaluated.bind(this));
|
| -
|
| - /**
|
| - * @this {WebInspector.ExecutionContext}
|
| - */
|
| - function evaluated(result, wasThrown)
|
| - {
|
| - if (!result || wasThrown) {
|
| - completionsReadyCallback([]);
|
| - return;
|
| - }
|
| -
|
| - /**
|
| - * @param {string} primitiveType
|
| - * @suppressReceiverCheck
|
| - * @this {WebInspector.ExecutionContext}
|
| - */
|
| - function getCompletions(primitiveType)
|
| - {
|
| - var object;
|
| - if (primitiveType === "string")
|
| - object = new String("");
|
| - else if (primitiveType === "number")
|
| - object = new Number(0);
|
| - else if (primitiveType === "boolean")
|
| - object = new Boolean(false);
|
| - else
|
| - object = this;
|
| -
|
| - var resultSet = {};
|
| - for (var o = object; o; o = o.__proto__) {
|
| - try {
|
| - var names = Object.getOwnPropertyNames(o);
|
| - for (var i = 0; i < names.length; ++i)
|
| - resultSet[names[i]] = true;
|
| - } catch (e) {
|
| - }
|
| - }
|
| - return resultSet;
|
| - }
|
| -
|
| - if (result.type === "object" || result.type === "function")
|
| - result.callFunctionJSON(getCompletions, undefined, receivedPropertyNames.bind(this));
|
| - else if (result.type === "string" || result.type === "number" || result.type === "boolean")
|
| - this.evaluate("(" + getCompletions + ")(\"" + result.type + "\")", "completion", false, true, true, false, receivedPropertyNamesFromEval.bind(this));
|
| - }
|
| -
|
| - /**
|
| - * @param {?WebInspector.RemoteObject} notRelevant
|
| - * @param {boolean} wasThrown
|
| - * @param {?RuntimeAgent.RemoteObject=} result
|
| - * @this {WebInspector.ExecutionContext}
|
| - */
|
| - function receivedPropertyNamesFromEval(notRelevant, wasThrown, result)
|
| - {
|
| - if (result && !wasThrown)
|
| - receivedPropertyNames.call(this, result.value);
|
| - else
|
| - completionsReadyCallback([]);
|
| - }
|
| + this.getCompletions(expressionString, receivedPropertyNames.bind(this));
|
|
|
| /**
|
| + * @param {?Protocol.Error} error
|
| + * @param {!Array.<string>} propertyNamesArray
|
| * @this {WebInspector.ExecutionContext}
|
| */
|
| - function receivedPropertyNames(propertyNames)
|
| + function receivedPropertyNames(error, propertyNamesArray)
|
| {
|
| this.target().runtimeAgent().releaseObjectGroup("completion");
|
| - if (!propertyNames) {
|
| + if (error) {
|
| completionsReadyCallback([]);
|
| return;
|
| }
|
| + var propertyNames = {};
|
| + for (var i = 0; i < propertyNamesArray.length; ++i)
|
| + propertyNames[propertyNamesArray[i]] = true;
|
| +
|
| var includeCommandLineAPI = (!dotNotation && !bracketNotation);
|
| if (includeCommandLineAPI) {
|
| const commandLineAPI = ["dir", "dirxml", "keys", "values", "profile", "profileEnd", "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear",
|
| @@ -375,7 +340,7 @@ WebInspector.ExecutionContext.prototype = {
|
| if (selectedCallFrame) {
|
| dartContext = selectedCallFrame.script && selectedCallFrame.script.language == "Dart";
|
| } else {
|
| - dartContext = WebInspector.runtimeModel.currentExecutionContext().language == "Dart";
|
| + dartContext = this.language == "Dart";
|
| }
|
|
|
| if (dartContext) {
|
|
|