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

Update github's syntax highlighting for NNBD #38569

Closed
stereotype441 opened this issue Sep 25, 2019 · 4 comments
Closed

Update github's syntax highlighting for NNBD #38569

stereotype441 opened this issue Sep 25, 2019 · 4 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. closed-duplicate Closed in favor of an existing report NNBD Issues related to NNBD Release
Milestone

Comments

@stereotype441
Copy link
Member

(Not really an analyzer issue, but I'm filing it as an analyzer issue on @aadilmaan's recommendation because we don't really have another good category for it)

We need to update the Atom grammar for Dart (https://github.com/dart-atom/dart/tree/master/grammars) to support NNBD, so that Dart code that shows up in github (and in gists) is properly syntax highlighted.

@stereotype441 stereotype441 added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. NNBD Issues related to NNBD Release labels Sep 25, 2019
@stereotype441 stereotype441 added this to the Future milestone Sep 25, 2019
@stereotype441
Copy link
Member Author

@devoncarew FYI

@lrhn
Copy link
Member

lrhn commented Sep 26, 2019

What syntax highlighting will we need for NNBD? As I read it, it's regexp-based substring matching for highlighting, not actual parsing, so there are limits to its precision.

There are two new built-in identifiers: required (perhaps only highlight when it occurs after a ( or ,) and late. Those should be recognized.

The remaining grammar changes are the type modifier (type?), expression non-null cast (expr!), and some more null-aware operations (?.., ?.[...], ?.(...)).

The current state is:

// @dart = 2.7
main({required int! z}) {
  late final x = [print("run me now")];
  int? x = 42;
  for (var y in [x!]) {
    print(x?.toString());
    print([x]?.[0])
    print([x]?..[0] = 1);
  }
}

The build-in identifiers obviously need to be recognized.
The ? after the type is already highlighted.
The ! and ? are colored red, but not combined with the following ., so maybe we can even improve that (should ?. have a different color than .?).

@srawlins
Copy link
Member

Mind if we close this in favor of #41882?

@devoncarew
Copy link
Member

Note that the system-of-record for the syntax highlighting for github has moved to https://github.com/dart-lang/dart-syntax-highlight/blob/master/grammars/dart.json.

@lrhn lrhn closed this as completed May 13, 2020
@lrhn lrhn added the closed-duplicate Closed in favor of an existing report label May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. closed-duplicate Closed in favor of an existing report NNBD Issues related to NNBD Release
Projects
None yet
Development

No branches or pull requests

4 participants