OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 | 337 |
338 delete this.commandSincePreviousMessage; | 338 delete this.commandSincePreviousMessage; |
339 delete this.previousMessage; | 339 delete this.previousMessage; |
340 }, | 340 }, |
341 | 341 |
342 completions: function(wordRange, bestMatchOnly, completionsReadyCallback) | 342 completions: function(wordRange, bestMatchOnly, completionsReadyCallback) |
343 { | 343 { |
344 // Pass less stop characters to rangeOfWord so the range will be a more
complete expression. | 344 // Pass less stop characters to rangeOfWord so the range will be a more
complete expression. |
345 var expressionRange = wordRange.startContainer.rangeOfWord(wordRange.sta
rtOffset, ExpressionStopCharacters, this.promptElement, "backward"); | 345 var expressionRange = wordRange.startContainer.rangeOfWord(wordRange.sta
rtOffset, ExpressionStopCharacters, this.promptElement, "backward"); |
346 var expressionString = expressionRange.toString(); | 346 var expressionString = expressionRange.toString(); |
| 347 var prefix = wordRange.toString(); |
| 348 this._completions(expressionString, prefix, bestMatchOnly, completionsRe
adyCallback); |
| 349 }, |
| 350 |
| 351 _completions: function(expressionString, prefix, bestMatchOnly, completionsR
eadyCallback) |
| 352 { |
347 var lastIndex = expressionString.length - 1; | 353 var lastIndex = expressionString.length - 1; |
348 | 354 |
349 var dotNotation = (expressionString[lastIndex] === "."); | 355 var dotNotation = (expressionString[lastIndex] === "."); |
350 var bracketNotation = (expressionString[lastIndex] === "["); | 356 var bracketNotation = (expressionString[lastIndex] === "["); |
351 | 357 |
352 if (dotNotation || bracketNotation) | 358 if (dotNotation || bracketNotation) |
353 expressionString = expressionString.substr(0, lastIndex); | 359 expressionString = expressionString.substr(0, lastIndex); |
354 | 360 |
355 var prefix = wordRange.toString(); | |
356 if (!expressionString && !prefix) | 361 if (!expressionString && !prefix) |
357 return; | 362 return; |
358 | 363 |
359 this.evalInInspectedWindow(expressionString, "completion", true, evaluat
ed.bind(this)); | 364 if (!expressionString && WebInspector.panels.scripts.paused) |
| 365 WebInspector.panels.scripts.getSelectedCallFrameVariables(reportComp
letions.bind(this)); |
| 366 else |
| 367 this.evalInInspectedWindow(expressionString, "completion", true, eva
luated.bind(this)); |
360 | 368 |
361 function evaluated(result) | 369 function evaluated(result) |
362 { | 370 { |
363 if (!result) | 371 if (!result) |
364 return; | 372 return; |
365 result.getAllProperties(evaluatedProperties.bind(this)); | 373 result.getAllProperties(evaluatedProperties.bind(this)); |
366 } | 374 } |
367 | 375 |
368 function evaluatedProperties(properties) | 376 function evaluatedProperties(properties) |
369 { | 377 { |
370 RuntimeAgent.releaseObjectGroup("completion"); | 378 RuntimeAgent.releaseObjectGroup("completion"); |
371 var propertyNames = []; | 379 var propertyNames = {}; |
372 for (var i = 0; properties && i < properties.length; ++i) | 380 for (var i = 0; properties && i < properties.length; ++i) |
373 propertyNames.push(properties[i].name); | 381 propertyNames[properties[i].name] = true; |
| 382 reportCompletions.call(this, propertyNames); |
| 383 } |
374 | 384 |
| 385 function reportCompletions(propertyNames) |
| 386 { |
375 var includeCommandLineAPI = (!dotNotation && !bracketNotation); | 387 var includeCommandLineAPI = (!dotNotation && !bracketNotation); |
376 if (includeCommandLineAPI) | 388 if (includeCommandLineAPI) { |
377 propertyNames.splice(0, 0, "dir", "dirxml", "keys", "values", "p
rofile", "profileEnd", "monitorEvents", "unmonitorEvents", "inspect", "copy", "c
lear"); | 389 const commandLineAPI = ["dir", "dirxml", "keys", "values", "prof
ile", "profileEnd", "monitorEvents", "unmonitorEvents", "inspect", "copy", "clea
r"]; |
378 this._reportCompletions(bestMatchOnly, completionsReadyCallback, dot
Notation, bracketNotation, prefix, propertyNames); | 390 for (var i = 0; i < commandLineAPI.length; ++i) |
| 391 propertyNames[commandLineAPI[i]] = true; |
| 392 } |
| 393 |
| 394 this._reportCompletions(bestMatchOnly, completionsReadyCallback, dot
Notation, bracketNotation, prefix, Object.keys(propertyNames)); |
379 } | 395 } |
380 }, | 396 }, |
381 | 397 |
382 _reportCompletions: function(bestMatchOnly, completionsReadyCallback, dotNot
ation, bracketNotation, prefix, properties) { | 398 _reportCompletions: function(bestMatchOnly, completionsReadyCallback, dotNot
ation, bracketNotation, prefix, properties) { |
383 if (bracketNotation) { | 399 if (bracketNotation) { |
384 if (prefix.length && prefix[0] === "'") | 400 if (prefix.length && prefix[0] === "'") |
385 var quoteUsed = "'"; | 401 var quoteUsed = "'"; |
386 else | 402 else |
387 var quoteUsed = "\""; | 403 var quoteUsed = "\""; |
388 } | 404 } |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 else | 1175 else |
1160 groupElement.addStyleClass("collapsed"); | 1176 groupElement.addStyleClass("collapsed"); |
1161 groupTitleElement.scrollIntoViewIfNeeded(true); | 1177 groupTitleElement.scrollIntoViewIfNeeded(true); |
1162 } | 1178 } |
1163 | 1179 |
1164 event.stopPropagation(); | 1180 event.stopPropagation(); |
1165 event.preventDefault(); | 1181 event.preventDefault(); |
1166 } | 1182 } |
1167 } | 1183 } |
1168 | 1184 |
OLD | NEW |