use raw strings to avoid escaping (#50322)
This commit is contained in:
committed by
GitHub
parent
8735ab1e35
commit
b953c3e5a8
@@ -49,7 +49,7 @@ void main() {
|
||||
'test/analyze-test-input/root/packages/foo/deprecation.dart:41: Deprecation notice does not match required pattern.\n'
|
||||
'test/analyze-test-input/root/packages/foo/deprecation.dart:48: End of deprecation notice does not match required pattern.\n'
|
||||
'test/analyze-test-input/root/packages/foo/deprecation.dart:51: Unexpected deprecation notice indent.\n'
|
||||
.replaceAll('/', Platform.isWindows ? '\\' : '/')
|
||||
.replaceAll('/', Platform.isWindows ? r'\' : '/')
|
||||
)
|
||||
+
|
||||
'See: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes\n'
|
||||
@@ -65,7 +65,7 @@ void main() {
|
||||
(
|
||||
'The following 1 file does not have the right license header:\n'
|
||||
'test/analyze-test-input/root/packages/foo/foo.dart\n'
|
||||
.replaceAll('/', Platform.isWindows ? '\\' : '/')
|
||||
.replaceAll('/', Platform.isWindows ? r'\' : '/')
|
||||
)
|
||||
+
|
||||
'The expected license header is:\n'
|
||||
@@ -85,7 +85,7 @@ void main() {
|
||||
(
|
||||
'test/analyze-test-input/root/packages/foo/spaces.txt:5: trailing U+0020 space character\n'
|
||||
'test/analyze-test-input/root/packages/foo/spaces.txt:9: trailing blank line\n'
|
||||
.replaceAll('/', Platform.isWindows ? '\\' : '/')
|
||||
.replaceAll('/', Platform.isWindows ? r'\' : '/')
|
||||
)
|
||||
+
|
||||
'━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'
|
||||
|
||||
@@ -73,7 +73,7 @@ Future<void> main() async {
|
||||
|
||||
section('Override settings.gradle V2');
|
||||
|
||||
const String deprecatedFileContentV2 = '''
|
||||
const String deprecatedFileContentV2 = r'''
|
||||
include ':app'
|
||||
|
||||
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
|
||||
@@ -86,8 +86,8 @@ if (pluginsFile.exists()) {
|
||||
|
||||
plugins.each { name, path ->
|
||||
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
|
||||
include ":\$name"
|
||||
project(":\$name").projectDir = pluginDirectory
|
||||
include ":$name"
|
||||
project(":$name").projectDir = pluginDirectory
|
||||
}
|
||||
''';
|
||||
settingsGradle.writeAsStringSync(deprecatedFileContentV2, flush: true);
|
||||
|
||||
@@ -588,7 +588,7 @@ String extractCloudAuthTokenArg(List<String> rawArgs) {
|
||||
|
||||
final RegExp _obsRegExp =
|
||||
RegExp('An Observatory debugger .* is available at: ');
|
||||
final RegExp _obsPortRegExp = RegExp('(\\S+:(\\d+)/\\S*)\$');
|
||||
final RegExp _obsPortRegExp = RegExp(r'(\S+:(\d+)/\S*)$');
|
||||
final RegExp _obsUriRegExp = RegExp(r'((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)');
|
||||
|
||||
/// Tries to extract a port from the string.
|
||||
|
||||
@@ -777,7 +777,7 @@ class ListStatistics {
|
||||
|
||||
class _UnzipListEntry {
|
||||
factory _UnzipListEntry.fromLine(String line) {
|
||||
final List<String> data = line.trim().split(RegExp('\\s+'));
|
||||
final List<String> data = line.trim().split(RegExp(r'\s+'));
|
||||
assert(data.length == 8);
|
||||
return _UnzipListEntry._(
|
||||
uncompressedSize: int.parse(data[0]),
|
||||
|
||||
@@ -64,7 +64,7 @@ main() {
|
||||
test('generates application snippets', () async {
|
||||
final File inputFile = File(path.join(tmpDir.absolute.path, 'snippet_in.txt'))
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
..writeAsStringSync(r'''
|
||||
A description of the snippet.
|
||||
|
||||
On several lines.
|
||||
@@ -75,7 +75,7 @@ const String name = 'snippet';
|
||||
|
||||
```dart
|
||||
void main() {
|
||||
print('The actual \$name.');
|
||||
print('The actual $name.');
|
||||
}
|
||||
```
|
||||
''');
|
||||
@@ -93,7 +93,7 @@ void main() {
|
||||
);
|
||||
expect(html, contains('<div>HTML Bits</div>'));
|
||||
expect(html, contains('<div>More HTML Bits</div>'));
|
||||
expect(html, contains('print('The actual \$name.');'));
|
||||
expect(html, contains(r'print('The actual $name.');'));
|
||||
expect(html, contains('A description of the snippet.\n'));
|
||||
expect(
|
||||
html,
|
||||
@@ -112,14 +112,14 @@ void main() {
|
||||
test('generates sample snippets', () async {
|
||||
final File inputFile = File(path.join(tmpDir.absolute.path, 'snippet_in.txt'))
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
..writeAsStringSync(r'''
|
||||
A description of the snippet.
|
||||
|
||||
On several lines.
|
||||
|
||||
```code
|
||||
void main() {
|
||||
print('The actual \$name.');
|
||||
print('The actual $name.');
|
||||
}
|
||||
```
|
||||
''');
|
||||
@@ -131,7 +131,7 @@ void main() {
|
||||
);
|
||||
expect(html, contains('<div>HTML Bits</div>'));
|
||||
expect(html, contains('<div>More HTML Bits</div>'));
|
||||
expect(html, contains(' print('The actual \$name.');'));
|
||||
expect(html, contains(r' print('The actual $name.');'));
|
||||
expect(html, contains('<div class="snippet-description">{@end-inject-html}A description of the snippet.\n\n'
|
||||
'On several lines.{@inject-html}</div>\n'));
|
||||
expect(html, contains('main() {'));
|
||||
@@ -140,14 +140,14 @@ void main() {
|
||||
test('generates dartpad snippets', () async {
|
||||
final File inputFile = File(path.join(tmpDir.absolute.path, 'snippet_in.txt'))
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
..writeAsStringSync(r'''
|
||||
A description of the snippet.
|
||||
|
||||
On several lines.
|
||||
|
||||
```code
|
||||
void main() {
|
||||
print('The actual \$name.');
|
||||
print('The actual $name.');
|
||||
}
|
||||
```
|
||||
''');
|
||||
@@ -167,14 +167,14 @@ void main() {
|
||||
test('generates snippet application metadata', () async {
|
||||
final File inputFile = File(path.join(tmpDir.absolute.path, 'snippet_in.txt'))
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
..writeAsStringSync(r'''
|
||||
A description of the snippet.
|
||||
|
||||
On several lines.
|
||||
|
||||
```code
|
||||
void main() {
|
||||
print('The actual \$name.');
|
||||
print('The actual $name.');
|
||||
}
|
||||
```
|
||||
''');
|
||||
|
||||
@@ -433,9 +433,9 @@ void main() {
|
||||
}
|
||||
|
||||
if (Platform.isWindows) {
|
||||
expect(generator.arbPathStrings.first, 'lib\\l10n\\app_en_US.arb');
|
||||
expect(generator.arbPathStrings.elementAt(1), 'lib\\l10n\\app_es.arb');
|
||||
expect(generator.arbPathStrings.elementAt(2), 'lib\\l10n\\app_zh.arb');
|
||||
expect(generator.arbPathStrings.first, r'lib\l10n\app_en_US.arb');
|
||||
expect(generator.arbPathStrings.elementAt(1), r'lib\l10n\app_es.arb');
|
||||
expect(generator.arbPathStrings.elementAt(2), r'lib\l10n\app_zh.arb');
|
||||
} else {
|
||||
expect(generator.arbPathStrings.first, 'lib/l10n/app_en_US.arb');
|
||||
expect(generator.arbPathStrings.elementAt(1), 'lib/l10n/app_es.arb');
|
||||
@@ -610,7 +610,8 @@ void main() {
|
||||
expect(generator.classMethods, isNotEmpty);
|
||||
expect(
|
||||
generator.classMethods.first,
|
||||
''' String get title {
|
||||
'''
|
||||
String get title {
|
||||
return Intl.message(
|
||||
'Title',
|
||||
locale: _localeName,
|
||||
@@ -655,9 +656,10 @@ void main() {
|
||||
expect(generator.classMethods, isNotEmpty);
|
||||
expect(
|
||||
generator.classMethods.first,
|
||||
''' String itemNumber(Object value) {
|
||||
r'''
|
||||
String itemNumber(Object value) {
|
||||
return Intl.message(
|
||||
'Item \${value}',
|
||||
'Item ${value}',
|
||||
locale: _localeName,
|
||||
name: 'itemNumber',
|
||||
desc: 'Item placement in list.',
|
||||
@@ -704,13 +706,14 @@ void main() {
|
||||
expect(generator.classMethods, isNotEmpty);
|
||||
expect(
|
||||
generator.classMethods.first,
|
||||
''' String springBegins(DateTime springStartDate) {
|
||||
r'''
|
||||
String springBegins(DateTime springStartDate) {
|
||||
final DateFormat springStartDateDateFormat = DateFormat.yMMMMEEEEd(_localeName);
|
||||
final String springStartDateString = springStartDateDateFormat.format(springStartDate);
|
||||
|
||||
String springBegins(Object springStartDate) {
|
||||
return Intl.message(
|
||||
'Spring begins on \${springStartDate}',
|
||||
'Spring begins on ${springStartDate}',
|
||||
locale: _localeName,
|
||||
name: 'springBegins',
|
||||
desc: 'The first day of spring',
|
||||
@@ -831,13 +834,14 @@ void main() {
|
||||
expect(generator.classMethods, isNotEmpty);
|
||||
expect(
|
||||
generator.classMethods.first,
|
||||
''' String springGreetings(DateTime springStartDate, Object helloWorld) {
|
||||
r'''
|
||||
String springGreetings(DateTime springStartDate, Object helloWorld) {
|
||||
final DateFormat springStartDateDateFormat = DateFormat.yMMMMEEEEd(_localeName);
|
||||
final String springStartDateString = springStartDateDateFormat.format(springStartDate);
|
||||
|
||||
String springGreetings(Object springStartDate, Object helloWorld) {
|
||||
return Intl.message(
|
||||
"Since it's \${springStartDate}, it's finally spring! \${helloWorld}!",
|
||||
"Since it's ${springStartDate}, it's finally spring! ${helloWorld}!",
|
||||
locale: _localeName,
|
||||
name: 'springGreetings',
|
||||
desc: "A realization that it's finally the spring season, followed by a greeting.",
|
||||
@@ -888,7 +892,8 @@ void main() {
|
||||
expect(generator.classMethods, isNotEmpty);
|
||||
expect(
|
||||
generator.classMethods.first,
|
||||
''' String springRange(DateTime springStartDate, DateTime springEndDate) {
|
||||
'''
|
||||
String springRange(DateTime springStartDate, DateTime springEndDate) {
|
||||
final DateFormat springStartDateDateFormat = DateFormat.yMMMMEEEEd(_localeName);
|
||||
final String springStartDateString = springStartDateDateFormat.format(springStartDate);
|
||||
|
||||
@@ -944,7 +949,8 @@ void main() {
|
||||
expect(generator.classMethods, isNotEmpty);
|
||||
expect(
|
||||
generator.classMethods.first,
|
||||
''' String helloWorlds(int count, DateTime currentDate) {
|
||||
r'''
|
||||
String helloWorlds(int count, DateTime currentDate) {
|
||||
final DateFormat currentDateDateFormat = DateFormat.yMMMMEEEEd(_localeName);
|
||||
final String currentDateString = currentDateDateFormat.format(currentDate);
|
||||
|
||||
@@ -954,10 +960,10 @@ void main() {
|
||||
locale: _localeName,
|
||||
name: 'helloWorlds',
|
||||
args: <Object>[count, currentDate],
|
||||
one: 'Hello World, today is \${currentDateString}',
|
||||
two: 'Hello two worlds, today is \${currentDateString}',
|
||||
many: 'Hello all \${count} worlds, today is \${currentDateString}',
|
||||
other: 'Hello other \${count} worlds, today is \${currentDateString}'
|
||||
one: 'Hello World, today is ${currentDateString}',
|
||||
two: 'Hello two worlds, today is ${currentDateString}',
|
||||
many: 'Hello all ${count} worlds, today is ${currentDateString}',
|
||||
other: 'Hello other ${count} worlds, today is ${currentDateString}'
|
||||
);
|
||||
}
|
||||
return helloWorlds(count, currentDateString);
|
||||
@@ -1001,7 +1007,8 @@ void main() {
|
||||
expect(generator.classMethods, isNotEmpty);
|
||||
expect(
|
||||
generator.classMethods.first,
|
||||
''' String courseCompletion(double progress) {
|
||||
r'''
|
||||
String courseCompletion(double progress) {
|
||||
final NumberFormat progressNumberFormat = NumberFormat.compact(
|
||||
locale: _localeName,
|
||||
);
|
||||
@@ -1009,7 +1016,7 @@ void main() {
|
||||
|
||||
String courseCompletion(Object progress) {
|
||||
return Intl.message(
|
||||
'You have completed \${progress} of the course.',
|
||||
'You have completed ${progress} of the course.',
|
||||
locale: _localeName,
|
||||
name: 'courseCompletion',
|
||||
desc: 'The amount of progress the student has made in their class.',
|
||||
@@ -1070,7 +1077,8 @@ void main() {
|
||||
expect(generator.classMethods, isNotEmpty);
|
||||
expect(
|
||||
generator.classMethods.first,
|
||||
''' String courseCompletion(double progress) {
|
||||
'''
|
||||
String courseCompletion(double progress) {
|
||||
final NumberFormat progressNumberFormat = NumberFormat.$numberFormat(
|
||||
locale: _localeName,
|
||||
decimalDigits: 2,
|
||||
@@ -1133,7 +1141,8 @@ void main() {
|
||||
expect(generator.classMethods, isNotEmpty);
|
||||
expect(
|
||||
generator.classMethods.first,
|
||||
''' String courseCompletion(double progress) {
|
||||
'''
|
||||
String courseCompletion(double progress) {
|
||||
final NumberFormat progressNumberFormat = NumberFormat.$numberFormat(_localeName);
|
||||
final String progressString = progressNumberFormat.format(progress);
|
||||
|
||||
@@ -1223,7 +1232,8 @@ void main() {
|
||||
expect(generator.classMethods, isNotEmpty);
|
||||
expect(
|
||||
generator.classMethods.first,
|
||||
''' String helloWorlds(int count) {
|
||||
r'''
|
||||
String helloWorlds(int count) {
|
||||
return Intl.plural(
|
||||
count,
|
||||
locale: _localeName,
|
||||
@@ -1232,9 +1242,9 @@ void main() {
|
||||
zero: 'Hello',
|
||||
one: 'Hello World',
|
||||
two: 'Hello two worlds',
|
||||
few: 'Hello \${count} worlds',
|
||||
many: 'Hello all \${count} worlds',
|
||||
other: 'Hello other \${count} worlds'
|
||||
few: 'Hello ${count} worlds',
|
||||
many: 'Hello all ${count} worlds',
|
||||
other: 'Hello other ${count} worlds'
|
||||
);
|
||||
}
|
||||
'''
|
||||
@@ -1273,18 +1283,19 @@ void main() {
|
||||
expect(generator.classMethods, isNotEmpty);
|
||||
expect(
|
||||
generator.classMethods.first,
|
||||
''' String helloWorlds(int count, Object adjective) {
|
||||
r'''
|
||||
String helloWorlds(int count, Object adjective) {
|
||||
return Intl.plural(
|
||||
count,
|
||||
locale: _localeName,
|
||||
name: 'helloWorlds',
|
||||
args: <Object>[count, adjective],
|
||||
zero: 'Hello',
|
||||
one: 'Hello \${adjective} World',
|
||||
two: 'Hello two \${adjective} worlds',
|
||||
few: 'Hello \${count} \${adjective} worlds',
|
||||
many: 'Hello all \${count} \${adjective} worlds',
|
||||
other: 'Hello other \${count} \${adjective} worlds'
|
||||
one: 'Hello ${adjective} World',
|
||||
two: 'Hello two ${adjective} worlds',
|
||||
few: 'Hello ${count} ${adjective} worlds',
|
||||
many: 'Hello all ${count} ${adjective} worlds',
|
||||
other: 'Hello other ${count} ${adjective} worlds'
|
||||
);
|
||||
}
|
||||
'''
|
||||
@@ -1326,7 +1337,8 @@ void main() {
|
||||
expect(generator.classMethods, isNotEmpty);
|
||||
expect(
|
||||
generator.classMethods.first,
|
||||
''' String helloWorlds(int count, DateTime currentDate) {
|
||||
r'''
|
||||
String helloWorlds(int count, DateTime currentDate) {
|
||||
final DateFormat currentDateDateFormat = DateFormat.yMMMMEEEEd(_localeName);
|
||||
final String currentDateString = currentDateDateFormat.format(currentDate);
|
||||
|
||||
@@ -1336,10 +1348,10 @@ void main() {
|
||||
locale: _localeName,
|
||||
name: 'helloWorlds',
|
||||
args: <Object>[count, currentDate],
|
||||
one: 'Hello World, today is \${currentDateString}',
|
||||
two: 'Hello two worlds, today is \${currentDateString}',
|
||||
many: 'Hello all \${count} worlds, today is \${currentDateString}',
|
||||
other: 'Hello other \${count} worlds, today is \${currentDateString}'
|
||||
one: 'Hello World, today is ${currentDateString}',
|
||||
two: 'Hello two worlds, today is ${currentDateString}',
|
||||
many: 'Hello all ${count} worlds, today is ${currentDateString}',
|
||||
other: 'Hello other ${count} worlds, today is ${currentDateString}'
|
||||
);
|
||||
}
|
||||
return helloWorlds(count, currentDateString);
|
||||
@@ -1383,7 +1395,8 @@ void main() {
|
||||
expect(generator.classMethods, isNotEmpty);
|
||||
expect(
|
||||
generator.classMethods.first,
|
||||
''' String helloWorlds(int count, int population) {
|
||||
r'''
|
||||
String helloWorlds(int count, int population) {
|
||||
final NumberFormat populationNumberFormat = NumberFormat.compactLong(
|
||||
locale: _localeName,
|
||||
);
|
||||
@@ -1395,10 +1408,10 @@ void main() {
|
||||
locale: _localeName,
|
||||
name: 'helloWorlds',
|
||||
args: <Object>[count, population],
|
||||
one: 'Hello World of \${populationString} citizens',
|
||||
two: 'Hello two worlds with \${populationString} total citizens',
|
||||
many: 'Hello all \${count} worlds, with a total of \${populationString} citizens',
|
||||
other: 'Hello other \${count} worlds, with a total of \${populationString} citizens'
|
||||
one: 'Hello World of ${populationString} citizens',
|
||||
two: 'Hello two worlds with ${populationString} total citizens',
|
||||
many: 'Hello all ${count} worlds, with a total of ${populationString} citizens',
|
||||
other: 'Hello other ${count} worlds, with a total of ${populationString} citizens'
|
||||
);
|
||||
}
|
||||
return helloWorlds(count, populationString);
|
||||
|
||||
@@ -460,7 +460,7 @@ class _Transform {
|
||||
}
|
||||
|
||||
|
||||
const String _transformCommandAtom = ' *([^(]+)\\(([^)]*)\\)';
|
||||
const String _transformCommandAtom = r' *([^(]+)\(([^)]*)\)';
|
||||
final RegExp _transformValidator = RegExp('^($_transformCommandAtom)*\$');
|
||||
final RegExp _transformCommand = RegExp(_transformCommandAtom);
|
||||
|
||||
@@ -522,7 +522,7 @@ Matrix3 _matrix(double a, double b, double c, double d, double e, double f) {
|
||||
|
||||
// Matches a pixels expression e.g "14px".
|
||||
// First group is just the number.
|
||||
final RegExp _pixelsExp = RegExp('^([0-9]+)px\$');
|
||||
final RegExp _pixelsExp = RegExp(r'^([0-9]+)px$');
|
||||
|
||||
/// Parses a pixel expression, e.g "14px", and returns the number.
|
||||
/// Throws an [ArgumentError] if the given string doesn't match the pattern.
|
||||
|
||||
@@ -559,7 +559,7 @@ void main() {
|
||||
),
|
||||
]);
|
||||
|
||||
expect(animation.toDart('_AnimatedIconData', '_\$data1'),
|
||||
expect(animation.toDart('_AnimatedIconData', r'_$data1'),
|
||||
'const _AnimatedIconData _\$data1 = const _AnimatedIconData(\n'
|
||||
' const Size(48.0, 48.0),\n'
|
||||
' const <_PathFrames>[\n'
|
||||
|
||||
Reference in New Issue
Block a user