Skip to content
This repository has been archived by the owner on Oct 22, 2020. It is now read-only.

Commit

Permalink
ddt - Try 'main' as a function name if we aren't given one (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-knight committed Mar 13, 2019
1 parent 899b2c9 commit 730039e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
* Dart DevTools Changes

## 0.0.5
* Add a heuristic to guess 'main' as the function name when we aren't getting
one from the scope information. This can happen in tests.

## 0.0.4
* Handle variables in nested closures properly.
* Minor bug fixes, including going back to allowing getters in the expression,
Expand Down
9 changes: 6 additions & 3 deletions front_end/sdk/DartEval.js
Expand Up @@ -205,13 +205,16 @@ Dart._Evaluation = class {
// we need this is for main, in which case we can find the library name
// from the module Id, but it's not clear, so let's be sure.
const moduleId = await this._currentModuleId();
const functionName = functionNames[0];
const expression = 'var module = dart._loadedModules.get("' + moduleId + '"); '
// In tests, we get no function name for main, so try that if we have a null.
// TODO(alanknight): A better way of identifying the library in tests.
const functionName = functionNames[0] || 'main';
const expression = 'let dart = dart_library.debuggerLibraries()[0]["dart"];'
+ 'module = dart._loadedModules.get("' + moduleId + '"); '
+ 'Object.keys(module).find(x => module[x]["' + functionName + '"])';
const candidates = await this.callFrame.evaluate(
{
expression: expression,
silent: true,
silent: false,
returnByValue: true,
generatePreview: false
},
Expand Down

0 comments on commit 730039e

Please sign in to comment.