Skip to content

dartpad: Implement external and abstract variables #1614

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

Closed
eernstg opened this issue Aug 18, 2020 · 14 comments
Closed

dartpad: Implement external and abstract variables #1614

eernstg opened this issue Aug 18, 2020 · 14 comments
Assignees
Labels
P2 A bug or feature request we're likely to work on

Comments

@eernstg
Copy link
Member

eernstg commented Aug 18, 2020

Cf. the implementation plan, the addition of external and abstract variables to Dart may require some updates.

https://github.com/codemirror/CodeMirror/blob/master/mode/dart/dart.js already recognizes external and abstract as keywords, so this might be working already.

@devoncarew devoncarew changed the title dartpad, cider: Implement external and abstract variables dartpad: Implement external and abstract variables Aug 18, 2020
@devoncarew
Copy link
Member

Note: I believe this is mostly updating the codemirror syntax highlighting. @eernstg, is there some good sample code to test against? The files in https://github.com/dart-lang/sdk/tree/master/tests/language/external_abstract_fields?

@domesticmouse
Copy link
Member

domesticmouse commented Aug 19, 2020

I tried abstract_fields_test.dart and external_fields_test.dart in dartpad.dev and they both appear to be rendering in CodeMirror as I'd expect.

If we need to make a change to CodeMirror's Dart parsing, we need to be aware that CodeMirror has a monthly release cadence (on the 20th, give or take), and I try to keep codemirror.dart updated on a timely basis.

@devoncarew
Copy link
Member

I believe that if you see abstract and external highlighting as you'd expect in those files, then we're good w/o any codemirror updates (the VS Code and github grammer - https://github.com/dart-lang/dart-syntax-highlight/tree/master/grammars - did not need updating).

@domesticmouse
Copy link
Member

Here's the abstract sample:

Screen Shot 2020-08-19 at 1 47 52 pm

And the external sample:

Screen Shot 2020-08-19 at 1 48 35 pm

@eernstg
Copy link
Member Author

eernstg commented Aug 19, 2020

is there some good sample code to test against? The files in
https://github.com/dart-lang/sdk/tree/master/tests/language/external_abstract_fields?

Exactly. Looks like it does work already!

@domesticmouse
Copy link
Member

@eernstg is this safe to close, or do you want to wait on a null safety release with these features included?

@eernstg
Copy link
Member Author

eernstg commented Aug 19, 2020

Depends on whether there is more dartpad specific work to do: The underlying tools (analyzer and compiler) have their own implementation tasks (dart-lang/sdk#41940, dart-lang/sdk#42718), and they are closed, so it seems likely that the only remaining work for dartpad is syntax highlighting.

@domesticmouse
Copy link
Member

Assigning this to @RedBrogdon to bundle testing this with the next null safety update.

@RedBrogdon RedBrogdon added the P2 A bug or feature request we're likely to work on label Aug 25, 2020
@leafpetersen
Copy link
Member

Any updates on this?

@franklinyow
Copy link
Contributor

Any update?
Thx

@franklinyow
Copy link
Contributor

@RedBrogdon What is the current status?

@mit-mit
Copy link
Member

mit-mit commented Nov 3, 2020

From #1614 (comment), it looks like this is already working?

@RedBrogdon
Copy link
Contributor

AFAICT, abstract variables are working just fine:

https://nullsafety.dartpad.dev/e5ace6215b5779c9b41ae5a136a9c1fd

External variables are highlighted correctly and cause no analyzer errors, but will not compile. This code, for example:

external int something;
external String toString();

void main() {
}

Produces this error when compiled:

Error compiling to JavaScript:
main.dart:1:14:
Error: Only external js-interop functions are supported.
external int something;
             ^
main.dart:2:17:
Error: Only external js-interop functions are supported.
external String toString();
                ^
main.dart:1:14:
Error: Only external js-interop functions are supported.
external int something;
             ^
Error: Compilation failed.

@leafpetersen
Copy link
Member

@RedBrogdon Great, thanks! The external behavior is WAI I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

7 participants