Skip to content

Commit

Permalink
Version 2.13.0-168.0.dev
Browse files Browse the repository at this point in the history
Merge commit '1453eebebcc8b881ddb18d25573ad245b4c47c94' into 'dev'
  • Loading branch information
Dart CI committed Mar 25, 2021
2 parents 78ea9e6 + 1453eeb commit d31a668
Show file tree
Hide file tree
Showing 16 changed files with 2,961 additions and 2,857 deletions.
Expand Up @@ -297,10 +297,12 @@ class AssistProcessor extends BaseProcessor {
/// being offered as a fix.
static Map<ProducerGenerator, Set<String>> createLintRuleMap() {
var map = <ProducerGenerator, Set<String>>{};
for (var entry in FixProcessor.lintProducerMap.entries) {
for (var entry in FixProcessor.lintProducerMap2.entries) {
var lintName = entry.key;
for (var generator in entry.value) {
map.putIfAbsent(generator, () => <String>{}).add(lintName);
for (var fix in entry.value) {
for (var generator in fix.generators) {
map.putIfAbsent(generator, () => <String>{}).add(lintName);
}
}
}
return map;
Expand Down
Expand Up @@ -28,6 +28,7 @@ import 'package:analyzer/src/util/file_paths.dart' as file_paths;
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
import 'package:analyzer_plugin/utilities/change_builder/conflicting_edit_exception.dart';
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:collection/collection.dart';

/// A fix producer that produces changes that will fix multiple diagnostics in
/// one or more files.
Expand Down Expand Up @@ -233,7 +234,7 @@ class BulkFixProcessor {
if (fix.canBeBulkApplied) {
final generators = fix.generators;
if (generators != null) {
yield* generators.map((g) => g().fixKind).where((k) => k != null);
yield* generators.map((g) => g().fixKind).whereNotNull();
}
}
}
Expand All @@ -245,7 +246,7 @@ class BulkFixProcessor {
if (fix.canBeBulkApplied) {
final generators = fix.generators;
if (generators != null) {
yield* generators.map((g) => g().fixKind).where((k) => k != null);
yield* generators.map((g) => g().fixKind).whereNotNull();
}
}
}
Expand Down
Expand Up @@ -1080,6 +1080,7 @@ class FixProcessor extends BaseProcessor {
/// A map from the names of lint rules to a list of generators used to create
/// the correction producers used to build fixes for those diagnostics. The
/// generators used for non-lint diagnostics are in the [nonLintProducerMap].
@Deprecated('To be replaced w/ lintProducerMap2')
static const Map<String, List<ProducerGenerator>> lintProducerMap = {
LintNames.always_declare_return_types: [
AddReturnType.newInstance,
Expand Down Expand Up @@ -1447,7 +1448,7 @@ class FixProcessor extends BaseProcessor {

/// A map from error codes to a list of generators used to create the
/// correction producers used to build fixes for those diagnostics. The
/// generators used for lint rules are in the [lintProducerMap].
/// generators used for lint rules are in the [lintProducerMap2].
static const Map<ErrorCode, List<ProducerGenerator>> nonLintProducerMap = {
CompileTimeErrorCode.ASSIGNMENT_TO_FINAL: [
MakeFieldNotFinal.newInstance,
Expand Down Expand Up @@ -2006,9 +2007,9 @@ class FixProcessor extends BaseProcessor {

var errorCode = error.errorCode;
if (errorCode is LintCode) {
var generators = lintProducerMap[errorCode.name];
if (generators != null) {
for (var generator in generators) {
var fixes = lintProducerMap2[errorCode.name] ?? [];
for (var fix in fixes) {
for (var generator in fix.generators) {
await compute(generator());
}
}
Expand Down
Expand Up @@ -121,6 +121,7 @@ class VerificationTests {
verify_fixInFileFixesHaveBulkFixTests();
verify_fixInFileFixKindsHaveMultiFixes();
verify_fixInFileFixesHaveUniqueBulkFixes();
verify_lintProducerMap2_coverage();
}

static void verify_fixInFileFixesHaveBulkFixTests() {
Expand All @@ -129,7 +130,7 @@ class VerificationTests {
var errorCode = fixEntry.key;
for (var fixInfo in fixEntry.value) {
if (fixInfo.canBeAppliedToFile) {
test(errorCode, () {
test('$errorCode |', () {
expect(fixInfo.canBeBulkApplied, isTrue);
});
}
Expand Down Expand Up @@ -187,6 +188,19 @@ class VerificationTests {
}
});
}

static void verify_lintProducerMap2_coverage() {
// todo (pq): remove when lintProducerMap is deleted.
group('VerificationTests | lintProducerMap2_coverage |', () {
// ignore: deprecated_member_use_from_same_package
for (var entry in FixProcessor.lintProducerMap.entries) {
var errorCode = entry.key;
test('$errorCode |', () {
expect(FixProcessor.lintProducerMap2, contains(errorCode));
});
}
});
}
}

/// todo (pq): add negative tests
11 changes: 11 additions & 0 deletions pkg/expect/lib/expect.dart
Expand Up @@ -451,6 +451,17 @@ class Expect {
}
}

/// Checks that [haystack] contains one of the given substrings [needles].
///
/// For example, this succeeds:
///
/// Expect.containsOneOf(["a", "h"], "abcdefg");
static void containsOneOf(Iterable<String> needles, String haystack) {
if (!needles.any((s) => haystack.contains(s))) {
_fail("None of the strings '$needles' found within '$haystack'");
}
}

/// Checks that [actual] contains a given list of [substrings] in order.
///
/// For example, this succeeds:
Expand Down

0 comments on commit d31a668

Please sign in to comment.