Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dartium enabled Console (dev tools) #1406

Closed
DartBot opened this issue Jan 31, 2012 · 17 comments
Closed

Dartium enabled Console (dev tools) #1406

DartBot opened this issue Jan 31, 2012 · 17 comments
Assignees
Labels
type-enhancement A request for a change that isn't a bug
Milestone

Comments

@DartBot
Copy link

DartBot commented Jan 31, 2012

This issue was originally filed by krhebba...@gmail.com


It would be nice if we can run dart code directly from Dartium console.

@whesse
Copy link
Member

whesse commented Jan 31, 2012

Since each Dart script runs in a new isolate, with its own global state, it is not really helpful (or meaningful) to run Dart code one statement at a time, from the console. There is, in principle, no way of adding code to a running isolate. Unless we introduced new semantics for compiling new lines and adding them to a script, all of the effects of a single Dart statement would be confined to the new isolate running that line (and the DOM state).. The least intrusive way to add code to an existing isolate in the debugger would, I suppose, be to add a new top-level function, and then call that function. But I doubt this is that useful.

I think most of the use case for running Dart code at the console is med by tools that would allow objects to be inspected and changed, and would let you step through an existing script, and let you get to the code you want to test using breakpoints and watchpoints.

It isn't clear if you are referring to dev tools running the javascript code, that was produced by the dart comipler, or to dev tools running on dartium, so I'm not sure what aread this belongs in.


Removed Type-Defect label.
Added Type-Enhancement, Area-UI, Triaged labels.

@vsmenon
Copy link
Member

vsmenon commented Apr 12, 2012

Removed Area-UI label.
Added Area-Dartium label.

@DartBot
Copy link
Author

DartBot commented Jun 1, 2012

This comment was originally written by antonm@google.com


Added this to the Later milestone.

@DartBot
Copy link
Author

DartBot commented Jun 23, 2012

This comment was originally written by @bgourlie


wheese's response makes it apparent why this is not trivially implemented, but I think it's vastly important to accommodate this considering it is something that can be done in javascript, and it would be taking a step back if I were unable to do so.

For my particular use case, I just want to call methods on globally defined objects within a particular isolate -- I don't want to redefine them or add new code. Of course, I don't know if this makes the solution any more trivial, or is universally useful enough to implement in this limited fashion.

@DartBot
Copy link
Author

DartBot commented Aug 31, 2012

This comment was originally written by antonm@google.com


Set owner to podivilov@google.com.

@DartBot
Copy link
Author

DartBot commented Nov 18, 2012

This comment was originally written by dbro...@gmail.com


I am new to Dart so let me know if I am mistaken here, but it seems to me that simply being able to interact with the DOM through the console would be immensely helpful. I don’t need to be able to interact with running code (other than indirectly).

@DartBot
Copy link
Author

DartBot commented Nov 18, 2012

This comment was originally written by dbrockman...@gmail.com


Hmm, perhaps I misunderstood what was said earlier about isolates. I guess you are saying that I wouldn’t for example be able to define a variable on one line in the console, and then use that variable on the next line?

@vsmenon
Copy link
Member

vsmenon commented Aug 15, 2013

Set owner to @jacob314.

@vsmenon
Copy link
Member

vsmenon commented Sep 13, 2013

This should be implemented with Jacob's CL:

https://codereview.chromium.org/23710032/


Removed this from the Later milestone.
Added this to the M7 milestone.

@vsmenon
Copy link
Member

vsmenon commented Oct 2, 2013

Removed this from the M7 milestone.
Added this to the M8 milestone.

@dgrove
Copy link
Contributor

dgrove commented Oct 8, 2013

This is fixed as of Dart release 0.8.1.2 .


Added Fixed label.

@DartBot
Copy link
Author

DartBot commented Nov 21, 2013

This comment was originally written by bangkok...@gmail.com


as of download from 2013/11/19, do not think it works

String s1 = 'hello'
SyntaxError: Unexpected identifier

if included file has nothing but
   String s1 = 'hello';

s1
ReferenceError: s1 is not defined

@jacob314
Copy link
Member

Make sure the context of the console is set to Dart not the JS context.
On the status bar of the console you will see a drop down where the top entry is <javascript page context>
Click on that list and select one of the Dart libraries loaded into your program.
As another tip, when defining new variables in the console, only use "var" instead of specifying types. Specifying a type for a console variable is unsupported and will generate an error.

You can verify that Dart code is running by writing the following two separate lines in the console:
var s1 = 'hello ${"dart"}'
s1

You should see
"hello dart"
in the console if you are running dart
but "hello ${"dart"}"
if you are running JavaScript.

@DartBot
Copy link
Author

DartBot commented Nov 22, 2013

This comment was originally written by bangko...@gmail.com


very good info. this would be most useful in
https://www.dartlang.org/tools/dartium/

@DartBot
Copy link
Author

DartBot commented Nov 22, 2013

This comment was originally written by bangko...@gmail.com


two issues:

  1. when the page is refreshed the context is always reset to <javascript
    page context>.
  2. if actually using dart sources, .../$script is a far more useful default

@DartBot
Copy link
Author

DartBot commented Nov 22, 2013

This comment was originally written by bangko...@gmail.com


cannot declare a class from the console

==> "'': Error: line 2 pos 1: unexpected token 'class'

is there some special syntax here, like having to declare variables with
var &tc?

@jacob314
Copy link
Member

Sorry defining classes from the console is not supported at this time.
You can however define arbitrarily complex closures from the console.
e.g.

var bar = (foo) { print("Hello $foo"); return ()=> 42;}

@DartBot DartBot added this to the M8 milestone Nov 22, 2013
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants