1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-19 21:10:15 +02:00

fix: add Dart required keyword

This commit is contained in:
mhmdanas 2022-03-04 12:08:40 +03:00 committed by Alec Thomas
parent 647b7a6352
commit 7bfe2f41c6
3 changed files with 16 additions and 8 deletions

View File

@ -97,7 +97,7 @@
<rule pattern="\b(assert|break|case|catch|continue|default|do|else|finally|for|if|in|is|new|return|super|switch|this|throw|try|while)\b">
<token type="Keyword"/>
</rule>
<rule pattern="\b(abstract|async|await|const|extends|factory|final|get|implements|native|operator|set|static|sync|typedef|var|with|yield)\b">
<rule pattern="\b(abstract|async|await|const|extends|factory|final|get|implements|native|operator|required|set|static|sync|typedef|var|with|yield)\b">
<token type="KeywordDeclaration"/>
</rule>
<rule pattern="\b(bool|double|dynamic|int|num|Object|String|void)\b">

View File

@ -39,12 +39,12 @@ Stream<double> computePi({int batch: 100000}) async* {
Iterable<Point> generateRandom([int seed]) sync* {
final random = new Random(seed);
while (true) {
yield new Point(random.nextDouble(), random.nextDouble());
yield new Point(x: random.nextDouble(), y: random.nextDouble());
}
}
class Point {
final double x, y;
const Point(this.x, this.y);
const Point({required this.x, required this.y});
bool get isInsideUnitCircle => x * x + y * y <= 1;
}

View File

@ -270,11 +270,15 @@
{"type":"Text","value":" "},
{"type":"Name","value":"Point"},
{"type":"Punctuation","value":"("},
{"type":"NameLabel","value":"x:"},
{"type":"Text","value":" "},
{"type":"Name","value":"random"},
{"type":"Punctuation","value":"."},
{"type":"Name","value":"nextDouble"},
{"type":"Punctuation","value":"(),"},
{"type":"Text","value":" "},
{"type":"NameLabel","value":"y:"},
{"type":"Text","value":" "},
{"type":"Name","value":"random"},
{"type":"Punctuation","value":"."},
{"type":"Name","value":"nextDouble"},
@ -303,16 +307,20 @@
{"type":"KeywordDeclaration","value":"const"},
{"type":"Text","value":" "},
{"type":"Name","value":"Point"},
{"type":"Punctuation","value":"("},
{"type":"Punctuation","value":"({"},
{"type":"KeywordDeclaration","value":"required"},
{"type":"Text","value":" "},
{"type":"Keyword","value":"this"},
{"type":"Punctuation","value":"."},
{"type":"Name","value":"x"},
{"type":"Punctuation","value":","},
{"type":"Text","value":" "},
{"type":"KeywordDeclaration","value":"required"},
{"type":"Text","value":" "},
{"type":"Keyword","value":"this"},
{"type":"Punctuation","value":"."},
{"type":"Name","value":"y"},
{"type":"Punctuation","value":");"},
{"type":"Punctuation","value":"});"},
{"type":"Text","value":"\n "},
{"type":"KeywordType","value":"bool"},
{"type":"Text","value":" "},