1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-01 10:52:24 +01:00

Better syntax highlighting for Dart (#1959)

Remove unmaintained Dart syntax submodule. Add elMuso/Dartlight as submodule. Update Dart syntax highlighting. Add changes to changelog.
This commit is contained in:
Ersikan
2021-12-06 08:40:43 +01:00
committed by GitHub
parent 8072d5a3e3
commit 29711c178a
7 changed files with 154 additions and 301 deletions

View File

@@ -0,0 +1,5 @@
return Object(
 Object(
 // Not highlighted as a comment
 )
)

View File

@@ -1,45 +1,45 @@
/* array sorting alogorithm */
int partition(List list, int low, int high) {
 if (list == null || list.length == 0) return 0;
 int pivot = list[high];
 int i = low - 1;
int partition(List list, int low, int high) {
 if (list == null || list.length == 0) return 0;
 int pivot = list[high];
 int i = low - 1;
 void swap(List list, int i, int j) {
 int temp = list[i];
 void swap(List list, int i, int j) {
 int temp = list[i];
 list[i] = list[j];
 list[j] = temp;
 }
 for (int j = low; j < high; j++) {
 for (int j = low; j < high; j++) {
 if (list[j] <= pivot) {
 i++;
 swap(list, i, j);
 swap(list, i, j);
 }
 swap(list, i + 1, high);
 swap(list, i + 1, high);
 return i + 1;
 }
}
void quickSort(List list, int low, int high) {
void quickSort(List list, int low, int high) {
 if (low < high) {
 int pi = partition(list, low, high);
 quickSort(list, low, pi - 1);
 quickSort(list, pi + 1, high);
 int pi = partition(list, low, high);
 quickSort(list, low, pi - 1);
 quickSort(list, pi + 1, high);
 }
}
void merge(List list, int leftIndex, int middleIndex, int rightIndex) {
 int leftSize = middleIndex - leftIndex + 1;
 int rightSize = rightIndex - middleIndex;
void merge(List list, int leftIndex, int middleIndex, int rightIndex) {
 int leftSize = middleIndex - leftIndex + 1;
 int rightSize = rightIndex - middleIndex;
 List leftList = new List(leftSize);
 List rightList = new List(rightSize);
 List leftList = new List(leftSize);
 List rightList = new List(rightSize);
 for (int i = 0; i < leftSize; i++) leftList[i] = list[leftIndex + i];
 for (int j = 0; j < rightSize; j++) rightList[j] = list[middleIndex + j + 1];
 for (int i = 0; i < leftSize; i++) leftList[i] = list[leftIndex + i];
 for (int j = 0; j < rightSize; j++) rightList[j] = list[middleIndex + j + 1];
 int i = 0, j = 0;
 int k = leftIndex;
 int i = 0, j = 0;
 int k = leftIndex;
 while (i < leftSize && j < rightSize) {
 if (leftList[i] <= rightList[j]) {
@@ -65,14 +65,14 @@
 }
}
void mergeSort(List list, int leftIndex, int rightIndex) {
void mergeSort(List list, int leftIndex, int rightIndex) {
 if (leftIndex < rightIndex) {
 int middleIndex = (rightIndex + leftIndex) ~/ 2;
 int middleIndex = (rightIndex + leftIndex) ~/ 2;
 mergeSort(list, leftIndex, middleIndex);
 mergeSort(list, middleIndex + 1, rightIndex);
 mergeSort(list, leftIndex, middleIndex);
 mergeSort(list, middleIndex + 1, rightIndex);
 merge(list, leftIndex, middleIndex, rightIndex);
 merge(list, leftIndex, middleIndex, rightIndex);
 }
}
@@ -80,54 +80,54 @@
var name = 'Voyager I';
var year = 1977;
var antennaDiameter = 3.7;
var flybyObjects = ['Jupiter', 'Saturn', 'Uranus', 'Neptune'];
var flybyObjects = ['Jupiter', 'Saturn', 'Uranus', 'Neptune'];
var image = {
 'tags': ['saturn'],
 'url': '//path/to/saturn.jpg'
 'tags': ['saturn'],
 'url': '//path/to/saturn.jpg'
};
/*classes */
class Spacecraft {
 String name;
 DateTime launchDate;
 Spacecraft(this.name, this.launchDate) {}
class Spacecraft {
 String name;
 DateTime launchDate;
 Spacecraft(this.name, this.launchDate) {}
 // Named constructor that forwards to the default one.
 Spacecraft.unlaunched(String name) : this(name, null);
 // Named constructor that forwards to the default one.
 Spacecraft.unlaunched(String name) : this(name, null);
 int get launchYear => launchDate?.year;
 int get launchYear => launchDate?.year;
 void describe() {
 print('Spacecraft: $name');
 void describe() {
 print('Spacecraft: $name');
 if (launchDate != null) {
 int years = DateTime.now().difference(launchDate).inDays ~/ 365;
 print('Launched: $launchYear ($years years ago)');
 int years = DateTime.now().difference(launchDate).inDays ~/ 365;
 print('Launched: $launchYear ($years years ago)');
 } else {
 print('Unlaunched');
 print('Unlaunched');
 }
 }
}
/* Mixins */
class PilotedCraft extends Spacecraft with Piloted {
 // ···
class PilotedCraft extends Spacecraft with Piloted {
 // ···
}
/* Interfaces and abstract classes */
class MockSpaceship implements Spacecraft {
 // ···
class MockSpaceship implements Spacecraft {
 // ···
}
/* async */
Future<void> printWithDelay(String message) {
 return Future.delayed(const Duration(seconds: 2)).then((_) {
 print(message);
Future<void> printWithDelay(String message) {
 return Future.delayed(const Duration(seconds: 2)).then((_) {
 print(message);
 });
}
Stream<String> report(Spacecraft craft, Iterable<String> objects) async* {
Stream<String> report(Spacecraft craft, Iterable<String> objects) async* {
 for (var object in objects) {
 await Future.delayed(const Duration(seconds: 2));
 yield '${craft.name} flies by $object';
 await Future.delayed(const Duration(seconds: 2));
 yield '${craft.name} flies by $object';
 }
}

View File

@@ -0,0 +1,5 @@
return Object(
Object(
// Not highlighted as a comment
)
)