Closed eernstg closed 3 years ago
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?
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.
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).
Here's the abstract
sample:
And the external
sample:
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!
@eernstg is this safe to close, or do you want to wait on a null safety release with these features included?
Depends on whether there is more dartpad specific work to do: The underlying tools (analyzer and compiler) have their own implementation tasks (https://github.com/dart-lang/sdk/issues/41940, https://github.com/dart-lang/sdk/issues/42718), and they are closed, so it seems likely that the only remaining work for dartpad is syntax highlighting.
Assigning this to @RedBrogdon to bundle testing this with the next null safety update.
Any updates on this?
Any update? Thx
@RedBrogdon What is the current status?
From https://github.com/dart-lang/dart-pad/issues/1614#issuecomment-675835503, it looks like this is already working?
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.
@RedBrogdon Great, thanks! The external behavior is WAI I believe.
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
andabstract
as keywords, so this might be working already.